]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/statbox.cpp
allow customization of individual grid lines appearance (patch 1496015)
[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
2e1f5012
VZ
59 m_widget = GTKCreateFrame(label);
60 wxControl::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 81void 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 88void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style)
e3716844 89{
2e1f5012
VZ
90 GTKFrameApplyWidgetStyle(GTK_FRAME(m_widget), style);
91}
92
93bool wxStaticBox::GTKWidgetNeedsMnemonic() const
94{
95 return true;
96}
97
98void wxStaticBox::GTKWidgetDoSetMnemonic(GtkWidget* w)
99{
100 GTKFrameSetMnemonicWidget(GTK_FRAME(m_widget), w);
e3716844
RR
101}
102
9d522606
RD
103// static
104wxVisualAttributes
105wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
106{
107 return GetDefaultAttributesFromGTKWidget(gtk_frame_new);
108}
109
c1f50b06
RD
110
111void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
112{
113 const int BORDER = 5; // FIXME: hardcoded value
114
115 *borderTop = GetLabel().empty() ? 2*BORDER : GetCharHeight();
116 *borderOther = BORDER;
117}
118
1e6feb95 119#endif // wxUSE_STATBOX