]> git.saurik.com Git - wxWidgets.git/blob - src/motif/control.cpp
Applied part 2 of [ 1415183 ] a couple of wxAutomation object/ole fixes
[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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #include "wx/defs.h"
16
17 #include "wx/control.h"
18 #include "wx/panel.h"
19 #include "wx/utils.h"
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_backgroundColour = *wxWHITE;
40 m_foregroundColour = *wxBLACK;
41
42 m_inSetValue = false;
43 }
44
45 bool wxControl::Create( wxWindow *parent,
46 wxWindowID id,
47 const wxPoint &pos,
48 const wxSize &size,
49 long style,
50 const wxValidator& validator,
51 const wxString &name)
52 {
53 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
54
55 #if wxUSE_VALIDATORS
56 SetValidator(validator);
57 #endif
58
59 return ret;
60 }
61
62 bool wxControl::CreateControl(wxWindow *parent,
63 wxWindowID id,
64 const wxPoint& pos,
65 const wxSize& size,
66 long style,
67 const wxValidator& validator,
68 const wxString& name)
69 {
70 if( !wxControlBase::CreateControl( parent, id, pos, size, style,
71 validator, name ) )
72 return false;
73
74 m_backgroundColour = parent->GetBackgroundColour();
75 m_foregroundColour = parent->GetForegroundColour();
76 m_font = parent->GetFont();
77
78 return true;
79 }
80
81 void wxControl::SetLabel(const wxString& label)
82 {
83 Widget widget = (Widget) GetLabelWidget() ;
84 if (!widget)
85 return;
86
87 wxXmString label_str(wxStripMenuCodes(label));
88
89 XtVaSetValues (widget,
90 XmNlabelString, label_str(),
91 XmNlabelType, XmSTRING,
92 NULL);
93 }
94
95 wxString wxControl::GetLabel() const
96 {
97 Widget widget = (Widget) GetLabelWidget() ;
98 if (!widget)
99 return wxEmptyString;
100
101 XmString text = NULL;
102 XtVaGetValues (widget,
103 XmNlabelString, &text,
104 NULL);
105
106 return wxXmStringToString( text );
107 }
108
109 bool wxControl::ProcessCommand(wxCommandEvent & event)
110 {
111 return GetEventHandler()->ProcessEvent(event);
112 }
113
114 wxSize wxControl::DoGetBestSize() const
115 {
116 Widget w = (Widget)GetTopWidget();
117
118 // Do not return any arbitrary default value...
119 wxASSERT_MSG (w, wxT("DoGetBestSize called before creation"));
120
121 XtWidgetGeometry preferred;
122 XtQueryGeometry (w, NULL, &preferred);
123
124 return wxSize(preferred.width, preferred.height);
125 }