]> git.saurik.com Git - wxWidgets.git/blame - src/motif/control.cpp
Unicode compilation fixes for BC++ 5
[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
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
28IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
29
30BEGIN_EVENT_TABLE(wxControl, wxWindow)
31END_EVENT_TABLE()
4bb6408c
JS
32
33// Item members
34wxControl::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
0148fe1e
VZ
46wxControl::wxControl( wxWindow *parent,
47 wxWindowID id,
48 const wxPoint &pos,
49 const wxSize &size,
50 long style,
51 const wxString &name )
52{
53 (void)Create(parent, id, pos, size, style, name);
54}
55
56#if wxUSE_VALIDATORS
57wxControl::wxControl( wxWindow *parent,
58 wxWindowID id,
59 const wxPoint &pos,
60 const wxSize &size,
61 long style,
62 const wxValidator& validator,
63 const wxString &name)
64{
65 (void)Create(parent, id, pos, size, style, name);
66 SetValidator(validator);
67}
68#endif
69
4bb6408c
JS
70wxControl::~wxControl()
71{
72 // If we delete an item, we should initialize the parent panel,
73 // because it could now be invalid.
dfe1eee3
VZ
74 wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
75 if (panel)
4bb6408c 76 {
dfe1eee3
VZ
77 if (panel->GetDefaultItem() == this)
78 panel->SetDefaultItem((wxButton*) NULL);
4bb6408c
JS
79 }
80}
81
82void wxControl::SetLabel(const wxString& label)
83{
a4294b78
JS
84 Widget widget = (Widget) GetLabelWidget() ;
85 if (!widget)
86 return;
dfe1eee3 87
a4294b78 88 wxStripMenuCodes((char*) (const char*) label, wxBuffer);
dfe1eee3 89
a4294b78
JS
90 XmString text = XmStringCreateSimple (wxBuffer);
91 XtVaSetValues (widget,
2d120f83
JS
92 XmNlabelString, text,
93 XmNlabelType, XmSTRING,
94 NULL);
a4294b78 95 XmStringFree (text);
4bb6408c
JS
96}
97
98wxString wxControl::GetLabel() const
99{
a4294b78
JS
100 Widget widget = (Widget) GetLabelWidget() ;
101 if (!widget)
102 return wxEmptyString;
dfe1eee3 103
a4294b78
JS
104 XmString text;
105 char *s;
106 XtVaGetValues (widget,
2d120f83
JS
107 XmNlabelString, &text,
108 NULL);
dfe1eee3 109
a4294b78 110 if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
02e8b2f9 111 {
a4294b78
JS
112 wxString str(s);
113 XtFree (s);
114 XmStringFree(text);
115 return str;
02e8b2f9 116 }
a4294b78 117 else
02e8b2f9 118 {
15d5ab67 119 // XmStringFree(text);
a4294b78 120 return wxEmptyString;
02e8b2f9 121 }
4bb6408c
JS
122}
123
31528cd3 124bool wxControl::ProcessCommand(wxCommandEvent & event)
4bb6408c 125{
31528cd3
VZ
126#if WXWIN_COMPATIBILITY
127 if ( m_callback )
4bb6408c 128 {
31528cd3
VZ
129 (void)(*m_callback)(this, event);
130
131 return TRUE;
4bb6408c
JS
132 }
133 else
31528cd3 134#endif // WXWIN_COMPATIBILITY
dfe1eee3 135
31528cd3 136 return GetEventHandler()->ProcessEvent(event);
4bb6408c 137}