]> git.saurik.com Git - wxWidgets.git/blame - src/motif/stattext.cpp
fix to not show ampersands in the static box title (needed after the previous change)
[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
02e8b2f9
JS
28#include <Xm/Label.h>
29#include <Xm/LabelG.h>
30#include <Xm/PushBG.h>
338dd992
JJ
31#ifdef __VMS__
32#pragma message enable nosimpint
33#endif
02e8b2f9 34
4bb6408c 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{
a4294b78
JS
44 SetName(name);
45 if (parent) parent->AddChild(this);
4bb6408c 46
0d57be45
JS
47 m_backgroundColour = parent->GetBackgroundColour();
48 m_foregroundColour = parent->GetForegroundColour();
4bb6408c 49
a4294b78 50 if ( id == -1 )
31528cd3 51 m_windowId = (int)NewControlId();
a4294b78 52 else
31528cd3 53 m_windowId = id;
4bb6408c 54
a4294b78 55 m_windowStyle = style;
da175b2c 56 m_font = parent->GetFont();
4bb6408c 57
7a4b8f27 58#if 0 // gcc 2.95 doesn't like this apparently
a4294b78 59 char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
7a4b8f27
MB
60#endif
61
a4294b78 62 Widget parentWidget = (Widget) parent->GetClientWidget();
02e8b2f9 63
7a4b8f27 64#if 0 // gcc 2.95 doesn't like this apparently
8cbd2bde
JS
65 // Use XmStringCreateLtoR(), since XmStringCreateSimple
66 // doesn't obey separators.
67// XmString text = XmStringCreateSimple (label1);
68 XmString text = XmStringCreateLtoR (label1, XmSTRING_DEFAULT_CHARSET);
7a4b8f27
MB
69#endif // 0
70
71 XmString text = XmStringCreateLtoR ((char *)(const char*)label, XmSTRING_DEFAULT_CHARSET);
72
da175b2c 73 XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
ea57084d 74
a4294b78 75 m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
02e8b2f9
JS
76 xmLabelWidgetClass,
77 parentWidget,
ea57084d 78 XmNfontList, fontList,
02e8b2f9
JS
79 XmNlabelString, text,
80 XmNalignment,
81 ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
82 ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER :
83 XmALIGNMENT_BEGINNING)),
84 NULL);
85
a4294b78 86 XmStringFree (text);
02e8b2f9 87
a4294b78
JS
88 SetCanAddEventHandler(TRUE);
89 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
02e8b2f9 90
0d57be45 91 ChangeBackgroundColour ();
4bb6408c 92
a4294b78 93 return TRUE;
4bb6408c
JS
94}
95
4b5f3fe6 96void wxStaticText::ChangeFont(bool keepOriginalSize)
0d57be45 97{
4b5f3fe6 98 wxWindow::ChangeFont(keepOriginalSize);
0d57be45
JS
99}
100
101void wxStaticText::ChangeBackgroundColour()
102{
321db4b6 103 wxWindow::ChangeBackgroundColour();
0d57be45
JS
104}
105
106void wxStaticText::ChangeForegroundColour()
107{
321db4b6 108 wxWindow::ChangeForegroundColour();
0d57be45
JS
109}
110