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