]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/control.cpp
Native PalmOS wxControl and wxButton implementation. wxTLW without fixed size. Unused...
[wxWidgets.git] / src / palmos / control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/control.cpp
3 // Purpose: wxControl class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "control.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #if wxUSE_CONTROLS
32
33 #ifndef WX_PRECOMP
34 #include "wx/event.h"
35 #include "wx/app.h"
36 #include "wx/dcclient.h"
37 #include "wx/log.h"
38 #include "wx/settings.h"
39 #endif
40
41 #include "wx/control.h"
42
43 // ----------------------------------------------------------------------------
44 // wxWin macros
45 // ----------------------------------------------------------------------------
46
47 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
48
49 BEGIN_EVENT_TABLE(wxControl, wxWindow)
50 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground)
51 END_EVENT_TABLE()
52
53 // ============================================================================
54 // wxControl implementation
55 // ============================================================================
56
57 // ----------------------------------------------------------------------------
58 // wxControl ctor/dtor
59 // ----------------------------------------------------------------------------
60
61 wxControl::~wxControl()
62 {
63 m_isBeingDeleted = true;
64 }
65
66 // ----------------------------------------------------------------------------
67 // control window creation
68 // ----------------------------------------------------------------------------
69
70 bool wxControl::Create(wxWindow *parent,
71 wxWindowID id,
72 const wxPoint& pos,
73 const wxSize& size,
74 long style,
75 const wxValidator& wxVALIDATOR_PARAM(validator),
76 const wxString& name)
77 {
78 if ( !wxWindow::Create(parent, id, pos, size, style, name) )
79 return false;
80
81 #if wxUSE_VALIDATORS
82 SetValidator(validator);
83 #endif
84
85 return true;
86 }
87
88 bool wxControl::PalmCreateControl(ControlStyleType style,
89 wxWindow *parent,
90 wxWindowID id,
91 const wxString& label,
92 const wxPoint& pos,
93 const wxSize& size)
94 {
95 FormType* form = FrmGetActiveForm ();
96 m_control = CtlNewControl (
97 (void **)&form,
98 id,
99 style,
100 label.c_str(),
101 pos.x,
102 pos.y,
103 size.x,
104 size.y,
105 boldFont,
106 0,
107 false
108 );
109
110 if(m_control==NULL)
111 return false;
112
113 form = FrmGetActiveForm ();
114 m_objectIndex = FrmGetObjectIndex(form, id);
115 Show();
116 return true;
117 }
118
119 // ----------------------------------------------------------------------------
120 // various accessors
121 // ----------------------------------------------------------------------------
122
123 wxBorder wxControl::GetDefaultBorder() const
124 {
125 // we want to automatically give controls a sunken style (confusingly,
126 // it may not really mean sunken at all as we map it to WS_EX_CLIENTEDGE
127 // which is not sunken at all under Windows XP -- rather, just the default)
128 return wxBORDER_SUNKEN;
129 }
130
131 wxSize wxControl::DoGetBestSize() const
132 {
133 return wxSize(16, 16);
134 }
135
136 bool wxControl::Enable(bool enable)
137 {
138 if( m_control == NULL )
139 return false;
140 if( IsEnabled() == enable)
141 return false;
142 CtlSetEnabled( m_control, enable);
143 return true;
144 }
145
146 bool wxControl::IsEnabled() const
147 {
148 if( m_control == NULL )
149 return false;
150 return CtlEnabled(m_control);
151 }
152
153 bool wxControl::IsShown() const
154 {
155 return StatGetAttribute ( statAttrBarVisible , NULL );
156 }
157
158 bool wxControl::Show( bool show )
159 {
160 if(show)
161 FrmShowObject(FrmGetActiveForm(), m_objectIndex);
162 else
163 FrmHideObject(FrmGetActiveForm(), m_objectIndex);
164 return true;
165 }
166
167 /* static */ wxVisualAttributes
168 wxControl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
169 {
170 wxVisualAttributes attrs;
171
172 // old school (i.e. not "common") controls use the standard dialog font
173 // by default
174 attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
175
176 // most, or at least many, of the controls use the same colours as the
177 // buttons -- others will have to override this (and possibly simply call
178 // GetCompositeControlsDefaultAttributes() from their versions)
179 attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT);
180 attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
181
182 return attrs;
183 }
184
185 // another version for the "composite", i.e. non simple controls
186 /* static */ wxVisualAttributes
187 wxControl::GetCompositeControlsDefaultAttributes(wxWindowVariant WXUNUSED(variant))
188 {
189 wxVisualAttributes attrs;
190 attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
191 attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
192 attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
193
194 return attrs;
195 }
196
197 // ----------------------------------------------------------------------------
198 // message handling
199 // ----------------------------------------------------------------------------
200
201 bool wxControl::ProcessCommand(wxCommandEvent& event)
202 {
203 return GetEventHandler()->ProcessEvent(event);
204 }
205
206 void wxControl::OnEraseBackground(wxEraseEvent& event)
207 {
208 }
209
210 WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
211 #if wxUSE_CTL3D
212 WXUINT message,
213 WXWPARAM wParam,
214 WXLPARAM lParam
215 #else
216 WXUINT WXUNUSED(message),
217 WXWPARAM WXUNUSED(wParam),
218 WXLPARAM WXUNUSED(lParam)
219 #endif
220 )
221 {
222 return (WXHBRUSH)0;
223 }
224
225 // ---------------------------------------------------------------------------
226 // global functions
227 // ---------------------------------------------------------------------------
228
229 #endif // wxUSE_CONTROLS