- Fixed wxPixelData<wxImage> compilation (Leonardo Fernandes).
- Added wxImage::GetType() (troelsk).
- Added wxGenericStaticBitmap suitable for display of large bitmaps.
+- Support wxListCtrl::GetViewRect() in report view too.
wxGTK:
EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
+ EVT_MENU(LIST_SHOW_VIEW_RECT, MyFrame::OnShowViewRect)
EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
EVT_MENU(LIST_THAW, MyFrame::OnThaw)
EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
menuList->AppendSeparator();
menuList->Append(LIST_SHOW_COL_INFO, _T("Show &column info\tCtrl-C"));
menuList->Append(LIST_SHOW_SEL_INFO, _T("Show &selected items\tCtrl-S"));
+ menuList->Append(LIST_SHOW_VIEW_RECT, _T("Show &view rect"));
menuList->AppendSeparator();
menuList->Append(LIST_SORT, _T("Sor&t\tCtrl-T"));
menuList->AppendSeparator();
}
}
+void MyFrame::OnShowViewRect(wxCommandEvent& WXUNUSED(event))
+{
+ const wxRect r = m_listCtrl->GetViewRect();
+ wxLogMessage("View rect: (%d, %d)-(%d, %d)",
+ r.GetLeft(), r.GetTop(), r.GetRight(), r.GetBottom());
+}
+
void MyFrame::OnShowColInfo(wxCommandEvent& WXUNUSED(event))
{
int count = m_listCtrl->GetColumnCount();
void OnToggleMultiSel(wxCommandEvent& event);
void OnShowColInfo(wxCommandEvent& event);
void OnShowSelInfo(wxCommandEvent& event);
+ void OnShowViewRect(wxCommandEvent& event);
void OnFreeze(wxCommandEvent& event);
void OnThaw(wxCommandEvent& event);
void OnToggleLines(wxCommandEvent& event);
LIST_TOGGLE_FIRST,
LIST_SHOW_COL_INFO,
LIST_SHOW_SEL_INFO,
+ LIST_SHOW_VIEW_RECT,
LIST_GOTO,
LIST_FOCUS_LAST,
LIST_FREEZE,
wxRect wxListMainWindow::GetViewRect() const
{
- wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST),
- _T("wxListCtrl::GetViewRect() only works in icon mode") );
+ wxASSERT_MSG( !HasFlag(wxLC_LIST), "not implemented for list view" );
// we need to find the longest/tallest label
wxCoord xMax = 0, yMax = 0;
wxRect wxListCtrl::GetViewRect() const
{
- wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST),
- _T("wxListCtrl::GetViewRect() only works in icon mode") );
+ wxRect rect;
- RECT rc;
- if ( !ListView_GetViewRect(GetHwnd(), &rc) )
+ // ListView_GetViewRect() can only be used in icon and small icon views
+ // (this is documented in MSDN and, indeed, it returns bogus results in
+ // report view, at least with comctl32.dll v6 under Windows 2003)
+ if ( HasFlag(wxLC_ICON | wxLC_SMALL_ICON) )
{
- wxLogDebug(_T("ListView_GetViewRect() failed."));
+ RECT rc;
+ if ( !ListView_GetViewRect(GetHwnd(), &rc) )
+ {
+ wxLogDebug(_T("ListView_GetViewRect() failed."));
- wxZeroMemory(rc);
+ wxZeroMemory(rc);
+ }
+
+ wxCopyRECTToRect(rc, rect);
}
+ else if ( HasFlag(wxLC_REPORT) )
+ {
+ const long count = GetItemCount();
+ if ( count )
+ {
+ GetItemRect(wxMin(GetTopItem() + GetCountPerPage(), count - 1), rect);
- wxRect rect;
- wxCopyRECTToRect(rc, rect);
+ // extend the rectangle to start at the top (we include the column
+ // headers, if any, for compatibility with the generic version)
+ rect.height += rect.y;
+ rect.y = 0;
+ }
+ }
+ else
+ {
+ wxFAIL_MSG( _T("not implemented in this mode") );
+ }
return rect;
}