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