]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
attempt at HP-UX compilation fix
[wxWidgets.git] / src / generic / listctrl.cpp
index 1ba7eda09dfe5966eedc28421a2299539096887b..4c9d73e2ed004bd7db0165ac292e5b228bff9cf6 100644 (file)
@@ -342,6 +342,7 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing )
                 if (s.IsNull()) s = "H";
                 wxCoord lw,lh;
                 dc->GetTextExtent( s, &lw, &lh );
+                if (lh < 15) lh = 15;
                 item->SetSize( item->GetWidth(), lh );
                 m_bound_all.width += lw;
                 m_bound_all.height = lh;
@@ -440,6 +441,7 @@ void wxListLineData::SetPosition( wxDC *dc, int x, int y, int window_width )
         {
             wxCoord lw,lh;
             dc->GetTextExtent( "H", &lw, &lh );
+            if (lh < 15) lh = 15;
             m_bound_all.x = 0;
             m_bound_all.y -= 0;
             m_bound_all.height = lh+3;
@@ -456,6 +458,7 @@ void wxListLineData::SetPosition( wxDC *dc, int x, int y, int window_width )
                 if (s.IsEmpty()) s = wxT("H");
                 wxCoord lw,lh;
                 dc->GetTextExtent( s, &lw, &lh );
+                if (lh < 15) lh = 15;
                 m_bound_label.width = lw;
                 m_bound_label.height = lh;
                 if (item->HasImage())
@@ -618,15 +621,14 @@ void wxListLineData::SetAttributes(wxDC *dc,
 
 void wxListLineData::DoDraw( wxDC *dc, bool hilight, bool paintBG )
 {
-    wxCoord dev_x = dc->LogicalToDeviceX( m_bound_all.x-2 );
-    wxCoord dev_y = dc->LogicalToDeviceY( m_bound_all.y-2 );
-    wxCoord dev_w = dc->LogicalToDeviceXRel( m_bound_all.width+4 );
-    wxCoord dev_h = dc->LogicalToDeviceYRel( m_bound_all.height+4 );
+    wxCoord dev_x = 0;
+    wxCoord dev_y = 0;
+    m_owner->CalcScrolledPosition( m_bound_all.x, m_bound_all.y, &dev_x, &dev_y );
+    wxCoord dev_w = m_bound_all.width;
+    wxCoord dev_h = m_bound_all.height;
 
     if (!m_owner->IsExposed( dev_x, dev_y, dev_w, dev_h ))
-    {
         return;
-    }
 
     wxWindow *listctrl = m_owner->GetParent();
 
@@ -677,7 +679,6 @@ void wxListLineData::DoDraw( wxDC *dc, bool hilight, bool paintBG )
         while (node)
         {
             wxListItemData *item = (wxListItemData*)node->Data();
-            dc->SetClippingRegion( item->GetX(), item->GetY(), item->GetWidth()-3, item->GetHeight() );
             int x = item->GetX();
             if (item->HasImage())
             {
@@ -686,9 +687,10 @@ void wxListLineData::DoDraw( wxDC *dc, bool hilight, bool paintBG )
                 m_owner->GetImageSize( item->GetImage(), x, y );
                 x += item->GetX() + 5;
             }
+            dc->SetClippingRegion( item->GetX(), item->GetY(), item->GetWidth()-3, item->GetHeight() );
             if (item->HasText())
             {
-                dc->DrawText( item->GetText(), x, item->GetY() );
+                dc->DrawText( item->GetText(), x, item->GetY()+1 );
             }
             dc->DestroyClippingRegion();
             node = node->Next();
@@ -1060,24 +1062,33 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
     {
         (*m_accept) = TRUE;
         (*m_res) = GetValue();
-        m_owner->SetFocus();
+        
+        if (!wxPendingDelete.Member(this))
+            wxPendingDelete.Append(this);
+
+        if ((*m_accept) && ((*m_res) != m_startValue))
+            m_owner->OnRenameAccept();
+            
         return;
     }
     if (event.m_keyCode == WXK_ESCAPE)
     {
         (*m_accept) = FALSE;
         (*m_res) = "";
-        m_owner->SetFocus();
+        
+        if (!wxPendingDelete.Member(this))
+            wxPendingDelete.Append(this);
+            
         return;
     }
+    
     event.Skip();
 }
 
 void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
 {
-    if (wxPendingDelete.Member(this)) return;
-
-    wxPendingDelete.Append(this);
+    if (!wxPendingDelete.Member(this))
+        wxPendingDelete.Append(this);
 
     if ((*m_accept) && ((*m_res) != m_startValue))
         m_owner->OnRenameAccept();
@@ -1097,7 +1108,7 @@ BEGIN_EVENT_TABLE(wxListMainWindow,wxScrolledWindow)
   EVT_KEY_DOWN       (wxListMainWindow::OnKeyDown)
   EVT_SET_FOCUS      (wxListMainWindow::OnSetFocus)
   EVT_KILL_FOCUS     (wxListMainWindow::OnKillFocus)
-  EVT_SCROLL                 (wxListMainWindow::OnScroll)
+  EVT_SCROLLWIN      (wxListMainWindow::OnScroll)
 END_EVENT_TABLE()
 
 wxListMainWindow::wxListMainWindow()
@@ -1166,7 +1177,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxWindowID id,
     m_renameTimer = new wxListRenameTimer( this );
     m_renameAccept = FALSE;
 
-    SetBackgroundColour( *wxWHITE );
+    SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
 }
 
 wxListMainWindow::~wxListMainWindow()
@@ -1182,22 +1193,16 @@ void wxListMainWindow::RefreshLine( wxListLineData *line )
 {
     if (m_dirty) return;
 
+    if (!line) return;
+    
     int x = 0;
     int y = 0;
     int w = 0;
     int h = 0;
-    if (line)
-    {
-        wxClientDC dc(this);
-        PrepareDC( dc );
-        line->GetExtent( x, y, w, h );
-        wxRect rect(
-          dc.LogicalToDeviceX(x-3),
-          dc.LogicalToDeviceY(y-3),
-          dc.LogicalToDeviceXRel(w+6),
-          dc.LogicalToDeviceXRel(h+6) );
-        Refresh( TRUE, &rect );
-    }
+    line->GetExtent( x, y, w, h );
+    CalcScrolledPosition( x, y, &x, &y );
+    wxRect rect( x, y, w, h );
+    Refresh( TRUE, &rect );
 }
 
 void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
@@ -2734,7 +2739,7 @@ bool wxListCtrl::Create(wxWindow *parent,
         m_headerWin = (wxListHeaderWindow *) NULL;
     }
 
-    SetBackgroundColour( *wxWHITE );
+    SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
 
     return ret;
 }