]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlcmn.cpp
eab0f889f12ae35443944932851c14336ae00c77
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "controlbase.h"
22 #pragma implementation "statbmpbase.h"
25 // For compilers that support precompilation, includes "wx.h".
26 #include "wx/wxprec.h"
35 #include "wx/control.h"
40 #include "wx/bitmap.h"
41 #include "wx/statbmp.h"
42 #endif // wxUSE_STATBMP
44 // ============================================================================
46 // ============================================================================
48 wxControlBase::~wxControlBase()
50 // this destructor is required for Darwin
53 bool wxControlBase::Create(wxWindow
*parent
,
58 const wxValidator
& wxVALIDATOR_PARAM(validator
),
61 bool ret
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
65 SetValidator(validator
);
66 #endif // wxUSE_VALIDATORS
72 void wxControlBase::Init()
74 m_adjustMinSize
= true;
78 bool wxControlBase::CreateControl(wxWindowBase
*parent
,
83 const wxValidator
& validator
,
86 // even if it's possible to create controls without parents in some port,
87 // it should surely be discouraged because it doesn't work at all under
89 wxCHECK_MSG( parent
, FALSE
, wxT("all controls must have parents") );
91 if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) )
94 parent
->AddChild(this);
99 void wxControlBase::Command(wxCommandEvent
& event
)
101 (void)GetEventHandler()->ProcessEvent(event
);
104 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const
106 event
.SetEventObject((wxControlBase
*)this); // const_cast
108 // event.SetId(GetId()); -- this is usuall done in the event ctor
110 switch ( m_clientDataType
)
112 case wxClientData_Void
:
113 event
.SetClientData(GetClientData());
116 case wxClientData_Object
:
117 event
.SetClientObject(GetClientObject());
120 case wxClientData_None
:
126 void wxControlBase::SetLabel(const wxString
& label
)
128 wxWindow::SetLabel(label
);
129 if (GetAdjustMinSizeFlag())
130 SetBestSize(wxDefaultSize
);
134 bool wxControlBase::SetFont(const wxFont
& font
)
136 bool ret
= wxWindow::SetFont(font
);
138 if (GetAdjustMinSizeFlag())
139 SetBestSize(wxDefaultSize
);
144 // ----------------------------------------------------------------------------
146 // ----------------------------------------------------------------------------
150 wxStaticBitmapBase::~wxStaticBitmapBase()
152 // this destructor is required for Darwin
155 wxSize
wxStaticBitmapBase::DoGetBestSize() const
157 wxBitmap bmp
= GetBitmap();
159 return wxSize(bmp
.GetWidth(), bmp
.GetHeight());
161 // this is completely arbitrary
162 return wxSize(16, 16);
165 #endif // wxUSE_STATBMP
167 #endif // wxUSE_CONTROLS