]>
git.saurik.com Git - wxWidgets.git/blob - 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: Wlodzimierz ABX Skiba - native implementation
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "control.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/dcclient.h"
38 #include "wx/settings.h"
41 #include "wx/control.h"
42 #include "wx/toplevel.h"
43 #include "wx/button.h"
44 #include "wx/checkbox.h"
45 #include "wx/tglbtn.h"
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
53 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
54 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
)
57 // ============================================================================
58 // wxControl implementation
59 // ============================================================================
61 // ----------------------------------------------------------------------------
62 // wxControl ctor/dtor
63 // ----------------------------------------------------------------------------
65 wxControl::~wxControl()
67 m_isBeingDeleted
= true;
70 // ----------------------------------------------------------------------------
71 // control window creation
72 // ----------------------------------------------------------------------------
74 bool wxControl::Create(wxWindow
*parent
,
79 const wxValidator
& wxVALIDATOR_PARAM(validator
),
82 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
86 SetValidator(validator
);
92 bool wxControl::PalmCreateControl(ControlStyleType style
,
95 const wxString
& label
,
99 wxWindow
* parentTLW
= parent
;
100 while ( parentTLW
&& !parentTLW
->IsTopLevel() )
102 parentTLW
= parentTLW
->GetParent();
104 wxTopLevelWindowPalm
* tlw
= wxDynamicCast(parentTLW
, wxTopLevelWindowPalm
);
107 FormType
* form
= tlw
->GetForm();
111 m_control
= CtlNewControl(
132 // ----------------------------------------------------------------------------
134 // ----------------------------------------------------------------------------
136 wxBorder
wxControl::GetDefaultBorder() const
138 // we want to automatically give controls a sunken style (confusingly,
139 // it may not really mean sunken at all as we map it to WS_EX_CLIENTEDGE
140 // which is not sunken at all under Windows XP -- rather, just the default)
141 return wxBORDER_SUNKEN
;
144 wxSize
wxControl::DoGetBestSize() const
146 return wxSize(16, 16);
149 bool wxControl::Enable(bool enable
)
151 if( m_control
== NULL
)
153 if( IsEnabled() == enable
)
155 CtlSetEnabled( m_control
, enable
);
159 bool wxControl::IsEnabled() const
161 if( m_control
== NULL
)
163 return CtlEnabled(m_control
);
166 bool wxControl::IsShown() const
168 return StatGetAttribute ( statAttrBarVisible
, NULL
);
171 bool wxControl::Show( bool show
)
174 CtlShowControl(m_control
);
176 CtlHideControl(m_control
);
180 void wxControl::SetLabel(const wxString
& label
)
182 // setting in wrong control causes crash
183 if ( ( wxDynamicCast(this,wxButton
) != NULL
) ||
184 ( wxDynamicCast(this,wxCheckBox
) != NULL
) ||
185 ( wxDynamicCast(this,wxToggleButton
) != NULL
) )
187 CtlSetLabel(m_control
,label
);
191 wxString
wxControl::GetLabel()
193 // setting in wrong control causes crash
194 if ( wxDynamicCast(this,wxButton
) ||
195 wxDynamicCast(this,wxCheckBox
) ||
196 wxDynamicCast(this,wxToggleButton
) )
198 return CtlGetLabel(m_control
);
201 return wxEmptyString
;
204 /* static */ wxVisualAttributes
205 wxControl::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
207 wxVisualAttributes attrs
;
209 // old school (i.e. not "common") controls use the standard dialog font
211 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
213 // most, or at least many, of the controls use the same colours as the
214 // buttons -- others will have to override this (and possibly simply call
215 // GetCompositeControlsDefaultAttributes() from their versions)
216 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT
);
217 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
222 // another version for the "composite", i.e. non simple controls
223 /* static */ wxVisualAttributes
224 wxControl::GetCompositeControlsDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
226 wxVisualAttributes attrs
;
227 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
228 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
229 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
234 // ----------------------------------------------------------------------------
236 // ----------------------------------------------------------------------------
238 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
240 return GetEventHandler()->ProcessEvent(event
);
243 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
247 WXHBRUSH
wxControl::OnCtlColor(WXHDC pDC
, WXHWND
WXUNUSED(pWnd
), WXUINT
WXUNUSED(nCtlColor
),
253 WXUINT
WXUNUSED(message
),
254 WXWPARAM
WXUNUSED(wParam
),
255 WXLPARAM
WXUNUSED(lParam
)
262 // ---------------------------------------------------------------------------
264 // ---------------------------------------------------------------------------
266 #endif // wxUSE_CONTROLS