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