1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/control.h
3 // Purpose: wxControl class
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_CONTROL_H_
12 #define _WX_CONTROL_H_
14 #include "wx/dynarray.h"
17 class WXDLLIMPEXP_CORE wxControl
: public wxControlBase
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
)
28 Create(parent
, id
, pos
, size
, style
, validator
, name
);
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
);
39 virtual void Command(wxCommandEvent
& event
) { ProcessCommand(event
); }
42 // implementation from now on
43 // --------------------------
45 virtual wxVisualAttributes
GetDefaultAttributes() const
47 return GetClassDefaultAttributes(GetWindowVariant());
50 static wxVisualAttributes
51 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
53 // Calls the callback and appropriate event handlers
54 bool ProcessCommand(wxCommandEvent
& event
);
57 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
59 // For ownerdraw items
60 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT
*WXUNUSED(item
)) { return false; }
61 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*WXUNUSED(item
)) { return false; }
63 const wxArrayLong
& GetSubcontrols() const { return m_subControls
; }
65 // default handling of WM_CTLCOLORxxx: this is public so that wxWindow
67 virtual WXHBRUSH
MSWControlColor(WXHDC pDC
, WXHWND hWnd
);
69 // default style for the control include WS_TABSTOP if it AcceptsFocus()
70 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
73 // choose the default border for this window
74 virtual wxBorder
GetDefaultBorder() const;
76 // return default best size (doesn't really make any sense, override this)
77 virtual wxSize
DoGetBestSize() const;
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;
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
,
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.
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
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
,
110 const wxPoint
& pos
= wxDefaultPosition
,
111 const wxSize
& size
= wxDefaultSize
,
112 const wxString
& label
= wxEmptyString
,
113 WXDWORD exstyle
= (WXDWORD
)-1);
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
);
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
122 virtual WXHBRUSH
DoMSWControlColor(WXHDC pDC
, wxColour colBg
, WXHWND hWnd
);
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
;
129 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl
)
132 #endif // _WX_CONTROL_H_