always show vert SB for multiline text ctrls without wxTE_RICH style

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8715 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-11-10 21:14:20 +00:00
parent c0bd235861
commit a00fd3e544
3 changed files with 48 additions and 28 deletions

View File

@@ -263,6 +263,7 @@ protected:
// more readable flag testing methods
bool IsSingleLine() const { return !(GetWindowStyle() & wxTE_MULTILINE); }
bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; }
bool WrapLines() const { return !(GetWindowStyle() & wxHSCROLL); }
// get the extent (width) of the text
wxCoord GetTextWidth(const wxString& text) const;

View File

@@ -80,6 +80,7 @@ enum
#endif // 0
TextTest_Password,
TextTest_HScroll,
TextTest_Textctrl,
TextTest_Quit
};
@@ -158,6 +159,7 @@ protected:
#endif
void OnUpdateUIPasswordCheckbox(wxUpdateUIEvent& event);
void OnUpdateUIHScrollCheckbox(wxUpdateUIEvent& event);
void OnUpdateUIResetButton(wxUpdateUIEvent& event);
@@ -169,17 +171,11 @@ protected:
// (re)create the textctrl
void CreateText();
// textctrl parameters
// ------------------
// single or multi line?
bool m_isSingleLine;
// readonly or can be modified?
bool m_isReadOnly;
// in password or normal mode?
bool m_isPassword;
// is the control currently single line?
bool IsSingleLine() const
{
return m_radioTextLines->GetSelection() == TextLines_Single;
}
// the controls
// ------------
@@ -190,8 +186,9 @@ protected:
// the radiobox to choose between single and multi line
wxRadioBox *m_radioTextLines;
// the checkboxes
// the checkboxes controlling text ctrl styles
wxCheckBox *m_chkPassword,
*m_chkHScroll,
*m_chkReadonly;
// the textctrl itself and the sizer it is in
@@ -270,6 +267,7 @@ BEGIN_EVENT_TABLE(TextTestFrame, wxFrame)
#endif // 0
EVT_UPDATE_UI(TextTest_Password, TextTestFrame::OnUpdateUIPasswordCheckbox)
EVT_UPDATE_UI(TextTest_HScroll, TextTestFrame::OnUpdateUIHScrollCheckbox)
EVT_UPDATE_UI(TextTest_Reset, TextTestFrame::OnUpdateUIResetButton)
@@ -310,6 +308,7 @@ TextTestFrame::TextTestFrame(const wxString& title)
m_radioTextLines = (wxRadioBox *)NULL;
m_chkPassword =
m_chkHScroll =
m_chkReadonly = (wxCheckBox *)NULL;
m_text =
@@ -353,6 +352,7 @@ TextTestFrame::TextTestFrame(const wxString& title)
1, wxRA_SPECIFY_COLS);
m_chkPassword = new wxCheckBox(m_panel, TextTest_Password, _T("&Password control"));
m_chkHScroll = new wxCheckBox(m_panel, TextTest_HScroll, _T("&Horz scrollbar"));
m_chkReadonly = new wxCheckBox(m_panel, -1, _T("&Read-only mode"));
sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
@@ -360,6 +360,7 @@ TextTestFrame::TextTestFrame(const wxString& title)
sizerLeft->Add(m_radioTextLines, 0, wxGROW | wxALL, 5);
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
sizerLeft->Add(m_chkPassword, 0, wxLEFT | wxRIGHT, 5);
sizerLeft->Add(m_chkHScroll, 0, wxLEFT | wxRIGHT, 5);
sizerLeft->Add(m_chkReadonly, 0, wxLEFT | wxRIGHT, 5);
wxButton *btn = new wxButton(m_panel, TextTest_Reset, _T("&Reset"));
@@ -552,6 +553,7 @@ void TextTestFrame::Reset()
{
m_radioTextLines->SetSelection(TextLines_Single);
m_chkPassword->SetValue(FALSE);
m_chkHScroll->SetValue(TRUE);
m_chkReadonly->SetValue(FALSE);
}
@@ -576,6 +578,8 @@ void TextTestFrame::CreateText()
flags |= wxTE_PASSWORD;
if ( m_chkReadonly->GetValue() )
flags |= wxTE_READONLY;
if ( m_chkHScroll->GetValue() )
flags |= wxHSCROLL;
wxString valueOld;
if ( m_text )
@@ -776,17 +780,23 @@ void TextTestFrame::OnUpdateUIClearButton(wxUpdateUIEvent& event)
event.Enable(!m_text->GetValue().empty());
}
void TextTestFrame::OnUpdateUIHScrollCheckbox(wxUpdateUIEvent& event)
{
event.Enable( !IsSingleLine() );
}
void TextTestFrame::OnUpdateUIPasswordCheckbox(wxUpdateUIEvent& event)
{
// can't put multiline control in password mode
event.Enable( m_radioTextLines->GetSelection() == TextLines_Single );
event.Enable( IsSingleLine() );
}
void TextTestFrame::OnUpdateUIResetButton(wxUpdateUIEvent& event)
{
event.Enable( (m_radioTextLines->GetSelection() != TextLines_Single) ||
m_chkReadonly->GetValue() ||
m_chkPassword->GetValue() );
m_chkPassword->GetValue() ||
!m_chkHScroll->GetValue() );
}
void TextTestFrame::OnText(wxCommandEvent& event)

