]> git.saurik.com Git - wxWidgets.git/blame - src/motif/control.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[wxWidgets.git] / src / motif / control.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
7520f3da 2// Name: src/motif/control.cpp
4bb6408c
JS
3// Purpose: wxControl class
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
4bb6408c 7// Copyright: (c) Julian Smart
65571936 8// Licence: wxWindows licence
4bb6408c
JS
9/////////////////////////////////////////////////////////////////////////////
10
1248b41f
MB
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
4bb6408c 14#include "wx/control.h"
de6185e2
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/utils.h"
8e609c82 18 #include "wx/panel.h"
de6185e2
WS
19#endif
20
338dd992
JJ
21#ifdef __VMS__
22#pragma message disable nosimpint
23#endif
02e8b2f9 24#include <Xm/Xm.h>
338dd992
JJ
25#ifdef __VMS__
26#pragma message enable nosimpint
27#endif
4bb6408c 28
ea19087e
JS
29#include "wx/motif/private.h"
30
4bb6408c
JS
31IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
32
33BEGIN_EVENT_TABLE(wxControl, wxWindow)
34END_EVENT_TABLE()
4bb6408c
JS
35
36// Item members
37wxControl::wxControl()
38{
0c02f070 39 m_inSetValue = false;
4bb6408c
JS
40}
41
5a2155ef 42bool wxControl::Create( wxWindow *parent,
0148fe1e
VZ
43 wxWindowID id,
44 const wxPoint &pos,
45 const wxSize &size,
46 long style,
47 const wxValidator& validator,
48 const wxString &name)
49{
5a2155ef 50 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
674ac8b9
VZ
51
52#if wxUSE_VALIDATORS
0148fe1e 53 SetValidator(validator);
0148fe1e 54#endif
5a2155ef
BJ
55
56 return ret;
674ac8b9 57}
0148fe1e 58
ec75d791
MB
59bool wxControl::CreateControl(wxWindow *parent,
60 wxWindowID id,
61 const wxPoint& pos,
62 const wxSize& size,
63 long style,
64 const wxValidator& validator,
65 const wxString& name)
66{
67 if( !wxControlBase::CreateControl( parent, id, pos, size, style,
68 validator, name ) )
0c02f070 69 return false;
ec75d791 70
0c02f070 71 return true;
ec75d791
MB
72}
73
4bb6408c
JS
74void wxControl::SetLabel(const wxString& label)
75{
a4294b78
JS
76 Widget widget = (Widget) GetLabelWidget() ;
77 if (!widget)
78 return;
dfe1eee3 79
32cd189d 80 wxXmString label_str(GetLabelText(label));
dfe1eee3 81
a4294b78 82 XtVaSetValues (widget,
ea19087e 83 XmNlabelString, label_str(),
2d120f83
JS
84 XmNlabelType, XmSTRING,
85 NULL);
4bb6408c
JS
86}
87
88wxString wxControl::GetLabel() const
89{
a4294b78
JS
90 Widget widget = (Widget) GetLabelWidget() ;
91 if (!widget)
92 return wxEmptyString;
dfe1eee3 93
88793548 94 XmString text = NULL;
a4294b78 95 XtVaGetValues (widget,
2d120f83
JS
96 XmNlabelString, &text,
97 NULL);
dfe1eee3 98
da494b40 99 return wxXmStringToString( text );
4bb6408c
JS
100}
101
31528cd3 102bool wxControl::ProcessCommand(wxCommandEvent & event)
4bb6408c 103{
937013e0 104 return HandleWindowEvent(event);
4bb6408c 105}
0c02f070
MB
106
107wxSize wxControl::DoGetBestSize() const
108{
109 Widget w = (Widget)GetTopWidget();
110
111 // Do not return any arbitrary default value...
112 wxASSERT_MSG (w, wxT("DoGetBestSize called before creation"));
113
114 XtWidgetGeometry preferred;
115 XtQueryGeometry (w, NULL, &preferred);
116
117 return wxSize(preferred.width, preferred.height);
118}