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