]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/stattext.cpp
added sorted arrays: they automatically sort items on insertion (using user
[wxWidgets.git] / src / gtk / stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stattext.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11
12 #ifdef __GNUG__
13 #pragma implementation "stattext.h"
14 #endif
15
16 #include "wx/stattext.h"
17
18 //-----------------------------------------------------------------------------
19 // wxStaticText
20 //-----------------------------------------------------------------------------
21
22 IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl)
23
24 wxStaticText::wxStaticText(void)
25 {
26 };
27
28 wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
29 const wxPoint &pos, const wxSize &size,
30 long style, const wxString &name )
31 {
32 Create( parent, id, label, pos, size, style, name );
33 };
34
35 bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label,
36 const wxPoint &pos, const wxSize &size,
37 long style, const wxString &name )
38 {
39 m_needParent = TRUE;
40
41 wxSize newSize = size;
42
43 PreCreation( parent, id, pos, size, style, name );
44
45 m_widget = gtk_label_new( label );
46 GtkJustification justify;
47 if ( style & wxALIGN_CENTER )
48 justify = GTK_JUSTIFY_CENTER;
49 else if ( style & wxALIGN_RIGHT )
50 justify = GTK_JUSTIFY_RIGHT;
51 else // wxALIGN_LEFT is 0
52 justify = GTK_JUSTIFY_LEFT;
53 gtk_label_set_justify(GTK_LABEL(m_widget), justify);
54
55 if (newSize.x == -1) newSize.x = gdk_string_measure( m_widget->style->font, label );
56 if (newSize.y == -1) newSize.y = 26;
57 SetSize( newSize.x, newSize.y );
58
59 PostCreation();
60
61 Show( TRUE );
62
63 return TRUE;
64 };
65
66 wxString wxStaticText::GetLabel(void) const
67 {
68 char *str = NULL;
69 gtk_label_get( GTK_LABEL(m_widget), &str );
70 wxString tmp( str );
71 return tmp;
72 };
73
74 void wxStaticText::SetLabel( const wxString &label )
75 {
76 gtk_label_set( GTK_LABEL(m_widget), label );
77 };