]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/stattext.cpp
b1f31084a56e3d833e5c06d226a1efc6ffbb7d42
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(void)
30 wxStaticText::wxStaticText( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
31 const wxPoint
&pos
, const wxSize
&size
,
32 long style
, const wxString
&name
)
34 Create( parent
, id
, label
, pos
, size
, style
, name
);
37 bool wxStaticText::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
38 const wxPoint
&pos
, const wxSize
&size
,
39 long style
, const wxString
&name
)
43 wxSize newSize
= size
;
45 PreCreation( parent
, id
, pos
, size
, style
, name
);
47 wxControl::SetLabel(label
);
48 m_widget
= gtk_label_new( m_label
);
50 GtkJustification justify
;
51 if ( style
& wxALIGN_CENTER
)
52 justify
= GTK_JUSTIFY_CENTER
;
53 else if ( style
& wxALIGN_RIGHT
)
54 justify
= GTK_JUSTIFY_RIGHT
;
55 else // wxALIGN_LEFT is 0
56 justify
= GTK_JUSTIFY_LEFT
;
57 gtk_label_set_justify(GTK_LABEL(m_widget
), justify
);
60 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget
)->klass
)->size_request
) (m_widget
, &req
);
62 if (newSize
.x
== -1) newSize
.x
= req
.width
;
63 if (newSize
.y
== -1) newSize
.y
= req
.height
;
65 SetSize( newSize
.x
, newSize
.y
);
67 m_parent
->AddChild( this );
69 (m_parent
->m_insertCallback
)( m_parent
, this );
73 SetBackgroundColour( parent
->GetBackgroundColour() );
74 SetForegroundColour( parent
->GetForegroundColour() );
81 wxString
wxStaticText::GetLabel(void) const
83 char *str
= (char *) NULL
;
84 gtk_label_get( GTK_LABEL(m_widget
), &str
);
89 void wxStaticText::SetLabel( const wxString
&label
)
91 wxControl::SetLabel(label
);
93 gtk_label_set( GTK_LABEL(m_widget
), m_label
);
96 void wxStaticText::ApplyWidgetStyle()
99 gtk_widget_set_style( m_widget
, m_widgetStyle
);