]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "stattext.h"
16 #include "wx/stattext.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
,wxControl
)
24 wxStaticText::wxStaticText(void)
28 wxStaticText::wxStaticText( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
29 const wxPoint
&pos
, const wxSize
&size
,
30 long style
, const wxString
&name
)
32 Create( parent
, id
, label
, pos
, size
, style
, name
);
35 bool wxStaticText::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
36 const wxPoint
&pos
, const wxSize
&size
,
37 long style
, const wxString
&name
)
41 wxSize newSize
= size
;
43 PreCreation( parent
, id
, pos
, size
, style
, name
);
45 wxControl::SetLabel(label
);
46 m_widget
= gtk_label_new( m_label
);
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
);
58 if (newSize
.x
== -1) {
59 char *s
= WXSTRINGCAST m_label
;
60 char *nl
= strchr(s
, '\n');
64 int x
= gdk_string_measure( m_widget
->style
->font
, s
);
69 if ((nl
= strchr(s
= nl
, '\n'))) {
72 int x
= gdk_string_measure( m_widget
->style
->font
, s
);
79 newSize
.x
= gdk_string_measure( m_widget
->style
->font
, label
);
82 if (newSize
.y
== -1) {
87 = y
* (m_widget
->style
->font
->ascent
+m_widget
->style
->font
->descent
);
91 SetSize( newSize
.x
, newSize
.y
);
100 wxString
wxStaticText::GetLabel(void) const
102 char *str
= (char *) NULL
;
103 gtk_label_get( GTK_LABEL(m_widget
), &str
);
108 void wxStaticText::SetLabel( const wxString
&label
)
110 wxControl::SetLabel(label
);
112 gtk_label_set( GTK_LABEL(m_widget
), m_label
);