]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticText
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "stattext.h"
17 #define XtDisplay XTDISPLAY
21 #include "wx/stattext.h"
26 #pragma message disable nosimpint
30 #include <Xm/LabelG.h>
31 #include <Xm/PushBG.h>
33 #pragma message enable nosimpint
36 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
)
38 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
39 const wxString
& label
,
46 if (parent
) parent
->AddChild(this);
48 m_backgroundColour
= parent
->GetBackgroundColour();
49 m_foregroundColour
= parent
->GetForegroundColour();
52 m_windowId
= (int)NewControlId();
56 m_windowStyle
= style
;
57 m_font
= parent
->GetFont();
59 #if 0 // gcc 2.95 doesn't like this apparently
60 char* label1
= (label
.IsNull() ? "" : (char*) (const char*) label
);
63 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
65 Widget borderWidget
= NULL
;
67 // Decorate the label widget if a border style is specified.
68 if (style
& wxSIMPLE_BORDER
)
70 borderWidget
= XtVaCreateManagedWidget
73 xmFrameWidgetClass
, parentWidget
,
74 XmNshadowType
, XmSHADOW_ETCHED_IN
,
75 XmNshadowThickness
, 1,
78 } else if (style
& wxSUNKEN_BORDER
)
80 borderWidget
= XtVaCreateManagedWidget
83 xmFrameWidgetClass
, parentWidget
,
84 XmNshadowType
, XmSHADOW_IN
,
87 } else if (style
& wxRAISED_BORDER
)
89 borderWidget
= XtVaCreateManagedWidget
92 xmFrameWidgetClass
, parentWidget
,
93 XmNshadowType
, XmSHADOW_OUT
,
98 #if 0 // gcc 2.95 doesn't like this apparently
99 // Use XmStringCreateLtoR(), since XmStringCreateSimple
100 // doesn't obey separators.
101 // XmString text = XmStringCreateSimple (label1);
102 XmString text
= XmStringCreateLtoR (label1
, XmSTRING_DEFAULT_CHARSET
);
105 XmString text
= XmStringCreateLtoR ((char *)(const char*)label
, XmSTRING_DEFAULT_CHARSET
);
107 XmFontList fontList
= (XmFontList
) m_font
.GetFontList(1.0, XtDisplay(parentWidget
));
109 Widget labelWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
111 borderWidget
? borderWidget
: parentWidget
,
112 XmNfontList
, fontList
,
113 XmNlabelString
, text
,
115 ((style
& wxALIGN_RIGHT
) ? XmALIGNMENT_END
:
116 ((style
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER
:
117 XmALIGNMENT_BEGINNING
)),
122 m_mainWidget
= borderWidget
? borderWidget
: labelWidget
;
124 SetCanAddEventHandler(TRUE
);
125 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
127 ChangeBackgroundColour ();
132 void wxStaticText::ChangeFont(bool keepOriginalSize
)
134 wxWindow::ChangeFont(keepOriginalSize
);
137 void wxStaticText::ChangeBackgroundColour()
139 wxWindow::ChangeBackgroundColour();
142 void wxStaticText::ChangeForegroundColour()
144 wxWindow::ChangeForegroundColour();