1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/univ/control.h 3 // Purpose: universal wxControl: adds handling of mnemonics 4 // Author: Vadim Zeitlin 5 // Modified by: 6 // Created: 14.08.00 7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) 8 // Licence: wxWindows licence 9 ///////////////////////////////////////////////////////////////////////////// 10 11 #ifndef _WX_UNIV_CONTROL_H_ 12 #define _WX_UNIV_CONTROL_H_ 13 14 class WXDLLIMPEXP_FWD_CORE wxControlRenderer; 15 class WXDLLIMPEXP_FWD_CORE wxInputHandler; 16 class WXDLLIMPEXP_FWD_CORE wxRenderer; 17 18 // we must include it as most/all control classes derive their handlers from 19 // it 20 #include "wx/univ/inphand.h" 21 22 #include "wx/univ/inpcons.h" 23 24 // ---------------------------------------------------------------------------- 25 // wxControlAction: the action is currently just a string which identifies it, 26 // later it might become an atom (i.e. an opaque handler to string). 27 // ---------------------------------------------------------------------------- 28 29 typedef wxString wxControlAction; 30 31 // the list of actions which apply to all controls (other actions are defined 32 // in the controls headers) 33 34 #define wxACTION_NONE wxT("") // no action to perform 35 36 // ---------------------------------------------------------------------------- 37 // wxControl: the base class for all GUI controls 38 // ---------------------------------------------------------------------------- 39 40 class WXDLLIMPEXP_CORE wxControl : public wxControlBase, public wxInputConsumer 41 { 42 public: wxControl()43 wxControl() { Init(); } 44 45 wxControl(wxWindow *parent, 46 wxWindowID id, 47 const wxPoint& pos = wxDefaultPosition, 48 const wxSize& size = wxDefaultSize, long style = 0, 49 const wxValidator& validator = wxDefaultValidator, 50 const wxString& name = wxControlNameStr) 51 { 52 Init(); 53 54 Create(parent, id, pos, size, style, validator, name); 55 } 56 57 bool Create(wxWindow *parent, 58 wxWindowID id, 59 const wxPoint& pos = wxDefaultPosition, 60 const wxSize& size = wxDefaultSize, long style = 0, 61 const wxValidator& validator = wxDefaultValidator, 62 const wxString& name = wxControlNameStr); 63 64 // this function will filter out '&' characters and will put the 65 // accelerator char (the one immediately after '&') into m_chAccel 66 virtual void SetLabel(const wxString& label); 67 68 // return the current label GetLabel()69 virtual wxString GetLabel() const { return m_label; } 70 71 // wxUniversal-specific methods 72 73 // return the index of the accel char in the label or -1 if none GetAccelIndex()74 int GetAccelIndex() const { return m_indexAccel; } 75 76 // return the accel char itself or 0 if none GetAccelChar()77 wxChar GetAccelChar() const 78 { 79 return m_indexAccel == -1 ? wxT('\0') : (wxChar)m_label[m_indexAccel]; 80 } 81 GetInputWindow()82 virtual wxWindow *GetInputWindow() const { return (wxWindow*)this; } 83 84 protected: 85 // common part of all ctors 86 void Init(); 87 88 // set m_label and m_indexAccel and refresh the control to show the new 89 // label (but, unlike SetLabel(), don't call the base class SetLabel() thus 90 // avoiding to change wxControlBase::m_labelOrig) 91 void UnivDoSetLabel(const wxString& label); 92 93 private: 94 // label and accel info 95 wxString m_label; 96 int m_indexAccel; 97 98 DECLARE_DYNAMIC_CLASS(wxControl) 99 DECLARE_EVENT_TABLE() 100 WX_DECLARE_INPUT_CONSUMER() 101 }; 102 103 #endif // _WX_UNIV_CONTROL_H_ 104