]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl common interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows 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()
52 wxControlBase::~wxControlBase()
54 // this destructor is required for Darwin
57 bool wxControlBase::Create(wxWindow
*parent
,
62 const wxValidator
& wxVALIDATOR_PARAM(validator
),
65 bool ret
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
69 SetValidator(validator
);
70 #endif // wxUSE_VALIDATORS
75 bool wxControlBase::CreateControl(wxWindowBase
*parent
,
80 const wxValidator
& validator
,
83 // even if it's possible to create controls without parents in some port,
84 // it should surely be discouraged because it doesn't work at all under
86 wxCHECK_MSG( parent
, FALSE
, wxT("all controls must have parents") );
88 if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) )
91 parent
->AddChild(this);
96 // inherit colour and font settings from the parent window
97 void wxControlBase::InheritAttributes()
99 if ( ShouldInheritColours() )
101 wxWindow
*parent
= GetParent();
103 wxCHECK_RET( parent
, _T("a control without parent?") );
105 SetBackgroundColour(parent
->GetBackgroundColour());
106 SetForegroundColour(parent
->GetForegroundColour());
111 // All OS/2 ctrls use the small font
113 SetFont(*wxSMALL_FONT
);
115 SetFont(GetParent()->GetFont());
119 void wxControlBase::Command(wxCommandEvent
& event
)
121 (void)GetEventHandler()->ProcessEvent(event
);
124 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const
126 event
.SetEventObject((wxControlBase
*)this); // const_cast
128 // event.SetId(GetId()); -- this is usuall done in the event ctor
130 switch ( m_clientDataType
)
132 case wxClientData_Void
:
133 event
.SetClientData(GetClientData());
136 case wxClientData_Object
:
137 event
.SetClientObject(GetClientObject());
140 case wxClientData_None
:
146 // ----------------------------------------------------------------------------
148 // ----------------------------------------------------------------------------
152 wxStaticBitmapBase::~wxStaticBitmapBase()
154 // this destructor is required for Darwin
157 wxSize
wxStaticBitmapBase::DoGetBestClientSize() const
159 wxBitmap bmp
= GetBitmap();
161 return wxSize(bmp
.GetWidth(), bmp
.GetHeight());
163 // this is completely arbitrary
164 return wxSize(16, 16);
167 #endif // wxUSE_STATBMP
169 #endif // wxUSE_CONTROLS