]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/control.h
fixed wxALL_FILES definition in Unicode build
[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 #ifdef __GNUG__
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 DECLARE_ABSTRACT_CLASS(wxControl)
25
26 public:
27 wxControl();
28 wxControl(wxWindow *parent, wxWindowID id,
29 const wxPoint& pos = wxDefaultPosition,
30 const wxSize& size = wxDefaultSize, long style = 0,
31 const wxValidator& validator = wxDefaultValidator,
32 const wxString& name = wxControlNameStr)
33 {
34 Create(parent, id, pos, size, style, validator, name);
35 }
36
37 bool Create(wxWindow *parent, wxWindowID id,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize, long style = 0,
40 const wxValidator& validator = wxDefaultValidator,
41 const wxString& name = wxControlNameStr);
42
43 virtual ~wxControl();
44
45 // Simulates an event
46 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
47
48 // implementation from now on
49 // --------------------------
50
51 // Calls the callback and appropriate event handlers
52 bool ProcessCommand(wxCommandEvent& event);
53
54 // MSW-specific
55 #ifdef __WIN95__
56 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
57 #endif // Win95
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 wxArrayLong GetSubcontrols() { return m_subControls; }
64
65 void OnEraseBackground(wxEraseEvent& event);
66
67 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
68 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
69
70 #if WXWIN_COMPATIBILITY
71 virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
72 wxColour* GetButtonColour() const { return NULL; }
73
74 inline virtual void SetLabelFont(const wxFont& font);
75 inline virtual void SetButtonFont(const wxFont& font);
76 inline wxFont& GetLabelFont() const;
77 inline wxFont& GetButtonFont() const;
78
79 // Adds callback
80 inline void Callback(const wxFunction function);
81
82 wxFunction GetCallback() { return m_callback; }
83
84 protected:
85 wxFunction m_callback; // Callback associated with the window
86 #endif // WXWIN_COMPATIBILITY
87
88 protected:
89 // for controls like radiobuttons which are really composite this array
90 // holds the ids (not HWNDs!) of the sub controls
91 wxArrayLong m_subControls;
92
93 virtual wxSize DoGetBestSize() const;
94
95 // create the control of the given Window class
96 bool MSWCreateControl(const wxChar *classname,
97 const wxString& label,
98 const wxPoint& pos,
99 const wxSize& size,
100 long style);
101
102 // NB: the method below is deprecated now, with MSWGetStyle() the method
103 // above should be used instead! Once all the controls are updated to
104 // implement MSWGetStyle() this version will disappear.
105 //
106 // create the control of the given class with the given style (combination
107 // of WS_XXX flags, i.e. Windows style, not wxWindows one), returns
108 // FALSE if creation failed
109 //
110 // All parameters except classname and style are optional, if the
111 // size/position are not given, they should be set later with SetSize()
112 // and, label (the title of the window), of course, is left empty. The
113 // extended style is determined from the style and the app 3D settings
114 // automatically if it's not specified explicitly.
115 bool MSWCreateControl(const wxChar *classname,
116 WXDWORD style,
117 const wxPoint& pos = wxDefaultPosition,
118 const wxSize& size = wxDefaultSize,
119 const wxString& label = wxEmptyString,
120 WXDWORD exstyle = (WXDWORD)-1);
121
122 // default style for the control include WS_TABSTOP if it AcceptsFocus()
123 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
124
125 private:
126 DECLARE_EVENT_TABLE()
127 };
128
129
130 #if WXWIN_COMPATIBILITY
131 inline void wxControl::Callback(const wxFunction f) { m_callback = f; };
132 inline wxFont& wxControl::GetLabelFont() const { return (wxFont &)GetFont(); }
133 inline wxFont& wxControl::GetButtonFont() const { return (wxFont &)GetFont(); }
134 inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
135 inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
136 #endif // WXWIN_COMPATIBILITY
137
138 #endif
139 // _WX_CONTROL_H_