]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/statbox.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        gtk/statbox.cpp 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  10 // For compilers that support precompilation, includes "wx.h". 
  11 #include "wx/wxprec.h" 
  15 #include "wx/statbox.h" 
  16 #include "wx/gtk/private.h" 
  21 //----------------------------------------------------------------------------- 
  23 //----------------------------------------------------------------------------- 
  25 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
) 
  27 wxStaticBox::wxStaticBox() 
  31 wxStaticBox::wxStaticBox( wxWindow 
*parent
, 
  33                           const wxString 
&label
, 
  37                           const wxString
& name 
) 
  39     Create( parent
, id
, label
, pos
, size
, style
, name 
); 
  42 bool wxStaticBox::Create( wxWindow 
*parent
, 
  44                           const wxString
& label
, 
  48                           const wxString
& name 
) 
  52     if (!PreCreation( parent
, pos
, size 
) || 
  53         !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name 
)) 
  55         wxFAIL_MSG( wxT("wxStaticBox creation failed") ); 
  59     m_widget 
= GTKCreateFrame(label
); 
  60     wxControl::SetLabel(label
); 
  62     m_parent
->DoAddChild( this ); 
  66     // need to set non default alignment? 
  68     if ( style 
& wxALIGN_CENTER 
) 
  70     else if ( style 
& wxALIGN_RIGHT 
) 
  75     if ( style 
& (wxALIGN_RIGHT 
| wxALIGN_CENTER
) ) // left alignment is default 
  76         gtk_frame_set_label_align(GTK_FRAME( m_widget 
), xalign
, 0.5); 
  81 void wxStaticBox::SetLabel( const wxString
& label 
) 
  83     wxCHECK_RET( m_widget 
!= NULL
, wxT("invalid staticbox") ); 
  85     GTKSetLabelForFrame(GTK_FRAME(m_widget
), label
); 
  88 void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle 
*style
) 
  90     GTKFrameApplyWidgetStyle(GTK_FRAME(m_widget
), style
); 
  93 bool wxStaticBox::GTKWidgetNeedsMnemonic() const 
  98 void wxStaticBox::GTKWidgetDoSetMnemonic(GtkWidget
* w
) 
 100     GTKFrameSetMnemonicWidget(GTK_FRAME(m_widget
), w
); 
 105 wxStaticBox::GetClassDefaultAttributes(wxWindowVariant 
WXUNUSED(variant
)) 
 107     return GetDefaultAttributesFromGTKWidget(gtk_frame_new
); 
 111 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const 
 113     const int BORDER 
= 5; // FIXME: hardcoded value 
 115     *borderTop 
= GetLabel().empty() ? 2*BORDER 
: GetCharHeight(); 
 116     *borderOther 
= BORDER
; 
 119 #endif // wxUSE_STATBOX