]>
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 |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_CONTROL_H_ |
13 | #define _WX_CONTROL_H_ | |
2bda0e17 | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
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 | { |
2bda0e17 | 24 | public: |
34040e31 VZ |
25 | wxControl() { } |
26 | ||
fc7a2a60 VZ |
27 | wxControl(wxWindow *parent, wxWindowID id, |
28 | const wxPoint& pos = wxDefaultPosition, | |
29 | const wxSize& size = wxDefaultSize, long style = 0, | |
30 | const wxValidator& validator = wxDefaultValidator, | |
31 | const wxString& name = wxControlNameStr) | |
8d772832 RD |
32 | { |
33 | Create(parent, id, pos, size, style, validator, name); | |
34 | } | |
35 | ||
36 | bool Create(wxWindow *parent, wxWindowID id, | |
37 | const wxPoint& pos = wxDefaultPosition, | |
38 | const wxSize& size = wxDefaultSize, long style = 0, | |
8d772832 | 39 | const wxValidator& validator = wxDefaultValidator, |
8d772832 RD |
40 | const wxString& name = wxControlNameStr); |
41 | ||
42 | virtual ~wxControl(); | |
341c92a8 | 43 | |
479cd5de VZ |
44 | // Simulates an event |
45 | virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } | |
8d99be5f | 46 | |
34040e31 | 47 | |
479cd5de VZ |
48 | // implementation from now on |
49 | // -------------------------- | |
2bda0e17 | 50 | |
34040e31 VZ |
51 | virtual wxVisualAttributes GetDefaultAttributes() const |
52 | { | |
53 | return GetClassDefaultAttributes(GetWindowVariant()); | |
54 | } | |
55 | ||
56 | static wxVisualAttributes | |
57 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
58 | ||
479cd5de VZ |
59 | // Calls the callback and appropriate event handlers |
60 | bool ProcessCommand(wxCommandEvent& event); | |
2bda0e17 | 61 | |
479cd5de | 62 | // MSW-specific |
a23fd0e1 | 63 | #ifdef __WIN95__ |
479cd5de | 64 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
a23fd0e1 | 65 | #endif // Win95 |
2bda0e17 | 66 | |
479cd5de | 67 | // For ownerdraw items |
4bf45c9e WS |
68 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return false; }; |
69 | virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return false; }; | |
2bda0e17 | 70 | |
bf25c88b | 71 | const wxArrayLong& GetSubcontrols() const { return m_subControls; } |
341c92a8 | 72 | |
42e69d6b | 73 | protected: |
65bc172c VZ |
74 | // choose the default border for this window |
75 | virtual wxBorder GetDefaultBorder() const; | |
479cd5de | 76 | |
d41f7b20 | 77 | // return default best size (doesn't really make any sense, override this) |
479cd5de VZ |
78 | virtual wxSize DoGetBestSize() const; |
79 | ||
4bf45c9e WS |
80 | // This is a helper for all wxControls made with UPDOWN native control. |
81 | // In wxMSW it was only wxSpinCtrl derived from wxSpinButton but in | |
82 | // WinCE of Smartphones this happens also for native wxTextCtrl, | |
83 | // wxChoice and others. | |
84 | virtual wxSize GetBestSpinerSize(const bool is_vertical) const; | |
85 | ||
6dd16e4f VZ |
86 | // create the control of the given Windows class: this is typically called |
87 | // from Create() method of the derived class passing its label, pos and | |
88 | // size parameter (style parameter is not needed because m_windowStyle is | |
89 | // supposed to had been already set and so is used instead when this | |
90 | // function is called) | |
5b2f31eb VZ |
91 | bool MSWCreateControl(const wxChar *classname, |
92 | const wxString& label, | |
93 | const wxPoint& pos, | |
6dd16e4f | 94 | const wxSize& size); |
5b2f31eb VZ |
95 | |
96 | // NB: the method below is deprecated now, with MSWGetStyle() the method | |
97 | // above should be used instead! Once all the controls are updated to | |
98 | // implement MSWGetStyle() this version will disappear. | |
99 | // | |
b225f659 | 100 | // create the control of the given class with the given style (combination |
77ffb593 | 101 | // of WS_XXX flags, i.e. Windows style, not wxWidgets one), returns |
4bf45c9e | 102 | // false if creation failed |
479cd5de VZ |
103 | // |
104 | // All parameters except classname and style are optional, if the | |
b225f659 VZ |
105 | // size/position are not given, they should be set later with SetSize() |
106 | // and, label (the title of the window), of course, is left empty. The | |
107 | // extended style is determined from the style and the app 3D settings | |
108 | // automatically if it's not specified explicitly. | |
479cd5de | 109 | bool MSWCreateControl(const wxChar *classname, |
b225f659 VZ |
110 | WXDWORD style, |
111 | const wxPoint& pos = wxDefaultPosition, | |
112 | const wxSize& size = wxDefaultSize, | |
113 | const wxString& label = wxEmptyString, | |
2eb4c3aa | 114 | WXDWORD exstyle = (WXDWORD)-1); |
479cd5de | 115 | |
5b2f31eb VZ |
116 | // default style for the control include WS_TABSTOP if it AcceptsFocus() |
117 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
4438caf4 | 118 | |
a8da30af VZ |
119 | // default handling of WM_CTLCOLORxxx |
120 | virtual WXHBRUSH MSWControlColor(WXHDC pDC); | |
121 | ||
122 | // call this from the derived class MSWControlColor() if you want to show | |
123 | // the control greyed out | |
124 | WXHBRUSH MSWControlColorDisabled(WXHDC pDC); | |
125 | ||
126 | // call this from the derived class MSWControlColor() if you want to always | |
127 | // paint the background (as all opaque controls do) | |
128 | WXHBRUSH MSWControlColorSolid(WXHDC pDC) | |
129 | { | |
130 | return MSWControlColorSolid(pDC, GetBackgroundColour()); | |
131 | } | |
132 | ||
133 | // common part of the 3 methods above | |
134 | WXHBRUSH MSWControlColorSolid(WXHDC pDC, wxColour colBg); | |
135 | ||
d34e375c VZ |
136 | // another WM_CTLCOLOR-related function: override this to return the brush |
137 | // which should be used to paint the control background by default | |
138 | // | |
139 | // for most controls, the default behaviour of returning 0 and letting the | |
140 | // system do it is correct, but for some -- e.g. checkboxes -- we actually | |
141 | // have to return transparent brush from here to prevent the system from | |
142 | // overwriting background with solid colour | |
143 | virtual WXHBRUSH MSWGetDefaultBgBrush() { return 0; } | |
144 | ||
34040e31 VZ |
145 | // this is a helper for the derived class GetClassDefaultAttributes() |
146 | // implementation: it returns the right colours for the classes which | |
147 | // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of | |
148 | // being simple controls (such as wxButton, wxCheckBox, ...) | |
149 | static wxVisualAttributes | |
150 | GetCompositeControlsDefaultAttributes(wxWindowVariant variant); | |
151 | ||
65bc172c VZ |
152 | // for controls like radiobuttons which are really composite this array |
153 | // holds the ids (not HWNDs!) of the sub controls | |
154 | wxArrayLong m_subControls; | |
155 | ||
341c92a8 | 156 | private: |
fc7a2a60 | 157 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl) |
2bda0e17 KB |
158 | }; |
159 | ||
4bf45c9e | 160 | #endif // _WX_CONTROL_H_ |