]> git.saurik.com Git - wxWidgets.git/blame - src/motif/stattext.cpp
warning about standard controls
[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
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"
47073128
WS
24
25#if wxUSE_STATTEXT
26
4bb6408c
JS
27#include "wx/stattext.h"
28
338dd992
JJ
29#ifdef __VMS__
30#pragma message disable nosimpint
31#endif
02e8b2f9 32#include <Xm/Label.h>
338dd992
JJ
33#ifdef __VMS__
34#pragma message enable nosimpint
35#endif
02e8b2f9 36
fe5de1ea
JS
37#include "wx/motif/private.h"
38
9a595736 39IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl);
4bb6408c
JS
40
41bool 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{
9a595736
MB
48 if( !CreateControl( parent, id, pos, size, style,
49 wxDefaultValidator, name ) )
50 return false;
4bb6408c 51
a4294b78 52 Widget parentWidget = (Widget) parent->GetClientWidget();
02e8b2f9 53
9a595736
MB
54 Widget borderWidget =
55 (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style );
6746fe58 56 wxXmString text( wxStripMenuCodes( label ) );
ea57084d 57
73608949
MB
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);
02e8b2f9 68
6886fcfa 69 m_mainWidget = borderWidget ? borderWidget : m_labelWidget;
7227cefd 70
9a595736
MB
71 AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
72 pos.x, pos.y, size.x, size.y);
02e8b2f9 73
0d57be45 74 ChangeBackgroundColour ();
4bb6408c 75
96be256b 76 return true;
4bb6408c
JS
77}
78
fe5de1ea
JS
79void wxStaticText::SetLabel(const wxString& label)
80{
9a595736 81 wxXmString label_str(wxStripMenuCodes(label));
fe5de1ea
JS
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,
47073128 99 NULL);
fe5de1ea
JS
100 XtManageChild(widget);
101 }
102 else
103 {
104 XtVaSetValues(widget,
105 XmNlabelString, label_str(),
106 XmNlabelType, XmSTRING,
107 NULL);
108 }
109}
47073128
WS
110
111#endif // wxUSE_STATTEXT