]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: control.h | |
3 | // Purpose: wxControl class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_CONTROL_H_ | |
13 | #define _WX_CONTROL_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "control.h" | |
17 | #endif | |
18 | ||
19 | WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr; | |
20 | ||
21 | // General item class | |
22 | class WXDLLEXPORT wxControl : public wxControlBase | |
23 | { | |
24 | DECLARE_ABSTRACT_CLASS(wxControl) | |
25 | ||
26 | public: | |
27 | wxControl(); | |
28 | wxControl(wxWindow *parent, wxWindowID id, | |
29 | const wxPoint& pos = wxDefaultPosition, | |
30 | const wxSize& size = wxDefaultSize, long style = 0, | |
31 | const wxValidator& validator = wxDefaultValidator, | |
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 | const wxValidator& validator = wxDefaultValidator, | |
41 | const wxString& name = wxControlNameStr); | |
42 | virtual ~wxControl(); | |
43 | ||
44 | // Simulates an event | |
45 | virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } | |
46 | ||
47 | // implementation from now on | |
48 | // -------------------------- | |
49 | ||
50 | // Calls the callback and appropriate event handlers | |
51 | bool ProcessCommand(wxCommandEvent& event); | |
52 | virtual void SetLabel(const wxString& title) ; | |
53 | ||
54 | wxList& GetSubcontrols() { return m_subControls; } | |
55 | ||
56 | void OnEraseBackground(wxEraseEvent& event); | |
57 | ||
58 | virtual bool Enable(bool enabled) ; | |
59 | virtual bool Show(bool show) ; | |
60 | ||
61 | virtual void MacRedrawControl () ; | |
62 | virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; | |
63 | virtual void MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label , | |
64 | const wxPoint& pos, | |
65 | const wxSize& size, long style, | |
66 | const wxValidator& validator, | |
67 | const wxString& name , Rect *outBounds , StringPtr maclabel ) ; | |
68 | virtual void MacPostControlCreate() ; | |
69 | virtual void MacAdjustControlRect() ; | |
70 | virtual ControlHandle MacGetContainerForEmbedding() ; | |
71 | virtual void MacSuperChangedPosition() ; | |
72 | virtual void MacSuperEnabled( bool enabled ) ; | |
73 | virtual void MacSuperShown( bool show ) ; | |
74 | virtual bool MacCanFocus() const ; | |
75 | ||
76 | virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags ) ; | |
77 | virtual void OnKeyDown( wxKeyEvent &event ) ; | |
78 | virtual void OnMouseEvent( wxMouseEvent &event ) ; | |
79 | virtual void OnPaint(wxPaintEvent& event) ; | |
80 | virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL) ; | |
81 | ControlHandle GetMacControl() { return m_macControl ;} | |
82 | ||
83 | #if WXWIN_COMPATIBILITY | |
84 | virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { } | |
85 | wxColour* GetButtonColour() const { return NULL; } | |
86 | ||
87 | inline virtual void SetLabelFont(const wxFont& font); | |
88 | inline virtual void SetButtonFont(const wxFont& font); | |
89 | inline wxFont& GetLabelFont() const; | |
90 | inline wxFont& GetButtonFont() const; | |
91 | ||
92 | // Adds callback | |
93 | inline void Callback(const wxFunction function); | |
94 | ||
95 | wxFunction GetCallback() { return m_callback; } | |
96 | ||
97 | protected: | |
98 | wxFunction m_callback; // Callback associated with the window | |
99 | #endif // WXWIN_COMPATIBILITY | |
100 | ||
101 | protected: | |
102 | // For controls like radiobuttons which are really composite | |
103 | ControlHandle m_macControl ; | |
104 | wxList m_subControls; | |
105 | int m_macHorizontalBorder ; | |
106 | int m_macVerticalBorder ; | |
107 | ||
108 | virtual wxSize DoGetBestSize() const; | |
109 | ||
110 | private: | |
111 | DECLARE_EVENT_TABLE() | |
112 | }; | |
113 | ||
114 | ||
115 | #if WXWIN_COMPATIBILITY | |
116 | inline void wxControl::Callback(const wxFunction f) { m_callback = f; }; | |
117 | inline wxFont& wxControl::GetLabelFont() const { return GetFont(); } | |
118 | inline wxFont& wxControl::GetButtonFont() const { return GetFont(); } | |
119 | inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); } | |
120 | inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); } | |
121 | #endif // WXWIN_COMPATIBILITY | |
122 | ||
123 | wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ; | |
124 | void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control) ; | |
125 | void wxRemoveMacControlAssociation(wxControl *control) ; | |
126 | ||
127 | #endif | |
128 | // _WX_CONTROL_H_ |