]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/statbox.cpp
Set the menu itself as event object for EVT_MENU_{OPEN,CLOSED} in wxMSW.
[wxWidgets.git] / src / motif / statbox.cpp
index c7c8dd099ae0872da09259e0d487bec6b0f08a79..2ea22aee4dc3cb3c0d1902ac93d188a7d06dfaff 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        statbox.cpp
+// Name:        src/motif/statbox.cpp
 // Purpose:     wxStaticBox
 // Author:      Julian Smart
 // Modified by:
@@ -9,18 +9,14 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "statbox.h"
-#endif
-
-#ifdef __VMS
-#define XtDisplay XTDISPLAY
-#endif
-
-#include "wx/defs.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
 
 #include "wx/statbox.h"
-#include "wx/utils.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/utils.h"
+#endif
 
 #ifdef __VMS__
 #pragma message disable nosimpint
@@ -33,8 +29,6 @@
 
 #include "wx/motif/private.h"
 
-IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
-
 BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
 END_EVENT_TABLE()
@@ -93,6 +87,8 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
     if( !CreateControl( parent, id, pos, size, style,
                         wxDefaultValidator, name ) )
         return false;
+    m_labelWidget = (WXWidget) 0;
+    PreCreation();
 
     Widget parentWidget = (Widget) parent->GetClientWidget();
 
@@ -102,30 +98,28 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
             // XmNshadowType, XmSHADOW_IN,
             NULL);
 
-    bool hasLabel = (!label.IsNull() && !label.IsEmpty()) ;
-    if (hasLabel)
+    if (!label.empty())
     {
-        XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay( parentWidget ) );
-        wxString label1(wxStripMenuCodes(label));
+        wxString label1(GetLabelText(label));
         wxXmString text(label1);
+        Display* dpy = XtDisplay( parentWidget );
 
         m_labelWidget = (WXWidget) XtVaCreateManagedWidget ("staticboxlabel",
                 xmLabelWidgetClass, (Widget)m_mainWidget,
-                XmNfontList, fontList,
+                wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
                 XmNlabelString, text(),
 #if wxCHECK_MOTIF_VERSION( 2, 0 )
                 XmNframeChildType, XmFRAME_TITLE_CHILD,
 #else
-                XmNchildType, XmFRAME_TITLE_CHILD,          
+                XmNchildType, XmFRAME_TITLE_CHILD,
 #endif
                 NULL);
     }
-    
-    SetCanAddEventHandler(TRUE);
+
+    PostCreation();
     AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y);
-    ChangeBackgroundColour();
 
-    return TRUE;
+    return true;
 }
 
 wxStaticBox::~wxStaticBox()
@@ -145,3 +139,27 @@ void wxStaticBox::SetLabel( const wxString& label )
 
     sk.Restore();
 }
+
+void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
+{
+    Dimension shadow, border;
+
+    XtVaGetValues( (Widget) GetMainWidget(),
+                   XmNshadowThickness, &shadow,
+                   XmNborderWidth, &border,
+                   NULL);
+
+    *borderOther = shadow + border;
+
+    if( GetLabelWidget() )
+    {
+        XtWidgetGeometry preferred;
+        XtQueryGeometry( (Widget) GetLabelWidget(), NULL, &preferred );
+
+        *borderTop = preferred.height;
+    }
+    else
+    {
+        *borderTop = shadow;
+    }
+}