]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/textctrl.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        wx/gtk/textctrl.h 
   4 // Author:      Robert Roebling 
   7 // Copyright:   (c) 1998 Robert Roebling 
   8 // Licence:     wxWindows licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  11 #ifndef __GTKTEXTCTRLH__ 
  12 #define __GTKTEXTCTRLH__ 
  14 #if defined(__GNUG__) && !defined(__APPLE__) 
  15     #pragma interface "textctrl.h" 
  18 //----------------------------------------------------------------------------- 
  20 //----------------------------------------------------------------------------- 
  22 class wxTextCtrl
: public wxTextCtrlBase
 
  25     wxTextCtrl() { Init(); } 
  26     wxTextCtrl(wxWindow 
*parent
, 
  28                const wxString 
&value 
= wxEmptyString
, 
  29                const wxPoint 
&pos 
= wxDefaultPosition
, 
  30                const wxSize 
&size 
= wxDefaultSize
, 
  32                const wxValidator
& validator 
= wxDefaultValidator
, 
  33                const wxString 
&name 
= wxTextCtrlNameStr
); 
  35     bool Create(wxWindow 
*parent
, 
  37                 const wxString 
&value 
= wxEmptyString
, 
  38                 const wxPoint 
&pos 
= wxDefaultPosition
, 
  39                 const wxSize 
&size 
= wxDefaultSize
, 
  41                 const wxValidator
& validator 
= wxDefaultValidator
, 
  42                 const wxString 
&name 
= wxTextCtrlNameStr
); 
  44     // implement base class pure virtuals 
  45     // ---------------------------------- 
  47     virtual wxString 
GetValue() const; 
  48     virtual void SetValue(const wxString
& value
); 
  50     virtual int GetLineLength(long lineNo
) const; 
  51     virtual wxString 
GetLineText(long lineNo
) const; 
  52     virtual int GetNumberOfLines() const; 
  54     virtual bool IsModified() const; 
  55     virtual bool IsEditable() const; 
  57     // If the return values from and to are the same, there is no selection. 
  58     virtual void GetSelection(long* from
, long* to
) const; 
  65     virtual void Replace(long from
, long to
, const wxString
& value
); 
  66     virtual void Remove(long from
, long to
); 
  68     // clears the dirty flag 
  69     virtual void DiscardEdits(); 
  71     virtual void SetMaxLength(unsigned long len
); 
  73     // writing text inserts it at the current position, appending always 
  74     // inserts it at the end 
  75     virtual void WriteText(const wxString
& text
); 
  76     virtual void AppendText(const wxString
& text
); 
  78     // apply text attribute to the range of text (only works with richedit 
  80     virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
); 
  82     // translate between the position (which is just an index in the text ctrl 
  83     // considering all its contents as a single strings) and (x, y) coordinates 
  84     // which represent column and line. 
  85     virtual long XYToPosition(long x
, long y
) const; 
  86     virtual bool PositionToXY(long pos
, long *x
, long *y
) const; 
  88     virtual void ShowPosition(long pos
); 
  90     // Clipboard operations 
  99     virtual bool CanUndo() const; 
 100     virtual bool CanRedo() const; 
 103     virtual void SetInsertionPoint(long pos
); 
 104     virtual void SetInsertionPointEnd(); 
 105     virtual long GetInsertionPoint() const; 
 106     virtual long GetLastPosition() const; 
 108     virtual void SetSelection(long from
, long to
); 
 109     virtual void SetEditable(bool editable
); 
 111     virtual bool Enable( bool enable 
= TRUE 
); 
 113     // Implementation from now on 
 114     void OnDropFiles( wxDropFilesEvent 
&event 
); 
 115     void OnChar( wxKeyEvent 
&event 
); 
 117     void OnCut(wxCommandEvent
& event
); 
 118     void OnCopy(wxCommandEvent
& event
); 
 119     void OnPaste(wxCommandEvent
& event
); 
 120     void OnUndo(wxCommandEvent
& event
); 
 121     void OnRedo(wxCommandEvent
& event
); 
 123     void OnUpdateCut(wxUpdateUIEvent
& event
); 
 124     void OnUpdateCopy(wxUpdateUIEvent
& event
); 
 125     void OnUpdatePaste(wxUpdateUIEvent
& event
); 
 126     void OnUpdateUndo(wxUpdateUIEvent
& event
); 
 127     void OnUpdateRedo(wxUpdateUIEvent
& event
); 
 129     bool SetFont(const wxFont
& font
); 
 130     bool SetForegroundColour(const wxColour
& colour
); 
 131     bool SetBackgroundColour(const wxColour
& colour
); 
 133     GtkWidget
* GetConnectWidget(); 
 134     bool IsOwnGtkWindow( GdkWindow 
*window 
); 
 135     void ApplyWidgetStyle(); 
 136     void CalculateScrollbar(); 
 137     void OnInternalIdle(); 
 138     void UpdateFontIfNeeded(); 
 140     void SetModified() { m_modified 
= TRUE
; } 
 142     // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to 
 143     // avoid horrible flicker/scrolling back and forth 
 144     virtual void Freeze(); 
 147     // textctrl specific scrolling 
 148     virtual bool ScrollLines(int lines
); 
 149     virtual bool ScrollPages(int pages
); 
 151     // implementation only from now on 
 153     // wxGTK-specific: called recursively by Enable, 
 154     // to give widgets an oppprtunity to correct their colours after they 
 155     // have been changed by Enable 
 156     virtual void OnParentEnable( bool enable 
) ; 
 158     // tell the control to ignore next text changed signal 
 159     void IgnoreNextTextUpdate(); 
 161     // should we ignore the changed signal? always resets the flag 
 162     bool IgnoreTextUpdate(); 
 165     virtual wxSize 
DoGetBestSize() const; 
 167     // common part of all ctors 
 170     // get the vertical adjustment, if any, NULL otherwise 
 171     GtkAdjustment 
*GetVAdj() const; 
 173     // scroll the control by the given number of pixels, return true if the 
 174     // scroll position changed 
 175     bool DoScroll(GtkAdjustment 
*adj
, int diff
); 
 178     // change the font for everything in this control 
 179     void ChangeFontGlobally(); 
 182     GtkWidget  
*m_vScrollbar
; 
 185     bool        m_vScrollbarVisible
:1; 
 187     bool        m_ignoreNextUpdate
:1; 
 189     DECLARE_EVENT_TABLE() 
 190     DECLARE_DYNAMIC_CLASS(wxTextCtrl
); 
 193 #endif // __GTKTEXTCTRLH__