]> git.saurik.com Git - wxWidgets.git/blame - src/qt/control.cpp
Commented out palette code for wxGTK
[wxWidgets.git] / src / qt / control.cpp
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: control.cpp
01b2eeec
KB
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
7c78e7c7
RR
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "control.h"
14#endif
15
16#include "wx/control.h"
17
01b2eeec 18IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
7c78e7c7 19
01b2eeec
KB
20BEGIN_EVENT_TABLE(wxControl, wxWindow)
21END_EVENT_TABLE()
7c78e7c7 22
01b2eeec
KB
23// Item members
24wxControl::wxControl()
7c78e7c7 25{
01b2eeec
KB
26 m_backgroundColour = *wxWHITE;
27 m_foregroundColour = *wxBLACK;
28 m_callback = 0;
29}
7c78e7c7 30
01b2eeec 31wxControl::~wxControl()
7c78e7c7 32{
01b2eeec
KB
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}
7c78e7c7 42
01b2eeec 43void wxControl::SetLabel(const wxString& label)
7c78e7c7 44{
01b2eeec
KB
45 // TODO
46}
7c78e7c7 47
01b2eeec 48wxString wxControl::GetLabel() const
7c78e7c7 49{
01b2eeec
KB
50 // TODO
51 return wxString("");
52}
53
54/*
55 * Allocates control IDs within the appropriate range
56 */
57
58int NewControlId()
59{
60 static int s_controlId = 0;
61 s_controlId ++;
62 return s_controlId;
63}
64
65void 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);
7c78e7c7 78 }
01b2eeec 79}
7c78e7c7 80
01b2eeec
KB
81void wxControl::SetClientSize (int width, int height)
82{
83 SetSize (-1, -1, width, height);
84}
7c78e7c7 85
01b2eeec 86void wxControl::Centre (int direction)
7c78e7c7 87{
01b2eeec
KB
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);
7c78e7c7 103
01b2eeec
KB
104 if (direction & wxVERTICAL)
105 new_y = (int) ((panel_height - height) / 2);
7c78e7c7 106
01b2eeec
KB
107 SetSize (new_x, new_y, width, height);
108}
7c78e7c7 109