]>
Commit | Line | Data |
---|---|---|
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 | |
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 | ||
f6045f99 GD |
15 | #include "wx/defs.h" |
16 | ||
4bb6408c | 17 | #include "wx/control.h" |
dfe1eee3 | 18 | #include "wx/panel.h" |
02e8b2f9 JS |
19 | #include "wx/utils.h" |
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 |
31 | IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) |
32 | ||
33 | BEGIN_EVENT_TABLE(wxControl, wxWindow) | |
34 | END_EVENT_TABLE() | |
4bb6408c JS |
35 | |
36 | // Item members | |
37 | wxControl::wxControl() | |
38 | { | |
39 | m_backgroundColour = *wxWHITE; | |
40 | m_foregroundColour = *wxBLACK; | |
31528cd3 | 41 | |
0c02f070 | 42 | m_inSetValue = false; |
4bb6408c JS |
43 | } |
44 | ||
5a2155ef | 45 | bool wxControl::Create( wxWindow *parent, |
0148fe1e VZ |
46 | wxWindowID id, |
47 | const wxPoint &pos, | |
48 | const wxSize &size, | |
49 | long style, | |
50 | const wxValidator& validator, | |
51 | const wxString &name) | |
52 | { | |
5a2155ef | 53 | bool ret = wxWindow::Create(parent, id, pos, size, style, name); |
674ac8b9 VZ |
54 | |
55 | #if wxUSE_VALIDATORS | |
0148fe1e | 56 | SetValidator(validator); |
0148fe1e | 57 | #endif |
5a2155ef BJ |
58 | |
59 | return ret; | |
674ac8b9 | 60 | } |
0148fe1e | 61 | |
ec75d791 MB |
62 | bool wxControl::CreateControl(wxWindow *parent, |
63 | wxWindowID id, | |
64 | const wxPoint& pos, | |
65 | const wxSize& size, | |
66 | long style, | |
67 | const wxValidator& validator, | |
68 | const wxString& name) | |
69 | { | |
70 | if( !wxControlBase::CreateControl( parent, id, pos, size, style, | |
71 | validator, name ) ) | |
0c02f070 | 72 | return false; |
ec75d791 MB |
73 | |
74 | m_backgroundColour = parent->GetBackgroundColour(); | |
75 | m_foregroundColour = parent->GetForegroundColour(); | |
76 | m_font = parent->GetFont(); | |
77 | ||
0c02f070 | 78 | return true; |
ec75d791 MB |
79 | } |
80 | ||
4bb6408c JS |
81 | void wxControl::SetLabel(const wxString& label) |
82 | { | |
a4294b78 JS |
83 | Widget widget = (Widget) GetLabelWidget() ; |
84 | if (!widget) | |
85 | return; | |
dfe1eee3 | 86 | |
ed0c2af3 | 87 | wxXmString label_str(wxStripMenuCodes(label)); |
dfe1eee3 | 88 | |
a4294b78 | 89 | XtVaSetValues (widget, |
ea19087e | 90 | XmNlabelString, label_str(), |
2d120f83 JS |
91 | XmNlabelType, XmSTRING, |
92 | NULL); | |
4bb6408c JS |
93 | } |
94 | ||
95 | wxString wxControl::GetLabel() const | |
96 | { | |
a4294b78 JS |
97 | Widget widget = (Widget) GetLabelWidget() ; |
98 | if (!widget) | |
99 | return wxEmptyString; | |
dfe1eee3 | 100 | |
88793548 | 101 | XmString text = NULL; |
a4294b78 | 102 | XtVaGetValues (widget, |
2d120f83 JS |
103 | XmNlabelString, &text, |
104 | NULL); | |
dfe1eee3 | 105 | |
da494b40 | 106 | return wxXmStringToString( text ); |
4bb6408c JS |
107 | } |
108 | ||
31528cd3 | 109 | bool wxControl::ProcessCommand(wxCommandEvent & event) |
4bb6408c | 110 | { |
31528cd3 | 111 | return GetEventHandler()->ProcessEvent(event); |
4bb6408c | 112 | } |
0c02f070 MB |
113 | |
114 | wxSize wxControl::DoGetBestSize() const | |
115 | { | |
116 | Widget w = (Widget)GetTopWidget(); | |
117 | ||
118 | // Do not return any arbitrary default value... | |
119 | wxASSERT_MSG (w, wxT("DoGetBestSize called before creation")); | |
120 | ||
121 | XtWidgetGeometry preferred; | |
122 | XtQueryGeometry (w, NULL, &preferred); | |
123 | ||
124 | return wxSize(preferred.width, preferred.height); | |
125 | } |