]>
Commit | Line | Data |
---|---|---|
4bb6408c JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: stattext.cpp | |
3 | // Purpose: wxStaticText | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/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 | ||
bcd055ae JJ |
15 | #ifdef __VMS |
16 | #define XtDisplay XTDISPLAY | |
17 | #endif | |
18 | ||
9a595736 | 19 | #include "wx/defs.h" |
47073128 WS |
20 | |
21 | #if wxUSE_STATTEXT | |
22 | ||
4bb6408c JS |
23 | #include "wx/stattext.h" |
24 | ||
338dd992 JJ |
25 | #ifdef __VMS__ |
26 | #pragma message disable nosimpint | |
27 | #endif | |
02e8b2f9 | 28 | #include <Xm/Label.h> |
338dd992 JJ |
29 | #ifdef __VMS__ |
30 | #pragma message enable nosimpint | |
31 | #endif | |
02e8b2f9 | 32 | |
fe5de1ea JS |
33 | #include "wx/motif/private.h" |
34 | ||
9a595736 | 35 | IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl); |
4bb6408c JS |
36 | |
37 | bool wxStaticText::Create(wxWindow *parent, wxWindowID id, | |
38 | const wxString& label, | |
39 | const wxPoint& pos, | |
40 | const wxSize& size, | |
41 | long style, | |
42 | const wxString& name) | |
43 | { | |
9a595736 MB |
44 | if( !CreateControl( parent, id, pos, size, style, |
45 | wxDefaultValidator, name ) ) | |
46 | return false; | |
4bb6408c | 47 | |
a4294b78 | 48 | Widget parentWidget = (Widget) parent->GetClientWidget(); |
02e8b2f9 | 49 | |
9a595736 MB |
50 | Widget borderWidget = |
51 | (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style ); | |
6746fe58 | 52 | wxXmString text( wxStripMenuCodes( label ) ); |
ea57084d | 53 | |
73608949 MB |
54 | m_labelWidget = |
55 | XtVaCreateManagedWidget (wxConstCast(name.c_str(), char), | |
56 | xmLabelWidgetClass, | |
57 | borderWidget ? borderWidget : parentWidget, | |
58 | wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)), | |
59 | XmNlabelString, text(), | |
60 | XmNalignment, ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END : | |
61 | ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER : | |
62 | XmALIGNMENT_BEGINNING)), | |
63 | NULL); | |
02e8b2f9 | 64 | |
6886fcfa | 65 | m_mainWidget = borderWidget ? borderWidget : m_labelWidget; |
7227cefd | 66 | |
9a595736 MB |
67 | AttachWidget (parent, m_mainWidget, (WXWidget) NULL, |
68 | pos.x, pos.y, size.x, size.y); | |
02e8b2f9 | 69 | |
0d57be45 | 70 | ChangeBackgroundColour (); |
4bb6408c | 71 | |
96be256b | 72 | return true; |
4bb6408c JS |
73 | } |
74 | ||
fe5de1ea JS |
75 | void wxStaticText::SetLabel(const wxString& label) |
76 | { | |
9a595736 | 77 | wxXmString label_str(wxStripMenuCodes(label)); |
fe5de1ea JS |
78 | |
79 | // This variable means we don't need so many casts later. | |
80 | Widget widget = (Widget) m_labelWidget; | |
81 | ||
82 | if (GetWindowStyle() & wxST_NO_AUTORESIZE) | |
83 | { | |
84 | XtUnmanageChild(widget); | |
85 | Dimension width, height; | |
86 | XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); | |
87 | ||
88 | XtVaSetValues(widget, | |
89 | XmNlabelString, label_str(), | |
90 | XmNlabelType, XmSTRING, | |
91 | NULL); | |
92 | XtVaSetValues(widget, | |
93 | XmNwidth, width, | |
94 | XmNheight, height, | |
47073128 | 95 | NULL); |
fe5de1ea JS |
96 | XtManageChild(widget); |
97 | } | |
98 | else | |
99 | { | |
100 | XtVaSetValues(widget, | |
101 | XmNlabelString, label_str(), | |
102 | XmNlabelType, XmSTRING, | |
103 | NULL); | |
104 | } | |
105 | } | |
47073128 WS |
106 | |
107 | #endif // wxUSE_STATTEXT |