]>
Commit | Line | Data |
---|---|---|
ffecfa5a | 1 | ///////////////////////////////////////////////////////////////////////////// |
e1d63b79 | 2 | // Name: wx/palmos/control.h |
ffecfa5a | 3 | // Purpose: wxControl class |
e1d63b79 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
bdb54365 | 5 | // Modified by: Wlodzimierz ABX Skiba - native implementation |
ffecfa5a | 6 | // Created: 10/13/04 |
e1d63b79 | 7 | // RCS-ID: $Id$ |
bdb54365 | 8 | // Copyright: (c) William Osborne, Wlodzimierz Skiba |
ffecfa5a JS |
9 | // Licence: wxWindows licence |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_CONTROL_H_ | |
13 | #define _WX_CONTROL_H_ | |
14 | ||
15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
16 | #pragma interface "control.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/dynarray.h" | |
20 | ||
21 | // General item class | |
22 | class WXDLLEXPORT wxControl : public wxControlBase | |
23 | { | |
24 | public: | |
a152561c | 25 | wxControl() { Init(); } |
ffecfa5a JS |
26 | |
27 | wxControl(wxWindow *parent, wxWindowID id, | |
28 | const wxPoint& pos = wxDefaultPosition, | |
29 | const wxSize& size = wxDefaultSize, long style = 0, | |
30 | const wxValidator& validator = wxDefaultValidator, | |
31 | const wxString& name = wxControlNameStr) | |
32 | { | |
a152561c | 33 | Init(); |
ffecfa5a JS |
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 | ||
43 | virtual ~wxControl(); | |
44 | ||
45 | // Simulates an event | |
46 | virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } | |
47 | ||
db101bd3 WS |
48 | virtual bool Enable( bool enable = true ); |
49 | virtual bool IsEnabled() const; | |
50 | ||
51 | virtual bool Show( bool show = true ); | |
52 | virtual bool IsShown() const; | |
ffecfa5a | 53 | |
bdb54365 WS |
54 | virtual void SetLabel(const wxString& label); |
55 | virtual wxString GetLabel(); | |
56 | ||
ffecfa5a JS |
57 | // implementation from now on |
58 | // -------------------------- | |
59 | ||
60 | virtual wxVisualAttributes GetDefaultAttributes() const | |
61 | { | |
62 | return GetClassDefaultAttributes(GetWindowVariant()); | |
63 | } | |
64 | ||
65 | static wxVisualAttributes | |
66 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
67 | ||
68 | // Calls the callback and appropriate event handlers | |
69 | bool ProcessCommand(wxCommandEvent& event); | |
70 | ||
ffecfa5a JS |
71 | const wxArrayLong& GetSubcontrols() const { return m_subControls; } |
72 | ||
73 | void OnEraseBackground(wxEraseEvent& event); | |
74 | ||
ffecfa5a | 75 | protected: |
ba889513 | 76 | // regardless how deeply we are in wxWidgets hierarchy always get correct form |
20bc5ad8 WS |
77 | WXFORMPTR GetParentForm() const; |
78 | WXFORMPTR GetObjectFormIndex(uint16_t& index) const; | |
a152561c | 79 | void* GetObjectPtr() const; |
ba889513 | 80 | |
ffecfa5a JS |
81 | // choose the default border for this window |
82 | virtual wxBorder GetDefaultBorder() const; | |
83 | ||
ba889513 WS |
84 | // on/off-like controls |
85 | void SetBoolValue(bool value); | |
86 | bool GetBoolValue() const; | |
87 | void SetIntValue(int val); | |
88 | ||
a152561c WS |
89 | // native labels access |
90 | void SetFieldLabel(const wxString& label); | |
91 | void SetControlLabel(const wxString& label); | |
92 | wxString GetFieldLabel(); | |
93 | wxString GetControlLabel(); | |
94 | ||
ffecfa5a JS |
95 | // return default best size (doesn't really make any sense, override this) |
96 | virtual wxSize DoGetBestSize() const; | |
97 | ||
808e3bce WS |
98 | // getting and setting sizes |
99 | virtual void DoGetPosition( int *x, int *y ) const; | |
100 | virtual void DoGetSize( int *width, int *height ) const; | |
324eeecb | 101 | virtual void DoMoveWindow(int x, int y, int width, int height); |
808e3bce | 102 | |
db101bd3 | 103 | // create the control of the given ControlStyleType: this is typically called |
ffecfa5a JS |
104 | // from Create() method of the derived class passing its label, pos and |
105 | // size parameter (style parameter is not needed because m_windowStyle is | |
106 | // supposed to had been already set and so is used instead when this | |
107 | // function is called) | |
20bc5ad8 | 108 | bool PalmCreateControl(int palmStyle, |
db101bd3 WS |
109 | const wxString& label, |
110 | const wxPoint& pos, | |
a152561c | 111 | const wxSize& size, |
8be10866 | 112 | uint8_t groupID = 0); |
a152561c WS |
113 | inline bool IsPalmControl() const { return m_palmControl; } |
114 | ||
115 | bool PalmCreateField(const wxString& label, | |
116 | const wxPoint& pos, | |
117 | const wxSize& size, | |
118 | bool editable, | |
119 | bool underlined, | |
20bc5ad8 | 120 | int justification); |
a152561c | 121 | inline bool IsPalmField() const { return m_palmField; } |
ffecfa5a JS |
122 | |
123 | // this is a helper for the derived class GetClassDefaultAttributes() | |
124 | // implementation: it returns the right colours for the classes which | |
125 | // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of | |
126 | // being simple controls (such as wxButton, wxCheckBox, ...) | |
127 | static wxVisualAttributes | |
128 | GetCompositeControlsDefaultAttributes(wxWindowVariant variant); | |
129 | ||
130 | ||
131 | // for controls like radiobuttons which are really composite this array | |
132 | // holds the ids (not HWNDs!) of the sub controls | |
133 | wxArrayLong m_subControls; | |
134 | ||
11f4a344 WS |
135 | // m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc. |
136 | // We must ensure that it persists for as long as it is being displayed | |
137 | // (that is, for as long as the control is displayed or until we call | |
138 | // CtlSetLabel() with a new string), and we must free the string after | |
139 | // it is no longer in use (typically after the form containing the | |
140 | // control is freed). | |
141 | wxString m_label; | |
142 | ||
ffecfa5a | 143 | private: |
ba889513 | 144 | |
a152561c WS |
145 | bool m_palmControl:1; |
146 | bool m_palmField:1; | |
147 | ||
148 | // common part of all ctors | |
149 | void Init(); | |
150 | ||
20bc5ad8 WS |
151 | virtual void DoGetBounds( WXRECTANGLEPTR rect ) const; |
152 | virtual void DoSetBounds( WXRECTANGLEPTR rect ); | |
808e3bce | 153 | |
ffecfa5a JS |
154 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl) |
155 | DECLARE_EVENT_TABLE() | |
156 | }; | |
157 | ||
158 | #endif | |
159 | // _WX_CONTROL_H_ |