]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/control.h
Permission for flood-fill code clarified
[wxWidgets.git] / include / wx / msw / control.h
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$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CONTROL_H_
13 #define _WX_CONTROL_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "control.h"
17 #endif
18
19 #include "wx/dynarray.h"
20
21 // General item class
22 class WXDLLEXPORT wxControl : public wxControlBase
23 {
24 public:
25 wxControl() { }
26
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)
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,
39 const wxValidator& validator = wxDefaultValidator,
40 const wxString& name = wxControlNameStr);
41
42 virtual ~wxControl();
43
44 // Simulates an event
45 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
46
47
48 // implementation from now on
49 // --------------------------
50
51 virtual wxVisualAttributes GetDefaultAttributes() const
52 {
53 return GetClassDefaultAttributes(GetWindowVariant());
54 }
55
56 static wxVisualAttributes
57 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
58
59 // Calls the callback and appropriate event handlers
60 bool ProcessCommand(wxCommandEvent& event);
61
62 // MSW-specific
63 #ifdef __WIN95__
64 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
65 #endif // Win95
66
67 // For ownerdraw items
68 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return false; };
69 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return false; };
70
71 const wxArrayLong& GetSubcontrols() const { return m_subControls; }
72
73 // default handling of WM_CTLCOLORxxx: this is public so that wxWindow
74 // could call it
75 virtual WXHBRUSH MSWControlColor(WXHDC pDC, WXHWND hWnd);
76
77 protected:
78 // choose the default border for this window
79 virtual wxBorder GetDefaultBorder() const;
80
81 // return default best size (doesn't really make any sense, override this)
82 virtual wxSize DoGetBestSize() const;
83
84 // This is a helper for all wxControls made with UPDOWN native control.
85 // In wxMSW it was only wxSpinCtrl derived from wxSpinButton but in
86 // WinCE of Smartphones this happens also for native wxTextCtrl,
87 // wxChoice and others.
88 virtual wxSize GetBestSpinnerSize(const bool is_vertical) const;
89
90 // create the control of the given Windows class: this is typically called
91 // from Create() method of the derived class passing its label, pos and
92 // size parameter (style parameter is not needed because m_windowStyle is
93 // supposed to had been already set and so is used instead when this
94 // function is called)
95 bool MSWCreateControl(const wxChar *classname,
96 const wxString& label,
97 const wxPoint& pos,
98 const wxSize& size);
99
100 // NB: the method below is deprecated now, with MSWGetStyle() the method
101 // above should be used instead! Once all the controls are updated to
102 // implement MSWGetStyle() this version will disappear.
103 //
104 // create the control of the given class with the given style (combination
105 // of WS_XXX flags, i.e. Windows style, not wxWidgets one), returns
106 // false if creation failed
107 //
108 // All parameters except classname and style are optional, if the
109 // size/position are not given, they should be set later with SetSize()
110 // and, label (the title of the window), of course, is left empty. The
111 // extended style is determined from the style and the app 3D settings
112 // automatically if it's not specified explicitly.
113 bool MSWCreateControl(const wxChar *classname,
114 WXDWORD style,
115 const wxPoint& pos = wxDefaultPosition,
116 const wxSize& size = wxDefaultSize,
117 const wxString& label = wxEmptyString,
118 WXDWORD exstyle = (WXDWORD)-1);
119
120 // default style for the control include WS_TABSTOP if it AcceptsFocus()
121 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
122
123 // call this from the derived class MSWControlColor() if you want to show
124 // the control greyed out (and opaque)
125 WXHBRUSH MSWControlColorDisabled(WXHDC pDC);
126
127 // common part of the 3 functions above: pass wxNullColour to use the
128 // appropriate background colour (meaning ours or our parents) or a fixed
129 // one
130 virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd);
131
132 // this is a helper for the derived class GetClassDefaultAttributes()
133 // implementation: it returns the right colours for the classes which
134 // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
135 // being simple controls (such as wxButton, wxCheckBox, ...)
136 static wxVisualAttributes
137 GetCompositeControlsDefaultAttributes(wxWindowVariant variant);
138
139 // for controls like radiobuttons which are really composite this array
140 // holds the ids (not HWNDs!) of the sub controls
141 wxArrayLong m_subControls;
142
143 private:
144 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
145 };
146
147 #endif // _WX_CONTROL_H_