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:
@@ -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:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
@@ -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)
|
||||||
};
|
};
|
||||||
|
@@ -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()
|
||||||
|
@@ -54,4 +54,31 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user