]>
Commit | Line | Data |
---|---|---|
4bb6408c JS |
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 | |
dfe1eee3 | 9 | // Licence: wxWindows licence |
4bb6408c JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "control.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/control.h" | |
dfe1eee3 | 17 | #include "wx/panel.h" |
02e8b2f9 JS |
18 | #include "wx/utils.h" |
19 | ||
338dd992 JJ |
20 | #ifdef __VMS__ |
21 | #pragma message disable nosimpint | |
22 | #endif | |
02e8b2f9 | 23 | #include <Xm/Xm.h> |
338dd992 JJ |
24 | #ifdef __VMS__ |
25 | #pragma message enable nosimpint | |
26 | #endif | |
4bb6408c | 27 | |
4bb6408c JS |
28 | IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) |
29 | ||
30 | BEGIN_EVENT_TABLE(wxControl, wxWindow) | |
31 | END_EVENT_TABLE() | |
4bb6408c JS |
32 | |
33 | // Item members | |
34 | wxControl::wxControl() | |
35 | { | |
36 | m_backgroundColour = *wxWHITE; | |
37 | m_foregroundColour = *wxBLACK; | |
31528cd3 VZ |
38 | |
39 | #if WXWIN_COMPATIBILITY | |
4bb6408c | 40 | m_callback = 0; |
31528cd3 VZ |
41 | #endif // WXWIN_COMPATIBILITY |
42 | ||
a4294b78 | 43 | m_inSetValue = FALSE; |
4bb6408c JS |
44 | } |
45 | ||
46 | wxControl::~wxControl() | |
47 | { | |
48 | // If we delete an item, we should initialize the parent panel, | |
49 | // because it could now be invalid. | |
dfe1eee3 VZ |
50 | wxPanel *panel = wxDynamicCast(GetParent(), wxPanel); |
51 | if (panel) | |
4bb6408c | 52 | { |
dfe1eee3 VZ |
53 | if (panel->GetDefaultItem() == this) |
54 | panel->SetDefaultItem((wxButton*) NULL); | |
4bb6408c JS |
55 | } |
56 | } | |
57 | ||
58 | void wxControl::SetLabel(const wxString& label) | |
59 | { | |
a4294b78 JS |
60 | Widget widget = (Widget) GetLabelWidget() ; |
61 | if (!widget) | |
62 | return; | |
dfe1eee3 | 63 | |
a4294b78 | 64 | wxStripMenuCodes((char*) (const char*) label, wxBuffer); |
dfe1eee3 | 65 | |
a4294b78 JS |
66 | XmString text = XmStringCreateSimple (wxBuffer); |
67 | XtVaSetValues (widget, | |
2d120f83 JS |
68 | XmNlabelString, text, |
69 | XmNlabelType, XmSTRING, | |
70 | NULL); | |
a4294b78 | 71 | XmStringFree (text); |
4bb6408c JS |
72 | } |
73 | ||
74 | wxString wxControl::GetLabel() const | |
75 | { | |
a4294b78 JS |
76 | Widget widget = (Widget) GetLabelWidget() ; |
77 | if (!widget) | |
78 | return wxEmptyString; | |
dfe1eee3 | 79 | |
a4294b78 JS |
80 | XmString text; |
81 | char *s; | |
82 | XtVaGetValues (widget, | |
2d120f83 JS |
83 | XmNlabelString, &text, |
84 | NULL); | |
dfe1eee3 | 85 | |
a4294b78 | 86 | if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s)) |
02e8b2f9 | 87 | { |
a4294b78 JS |
88 | wxString str(s); |
89 | XtFree (s); | |
90 | XmStringFree(text); | |
91 | return str; | |
02e8b2f9 | 92 | } |
a4294b78 | 93 | else |
02e8b2f9 | 94 | { |
15d5ab67 | 95 | // XmStringFree(text); |
a4294b78 | 96 | return wxEmptyString; |
02e8b2f9 | 97 | } |
4bb6408c JS |
98 | } |
99 | ||
31528cd3 | 100 | bool wxControl::ProcessCommand(wxCommandEvent & event) |
4bb6408c | 101 | { |
31528cd3 VZ |
102 | #if WXWIN_COMPATIBILITY |
103 | if ( m_callback ) | |
4bb6408c | 104 | { |
31528cd3 VZ |
105 | (void)(*m_callback)(this, event); |
106 | ||
107 | return TRUE; | |
4bb6408c JS |
108 | } |
109 | else | |
31528cd3 | 110 | #endif // WXWIN_COMPATIBILITY |
dfe1eee3 | 111 | |
31528cd3 | 112 | return GetEventHandler()->ProcessEvent(event); |
4bb6408c | 113 | } |