]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbox.cpp
Status bar positioned correctly, but no sign of the
[wxWidgets.git] / src / gtk1 / statbox.cpp
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
20 #include "gdk/gdk.h"
21 #include "gtk/gtk.h"
22
23 //-----------------------------------------------------------------------------
24 // wxStaticBox
25 //-----------------------------------------------------------------------------
26
27 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
28
29 wxStaticBox::wxStaticBox()
30 {
31 }
32
33 wxStaticBox::wxStaticBox( wxWindow *parent,
34 wxWindowID id,
35 const wxString &label,
36 const wxPoint& pos,
37 const wxSize& size,
38 long style,
39 const wxString& name )
40 {
41 Create( parent, id, label, pos, size, style, name );
42 }
43
44 bool wxStaticBox::Create( wxWindow *parent,
45 wxWindowID id,
46 const wxString& label,
47 const wxPoint& pos,
48 const wxSize& size,
49 long style,
50 const wxString& name )
51 {
52 m_needParent = TRUE;
53
54 if (!PreCreation( parent, pos, size ) ||
55 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
56 {
57 wxFAIL_MSG( wxT("wxStaticBox creation failed") );
58 return FALSE;
59 }
60
61 m_isStaticBox = TRUE;
62
63 if (label.empty())
64 m_widget = gtk_frame_new( (char*) NULL );
65 else
66 m_widget = gtk_frame_new( m_label.mbc_str() );
67
68 m_parent->DoAddChild( this );
69
70 PostCreation();
71
72 SetLabel(label);
73
74 InheritAttributes();
75
76 // need to set non default alignment?
77 gfloat xalign;
78 if ( style & wxALIGN_CENTER )
79 xalign = 0.5;
80 else if ( style & wxALIGN_RIGHT )
81 xalign = 1.0;
82 else // wxALIGN_LEFT
83 xalign = 0.0;
84
85 if ( xalign )
86 gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
87
88 Show( TRUE );
89
90 return TRUE;
91 }
92
93 void wxStaticBox::SetLabel( const wxString &label )
94 {
95 wxControl::SetLabel( label );
96
97 gtk_frame_set_label( GTK_FRAME( m_widget ), GetLabel().mbc_str() );
98 }
99
100 void wxStaticBox::ApplyWidgetStyle()
101 {
102 SetWidgetStyle();
103 gtk_widget_set_style( m_widget, m_widgetStyle );
104 }
105
106 #endif // wxUSE_STATBOX