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