extracted platform-specific code to determine static box borders to wxStaticBox::GetBordersForSizer()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32654 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-03-07 23:37:15 +00:00
parent 7e75449835
commit 5dd070c25b
5 changed files with 50 additions and 51 deletions

View File

@@ -51,7 +51,7 @@ protected:
// Implementation // Implementation
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
public: public:
void GetBordersForSizer(int *borderTop, int *borderOther) const; virtual void GetBordersForSizer(int *borderTop, int *borderOther) const;
protected: protected:
}; };

View File

@@ -47,8 +47,7 @@ class WXDLLEXPORT wxStaticBox: public wxControl
virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {}; virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
virtual void GetBordersForSizer(int *borderTop, int *borderOther) const;
protected:
}; };
#endif #endif

View File

@@ -20,6 +20,19 @@ public:
virtual bool AcceptsFocus() const { return false; } virtual bool AcceptsFocus() const { return false; }
virtual bool HasTransparentBackground() { return true; } 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: private:
DECLARE_NO_COPY_CLASS(wxStaticBoxBase) DECLARE_NO_COPY_CLASS(wxStaticBoxBase)
}; };

View File

@@ -36,10 +36,6 @@
#include "wx/notebook.h" #include "wx/notebook.h"
#endif #endif
#ifdef __WXMAC__
# include "wx/mac/uma.h"
#endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
IMPLEMENT_CLASS(wxSizerItem, wxObject) 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 // this has to be done platform by platform as there is no way to
// guess the thickness of a wxStaticBox border // guess the thickness of a wxStaticBox border
#ifdef __WXCOCOA__ box->GetBordersForSizer(borderTop, borderOther);
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__
} }
void wxStaticBoxSizer::RecalcSizes() void wxStaticBoxSizer::RecalcSizes()

View File

@@ -27,7 +27,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
/* /*
* Static box * Static box
*/ */
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
@@ -36,7 +36,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ; m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, if ( !wxControl::Create(parent, id, pos, size,
style, wxDefaultValidator, name) ) style, wxDefaultValidator, name) )
return false; return false;
@@ -44,14 +44,41 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
m_label = label ; m_label = label ;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_peer = new wxMacControl(this) ; m_peer = new wxMacControl(this) ;
verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") ,
true /*primary*/ , m_peer->GetControlRefAddr() ) ) ; true /*primary*/ , m_peer->GetControlRefAddr() ) ) ;
MacPostControlCreate(pos,size) ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
#endif 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