]> git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlcmn.cpp
Added RTL functions missing from WinCE to wxchar.h/cpp
[wxWidgets.git] / src / common / ctrlcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: ctrlcmn.cpp
3 // Purpose: wxControl common interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 26.07.99
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "controlbase.h"
22 #pragma implementation "statbmpbase.h"
23 #endif
24
25 // For compilers that support precompilation, includes "wx.h".
26 #include "wx/wxprec.h"
27
28 #ifdef __BORLANDC__
29 #pragma hdrstop
30 #endif
31
32 #if wxUSE_CONTROLS
33
34 #ifndef WX_PRECOMP
35 #include "wx/control.h"
36 #include "wx/log.h"
37 #endif
38
39 #if wxUSE_STATBMP
40 #include "wx/bitmap.h"
41 #include "wx/statbmp.h"
42 #endif // wxUSE_STATBMP
43
44 // ============================================================================
45 // implementation
46 // ============================================================================
47
48 wxControlBase::~wxControlBase()
49 {
50 // this destructor is required for Darwin
51 }
52
53 bool wxControlBase::Create(wxWindow *parent,
54 wxWindowID id,
55 const wxPoint &pos,
56 const wxSize &size,
57 long style,
58 const wxValidator& validator,
59 const wxString &name)
60 {
61 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
62
63 #if wxUSE_VALIDATORS
64 if ( ret )
65 SetValidator(validator);
66 #endif // wxUSE_VALIDATORS
67
68 return ret;
69 }
70
71 bool wxControlBase::CreateControl(wxWindowBase *parent,
72 wxWindowID id,
73 const wxPoint& pos,
74 const wxSize& size,
75 long style,
76 const wxValidator& validator,
77 const wxString& name)
78 {
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
81 // Windows
82 wxCHECK_MSG( parent, FALSE, wxT("all controls must have parents") );
83
84 if ( !CreateBase(parent, id, pos, size, style, validator, name) )
85 return FALSE;
86
87 parent->AddChild(this);
88
89 return TRUE;
90 }
91
92 // inherit colour and font settings from the parent window
93 void wxControlBase::InheritAttributes()
94 {
95 // it definitely doesn't make sense to inherit the background colour as the
96 // controls typically have their own standard one and probably not the
97 // foreground neither?
98 #if 0
99 SetBackgroundColour(GetParent()->GetBackgroundColour());
100 SetForegroundColour(GetParent()->GetForegroundColour());
101 #endif // 0
102
103 #ifdef __WXPM__
104 //
105 // All OS/2 ctrls use the small font
106 //
107 SetFont(*wxSMALL_FONT);
108 #else
109 SetFont(GetParent()->GetFont());
110 #endif
111 }
112
113 void wxControlBase::Command(wxCommandEvent& event)
114 {
115 (void)GetEventHandler()->ProcessEvent(event);
116 }
117
118 void wxControlBase::InitCommandEvent(wxCommandEvent& event) const
119 {
120 event.SetEventObject((wxControlBase *)this); // const_cast
121
122 // event.SetId(GetId()); -- this is usuall done in the event ctor
123
124 switch ( m_clientDataType )
125 {
126 case wxClientData_Void:
127 event.SetClientData(GetClientData());
128 break;
129
130 case wxClientData_Object:
131 event.SetClientObject(GetClientObject());
132 break;
133
134 case wxClientData_None:
135 // nothing to do
136 ;
137 }
138 }
139
140 // ----------------------------------------------------------------------------
141 // wxStaticBitmap
142 // ----------------------------------------------------------------------------
143
144 #if wxUSE_STATBMP
145
146 wxStaticBitmapBase::~wxStaticBitmapBase()
147 {
148 // this destructor is required for Darwin
149 }
150
151 wxSize wxStaticBitmapBase::DoGetBestClientSize() const
152 {
153 wxBitmap bmp = GetBitmap();
154 if ( bmp.Ok() )
155 return wxSize(bmp.GetWidth(), bmp.GetHeight());
156
157 // this is completely arbitrary
158 return wxSize(16, 16);
159 }
160
161 #endif // wxUSE_STATBMP
162
163 #endif // wxUSE_CONTROLS
164