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