]> git.saurik.com Git - wxWidgets.git/blame - src/motif/stattext.cpp
Changed two conflicting defines in defs.h
[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
16#include "wx/app.h"
17#include "wx/stattext.h"
18
19#include <stdio.h>
20
02e8b2f9
JS
21#include <Xm/Label.h>
22#include <Xm/LabelG.h>
23#include <Xm/PushBG.h>
24
4bb6408c
JS
25#if !USE_SHARED_LIBRARY
26IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
27#endif
28
29bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
30 const wxString& label,
31 const wxPoint& pos,
32 const wxSize& size,
33 long style,
34 const wxString& name)
35{
a4294b78
JS
36 SetName(name);
37 if (parent) parent->AddChild(this);
4bb6408c 38
0d57be45
JS
39 m_backgroundColour = parent->GetBackgroundColour();
40 m_foregroundColour = parent->GetForegroundColour();
4bb6408c 41
a4294b78 42 if ( id == -1 )
31528cd3 43 m_windowId = (int)NewControlId();
a4294b78 44 else
31528cd3 45 m_windowId = id;
4bb6408c 46
a4294b78 47 m_windowStyle = style;
da175b2c 48 m_font = parent->GetFont();
4bb6408c 49
7a4b8f27 50#if 0 // gcc 2.95 doesn't like this apparently
a4294b78 51 char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
7a4b8f27
MB
52#endif
53
a4294b78 54 Widget parentWidget = (Widget) parent->GetClientWidget();
02e8b2f9 55
7a4b8f27 56#if 0 // gcc 2.95 doesn't like this apparently
8cbd2bde
JS
57 // Use XmStringCreateLtoR(), since XmStringCreateSimple
58 // doesn't obey separators.
59// XmString text = XmStringCreateSimple (label1);
60 XmString text = XmStringCreateLtoR (label1, XmSTRING_DEFAULT_CHARSET);
7a4b8f27
MB
61#endif // 0
62
63 XmString text = XmStringCreateLtoR ((char *)(const char*)label, XmSTRING_DEFAULT_CHARSET);
64
da175b2c 65 XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
ea57084d 66
a4294b78 67 m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
02e8b2f9
JS
68 xmLabelWidgetClass,
69 parentWidget,
ea57084d 70 XmNfontList, fontList,
02e8b2f9
JS
71 XmNlabelString, text,
72 XmNalignment,
73 ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
74 ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER :
75 XmALIGNMENT_BEGINNING)),
76 NULL);
77
a4294b78 78 XmStringFree (text);
02e8b2f9 79
a4294b78
JS
80 SetCanAddEventHandler(TRUE);
81 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
02e8b2f9 82
0d57be45 83 ChangeBackgroundColour ();
4bb6408c 84
a4294b78 85 return TRUE;
4bb6408c
JS
86}
87
4b5f3fe6 88void wxStaticText::ChangeFont(bool keepOriginalSize)
0d57be45 89{
4b5f3fe6 90 wxWindow::ChangeFont(keepOriginalSize);
0d57be45
JS
91}
92
93void wxStaticText::ChangeBackgroundColour()
94{
321db4b6 95 wxWindow::ChangeBackgroundColour();
0d57be45
JS
96}
97
98void wxStaticText::ChangeForegroundColour()
99{
321db4b6 100 wxWindow::ChangeForegroundColour();
0d57be45
JS
101}
102