]> git.saurik.com Git - wxWidgets.git/blob - src/motif/control.cpp
Suboptimal wxColour::CreateByName implementation for wxMotif.
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 #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(wxStripMenuCodes(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 }