]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp
added a test to check how exception handling works with Win32 SEH; corrected copyright
[wxWidgets.git] / wxPython / contrib / gizmos / wxCode / src / treelistctrl.cpp
index 8aef1b7cba842e019244d5a5d2527c113d239331..c178ad47ebf40455d1dff9a778635232aafe149b 100644 (file)
@@ -40,6 +40,7 @@
 #include <wx/dcscreen.h>
 #include <wx/scrolwin.h>
 #include <wx/renderer.h>
+#include <wx/dcmemory.h>
 
 #include "wx/treelistctrl.h"
 
@@ -152,6 +153,7 @@ public:
     void DrawCurrent();
     void AdjustDC(wxDC& dc);
 
+    void OnEraseBackground( wxEraseEvent& event );
     void OnPaint( wxPaintEvent &event );
     void OnMouse( wxMouseEvent &event );
     void OnSetFocus( wxFocusEvent &event );
@@ -1075,9 +1077,10 @@ void wxTreeListTextCtrl::OnKillFocus( wxFocusEvent &event )
 IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow,wxWindow);
 
 BEGIN_EVENT_TABLE(wxTreeListHeaderWindow,wxWindow)
-    EVT_PAINT         (wxTreeListHeaderWindow::OnPaint)
-    EVT_MOUSE_EVENTS  (wxTreeListHeaderWindow::OnMouse)
-    EVT_SET_FOCUS     (wxTreeListHeaderWindow::OnSetFocus)
+    EVT_ERASE_BACKGROUND  (wxTreeListHeaderWindow::OnEraseBackground)
+    EVT_PAINT             (wxTreeListHeaderWindow::OnPaint)
+    EVT_MOUSE_EVENTS      (wxTreeListHeaderWindow::OnMouse)
+    EVT_SET_FOCUS         (wxTreeListHeaderWindow::OnSetFocus)
 END_EVENT_TABLE()
 
 void wxTreeListHeaderWindow::Init()
@@ -1190,26 +1193,35 @@ void wxTreeListHeaderWindow::AdjustDC(wxDC& dc)
     dc.SetDeviceOrigin( -x * xpix, 0 );
 }
 
+
+void wxTreeListHeaderWindow::OnEraseBackground( wxEraseEvent& event )
+{
+}
+
 void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
 {
 #ifdef __WXGTK__
-    wxClientDC dc( this );
+    wxClientDC real_dc( this );
 #else
-    wxPaintDC dc( this );
+    wxPaintDC real_dc( this );
 #endif
 
-    PrepareDC( dc );
-    AdjustDC( dc );
-
-    dc.BeginDrawing();
-
-    dc.SetFont( GetFont() );
+    AdjustDC( real_dc );
 
     // width and height of the entire header window
     int w, h;
     GetClientSize( &w, &h );
     m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
 
+    // Setup double buffering to eliminate the flicker
+    wxMemoryDC dc;
+    wxBitmap   buffer(w, h);
+    dc.SelectObject(buffer);
+    dc.SetBackground(wxBrush(GetBackgroundColour()));
+    dc.Clear();
+    
+    dc.BeginDrawing();
+    dc.SetFont( GetFont() );
     dc.SetBackgroundMode(wxTRANSPARENT);
 
     // do *not* use the listctrl colour for headers - one day we will have a
@@ -1294,12 +1306,14 @@ void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
     {
         //DoDrawRect( &dc, x, HEADER_OFFSET_Y, more_w, h-2 );
         wxRendererNative::Get().DrawHeaderButton(
-            this, dc, wxRect(x, HEADER_OFFSET_Y, more_w, h-3),
+            this, dc, wxRect(x, HEADER_OFFSET_Y, more_w, h-2),
             m_parent->IsEnabled() ? 0 : wxCONTROL_DISABLED);
     }
 
-
+    // Finish up by drawing the buffer to the real dc
     dc.EndDrawing();
+    dc.SelectObject(wxNullBitmap);
+    real_dc.DrawBitmap(buffer, 0, 0, false);
 }
 
 void wxTreeListHeaderWindow::DrawCurrent()
@@ -1676,8 +1690,10 @@ wxTreeListItem *wxTreeListItem::HitTest(const wxPoint& point,
             }
 
             // check for image hit
-            if (theCtrl->m_imgWidth > 0) {
+            if (theCtrl->m_imgWidth > 0 && GetImage() != NO_IMAGE) {
                 int imgX = m_x - theCtrl->m_imgWidth2;
+                if (HasPlus() && theCtrl->HasButtons())
+                    imgX += theCtrl->m_btnWidth + LINEATROOT;
                 int imgY = y_mid - theCtrl->m_imgHeight2;
                 if ((point.x >= imgX) && (point.x <= (imgX + theCtrl->m_imgWidth)) &&
                     (point.y >= imgY) && (point.y <= (imgY + theCtrl->m_imgHeight))) {
@@ -1875,7 +1891,7 @@ void wxTreeListMainWindow::Init()
 
     m_underMouse = NULL;
 
-#if defined( __WXMAC__ ) && __WXMAC_CARBON__
+#if defined( __WXMAC__ ) && defined(__WXMAC_CARBON__)
     m_normalFont.MacCreateThemeFont( kThemeViewsFont ) ;
 #else
     m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
@@ -4629,10 +4645,10 @@ void wxTreeListCtrl::CalculateAndSetHeaderHeight()
         h += d + 2 * HEADER_OFFSET_Y + EXTRA_HEIGHT;
 
         // only update if changed
-        if ( h != m_headerHeight )
+        if ( h != (int)m_headerHeight )
         {
-            m_headerHeight = h;
-            //m_header_win->SetSize(m_header_win->GetSize().x, m_headerHeight);
+            m_headerHeight = (size_t)h;
+            m_header_win->SetSize(m_header_win->GetSize().x, m_headerHeight);
         }
     }
 }
@@ -4642,9 +4658,11 @@ void wxTreeListCtrl::OnSize(wxSizeEvent& WXUNUSED(event))
 {
     int w, h;
     GetClientSize(&w, &h);
-    printf("%d  (%d, %d)\n", m_headerHeight, w, h);
     if (m_header_win)
+    {
         m_header_win->SetSize(0, 0, w, m_headerHeight);
+        m_header_win->Refresh(false);
+    }
     if (m_main_win)
         m_main_win->SetSize(0, m_headerHeight + 1, w, h - m_headerHeight - 1);
 }