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