]> git.saurik.com Git - wxWidgets.git/blob - src/stubs/control.cpp
some scrolling&refreshing fixed ; removed wxHtmlWindow::OnKeyDown
[wxWidgets.git] / src / stubs / 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() == (wxButton*) 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 void wxControl::ProcessCommand (wxCommandEvent & event)
55 {
56 // Tries:
57 // 1) A callback function (to become obsolete)
58 // 2) OnCommand, starting at this window and working up parent hierarchy
59 // 3) OnCommand then calls ProcessEvent to search the event tables.
60 if (m_callback)
61 {
62 (void) (*(m_callback)) (*this, event);
63 }
64 else
65 {
66 GetEventHandler()->OnCommand(*this, event);
67 }
68 }
69
70 void wxControl::Centre (int direction)
71 {
72 int x, y, width, height, panel_width, panel_height, new_x, new_y;
73
74 wxWindow *parent = (wxWindow *) GetParent ();
75 if (!parent)
76 return;
77
78 parent->GetClientSize (&panel_width, &panel_height);
79 GetSize (&width, &height);
80 GetPosition (&x, &y);
81
82 new_x = x;
83 new_y = y;
84
85 if (direction & wxHORIZONTAL)
86 new_x = (int) ((panel_width - width) / 2);
87
88 if (direction & wxVERTICAL)
89 new_y = (int) ((panel_height - height) / 2);
90
91 SetSize (new_x, new_y, width, height);
92 }
93