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