sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
}
- SetBestSize(size);
+ SetInitialSize(size);
(void)::ShowWindow(GetBuddyHwnd(), SW_SHOW);
return str;
}
-void wxTextCtrl::SetValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
{
// if the text is long enough, it's faster to just set it instead of first
// comparing it with the old one (chances are that it will be different
// edit controls mostly)
if ( (value.length() > 0x400) || (value != GetValue()) )
{
- DoWriteText(value, false);
+ DoWriteText(value, flags);
// for compatibility, don't move the cursor when doing SetValue()
SetInsertionPoint(0);
else // same text
{
// still send an event for consistency
- SendUpdateEvent();
+ if ( flags & SetValue_SendEvent )
+ SendUpdateEvent();
}
// we should reset the modified flag even if the value didn't really change
DoWriteText(value);
}
-void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly)
+void wxTextCtrl::DoWriteText(const wxString& value, int flags)
{
+ bool selectionOnly = (flags & SetValue_SelectionOnly) != 0;
wxString valueDos;
if ( m_windowStyle & wxTE_MULTILINE )
valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
// call below which is confusing for the client code and so should be
// avoided
//
- if ( ( selectionOnly && HasSelection() ) )
+ if ( selectionOnly && HasSelection() )
{
m_suppressNextUpdate = true;
}
::SendMessage(GetBuddyHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
0, (LPARAM)valueDos.c_str());
- if ( !selectionOnly )
+ if ( !selectionOnly && !( flags & SetValue_SendEvent ) )
{
// Windows already sends an update event for single-line
// controls.
// Set selection and remove it
DoSetSelection(from, to, false);
- DoWriteText(value, true);
+ DoWriteText(value, SetValue_SelectionOnly);
}
void wxTextCtrl::Remove(long from, long to)