]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/control.h
Halved DEFAULT_ITEM_WIDTH so default sizes resembles wxGTK better
[wxWidgets.git] / include / wx / msw / control.h
CommitLineData
2bda0e17
KB
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$
bbcdf8bc 8// Copyright: (c) Julian Smart
42e69d6b 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_CONTROL_H_
13#define _WX_CONTROL_H_
2bda0e17
KB
14
15#ifdef __GNUG__
341c92a8 16 #pragma interface "control.h"
2bda0e17
KB
17#endif
18
10a0bdb1
VZ
19#include "wx/dynarray.h"
20
8d772832
RD
21WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr;
22
2bda0e17 23// General item class
8d99be5f 24class WXDLLEXPORT wxControl : public wxControlBase
2bda0e17 25{
341c92a8
VZ
26 DECLARE_ABSTRACT_CLASS(wxControl)
27
2bda0e17 28public:
341c92a8 29 wxControl();
8d772832
RD
30 wxControl(wxWindow *parent, wxWindowID id,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize, long style = 0,
33#if wxUSE_VALIDATORS
34 const wxValidator& validator = wxDefaultValidator,
35#endif
36 const wxString& name = wxControlNameStr)
37 {
38 Create(parent, id, pos, size, style, validator, name);
39 }
40
41 bool Create(wxWindow *parent, wxWindowID id,
42 const wxPoint& pos = wxDefaultPosition,
43 const wxSize& size = wxDefaultSize, long style = 0,
44#if wxUSE_VALIDATORS
45 const wxValidator& validator = wxDefaultValidator,
46#endif
47 const wxString& name = wxControlNameStr);
48
49 virtual ~wxControl();
341c92a8
VZ
50
51 // Simulates an event
8d99be5f
VZ
52 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
53
54 // implementation from now on
55 // --------------------------
2bda0e17 56
42e69d6b
VZ
57 // Calls the callback and appropriate event handlers
58 bool ProcessCommand(wxCommandEvent& event);
2bda0e17 59
2bda0e17 60 // MSW-specific
a23fd0e1
VZ
61#ifdef __WIN95__
62 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
63#endif // Win95
2bda0e17
KB
64
65 // For ownerdraw items
66 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
67 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
68
f048e32f 69 wxArrayLong GetSubcontrols() { return m_subControls; }
341c92a8 70
a23fd0e1
VZ
71 void OnEraseBackground(wxEraseEvent& event);
72
f048e32f
VZ
73 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
74 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
75
42e69d6b
VZ
76#if WXWIN_COMPATIBILITY
77 virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
78 wxColour* GetButtonColour() const { return NULL; }
79
80 inline virtual void SetLabelFont(const wxFont& font);
81 inline virtual void SetButtonFont(const wxFont& font);
82 inline wxFont& GetLabelFont() const;
83 inline wxFont& GetButtonFont() const;
84
85 // Adds callback
86 inline void Callback(const wxFunction function);
87
88 wxFunction GetCallback() { return m_callback; }
89
2bda0e17
KB
90protected:
91 wxFunction m_callback; // Callback associated with the window
42e69d6b
VZ
92#endif // WXWIN_COMPATIBILITY
93
94protected:
f048e32f
VZ
95 // for controls like radiobuttons which are really composite this array
96 // holds the ids (not HWNDs!) of the sub controls
97 wxArrayLong m_subControls;
8d99be5f 98
f68586e5 99 virtual wxSize DoGetBestSize() const;
8d99be5f
VZ
100
101 // create the control of the given class with the given style, returns FALSE
102 // if creation failed
222594ea
VZ
103 //
104 // All parameters except classname and style are optional, if the
105 // size/position are not given, they should be set later with SetSize() and,
106 // label (the title of the window), of course, is left empty. The extended
107 // style is determined from the style and the app 3D settings automatically
108 // if it's not specified explicitly.
109 bool MSWCreateControl(const wxChar *classname,
110 WXDWORD style,
111 const wxPoint& pos = wxDefaultPosition,
112 const wxSize& size = wxDefaultSize,
113 const wxString& label = wxEmptyString,
114 WXDWORD exstyle = (WXDWORD)-1);
2bda0e17 115
8d99be5f 116 // determine the extended styles combination for this window (may slightly
3f2711d5
VZ
117 // modify style parameter, this is why it's non const)
118 WXDWORD GetExStyle(WXDWORD& style, bool *want3D) const;
4438caf4 119
341c92a8
VZ
120private:
121 DECLARE_EVENT_TABLE()
2bda0e17
KB
122};
123
2bda0e17
KB
124
125#if WXWIN_COMPATIBILITY
42e69d6b 126 inline void wxControl::Callback(const wxFunction f) { m_callback = f; };
8d99be5f
VZ
127 inline wxFont& wxControl::GetLabelFont() const { return GetFont(); }
128 inline wxFont& wxControl::GetButtonFont() const { return GetFont(); }
341c92a8
VZ
129 inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
130 inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
42e69d6b 131#endif // WXWIN_COMPATIBILITY
2bda0e17
KB
132
133#endif
bbcdf8bc 134 // _WX_CONTROL_H_