]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 803473 ] wxListCtrl header height bugfix
authorJulian Smart <julian@anthemion.co.uk>
Thu, 11 Sep 2003 15:38:38 +0000 (15:38 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 11 Sep 2003 15:38:38 +0000 (15:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23514 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/listctrl.h
src/generic/listctrl.cpp

index d5e35bf8322c0ab73e735080bc9bccd018e303ee..e388a13d10567d8d6a8cb44e97b5a82cf47586d0 100644 (file)
@@ -201,6 +201,7 @@ public:
                          m_ownsImageListState;
     wxListHeaderWindow  *m_headerWin;
     wxListMainWindow    *m_mainWin;
+    wxCoord              m_headerHeight;
 
 protected:
     // return the text for the given column of the given item
@@ -222,6 +223,9 @@ private:
     // create the header window
     void CreateHeaderWindow();
 
+    // calculate and set height of the header
+    void CalculateAndSetHeaderHeight();
+
     // reposition the header and the main window in the report view depending
     // on whether it should be shown or not
     void ResizeReportView(bool showHeader);
index 6674b681f658d6612c64bac74c5979bf9f4fae55..3ef7404b3b5839b524bb1d7e12c05e3dd45ae4fc 100644 (file)
@@ -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;
@@ -4429,6 +4429,7 @@ wxGenericListCtrl::wxGenericListCtrl()
 
     m_mainWin = (wxListMainWindow*) NULL;
     m_headerWin = (wxListHeaderWindow*) NULL;
+    m_headerHeight = 0;
 }
 
 wxGenericListCtrl::~wxGenericListCtrl()
@@ -4441,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,
@@ -4676,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;
 }
 
@@ -5008,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
     {
@@ -5076,8 +5087,11 @@ bool wxGenericListCtrl::SetFont( const wxFont &font )
     if (m_headerWin)
     {
         m_headerWin->SetFont( font );
+        CalculateAndSetHeaderHeight();
     }
 
+    Refresh();
+
     return TRUE;
 }