// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "listbook.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __WXMSW__
// On XP with themes enabled the GetViewRect used in GetListSize to
// determine the space needed for the list view will incorrectly return
- // (0,0,0,0) the first time. So send a pending event so OnSize wiull be
+ // (0,0,0,0) the first time. So send a pending event so OnSize will be
// called again after the window is ready to go. Technically we don't
// need to do this on non-XP windows, but if things are already sized
// correctly then nothing changes and so there is no harm.
wxSize wxListbook::GetListSize() const
{
const wxSize sizeClient = GetClientSize(),
- sizeList = m_list->GetViewRect().GetSize();
+ sizeBorder = m_list->GetSize() - m_list->GetClientSize(),
+ sizeList = m_list->GetViewRect().GetSize() + sizeBorder;
wxSize size;
if ( IsVertical() )
return;
}
+ // arrange the icons before calling SetClientSize(), otherwise it wouldn't
+ // account for the scrollbars the list control might need and, at least
+ // under MSW, we'd finish with an ugly looking list control with both
+ // vertical and horizontal scrollbar (with one of them being added because
+ // the other one is not accounted for in client size computations)
+ m_list->Arrange();
+
// resize the list control and the page area to fit inside our new size
const wxSize sizeClient = GetClientSize(),
+ sizeBorder = m_list->GetSize() - m_list->GetClientSize(),
sizeList = GetListSize();
+ m_list->SetClientSize( sizeList.x - sizeBorder.x, sizeList.y - sizeBorder.y );
+
+ const wxSize sizeNew = m_list->GetSize();
wxPoint posList;
switch ( GetWindowStyle() & wxLB_ALIGN_MASK )
{
break;
case wxLB_BOTTOM:
- posList.y = sizeClient.y - sizeList.y;
+ posList.y = sizeClient.y - sizeNew.y;
break;
case wxLB_RIGHT:
- posList.x = sizeClient.x - sizeList.x;
+ posList.x = sizeClient.x - sizeNew.x;
break;
}
- m_list->Move(posList.x, posList.y);
- m_list->SetClientSize(sizeList.x, sizeList.y);
+ if ( m_list->GetPosition() != posList )
+ m_list->Move(posList);
#if wxUSE_LINE_IN_LISTBOOK
if ( m_line )
switch ( GetWindowStyle() & wxLB_ALIGN_MASK )
{
case wxLB_TOP:
- rectLine.y = sizeList.y + 1;
+ rectLine.y = sizeNew.y + 1;
rectLine.height = MARGIN - 2;
break;
case wxLB_BOTTOM:
rectLine.height = MARGIN - 2;
- rectLine.y = sizeClient.y - sizeList.y - rectLine.height;
+ rectLine.y = sizeClient.y - sizeNew.y - rectLine.height;
break;
case wxLB_LEFT:
- rectLine.x = sizeList.x + 1;
+ rectLine.x = sizeNew.x + 1;
rectLine.width = MARGIN - 2;
break;
case wxLB_RIGHT:
rectLine.width = MARGIN - 2;
- rectLine.x = sizeClient.x - sizeList.x - rectLine.width;
+ rectLine.x = sizeClient.x - sizeNew.x - rectLine.width;
break;
}
wxWindow *page = m_pages[m_selection];
wxCHECK_RET( page, _T("NULL page in wxListbook?") );
page->SetSize(GetPageRect());
- }
+ }
}
wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
{
wxFAIL_MSG( _T("wxListbook::GetPageImage() not implemented") );
- return -1;
+ return wxNOT_FOUND;
}
bool wxListbook::SetPageImage(size_t n, int imageId)
SetSelection(selNew);
InvalidateBestSize();
+ m_list->Arrange();
return true;
}
if ((sel != wxNOT_FOUND) && (sel != m_selection))
SetSelection(sel);
}
+
+ m_list->Arrange();
}
return win;