]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
no real change: just rename "near" into "onNearPart" (MSVC doesn't like 'near' as...
[wxWidgets.git] / src / generic / listctrl.cpp
index 4cd96c9e6acfaeceab48d19f93cfe6839df071a8..b5b460022058c81c9728234ace4882fe4d1fa7d8 100644 (file)
@@ -1160,7 +1160,7 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
 
         // draw the text and image clipping them so that they
         // don't overwrite the column boundary
 
         // draw the text and image clipping them so that they
         // don't overwrite the column boundary
-        wxDCClipper clipper(dc, x, HEADER_OFFSET_Y, cw, h - 4 );
+        wxDCClipper clipper(dc, x, HEADER_OFFSET_Y, cw, h);
 
         // if we have an image, draw it on the right of the label
         if ( imageList )
 
         // if we have an image, draw it on the right of the label
         if ( imageList )
@@ -1170,13 +1170,13 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
                         image,
                         dc,
                         xAligned + wLabel - ix - HEADER_IMAGE_MARGIN_IN_REPORT_MODE,
                         image,
                         dc,
                         xAligned + wLabel - ix - HEADER_IMAGE_MARGIN_IN_REPORT_MODE,
-                        HEADER_OFFSET_Y + (h - 4 - iy)/2,
+                        HEADER_OFFSET_Y + (h - iy)/2,
                         wxIMAGELIST_DRAW_TRANSPARENT
                        );
         }
 
         dc.DrawText( item.GetText(),
                         wxIMAGELIST_DRAW_TRANSPARENT
                        );
         }
 
         dc.DrawText( item.GetText(),
-                     xAligned + EXTRA_WIDTH, h / 2 - hLabel / 2 ); //HEADER_OFFSET_Y + EXTRA_HEIGHT );
+                     xAligned + EXTRA_WIDTH, (h - hLabel) / 2 );
 
         x += wCol;
     }
 
         x += wCol;
     }
@@ -1650,6 +1650,15 @@ wxListMainWindow::~wxListMainWindow()
     delete m_renameTimer;
 }
 
     delete m_renameTimer;
 }
 
