fix a fatal crash due to using wxHSCROLL presence in m_windowStyle as indicator of whether we wrap lines or not: this didn't work because wxHSCROLL was temporarily reset in wxWindow::Create() and so we used wxTextWrappedData when we only had created wxTextMultiLineData

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-04-08 23:25:36 +00:00
parent 2e9c0c010a
commit ccc20afae9
2 changed files with 15 additions and 5 deletions

View File

@@ -234,9 +234,8 @@ public:
virtual bool Enable(bool enable = true); virtual bool Enable(bool enable = true);
// more readable flag testing methods // more readable flag testing methods
bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; } bool IsPassword() const { return HasFlag(wxTE_PASSWORD); }
bool WrapLines() const bool WrapLines() const { return m_wrapLines; }
{ return !IsSingleLine() && !(GetWindowStyle() & wxHSCROLL); }
// only for wxStdTextCtrlInputHandler // only for wxStdTextCtrlInputHandler
void RefreshSelection(); void RefreshSelection();
@@ -500,7 +499,8 @@ private:
// flags // flags
bool m_isModified:1, bool m_isModified:1,
m_isEditable:1, m_isEditable:1,
m_hasCaret:1; m_hasCaret:1,
m_wrapLines:1; // can't be changed after creation
// the rectangle (in client coordinates) to draw text inside // the rectangle (in client coordinates) to draw text inside
wxRect m_rectText; wxRect m_rectText;

View File

@@ -650,6 +650,7 @@ void wxTextCtrl::Init()
m_isModified = false; m_isModified = false;
m_isEditable = true; m_isEditable = true;
m_wrapLines = false;
m_posLast = m_posLast =
m_curPos = m_curPos =
@@ -695,10 +696,19 @@ bool wxTextCtrl::Create(wxWindow *parent,
// create data object for normal multiline or for controls with line // create data object for normal multiline or for controls with line
// wrap as needed // wrap as needed
if ( style & wxHSCROLL ) if ( style & wxHSCROLL )
{
m_data.mdata = new wxTextMultiLineData; m_data.mdata = new wxTextMultiLineData;
else }
else // we must wrap lines if we don't have horizontal scrollbar
{
// NB: we can't rely on HasFlag(wxHSCROLL) as the flags can change
// later and even wxWindow::Create() itself temporarily resets
// wxHSCROLL in wxUniv, so remember that we have a wrapped data
// and not just a multi line data in a separate variable
m_wrapLines = true;
m_data.wdata = new wxTextWrappedData; m_data.wdata = new wxTextWrappedData;
} }
}
else else
{ {
// this doesn't make sense for single line controls // this doesn't make sense for single line controls