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
*parent
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
32 const wxValidator
& validator
= wxDefaultValidator
,
34 const wxString
& name
= wxControlNameStr
)
36 Create(parent
, id
, pos
, size
, style
, validator
, name
);
39 bool Create(wxWindow
*parent
, wxWindowID id
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
, long style
= 0,
43 const wxValidator
& validator
= wxDefaultValidator
,
45 const wxString
& name
= wxControlNameStr
);
49 virtual void Command(wxCommandEvent
& event
) { ProcessCommand(event
); }
51 // implementation from now on
52 // --------------------------
54 // Calls the callback and appropriate event handlers
55 bool ProcessCommand(wxCommandEvent
& event
);
58 virtual bool OS2OnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
60 // For ownerdraw items
61 virtual bool OS2OnDraw(WXDRAWITEMSTRUCT
*WXUNUSED(item
)) { return FALSE
; };
62 virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT
*WXUNUSED(item
)) { return FALSE
; };
64 wxArrayLong
& GetSubcontrols() { return m_subControls
; }
66 void OnEraseBackground(wxEraseEvent
& event
);
68 #if WXWIN_COMPATIBILITY
69 virtual void SetButtonColour(const wxColour
& WXUNUSED(col
)) { }
70 wxColour
* GetButtonColour() const { return NULL
; }
72 inline virtual void SetLabelFont(const wxFont
& font
);
73 inline virtual void SetButtonFont(const wxFont
& font
);
74 inline wxFont
& GetLabelFont() const;
75 inline wxFont
& GetButtonFont() const;
78 inline void Callback(const wxFunction function
);
80 wxFunction
GetCallback() { return m_callback
; }
83 wxFunction m_callback
; // Callback associated with the window
84 #endif // WXWIN_COMPATIBILITY
87 // For controls like radiobuttons which are really composite
88 wxArrayLong m_subControls
;
90 virtual wxSize
DoGetBestSize() const;
92 // create the control of the given class with the given style, returns FALSE
94 bool OS2CreateControl(const wxChar
*classname
, WXDWORD style
,
95 const wxPoint
& pos
= wxDefaultPosition
,
96 const wxSize
& size
= wxDefaultSize
,
97 const wxString
& label
= wxEmptyString
,
98 WXDWORD exstyle
= (WXDWORD
)-1);
100 // determine the extended styles combination for this window (may slightly
101 // modify styl parameter)
102 WXDWORD
GetExStyle(WXDWORD
& style
) const;
105 DECLARE_EVENT_TABLE()
109 #if WXWIN_COMPATIBILITY
110 inline void wxControl::Callback(const wxFunction f
) { m_callback
= f
; };
111 inline wxFont
& wxControl::GetLabelFont() const { return GetFont(); }
112 inline wxFont
& wxControl::GetButtonFont() const { return GetFont(); }
113 inline void wxControl::SetLabelFont(const wxFont
& font
) { SetFont(font
); }
114 inline void wxControl::SetButtonFont(const wxFont
& font
) { SetFont(font
); }
115 #endif // WXWIN_COMPATIBILITY