]> git.saurik.com Git - wxWidgets.git/blob - src/motif/control.cpp
Move per display data cleanup to wxApp::CleanUp where it belongs.
[wxWidgets.git] / src / motif / control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.cpp
3 // Purpose: wxControl class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "control.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #include "wx/defs.h"
20
21 #include "wx/control.h"
22 #include "wx/panel.h"
23 #include "wx/utils.h"
24
25 #ifdef __VMS__
26 #pragma message disable nosimpint
27 #endif
28 #include <Xm/Xm.h>
29 #ifdef __VMS__
30 #pragma message enable nosimpint
31 #endif
32
33 #include "wx/motif/private.h"
34
35 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
36
37 BEGIN_EVENT_TABLE(wxControl, wxWindow)
38 END_EVENT_TABLE()
39
40 // Item members
41 wxControl::wxControl()
42 {
43 m_backgroundColour = *wxWHITE;
44 m_foregroundColour = *wxBLACK;
45
46 m_inSetValue = false;
47 }
48
49 bool wxControl::Create( wxWindow *parent,
50 wxWindowID id,
51 const wxPoint &pos,
52 const wxSize &size,
53 long style,
54 const wxValidator& validator,
55 const wxString &name)
56 {
57 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
58
59 #if wxUSE_VALIDATORS
60 SetValidator(validator);
61 #endif
62
63 return ret;
64 }
65
66 bool wxControl::CreateControl(wxWindow *parent,
67 wxWindowID id,
68 const wxPoint& pos,
69 const wxSize& size,
70 long style,
71 const wxValidator& validator,
72 const wxString& name)
73 {
74 if( !wxControlBase::CreateControl( parent, id, pos, size, style,
75 validator, name ) )
76 return false;
77
78 m_backgroundColour = parent->GetBackgroundColour();
79 m_foregroundColour = parent->GetForegroundColour();
80 m_font = parent->GetFont();
81
82 return true;
83 }
84
85 void wxControl::SetLabel(const wxString& label)
86 {
87 Widget widget = (Widget) GetLabelWidget() ;
88 if (!widget)
89 return;
90
91 wxXmString label_str(wxStripMenuCodes(label));
92
93 XtVaSetValues (widget,
94 XmNlabelString, label_str(),
95 XmNlabelType, XmSTRING,
96 NULL);
97 }
98
99 wxString wxControl::GetLabel() const
100 {
101 Widget widget = (Widget) GetLabelWidget() ;
102 if (!widget)
103 return wxEmptyString;
104
105 XmString text = NULL;
106 XtVaGetValues (widget,
107 XmNlabelString, &text,
108 NULL);
109
110 return wxXmStringToString( text );
111 }
112
113 bool wxControl::ProcessCommand(wxCommandEvent & event)
114 {
115 return GetEventHandler()->ProcessEvent(event);
116 }
117
118 wxSize wxControl::DoGetBestSize() const
119 {
120 Widget w = (Widget)GetTopWidget();
121
122 // Do not return any arbitrary default value...
123 wxASSERT_MSG (w, wxT("DoGetBestSize called before creation"));
124
125 XtWidgetGeometry preferred;
126 XtQueryGeometry (w, NULL, &preferred);
127
128 return wxSize(preferred.width, preferred.height);
129 }