X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/61fef19b852d426f5b00b60de083539b9ba0f76c..76fae052f14db3c4c8a3d233fce0074ab25d4789:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index ac046f88fd..3ef7404b3b 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -23,7 +23,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "listctrl.h" #pragma implementation "listctrlbase.h" #endif @@ -103,8 +103,8 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT) // constants // ---------------------------------------------------------------------------- -// the height of the header window (FIXME: should depend on its font!) -static const int HEADER_HEIGHT = 23; +// // the height of the header window (FIXME: should depend on its font!) +// static const int HEADER_HEIGHT = 23; // the scrollbar units static const int SCROLL_UNIT_X = 15; @@ -3778,6 +3778,13 @@ void wxListMainWindow::GetItemRect( long index, wxRect &rect ) const wxCHECK_RET( index >= 0 && (size_t)index < GetItemCount(), _T("invalid index in GetItemRect") ); + // ensure that we're laid out, otherwise we could return nonsense + if ( m_dirty ) + { + wxConstCast(this, wxListMainWindow)-> + RecalculatePositions(TRUE /* no refresh */); + } + rect = GetLineRect((size_t)index); CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y); @@ -4422,6 +4429,7 @@ wxGenericListCtrl::wxGenericListCtrl() m_mainWin = (wxListMainWindow*) NULL; m_headerWin = (wxListHeaderWindow*) NULL; + m_headerHeight = 0; } wxGenericListCtrl::~wxGenericListCtrl() @@ -4434,15 +4442,25 @@ wxGenericListCtrl::~wxGenericListCtrl() delete m_imageListState; } +void wxGenericListCtrl::CalculateAndSetHeaderHeight() +{ + // we use the letter "H" for calculating the needed space, basing on the current font + int w, h; + m_headerWin->GetTextExtent(wxT("H"), &w, &h); + m_headerHeight = h + 2 * HEADER_OFFSET_Y + EXTRA_HEIGHT; + m_headerWin->SetSize(m_headerWin->GetSize().x, m_headerHeight); +} + void wxGenericListCtrl::CreateHeaderWindow() { m_headerWin = new wxListHeaderWindow ( this, -1, m_mainWin, wxPoint(0, 0), - wxSize(GetClientSize().x, HEADER_HEIGHT), + wxSize(GetClientSize().x, m_headerHeight), wxTAB_TRAVERSAL ); + CalculateAndSetHeaderHeight(); } bool wxGenericListCtrl::Create(wxWindow *parent, @@ -4669,7 +4687,7 @@ bool wxGenericListCtrl::GetItemRect( long item, wxRect &rect, int WXUNUSED(code { m_mainWin->GetItemRect( item, rect ); if ( m_mainWin->HasHeader() ) - rect.y += HEADER_HEIGHT + 1; + rect.y += m_headerHeight + 1; return TRUE; } @@ -5001,8 +5019,8 @@ void wxGenericListCtrl::ResizeReportView(bool showHeader) if ( showHeader ) { - m_headerWin->SetSize( 0, 0, cw, HEADER_HEIGHT ); - m_mainWin->SetSize( 0, HEADER_HEIGHT + 1, cw, ch - HEADER_HEIGHT - 1 ); + m_headerWin->SetSize( 0, 0, cw, m_headerHeight ); + m_mainWin->SetSize( 0, m_headerHeight + 1, cw, ch - m_headerHeight - 1 ); } else // no header window { @@ -5069,8 +5087,11 @@ bool wxGenericListCtrl::SetFont( const wxFont &font ) if (m_headerWin) { m_headerWin->SetFont( font ); + CalculateAndSetHeaderHeight(); } + Refresh(); + return TRUE; }