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