]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/control.cpp
adding another assert for tracking modalSession problems
[wxWidgets.git] / src / osx / carbon / control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/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 #include "wx/wxprec.h"
13
14 #include "wx/control.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/app.h"
18 #include "wx/panel.h"
19 #include "wx/dc.h"
20 #include "wx/dcclient.h"
21 #include "wx/button.h"
22 #include "wx/dialog.h"
23 #include "wx/scrolbar.h"
24 #include "wx/stattext.h"
25 #include "wx/statbox.h"
26 #include "wx/radiobox.h"
27 #include "wx/sizer.h"
28 #endif // WX_PRECOMP
29
30 #include "wx/osx/private.h"
31
32 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
33
34
35 wxControl::wxControl()
36 {
37 }
38
39 bool wxControl::Create( wxWindow *parent,
40 wxWindowID id,
41 const wxPoint& pos,
42 const wxSize& size,
43 long style,
44 const wxValidator& validator,
45 const wxString& name )
46 {
47 bool rval = wxWindow::Create( parent, id, pos, size, style, name );
48
49 #if 0
50 // no automatic inheritance as we most often need transparent backgrounds
51 if ( parent )
52 {
53 m_backgroundColour = parent->GetBackgroundColour();
54 m_foregroundColour = parent->GetForegroundColour();
55 }
56 #endif
57
58 #if wxUSE_VALIDATORS
59 if (rval)
60 SetValidator( validator );
61 #endif
62
63 return rval;
64 }
65
66 bool wxControl::ProcessCommand( wxCommandEvent &event )
67 {
68 // Tries:
69 // 1) OnCommand, starting at this window and working up parent hierarchy
70 // 2) OnCommand then calls ProcessEvent to search the event tables.
71 return HandleWindowEvent( event );
72 }
73
74 void wxControl::OnKeyDown( wxKeyEvent &WXUNUSED(event) )
75 {
76 if ( GetPeer() == NULL || !GetPeer()->IsOk() )
77 return;
78
79 #if wxOSX_USE_CARBON
80 UInt32 keyCode, modifiers;
81 char charCode;
82
83 GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
84 GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
85 GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
86
87 GetPeer()->HandleKey( keyCode, charCode, modifiers );
88 #else
89 // TODO
90 #endif
91 }