]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/stattext.cpp
wxGTK compiles (and links) when configured without threads
[wxWidgets.git] / src / gtk / stattext.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: stattext.cpp
3// Purpose:
4// Author: Robert Roebling
a81258be
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
c801d85f
KB
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifdef __GNUG__
12#pragma implementation "stattext.h"
13#endif
14
15#include "wx/stattext.h"
16
17//-----------------------------------------------------------------------------
18// wxStaticText
19//-----------------------------------------------------------------------------
20
21IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl)
22
23wxStaticText::wxStaticText(void)
24{
3f659fd6 25}
c801d85f
KB
26
27wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
28 const wxPoint &pos, const wxSize &size,
debe6624 29 long style, const wxString &name )
c801d85f
KB
30{
31 Create( parent, id, label, pos, size, style, name );
3f659fd6 32}
c801d85f
KB
33
34bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label,
35 const wxPoint &pos, const wxSize &size,
debe6624 36 long style, const wxString &name )
c801d85f 37{
a93109d5 38 m_needParent = TRUE;
c801d85f 39
a93109d5 40 wxSize newSize = size;
c801d85f 41
a93109d5 42 PreCreation( parent, id, pos, size, style, name );
c801d85f 43
a93109d5
RR
44 wxControl::SetLabel(label);
45 m_widget = gtk_label_new( m_label );
46
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);
55
56 GtkRequisition req;
57 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
58
59 if (newSize.x == -1) newSize.x = req.width;
60 if (newSize.y == -1) newSize.y = req.height;
61
62 SetSize( newSize.x, newSize.y );
c801d85f 63
a93109d5 64 m_parent->AddChild( this );
6ca41e57 65
a93109d5 66 (m_parent->m_insertCallback)( m_parent, this );
6ca41e57 67
a93109d5 68 PostCreation();
c801d85f 69
a93109d5
RR
70 SetBackgroundColour( parent->GetBackgroundColour() );
71 SetForegroundColour( parent->GetForegroundColour() );
58614078 72
a93109d5 73 Show( TRUE );
c801d85f 74
a93109d5 75 return TRUE;
3f659fd6 76}
c801d85f
KB
77
78wxString wxStaticText::GetLabel(void) const
79{
a93109d5
RR
80 char *str = (char *) NULL;
81 gtk_label_get( GTK_LABEL(m_widget), &str );
82 wxString tmp( str );
83 return tmp;
3f659fd6 84}
c801d85f
KB
85
86void wxStaticText::SetLabel( const wxString &label )
87{
a93109d5 88 wxControl::SetLabel(label);
32c77a71 89
a93109d5
RR
90 gtk_label_set( GTK_LABEL(m_widget), m_label );
91}
58614078
RR
92
93void wxStaticText::ApplyWidgetStyle()
94{
a93109d5
RR
95 SetWidgetStyle();
96 gtk_widget_set_style( m_widget, m_widgetStyle );
58614078
RR
97}
98