1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxStaticBox 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  16 #define XtDisplay XTDISPLAY 
  21 #include "wx/statbox.h" 
  25 #pragma message disable nosimpint 
  30 #pragma message enable nosimpint 
  33 #include "wx/motif/private.h" 
  35 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
) 
  37 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
) 
  38 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) 
  41 // ---------------------------------------------------------------------------- 
  43 // ---------------------------------------------------------------------------- 
  45 // helper class to reduce code duplication 
  51     wxXmSizeKeeper( Widget w 
) 
  54         XtVaGetValues( m_widget
, 
  64         XtVaGetValues( m_widget
, 
  68         if( x 
!= m_x 
|| y 
!= m_y 
) 
  69             XtVaSetValues( m_widget
, 
  80 wxStaticBox::wxStaticBox() 
  82     m_labelWidget 
= (WXWidget
) 0; 
  85 bool wxStaticBox::Create(wxWindow 
*parent
, wxWindowID id
, 
  86            const wxString
& label
, 
  92     if( !CreateControl( parent
, id
, pos
, size
, style
, 
  93                         wxDefaultValidator
, name 
) ) 
  96     Widget parentWidget 
= (Widget
) parent
->GetClientWidget(); 
  98     m_mainWidget 
= XtVaCreateManagedWidget ("staticboxframe", 
  99             xmFrameWidgetClass
, parentWidget
, 
 100             // MBN: why override default? 
 101             // XmNshadowType, XmSHADOW_IN, 
 104     bool hasLabel 
= (!label
.IsNull() && !label
.IsEmpty()) ; 
 107         wxString 
label1(wxStripMenuCodes(label
)); 
 108         wxXmString 
text(label1
); 
 109         Display
* dpy 
= XtDisplay( parentWidget 
); 
 111         m_labelWidget 
= (WXWidget
) XtVaCreateManagedWidget ("staticboxlabel", 
 112                 xmLabelWidgetClass
, (Widget
)m_mainWidget
, 
 113                 wxFont::GetFontTag(), m_font
.GetFontTypeC(dpy
), 
 114                 XmNlabelString
, text(), 
 115 #if wxCHECK_MOTIF_VERSION( 2, 0 ) 
 116                 XmNframeChildType
, XmFRAME_TITLE_CHILD
, 
 118                 XmNchildType
, XmFRAME_TITLE_CHILD
,           
 123     AttachWidget (parent
, m_mainWidget
, NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
); 
 124     ChangeBackgroundColour(); 
 129 wxStaticBox::~wxStaticBox() 
 131    DetachWidget(m_mainWidget
); 
 132    XtDestroyWidget((Widget
) m_mainWidget
); 
 134    m_mainWidget 
= (WXWidget
) 0; 
 135    m_labelWidget 
= (WXWidget
) 0; 
 138 void wxStaticBox::SetLabel( const wxString
& label 
) 
 140     wxXmSizeKeeper 
sk( (Widget
)GetMainWidget() ); 
 142     wxStaticBoxBase::SetLabel( label 
); 
 147 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const 
 149     Dimension shadow
, border
; 
 151     XtVaGetValues( (Widget
) GetMainWidget(), 
 152                    XmNshadowThickness
, &shadow
, 
 153                    XmNborderWidth
, &border
, 
 156     *borderOther 
= shadow 
+ border
; 
 158     if( GetLabelWidget() ) 
 160         XtWidgetGeometry preferred
; 
 161         XtQueryGeometry( (Widget
) GetLabelWidget(), NULL
, &preferred 
); 
 163         *borderTop 
= preferred
.height
;