Committing in .
[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 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
33 #endif
34
35 bool 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 {
42 SetName(name);
43 if (parent) parent->AddChild(this);
44
45 m_backgroundColour = parent->GetBackgroundColour();
46 m_foregroundColour = parent->GetForegroundColour();
47
48 if ( id == -1 )
49 m_windowId = (int)NewControlId();
50 else
51 m_windowId = id;
52
53 m_windowStyle = style;
54 m_font = parent->GetFont();
55
56 #if 0 // gcc 2.95 doesn't like this apparently
57 char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
58 #endif
59
60 Widget parentWidget = (Widget) parent->GetClientWidget();
61
62 #if 0 // gcc 2.95 doesn't like this apparently
63 // Use XmStringCreateLtoR(), since XmStringCreateSimple
64 // doesn't obey separators.
65 // XmString text = XmStringCreateSimple (label1);
66 XmString text = XmStringCreateLtoR (label1, XmSTRING_DEFAULT_CHARSET);
67 #endif // 0
68
69 XmString text = XmStringCreateLtoR ((char *)(const char*)label, XmSTRING_DEFAULT_CHARSET);
70
71 XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
72
73 m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
74 xmLabelWidgetClass,
75 parentWidget,
76 XmNfontList, fontList,
77 XmNlabelString, text,
78 XmNalignment,
79 ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
80 ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER :
81 XmALIGNMENT_BEGINNING)),
82 NULL);
83
84 XmStringFree (text);
85
86 SetCanAddEventHandler(TRUE);
87 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
88
89 ChangeBackgroundColour ();
90
91 return TRUE;
92 }
93
94 void wxStaticText::ChangeFont(bool keepOriginalSize)
95 {
96 wxWindow::ChangeFont(keepOriginalSize);
97 }
98
99 void wxStaticText::ChangeBackgroundColour()
100 {
101 wxWindow::ChangeBackgroundColour();
102 }
103
104 void wxStaticText::ChangeForegroundColour()
105 {
106 wxWindow::ChangeForegroundColour();
107 }
108