]>
Commit | Line | Data |
---|---|---|
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 | #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 | #if WXWIN_COMPATIBILITY | |
44 | m_callback = 0; | |
45 | #endif // WXWIN_COMPATIBILITY | |
46 | ||
47 | m_inSetValue = FALSE; | |
48 | } | |
49 | ||
50 | bool wxControl::Create( wxWindow *parent, | |
51 | wxWindowID id, | |
52 | const wxPoint &pos, | |
53 | const wxSize &size, | |
54 | long style, | |
55 | const wxValidator& validator, | |
56 | const wxString &name) | |
57 | { | |
58 | bool ret = wxWindow::Create(parent, id, pos, size, style, name); | |
59 | ||
60 | #if wxUSE_VALIDATORS | |
61 | SetValidator(validator); | |
62 | #endif | |
63 | ||
64 | return ret; | |
65 | } | |
66 | ||
67 | bool wxControl::CreateControl(wxWindow *parent, | |
68 | wxWindowID id, | |
69 | const wxPoint& pos, | |
70 | const wxSize& size, | |
71 | long style, | |
72 | const wxValidator& validator, | |
73 | const wxString& name) | |
74 | { | |
75 | if( !wxControlBase::CreateControl( parent, id, pos, size, style, | |
76 | validator, name ) ) | |
77 | return FALSE; | |
78 | ||
79 | m_backgroundColour = parent->GetBackgroundColour(); | |
80 | m_foregroundColour = parent->GetForegroundColour(); | |
81 | m_font = parent->GetFont(); | |
82 | ||
83 | return TRUE; | |
84 | } | |
85 | ||
86 | void wxControl::SetLabel(const wxString& label) | |
87 | { | |
88 | Widget widget = (Widget) GetLabelWidget() ; | |
89 | if (!widget) | |
90 | return; | |
91 | ||
92 | wxString buf(wxStripMenuCodes(label)); | |
93 | wxXmString label_str(buf); | |
94 | ||
95 | XtVaSetValues (widget, | |
96 | XmNlabelString, label_str(), | |
97 | XmNlabelType, XmSTRING, | |
98 | NULL); | |
99 | } | |
100 | ||
101 | wxString wxControl::GetLabel() const | |
102 | { | |
103 | Widget widget = (Widget) GetLabelWidget() ; | |
104 | if (!widget) | |
105 | return wxEmptyString; | |
106 | ||
107 | XmString text; | |
108 | XtVaGetValues (widget, | |
109 | XmNlabelString, &text, | |
110 | NULL); | |
111 | ||
112 | return wxXmStringToString( text ); | |
113 | } | |
114 | ||
115 | bool wxControl::ProcessCommand(wxCommandEvent & event) | |
116 | { | |
117 | #if WXWIN_COMPATIBILITY | |
118 | if ( m_callback ) | |
119 | { | |
120 | (void)(*m_callback)(this, event); | |
121 | ||
122 | return TRUE; | |
123 | } | |
124 | else | |
125 | #endif // WXWIN_COMPATIBILITY | |
126 | ||
127 | return GetEventHandler()->ProcessEvent(event); | |
128 | } |