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