]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/statbox.cpp
Fix for the irksome, 'Details' sizing bug. Or at least a patch on a hornet's
[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
0154a297 61 m_widget = gtk_frame_new(label.empty() ? (char *)NULL : label.mbc_str());
904f68c7 62
f03fc89f 63 m_parent->DoAddChild( this );
1e6feb95 64
1ecc4d80 65 PostCreation();
904f68c7 66
1ecc4d80 67 SetLabel(label);
1e6feb95 68
4d23a4bf 69 InheritAttributes();
db434467 70
4d23a4bf
VZ
71 // need to set non default alignment?
72 gfloat xalign;
73 if ( style & wxALIGN_CENTER )
74 xalign = 0.5;
75 else if ( style & wxALIGN_RIGHT )
76 xalign = 1.0;
77 else // wxALIGN_LEFT
78 xalign = 0.0;
58614078 79
4d23a4bf
VZ
80 if ( xalign )
81 gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
0154a297 82
1ecc4d80 83 Show( TRUE );
904f68c7 84
1ecc4d80 85 return TRUE;
3f659fd6 86}
d3904ceb
RR
87
88void wxStaticBox::SetLabel( const wxString &label )
89{
1ecc4d80 90 wxControl::SetLabel( label );
4d23a4bf 91
0154a297
RD
92 gtk_frame_set_label( GTK_FRAME( m_widget ),
93 label.empty() ? (char *)NULL : label.mbc_str() );
d3904ceb 94}
58614078
RR
95
96void wxStaticBox::ApplyWidgetStyle()
97{
1ecc4d80
RR
98 SetWidgetStyle();
99 gtk_widget_set_style( m_widget, m_widgetStyle );
58614078 100}
dcf924a3 101
1e6feb95 102#endif // wxUSE_STATBOX