1///////////////////////////////////////////////////////////////////////////// 2// Name: src/motif/stattext.cpp 3// Purpose: wxStaticText 4// Author: Julian Smart 5// Modified by: 6// Created: 04/01/98 7// RCS-ID: $Id: stattext.cpp 50982 2008-01-01 20:38:33Z VZ $ 8// Copyright: (c) Julian Smart 9// Licence: wxWindows licence 10///////////////////////////////////////////////////////////////////////////// 11 12// For compilers that support precompilation, includes "wx.h". 13#include "wx/wxprec.h" 14 15#if wxUSE_STATTEXT 16 17#include "wx/stattext.h" 18 19#ifdef __VMS__ 20#pragma message disable nosimpint 21#endif 22#include <Xm/Label.h> 23#ifdef __VMS__ 24#pragma message enable nosimpint 25#endif 26 27#include "wx/motif/private.h" 28 29IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) 30 31bool wxStaticText::Create(wxWindow *parent, wxWindowID id, 32 const wxString& label, 33 const wxPoint& pos, 34 const wxSize& size, 35 long style, 36 const wxString& name) 37{ 38 if( !CreateControl( parent, id, pos, size, style, 39 wxDefaultValidator, name ) ) 40 return false; 41 42 Widget parentWidget = (Widget) parent->GetClientWidget(); 43 44 Widget borderWidget = 45 (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style ); 46 wxXmString text( GetLabelText( label ) ); 47 48 m_labelWidget = 49 XtVaCreateManagedWidget (wxConstCast(name.c_str(), char), 50 xmLabelWidgetClass, 51 borderWidget ? borderWidget : parentWidget, 52 wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)), 53 XmNlabelString, text(), 54 XmNalignment, ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END : 55 ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER : 56 XmALIGNMENT_BEGINNING)), 57 XmNrecomputeSize, ((style & wxST_NO_AUTORESIZE) ? TRUE : FALSE), 58 NULL); 59 60 m_mainWidget = borderWidget ? borderWidget : m_labelWidget; 61 62 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, 63 pos.x, pos.y, size.x, size.y); 64 65 ChangeBackgroundColour (); 66 67 return true; 68} 69 70void wxStaticText::SetLabel(const wxString& label) 71{ 72 wxXmString label_str(GetLabelText(label)); 73 74 // This variable means we don't need so many casts later. 75 Widget widget = (Widget) m_labelWidget; 76 77 XtVaSetValues(widget, 78 XmNlabelString, label_str(), 79 XmNlabelType, XmSTRING, 80 NULL); 81} 82 83#endif // wxUSE_STATTEXT 84