]>
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 license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
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 bool wxControlBase::Create(wxWindow
*parent
,
53 const wxValidator
& 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 // inherit colour and font settings from the parent window
88 void wxControlBase::InheritAttributes()
90 SetBackgroundColour(GetParent()->GetBackgroundColour());
91 SetForegroundColour(GetParent()->GetForegroundColour());
92 SetFont(GetParent()->GetFont());
95 void wxControlBase::Command(wxCommandEvent
& event
)
97 (void)GetEventHandler()->ProcessEvent(event
);
100 void wxControlBase::InitCommandEvent(wxCommandEvent
& event
) const
102 event
.SetEventObject((wxControlBase
*)this); // const_cast
104 // event.SetId(GetId()); -- this is usuall done in the event ctor
106 switch ( m_clientDataType
)
108 case wxClientData_Void
:
109 event
.SetClientData(GetClientData());
112 case wxClientData_Object
:
113 event
.SetClientObject(GetClientObject());
116 case wxClientData_None
:
122 // ----------------------------------------------------------------------------
124 // ----------------------------------------------------------------------------
128 wxSize
wxStaticBitmapBase::DoGetBestClientSize() const
130 wxBitmap bmp
= GetBitmap();
132 return wxSize(bmp
.GetWidth(), bmp
.GetHeight());
134 // this is completely arbitrary
135 return wxSize(16, 16);
138 #endif // wxUSE_STATBMP
140 #endif // wxUSE_CONTROLS