]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: control.h | |
3 | // Purpose: wxControl class | |
45fcbf3b | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
45fcbf3b | 6 | // Created: 09/17/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
45fcbf3b DW |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_CONTROL_H_ | |
13 | #define _WX_CONTROL_H_ | |
14 | ||
b2a81bd9 DW |
15 | #include "wx/dynarray.h" |
16 | ||
a5569657 DW |
17 | WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr; |
18 | ||
0e320a79 | 19 | // General item class |
45fcbf3b | 20 | class WXDLLEXPORT wxControl : public wxControlBase |
0e320a79 | 21 | { |
45fcbf3b DW |
22 | DECLARE_ABSTRACT_CLASS(wxControl) |
23 | ||
0e320a79 DW |
24 | public: |
25 | wxControl(); | |
d608dde1 DW |
26 | wxControl( wxWindow* pParent |
27 | ,wxWindowID vId | |
28 | ,const wxPoint& rPos = wxDefaultPosition | |
29 | ,const wxSize& rSize = wxDefaultSize | |
30 | ,long lStyle = 0 | |
a5569657 | 31 | #if wxUSE_VALIDATORS |
d608dde1 | 32 | ,const wxValidator& rValidator = wxDefaultValidator |
a5569657 | 33 | #endif |
d608dde1 DW |
34 | ,const wxString& rsName = wxControlNameStr |
35 | ) | |
a5569657 | 36 | { |
d608dde1 DW |
37 | Create( pParent |
38 | ,vId | |
39 | ,rPos | |
40 | ,rSize | |
41 | ,lStyle | |
42 | ,rValidator | |
43 | ,rsName | |
44 | ); | |
a5569657 | 45 | } |
d608dde1 | 46 | virtual ~wxControl(); |
a5569657 | 47 | |
d608dde1 DW |
48 | bool Create( wxWindow* pParent |
49 | ,wxWindowID vId | |
50 | ,const wxPoint& rPos = wxDefaultPosition | |
51 | ,const wxSize& rSize = wxDefaultSize | |
52 | ,long lStyle = 0 | |
a5569657 | 53 | #if wxUSE_VALIDATORS |
d608dde1 | 54 | ,const wxValidator& rValidator = wxDefaultValidator |
a5569657 | 55 | #endif |
d608dde1 DW |
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 | ); | |
0e320a79 | 89 | |
45fcbf3b | 90 | #if WXWIN_COMPATIBILITY |
d608dde1 DW |
91 | virtual void SetButtonColour(const wxColour& WXUNUSED(rCol)) { } |
92 | wxColour* GetButtonColour(void) const { return NULL; } | |
0e320a79 | 93 | |
d608dde1 DW |
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; | |
45fcbf3b | 98 | |
d608dde1 DW |
99 | // |
100 | // Adds callback | |
101 | // | |
102 | inline void Callback(const wxFunction function); | |
103 | wxFunction GetCallback(void) { return m_callback; } | |
0e320a79 DW |
104 | |
105 | protected: | |
d608dde1 | 106 | wxFunction m_callback; // Callback associated with the window |
45fcbf3b DW |
107 | #endif // WXWIN_COMPATIBILITY |
108 | ||
afa59b4e | 109 | public: |
d608dde1 DW |
110 | // |
111 | // For controls like radiobuttons which are really composite | |
112 | // | |
113 | wxArrayLong m_aSubControls; | |
114 | ||
115 | virtual wxSize DoGetBestSize(void) const; | |
116 | ||
fb49f3b3 DW |
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 | ); | |
d608dde1 DW |
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; | |
45fcbf3b | 144 | |
afa59b4e DW |
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 | ||
45fcbf3b | 150 | private: |
afa59b4e DW |
151 | int m_nXComp; |
152 | int m_nYComp; | |
45fcbf3b | 153 | DECLARE_EVENT_TABLE() |
d608dde1 | 154 | }; // end of wxControl |
45fcbf3b DW |
155 | |
156 | #if WXWIN_COMPATIBILITY | |
157 | inline void wxControl::Callback(const wxFunction f) { m_callback = f; }; | |
d608dde1 DW |
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); } | |
45fcbf3b DW |
162 | #endif // WXWIN_COMPATIBILITY |
163 | ||
d608dde1 DW |
164 | #endif // _WX_CONTROL_H_ |
165 |