1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: David Webster
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CONTROL_H_
13 #define _WX_CONTROL_H_
15 #include "wx/dynarray.h"
17 WXDLLEXPORT_DATA(extern const wxChar
*) wxControlNameStr
;
20 class WXDLLEXPORT wxControl
: public wxControlBase
22 DECLARE_ABSTRACT_CLASS(wxControl
)
26 wxControl( wxWindow
* pParent
28 ,const wxPoint
& rPos
= wxDefaultPosition
29 ,const wxSize
& rSize
= wxDefaultSize
32 ,const wxValidator
& rValidator
= wxDefaultValidator
34 ,const wxString
& rsName
= wxControlNameStr
48 bool Create( wxWindow
* pParent
50 ,const wxPoint
& rPos
= wxDefaultPosition
51 ,const wxSize
& rSize
= wxDefaultSize
54 ,const wxValidator
& rValidator
= wxDefaultValidator
56 ,const wxString
& rsName
= wxControlNameStr
62 virtual void Command(wxCommandEvent
& rEvent
) { ProcessCommand(rEvent
); }
65 // Implementation from now on
66 // --------------------------
70 // Calls the callback and appropriate event handlers
72 bool ProcessCommand(wxCommandEvent
& rEvent
);
75 // For ownerdraw items
77 virtual bool OS2OnDraw(WXDRAWITEMSTRUCT
* WXUNUSED(pItem
)) { return FALSE
; };
78 virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT
* WXUNUSED(pItem
)) { return FALSE
; };
80 wxArrayLong
& GetSubcontrols() { return m_aSubControls
; }
81 void OnEraseBackground(wxEraseEvent
& rEvent
);
82 virtual WXHBRUSH
OnCtlColor( WXHDC hDC
90 #if WXWIN_COMPATIBILITY
91 virtual void SetButtonColour(const wxColour
& WXUNUSED(rCol
)) { }
92 wxColour
* GetButtonColour(void) const { return NULL
; }
94 inline virtual void SetLabelFont(const wxFont
& rFont
);
95 inline virtual void SetButtonFont(const wxFont
& rFont
);
96 inline wxFont
& GetLabelFont(void) const;
97 inline wxFont
& GetButtonFont(void) const;
102 inline void Callback(const wxFunction function
);
103 wxFunction
GetCallback(void) { return m_callback
; }
106 wxFunction m_callback
; // Callback associated with the window
107 #endif // WXWIN_COMPATIBILITY
111 // For controls like radiobuttons which are really composite
113 wxArrayLong m_aSubControls
;
115 virtual wxSize
DoGetBestSize(void) const;
118 // Create the control of the given class with the given style, returns FALSE
119 // if creation failed.
121 bool OS2CreateControl( const wxChar
* zClassname
123 ,const wxPoint
& rPos
= wxDefaultPosition
124 ,const wxSize
& rSize
= wxDefaultSize
125 ,const wxString
& rsLabel
= wxEmptyString
126 ,WXDWORD dwExstyle
= (WXDWORD
)-1
130 // Determine the extended styles combination for this window (may slightly
131 // modify styl parameter)
133 WXDWORD
GetExStyle(WXDWORD
& rStyle
) const;
136 DECLARE_EVENT_TABLE()
137 }; // end of wxControl
139 #if WXWIN_COMPATIBILITY
140 inline void wxControl::Callback(const wxFunction f
) { m_callback
= f
; };
141 inline wxFont
& wxControl::GetLabelFont(void) const { return GetFont(); }
142 inline wxFont
& wxControl::GetButtonFont(void) const { return GetFont(); }
143 inline void wxControl::SetLabelFont(const wxFont
& rFont
) { SetFont(rFont
); }
144 inline void wxControl::SetButtonFont(const wxFont
& rFont
) { SetFont(rFont
); }
145 #endif // WXWIN_COMPATIBILITY
147 #endif // _WX_CONTROL_H_