support wxListCtrl::GetViewRect() in report view too; test it in the sample (#9484)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54412 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -368,6 +368,7 @@ All (GUI):
|
|||||||
- Fixed wxPixelData<wxImage> compilation (Leonardo Fernandes).
|
- Fixed wxPixelData<wxImage> compilation (Leonardo Fernandes).
|
||||||
- Added wxImage::GetType() (troelsk).
|
- Added wxImage::GetType() (troelsk).
|
||||||
- Added wxGenericStaticBitmap suitable for display of large bitmaps.
|
- Added wxGenericStaticBitmap suitable for display of large bitmaps.
|
||||||
|
- Support wxListCtrl::GetViewRect() in report view too.
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -90,6 +90,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
|
EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
|
||||||
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
|
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
|
||||||
EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
|
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_FREEZE, MyFrame::OnFreeze)
|
||||||
EVT_MENU(LIST_THAW, MyFrame::OnThaw)
|
EVT_MENU(LIST_THAW, MyFrame::OnThaw)
|
||||||
EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
|
EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
|
||||||
@@ -234,6 +235,7 @@ MyFrame::MyFrame(const wxChar *title)
|
|||||||
menuList->AppendSeparator();
|
menuList->AppendSeparator();
|
||||||
menuList->Append(LIST_SHOW_COL_INFO, _T("Show &column info\tCtrl-C"));
|
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_SEL_INFO, _T("Show &selected items\tCtrl-S"));
|
||||||
|
menuList->Append(LIST_SHOW_VIEW_RECT, _T("Show &view rect"));
|
||||||
menuList->AppendSeparator();
|
menuList->AppendSeparator();
|
||||||
menuList->Append(LIST_SORT, _T("Sor&t\tCtrl-T"));
|
menuList->Append(LIST_SORT, _T("Sor&t\tCtrl-T"));
|
||||||
menuList->AppendSeparator();
|
menuList->AppendSeparator();
|
||||||
@@ -643,6 +645,13 @@ void MyFrame::OnShowSelInfo(wxCommandEvent& WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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))
|
void MyFrame::OnShowColInfo(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
int count = m_listCtrl->GetColumnCount();
|
int count = m_listCtrl->GetColumnCount();
|
||||||
|
@@ -135,6 +135,7 @@ protected:
|
|||||||
void OnToggleMultiSel(wxCommandEvent& event);
|
void OnToggleMultiSel(wxCommandEvent& event);
|
||||||
void OnShowColInfo(wxCommandEvent& event);
|
void OnShowColInfo(wxCommandEvent& event);
|
||||||
void OnShowSelInfo(wxCommandEvent& event);
|
void OnShowSelInfo(wxCommandEvent& event);
|
||||||
|
void OnShowViewRect(wxCommandEvent& event);
|
||||||
void OnFreeze(wxCommandEvent& event);
|
void OnFreeze(wxCommandEvent& event);
|
||||||
void OnThaw(wxCommandEvent& event);
|
void OnThaw(wxCommandEvent& event);
|
||||||
void OnToggleLines(wxCommandEvent& event);
|
void OnToggleLines(wxCommandEvent& event);
|
||||||
@@ -202,6 +203,7 @@ enum
|
|||||||
LIST_TOGGLE_FIRST,
|
LIST_TOGGLE_FIRST,
|
||||||
LIST_SHOW_COL_INFO,
|
LIST_SHOW_COL_INFO,
|
||||||
LIST_SHOW_SEL_INFO,
|
LIST_SHOW_SEL_INFO,
|
||||||
|
LIST_SHOW_VIEW_RECT,
|
||||||
LIST_GOTO,
|
LIST_GOTO,
|
||||||
LIST_FOCUS_LAST,
|
LIST_FOCUS_LAST,
|
||||||
LIST_FREEZE,
|
LIST_FREEZE,
|
||||||
|
@@ -4110,8 +4110,7 @@ int wxListMainWindow::GetSelectedItemCount() const
|
|||||||
|
|
||||||
wxRect wxListMainWindow::GetViewRect() const
|
wxRect wxListMainWindow::GetViewRect() const
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST),
|
wxASSERT_MSG( !HasFlag(wxLC_LIST), "not implemented for list view" );
|
||||||
_T("wxListCtrl::GetViewRect() only works in icon mode") );
|
|
||||||
|
|
||||||
// we need to find the longest/tallest label
|
// we need to find the longest/tallest label
|
||||||
wxCoord xMax = 0, yMax = 0;
|
wxCoord xMax = 0, yMax = 0;
|
||||||
|
@@ -1082,19 +1082,40 @@ bool wxListCtrl::SetItemPtrData(long item, wxUIntPtr data)
|
|||||||
|
|
||||||
wxRect wxListCtrl::GetViewRect() const
|
wxRect wxListCtrl::GetViewRect() const
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST),
|
|
||||||
_T("wxListCtrl::GetViewRect() only works in icon mode") );
|
|
||||||
|
|
||||||
RECT rc;
|
|
||||||
if ( !ListView_GetViewRect(GetHwnd(), &rc) )
|
|
||||||
{
|
|
||||||
wxLogDebug(_T("ListView_GetViewRect() failed."));
|
|
||||||
|
|
||||||
wxZeroMemory(rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxRect rect;
|
wxRect rect;
|
||||||
wxCopyRECTToRect(rc, rect);
|
|
||||||
|
// 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) )
|
||||||
|
{
|
||||||
|
RECT rc;
|
||||||
|
if ( !ListView_GetViewRect(GetHwnd(), &rc) )
|
||||||
|
{
|
||||||
|
wxLogDebug(_T("ListView_GetViewRect() failed."));
|
||||||
|
|
||||||
|
wxZeroMemory(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCopyRECTToRect(rc, rect);
|
||||||
|
}
|
||||||
|
else if ( HasFlag(wxLC_REPORT) )
|
||||||
|
{
|
||||||
|
const long count = GetItemCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
GetItemRect(wxMin(GetTopItem() + GetCountPerPage(), count - 1), 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;
|
return rect;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user