]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbox.cpp
follow up parent chain to properly support modal dialog parents, see #15383
[wxWidgets.git] / src / gtk1 / statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/statbox.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11
12 #if wxUSE_STATBOX
13
14 #include "wx/statbox.h"
15 #include "wx/gtk1/private.h"
16
17 #include "gdk/gdk.h"
18 #include "gtk/gtk.h"
19
20 //-----------------------------------------------------------------------------
21 // wxStaticBox
22 //-----------------------------------------------------------------------------
23
24 wxStaticBox::wxStaticBox()
25 {
26 }
27
28 wxStaticBox::wxStaticBox( wxWindow *parent,
29 wxWindowID id,
30 const wxString &label,
31 const wxPoint& pos,
32 const wxSize& size,
33 long style,
34 const wxString& name )
35 {
36 Create( parent, id, label, pos, size, style, name );
37 }
38
39 bool wxStaticBox::Create( wxWindow *parent,
40 wxWindowID id,
41 const wxString& label,
42 const wxPoint& pos,
43 const wxSize& size,
44 long style,
45 const wxString& name )
46 {
47 m_needParent = TRUE;
48
49 if (!PreCreation( parent, pos, size ) ||
50 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
51 {
52 wxFAIL_MSG( wxT("wxStaticBox creation failed") );
53 return FALSE;
54 }
55
56 m_widget = gtk_frame_new(NULL);
57 SetLabel(label);
58
59 m_parent->DoAddChild( this );
60
61 PostCreation(size);
62
63 // need to set non default alignment?
64 gfloat xalign;
65 if ( style & wxALIGN_CENTER )
66 xalign = 0.5;
67 else if ( style & wxALIGN_RIGHT )
68 xalign = 1.0;
69 else // wxALIGN_LEFT
70 xalign = 0.0;
71
72 if ( style & (wxALIGN_RIGHT | wxALIGN_CENTER) ) // left alignment is default
73 gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5);
74
75 return TRUE;
76 }
77
78 void wxStaticBox::SetLabel( const wxString& label )
79 {
80 wxCHECK_RET( m_widget != NULL, wxT("invalid staticbox") );
81
82 GTKSetLabelForFrame(GTK_FRAME(m_widget), label);
83 }
84
85 void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style)
86 {
87 gtk_widget_modify_style(m_widget, style);
88 }
89
90 // static
91 wxVisualAttributes
92 wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
93 {
94 return GetDefaultAttributesFromGTKWidget(gtk_frame_new);
95 }
96
97 #endif // wxUSE_STATBOX