]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlcmn.cpp
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"
34 #include "wx/statbmp.h"
38 #include "wx/bitmap.h"
39 #endif // wxUSE_STATBMP
41 const wxChar wxControlNameStr
[] = wxT("control");
43 // ============================================================================
45 // ============================================================================
47 wxControlBase::~wxControlBase()
49 // this destructor is required for Darwin
52 bool wxControlBase::Create(wxWindow
*parent
,
57 const wxValidator
& wxVALIDATOR_PARAM(validator
),
60 bool ret
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
64 SetValidator(validator
);
65 #endif // wxUSE_VALIDATORS
70 bool wxControlBase::CreateControl(wxWindowBase
*parent
,
75 const wxValidator
& validator
,
78 // even if it's possible to create controls without parents in some port,
79 // it should surely be discouraged because it doesn't work at all under
81 wxCHECK_MSG( parent
, false, wxT("all controls must have parents") );
83 if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) )
86 parent
->AddChild(this);
91 void wxControlBase::Command(wxCommandEvent
& event
)
93 (void)GetEventHandler()->ProcessEvent(event
);
96 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const
98 event
.SetEventObject((wxControlBase
*)this); // const_cast
100 // event.SetId(GetId()); -- this is usuall done in the event ctor
102 switch ( m_clientDataType
)
104 case wxClientData_Void
:
105 event
.SetClientData(GetClientData());
108 case wxClientData_Object
:
109 event
.SetClientObject(GetClientObject());
112 case wxClientData_None
:
119 void wxControlBase::SetLabel( const wxString
&label
)
121 InvalidateBestSize();
122 wxWindow::SetLabel(label
);
125 bool wxControlBase::SetFont(const wxFont
& font
)
127 InvalidateBestSize();
128 return wxWindow::SetFont(font
);
131 // wxControl-specific processing after processing the update event
132 void wxControlBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
135 wxWindowBase::DoUpdateWindowUI(event
);
138 if ( event
.GetSetText() )
140 if ( event
.GetText() != GetLabel() )
141 SetLabel(event
.GetText());
144 // Unfortunately we don't yet have common base class for
145 // wxRadioButton, so we handle updates of radiobuttons here.
146 // TODO: If once wxRadioButtonBase will exist, move this code there.
148 if ( event
.GetSetChecked() )
150 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
152 radiobtn
->SetValue(event
.GetChecked());
154 #endif // wxUSE_RADIOBTN
157 // ----------------------------------------------------------------------------
159 // ----------------------------------------------------------------------------
163 wxStaticBitmapBase::~wxStaticBitmapBase()
165 // this destructor is required for Darwin
168 wxSize
wxStaticBitmapBase::DoGetBestSize() const
171 wxBitmap bmp
= GetBitmap();
173 best
= wxSize(bmp
.GetWidth(), bmp
.GetHeight());
175 // this is completely arbitrary
176 best
= wxSize(16, 16);
181 #endif // wxUSE_STATBMP
183 #endif // wxUSE_CONTROLS