Fix page positioning when the tabs are on a side different than
wxNB_TOP by choosing margins dynamically instead of always using fixed margin sizes. Also remove unnecessary large internal borders (although they can be reactivated by flipping an #if.) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20689 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -33,12 +33,6 @@
|
||||
// check that the page index is valid
|
||||
#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
|
||||
|
||||
static bool constantsSet = false ;
|
||||
|
||||
short kwxMacTabLeftMargin = 0 ;
|
||||
short kwxMacTabTopMargin = 0 ;
|
||||
short kwxMacTabRightMargin = 0 ;
|
||||
short kwxMacTabBottomMargin = 0 ;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event table
|
||||
@@ -65,6 +59,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// The Appearance Manager docs show using tab controls in either edge to edge
|
||||
// mode, or inset. I think edge to edge conforms better to the other ports,
|
||||
// and inset mode is better accomplished with space around the wxNotebook rather
|
||||
// than within it. --Robin
|
||||
#define wxMAC_EDGE_TO_EDGE 1
|
||||
|
||||
static inline int wxMacTabMargin(long nbStyle, long side)
|
||||
{
|
||||
static int tabMargin = -1;
|
||||
static int otherMargin = -1;
|
||||
|
||||
if ( tabMargin == -1)
|
||||
{
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
tabMargin = 26; // From Appearance Manager docs for small tab control dimensions
|
||||
#if wxMAC_EDGE_TO_EDGE
|
||||
otherMargin = 0;
|
||||
#else
|
||||
otherMargin = 20;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
tabMargin = 30;
|
||||
#if wxMAC_EDGE_TO_EDGE
|
||||
otherMargin = 0;
|
||||
#else
|
||||
otherMargin = 16;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// If the style matches the side asked for then return the tab margin,
|
||||
// but we have to special case wxNB_TOP since it is zero...
|
||||
if ( side == wxNB_TOP)
|
||||
{
|
||||
if ( nbStyle != 0 && nbStyle & wxNB_LEFT|wxNB_RIGHT|wxNB_BOTTOM)
|
||||
{
|
||||
return otherMargin;
|
||||
}
|
||||
else
|
||||
{
|
||||
return tabMargin;
|
||||
}
|
||||
}
|
||||
else if ( nbStyle & side)
|
||||
return tabMargin;
|
||||
else
|
||||
return otherMargin;
|
||||
}
|
||||
|
||||
static inline int wxMacTabLeftMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_LEFT);
|
||||
}
|
||||
|
||||
static inline int wxMacTabTopMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_TOP);
|
||||
}
|
||||
|
||||
static inline int wxMacTabRightMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_RIGHT);
|
||||
}
|
||||
|
||||
static inline int wxMacTabBottomMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_BOTTOM);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxNotebook construction
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -72,27 +138,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
|
||||
// common part of all ctors
|
||||
void wxNotebook::Init()
|
||||
{
|
||||
if ( !constantsSet )
|
||||
{
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
// I got these values for Mac OS X from the Appearance mgr docs. (Mark Newsam)
|
||||
kwxMacTabLeftMargin = 20 ;
|
||||
kwxMacTabTopMargin = 38 ;
|
||||
kwxMacTabRightMargin = 20 ;
|
||||
kwxMacTabBottomMargin = 12 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
kwxMacTabLeftMargin = 16 ;
|
||||
kwxMacTabTopMargin = 30 ;
|
||||
kwxMacTabRightMargin = 16 ;
|
||||
kwxMacTabBottomMargin = 16 ;
|
||||
}
|
||||
constantsSet = true ;
|
||||
}
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
// Should these depend on wxMAC_EDGE_TO_EDGE too?
|
||||
m_macHorizontalBorder = 7;
|
||||
m_macVerticalBorder = 8;
|
||||
}
|
||||
@@ -333,9 +381,10 @@ bool wxNotebook::InsertPage(int nPage,
|
||||
|
||||
int h, w;
|
||||
GetSize(&w, &h);
|
||||
pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin,
|
||||
w - kwxMacTabLeftMargin - kwxMacTabRightMargin,
|
||||
h - kwxMacTabTopMargin - kwxMacTabBottomMargin );
|
||||
pPage->SetSize(wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
|
||||
wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
|
||||
w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
|
||||
h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
|
||||
if ( pPage->GetAutoLayout() ) {
|
||||
pPage->Layout();
|
||||
}
|
||||
@@ -419,9 +468,10 @@ void wxNotebook::OnSize(wxSizeEvent& event)
|
||||
unsigned int nCount = m_pages.Count();
|
||||
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
|
||||
wxNotebookPage *pPage = m_pages[nPage];
|
||||
pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin,
|
||||
w - kwxMacTabLeftMargin - kwxMacTabRightMargin,
|
||||
h - kwxMacTabTopMargin - kwxMacTabBottomMargin );
|
||||
pPage->SetSize(wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
|
||||
wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
|
||||
w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
|
||||
h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
|
||||
if ( pPage->GetAutoLayout() ) {
|
||||
pPage->Layout();
|
||||
}
|
||||
|
@@ -33,12 +33,6 @@
|
||||
// check that the page index is valid
|
||||
#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
|
||||
|
||||
static bool constantsSet = false ;
|
||||
|
||||
short kwxMacTabLeftMargin = 0 ;
|
||||
short kwxMacTabTopMargin = 0 ;
|
||||
short kwxMacTabRightMargin = 0 ;
|
||||
short kwxMacTabBottomMargin = 0 ;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event table
|
||||
@@ -65,6 +59,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// The Appearance Manager docs show using tab controls in either edge to edge
|
||||
// mode, or inset. I think edge to edge conforms better to the other ports,
|
||||
// and inset mode is better accomplished with space around the wxNotebook rather
|
||||
// than within it. --Robin
|
||||
#define wxMAC_EDGE_TO_EDGE 1
|
||||
|
||||
static inline int wxMacTabMargin(long nbStyle, long side)
|
||||
{
|
||||
static int tabMargin = -1;
|
||||
static int otherMargin = -1;
|
||||
|
||||
if ( tabMargin == -1)
|
||||
{
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
tabMargin = 26; // From Appearance Manager docs for small tab control dimensions
|
||||
#if wxMAC_EDGE_TO_EDGE
|
||||
otherMargin = 0;
|
||||
#else
|
||||
otherMargin = 20;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
tabMargin = 30;
|
||||
#if wxMAC_EDGE_TO_EDGE
|
||||
otherMargin = 0;
|
||||
#else
|
||||
otherMargin = 16;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// If the style matches the side asked for then return the tab margin,
|
||||
// but we have to special case wxNB_TOP since it is zero...
|
||||
if ( side == wxNB_TOP)
|
||||
{
|
||||
if ( nbStyle != 0 && nbStyle & wxNB_LEFT|wxNB_RIGHT|wxNB_BOTTOM)
|
||||
{
|
||||
return otherMargin;
|
||||
}
|
||||
else
|
||||
{
|
||||
return tabMargin;
|
||||
}
|
||||
}
|
||||
else if ( nbStyle & side)
|
||||
return tabMargin;
|
||||
else
|
||||
return otherMargin;
|
||||
}
|
||||
|
||||
static inline int wxMacTabLeftMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_LEFT);
|
||||
}
|
||||
|
||||
static inline int wxMacTabTopMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_TOP);
|
||||
}
|
||||
|
||||
static inline int wxMacTabRightMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_RIGHT);
|
||||
}
|
||||
|
||||
static inline int wxMacTabBottomMargin(long style)
|
||||
{
|
||||
return wxMacTabMargin(style, wxNB_BOTTOM);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxNotebook construction
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -72,27 +138,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
|
||||
// common part of all ctors
|
||||
void wxNotebook::Init()
|
||||
{
|
||||
if ( !constantsSet )
|
||||
{
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
// I got these values for Mac OS X from the Appearance mgr docs. (Mark Newsam)
|
||||
kwxMacTabLeftMargin = 20 ;
|
||||
kwxMacTabTopMargin = 38 ;
|
||||
kwxMacTabRightMargin = 20 ;
|
||||
kwxMacTabBottomMargin = 12 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
kwxMacTabLeftMargin = 16 ;
|
||||
kwxMacTabTopMargin = 30 ;
|
||||
kwxMacTabRightMargin = 16 ;
|
||||
kwxMacTabBottomMargin = 16 ;
|
||||
}
|
||||
constantsSet = true ;
|
||||
}
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
// Should these depend on wxMAC_EDGE_TO_EDGE too?
|
||||
m_macHorizontalBorder = 7;
|
||||
m_macVerticalBorder = 8;
|
||||
}
|
||||
@@ -333,9 +381,10 @@ bool wxNotebook::InsertPage(int nPage,
|
||||
|
||||
int h, w;
|
||||
GetSize(&w, &h);
|
||||
pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin,
|
||||
w - kwxMacTabLeftMargin - kwxMacTabRightMargin,
|
||||
h - kwxMacTabTopMargin - kwxMacTabBottomMargin );
|
||||
pPage->SetSize(wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
|
||||
wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
|
||||
w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
|
||||
h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
|
||||
if ( pPage->GetAutoLayout() ) {
|
||||
pPage->Layout();
|
||||
}
|
||||
@@ -419,9 +468,10 @@ void wxNotebook::OnSize(wxSizeEvent& event)
|
||||
unsigned int nCount = m_pages.Count();
|
||||
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
|
||||
wxNotebookPage *pPage = m_pages[nPage];
|
||||
pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin,
|
||||
w - kwxMacTabLeftMargin - kwxMacTabRightMargin,
|
||||
h - kwxMacTabTopMargin - kwxMacTabBottomMargin );
|
||||
pPage->SetSize(wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
|
||||
wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
|
||||
w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
|
||||
h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
|
||||
if ( pPage->GetAutoLayout() ) {
|
||||
pPage->Layout();
|
||||
}
|
||||
|
Reference in New Issue
Block a user