]> git.saurik.com Git - wxWidgets.git/blame - src/motif/stattext.cpp
Warning fix.
[wxWidgets.git] / src / motif / stattext.cpp
CommitLineData
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
e933b5bc 35IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
4bb6408c
JS
36
37bool 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)),
3fe5be6e 63 XmNrecomputeSize, ((style & wxST_NO_AUTORESIZE) ? TRUE : FALSE),
73608949 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
76void 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
fe5de1ea
JS
83 XtVaSetValues(widget,
84 XmNlabelString, label_str(),
85 XmNlabelType, XmSTRING,
86 NULL);
fe5de1ea 87}
47073128
WS
88
89#endif // wxUSE_STATTEXT