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