]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: control.h | |
3 | // Purpose: wxControl class | |
45fcbf3b | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
45fcbf3b | 6 | // Created: 09/17/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
45fcbf3b DW |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_CONTROL_H_ | |
13 | #define _WX_CONTROL_H_ | |
14 | ||
b2a81bd9 DW |
15 | #include "wx/dynarray.h" |
16 | ||
a5569657 DW |
17 | WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr; |
18 | ||
0e320a79 | 19 | // General item class |
45fcbf3b | 20 | class WXDLLEXPORT wxControl : public wxControlBase |
0e320a79 | 21 | { |
45fcbf3b DW |
22 | DECLARE_ABSTRACT_CLASS(wxControl) |
23 | ||
0e320a79 DW |
24 | public: |
25 | wxControl(); | |
a5569657 DW |
26 | wxControl(wxWindow *parent, |
27 | wxWindowID id, | |
28 | const wxPoint& pos = wxDefaultPosition, | |
29 | const wxSize& size = wxDefaultSize, | |
30 | long style = 0, | |
31 | #if wxUSE_VALIDATORS | |
32 | const wxValidator& validator = wxDefaultValidator, | |
33 | #endif | |
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, | |
42 | #if wxUSE_VALIDATORS | |
43 | const wxValidator& validator = wxDefaultValidator, | |
44 | #endif | |
45 | const wxString& name = wxControlNameStr); | |
46 | virtual ~wxControl(); | |
45fcbf3b DW |
47 | |
48 | // Simulates an event | |
49 | virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } | |
50 | ||
51 | // implementation from now on | |
52 | // -------------------------- | |
53 | ||
54 | // Calls the callback and appropriate event handlers | |
55 | bool ProcessCommand(wxCommandEvent& event); | |
56 | ||
57 | // OS2-specific | |
58 | virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); | |
59 | ||
60 | // For ownerdraw items | |
61 | virtual bool OS2OnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
62 | virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
63 | ||
f9380570 | 64 | wxArrayLong& GetSubcontrols() { return m_subControls; } |
45fcbf3b DW |
65 | |
66 | void OnEraseBackground(wxEraseEvent& event); | |
0e320a79 | 67 | |
45fcbf3b DW |
68 | #if WXWIN_COMPATIBILITY |
69 | virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { } | |
70 | wxColour* GetButtonColour() const { return NULL; } | |
0e320a79 | 71 | |
45fcbf3b DW |
72 | inline virtual void SetLabelFont(const wxFont& font); |
73 | inline virtual void SetButtonFont(const wxFont& font); | |
74 | inline wxFont& GetLabelFont() const; | |
75 | inline wxFont& GetButtonFont() const; | |
0e320a79 | 76 | |
45fcbf3b DW |
77 | // Adds callback |
78 | inline void Callback(const wxFunction function); | |
79 | ||
80 | wxFunction GetCallback() { return m_callback; } | |
0e320a79 DW |
81 | |
82 | protected: | |
83 | wxFunction m_callback; // Callback associated with the window | |
45fcbf3b DW |
84 | #endif // WXWIN_COMPATIBILITY |
85 | ||
86 | protected: | |
87 | // For controls like radiobuttons which are really composite | |
b2a81bd9 | 88 | wxArrayLong m_subControls; |
45fcbf3b | 89 | |
e78c4d50 | 90 | virtual wxSize DoGetBestSize() const; |
0e320a79 | 91 | |
45fcbf3b DW |
92 | // create the control of the given class with the given style, returns FALSE |
93 | // if creation failed | |
a5569657 DW |
94 | bool OS2CreateControl(const wxChar *classname, WXDWORD style, |
95 | const wxPoint& pos = wxDefaultPosition, | |
96 | const wxSize& size = wxDefaultSize, | |
97 | const wxString& label = wxEmptyString, | |
98 | WXDWORD exstyle = (WXDWORD)-1); | |
45fcbf3b DW |
99 | |
100 | // determine the extended styles combination for this window (may slightly | |
101 | // modify styl parameter) | |
102 | WXDWORD GetExStyle(WXDWORD& style) const; | |
103 | ||
104 | private: | |
105 | DECLARE_EVENT_TABLE() | |
0e320a79 DW |
106 | }; |
107 | ||
45fcbf3b DW |
108 | |
109 | #if WXWIN_COMPATIBILITY | |
110 | inline void wxControl::Callback(const wxFunction f) { m_callback = f; }; | |
111 | inline wxFont& wxControl::GetLabelFont() const { return GetFont(); } | |
112 | inline wxFont& wxControl::GetButtonFont() const { return GetFont(); } | |
113 | inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); } | |
114 | inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); } | |
115 | #endif // WXWIN_COMPATIBILITY | |
116 | ||
0e320a79 DW |
117 | #endif |
118 | // _WX_CONTROL_H_ |