]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/statbox.cpp
fix compilation for GTK1
[wxWidgets.git] / src / gtk1 / statbox.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: gtk/statbox.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "statbox.h"
12#endif
13
14#include "wx/defs.h"
15
16#if wxUSE_STATBOX
17
18#include "wx/statbox.h"
19#include "wx/gtk/private.h"
20
21#include "gdk/gdk.h"
22#include "gtk/gtk.h"
23
24//-----------------------------------------------------------------------------
25// wxStaticBox
26//-----------------------------------------------------------------------------
27
28IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
29
30wxStaticBox::wxStaticBox()
31{
32}
33
34wxStaticBox::wxStaticBox( wxWindow *parent,
35 wxWindowID id,
36 const wxString &label,
37 const wxPoint& pos,
38 const wxSize& size,
39 long style,
40 const wxString& name )
41{
42 Create( parent, id, label, pos, size, style, name );
43}
44
45bool wxStaticBox::Create( wxWindow *parent,
46 wxWindowID id,
47 const wxString& label,
48 const wxPoint& pos,
49 const wxSize& size,
50 long style,
51 const wxString& name )
52{
53 m_needParent = TRUE;
54
55 if (!PreCreation( parent, pos, size ) ||
56 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
57 {
58 wxFAIL_MSG( wxT("wxStaticBox creation failed") );
59 return FALSE;
60 }
61
62 wxControl::SetLabel(label);
63
64 m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
65
66 m_parent->DoAddChild( this );
67
68 PostCreation();
69
70 InheritAttributes();
71
72 // need to set non default alignment?
73 gfloat xalign;
74 if ( style & wxALIGN_CENTER )
75 xalign = 0.5;
76 else if ( style & wxALIGN_RIGHT )
77 xalign = 1.0;
78 else // wxALIGN_LEFT
79 xalign = 0.0;
80
81 if ( xalign )
82 gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
83
84 Show( TRUE );
85
86 return TRUE;
87}
88
89void wxStaticBox::SetLabel( const wxString &label )
90{
91 wxControl::SetLabel( label );
92
93 gtk_frame_set_label( GTK_FRAME( m_widget ),
94 m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
95}
96
97void wxStaticBox::ApplyWidgetStyle()
98{
99 SetWidgetStyle();
100 gtk_widget_set_style( m_widget, m_widgetStyle );
101}
102
103#endif // wxUSE_STATBOX