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