added wxListCtrl::GetViewRect()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2003-09-14 15:58:41 +00:00
parent ee47181777
commit 11ebea162a
6 changed files with 95 additions and 0 deletions

View File

@ -40,6 +40,18 @@ versions, please update your code to not use them.
OTHER CHANGES
=============
2.5.1
-----
wxMSW:
- fixed wxTE_*WRAP styles handling
All (GUI):
- added wxListCtrl::GetViewRect()
2.5.0
-----

View File

@ -463,6 +463,19 @@ Gets the text colour of the list control.
Gets the index of the topmost visible item when in
list or report view.
\membersection{wxRect}{wxListCtrl::GetViewRect}\label{wxlistctrlgetviewrect}
\constfunc{wxRect}{GetViewRect}{\void}
Returns the rectangle taken by all items in the control. In other words, if the
controls client size were equal to the size of this rectangle, no scrollbars
would be needed and no free space would be left.
Note that this function only works in the icon and small icon views, not in
list or report views (this is a limitation of the native Win32 control).
\membersection{wxListCtrl::HitTest}\label{wxlistctrlhittest}
\func{long}{HitTest}{\param{const wxPoint\& }{point}, \param{int\& }{flags}}

View File

@ -91,6 +91,7 @@ public:
int GetColumnWidth( int col ) const;
bool SetColumnWidth( int col, int width);
int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
wxRect GetViewRect() const;
bool GetItem( wxListItem& info ) const;
bool SetItem( wxListItem& info ) ;

View File

@ -138,6 +138,9 @@ public:
// or small icon view)
int GetCountPerPage() const;
// return the total area occupied by all the items (icon/small icon only)
wxRect GetViewRect() const;
// Gets the edit control for editing labels.
wxTextCtrl* GetEditControl() const;

View File

@ -3773,6 +3773,41 @@ int wxListMainWindow::GetSelectedItemCount() const
// item position/size
// ----------------------------------------------------------------------------
wxRect wxListMainWindow::GetViewRect() const
{
wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST),
_T("wxListCtrl::GetViewRect() only works in icon mode") );
// we need to find the longest/tallest label
wxCoord xMax = 0,
yMax = 0;
const int count = GetItemCount();
if ( count )
{
for ( int i = 0; i < count; i++ )
{
wxRect r;
GetItemRect(i, r);
wxCoord x = r.GetRight(),
y = r.GetBottom();
if ( x > xMax )
xMax = x;
if ( y > yMax )
yMax = y;
}
}
#if 0
// account for the scrollbar
yMax += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
xMax += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
#endif
return wxRect(0, 0, xMax, yMax);
}
void wxListMainWindow::GetItemRect( long index, wxRect &rect ) const
{
wxCHECK_RET( index >= 0 && (size_t)index < GetItemCount(),
@ -4683,6 +4718,11 @@ bool wxGenericListCtrl::SetItemData( long item, long data )
return TRUE;
}
wxRect wxGenericListCtrl::GetViewRect() const
{
return m_mainWin->GetViewRect();
}
bool wxGenericListCtrl::GetItemRect( long item, wxRect &rect, int WXUNUSED(code) ) const
{
m_mainWin->GetItemRect( item, rect );

View File

@ -1032,6 +1032,32 @@ bool wxListCtrl::SetItemData(long item, long data)
return SetItem(info);
}
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);
}
else
{
// VZ: I have no idea why is this needed but without it the listbook
// control shows a tiny vertical scrollbar, make sure that it works
// correctly if you decide to change this
rc.bottom += 5;
}
wxRect rect;
wxCopyRECTToRect(rc, rect);
return rect;
}
// Gets the item rectangle
bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
{