X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f1160963c677202f56e548df63e65e7d458d8e7e..e70b4f10951f806a7b6cf7e65317a21421e2f3a6:/src/generic/listbkg.cpp diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index 67f4f20987..c4c83d0b91 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -34,6 +34,7 @@ #include "wx/statline.h" #include "wx/listbook.h" #include "wx/imaglist.h" +#include "wx/settings.h" // ---------------------------------------------------------------------------- // constants @@ -52,11 +53,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxListbookEvent, wxNotifyEvent) const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING = wxNewEventType(); const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED = wxNewEventType(); +const int wxID_LISTBOOKLISTVIEW = wxNewId(); BEGIN_EVENT_TABLE(wxListbook, wxBookCtrl) EVT_SIZE(wxListbook::OnSize) - EVT_LIST_ITEM_SELECTED(wxID_ANY, wxListbook::OnListSelected) + EVT_LIST_ITEM_SELECTED(wxID_LISTBOOKLISTVIEW, wxListbook::OnListSelected) END_EVENT_TABLE() // ============================================================================ @@ -98,7 +100,7 @@ wxListbook::Create(wxWindow *parent, m_list = new wxListView ( this, - -1, + wxID_LISTBOOKLISTVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON | wxLC_SINGLE_SEL @@ -135,8 +137,8 @@ wxSize wxListbook::GetListSize() const wxRect r; m_list->GetItemRect(i, r); - wxCoord w = r.x + r.width, - h = r.y + r.height; + wxCoord w = r.width, + h = r.height; if ( w > widthMax ) widthMax = w; @@ -150,11 +152,25 @@ wxSize wxListbook::GetListSize() const { size.x = sizeClient.x; size.y = heightMax; + + if ( widthMax >= sizeClient.x ) + { + // account for the scrollbar + size.y += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); + } } else // left/right aligned { - size.x = widthMax + 10; + // +20 is due to an apparent bug in wxListCtrl::GetItemRect() but I + // can't fix it there right now so just add a fudge here... + size.x = widthMax + 20; size.y = sizeClient.y; + + if ( heightMax >= sizeClient.y ) + { + // account for the scrollbar + size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + } } return size;