]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/stattext.cpp
Changed event type ids to constants instead of enum, for extensibility.
[wxWidgets.git] / src / gtk1 / stattext.cpp
CommitLineData
c801d85f
KB
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
22IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl)
23
24wxStaticText::wxStaticText(void)
25{
26};
27
28wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
29 const wxPoint &pos, const wxSize &size,
debe6624 30 long style, const wxString &name )
c801d85f
KB
31{
32 Create( parent, id, label, pos, size, style, name );
33};
34
35bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label,
36 const wxPoint &pos, const wxSize &size,
debe6624 37 long style, const wxString &name )
c801d85f
KB
38{
39 m_needParent = TRUE;
40
41 wxSize newSize = size;
42
43 PreCreation( parent, id, pos, size, style, name );
44
32c77a71
VZ
45 wxControl::SetLabel(label);
46 m_widget = gtk_label_new( m_label );
47
604a1783
VZ
48 GtkJustification justify;
49 if ( style & wxALIGN_CENTER )
50 justify = GTK_JUSTIFY_CENTER;
51 else if ( style & wxALIGN_RIGHT )
52 justify = GTK_JUSTIFY_RIGHT;
53 else // wxALIGN_LEFT is 0
54 justify = GTK_JUSTIFY_LEFT;
55 gtk_label_set_justify(GTK_LABEL(m_widget), justify);
c801d85f
KB
56
57 if (newSize.x == -1) newSize.x = gdk_string_measure( m_widget->style->font, label );
58 if (newSize.y == -1) newSize.y = 26;
59 SetSize( newSize.x, newSize.y );
60
61 PostCreation();
62
63 Show( TRUE );
64
65 return TRUE;
66};
67
68wxString wxStaticText::GetLabel(void) const
69{
70 char *str = NULL;
71 gtk_label_get( GTK_LABEL(m_widget), &str );
72 wxString tmp( str );
73 return tmp;
74};
75
76void wxStaticText::SetLabel( const wxString &label )
77{
32c77a71
VZ
78 wxControl::SetLabel(label);
79
80 gtk_label_set( GTK_LABEL(m_widget), m_label );
c801d85f 81};