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