]> git.saurik.com Git - wxWidgets.git/blob - src/motif/stattext.cpp
support for incorrect entries in .mime.types added (world is not perfect, alas)
[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 #include <Xm/Label.h>
22 #include <Xm/LabelG.h>
23 #include <Xm/PushBG.h>
24
25 #if !USE_SHARED_LIBRARY
26 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
27 #endif
28
29 bool 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 {
36 SetName(name);
37 if (parent) parent->AddChild(this);
38
39 m_backgroundColour = parent->GetBackgroundColour();
40 m_foregroundColour = parent->GetForegroundColour();
41
42 if ( id == -1 )
43 m_windowId = (int)NewControlId();
44 else
45 m_windowId = id;
46
47 m_windowStyle = style;
48 m_windowFont = parent->GetFont();
49
50 char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
51
52 Widget parentWidget = (Widget) parent->GetClientWidget();
53
54 // Use XmStringCreateLtoR(), since XmStringCreateSimple
55 // doesn't obey separators.
56 // XmString text = XmStringCreateSimple (label1);
57 XmString text = XmStringCreateLtoR (label1, XmSTRING_DEFAULT_CHARSET);
58
59 XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
60
61 m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
62 xmLabelWidgetClass,
63 parentWidget,
64 XmNfontList, fontList,
65 XmNlabelString, text,
66 XmNalignment,
67 ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
68 ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER :
69 XmALIGNMENT_BEGINNING)),
70 NULL);
71
72 XmStringFree (text);
73
74 SetCanAddEventHandler(TRUE);
75 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
76
77 ChangeBackgroundColour ();
78
79 return TRUE;
80 }
81
82 void wxStaticText::ChangeFont(bool keepOriginalSize)
83 {
84 wxWindow::ChangeFont(keepOriginalSize);
85 }
86
87 void wxStaticText::ChangeBackgroundColour()
88 {
89 wxWindow::ChangeBackgroundColour();
90 }
91
92 void wxStaticText::ChangeForegroundColour()
93 {
94 wxWindow::ChangeForegroundColour();
95 }
96