]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlcmn.cpp
beae40cb11fea06f73c69f6d582b10f139416e20
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/ctrlcmn.cpp
3 // Purpose: wxControl common interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/control.h"
33 #include "wx/radiobut.h"
37 #include "wx/bitmap.h"
38 #include "wx/statbmp.h"
39 #endif // wxUSE_STATBMP
41 // ============================================================================
43 // ============================================================================
45 wxControlBase::~wxControlBase()
47 // this destructor is required for Darwin
50 bool wxControlBase::Create(wxWindow
*parent
,
55 const wxValidator
& wxVALIDATOR_PARAM(validator
),
58 bool ret
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
62 SetValidator(validator
);
63 #endif // wxUSE_VALIDATORS
68 bool wxControlBase::CreateControl(wxWindowBase
*parent
,
73 const wxValidator
& validator
,
76 // even if it's possible to create controls without parents in some port,
77 // it should surely be discouraged because it doesn't work at all under
79 wxCHECK_MSG( parent
, false, wxT("all controls must have parents") );
81 if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) )
84 parent
->AddChild(this);
89 void wxControlBase::Command(wxCommandEvent
& event
)
91 (void)GetEventHandler()->ProcessEvent(event
);
94 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const
96 event
.SetEventObject((wxControlBase
*)this); // const_cast
98 // event.SetId(GetId()); -- this is usuall done in the event ctor
100 switch ( m_clientDataType
)
102 case wxClientData_Void
:
103 event
.SetClientData(GetClientData());
106 case wxClientData_Object
:
107 event
.SetClientObject(GetClientObject());
110 case wxClientData_None
:
117 void wxControlBase::SetLabel( const wxString
&label
)
119 InvalidateBestSize();
120 wxWindow::SetLabel(label
);
123 bool wxControlBase::SetFont(const wxFont
& font
)
125 InvalidateBestSize();
126 return wxWindow::SetFont(font
);
129 // wxControl-specific processing after processing the update event
130 void wxControlBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
133 wxWindowBase::DoUpdateWindowUI(event
);
136 if ( event
.GetSetText() )
138 if ( event
.GetText() != GetLabel() )
139 SetLabel(event
.GetText());
142 // Unfortunately we don't yet have common base class for
143 // wxRadioButton, so we handle updates of radiobuttons here.
144 // TODO: If once wxRadioButtonBase will exist, move this code there.
146 if ( event
.GetSetChecked() )
148 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
150 radiobtn
->SetValue(event
.GetChecked());
152 #endif // wxUSE_RADIOBTN
155 // ----------------------------------------------------------------------------
157 // ----------------------------------------------------------------------------
161 wxStaticBitmapBase::~wxStaticBitmapBase()
163 // this destructor is required for Darwin
166 wxSize
wxStaticBitmapBase::DoGetBestSize() const
169 wxBitmap bmp
= GetBitmap();
171 best
= wxSize(bmp
.GetWidth(), bmp
.GetHeight());
173 // this is completely arbitrary
174 best
= wxSize(16, 16);
179 #endif // wxUSE_STATBMP
181 #endif // wxUSE_CONTROLS