]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/control.h
Simplified sizing code. Sub-windows are now sized explicitly in wxGrid::CalcWindowSi...
[wxWidgets.git] / include / wx / os2 / control.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.h
3 // Purpose: wxControl class
4 // Author: David Webster
5 // Modified by:
6 // Created: 09/17/99
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CONTROL_H_
13 #define _WX_CONTROL_H_
14
15 WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr;
16
17 // General item class
18 class WXDLLEXPORT wxControl : public wxControlBase
19 {
20 DECLARE_ABSTRACT_CLASS(wxControl)
21
22 public:
23 wxControl();
24 wxControl(wxWindow *parent,
25 wxWindowID id,
26 const wxPoint& pos = wxDefaultPosition,
27 const wxSize& size = wxDefaultSize,
28 long style = 0,
29 #if wxUSE_VALIDATORS
30 const wxValidator& validator = wxDefaultValidator,
31 #endif
32 const wxString& name = wxControlNameStr)
33 {
34 Create(parent, id, pos, size, style, validator, name);
35 }
36
37 bool Create(wxWindow *parent, wxWindowID id,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize, long style = 0,
40 #if wxUSE_VALIDATORS
41 const wxValidator& validator = wxDefaultValidator,
42 #endif
43 const wxString& name = wxControlNameStr);
44 virtual ~wxControl();
45
46 // Simulates an event
47 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
48
49 // implementation from now on
50 // --------------------------
51
52 // Calls the callback and appropriate event handlers
53 bool ProcessCommand(wxCommandEvent& event);
54
55 // OS2-specific
56 virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
57
58 // For ownerdraw items
59 virtual bool OS2OnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
60 virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
61
62 wxList& GetSubcontrols() { return m_subControls; }
63
64 void OnEraseBackground(wxEraseEvent& event);
65
66 #if WXWIN_COMPATIBILITY
67 virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
68 wxColour* GetButtonColour() const { return NULL; }
69
70 inline virtual void SetLabelFont(const wxFont& font);
71 inline virtual void SetButtonFont(const wxFont& font);
72 inline wxFont& GetLabelFont() const;
73 inline wxFont& GetButtonFont() const;
74
75 // Adds callback
76 inline void Callback(const wxFunction function);
77
78 wxFunction GetCallback() { return m_callback; }
79
80 protected:
81 wxFunction m_callback; // Callback associated with the window
82 #endif // WXWIN_COMPATIBILITY
83
84 protected:
85 // For controls like radiobuttons which are really composite
86 wxList m_subControls;
87
88 virtual wxSize DoGetBestSize() const;
89
90 // create the control of the given class with the given style, returns FALSE
91 // if creation failed
92 bool OS2CreateControl(const wxChar *classname, WXDWORD style,
93 const wxPoint& pos = wxDefaultPosition,
94 const wxSize& size = wxDefaultSize,
95 const wxString& label = wxEmptyString,
96 WXDWORD exstyle = (WXDWORD)-1);
97
98 // determine the extended styles combination for this window (may slightly
99 // modify styl parameter)
100 WXDWORD GetExStyle(WXDWORD& style) const;
101
102 private:
103 DECLARE_EVENT_TABLE()
104 };
105
106
107 #if WXWIN_COMPATIBILITY
108 inline void wxControl::Callback(const wxFunction f) { m_callback = f; };
109 inline wxFont& wxControl::GetLabelFont() const { return GetFont(); }
110 inline wxFont& wxControl::GetButtonFont() const { return GetFont(); }
111 inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
112 inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
113 #endif // WXWIN_COMPATIBILITY
114
115 #endif
116 // _WX_CONTROL_H_