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;
117 bool OS2CreateControl( wxWindow
* pParent
123 ,const wxValidator
& rValidator
125 ,const wxString
& rsName
128 // Create the control of the given class with the given style, returns FALSE
129 // if creation failed.
131 bool OS2CreateControl( const wxChar
* zClassname
133 ,const wxPoint
& rPos
= wxDefaultPosition
134 ,const wxSize
& rSize
= wxDefaultSize
135 ,const wxString
& rsLabel
= wxEmptyString
136 ,WXDWORD dwExstyle
= (WXDWORD
)-1
140 // Determine the extended styles combination for this window (may slightly
141 // modify styl parameter)
143 WXDWORD
GetExStyle(WXDWORD
& rStyle
) const;
145 inline int GetXComp(void) const {return m_nXComp
;}
146 inline int GetYComp(void) const {return m_nYComp
;}
147 inline void SetXComp(const int nXComp
) {m_nXComp
= nXComp
;}
148 inline void SetYComp(const int nYComp
) {m_nYComp
= nYComp
;}
153 DECLARE_EVENT_TABLE()
154 }; // end of wxControl
156 #if WXWIN_COMPATIBILITY
157 inline void wxControl::Callback(const wxFunction f
) { m_callback
= f
; };
158 inline wxFont
& wxControl::GetLabelFont(void) const { return GetFont(); }
159 inline wxFont
& wxControl::GetButtonFont(void) const { return GetFont(); }
160 inline void wxControl::SetLabelFont(const wxFont
& rFont
) { SetFont(rFont
); }
161 inline void wxControl::SetButtonFont(const wxFont
& rFont
) { SetFont(rFont
); }
162 #endif // WXWIN_COMPATIBILITY
164 #endif // _WX_CONTROL_H_