]> git.saurik.com Git - wxWidgets.git/commitdiff
extracted platform-specific code to determine static box borders to wxStaticBox:...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 7 Mar 2005 23:37:15 +0000 (23:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 7 Mar 2005 23:37:15 +0000 (23:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32654 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/statbox.h
include/wx/mac/carbon/statbox.h
include/wx/statbox.h
src/common/sizer.cpp
src/mac/carbon/statbox.cpp

index 92e2985d42b2676e0a67b827dbc5c9a0eb38bf6b..8764385c1e92751c85d96a3acf5dca4bdc957977 100644 (file)
@@ -51,7 +51,7 @@ protected:
 // Implementation
 // ------------------------------------------------------------------------
 public:
-    void GetBordersForSizer(int *borderTop, int *borderOther) const;
+    virtual void GetBordersForSizer(int *borderTop, int *borderOther) const;
 protected:
 };
 
index 6dd85bf43dc78c2527cb7521203eb4dbe13c2868..2cd136e65080bfd987cfad51b567573e52c4b1aa 100644 (file)
@@ -47,8 +47,7 @@ class WXDLLEXPORT wxStaticBox: public wxControl
     virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
     virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
 
-
-protected:
+    virtual void GetBordersForSizer(int *borderTop, int *borderOther) const;
 };
 
 #endif
index 78690c41a0b60bb1b79733a7c6cdf5300006345b..41d29b05b90a97b9db1be5996085dfe40f822e87 100644 (file)
@@ -20,6 +20,19 @@ public:
     virtual bool AcceptsFocus() const { return false; }
     virtual bool HasTransparentBackground() { return true; }
 
+    // implementation only: this is used by wxStaticBoxSizer to account for the
+    // need for extra space taken by the static box
+    //
+    // the top border is the margin at the top (where the title is),
+    // borderOther is the margin on all other sides
+    virtual void GetBordersForSizer(int *borderTop, int *borderOther) const
+    {
+        static const int BORDER = 5; // FIXME: hardcoded value
+
+        *borderTop = GetLabel().empty() ? BORDER : GetCharHeight();
+        *borderOther = BORDER;
+    }
+
 private:
     DECLARE_NO_COPY_CLASS(wxStaticBoxBase)
 };
index f787a74ffc5e83e447c1da6726e1f408c87a522b..703882151eb955b5b9e70b0984580ebc77bf8d9a 100644 (file)
     #include "wx/notebook.h"
 #endif
 
-#ifdef __WXMAC__
-#   include "wx/mac/uma.h"
-#endif
-
 //---------------------------------------------------------------------------
 
 IMPLEMENT_CLASS(wxSizerItem, wxObject)
@@ -1582,43 +1578,7 @@ static void GetStaticBoxBorders( wxStaticBox *box,
 {
     // this has to be done platform by platform as there is no way to
     // guess the thickness of a wxStaticBox border
-#ifdef __WXCOCOA__
-    box->GetBordersForSizer(borderTop,borderOther);
-#elif defined(__WXMAC__)
-
-    static int extraTop = -1; // Uninitted
-    static int other = 5;
-
-    if ( extraTop == -1 )
-    {
-        // The minimal border used for the top. Later on the staticbox'
-        // font height is added to this.
-        extraTop = 0;
-
-        if ( UMAGetSystemVersion() >= 0x1030 /*Panther*/ )
-        {
-            // As indicated by the HIG, Panther needs an extra border of 11
-            // pixels (otherwise overlapping occurs at the top). The "other"
-            // border has to be 11.
-            extraTop = 11;
-            other = 11;
-        }
-
-    }
-
-    *borderTop = extraTop + box->GetCharHeight();
-    *borderOther = other;
-
-#else
-#ifdef __WXGTK__
-    if ( box->GetLabel().empty() )
-        *borderTop = 5;
-    else
-#endif // __WXGTK__
-        *borderTop = box->GetCharHeight();
-
-    *borderOther = 5;
-#endif // __WXCOCOA__
+    box->GetBordersForSizer(borderTop, borderOther);
 }
 
 void wxStaticBoxSizer::RecalcSizes()
index cc29e9b2675a79bb0a32b98546e3e18586fad3d5..50e62f2b92681269f9c36d0e2c44e2f8cbbfef18 100644 (file)
@@ -27,7 +27,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
 /*
  * Static box
  */
+
 bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
            const wxString& label,
            const wxPoint& pos,
@@ -36,7 +36,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
            const wxString& name)
 {
     m_macIsUserPane = FALSE ;
-    
+
     if ( !wxControl::Create(parent, id, pos, size,
                             style, wxDefaultValidator, name) )
         return false;
@@ -44,14 +44,41 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
     m_label = label ;
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
-    
+
     m_peer = new wxMacControl(this) ;
-    verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , 
-        true /*primary*/ , m_peer->GetControlRefAddr() ) ) ;  
+    verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") ,
+        true /*primary*/ , m_peer->GetControlRefAddr() ) ) ;
 
     MacPostControlCreate(pos,size) ;
-    
+
     return TRUE;
 }
 
-#endif
\ No newline at end of file
+void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
+{
+    static int extraTop = -1; // Uninitted
+    static int other = 5;
+
+    if ( extraTop == -1 )
+    {
+        // The minimal border used for the top. Later on the staticbox'
+        // font height is added to this.
+        extraTop = 0;
+
+        if ( UMAGetSystemVersion() >= 0x1030 /*Panther*/ )
+        {
+            // As indicated by the HIG, Panther needs an extra border of 11
+            // pixels (otherwise overlapping occurs at the top). The "other"
+            // border has to be 11.
+            extraTop = 11;
+            other = 11;
+        }
+
+    }
+
+    *borderTop = extraTop + box->GetCharHeight();
+    *borderOther = other;
+}
+
+#endif // wxUSE_STATBOX
+