]> git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlcmn.cpp
wxIsAbsolutePath is strange under wxMac
[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 license
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 bool wxControlBase::Create(wxWindow *parent,
49 wxWindowID id,
50 const wxPoint &pos,
51 const wxSize &size,
52 long style,
53 const wxValidator& validator,
54 const wxString &name)
55 {
56 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
57
58 #if wxUSE_VALIDATORS
59 if ( ret )
60 SetValidator(validator);
61 #endif // wxUSE_VALIDATORS
62
63 return ret;
64 }
65
66 bool wxControlBase::CreateControl(wxWindowBase *parent,
67 wxWindowID id,
68 const wxPoint& pos,
69 const wxSize& size,
70 long style,
71 const wxValidator& validator,
72 const wxString& name)
73 {
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
76 // Windows
77 wxCHECK_MSG( parent, FALSE, wxT("all controls must have parents") );
78
79 if ( !CreateBase(parent, id, pos, size, style, validator, name) )
80 return FALSE;
81
82 parent->AddChild(this);
83
84 return TRUE;
85 }
86
87 // inherit colour and font settings from the parent window
88 void wxControlBase::InheritAttributes()
89 {
90 SetBackgroundColour(GetParent()->GetBackgroundColour());
91 SetForegroundColour(GetParent()->GetForegroundColour());
92 SetFont(GetParent()->GetFont());
93 }
94
95 void wxControlBase::Command(wxCommandEvent& event)
96 {
97 (void)GetEventHandler()->ProcessEvent(event);
98 }
99
100 void wxControlBase::InitCommandEvent(wxCommandEvent& event) const
101 {
102 event.SetEventObject((wxControlBase *)this); // const_cast
103
104 // event.SetId(GetId()); -- this is usuall done in the event ctor
105
106 switch ( m_clientDataType )
107 {
108 case wxClientData_Void:
109 event.SetClientData(GetClientData());
110 break;
111
112 case wxClientData_Object:
113 event.SetClientObject(GetClientObject());
114 break;
115
116 case wxClientData_None:
117 // nothing to do
118 ;
119 }
120 }
121
122 // ----------------------------------------------------------------------------
123 // wxStaticBitmap
124 // ----------------------------------------------------------------------------
125
126 #if wxUSE_STATBMP
127
128 wxSize wxStaticBitmapBase::DoGetBestClientSize() const
129 {
130 wxBitmap bmp = GetBitmap();
131 if ( bmp.Ok() )
132 return wxSize(bmp.GetWidth(), bmp.GetHeight());
133
134 // this is completely arbitrary
135 return wxSize(16, 16);
136 }
137
138 #endif // wxUSE_STATBMP
139
140 #endif // wxUSE_CONTROLS
141