]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/statbox.cpp
Put some life into GTK 2.0 drawing.
[wxWidgets.git] / src / gtk / statbox.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
4d23a4bf 2// Name: gtk/statbox.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
a81258be
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
904f68c7 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "statbox.h"
12#endif
13
1e6feb95 14#include "wx/defs.h"
c801d85f 15
dcf924a3
RR
16#if wxUSE_STATBOX
17
1e6feb95
VZ
18#include "wx/statbox.h"
19
83624f79
RR
20#include "gdk/gdk.h"
21#include "gtk/gtk.h"
22
c801d85f
KB
23//-----------------------------------------------------------------------------
24// wxStaticBox
25//-----------------------------------------------------------------------------
26
4d23a4bf 27IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
c801d85f 28
4d23a4bf 29wxStaticBox::wxStaticBox()
c801d85f 30{
3f659fd6 31}
c801d85f 32
4d23a4bf
VZ
33wxStaticBox::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 )
c801d85f 40{
1ecc4d80 41 Create( parent, id, label, pos, size, style, name );
3f659fd6 42}
c801d85f 43
4d23a4bf
VZ
44bool 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 )
c801d85f 51{
1ecc4d80 52 m_needParent = TRUE;
904f68c7 53
4dcaf11a
RR
54 if (!PreCreation( parent, pos, size ) ||
55 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
56 {
223d09f6 57 wxFAIL_MSG( wxT("wxStaticBox creation failed") );
1e6feb95 58 return FALSE;
4dcaf11a 59 }
c801d85f 60
1ecc4d80 61 m_isStaticBox = TRUE;
1e6feb95 62
4d23a4bf 63 if (label.empty())
2e0e025e
RR
64 m_widget = gtk_frame_new( (char*) NULL );
65 else
66 m_widget = gtk_frame_new( m_label.mbc_str() );
904f68c7 67
f03fc89f 68 m_parent->DoAddChild( this );
1e6feb95 69
1ecc4d80 70 PostCreation();
904f68c7 71
1ecc4d80 72 SetLabel(label);
1e6feb95 73
4d23a4bf 74 InheritAttributes();
db434467 75
4d23a4bf
VZ
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;
58614078 84
4d23a4bf
VZ
85 if ( xalign )
86 gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
87
1ecc4d80 88 Show( TRUE );
904f68c7 89
1ecc4d80 90 return TRUE;
3f659fd6 91}
d3904ceb
RR
92
93void wxStaticBox::SetLabel( const wxString &label )
94{
1ecc4d80 95 wxControl::SetLabel( label );
4d23a4bf
VZ
96
97 gtk_frame_set_label( GTK_FRAME( m_widget ), GetLabel().mbc_str() );
d3904ceb 98}
58614078
RR
99
100void wxStaticBox::ApplyWidgetStyle()
101{
1ecc4d80
RR
102 SetWidgetStyle();
103 gtk_widget_set_style( m_widget, m_widgetStyle );
58614078 104}
dcf924a3 105
1e6feb95 106#endif // wxUSE_STATBOX