]>
git.saurik.com Git - wxWidgets.git/blob - src/qt/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 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
20 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
24 wxControl::wxControl()
26 m_backgroundColour
= *wxWHITE
;
27 m_foregroundColour
= *wxBLACK
;
31 wxControl::~wxControl()
33 // If we delete an item, we should initialize the parent panel,
34 // because it could now be invalid.
35 wxWindow
*parent
= (wxWindow
*)GetParent();
38 if (parent
->GetDefaultItem() == this)
39 parent
->SetDefaultItem(NULL
);
43 void wxControl::SetLabel(const wxString
& label
)
48 wxString
wxControl::GetLabel() const
55 * Allocates control IDs within the appropriate range
60 static int s_controlId
= 0;
65 void wxControl::ProcessCommand (wxCommandEvent
& event
)
68 // 1) A callback function (to become obsolete)
69 // 2) OnCommand, starting at this window and working up parent hierarchy
70 // 3) OnCommand then calls ProcessEvent to search the event tables.
73 (void) (*(m_callback
)) (*this, event
);
77 GetEventHandler()->OnCommand(*this, event
);
81 void wxControl::SetClientSize (int width
, int height
)
83 SetSize (-1, -1, width
, height
);
86 void wxControl::Centre (int direction
)
88 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
90 wxWindow
*parent
= (wxWindow
*) GetParent ();
94 parent
->GetClientSize (&panel_width
, &panel_height
);
95 GetSize (&width
, &height
);
101 if (direction
& wxHORIZONTAL
)
102 new_x
= (int) ((panel_width
- width
) / 2);
104 if (direction
& wxVERTICAL
)
105 new_y
= (int) ((panel_height
- height
) / 2);
107 SetSize (new_x
, new_y
, width
, height
);