]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/stattext.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/motif/stattext.cpp 
   3 // Purpose:     wxStaticText 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  17 #include "wx/stattext.h" 
  20 #pragma message disable nosimpint 
  24 #pragma message enable nosimpint 
  27 #include "wx/motif/private.h" 
  29 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
) 
  31 bool wxStaticText::Create(wxWindow 
*parent
, wxWindowID id
, 
  32            const wxString
& label
, 
  38     if( !CreateControl( parent
, id
, pos
, size
, style
, 
  39                         wxDefaultValidator
, name 
) ) 
  41     m_labelWidget 
= (WXWidget
) 0; 
  44     Widget parentWidget 
= (Widget
) parent
->GetClientWidget(); 
  47         (Widget
) wxCreateBorderWidget( (WXWidget
)parentWidget
, style 
); 
  50         XtVaCreateManagedWidget (name
.mb_str(), 
  52             borderWidget 
? borderWidget 
: parentWidget
, 
  53             wxFont::GetFontTag(), m_font
.GetFontTypeC(XtDisplay(parentWidget
)), 
  54             XmNalignment
, ((style 
& wxALIGN_RIGHT
)  ? XmALIGNMENT_END 
: 
  55                           ((style 
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER 
: 
  56                                                       XmALIGNMENT_BEGINNING
)), 
  57             XmNrecomputeSize
, ((style 
& wxST_NO_AUTORESIZE
) ? TRUE 
: FALSE
), 
  60     m_mainWidget 
= borderWidget 
? borderWidget 
: m_labelWidget
; 
  64     wxSize best 
= GetBestSize(); 
  65     if( size
.x 
!= -1 ) best
.x 
= size
.x
; 
  66     if( size
.y 
!= -1 ) best
.y 
= size
.y
; 
  69     AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, 
  70                   pos
.x
, pos
.y
, best
.x
, best
.y
); 
  75 void wxStaticText::SetLabel(const wxString
& label
) 
  77     m_labelOrig 
= label
;       // save original label 
  79     // Motif does not support neither ellipsize nor markup in static text: 
  80     DoSetLabel(GetEllipsizedLabelWithoutMarkup()); 
  83 // for wxST_ELLIPSIZE_* support: 
  85 wxString 
wxStaticText::DoGetLabel() const 
  87     XmString label 
= NULL
; 
  88     XtVaGetValues((Widget
)m_labelWidget
, XmNlabelString
, &label
, NULL
); 
  90     return wxXmStringToString(label
); 
  93 void wxStaticText::DoSetLabel(const wxString
& str
) 
  95     // build our own cleaned label 
  96     wxXmString 
label_str(RemoveMnemonics(str
)); 
  98     // This variable means we don't need so many casts later. 
  99     Widget widget 
= (Widget
) m_labelWidget
; 
 101         XtVaSetValues(widget
, 
 102             XmNlabelString
, label_str(), 
 103             XmNlabelType
, XmSTRING
, 
 108    FIXME: UpdateLabel() should be called on size events to allow correct 
 109           dynamic ellipsizing of the label 
 112 wxSize 
wxStaticText::DoGetBestSize() const 
 115     GetTextExtent(GetLabelText(), &w
, &h
, NULL
, NULL
, NULL
); 
 120 #endif // wxUSE_STATTEXT