]> git.saurik.com Git - wxWidgets.git/blame - src/motif/stattext.cpp
Committing in .
[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
4bb6408c
JS
20#include "wx/app.h"
21#include "wx/stattext.h"
22
23#include <stdio.h>
24
338dd992
JJ
25#ifdef __VMS__
26#pragma message disable nosimpint
27#endif
7227cefd 28#include <Xm/Frame.h>
02e8b2f9
JS
29#include <Xm/Label.h>
30#include <Xm/LabelG.h>
31#include <Xm/PushBG.h>
338dd992
JJ
32#ifdef __VMS__
33#pragma message enable nosimpint
34#endif
02e8b2f9 35
4bb6408c 36IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
4bb6408c
JS
37
38bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
39 const wxString& label,
40 const wxPoint& pos,
41 const wxSize& size,
42 long style,
43 const wxString& name)
44{
a4294b78
JS
45 SetName(name);
46 if (parent) parent->AddChild(this);
4bb6408c 47
0d57be45
JS
48 m_backgroundColour = parent->GetBackgroundColour();
49 m_foregroundColour = parent->GetForegroundColour();
4bb6408c 50
a4294b78 51 if ( id == -1 )
31528cd3 52 m_windowId = (int)NewControlId();
a4294b78 53 else
31528cd3 54 m_windowId = id;
4bb6408c 55
a4294b78 56 m_windowStyle = style;
da175b2c 57 m_font = parent->GetFont();
4bb6408c 58
7a4b8f27 59#if 0 // gcc 2.95 doesn't like this apparently
a4294b78 60 char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
7a4b8f27
MB
61#endif
62
a4294b78 63 Widget parentWidget = (Widget) parent->GetClientWidget();
02e8b2f9 64
7227cefd
JS
65 Widget borderWidget = NULL;
66
67 // Decorate the label widget if a border style is specified.
68 if (style & wxSIMPLE_BORDER)
69 {
70 borderWidget = XtVaCreateManagedWidget
71 (
72 "simpleBorder",
73 xmFrameWidgetClass, parentWidget,
74 XmNshadowType, XmSHADOW_ETCHED_IN,
75 XmNshadowThickness, 1,
76 NULL
77 );
78 } else if (style & wxSUNKEN_BORDER)
79 {
80 borderWidget = XtVaCreateManagedWidget
81 (
82 "sunkenBorder",
83 xmFrameWidgetClass, parentWidget,
84 XmNshadowType, XmSHADOW_IN,
85 NULL
86 );
87 } else if (style & wxRAISED_BORDER)
88 {
89 borderWidget = XtVaCreateManagedWidget
90 (
91 "raisedBorder",
92 xmFrameWidgetClass, parentWidget,
93 XmNshadowType, XmSHADOW_OUT,
94 NULL
95 );
96 }
97
7a4b8f27 98#if 0 // gcc 2.95 doesn't like this apparently
8cbd2bde
JS
99 // Use XmStringCreateLtoR(), since XmStringCreateSimple
100 // doesn't obey separators.
101// XmString text = XmStringCreateSimple (label1);
102 XmString text = XmStringCreateLtoR (label1, XmSTRING_DEFAULT_CHARSET);
7a4b8f27
MB
103#endif // 0
104
105 XmString text = XmStringCreateLtoR ((char *)(const char*)label, XmSTRING_DEFAULT_CHARSET);
106
da175b2c 107 XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
ea57084d 108
7227cefd 109 Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
02e8b2f9 110 xmLabelWidgetClass,
7227cefd 111 borderWidget ? borderWidget : parentWidget,
ea57084d 112 XmNfontList, fontList,
02e8b2f9
JS
113 XmNlabelString, text,
114 XmNalignment,
115 ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
116 ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER :
117 XmALIGNMENT_BEGINNING)),
118 NULL);
119
a4294b78 120 XmStringFree (text);
02e8b2f9 121
7227cefd
JS
122 m_mainWidget = borderWidget ? borderWidget : labelWidget;
123
a4294b78
JS
124 SetCanAddEventHandler(TRUE);
125 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
02e8b2f9 126
0d57be45 127 ChangeBackgroundColour ();
4bb6408c 128
a4294b78 129 return TRUE;
4bb6408c
JS
130}
131
4b5f3fe6 132void wxStaticText::ChangeFont(bool keepOriginalSize)
0d57be45 133{
4b5f3fe6 134 wxWindow::ChangeFont(keepOriginalSize);
0d57be45
JS
135}
136
137void wxStaticText::ChangeBackgroundColour()
138{
321db4b6 139 wxWindow::ChangeBackgroundColour();
0d57be45
JS
140}
141
142void wxStaticText::ChangeForegroundColour()
143{
321db4b6 144 wxWindow::ChangeForegroundColour();
0d57be45
JS
145}
146