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:
parent
7e75449835
commit
5dd070c25b
@ -51,7 +51,7 @@ protected:
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
void GetBordersForSizer(int *borderTop, int *borderOther) const;
|
||||
virtual void GetBordersForSizer(int *borderTop, int *borderOther) const;
|
||||
protected:
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
};
|
||||
|
@ -36,10 +36,6 @@
|
||||
#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()
|
||||
|
@ -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
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user