Set/get for internal border in book based controls.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35930 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
afe1376994
commit
159e6235b2
@ -16,6 +16,8 @@ All (GUI):
|
||||
- wxItemContainerImmutable::FindString unified (affects wxRadioBox, wxListBox,
|
||||
wxComboBox and wxChoice)
|
||||
- wxWindow::Fit() now works correctly for frames and dialogs too
|
||||
- added access to the border size between pages and controller in book
|
||||
based controls (wxBookCtrlBase::Get/SetInternalBorder)
|
||||
|
||||
wxMSW:
|
||||
|
||||
|
@ -118,6 +118,15 @@ public:
|
||||
// calculate the size of the control from the size of its page
|
||||
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
|
||||
|
||||
// get/set size of area between book control area and page area
|
||||
inline unsigned int GetInternalBorder() const
|
||||
{
|
||||
return m_internalBorder;
|
||||
}
|
||||
void SetInternalBorder(unsigned int internalBorder)
|
||||
{
|
||||
m_internalBorder = internalBorder;
|
||||
}
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
@ -192,13 +201,9 @@ protected:
|
||||
// helper: get the next page wrapping if we reached the end
|
||||
int GetNextPage(bool forward) const;
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// Always rely on GetBestSize, which will look at all the pages
|
||||
virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
|
||||
|
||||
|
||||
// the array of all pages of this control
|
||||
wxArrayPages m_pages;
|
||||
|
||||
@ -208,6 +213,13 @@ protected:
|
||||
// true if we must delete m_imageList
|
||||
bool m_ownsImageList;
|
||||
|
||||
private:
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// internal border
|
||||
unsigned int m_internalBorder;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxBookCtrlBase)
|
||||
};
|
||||
|
@ -42,6 +42,12 @@ void wxBookCtrlBase::Init()
|
||||
{
|
||||
m_imageList = NULL;
|
||||
m_ownsImageList = false;
|
||||
|
||||
#if defined(__WXWINCE__)
|
||||
m_internalBorder = 1;
|
||||
#else
|
||||
m_internalBorder = 5;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
@ -196,11 +202,10 @@ int wxBookCtrlBase::GetNextPage(bool forward) const
|
||||
}
|
||||
else // notebook is empty, no next page
|
||||
{
|
||||
nPage = -1;
|
||||
nPage = wxNOT_FOUND;
|
||||
}
|
||||
|
||||
return nPage;
|
||||
}
|
||||
|
||||
#endif // wxUSE_BOOKCTRL
|
||||
|
||||
|
@ -31,17 +31,6 @@
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/settings.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// margin between the choice and the page
|
||||
#if defined(__WXWINCE__)
|
||||
const wxCoord MARGIN = 1;
|
||||
#else
|
||||
const wxCoord MARGIN = 5;
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// various wxWidgets macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -149,19 +138,19 @@ wxRect wxChoicebook::GetPageRect() const
|
||||
// fall through
|
||||
|
||||
case wxCHB_TOP:
|
||||
rectPage.y = sizeChoice.y + MARGIN;
|
||||
rectPage.y = sizeChoice.y + GetInternalBorder();
|
||||
// fall through
|
||||
|
||||
case wxCHB_BOTTOM:
|
||||
rectPage.height -= sizeChoice.y + MARGIN;
|
||||
rectPage.height -= sizeChoice.y + GetInternalBorder();
|
||||
break;
|
||||
|
||||
case wxCHB_LEFT:
|
||||
rectPage.x = sizeChoice.x + MARGIN;
|
||||
rectPage.x = sizeChoice.x + GetInternalBorder();
|
||||
// fall through
|
||||
|
||||
case wxCHB_RIGHT:
|
||||
rectPage.width -= sizeChoice.x + MARGIN;
|
||||
rectPage.width -= sizeChoice.x + GetInternalBorder();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -217,17 +206,17 @@ void wxChoicebook::OnSize(wxSizeEvent& event)
|
||||
|
||||
wxSize wxChoicebook::CalcSizeFromPage(const wxSize& sizePage) const
|
||||
{
|
||||
// we need to add the size of the choice control and the margin
|
||||
// we need to add the size of the choice control and the border between
|
||||
const wxSize sizeChoice = GetChoiceSize();
|
||||
|
||||
wxSize size = sizePage;
|
||||
if ( IsVertical() )
|
||||
{
|
||||
size.y += sizeChoice.y + MARGIN;
|
||||
size.y += sizeChoice.y + GetInternalBorder();
|
||||
}
|
||||
else // left/right aligned
|
||||
{
|
||||
size.x += sizeChoice.x + MARGIN;
|
||||
size.x += sizeChoice.x + GetInternalBorder();
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -346,16 +335,16 @@ wxChoicebook::InsertPage(size_t n,
|
||||
|
||||
// some page should be selected: either this one or the first one if there
|
||||
// is still no selection
|
||||
int selNew = -1;
|
||||
int selNew = wxNOT_FOUND;
|
||||
if ( bSelect )
|
||||
selNew = n;
|
||||
else if ( m_selection == -1 )
|
||||
else if ( m_selection == wxNOT_FOUND )
|
||||
selNew = 0;
|
||||
|
||||
if ( selNew != m_selection )
|
||||
page->Hide();
|
||||
|
||||
if ( selNew != -1 )
|
||||
if ( selNew != wxNOT_FOUND )
|
||||
SetSelection(selNew);
|
||||
|
||||
InvalidateBestSize();
|
||||
|
@ -32,14 +32,6 @@
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/settings.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// margin between the list and the page, should be bigger than wxStaticLine
|
||||
// size
|
||||
const wxCoord MARGIN = 5;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// various wxWidgets macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -178,19 +170,19 @@ wxRect wxListbook::GetPageRect() const
|
||||
// fall through
|
||||
|
||||
case wxLB_TOP:
|
||||
rectPage.y = sizeList.y + MARGIN;
|
||||
rectPage.y = sizeList.y + GetInternalBorder();
|
||||
// fall through
|
||||
|
||||
case wxLB_BOTTOM:
|
||||
rectPage.height -= sizeList.y + MARGIN;
|
||||
rectPage.height -= sizeList.y + GetInternalBorder();
|
||||
break;
|
||||
|
||||
case wxLB_LEFT:
|
||||
rectPage.x = sizeList.x + MARGIN;
|
||||
rectPage.x = sizeList.x + GetInternalBorder();
|
||||
// fall through
|
||||
|
||||
case wxLB_RIGHT:
|
||||
rectPage.width -= sizeList.x + MARGIN;
|
||||
rectPage.width -= sizeList.x + GetInternalBorder();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -255,21 +247,21 @@ void wxListbook::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
case wxLB_TOP:
|
||||
rectLine.y = sizeNew.y + 1;
|
||||
rectLine.height = MARGIN - 2;
|
||||
rectLine.height = GetInternalBorder() - 2;
|
||||
break;
|
||||
|
||||
case wxLB_BOTTOM:
|
||||
rectLine.height = MARGIN - 2;
|
||||
rectLine.height = GetInternalBorder() - 2;
|
||||
rectLine.y = sizeClient.y - sizeNew.y - rectLine.height;
|
||||
break;
|
||||
|
||||
case wxLB_LEFT:
|
||||
rectLine.x = sizeNew.x + 1;
|
||||
rectLine.width = MARGIN - 2;
|
||||
rectLine.width = GetInternalBorder() - 2;
|
||||
break;
|
||||
|
||||
case wxLB_RIGHT:
|
||||
rectLine.width = MARGIN - 2;
|
||||
rectLine.width = GetInternalBorder() - 2;
|
||||
rectLine.x = sizeClient.x - sizeNew.x - rectLine.width;
|
||||
break;
|
||||
}
|
||||
@ -289,17 +281,17 @@ void wxListbook::OnSize(wxSizeEvent& event)
|
||||
|
||||
wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
|
||||
{
|
||||
// we need to add the size of the list control and the margin
|
||||
// we need to add the size of the list control and the border between
|
||||
const wxSize sizeList = GetListSize();
|
||||
|
||||
wxSize size = sizePage;
|
||||
if ( IsVertical() )
|
||||
{
|
||||
size.y += sizeList.y + MARGIN;
|
||||
size.y += sizeList.y + GetInternalBorder();
|
||||
}
|
||||
else // left/right aligned
|
||||
{
|
||||
size.x += sizeList.x + MARGIN;
|
||||
size.x += sizeList.x + GetInternalBorder();
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -500,4 +492,3 @@ void wxListbook::OnListSelected(wxListEvent& eventList)
|
||||
}
|
||||
|
||||
#endif // wxUSE_LISTBOOK
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user