]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/stattext.cpp
support for incorrect entries in .mime.types added (world is not perfect, alas)
[wxWidgets.git] / src / gtk1 / stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stattext.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
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 #include "gdk/gdk.h"
18 #include "gtk/gtk.h"
19
20 //-----------------------------------------------------------------------------
21 // wxStaticText
22 //-----------------------------------------------------------------------------
23
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl)
25
26 wxStaticText::wxStaticText(void)
27 {
28 }
29
30 wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
31 const wxPoint &pos, const wxSize &size,
32 long style, const wxString &name )
33 {
34 Create( parent, id, label, pos, size, style, name );
35 }
36
37 bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label,
38 const wxPoint &pos, const wxSize &size,
39 long style, const wxString &name )
40 {
41 m_needParent = TRUE;
42
43 wxSize newSize = size;
44
45 PreCreation( parent, id, pos, size, style, name );
46
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 );
66
67 m_parent->AddChild( this );
68
69 (m_parent->m_insertCallback)( m_parent, this );
70
71 PostCreation();
72
73 SetBackgroundColour( parent->GetBackgroundColour() );
74 SetForegroundColour( parent->GetForegroundColour() );
75 SetFont( parent->GetFont() );
76
77 Show( TRUE );
78
79 return TRUE;
80 }
81
82 wxString wxStaticText::GetLabel(void) const
83 {
84 char *str = (char *) NULL;
85 gtk_label_get( GTK_LABEL(m_widget), &str );
86 wxString tmp( str );
87 return tmp;
88 }
89
90 void wxStaticText::SetLabel( const wxString &label )
91 {
92 wxControl::SetLabel(label);
93
94 gtk_label_set( GTK_LABEL(m_widget), m_label );
95 }
96
97 void wxStaticText::ApplyWidgetStyle()
98 {
99 SetWidgetStyle();
100 gtk_widget_set_style( m_widget, m_widgetStyle );
101 }
102