]> git.saurik.com Git - wxWidgets.git/blame - src/motif/control.cpp
added wxLocale::GetLanguageName
[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
f6045f99
GD
16#include "wx/defs.h"
17
4bb6408c 18#include "wx/control.h"
dfe1eee3 19#include "wx/panel.h"
02e8b2f9
JS
20#include "wx/utils.h"
21
338dd992
JJ
22#ifdef __VMS__
23#pragma message disable nosimpint
24#endif
02e8b2f9 25#include <Xm/Xm.h>
338dd992
JJ
26#ifdef __VMS__
27#pragma message enable nosimpint
28#endif
4bb6408c 29
ea19087e
JS
30#include "wx/motif/private.h"
31
4bb6408c
JS
32IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
33
34BEGIN_EVENT_TABLE(wxControl, wxWindow)
35END_EVENT_TABLE()
4bb6408c
JS
36
37// Item members
38wxControl::wxControl()
39{
40 m_backgroundColour = *wxWHITE;
41 m_foregroundColour = *wxBLACK;
31528cd3
VZ
42
43#if WXWIN_COMPATIBILITY
4bb6408c 44 m_callback = 0;
31528cd3
VZ
45#endif // WXWIN_COMPATIBILITY
46
a4294b78 47 m_inSetValue = FALSE;
4bb6408c
JS
48}
49
5a2155ef 50bool wxControl::Create( wxWindow *parent,
0148fe1e
VZ
51 wxWindowID id,
52 const wxPoint &pos,
53 const wxSize &size,
54 long style,
55 const wxValidator& validator,
56 const wxString &name)
57{
5a2155ef 58 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
674ac8b9
VZ
59
60#if wxUSE_VALIDATORS
0148fe1e 61 SetValidator(validator);
0148fe1e 62#endif
5a2155ef
BJ
63
64 return ret;
674ac8b9 65}
0148fe1e 66
ec75d791
MB
67bool wxControl::CreateControl(wxWindow *parent,
68 wxWindowID id,
69 const wxPoint& pos,
70 const wxSize& size,
71 long style,
72 const wxValidator& validator,
73 const wxString& name)
74{
75 if( !wxControlBase::CreateControl( parent, id, pos, size, style,
76 validator, name ) )
77 return FALSE;
78
79 m_backgroundColour = parent->GetBackgroundColour();
80 m_foregroundColour = parent->GetForegroundColour();
81 m_font = parent->GetFont();
82
83 return TRUE;
84}
85
4bb6408c
JS
86void wxControl::SetLabel(const wxString& label)
87{
a4294b78
JS
88 Widget widget = (Widget) GetLabelWidget() ;
89 if (!widget)
90 return;
dfe1eee3 91
ed0c2af3 92 wxXmString label_str(wxStripMenuCodes(label));
dfe1eee3 93
a4294b78 94 XtVaSetValues (widget,
ea19087e 95 XmNlabelString, label_str(),
2d120f83
JS
96 XmNlabelType, XmSTRING,
97 NULL);
4bb6408c
JS
98}
99
100wxString wxControl::GetLabel() const
101{
a4294b78
JS
102 Widget widget = (Widget) GetLabelWidget() ;
103 if (!widget)
104 return wxEmptyString;
dfe1eee3 105
a4294b78 106 XmString text;
a4294b78 107 XtVaGetValues (widget,
2d120f83
JS
108 XmNlabelString, &text,
109 NULL);
dfe1eee3 110
da494b40 111 return wxXmStringToString( text );
4bb6408c
JS
112}
113
31528cd3 114bool wxControl::ProcessCommand(wxCommandEvent & event)
4bb6408c 115{
31528cd3
VZ
116#if WXWIN_COMPATIBILITY
117 if ( m_callback )
4bb6408c 118 {
31528cd3
VZ
119 (void)(*m_callback)(this, event);
120
121 return TRUE;
4bb6408c
JS
122 }
123 else
31528cd3 124#endif // WXWIN_COMPATIBILITY
dfe1eee3 125
31528cd3 126 return GetEventHandler()->ProcessEvent(event);
4bb6408c 127}