]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/control.h
Get SetLabel working again for wxStaticText by overriding SetLabel so that we can...
[wxWidgets.git] / include / wx / msw / control.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/control.h
3 // Purpose: wxControl class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
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 WXDLLIMPEXP_CORE wxControl : public wxControlBase
19 {
20 public:
21 wxControl() { }
22
23 wxControl(wxWindow *parent, wxWindowID id,
24 const wxPoint& pos = wxDefaultPosition,
25 const wxSize& size = wxDefaultSize, long style = 0,
26 const wxValidator& validator = wxDefaultValidator,
27 const wxString& name = wxControlNameStr)
28 {
29 Create(parent, id, pos, size, style, validator, name);
30 }
31
32 bool Create(wxWindow *parent, wxWindowID id,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize, long style = 0,
35 const wxValidator& validator = wxDefaultValidator,
36 const wxString& name = wxControlNameStr);
37
38
39 // Simulates an event
40 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
41
42
43 // implementation from now on
44 // --------------------------
45
46 virtual wxVisualAttributes GetDefaultAttributes() const
47 {
48 return GetClassDefaultAttributes(GetWindowVariant());
49 }
50
51 static wxVisualAttributes
52 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
53
54 // Calls the callback and appropriate event handlers
55 bool ProcessCommand(wxCommandEvent& event);
56
57 // MSW-specific
58 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
59
60 // For ownerdraw items
61 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return false; }
62 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return false; }
63
64 const wxArrayLong& GetSubcontrols() const { return m_subControls; }
65
66 // default handling of WM_CTLCOLORxxx: this is public so that wxWindow
67 // could call it
68 virtual WXHBRUSH MSWControlColor(WXHDC pDC, WXHWND hWnd);
69
70 // default style for the control include WS_TABSTOP if it AcceptsFocus()
71 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
72
73 protected:
74 // choose the default border for this window
75 virtual wxBorder GetDefaultBorder() const;
76
77 // return default best size (doesn't really make any sense, override this)
78 virtual wxSize DoGetBestSize() const;
79
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 GetBestSpinnerSize(const bool is_vertical) const;
85
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)
91 bool MSWCreateControl(const wxChar *classname,
92 const wxString& label,
93 const wxPoint& pos,
94 const wxSize& size);
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 //
100 // create the control of the given class with the given style (combination
101 // of WS_XXX flags, i.e. Windows style, not wxWidgets one), returns
102 // false if creation failed
103 //
104 // All parameters except classname and style are optional, if the
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.
109 bool MSWCreateControl(const wxChar *classname,
110 WXDWORD style,
111 const wxPoint& pos = wxDefaultPosition,
112 const wxSize& size = wxDefaultSize,
113 const wxString& label = wxEmptyString,
114 WXDWORD exstyle = (WXDWORD)-1);
115
116 // call this from the derived class MSWControlColor() if you want to show
117 // the control greyed out (and opaque)
118 WXHBRUSH MSWControlColorDisabled(WXHDC pDC);
119
120 // common part of the 3 functions above: pass wxNullColour to use the
121 // appropriate background colour (meaning ours or our parents) or a fixed
122 // one
123 virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd);
124
125 // this is a helper for the derived class GetClassDefaultAttributes()
126 // implementation: it returns the right colours for the classes which
127 // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
128 // being simple controls (such as wxButton, wxCheckBox, ...)
129 static wxVisualAttributes
130 GetCompositeControlsDefaultAttributes(wxWindowVariant variant);
131
132 // for controls like radiobuttons which are really composite this array
133 // holds the ids (not HWNDs!) of the sub controls
134 wxArrayLong m_subControls;
135
136 private:
137 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
138 };
139
140 #endif // _WX_CONTROL_H_