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