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