]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlcmn.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   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" 
  30     #include "wx/control.h" 
  35     #include "wx/bitmap.h" 
  36     #include "wx/statbmp.h" 
  37 #endif // wxUSE_STATBMP 
  39 // ============================================================================ 
  41 // ============================================================================ 
  43 wxControlBase::~wxControlBase() 
  45     // this destructor is required for Darwin 
  48 bool wxControlBase::Create(wxWindow 
*parent
, 
  53                            const wxValidator
& wxVALIDATOR_PARAM(validator
), 
  56     bool ret 
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
); 
  60         SetValidator(validator
); 
  61 #endif // wxUSE_VALIDATORS 
  66 bool wxControlBase::CreateControl(wxWindowBase 
*parent
, 
  71                                   const wxValidator
& validator
, 
  74     // even if it's possible to create controls without parents in some port, 
  75     // it should surely be discouraged because it doesn't work at all under 
  77     wxCHECK_MSG( parent
, false, wxT("all controls must have parents") ); 
  79     if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) ) 
  82     parent
->AddChild(this); 
  87 void wxControlBase::Command(wxCommandEvent
& event
) 
  89     (void)GetEventHandler()->ProcessEvent(event
); 
  92 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const 
  94     event
.SetEventObject((wxControlBase 
*)this);    // const_cast 
  96     // event.SetId(GetId()); -- this is usuall done in the event ctor 
  98     switch ( m_clientDataType 
) 
 100         case wxClientData_Void
: 
 101             event
.SetClientData(GetClientData()); 
 104         case wxClientData_Object
: 
 105             event
.SetClientObject(GetClientObject()); 
 108         case wxClientData_None
: 
 115 void wxControlBase::SetLabel( const wxString 
&label 
) 
 117     InvalidateBestSize(); 
 118     wxWindow::SetLabel(label
); 
 121 bool wxControlBase::SetFont(const wxFont
& font
) 
 123     InvalidateBestSize(); 
 124     return wxWindow::SetFont(font
); 
 127 // ---------------------------------------------------------------------------- 
 129 // ---------------------------------------------------------------------------- 
 133 wxStaticBitmapBase::~wxStaticBitmapBase() 
 135     // this destructor is required for Darwin 
 138 wxSize 
wxStaticBitmapBase::DoGetBestSize() const 
 141     wxBitmap bmp 
= GetBitmap(); 
 143         best 
= wxSize(bmp
.GetWidth(), bmp
.GetHeight()); 
 145         // this is completely arbitrary 
 146         best 
= wxSize(16, 16); 
 151 #endif // wxUSE_STATBMP 
 153 #endif // wxUSE_CONTROLS