]> git.saurik.com Git - wxWidgets.git/blob - src/qt/control.cpp
Busy cursor don't need wxYield(), SendIdleEvents()
[wxWidgets.git] / src / qt / control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.cpp
3 // Purpose: wxControl class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "control.h"
14 #endif
15
16 #include "wx/control.h"
17
18 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
19
20 BEGIN_EVENT_TABLE(wxControl, wxWindow)
21 END_EVENT_TABLE()
22
23 // Item members
24 wxControl::wxControl()
25 {
26 m_backgroundColour = *wxWHITE;
27 m_foregroundColour = *wxBLACK;
28 m_callback = 0;
29 }
30
31 wxControl::~wxControl()
32 {
33 // If we delete an item, we should initialize the parent panel,
34 // because it could now be invalid.
35 wxWindow *parent = (wxWindow *)GetParent();
36 if (parent)
37 {
38 if (parent->GetDefaultItem() == this)
39 parent->SetDefaultItem(NULL);
40 }
41 }
42
43 void wxControl::SetLabel(const wxString& label)
44 {
45 // TODO
46 }
47
48 wxString wxControl::GetLabel() const
49 {
50 // TODO
51 return wxString("");
52 }
53
54 /*
55 * Allocates control IDs within the appropriate range
56 */
57
58 int NewControlId()
59 {
60 static int s_controlId = 0;
61 s_controlId ++;
62 return s_controlId;
63 }
64
65 void wxControl::ProcessCommand (wxCommandEvent & event)
66 {
67 // Tries:
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.
71 if (m_callback)
72 {
73 (void) (*(m_callback)) (*this, event);
74 }
75 else
76 {
77 GetEventHandler()->OnCommand(*this, event);
78 }
79 }
80
81 void wxControl::SetClientSize (int width, int height)
82 {
83 SetSize (-1, -1, width, height);
84 }
85
86 void wxControl::Centre (int direction)
87 {
88 int x, y, width, height, panel_width, panel_height, new_x, new_y;
89
90 wxWindow *parent = (wxWindow *) GetParent ();
91 if (!parent)
92 return;
93
94 parent->GetClientSize (&panel_width, &panel_height);
95 GetSize (&width, &height);
96 GetPosition (&x, &y);
97
98 new_x = x;
99 new_y = y;
100
101 if (direction & wxHORIZONTAL)
102 new_x = (int) ((panel_width - width) / 2);
103
104 if (direction & wxVERTICAL)
105 new_y = (int) ((panel_height - height) / 2);
106
107 SetSize (new_x, new_y, width, height);
108 }
109