]> git.saurik.com Git - wxWidgets.git/blob - src/motif/stattext.cpp
use wxDiskspaceSize_t which is long and not wxLongLong if wxUSE_LONGLONG==0 (part...
[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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __VMS
16 #define XtDisplay XTDISPLAY
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_STATTEXT
22
23 #include "wx/stattext.h"
24
25 #ifdef __VMS__
26 #pragma message disable nosimpint
27 #endif
28 #include <Xm/Label.h>
29 #ifdef __VMS__
30 #pragma message enable nosimpint
31 #endif
32
33 #include "wx/motif/private.h"
34
35 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
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 {
44 if( !CreateControl( parent, id, pos, size, style,
45 wxDefaultValidator, name ) )
46 return false;
47
48 Widget parentWidget = (Widget) parent->GetClientWidget();
49
50 Widget borderWidget =
51 (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style );
52 wxXmString text( wxStripMenuCodes( label ) );
53
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 XmNrecomputeSize, ((style & wxST_NO_AUTORESIZE) ? TRUE : FALSE),
64 NULL);
65
66 m_mainWidget = borderWidget ? borderWidget : m_labelWidget;
67
68 AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
69 pos.x, pos.y, size.x, size.y);
70
71 ChangeBackgroundColour ();
72
73 return true;
74 }
75
76 void wxStaticText::SetLabel(const wxString& label)
77 {
78 wxXmString label_str(wxStripMenuCodes(label));
79
80 // This variable means we don't need so many casts later.
81 Widget widget = (Widget) m_labelWidget;
82
83 XtVaSetValues(widget,
84 XmNlabelString, label_str(),
85 XmNlabelType, XmSTRING,
86 NULL);
87 }
88
89 #endif // wxUSE_STATTEXT