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"
18 class WXDLLEXPORT wxControl
: public wxControlBase
20 DECLARE_ABSTRACT_CLASS(wxControl
)
24 wxControl( wxWindow
* pParent
26 ,const wxPoint
& rPos
= wxDefaultPosition
27 ,const wxSize
& rSize
= wxDefaultSize
30 ,const wxValidator
& rValidator
= wxDefaultValidator
32 ,const wxString
& rsName
= wxControlNameStr
46 bool Create( wxWindow
* pParent
48 ,const wxPoint
& rPos
= wxDefaultPosition
49 ,const wxSize
& rSize
= wxDefaultSize
52 ,const wxValidator
& rValidator
= wxDefaultValidator
54 ,const wxString
& rsName
= wxControlNameStr
60 virtual void Command(wxCommandEvent
& rEvent
) { ProcessCommand(rEvent
); }
63 // Implementation from now on
64 // --------------------------
68 // Calls the callback and appropriate event handlers
70 bool ProcessCommand(wxCommandEvent
& rEvent
);
73 // For ownerdraw items
75 virtual bool OS2OnDraw(WXDRAWITEMSTRUCT
* WXUNUSED(pItem
)) { return FALSE
; };
76 virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT
* WXUNUSED(pItem
)) { return FALSE
; };
78 wxArrayLong
& GetSubcontrols() { return m_aSubControls
; }
79 void OnEraseBackground(wxEraseEvent
& rEvent
);
80 virtual WXHBRUSH
OnCtlColor( WXHDC hDC
88 #if WXWIN_COMPATIBILITY
89 virtual void SetButtonColour(const wxColour
& WXUNUSED(rCol
)) { }
90 wxColour
* GetButtonColour(void) const { return NULL
; }
92 inline virtual void SetLabelFont(const wxFont
& rFont
);
93 inline virtual void SetButtonFont(const wxFont
& rFont
);
94 inline wxFont
& GetLabelFont(void) const;
95 inline wxFont
& GetButtonFont(void) const;
100 inline void Callback(const wxFunction function
);
101 wxFunction
GetCallback(void) { return m_callback
; }
104 wxFunction m_callback
; // Callback associated with the window
105 #endif // WXWIN_COMPATIBILITY
109 // For controls like radiobuttons which are really composite
111 wxArrayLong m_aSubControls
;
113 virtual wxSize
DoGetBestSize(void) const;
116 // Create the control of the given PM class
118 bool OS2CreateControl( const wxChar
* zClassname
119 ,const wxString
& rsLabel
125 // Create the control of the given class with the given style, returns FALSE
126 // if creation failed.
128 bool OS2CreateControl( const wxChar
* zClassname
130 ,const wxPoint
& rPos
= wxDefaultPosition
131 ,const wxSize
& rSize
= wxDefaultSize
132 ,const wxString
& rsLabel
= wxEmptyString
133 ,WXDWORD dwExstyle
= (WXDWORD
)-1
137 // Default style for the control include WS_TABSTOP if it AcceptsFocus()
139 virtual WXDWORD
OS2GetStyle( long lStyle
143 inline int GetXComp(void) const {return m_nXComp
;}
144 inline int GetYComp(void) const {return m_nYComp
;}
145 inline void SetXComp(const int nXComp
) {m_nXComp
= nXComp
;}
146 inline void SetYComp(const int nYComp
) {m_nYComp
= nYComp
;}
151 DECLARE_EVENT_TABLE()
152 }; // end of wxControl
154 #if WXWIN_COMPATIBILITY
155 inline void wxControl::Callback(const wxFunction f
) { m_callback
= f
; };
156 inline wxFont
& wxControl::GetLabelFont(void) const { return GetFont(); }
157 inline wxFont
& wxControl::GetButtonFont(void) const { return GetFont(); }
158 inline void wxControl::SetLabelFont(const wxFont
& rFont
) { SetFont(rFont
); }
159 inline void wxControl::SetButtonFont(const wxFont
& rFont
) { SetFont(rFont
); }
160 #endif // WXWIN_COMPATIBILITY
162 #endif // _WX_CONTROL_H_