]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/control.cpp
Use empty check consistent with other parts.
[wxWidgets.git] / src / mac / carbon / control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.cpp
3 // Purpose: wxControl class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "control.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #include "wx/control.h"
19 #include "wx/panel.h"
20 #include "wx/app.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23 #include "wx/notebook.h"
24 #include "wx/tabctrl.h"
25 #include "wx/radiobox.h"
26 #include "wx/spinbutt.h"
27 #include "wx/scrolbar.h"
28 #include "wx/button.h"
29 #include "wx/dialog.h"
30 #include "wx/statbox.h"
31 #include "wx/sizer.h"
32 #include "wx/stattext.h"
33
34 #if !USE_SHARED_LIBRARY
35 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
36 #endif
37
38 #include "wx/mac/uma.h"
39 #include "wx/mac/private.h"
40
41 // Item members
42
43 wxControl::wxControl()
44 {
45 }
46
47 bool wxControl::Create(wxWindow *parent, wxWindowID id,
48 const wxPoint& pos,
49 const wxSize& size, long style,
50 const wxValidator& validator,
51 const wxString& name)
52 {
53 bool rval = wxWindow::Create(parent, id, pos, size, style, name);
54
55 #if 0
56 // no automatic inheritance as we most often need transparent backgrounds
57 if ( parent )
58 {
59 m_backgroundColour = parent->GetBackgroundColour() ;
60 m_foregroundColour = parent->GetForegroundColour() ;
61 }
62 #endif
63
64 if (rval)
65 {
66 #if wxUSE_VALIDATORS
67 SetValidator(validator);
68 #endif
69 }
70 return rval;
71 }
72
73 wxControl::~wxControl()
74 {
75 m_isBeingDeleted = TRUE;
76 }
77
78 bool wxControl::ProcessCommand (wxCommandEvent & event)
79 {
80 // Tries:
81 // 1) OnCommand, starting at this window and working up parent hierarchy
82 // 2) OnCommand then calls ProcessEvent to search the event tables.
83 return GetEventHandler()->ProcessEvent(event);
84 }
85
86 void wxControl::OnKeyDown( wxKeyEvent &event )
87 {
88 if ( m_peer == NULL || !m_peer->Ok() )
89 return ;
90
91 char charCode ;
92 UInt32 keyCode ;
93 UInt32 modifiers ;
94
95 GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
96 GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
97 GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
98
99 m_peer->HandleKey( keyCode , charCode , modifiers ) ;
100 }
101