+void wxListMainWindow::SetReportView(bool inReportView)
+{
+    const size_t count = m_lines.size();
+    for ( size_t n = 0; n < count; n++ )
+    {
+        m_lines[n].SetReportView(inReportView);
+    }
+}
+
 void wxListMainWindow::CacheLineData(size_t line)
 {
     wxGenericListCtrl *listctrl = GetListCtrl();
 void wxListMainWindow::CacheLineData(size_t line)
 {
     wxGenericListCtrl *listctrl = GetListCtrl();
@@ -4050,8 +4059,11 @@ void wxListMainWindow::InsertItem( wxListItem &item )
     {
         ResetVisibleLinesRange();
 
     {
         ResetVisibleLinesRange();
 
+        const unsigned col = item.GetColumn();
+        wxCHECK_RET( col < m_aColWidths.size(), "invalid item column" );
+
         // calculate the width of the item and adjust the max column width
         // calculate the width of the item and adjust the max column width
-        wxColWidthInfo *pWidthInfo = m_aColWidths.Item(item.GetColumn());
+        wxColWidthInfo *pWidthInfo = m_aColWidths.Item(col);
         int width = GetItemWidthWithImage(&item);
         item.SetWidth(width);
         if (width > pWidthInfo->nMaxWidth)
         int width = GetItemWidthWithImage(&item);
         item.SetWidth(width);
         if (width > pWidthInfo->nMaxWidth)
@@ -4272,7 +4284,6 @@ void wxGenericListCtrl::Init()
 
     m_mainWin = NULL;
     m_headerWin = NULL;
 
     m_mainWin = NULL;
     m_headerWin = NULL;
-    m_headerHeight = wxRendererNative::Get().GetHeaderButtonHeight(this);
 }
 
 wxGenericListCtrl::~wxGenericListCtrl()
 }
 
 wxGenericListCtrl::~wxGenericListCtrl()
@@ -4299,22 +4310,20 @@ void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded()
                       (
                         this, wxID_ANY, m_mainWin,
                         wxPoint(0,0),
                       (
                         this, wxID_ANY, m_mainWin,
                         wxPoint(0,0),
-                        wxSize(GetClientSize().x, m_headerHeight),
+                        wxSize
+                        (
+                          GetClientSize().x,
+                          wxRendererNative::Get().GetHeaderButtonHeight(this)
+                        ),
                         wxTAB_TRAVERSAL
                       );
 
 #if defined( __WXMAC__ )
                         wxTAB_TRAVERSAL
                       );
 
 #if defined( __WXMAC__ )
-        wxFont font;
-        font.CreateSystemFont( wxOSX_SYSTEM_FONT_SMALL );
+        static wxFont font( wxOSX_SYSTEM_FONT_SMALL );
         m_headerWin->SetFont( font );
 #endif
 
         GetSizer()->Prepend( m_headerWin, 0, wxGROW );
         m_headerWin->SetFont( font );
 #endif
 
         GetSizer()->Prepend( m_headerWin, 0, wxGROW );
-#ifdef __WXOSX__
-        // TODO not tested under other platforms, remove the platform condition if
-        // it works on those as well
-        GetSizer()->SetItemMinSize( m_headerWin, wxSize(-1,m_headerHeight) ); 
-#endif
     }
     else
     {
     }
     else
     {
@@ -4446,16 +4455,28 @@ void wxGenericListCtrl::SetSingleStyle( long style, bool add )
 
 void wxGenericListCtrl::SetWindowStyleFlag( long flag )
 {
 
 void wxGenericListCtrl::SetWindowStyleFlag( long flag )
 {
+    const bool wasInReportView = HasFlag(wxLC_REPORT);
+
+    // update the window style first so that the header is created or destroyed
+    // corresponding to the new style
+    wxWindow::SetWindowStyleFlag( flag );
+
     if (m_mainWin)
     {
     if (m_mainWin)
     {
+        const bool inReportView = (flag & wxLC_REPORT) != 0;
+        if ( inReportView != wasInReportView )
+        {
+            // we need to notify the main window about this change as it must
+            // update its data structures
+            m_mainWin->SetReportView(inReportView);
+        }
+
         // m_mainWin->DeleteEverything();  wxMSW doesn't do that
 
         CreateOrDestroyHeaderWindowAsNeeded();
 
         GetSizer()->Layout();
     }
         // m_mainWin->DeleteEverything();  wxMSW doesn't do that
 
         CreateOrDestroyHeaderWindowAsNeeded();
 
         GetSizer()->Layout();
     }
-
-    wxWindow::SetWindowStyleFlag( flag );
 }
 
 bool wxGenericListCtrl::GetColumn(int col, wxListItem &item) const
 }
 
 bool wxGenericListCtrl::GetColumn(int col, wxListItem &item) const
@@ -4544,9 +4565,9 @@ wxGenericListCtrl::SetItemColumnImage( long item, long column, int image )
     return true;
 }
 
     return true;
 }
 
-wxString wxGenericListCtrl::GetItemText( long item ) const
+wxString wxGenericListCtrl::GetItemText( long item, int col ) const
 {
 {
-    return m_mainWin->GetItemText(item);
+    return m_mainWin->GetItemText(item, col);
 }
 
 void wxGenericListCtrl::SetItemText( long item, const wxString& str )
 }
 
 void wxGenericListCtrl::SetItemText( long item, const wxString& str )
@@ -4592,7 +4613,7 @@ bool wxGenericListCtrl::GetSubItemRect(long item,
         return false;
 
     if ( m_mainWin->HasHeader() )
         return false;
 
     if ( m_mainWin->HasHeader() )
-        rect.y += m_headerHeight + 1;
+        rect.y += m_headerWin->GetSize().y + 1;
 
     return true;
 }
 
     return true;
 }