]>
Commit | Line | Data |
---|---|---|
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 | ||
19 | #include "wx/window.h" | |
20 | #include "wx/list.h" | |
2bda0e17 KB |
21 | |
22 | // General item class | |
341c92a8 | 23 | class WXDLLEXPORT wxControl : public wxWindow |
2bda0e17 | 24 | { |
341c92a8 VZ |
25 | DECLARE_ABSTRACT_CLASS(wxControl) |
26 | ||
2bda0e17 | 27 | public: |
341c92a8 VZ |
28 | wxControl(); |
29 | virtual ~wxControl(); | |
30 | ||
31 | // Simulates an event | |
42e69d6b | 32 | bool Command(wxCommandEvent& event) { return ProcessCommand(event); } |
2bda0e17 | 33 | |
42e69d6b VZ |
34 | // Calls the callback and appropriate event handlers |
35 | bool ProcessCommand(wxCommandEvent& event); | |
2bda0e17 KB |
36 | |
37 | // Places item in centre of panel - so can't be used BEFORE panel->Fit() | |
debe6624 | 38 | void Centre(int direction = wxHORIZONTAL); |
341c92a8 | 39 | |
2bda0e17 | 40 | // MSW-specific |
a23fd0e1 VZ |
41 | #ifdef __WIN95__ |
42 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); | |
43 | #endif // Win95 | |
2bda0e17 KB |
44 | |
45 | // For ownerdraw items | |
46 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
47 | virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
48 | ||
341c92a8 VZ |
49 | wxList& GetSubcontrols() { return m_subControls; } |
50 | ||
a23fd0e1 VZ |
51 | void OnEraseBackground(wxEraseEvent& event); |
52 | ||
42e69d6b VZ |
53 | #if WXWIN_COMPATIBILITY |
54 | virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { } | |
55 | wxColour* GetButtonColour() const { return NULL; } | |
56 | ||
57 | inline virtual void SetLabelFont(const wxFont& font); | |
58 | inline virtual void SetButtonFont(const wxFont& font); | |
59 | inline wxFont& GetLabelFont() const; | |
60 | inline wxFont& GetButtonFont() const; | |
61 | ||
62 | // Adds callback | |
63 | inline void Callback(const wxFunction function); | |
64 | ||
65 | wxFunction GetCallback() { return m_callback; } | |
66 | ||
2bda0e17 KB |
67 | protected: |
68 | wxFunction m_callback; // Callback associated with the window | |
42e69d6b VZ |
69 | #endif // WXWIN_COMPATIBILITY |
70 | ||
71 | protected: | |
72 | // For controls like radiobuttons which are really composite | |
73 | wxList m_subControls; | |
2bda0e17 | 74 | |
341c92a8 VZ |
75 | private: |
76 | DECLARE_EVENT_TABLE() | |
2bda0e17 KB |
77 | }; |
78 | ||
2bda0e17 KB |
79 | |
80 | #if WXWIN_COMPATIBILITY | |
42e69d6b | 81 | inline void wxControl::Callback(const wxFunction f) { m_callback = f; }; |
341c92a8 VZ |
82 | inline wxFont& wxControl::GetLabelFont() const { return GetFont() ; } |
83 | inline wxFont& wxControl::GetButtonFont() const { return GetFont() ; } | |
84 | inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); } | |
85 | inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); } | |
42e69d6b | 86 | #endif // WXWIN_COMPATIBILITY |
2bda0e17 KB |
87 | |
88 | #endif | |
bbcdf8bc | 89 | // _WX_CONTROL_H_ |