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