]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/stattext.cpp
fd3c5ee83d3ba2fd19499e75e93023ea46792340
   1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  12 #pragma implementation "stattext.h" 
  15 #include "wx/stattext.h" 
  17 //----------------------------------------------------------------------------- 
  19 //----------------------------------------------------------------------------- 
  21 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
,wxControl
) 
  23 wxStaticText::wxStaticText(void) 
  27 wxStaticText::wxStaticText( wxWindow 
*parent
, wxWindowID id
, const wxString 
&label
,  
  28       const wxPoint 
&pos
, const wxSize 
&size
,  
  29       long style
, const wxString 
&name 
) 
  31   Create( parent
, id
, label
, pos
, size
, style
, name 
); 
  34 bool wxStaticText::Create( wxWindow 
*parent
, wxWindowID id
, const wxString 
&label
,  
  35       const wxPoint 
&pos
, const wxSize 
&size
,  
  36       long style
, const wxString 
&name 
) 
  40   wxSize newSize 
= size
; 
  42   PreCreation( parent
, id
, pos
, size
, style
, name 
); 
  44   wxControl::SetLabel(label
); 
  45   m_widget 
= gtk_label_new( m_label 
); 
  47   GtkJustification justify
; 
  48   if ( style 
& wxALIGN_CENTER 
) 
  49     justify 
= GTK_JUSTIFY_CENTER
; 
  50   else if ( style 
& wxALIGN_RIGHT 
) 
  51     justify 
= GTK_JUSTIFY_RIGHT
; 
  52   else // wxALIGN_LEFT is 0 
  53     justify 
= GTK_JUSTIFY_LEFT
; 
  54   gtk_label_set_justify(GTK_LABEL(m_widget
), justify
); 
  59      char *s 
= WXSTRINGCAST m_label
; 
  60      char *nl 
= strchr(s
, '\n'); 
  66          int x 
= gdk_string_measure( m_widget
->style
->font
, s 
) + 4; 
  67          if (x 
> newSize
.x
) newSize
.x 
= x
; 
  70          if (! (nl 
= strchr(s 
= nl
, '\n')))  
  73            int x 
= gdk_string_measure( m_widget
->style
->font
, s 
) + 4; 
  74            if (x 
> newSize
.x
) newSize
.x 
= x
; 
  80        newSize
.x 
= gdk_string_measure( m_widget
->style
->font
, label 
) + 4; 
  88        newSize
.y 
= 4 + y 
* (m_widget
->style
->font
->ascent 
+ m_widget
->style
->font
->descent 
+ 2); 
  91   SetSize( newSize
.x
, newSize
.y 
); 
  93   m_parent
->AddChild( this ); 
  95   (m_parent
->m_insertCallback
)( m_parent
, this ); 
  99   SetBackgroundColour( parent
->GetBackgroundColour() ); 
 100   SetForegroundColour( parent
->GetForegroundColour() ); 
 107 wxString 
wxStaticText::GetLabel(void) const 
 109   char *str 
= (char *) NULL
; 
 110   gtk_label_get( GTK_LABEL(m_widget
), &str 
); 
 115 void wxStaticText::SetLabel( const wxString 
&label 
) 
 117   wxControl::SetLabel(label
); 
 119   gtk_label_set( GTK_LABEL(m_widget
), m_label 
); 
 122 void wxStaticText::ApplyWidgetStyle() 
 125   gtk_widget_set_style( m_widget
, m_widgetStyle 
);