]> git.saurik.com Git - wxWidgets.git/blob - src/motif/control.cpp
Make wxToolBar styles consistent and add wxTB_DEFAULT_STYLE.
[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_inSetValue = false;
41 }
42
43 bool wxControl::Create( wxWindow *parent,
44 wxWindowID id,
45 const wxPoint &pos,
46 const wxSize &size,
47 long style,
48 const wxValidator& validator,
49 const wxString &name)
50 {
51 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
52
53 #if wxUSE_VALIDATORS
54 SetValidator(validator);
55 #endif
56
57 return ret;
58 }
59
60 bool wxControl::CreateControl(wxWindow *parent,
61 wxWindowID id,
62 const wxPoint& pos,
63 const wxSize& size,
64 long style,
65 const wxValidator& validator,
66 const wxString& name)
67 {
68 if( !wxControlBase::CreateControl( parent, id, pos, size, style,
69 validator, name ) )
70 return false;
71
72 return true;
73 }
74
75 void wxControl::SetLabel(const wxString& label)
76 {
77 Widget widget = (Widget) GetLabelWidget() ;
78 if (!widget)
79 return;
80
81 wxXmString label_str(GetLabelText(label));
82
83 XtVaSetValues (widget,
84 XmNlabelString, label_str(),
85 XmNlabelType, XmSTRING,
86 NULL);
87 }
88
89 wxString wxControl::GetLabel() const
90 {
91 Widget widget = (Widget) GetLabelWidget() ;
92 if (!widget)
93 return wxEmptyString;
94
95 XmString text = NULL;
96 XtVaGetValues (widget,
97 XmNlabelString, &text,
98 NULL);
99
100 return wxXmStringToString( text );
101 }
102
103 bool wxControl::ProcessCommand(wxCommandEvent & event)
104 {
105 return HandleWindowEvent(event);
106 }
107
108 wxSize wxControl::DoGetBestSize() const
109 {
110 Widget w = (Widget)GetTopWidget();
111
112 // Do not return any arbitrary default value...
113 wxASSERT_MSG (w, wxT("DoGetBestSize called before creation"));
114
115 XtWidgetGeometry preferred;
116 XtQueryGeometry (w, NULL, &preferred);
117
118 return wxSize(preferred.width, preferred.height);
119 }