1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CONTROL_H_
13 #define _WX_CONTROL_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "control.h"
19 #include "wx/dynarray.h"
22 class WXDLLEXPORT wxControl
: public wxControlBase
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
)
33 Create(parent
, id
, pos
, size
, style
, validator
, name
);
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
);
45 virtual void Command(wxCommandEvent
& event
) { ProcessCommand(event
); }
48 // implementation from now on
49 // --------------------------
51 virtual wxVisualAttributes
GetDefaultAttributes() const
53 return GetClassDefaultAttributes(GetWindowVariant());
56 static wxVisualAttributes
57 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
59 // Calls the callback and appropriate event handlers
60 bool ProcessCommand(wxCommandEvent
& event
);
64 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
67 // For ownerdraw items
68 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT
*WXUNUSED(item
)) { return false; };
69 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*WXUNUSED(item
)) { return false; };
71 const wxArrayLong
& GetSubcontrols() const { return m_subControls
; }
73 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
74 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
77 // choose the default border for this window
78 virtual wxBorder
GetDefaultBorder() const;
80 // return default best size (doesn't really make any sense, override this)
81 virtual wxSize
DoGetBestSize() const;
83 // This is a helper for all wxControls made with UPDOWN native control.
84 // In wxMSW it was only wxSpinCtrl derived from wxSpinButton but in
85 // WinCE of Smartphones this happens also for native wxTextCtrl,
86 // wxChoice and others.
87 virtual wxSize
GetBestSpinerSize(const bool is_vertical
) const;
89 // create the control of the given Windows class: this is typically called
90 // from Create() method of the derived class passing its label, pos and
91 // size parameter (style parameter is not needed because m_windowStyle is
92 // supposed to had been already set and so is used instead when this
93 // function is called)
94 bool MSWCreateControl(const wxChar
*classname
,
95 const wxString
& label
,
99 // NB: the method below is deprecated now, with MSWGetStyle() the method
100 // above should be used instead! Once all the controls are updated to
101 // implement MSWGetStyle() this version will disappear.
103 // create the control of the given class with the given style (combination
104 // of WS_XXX flags, i.e. Windows style, not wxWidgets one), returns
105 // false if creation failed
107 // All parameters except classname and style are optional, if the
108 // size/position are not given, they should be set later with SetSize()
109 // and, label (the title of the window), of course, is left empty. The
110 // extended style is determined from the style and the app 3D settings
111 // automatically if it's not specified explicitly.
112 bool MSWCreateControl(const wxChar
*classname
,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
,
116 const wxString
& label
= wxEmptyString
,
117 WXDWORD exstyle
= (WXDWORD
)-1);
119 // default style for the control include WS_TABSTOP if it AcceptsFocus()
120 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
122 // this is a helper for the derived class GetClassDefaultAttributes()
123 // implementation: it returns the right colours for the classes which
124 // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
125 // being simple controls (such as wxButton, wxCheckBox, ...)
126 static wxVisualAttributes
127 GetCompositeControlsDefaultAttributes(wxWindowVariant variant
);
129 // for controls like radiobuttons which are really composite this array
130 // holds the ids (not HWNDs!) of the sub controls
131 wxArrayLong m_subControls
;
134 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl
)
137 #endif // _WX_CONTROL_H_