]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/statbox.cpp
WinCE build fixes.
[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
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
c801d85f 12
dcf924a3
RR
13#if wxUSE_STATBOX
14
1e6feb95 15#include "wx/statbox.h"
fab591c5 16#include "wx/gtk/private.h"
1e6feb95 17
83624f79
RR
18#include "gdk/gdk.h"
19#include "gtk/gtk.h"
20
c801d85f
KB
21//-----------------------------------------------------------------------------
22// wxStaticBox
23//-----------------------------------------------------------------------------
24
4d23a4bf 25IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
c801d85f 26
4d23a4bf 27wxStaticBox::wxStaticBox()
c801d85f 28{
3f659fd6 29}
c801d85f 30
4d23a4bf
VZ
31wxStaticBox::wxStaticBox( wxWindow *parent,
32 wxWindowID id,
33 const wxString &label,
34 const wxPoint& pos,
35 const wxSize& size,
36 long style,
37 const wxString& name )
c801d85f 38{
1ecc4d80 39 Create( parent, id, label, pos, size, style, name );
3f659fd6 40}
c801d85f 41
4d23a4bf
VZ
42bool wxStaticBox::Create( wxWindow *parent,
43 wxWindowID id,
44 const wxString& label,
45 const wxPoint& pos,
46 const wxSize& size,
47 long style,
48 const wxString& name )
c801d85f 49{
1ecc4d80 50 m_needParent = TRUE;
904f68c7 51
4dcaf11a
RR
52 if (!PreCreation( parent, pos, size ) ||
53 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
54 {
223d09f6 55 wxFAIL_MSG( wxT("wxStaticBox creation failed") );
1e6feb95 56 return FALSE;
4dcaf11a 57 }
c801d85f 58
fa2540e3
VZ
59 wxControl::SetLabel(label);
60
fab591c5 61 m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
904f68c7 62
f03fc89f 63 m_parent->DoAddChild( this );
1e6feb95 64
abdeb9e7 65 PostCreation(size);
db434467 66
4d23a4bf
VZ
67 // need to set non default alignment?
68 gfloat xalign;
69 if ( style & wxALIGN_CENTER )
70 xalign = 0.5;
71 else if ( style & wxALIGN_RIGHT )
72 xalign = 1.0;
73 else // wxALIGN_LEFT
74 xalign = 0.0;
58614078 75
c77a6796 76 if ( style & (wxALIGN_RIGHT | wxALIGN_CENTER) ) // left alignment is default
308a5aeb 77 gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5);
0154a297 78
1ecc4d80 79 return TRUE;
3f659fd6 80}
d3904ceb
RR
81
82void wxStaticBox::SetLabel( const wxString &label )
83{
1ecc4d80 84 wxControl::SetLabel( label );
4d23a4bf 85
0154a297 86 gtk_frame_set_label( GTK_FRAME( m_widget ),
fab591c5 87 m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
d3904ceb 88}
58614078 89
7545e132 90void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style)
e3716844 91{
7545e132 92 gtk_widget_modify_style(m_widget, style);
b88ccc4e 93#ifdef __WXGTK20__
7545e132 94 gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style);
b88ccc4e 95#endif
e3716844
RR
96}
97
9d522606
RD
98// static
99wxVisualAttributes
100wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
101{
102 return GetDefaultAttributesFromGTKWidget(gtk_frame_new);
103}
104
1e6feb95 105#endif // wxUSE_STATBOX