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