#include "wx/statline.h"
#include "wx/listbook.h"
#include "wx/imaglist.h"
+#include "wx/settings.h"
// ----------------------------------------------------------------------------
// constants
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()
// ============================================================================
m_list = new wxListView
(
this,
- -1,
+ wxID_LISTBOOKLISTVIEW,
wxDefaultPosition,
wxDefaultSize,
wxLC_ICON | wxLC_SINGLE_SEL
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;
{
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;
void wxListbook::OnSize(wxSizeEvent& event)
{
+ event.Skip();
+
+ if ( !m_list )
+ {
+ // we're not fully created yet
+ return;
+ }
+
// resize the list control and the page area to fit inside our new size
const wxSize sizeClient = GetClientSize(),
sizeList = GetListSize();
page->Show();
}
}
-
- event.Skip();
}
wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const