]>
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()
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
71 bool wxControlBase::CreateControl(wxWindowBase
*parent
,
76 const wxValidator
& validator
,
79 // even if it's possible to create controls without parents in some port,
80 // it should surely be discouraged because it doesn't work at all under
82 wxCHECK_MSG( parent
, FALSE
, wxT("all controls must have parents") );
84 if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) )
87 parent
->AddChild(this);
92 // inherit colour and font settings from the parent window
93 void wxControlBase::InheritAttributes()
95 if ( ShouldInheritColours() )
97 wxWindow
*parent
= GetParent();
99 wxCHECK_RET( parent
, _T("a control without parent?") );
101 SetBackgroundColour(parent
->GetBackgroundColour());
102 SetForegroundColour(parent
->GetForegroundColour());
107 // All OS/2 ctrls use the small font
109 SetFont(*wxSMALL_FONT
);
111 SetFont(GetParent()->GetFont());
115 void wxControlBase::Command(wxCommandEvent
& event
)
117 (void)GetEventHandler()->ProcessEvent(event
);
120 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const
122 event
.SetEventObject((wxControlBase
*)this); // const_cast
124 // event.SetId(GetId()); -- this is usuall done in the event ctor
126 switch ( m_clientDataType
)
128 case wxClientData_Void
:
129 event
.SetClientData(GetClientData());
132 case wxClientData_Object
:
133 event
.SetClientObject(GetClientObject());
136 case wxClientData_None
:
142 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
148 wxStaticBitmapBase::~wxStaticBitmapBase()
150 // this destructor is required for Darwin
153 wxSize
wxStaticBitmapBase::DoGetBestClientSize() const
155 wxBitmap bmp
= GetBitmap();
157 return wxSize(bmp
.GetWidth(), bmp
.GetHeight());
159 // this is completely arbitrary
160 return wxSize(16, 16);
163 #endif // wxUSE_STATBMP
165 #endif // wxUSE_CONTROLS