added wxTE_BESTWRAP style (which is the default now); renamed wxTE_LINEWRAP to wxTE_CHARWRAP as this corresponds better to what it does; added tests for wxTE_*WRAP to the widgets sample (replaces patch 1156507)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2005-03-27 15:25:21 +00:00
parent 120678ee96
commit fb4888a650
5 changed files with 88 additions and 32 deletions

View File

@ -26,6 +26,7 @@ All (GUI):
- Restored ability to set a custom splitter sash size with SetSashSize.
- Fixed wxScrolledWindow sizer behaviour so that the virtual size
isn't used to set the window size.
- Added wxTE_BESTWRAP (based on patch by Mart Raudsepp)
Unix:

View File

@ -306,9 +306,10 @@ used, so that text won't be wrapped. No effect under wxGTK1.}
\twocolitem{\windowstyle{wxTE\_LEFT}}{The text in the control will be left-justified (default).}
\twocolitem{\windowstyle{wxTE\_CENTRE}}{The text in the control will be centered (currently wxMSW and wxGTK2 only).}
\twocolitem{\windowstyle{wxTE\_RIGHT}}{The text in the control will be right-justified (currently wxMSW and wxGTK2 only).}
\twocolitem{\windowstyle{wxTE\_DONTWRAP}}{Same as {\tt wxHSCROLL} style.}
\twocolitem{\windowstyle{wxTE\_LINEWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv and wxGTK2 only currently).}
\twocolitem{\windowstyle{wxTE\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries (this is the default if wxTE\_DONTWRAP is not given).}
\twocolitem{\windowstyle{wxTE\_DONTWRAP}}{Same as {\tt wxHSCROLL} style: don't wrap at all, show horizontal scrollbar instead.}
\twocolitem{\windowstyle{wxTE\_CHARWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv and wxGTK2 only).}
\twocolitem{\windowstyle{wxTE\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries (wxUniv and wxGTK2 only).}
\twocolitem{\windowstyle{wxTE\_BESTWRAP}}{Wrap the lines at word boundaries or at any other character if there are words longer than the window width (this is the default).}
\twocolitem{\windowstyle{wxTE\_CAPITALIZE}}{On PocketPC and Smartphone, causes the first letter to be capitalized.}
\end{twocollist}

View File

@ -79,9 +79,9 @@ const wxTextCoord wxInvalidTextCoord = -2;
// wxTextCtrl style flags
// ----------------------------------------------------------------------------
// the flag bits 0x0001, and 0x0004 are free but should be used only for the
// things which don't make sense for a text control used by wxTextEntryDialog
// because they would otherwise conflict with wxOK, wxCANCEL, wxCENTRE
// the flag bit 0x0001 s free but should be used only for the things which
// don't make sense for a text control used by wxTextEntryDialog because they
// would otherwise conflict with wxOK, wxCANCEL, wxCENTRE
#define wxTE_NO_VSCROLL 0x0002
#define wxTE_AUTO_SCROLL 0x0008
@ -113,11 +113,17 @@ const wxTextCoord wxInvalidTextCoord = -2;
// doesn't have focus - use this style to force it to always show it
#define wxTE_NOHIDESEL 0x2000
// use wxHSCROLL to not wrap text at all, wxTE_LINEWRAP to wrap it at any
// use wxHSCROLL to not wrap text at all, wxTE_CHARWRAP to wrap it at any
// position and wxTE_WORDWRAP to wrap at words boundary
//
// if no wrapping style is given at all, the control wraps at word boundary
#define wxTE_DONTWRAP wxHSCROLL
#define wxTE_LINEWRAP 0x4000
#define wxTE_WORDWRAP 0x0000 // it's just == !wxHSCROLL
#define wxTE_CHARWRAP 0x4000 // wrap at any position
#define wxTE_WORDWRAP 0x0001 // wrap only at words boundaries
#define wxTE_BESTWRAP 0x0000 // this is the default
// obsolete synonym
#define wxTE_LINEWRAP wxTE_CHARWRAP
// force using RichEdit version 2.0 or 3.0 instead of 1.0 (default) for
// wxTE_RICH controls - can be used together with or instead of wxTE_RICH

View File

@ -68,7 +68,18 @@ enum
enum TextLines
{
TextLines_Single,
TextLines_Multi
TextLines_Multi,
TextLines_Max
};
// wrap style radio box
enum WrapStyle
{
WrapStyle_None,
WrapStyle_Word,
WrapStyle_Char,
WrapStyle_Best,
WrapStyle_Max
};
#ifdef __WXMSW__
@ -78,7 +89,8 @@ enum TextKind
{
TextKind_Plain,
TextKind_Rich,
TextKind_Rich2
TextKind_Rich2,
TextKind_Max
};
#endif // __WXMSW__
@ -87,9 +99,12 @@ enum TextKind
static const struct ControlValues
{
TextLines textLines;
bool password;
bool wraplines;
bool readonly;
WrapStyle wrapStyle;
#ifdef __WXMSW__
TextKind textKind;
#endif // __WXMSW__
@ -97,8 +112,8 @@ static const struct ControlValues
{
TextLines_Multi, // multiline
false, // not password
true, // do wrap lines
false, // not readonly
WrapStyle_Word, // wrap on word boundaries
#ifdef __WXMSW__
TextKind_Plain // plain EDIT control
#endif // __WXMSW__
@ -172,9 +187,11 @@ protected:
// the radiobox to choose between single and multi line
wxRadioBox *m_radioTextLines;
// and another one to choose the wrapping style
wxRadioBox *m_radioWrap;
// the checkboxes controlling text ctrl styles
wxCheckBox *m_chkPassword,
*m_chkWrapLines,
*m_chkReadonly;
// under MSW we test rich edit controls as well here
@ -319,10 +336,10 @@ TextWidgetsPage::TextWidgetsPage(wxBookCtrl *book, wxImageList *imaglist)
#ifdef __WXMSW__
m_radioKind =
#endif // __WXMSW__
m_radioWrap =
m_radioTextLines = (wxRadioBox *)NULL;
m_chkPassword =
m_chkWrapLines =
m_chkReadonly = (wxCheckBox *)NULL;
m_text =
@ -358,17 +375,29 @@ TextWidgetsPage::TextWidgetsPage(wxBookCtrl *book, wxImageList *imaglist)
wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
sizerLeft->Add(m_radioTextLines, 0, wxGROW | wxALL, 5);
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
sizerLeft->AddSpacer(5);
m_chkPassword = CreateCheckBoxAndAddToSizer(
sizerLeft, _T("&Password control"), TextPage_Password
);
m_chkWrapLines = CreateCheckBoxAndAddToSizer(
sizerLeft, _T("Line &wrap"), TextPage_WrapLines
);
m_chkReadonly = CreateCheckBoxAndAddToSizer(
sizerLeft, _T("&Read-only mode")
);
sizerLeft->AddSpacer(5);
static const wxString wrap[] =
{
_T("no wrap"),
_T("word wrap"),
_T("char wrap"),
_T("best wrap"),
};
m_radioWrap = new wxRadioBox(this, wxID_ANY, _T("&Wrap style:"),
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(wrap), wrap,
1, wxRA_SPECIFY_COLS);
sizerLeft->Add(m_radioWrap, 0, wxGROW | wxALL, 5);
#ifdef __WXMSW__
static const wxString kinds[] =
@ -383,7 +412,7 @@ TextWidgetsPage::TextWidgetsPage(wxBookCtrl *book, wxImageList *imaglist)
WXSIZEOF(kinds), kinds,
1, wxRA_SPECIFY_COLS);
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
sizerLeft->AddSpacer(5);
sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
#endif // __WXMSW__
@ -547,9 +576,12 @@ wxSizer *TextWidgetsPage::CreateTextWithLabelSizer(const wxString& label,
void TextWidgetsPage::Reset()
{
m_radioTextLines->SetSelection(DEFAULTS.textLines);
m_chkPassword->SetValue(DEFAULTS.password);
m_chkWrapLines->SetValue(DEFAULTS.wraplines);
m_chkReadonly->SetValue(DEFAULTS.readonly);
m_radioWrap->SetSelection(DEFAULTS.wrapStyle);
#ifdef __WXMSW__
m_radioKind->SetSelection(DEFAULTS.textKind);
#endif // __WXMSW__
@ -576,8 +608,29 @@ void TextWidgetsPage::CreateText()
flags |= wxTE_PASSWORD;
if ( m_chkReadonly->GetValue() )
flags |= wxTE_READONLY;
if ( !m_chkWrapLines->GetValue() )
flags |= wxHSCROLL;
switch ( m_radioWrap->GetSelection() )
{
default:
wxFAIL_MSG( _T("unexpected wrap style radio box selection") );
case WrapStyle_None:
flags |= wxTE_DONTWRAP; // same as wxHSCROLL
break;
case WrapStyle_Word:
flags |= wxTE_WORDWRAP;
break;
case WrapStyle_Char:
flags |= wxTE_LINEWRAP;
break;
case WrapStyle_Best:
// this is default but use symbolic file name for consistency
flags |= wxTE_BESTWRAP;
break;
}
#ifdef __WXMSW__
switch ( m_radioKind->GetSelection() )
@ -794,7 +847,7 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
#endif // __WXMSW__
(m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
(m_chkPassword->GetValue() != DEFAULTS.password) ||
(m_chkWrapLines->GetValue() != DEFAULTS.wraplines) );
(m_radioWrap->GetSelection() != DEFAULTS.wrapStyle) );
}
void TextWidgetsPage::OnText(wxCommandEvent& WXUNUSED(event))

View File

@ -669,14 +669,9 @@ bool wxTextCtrl::Create(wxWindow *parent,
style |= wxALWAYS_SHOW_SB;
}
// wxTE_WORDWRAP is 0 for now so we don't need the code below
#if 0
if ( style & wxTE_WORDWRAP )
{
// wrapping words means wrapping, hence no horz scrollbar
style &= ~wxHSCROLL;
}
#endif // 0
// wrapping style: wxTE_DONTWRAP == wxHSCROLL so if it's _not_ given,
// we won't have horizontal scrollbar automatically, no need to do
// anything
// TODO: support wxTE_NO_VSCROLL (?)