]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/stattext.cpp
Added menu_highlight behaviour as in wxMSW (statusbar)
[wxWidgets.git] / src / gtk / 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
76 Show( TRUE );
77
78 return TRUE;
79 }
80
81 wxString wxStaticText::GetLabel(void) const
82 {
83 char *str = (char *) NULL;
84 gtk_label_get( GTK_LABEL(m_widget), &str );
85 wxString tmp( str );
86 return tmp;
87 }
88
89 void wxStaticText::SetLabel( const wxString &label )
90 {
91 wxControl::SetLabel(label);
92
93 gtk_label_set( GTK_LABEL(m_widget), m_label );
94 }
95
96 void wxStaticText::ApplyWidgetStyle()
97 {
98 SetWidgetStyle();
99 gtk_widget_set_style( m_widget, m_widgetStyle );
100 }
101