]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/control.h
Implementing some more controls and an MDI child frame fix for wxFrame.
[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 #include "wx/dynarray.h"
16
17 WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr;
18
19 // General item class
20 class WXDLLEXPORT wxControl : public wxControlBase
21 {
22 DECLARE_ABSTRACT_CLASS(wxControl)
23
24 public:
25 wxControl();
26 wxControl( wxWindow* pParent
27 ,wxWindowID vId
28 ,const wxPoint& rPos = wxDefaultPosition
29 ,const wxSize& rSize = wxDefaultSize
30 ,long lStyle = 0
31 #if wxUSE_VALIDATORS
32 ,const wxValidator& rValidator = wxDefaultValidator
33 #endif
34 ,const wxString& rsName = wxControlNameStr
35 )
36 {
37 Create( pParent
38 ,vId
39 ,rPos
40 ,rSize
41 ,lStyle
42 ,rValidator
43 ,rsName
44 );
45 }
46 virtual ~wxControl();
47
48 bool Create( wxWindow* pParent
49 ,wxWindowID vId
50 ,const wxPoint& rPos = wxDefaultPosition
51 ,const wxSize& rSize = wxDefaultSize
52 ,long lStyle = 0
53 #if wxUSE_VALIDATORS
54 ,const wxValidator& rValidator = wxDefaultValidator
55 #endif
56 ,const wxString& rsName = wxControlNameStr
57 );
58
59 //
60 // Simulates an event
61 //
62 virtual void Command(wxCommandEvent& rEvent) { ProcessCommand(rEvent); }
63
64 //
65 // Implementation from now on
66 // --------------------------
67 //
68
69 //
70 // Calls the callback and appropriate event handlers
71 //
72 bool ProcessCommand(wxCommandEvent& rEvent);
73
74 //
75 // For ownerdraw items
76 //
77 virtual bool OS2OnDraw(WXDRAWITEMSTRUCT* WXUNUSED(pItem)) { return FALSE; };
78 virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT* WXUNUSED(pItem)) { return FALSE; };
79
80 wxArrayLong& GetSubcontrols() { return m_aSubControls; }
81 void OnEraseBackground(wxEraseEvent& rEvent);
82 virtual WXHBRUSH OnCtlColor( WXHDC hDC
83 ,WXHWND pWnd
84 ,WXUINT nCtlColor
85 ,WXUINT uMessage
86 ,WXWPARAM wParam
87 ,WXLPARAM lParam
88 );
89
90 #if WXWIN_COMPATIBILITY
91 virtual void SetButtonColour(const wxColour& WXUNUSED(rCol)) { }
92 wxColour* GetButtonColour(void) const { return NULL; }
93
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;
98
99 //
100 // Adds callback
101 //
102 inline void Callback(const wxFunction function);
103 wxFunction GetCallback(void) { return m_callback; }
104
105 protected:
106 wxFunction m_callback; // Callback associated with the window
107 #endif // WXWIN_COMPATIBILITY
108
109 public:
110 //
111 // For controls like radiobuttons which are really composite
112 //
113 wxArrayLong m_aSubControls;
114
115 virtual wxSize DoGetBestSize(void) const;
116
117 bool OS2CreateControl( wxWindow* pParent
118 ,wxWindowID lId
119 ,const wxPoint& rPos
120 ,const wxSize& rSize
121 ,long lStyle
122 #if wxUSE_VALIDATORS
123 ,const wxValidator& rValidator
124 #endif
125 ,const wxString& rsName
126 );
127 //
128 // Create the control of the given class with the given style, returns FALSE
129 // if creation failed.
130 //
131 bool OS2CreateControl( const wxChar* zClassname
132 ,WXDWORD dwStyle
133 ,const wxPoint& rPos = wxDefaultPosition
134 ,const wxSize& rSize = wxDefaultSize
135 ,const wxString& rsLabel = wxEmptyString
136 ,WXDWORD dwExstyle = (WXDWORD)-1
137 );
138
139 //
140 // Determine the extended styles combination for this window (may slightly
141 // modify styl parameter)
142 //
143 WXDWORD GetExStyle(WXDWORD& rStyle) const;
144
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;}
149
150 private:
151 int m_nXComp;
152 int m_nYComp;
153 DECLARE_EVENT_TABLE()
154 }; // end of wxControl
155
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
163
164 #endif // _WX_CONTROL_H_
165