]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/stattext.cpp
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"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
,wxControl
)
26 wxStaticText::wxStaticText()
30 wxStaticText::wxStaticText(wxWindow
*parent
,
32 const wxString
&label
,
38 Create( parent
, id
, label
, pos
, size
, style
, name
);
41 bool wxStaticText::Create(wxWindow
*parent
,
43 const wxString
&label
,
47 const wxString
&name
)
51 wxSize newSize
= size
;
53 PreCreation( parent
, id
, pos
, size
, style
, name
);
55 // notice that we call the base class version which will just remove the
56 // '&' characters from the string, but not set the label's text to it
57 // because the label is not yet created and because SetLabel() has a side
58 // effect of changing the control size which might not be desirable
59 wxControl::SetLabel(label
);
60 m_widget
= gtk_label_new( m_label
);
62 GtkJustification justify
;
63 if ( style
& wxALIGN_CENTER
)
64 justify
= GTK_JUSTIFY_CENTER
;
65 else if ( style
& wxALIGN_RIGHT
)
66 justify
= GTK_JUSTIFY_RIGHT
;
67 else // wxALIGN_LEFT is 0
68 justify
= GTK_JUSTIFY_LEFT
;
69 gtk_label_set_justify(GTK_LABEL(m_widget
), justify
);
72 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget
)->klass
)->size_request
) (m_widget
, &req
);
74 if (newSize
.x
== -1) newSize
.x
= req
.width
;
75 if (newSize
.y
== -1) newSize
.y
= req
.height
;
77 SetSize( newSize
.x
, newSize
.y
);
79 m_parent
->AddChild( this );
81 (m_parent
->m_insertCallback
)( m_parent
, this );
85 SetBackgroundColour( parent
->GetBackgroundColour() );
86 SetForegroundColour( parent
->GetForegroundColour() );
87 SetFont( parent
->GetFont() );
94 wxString
wxStaticText::GetLabel(void) const
96 char *str
= (char *) NULL
;
97 gtk_label_get( GTK_LABEL(m_widget
), &str
);
102 void wxStaticText::SetLabel( const wxString
&label
)
104 wxControl::SetLabel(label
);
106 gtk_label_set( GTK_LABEL(m_widget
), m_label
);
108 // adjust the label size to the new label
110 // TODO there should be a way to prevent SetLabel() from doing it (an
111 // additional parameter?)
113 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget
)->klass
)->size_request
) (m_widget
, &req
);
115 SetSize( req
.width
, req
.height
);
118 void wxStaticText::ApplyWidgetStyle()
121 gtk_widget_set_style( m_widget
, m_widgetStyle
);