]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/control.h
More WinCE mods.
[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
2bda0e17 21// General item class
8d99be5f 22class WXDLLEXPORT wxControl : public wxControlBase
2bda0e17 23{
2bda0e17 24public:
341c92a8 25 wxControl();
8d772832
RD
26 wxControl(wxWindow *parent, wxWindowID id,
27 const wxPoint& pos = wxDefaultPosition,
28 const wxSize& size = wxDefaultSize, long style = 0,
8d772832 29 const wxValidator& validator = wxDefaultValidator,
8d772832
RD
30 const wxString& name = wxControlNameStr)
31 {
32 Create(parent, id, pos, size, style, validator, name);
33 }
34
35 bool Create(wxWindow *parent, wxWindowID id,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize, long style = 0,
8d772832 38 const wxValidator& validator = wxDefaultValidator,
8d772832
RD
39 const wxString& name = wxControlNameStr);
40
41 virtual ~wxControl();
341c92a8 42
479cd5de
VZ
43 // Simulates an event
44 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
8d99be5f 45
479cd5de
VZ
46 // implementation from now on
47 // --------------------------
2bda0e17 48
479cd5de
VZ
49 // Calls the callback and appropriate event handlers
50 bool ProcessCommand(wxCommandEvent& event);
2bda0e17 51
479cd5de 52 // MSW-specific
a23fd0e1 53#ifdef __WIN95__
479cd5de 54 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
a23fd0e1 55#endif // Win95
2bda0e17 56
479cd5de
VZ
57 // For ownerdraw items
58 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
59 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
2bda0e17 60
479cd5de 61 wxArrayLong GetSubcontrols() { return m_subControls; }
341c92a8 62
479cd5de 63 void OnEraseBackground(wxEraseEvent& event);
a23fd0e1 64
479cd5de
VZ
65 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
66 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
f048e32f 67
42e69d6b 68#if WXWIN_COMPATIBILITY
479cd5de
VZ
69 virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
70 wxColour* GetButtonColour() const { return NULL; }
42e69d6b 71
70dc287a
VZ
72 virtual void SetLabelFont(const wxFont& font);
73 virtual void SetButtonFont(const wxFont& font);
74 wxFont& GetLabelFont() const;
75 wxFont& GetButtonFont() const;
42e69d6b
VZ
76#endif // WXWIN_COMPATIBILITY
77
78protected:
65bc172c
VZ
79 // choose the default border for this window
80 virtual wxBorder GetDefaultBorder() const;
479cd5de
VZ
81
82 virtual wxSize DoGetBestSize() const;
83
6dd16e4f
VZ
84 // create the control of the given Windows class: this is typically called
85 // from Create() method of the derived class passing its label, pos and
86 // size parameter (style parameter is not needed because m_windowStyle is
87 // supposed to had been already set and so is used instead when this
88 // function is called)
5b2f31eb
VZ
89 bool MSWCreateControl(const wxChar *classname,
90 const wxString& label,
91 const wxPoint& pos,
6dd16e4f 92 const wxSize& size);
5b2f31eb
VZ
93
94 // NB: the method below is deprecated now, with MSWGetStyle() the method
95 // above should be used instead! Once all the controls are updated to
96 // implement MSWGetStyle() this version will disappear.
97 //
b225f659
VZ
98 // create the control of the given class with the given style (combination
99 // of WS_XXX flags, i.e. Windows style, not wxWindows one), returns
100 // FALSE if creation failed
479cd5de
VZ
101 //
102 // All parameters except classname and style are optional, if the
b225f659
VZ
103 // size/position are not given, they should be set later with SetSize()
104 // and, label (the title of the window), of course, is left empty. The
105 // extended style is determined from the style and the app 3D settings
106 // automatically if it's not specified explicitly.
479cd5de 107 bool MSWCreateControl(const wxChar *classname,
b225f659
VZ
108 WXDWORD style,
109 const wxPoint& pos = wxDefaultPosition,
110 const wxSize& size = wxDefaultSize,
111 const wxString& label = wxEmptyString,
2eb4c3aa 112 WXDWORD exstyle = (WXDWORD)-1);
479cd5de 113
5b2f31eb
VZ
114 // default style for the control include WS_TABSTOP if it AcceptsFocus()
115 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
4438caf4 116
65bc172c
VZ
117 // for controls like radiobuttons which are really composite this array
118 // holds the ids (not HWNDs!) of the sub controls
119 wxArrayLong m_subControls;
120
341c92a8 121private:
65bc172c 122 DECLARE_ABSTRACT_CLASS(wxControl)
479cd5de 123 DECLARE_EVENT_TABLE()
2bda0e17
KB
124};
125
2bda0e17
KB
126
127#if WXWIN_COMPATIBILITY
09b61d99
VZ
128 inline wxFont& wxControl::GetLabelFont() const { return (wxFont &)GetFont(); }
129 inline wxFont& wxControl::GetButtonFont() const { return (wxFont &)GetFont(); }
341c92a8
VZ
130 inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
131 inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
42e69d6b 132#endif // WXWIN_COMPATIBILITY
2bda0e17
KB
133
134#endif
bbcdf8bc 135 // _WX_CONTROL_H_