]> git.saurik.com Git - wxWidgets.git/blob - src/motif/control.cpp
Stopped width = 0 fouling up window size change
[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 #ifdef __GNUG__
13 #pragma implementation "control.h"
14 #endif
15
16 #include "wx/defs.h"
17
18 #include "wx/control.h"
19 #include "wx/panel.h"
20 #include "wx/utils.h"
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 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
31
32 BEGIN_EVENT_TABLE(wxControl, wxWindow)
33 END_EVENT_TABLE()
34
35 // Item members
36 wxControl::wxControl()
37 {
38 m_backgroundColour = *wxWHITE;
39 m_foregroundColour = *wxBLACK;
40
41 #if WXWIN_COMPATIBILITY
42 m_callback = 0;
43 #endif // WXWIN_COMPATIBILITY
44
45 m_inSetValue = FALSE;
46 }
47
48 bool wxControl::Create( wxWindow *parent,
49 wxWindowID id,
50 const wxPoint &pos,
51 const wxSize &size,
52 long style,
53 const wxValidator& validator,
54 const wxString &name)
55 {
56 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
57
58 #if wxUSE_VALIDATORS
59 SetValidator(validator);
60 #endif
61
62 return ret;
63 }
64
65 void wxControl::SetLabel(const wxString& label)
66 {
67 Widget widget = (Widget) GetLabelWidget() ;
68 if (!widget)
69 return;
70
71 wxString buf(wxStripMenuCodes());
72 wxXmString label_str(buf);
73
74 XtVaSetValues (widget,
75 XmNlabelString, label_str,
76 XmNlabelType, XmSTRING,
77 NULL);
78 }
79
80 wxString wxControl::GetLabel() const
81 {
82 Widget widget = (Widget) GetLabelWidget() ;
83 if (!widget)
84 return wxEmptyString;
85
86 XmString text;
87 char *s;
88 XtVaGetValues (widget,
89 XmNlabelString, &text,
90 NULL);
91
92 if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
93 {
94 wxString str(s);
95 XtFree (s);
96 XmStringFree(text);
97 return str;
98 }
99 else
100 {
101 // XmStringFree(text);
102 return wxEmptyString;
103 }
104 }
105
106 bool wxControl::ProcessCommand(wxCommandEvent & event)
107 {
108 #if WXWIN_COMPATIBILITY
109 if ( m_callback )
110 {
111 (void)(*m_callback)(this, event);
112
113 return TRUE;
114 }
115 else
116 #endif // WXWIN_COMPATIBILITY
117
118 return GetEventHandler()->ProcessEvent(event);
119 }