]> git.saurik.com Git - wxWidgets.git/blame - src/qt/control.cpp
bitmap and image updates
[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
KB
18#if !USE_SHARED_LIBRARY
19IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
7c78e7c7 20
01b2eeec
KB
21BEGIN_EVENT_TABLE(wxControl, wxWindow)
22END_EVENT_TABLE()
23#endif
7c78e7c7 24
01b2eeec
KB
25// Item members
26wxControl::wxControl()
7c78e7c7 27{
01b2eeec
KB
28 m_backgroundColour = *wxWHITE;
29 m_foregroundColour = *wxBLACK;
30 m_callback = 0;
31}
7c78e7c7 32
01b2eeec 33wxControl::~wxControl()
7c78e7c7 34{
01b2eeec
KB
35 // If we delete an item, we should initialize the parent panel,
36 // because it could now be invalid.
37 wxWindow *parent = (wxWindow *)GetParent();
38 if (parent)
39 {
40 if (parent->GetDefaultItem() == this)
41 parent->SetDefaultItem(NULL);
42 }
43}
7c78e7c7 44
01b2eeec 45void wxControl::SetLabel(const wxString& label)
7c78e7c7 46{
01b2eeec
KB
47 // TODO
48}
7c78e7c7 49
01b2eeec 50wxString wxControl::GetLabel() const
7c78e7c7 51{
01b2eeec
KB
52 // TODO
53 return wxString("");
54}
55
56/*
57 * Allocates control IDs within the appropriate range
58 */
59
60int NewControlId()
61{
62 static int s_controlId = 0;
63 s_controlId ++;
64 return s_controlId;
65}
66
67void wxControl::ProcessCommand (wxCommandEvent & event)
68{
69 // Tries:
70 // 1) A callback function (to become obsolete)
71 // 2) OnCommand, starting at this window and working up parent hierarchy
72 // 3) OnCommand then calls ProcessEvent to search the event tables.
73 if (m_callback)
74 {
75 (void) (*(m_callback)) (*this, event);
76 }
77 else
78 {
79 GetEventHandler()->OnCommand(*this, event);
7c78e7c7 80 }
01b2eeec 81}
7c78e7c7 82
01b2eeec
KB
83void wxControl::SetClientSize (int width, int height)
84{
85 SetSize (-1, -1, width, height);
86}
7c78e7c7 87
01b2eeec 88void wxControl::Centre (int direction)
7c78e7c7 89{
01b2eeec
KB
90 int x, y, width, height, panel_width, panel_height, new_x, new_y;
91
92 wxWindow *parent = (wxWindow *) GetParent ();
93 if (!parent)
94 return;
95
96 parent->GetClientSize (&panel_width, &panel_height);
97 GetSize (&width, &height);
98 GetPosition (&x, &y);
99
100 new_x = x;
101 new_y = y;
102
103 if (direction & wxHORIZONTAL)
104 new_x = (int) ((panel_width - width) / 2);
7c78e7c7 105
01b2eeec
KB
106 if (direction & wxVERTICAL)
107 new_y = (int) ((panel_height - height) / 2);
7c78e7c7 108
01b2eeec
KB
109 SetSize (new_x, new_y, width, height);
110}
7c78e7c7 111