1/////////////////////////////////////////////////////////////////////////////
2// Name:        src/mac/carbon/control.cpp
3// Purpose:     wxControl class
4// Author:      Stefan Csomor
5// Modified by:
6// Created:     1998-01-01
7// RCS-ID:      $Id: control.cpp 39627 2006-06-08 06:57:39Z ABX $
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/notebook.h"
31#include "wx/tabctrl.h"
32#include "wx/spinbutt.h"
33
34#include "wx/mac/uma.h"
35#include "wx/mac/private.h"
36
37IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
38
39
40wxControl::wxControl()
41{
42}
43
44bool wxControl::Create( wxWindow *parent,
45       wxWindowID id,
46       const wxPoint& pos,
47       const wxSize& size,
48       long style,
49       const wxValidator& validator,
50       const wxString& name )
51{
52    bool rval = wxWindow::Create( parent, id, pos, size, style, name );
53
54#if 0
55    // no automatic inheritance as we most often need transparent backgrounds
56    if ( parent )
57    {
58        m_backgroundColour = parent->GetBackgroundColour();
59        m_foregroundColour = parent->GetForegroundColour();
60    }
61#endif
62
63#if wxUSE_VALIDATORS
64    if (rval)
65        SetValidator( validator );
66#endif
67
68    return rval;
69}
70
71wxControl::~wxControl()
72{
73    m_isBeingDeleted = true;
74}
75
76bool wxControl::ProcessCommand( wxCommandEvent &event )
77{
78    // Tries:
79    // 1) OnCommand, starting at this window and working up parent hierarchy
80    // 2) OnCommand then calls ProcessEvent to search the event tables.
81    return GetEventHandler()->ProcessEvent( event );
82}
83
84void  wxControl::OnKeyDown( wxKeyEvent &event )
85{
86    if ( m_peer == NULL || !m_peer->Ok() )
87        return;
88
89    UInt32 keyCode, modifiers;
90    char charCode;
91
92    GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode  );
93    GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
94    GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
95
96    m_peer->HandleKey( keyCode, charCode, modifiers );
97}
98