// ------------------------------------------------------------------------
public:
virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value);
-
- virtual void ChangeValue(const wxString &value);
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
protected:
virtual wxSize DoGetBestSize() const;
+
+ virtual void DoSetValue(const wxString& value, int flags = 0);
};
#endif // __WX_COCOA_TEXTCTRL_H__
virtual wxString GetValue() const;
virtual bool IsEmpty() const;
- virtual void SetValue(const wxString& value) { DoSetValue(value, SetValue_SendEvent); }
- virtual void ChangeValue(const wxString& value) { DoSetValue(value); }
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
// has the control been frozen by Freeze()?
bool IsFrozen() const { return m_frozenness > 0; }
- void DoSetValue(const wxString &value, int flags = 0);
+ virtual void DoSetValue(const wxString &value, int flags = 0);
private:
// change the font for everything in this control
// ----------------------------------
virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value) { DoSetValue(value, SetValue_SendEvent); }
-
- virtual void ChangeValue(const wxString &value) { DoSetValue(value); }
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
// override this and return true.
virtual bool UseGTKStyleBase() const { return true; }
- void DoSetValue(const wxString &value, int flags = 0);
+ virtual void DoSetValue(const wxString &value, int flags = 0);
private:
// change the font for everything in this control
// accessors
// ---------
virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value);
-
- virtual void ChangeValue(const wxString &value);
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
wxMacTextControl * GetPeer() const
{ return (wxMacTextControl*) m_peer; }
-
+
protected:
// common part of all ctors
void Init();
virtual wxSize DoGetBestSize() const;
+ virtual void DoSetValue(const wxString& value, int flags = 0);
+
bool m_editable;
// flag is set to true when the user edits the controls contents
// need to make this public because of the current implementation via callbacks
unsigned long m_maxLength;
-
- bool GetTriggerOnSetValue() const
- {
- return m_triggerOnSetValue;
+
+ bool GetTriggerOnSetValue() const
+ {
+ return m_triggerOnSetValue;
}
-
- void SetTriggerOnSetValue(bool trigger)
- {
- m_triggerOnSetValue = trigger;
+
+ void SetTriggerOnSetValue(bool trigger)
+ {
+ m_triggerOnSetValue = trigger;
}
-
+
bool m_triggerOnSetValue ;
private :
// accessors
// ---------
virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value)
- { ChangeValue(value); SendTextUpdatedEvent(); }
-
- virtual void ChangeValue(const wxString &value);
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
wxString m_fileName;
virtual wxSize DoGetBestSize() const;
+
+ virtual void DoSetValue(const wxString& value, int flags = 0);
+
public:
// Motif-specific
void* m_tempCallbackStruct;
virtual wxString GetValue() const;
virtual bool IsEmpty() const;
- virtual void SetValue(const wxString& value) { DoSetValue(value, SetValue_SendEvent); }
- virtual void ChangeValue(const wxString& value) { DoSetValue(value); }
virtual wxString GetRange(long from, long to) const;
// common part of all ctors
void Init();
- void DoSetValue(const wxString &value, int flags = 0);
+ virtual void DoSetValue(const wxString &value, int flags = 0);
// return true if this control has a user-set limit on amount of text (i.e.
// the limit is due to a previous call to SetMaxLength() and not built in)
// ----------------------------------
//
virtual wxString GetValue(void) const;
- virtual void SetValue(const wxString& value) { DoSetValue(value, SetValue_SendEvent); }
-
- virtual void ChangeValue(const wxString &value) { DoSetValue(value); }
virtual int GetLineLength(long nLineNo) const;
virtual wxString GetLineText(long nLineNo) const;
,WXDWORD* dwExstyle
) const;
- void DoSetValue(const wxString &value, int flags = 0);
+ virtual void DoSetValue(const wxString &value, int flags = 0);
bool m_bSkipUpdate;
// ----------------------------------
virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value);
-
- virtual void ChangeValue(const wxString &value);
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
// common part of all ctors
void Init();
+ virtual void DoSetValue(const wxString& value, int flags = 0);
+
+
// intercept WM_GETDLGCODE
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// ---------
virtual wxString GetValue() const = 0;
- virtual void SetValue(const wxString& value) = 0;
-
virtual bool IsEmpty() const { return GetValue().empty(); }
- virtual void ChangeValue(const wxString &value) = 0;
+ virtual void SetValue(const wxString& value)
+ { DoSetValue(value, SetValue_SendEvent); }
+ virtual void ChangeValue(const wxString& value)
+ { DoSetValue(value); }
virtual wxString GetRange(long from, long to) const;
wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const wxChar c);
+ // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does
+ void SendTextUpdatedEvent();
+
// do the window-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
int overflow(int i);
#endif // wxHAS_TEXT_WINDOW_STREAM
- // typically, wxTextCtrl classes will use a DoSetValue() function to
- // implement both SetValue() and ChangeValue() functions and these
- // flags are meant to be passed to such DoSetValue()
+ // flags for DoSetValue(): common part of SetValue() and ChangeValue() and
+ // also used to implement WriteText() in wxMSW
enum
{
SetValue_SendEvent = 1,
SetValue_SelectionOnly = 2
};
- // generate the wxEVT_COMMAND_TEXT_UPDATED event
- void SendTextUpdatedEvent();
+ virtual void DoSetValue(const wxString& value, int flags = 0) = 0;
+
// the name of the last file loaded with LoadFile() which will be used by
// SaveFile() by default
// ----------------------------------
virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value);
-
- virtual void ChangeValue(const wxString &value);
virtual int GetLineLength(wxTextCoord lineNo) const;
virtual wxString GetLineText(wxTextCoord lineNo) const;
// calc the size from the text extent
virtual wxSize DoGetBestClientSize() const;
+ // implements Set/ChangeValue()
+ virtual void DoSetValue(const wxString& value, int flags = 0);
+
// common part of all ctors
void Init();
// implement base class pure virtuals
// ----------------------------------
- virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value)
- { ChangeValue(value); SendTextUpdatedEvent(); }
-
virtual void ChangeValue(const wxString &value);
virtual int GetLineLength(long lineNo) const;
// more readable flag testing methods
// ----------------------------------
-#if 0
- // it seems now in wxTextCtrlBase
- bool IsSingleLine() const { return !(GetWindowStyle() & wxTE_MULTILINE); }
-#endif
bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; }
bool WrapLines() const { return false; }
virtual wxSize DoGetBestSize() const;
+ virtual void DoSetValue(const wxString& value, int flags = 0);
+
friend class wxSourceUndoStep;
wxSourceLineArray m_lines;
{
}
-void wxTextCtrl::SetValue(wxString const& value)
+void wxTextCtrl::DoSetValue(wxString const& value, int flags)
{
wxAutoNSAutoreleasePool pool;
[GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
+
+ if ( flags & SetValue_SendEvent )
+ SendTextUpdatedEvent();
}
void wxTextCtrl::WriteText(wxString const&)
{
// if it worked, save for future calls
m_filename = filename;
-
+
// it's not modified any longer
DiscardEdits();
return wxTE_HT_UNKNOWN;
}
+// ----------------------------------------------------------------------------
+// events
+// ----------------------------------------------------------------------------
+
+void wxTextCtrlBase::SendTextUpdatedEvent()
+{
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
+
+ // do not do this as it could be very inefficient if the text control
+ // contains a lot of text and we're not using ref-counted wxString
+ // implementation -- instead, event.GetString() will query the control for
+ // its current text if needed
+ //event.SetString(GetValue());
+
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+}
+
#else // !wxUSE_TEXTCTRL
// define this one even if !wxUSE_TEXTCTRL because it is also used by other
if ( win->MarkDirtyOnChange() )
win->MarkDirty();
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
- event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( event );
+ win->SendTextUpdatedEvent();
}
}
GetPeer()->GetSelection( from , to ) ;
}
-void wxTextCtrl::SetValue(const wxString& str)
+void wxTextCtrl::DoSetValue(const wxString& str, int flags)
{
// optimize redraws
if ( GetValue() == str )
- return ;
+ return;
GetPeer()->SetStringValue( str ) ;
- if ( m_triggerOnSetValue )
+ if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue )
{
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
- event.SetString( GetValue() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
+ SendTextUpdatedEvent();
}
}
-void wxTextCtrl::ChangeValue(const wxString& str)
-{
- // optimize redraws
- if ( GetValue() == str )
- return ;
-
- GetPeer()->SetStringValue( str ) ;
-}
-
void wxTextCtrl::SetMaxLength(unsigned long len)
{
m_maxLength = len ;
return str;
}
-void wxTextCtrl::ChangeValue(const wxString& text)
+void wxTextCtrl::DoSetValue(const wxString& text, int flags)
{
m_inSetValue = true;
m_modified = true;
m_inSetValue = false;
+
+ if ( flags & SetValue_SendEvent )
+ SendTextUpdatedEvent();
}
// Clipboard operations
return res;
}
-void wxTextCtrl::SetValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
{
}
-void wxTextCtrl::ChangeValue(const wxString& value)
-{
-}
-
-#if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
-
-// TODO: using memcpy() would improve performance a lot for big amounts of text
-
-DWORD CALLBACK
-wxRichEditStreamIn(DWORD dwCookie, BYTE *buf, LONG cb, LONG *pcb)
-{
- return 0;
-}
-
-// helper struct used to pass parameters from wxTextCtrl to wxRichEditStreamOut
-struct wxStreamOutData
-{
- wchar_t *wpc;
- size_t len;
-};
-
-DWORD CALLBACK
-wxRichEditStreamOut(DWORD_PTR dwCookie, BYTE *buf, LONG cb, LONG *pcb)
-{
- return 0;
-}
-
-
-#if wxUSE_UNICODE_MSLU
- #define UNUSED_IF_MSLU(param)
-#else
- #define UNUSED_IF_MSLU(param) param
-#endif
-
-bool
-wxTextCtrl::StreamIn(const wxString& value,
- wxFontEncoding UNUSED_IF_MSLU(encoding),
- bool selectionOnly)
-{
- return false;
-}
-
-#if !wxUSE_UNICODE_MSLU
-
-wxString
-wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
-{
- wxString out;
-
- return out;
-}
-
-#endif // !wxUSE_UNICODE_MSLU
-
-#endif // wxUSE_RICHEDIT
-
void wxTextCtrl::WriteText(const wxString& value)
{
}
// set/get the value
// ----------------------------------------------------------------------------
-void wxTextCtrl::ChangeValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
{
if ( IsSingleLine() && (value == GetValue()) )
{
{
SetInsertionPoint(0);
}
-}
-void wxTextCtrl::SetValue(const wxString& value)
-{
- ChangeValue(value);
- SendTextUpdatedEvent();
+ if ( flags & SetValue_SendEvent )
+ SendTextUpdatedEvent();
}
const wxArrayString& wxTextCtrl::GetLines() const
return ret;
}
-void wxTextCtrl::ChangeValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
{
m_modified = false;
MyAdjustScrollbars();
Refresh();
+
+ if ( flags & SetValue_SendEvent )
+ SendTextUpdatedEvent();
}
int wxTextCtrl::GetLineLength(long lineNo) const