]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/control.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "control.h"
16 #include "wx/control.h"
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
21 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
26 wxControl::wxControl()
28 m_backgroundColour
= *wxWHITE
;
29 m_foregroundColour
= *wxBLACK
;
33 wxControl::~wxControl()
35 // If we delete an item, we should initialize the parent panel,
36 // because it could now be invalid.
37 wxWindow
*parent
= (wxWindow
*)GetParent();
40 if (parent
->GetDefaultItem() == (wxButton
*) this)
41 parent
->SetDefaultItem(NULL
);
45 void wxControl::SetLabel(const wxString
& label
)
50 wxString
wxControl::GetLabel() const
56 void wxControl::ProcessCommand (wxCommandEvent
& event
)
59 // 1) A callback function (to become obsolete)
60 // 2) OnCommand, starting at this window and working up parent hierarchy
61 // 3) OnCommand then calls ProcessEvent to search the event tables.
64 (void) (*(m_callback
)) (*this, event
);
68 GetEventHandler()->OnCommand(*this, event
);
72 void wxControl::Centre (int direction
)
74 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
76 wxWindow
*parent
= (wxWindow
*) GetParent ();
80 parent
->GetClientSize (&panel_width
, &panel_height
);
81 GetSize (&width
, &height
);
87 if (direction
& wxHORIZONTAL
)
88 new_x
= (int) ((panel_width
- width
) / 2);
90 if (direction
& wxVERTICAL
)
91 new_y
= (int) ((panel_height
- height
) / 2);
93 SetSize (new_x
, new_y
, width
, height
);