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