]>
Commit | Line | Data |
---|---|---|
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" |
3cbab641 | 16 | #include "wx/gtk1/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 | 25 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) |
c801d85f | 26 | |
4d23a4bf | 27 | wxStaticBox::wxStaticBox() |
c801d85f | 28 | { |
3f659fd6 | 29 | } |
c801d85f | 30 | |
4d23a4bf VZ |
31 | wxStaticBox::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 |
42 | bool 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 | |
b2ff89d6 VZ |
59 | m_widget = gtk_frame_new(NULL); |
60 | SetLabel(label); | |
904f68c7 | 61 | |
f03fc89f | 62 | m_parent->DoAddChild( this ); |
1e6feb95 | 63 | |
abdeb9e7 | 64 | PostCreation(size); |
db434467 | 65 | |
4d23a4bf VZ |
66 | // need to set non default alignment? |
67 | gfloat xalign; | |
68 | if ( style & wxALIGN_CENTER ) | |
69 | xalign = 0.5; | |
70 | else if ( style & wxALIGN_RIGHT ) | |
71 | xalign = 1.0; | |
72 | else // wxALIGN_LEFT | |
73 | xalign = 0.0; | |
58614078 | 74 | |
c77a6796 | 75 | if ( style & (wxALIGN_RIGHT | wxALIGN_CENTER) ) // left alignment is default |
308a5aeb | 76 | gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5); |
0154a297 | 77 | |
1ecc4d80 | 78 | return TRUE; |
3f659fd6 | 79 | } |
d3904ceb | 80 | |
b2ff89d6 | 81 | void wxStaticBox::SetLabel( const wxString& label ) |
d3904ceb | 82 | { |
b2ff89d6 | 83 | wxCHECK_RET( m_widget != NULL, wxT("invalid staticbox") ); |
4d23a4bf | 84 | |
b2ff89d6 | 85 | GTKSetLabelForFrame(GTK_FRAME(m_widget), label); |
d3904ceb | 86 | } |
58614078 | 87 | |
7545e132 | 88 | void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style) |
e3716844 | 89 | { |
7545e132 | 90 | gtk_widget_modify_style(m_widget, style); |
e3716844 RR |
91 | } |
92 | ||
9d522606 RD |
93 | // static |
94 | wxVisualAttributes | |
95 | wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) | |
96 | { | |
97 | return GetDefaultAttributesFromGTKWidget(gtk_frame_new); | |
98 | } | |
99 | ||
1e6feb95 | 100 | #endif // wxUSE_STATBOX |