textctrl.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/os2/textctrl.h
  3. // Purpose: wxTextCtrl class
  4. // Author: David Webster
  5. // Modified by:
  6. // Created: 10/17/99
  7. // Copyright: (c) David Webster
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_TEXTCTRL_H_
  11. #define _WX_TEXTCTRL_H_
  12. typedef int (wxCALLBACK *wxTreeCtrlCompare)(long lItem1, long lItem2, long lSortData);
  13. class WXDLLIMPEXP_CORE wxTextCtrl : public wxTextCtrlBase
  14. {
  15. public:
  16. wxTextCtrl();
  17. wxTextCtrl( wxWindow* pParent
  18. ,wxWindowID vId
  19. ,const wxString& rsValue = wxEmptyString
  20. ,const wxPoint& rPos = wxDefaultPosition
  21. ,const wxSize& rSize = wxDefaultSize
  22. ,long lStyle = 0
  23. ,const wxValidator& rValidator = wxDefaultValidator
  24. ,const wxString& rsName = wxTextCtrlNameStr
  25. )
  26. {
  27. Create(pParent, vId, rsValue, rPos, rSize, lStyle, rValidator, rsName);
  28. }
  29. virtual ~wxTextCtrl();
  30. bool Create( wxWindow* pParent
  31. ,wxWindowID vId
  32. ,const wxString& rsValue = wxEmptyString
  33. ,const wxPoint& rPos = wxDefaultPosition
  34. ,const wxSize& rSize = wxDefaultSize
  35. ,long lStyle = 0
  36. ,const wxValidator& rValidator = wxDefaultValidator
  37. ,const wxString& rsName = wxTextCtrlNameStr
  38. );
  39. //
  40. // Implement base class pure virtuals
  41. // ----------------------------------
  42. //
  43. virtual wxString GetValue(void) const;
  44. virtual int GetLineLength(long nLineNo) const;
  45. virtual wxString GetLineText(long nLineNo) const;
  46. virtual int GetNumberOfLines(void) const;
  47. virtual bool IsModified(void) const;
  48. virtual bool IsEditable(void) const;
  49. virtual void GetSelection( long* pFrom
  50. ,long* pTo
  51. ) const;
  52. //
  53. // Operations
  54. // ----------
  55. //
  56. virtual void Clear(void);
  57. virtual void Replace( long lFrom
  58. ,long lTo
  59. ,const wxString& rsValue
  60. );
  61. virtual void Remove( long lFrom
  62. ,long lTo
  63. );
  64. virtual bool DoLoadFile(const wxString& rsFile, int fileType);
  65. virtual void MarkDirty();
  66. virtual void DiscardEdits(void);
  67. virtual void WriteText(const wxString& rsText);
  68. virtual void AppendText(const wxString& rsText);
  69. virtual bool EmulateKeyPress(const wxKeyEvent& rEvent);
  70. virtual bool SetStyle( long lStart
  71. ,long lEnd
  72. ,const wxTextAttr& rStyle
  73. );
  74. virtual long XYToPosition( long lX
  75. ,long lY
  76. ) const;
  77. virtual bool PositionToXY( long lPos
  78. ,long* plX
  79. ,long* plY
  80. ) const;
  81. virtual void ShowPosition(long lPos);
  82. virtual void Copy(void);
  83. virtual void Cut(void);
  84. virtual void Paste(void);
  85. virtual bool CanCopy(void) const;
  86. virtual bool CanCut(void) const;
  87. virtual bool CanPaste(void) const;
  88. virtual void Undo(void);
  89. virtual void Redo(void);
  90. virtual bool CanUndo(void) const;
  91. virtual bool CanRedo(void) const;
  92. virtual void SetInsertionPoint(long lPos);
  93. virtual void SetInsertionPointEnd(void);
  94. virtual long GetInsertionPoint(void) const;
  95. virtual wxTextPos GetLastPosition(void) const;
  96. virtual void SetSelection( long lFrom
  97. ,long lTo
  98. );
  99. virtual void SetEditable(bool bEditable);
  100. virtual void SetWindowStyleFlag(long lStyle);
  101. //
  102. // Implementation from now on
  103. // --------------------------
  104. //
  105. virtual void Command(wxCommandEvent& rEvent);
  106. virtual bool OS2Command( WXUINT uParam
  107. ,WXWORD wId
  108. );
  109. virtual WXHBRUSH OnCtlColor( WXHDC hDC
  110. ,WXHWND pWnd
  111. ,WXUINT nCtlColor
  112. ,WXUINT message
  113. ,WXWPARAM wParam
  114. ,WXLPARAM lParam
  115. );
  116. virtual bool SetBackgroundColour(const wxColour& colour);
  117. virtual bool SetForegroundColour(const wxColour& colour);
  118. virtual void AdoptAttributesFromHWND(void);
  119. virtual void SetupColours(void);
  120. virtual bool AcceptsFocus(void) const;
  121. // callbacks
  122. void OnDropFiles(wxDropFilesEvent& rEvent);
  123. void OnChar(wxKeyEvent& rEvent); // Process 'enter' if required
  124. void OnCut(wxCommandEvent& rEvent);
  125. void OnCopy(wxCommandEvent& rEvent);
  126. void OnPaste(wxCommandEvent& rEvent);
  127. void OnUndo(wxCommandEvent& rEvent);
  128. void OnRedo(wxCommandEvent& rEvent);
  129. void OnDelete(wxCommandEvent& rEvent);
  130. void OnSelectAll(wxCommandEvent& rEvent);
  131. void OnUpdateCut(wxUpdateUIEvent& rEvent);
  132. void OnUpdateCopy(wxUpdateUIEvent& rEvent);
  133. void OnUpdatePaste(wxUpdateUIEvent& rEvent);
  134. void OnUpdateUndo(wxUpdateUIEvent& rEvent);
  135. void OnUpdateRedo(wxUpdateUIEvent& rEvent);
  136. void OnUpdateDelete(wxUpdateUIEvent& rEvent);
  137. void OnUpdateSelectAll(wxUpdateUIEvent& rEvent);
  138. inline bool IsMLE(void) {return m_bIsMLE;}
  139. inline void SetMLE(bool bIsMLE) {m_bIsMLE = bIsMLE;}
  140. protected:
  141. //
  142. // call this to increase the size limit (will do nothing if the current
  143. // limit is big enough)
  144. //
  145. void AdjustSpaceLimit(void);
  146. virtual wxSize DoGetBestSize(void) const;
  147. virtual bool OS2ShouldPreProcessMessage(WXMSG* pMsg);
  148. virtual WXDWORD OS2GetStyle( long lStyle
  149. ,WXDWORD* dwExstyle
  150. ) const;
  151. virtual void DoSetValue(const wxString &value, int flags = 0);
  152. bool m_bSkipUpdate;
  153. private:
  154. // implement wxTextEntry pure virtual: it implements all the operations for
  155. // the simple EDIT controls
  156. virtual WXHWND GetEditHWND() const { return m_hWnd; }
  157. bool m_bIsMLE;
  158. DECLARE_EVENT_TABLE()
  159. DECLARE_DYNAMIC_CLASS(wxTextCtrl)
  160. }; // end of CLASS wxTextCtrl
  161. #endif
  162. // _WX_TEXTCTRL_H_