]> git.saurik.com Git - wxWidgets.git/blame - src/motif/control.cpp
Make room for the focus ring to be visible on Mac.
[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"
de6185e2
WS
16
17#ifndef WX_PRECOMP
18 #include "wx/utils.h"
8e609c82 19 #include "wx/panel.h"
de6185e2
WS
20#endif
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 42
0c02f070 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
ec75d791
MB
63bool wxControl::CreateControl(wxWindow *parent,
64 wxWindowID id,
65 const wxPoint& pos,
66 const wxSize& size,
67 long style,
68 const wxValidator& validator,
69 const wxString& name)
70{
71 if( !wxControlBase::CreateControl( parent, id, pos, size, style,
72 validator, name ) )
0c02f070 73 return false;
ec75d791
MB
74
75 m_backgroundColour = parent->GetBackgroundColour();
76 m_foregroundColour = parent->GetForegroundColour();
77 m_font = parent->GetFont();
78
0c02f070 79 return true;
ec75d791
MB
80}
81
4bb6408c
JS
82void wxControl::SetLabel(const wxString& label)
83{
a4294b78
JS
84 Widget widget = (Widget) GetLabelWidget() ;
85 if (!widget)
86 return;
dfe1eee3 87
32cd189d 88 wxXmString label_str(GetLabelText(label));
dfe1eee3 89
a4294b78 90 XtVaSetValues (widget,
ea19087e 91 XmNlabelString, label_str(),
2d120f83
JS
92 XmNlabelType, XmSTRING,
93 NULL);
4bb6408c
JS
94}
95
96wxString wxControl::GetLabel() const
97{
a4294b78
JS
98 Widget widget = (Widget) GetLabelWidget() ;
99 if (!widget)
100 return wxEmptyString;
dfe1eee3 101
88793548 102 XmString text = NULL;
a4294b78 103 XtVaGetValues (widget,
2d120f83
JS
104 XmNlabelString, &text,
105 NULL);
dfe1eee3 106
da494b40 107 return wxXmStringToString( text );
4bb6408c
JS
108}
109
31528cd3 110bool wxControl::ProcessCommand(wxCommandEvent & event)
4bb6408c 111{
31528cd3 112 return GetEventHandler()->ProcessEvent(event);
4bb6408c 113}
0c02f070
MB
114
115wxSize wxControl::DoGetBestSize() const
116{
117 Widget w = (Widget)GetTopWidget();
118
119 // Do not return any arbitrary default value...
120 wxASSERT_MSG (w, wxT("DoGetBestSize called before creation"));
121
122 XtWidgetGeometry preferred;
123 XtQueryGeometry (w, NULL, &preferred);
124
125 return wxSize(preferred.width, preferred.height);
126}