]>
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 | ||
0e320a79 | 17 | // General item class |
45fcbf3b | 18 | class WXDLLEXPORT wxControl : public wxControlBase |
0e320a79 | 19 | { |
45fcbf3b DW |
20 | DECLARE_ABSTRACT_CLASS(wxControl) |
21 | ||
0e320a79 DW |
22 | public: |
23 | wxControl(); | |
d608dde1 DW |
24 | wxControl( wxWindow* pParent |
25 | ,wxWindowID vId | |
26 | ,const wxPoint& rPos = wxDefaultPosition | |
27 | ,const wxSize& rSize = wxDefaultSize | |
28 | ,long lStyle = 0 | |
d608dde1 | 29 | ,const wxValidator& rValidator = wxDefaultValidator |
d608dde1 DW |
30 | ,const wxString& rsName = wxControlNameStr |
31 | ) | |
a5569657 | 32 | { |
d608dde1 DW |
33 | Create( pParent |
34 | ,vId | |
35 | ,rPos | |
36 | ,rSize | |
37 | ,lStyle | |
38 | ,rValidator | |
39 | ,rsName | |
40 | ); | |
a5569657 | 41 | } |
d608dde1 | 42 | virtual ~wxControl(); |
a5569657 | 43 | |
d608dde1 DW |
44 | bool Create( wxWindow* pParent |
45 | ,wxWindowID vId | |
46 | ,const wxPoint& rPos = wxDefaultPosition | |
47 | ,const wxSize& rSize = wxDefaultSize | |
48 | ,long lStyle = 0 | |
d608dde1 | 49 | ,const wxValidator& rValidator = wxDefaultValidator |
d608dde1 DW |
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; }; | |
f5ea767e | 72 | virtual long OS2OnMeasure(WXMEASUREITEMSTRUCT* WXUNUSED(pItem)) { return 0L; }; |
d608dde1 DW |
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 | ); | |
0e320a79 | 83 | |
45fcbf3b | 84 | #if WXWIN_COMPATIBILITY |
d608dde1 DW |
85 | virtual void SetButtonColour(const wxColour& WXUNUSED(rCol)) { } |
86 | wxColour* GetButtonColour(void) const { return NULL; } | |
0e320a79 | 87 | |
d608dde1 DW |
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; | |
45fcbf3b DW |
92 | #endif // WXWIN_COMPATIBILITY |
93 | ||
afa59b4e | 94 | public: |
d608dde1 DW |
95 | // |
96 | // For controls like radiobuttons which are really composite | |
97 | // | |
98 | wxArrayLong m_aSubControls; | |
99 | ||
100 | virtual wxSize DoGetBestSize(void) const; | |
101 | ||
b9b1d6c8 DW |
102 | // |
103 | // Create the control of the given PM class | |
104 | // | |
105 | bool OS2CreateControl( const wxChar* zClassname | |
106 | ,const wxString& rsLabel | |
107 | ,const wxPoint& rPos | |
108 | ,const wxSize& rSize | |
109 | ,long lStyle | |
fb49f3b3 | 110 | ); |
d608dde1 DW |
111 | // |
112 | // Create the control of the given class with the given style, returns FALSE | |
113 | // if creation failed. | |
114 | // | |
115 | bool OS2CreateControl( const wxChar* zClassname | |
116 | ,WXDWORD dwStyle | |
117 | ,const wxPoint& rPos = wxDefaultPosition | |
118 | ,const wxSize& rSize = wxDefaultSize | |
119 | ,const wxString& rsLabel = wxEmptyString | |
120 | ,WXDWORD dwExstyle = (WXDWORD)-1 | |
121 | ); | |
122 | ||
123 | // | |
b9b1d6c8 | 124 | // Default style for the control include WS_TABSTOP if it AcceptsFocus() |
d608dde1 | 125 | // |
b9b1d6c8 DW |
126 | virtual WXDWORD OS2GetStyle( long lStyle |
127 | ,WXDWORD* pdwExstyle | |
128 | ) const; | |
45fcbf3b | 129 | |
afa59b4e DW |
130 | inline int GetXComp(void) const {return m_nXComp;} |
131 | inline int GetYComp(void) const {return m_nYComp;} | |
132 | inline void SetXComp(const int nXComp) {m_nXComp = nXComp;} | |
133 | inline void SetYComp(const int nYComp) {m_nYComp = nYComp;} | |
134 | ||
45fcbf3b | 135 | private: |
afa59b4e DW |
136 | int m_nXComp; |
137 | int m_nYComp; | |
45fcbf3b | 138 | DECLARE_EVENT_TABLE() |
d608dde1 | 139 | }; // end of wxControl |
45fcbf3b DW |
140 | |
141 | #if WXWIN_COMPATIBILITY | |
d608dde1 DW |
142 | inline wxFont& wxControl::GetLabelFont(void) const { return GetFont(); } |
143 | inline wxFont& wxControl::GetButtonFont(void) const { return GetFont(); } | |
144 | inline void wxControl::SetLabelFont(const wxFont& rFont) { SetFont(rFont); } | |
145 | inline void wxControl::SetButtonFont(const wxFont& rFont) { SetFont(rFont); } | |
45fcbf3b DW |
146 | #endif // WXWIN_COMPATIBILITY |
147 | ||
d608dde1 DW |
148 | #endif // _WX_CONTROL_H_ |
149 |