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