]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/stattext.cpp
Cured some Latex problems; fixed i declaration; fixed filedlg.cpp
[wxWidgets.git] / src / gtk1 / 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
83624f79
RR
17#include "gdk/gdk.h"
18#include "gtk/gtk.h"
19
c801d85f
KB
20//-----------------------------------------------------------------------------
21// wxStaticText
22//-----------------------------------------------------------------------------
23
24IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl)
25
26wxStaticText::wxStaticText(void)
27{
3f659fd6 28}
c801d85f
KB
29
30wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
31 const wxPoint &pos, const wxSize &size,
debe6624 32 long style, const wxString &name )
c801d85f
KB
33{
34 Create( parent, id, label, pos, size, style, name );
3f659fd6 35}
c801d85f
KB
36
37bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label,
38 const wxPoint &pos, const wxSize &size,
debe6624 39 long style, const wxString &name )
c801d85f 40{
a93109d5 41 m_needParent = TRUE;
c801d85f 42
a93109d5 43 wxSize newSize = size;
c801d85f 44
a93109d5 45 PreCreation( parent, id, pos, size, style, name );
c801d85f 46
a93109d5
RR
47 wxControl::SetLabel(label);
48 m_widget = gtk_label_new( m_label );
49
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);
58
59 GtkRequisition req;
60 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
61
62 if (newSize.x == -1) newSize.x = req.width;
63 if (newSize.y == -1) newSize.y = req.height;
64
65 SetSize( newSize.x, newSize.y );
c801d85f 66
a93109d5 67 m_parent->AddChild( this );
6ca41e57 68
a93109d5 69 (m_parent->m_insertCallback)( m_parent, this );
6ca41e57 70
a93109d5 71 PostCreation();
c801d85f 72
a93109d5
RR
73 SetBackgroundColour( parent->GetBackgroundColour() );
74 SetForegroundColour( parent->GetForegroundColour() );
58614078 75
a93109d5 76 Show( TRUE );
c801d85f 77
a93109d5 78 return TRUE;
3f659fd6 79}
c801d85f
KB
80
81wxString wxStaticText::GetLabel(void) const
82{
a93109d5
RR
83 char *str = (char *) NULL;
84 gtk_label_get( GTK_LABEL(m_widget), &str );
85 wxString tmp( str );
86 return tmp;
3f659fd6 87}
c801d85f
KB
88
89void wxStaticText::SetLabel( const wxString &label )
90{
a93109d5 91 wxControl::SetLabel(label);
32c77a71 92
a93109d5
RR
93 gtk_label_set( GTK_LABEL(m_widget), m_label );
94}
58614078
RR
95
96void wxStaticText::ApplyWidgetStyle()
97{
a93109d5
RR
98 SetWidgetStyle();
99 gtk_widget_set_style( m_widget, m_widgetStyle );
58614078
RR
100}
101