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