View File

@@ -277,6 +277,20 @@ bool wxTextCtrl::Create(wxWindow *parent,
const wxValidator& validator,
const wxString &name)
{
if ( style & wxTE_MULTILINE )
{
// for compatibility with wxMSW we create the controls with vertical
// scrollbar always shown unless they have wxTE_RICH style (because
// Windows text controls always has vert scrollbar but richedit one
// doesn't)
if ( !(style & wxTE_RICH) )
{
style |= wxALWAYS_SHOW_SB;
}
// TODO: support wxTE_NO_VSCROLL (?)
}
if ( !wxControl::Create(parent, id, pos, size, style,
validator, name) )
{
@@ -294,16 +308,6 @@ bool wxTextCtrl::Create(wxWindow *parent,
// support it anyhow
wxASSERT_MSG( !(style & wxTE_PASSWORD),
_T("wxTE_PASSWORD can't be used with multiline ctrls") );
// create vertical scrollbar if necessary (on by default)
if ( !(style & wxTE_NO_VSCROLL) )
{
}
// and the horizontal one
if ( style & wxHSCROLL )
{
}
}
SetValue(value);
@@ -2627,8 +2631,8 @@ void wxTextCtrl::DoDraw(wxControlRenderer *renderer)
dc.SetTextForeground(GetForegroundColour());
// get the intersection of the update region with the text area: note that
// the update region is in window coord and text area is in the client
// ones, so it must be shifted before computing intesection
// the update region is in window coords and text area is in the client
// ones, so it must be shifted before computing intersection
wxRegion rgnUpdate = GetUpdateRegion();
wxRect rectTextArea = GetRealTextArea();
wxPoint pt = GetClientAreaOrigin();
@@ -2652,16 +2656,21 @@ void wxTextCtrl::DoDraw(wxControlRenderer *renderer)
for ( ; iter.HaveRects(); iter++ )
{
wxRect r = iter.GetRect();
// this is a workaround for wxGTK::wxRegion bug
#ifdef __WXGTK__
if ( !r.width || !r.height )
{
// this happens under wxGTK
// ignore invalid rect
continue;
}
#endif // __WXGTK__
DoDrawTextInRect(dc, r);
}
// show caret first time only
// show caret first time only: we must show it after drawing the text or
// the display can be corrupted when it's hidden
if ( !m_hasCaret && GetCaret() )
{
GetCaret()->Show();