]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: control.h | |
3 | // Purpose: wxControl class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
42e69d6b | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_CONTROL_H_ |
13 | #define _WX_CONTROL_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
341c92a8 | 16 | #pragma interface "control.h" |
2bda0e17 KB |
17 | #endif |
18 | ||
10a0bdb1 VZ |
19 | #include "wx/dynarray.h" |
20 | ||
2bda0e17 | 21 | // General item class |
8d99be5f | 22 | class WXDLLEXPORT wxControl : public wxControlBase |
2bda0e17 | 23 | { |
341c92a8 VZ |
24 | DECLARE_ABSTRACT_CLASS(wxControl) |
25 | ||
2bda0e17 | 26 | public: |
341c92a8 | 27 | wxControl(); |
8d772832 RD |
28 | wxControl(wxWindow *parent, wxWindowID id, |
29 | const wxPoint& pos = wxDefaultPosition, | |
30 | const wxSize& size = wxDefaultSize, long style = 0, | |
8d772832 | 31 | const wxValidator& validator = wxDefaultValidator, |
8d772832 RD |
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, | |
8d772832 | 40 | const wxValidator& validator = wxDefaultValidator, |
8d772832 RD |
41 | const wxString& name = wxControlNameStr); |
42 | ||
43 | virtual ~wxControl(); | |
341c92a8 | 44 | |
479cd5de VZ |
45 | // Simulates an event |
46 | virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } | |
8d99be5f | 47 | |
479cd5de VZ |
48 | // implementation from now on |
49 | // -------------------------- | |
2bda0e17 | 50 | |
479cd5de VZ |
51 | // Calls the callback and appropriate event handlers |
52 | bool ProcessCommand(wxCommandEvent& event); | |
2bda0e17 | 53 | |
479cd5de | 54 | // MSW-specific |
a23fd0e1 | 55 | #ifdef __WIN95__ |
479cd5de | 56 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
a23fd0e1 | 57 | #endif // Win95 |
2bda0e17 | 58 | |
479cd5de VZ |
59 | // For ownerdraw items |
60 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
61 | virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
2bda0e17 | 62 | |
479cd5de | 63 | wxArrayLong GetSubcontrols() { return m_subControls; } |
341c92a8 | 64 | |
479cd5de | 65 | void OnEraseBackground(wxEraseEvent& event); |
a23fd0e1 | 66 | |
479cd5de VZ |
67 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
68 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
f048e32f | 69 | |
42e69d6b | 70 | #if WXWIN_COMPATIBILITY |
479cd5de VZ |
71 | virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { } |
72 | wxColour* GetButtonColour() const { return NULL; } | |
42e69d6b | 73 | |
70dc287a VZ |
74 | virtual void SetLabelFont(const wxFont& font); |
75 | virtual void SetButtonFont(const wxFont& font); | |
76 | wxFont& GetLabelFont() const; | |
77 | wxFont& GetButtonFont() const; | |
42e69d6b VZ |
78 | #endif // WXWIN_COMPATIBILITY |
79 | ||
80 | protected: | |
479cd5de VZ |
81 | // for controls like radiobuttons which are really composite this array |
82 | // holds the ids (not HWNDs!) of the sub controls | |
83 | wxArrayLong m_subControls; | |
84 | ||
85 | virtual wxSize DoGetBestSize() const; | |
86 | ||
6dd16e4f VZ |
87 | // create the control of the given Windows class: this is typically called |
88 | // from Create() method of the derived class passing its label, pos and | |
89 | // size parameter (style parameter is not needed because m_windowStyle is | |
90 | // supposed to had been already set and so is used instead when this | |
91 | // function is called) | |
5b2f31eb VZ |
92 | bool MSWCreateControl(const wxChar *classname, |
93 | const wxString& label, | |
94 | const wxPoint& pos, | |
6dd16e4f | 95 | const wxSize& size); |
5b2f31eb VZ |
96 | |
97 | // NB: the method below is deprecated now, with MSWGetStyle() the method | |
98 | // above should be used instead! Once all the controls are updated to | |
99 | // implement MSWGetStyle() this version will disappear. | |
100 | // | |
b225f659 VZ |
101 | // create the control of the given class with the given style (combination |
102 | // of WS_XXX flags, i.e. Windows style, not wxWindows one), returns | |
103 | // FALSE if creation failed | |
479cd5de VZ |
104 | // |
105 | // All parameters except classname and style are optional, if the | |
b225f659 VZ |
106 | // size/position are not given, they should be set later with SetSize() |
107 | // and, label (the title of the window), of course, is left empty. The | |
108 | // extended style is determined from the style and the app 3D settings | |
109 | // automatically if it's not specified explicitly. | |
479cd5de | 110 | bool MSWCreateControl(const wxChar *classname, |
b225f659 VZ |
111 | WXDWORD style, |
112 | const wxPoint& pos = wxDefaultPosition, | |
113 | const wxSize& size = wxDefaultSize, | |
114 | const wxString& label = wxEmptyString, | |
2eb4c3aa | 115 | WXDWORD exstyle = (WXDWORD)-1); |
479cd5de | 116 | |
5b2f31eb VZ |
117 | // default style for the control include WS_TABSTOP if it AcceptsFocus() |
118 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
4438caf4 | 119 | |
341c92a8 | 120 | private: |
479cd5de | 121 | DECLARE_EVENT_TABLE() |
2bda0e17 KB |
122 | }; |
123 | ||
2bda0e17 KB |
124 | |
125 | #if WXWIN_COMPATIBILITY | |
09b61d99 VZ |
126 | inline wxFont& wxControl::GetLabelFont() const { return (wxFont &)GetFont(); } |
127 | inline wxFont& wxControl::GetButtonFont() const { return (wxFont &)GetFont(); } | |
341c92a8 VZ |
128 | inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); } |
129 | inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); } | |
42e69d6b | 130 | #endif // WXWIN_COMPATIBILITY |
2bda0e17 KB |
131 | |
132 | #endif | |
bbcdf8bc | 133 | // _WX_CONTROL_H_ |