]>
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" 
  35     #include "wx/bitmap.h" 
  38 const wxChar wxControlNameStr
[] = wxT("control"); 
  40 // ============================================================================ 
  42 // ============================================================================ 
  44 wxControlBase::~wxControlBase() 
  46     // this destructor is required for Darwin 
  49 bool wxControlBase::Create(wxWindow 
*parent
, 
  54                            const wxValidator
& wxVALIDATOR_PARAM(validator
), 
  57     bool ret 
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
); 
  61         SetValidator(validator
); 
  62 #endif // wxUSE_VALIDATORS 
  67 bool wxControlBase::CreateControl(wxWindowBase 
*parent
, 
  72                                   const wxValidator
& validator
, 
  75     // even if it's possible to create controls without parents in some port, 
  76     // it should surely be discouraged because it doesn't work at all under 
  78     wxCHECK_MSG( parent
, false, wxT("all controls must have parents") ); 
  80     if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) ) 
  83     parent
->AddChild(this); 
  88 void wxControlBase::Command(wxCommandEvent
& event
) 
  90     (void)GetEventHandler()->ProcessEvent(event
); 
  93 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const 
  95     event
.SetEventObject((wxControlBase 
*)this);    // const_cast 
  97     // event.SetId(GetId()); -- this is usuall done in the event ctor 
  99     switch ( m_clientDataType 
) 
 101         case wxClientData_Void
: 
 102             event
.SetClientData(GetClientData()); 
 105         case wxClientData_Object
: 
 106             event
.SetClientObject(GetClientObject()); 
 109         case wxClientData_None
: 
 116 void wxControlBase::SetLabel( const wxString 
&label 
) 
 118     InvalidateBestSize(); 
 119     wxWindow::SetLabel(label
); 
 122 bool wxControlBase::SetFont(const wxFont
& font
) 
 124     InvalidateBestSize(); 
 125     return wxWindow::SetFont(font
); 
 128 // wxControl-specific processing after processing the update event 
 129 void wxControlBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
) 
 132     wxWindowBase::DoUpdateWindowUI(event
); 
 135     if ( event
.GetSetText() ) 
 137         if ( event
.GetText() != GetLabel() ) 
 138             SetLabel(event
.GetText()); 
 141     // Unfortunately we don't yet have common base class for 
 142     // wxRadioButton, so we handle updates of radiobuttons here. 
 143     // TODO: If once wxRadioButtonBase will exist, move this code there. 
 145     if ( event
.GetSetChecked() ) 
 147         wxRadioButton 
*radiobtn 
= wxDynamicCastThis(wxRadioButton
); 
 149             radiobtn
->SetValue(event
.GetChecked()); 
 151 #endif // wxUSE_RADIOBTN 
 154 // ---------------------------------------------------------------------------- 
 156 // ---------------------------------------------------------------------------- 
 160 wxStaticBitmapBase::~wxStaticBitmapBase() 
 162     // this destructor is required for Darwin 
 165 wxSize 
wxStaticBitmapBase::DoGetBestSize() const 
 168     wxBitmap bmp 
= GetBitmap(); 
 170         best 
= wxSize(bmp
.GetWidth(), bmp
.GetHeight()); 
 172         // this is completely arbitrary 
 173         best 
= wxSize(16, 16); 
 178 #endif // wxUSE_STATBMP 
 180 #endif // wxUSE_CONTROLS