]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/statbox.cpp
fixed memory leak with client data when using DeleteAllItems() (bug 1107215)
[wxWidgets.git] / src / gtk1 / 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
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
11#pragma implementation "statbox.h"
12#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
c801d85f 16
dcf924a3
RR
17#if wxUSE_STATBOX
18
1e6feb95 19#include "wx/statbox.h"
fab591c5 20#include "wx/gtk/private.h"
1e6feb95 21
83624f79
RR
22#include "gdk/gdk.h"
23#include "gtk/gtk.h"
24
c801d85f
KB
25//-----------------------------------------------------------------------------
26// wxStaticBox
27//-----------------------------------------------------------------------------
28
4d23a4bf 29IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
c801d85f 30
4d23a4bf 31wxStaticBox::wxStaticBox()
c801d85f 32{
3f659fd6 33}
c801d85f 34
4d23a4bf
VZ
35wxStaticBox::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 )
c801d85f 42{
1ecc4d80 43 Create( parent, id, label, pos, size, style, name );
3f659fd6 44}
c801d85f 45
4d23a4bf
VZ
46bool 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 )
c801d85f 53{
1ecc4d80 54 m_needParent = TRUE;
904f68c7 55
4dcaf11a
RR
56 if (!PreCreation( parent, pos, size ) ||
57 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
58 {
223d09f6 59 wxFAIL_MSG( wxT("wxStaticBox creation failed") );
1e6feb95 60 return FALSE;
4dcaf11a 61 }
c801d85f 62
fa2540e3
VZ
63 wxControl::SetLabel(label);
64
fab591c5 65 m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
904f68c7 66
f03fc89f 67 m_parent->DoAddChild( this );
1e6feb95 68
abdeb9e7 69 PostCreation(size);
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 return TRUE;
3f659fd6 84}
d3904ceb
RR
85
86void wxStaticBox::SetLabel( const wxString &label )
87{
1ecc4d80 88 wxControl::SetLabel( label );
4d23a4bf 89
0154a297 90 gtk_frame_set_label( GTK_FRAME( m_widget ),
fab591c5 91 m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
d3904ceb 92}
58614078 93
7545e132 94void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style)
e3716844 95{
7545e132 96 gtk_widget_modify_style(m_widget, style);
b88ccc4e 97#ifdef __WXGTK20__
7545e132 98 gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style);
b88ccc4e 99#endif
e3716844
RR
100}
101
9d522606
RD
102// static
103wxVisualAttributes
104wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
105{
106 return GetDefaultAttributesFromGTKWidget(gtk_frame_new);
107}
108
1e6feb95 109#endif // wxUSE_STATBOX