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