]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Fix so OGL can build without wxBuffer
[wxWidgets.git] / src / generic / listctrl.cpp
index 9f32c43da4a62f9874dc4951df0b30b68383a783..07141e897ec33543ec778a9cd48cfa65a2e981c2 100644 (file)
@@ -50,7 +50,7 @@
 #include "wx/imaglist.h"
 #include "wx/listctrl.h"
 
-#ifdef __WXGTK__
+#if defined(__WXGTK__)
     #include <gtk/gtk.h>
     #include "wx/gtk/win_gtk.h"
 #endif
@@ -626,6 +626,8 @@ public:
     // suspend/resume redrawing the control
     void Freeze();
     void Thaw();
+    
+    void SetFocus();
 
     void OnRenameTimer();
     void OnRenameAccept();
@@ -827,7 +829,7 @@ protected:
 #ifdef __WXMAC__
         return *wxWHITE;
 #else
-        return wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT);
+        return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
 #endif
     }
 
@@ -1595,7 +1597,7 @@ bool wxListLineData::SetAttributes(wxDC *dc,
     wxColour colText;
     if ( highlighted )
     {
-        colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
+        colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
     }
     else
     {
@@ -1786,7 +1788,7 @@ wxListHeaderWindow::wxListHeaderWindow( wxWindow *win,
     m_owner = owner;
     m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
 
-    SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ) );
+    SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
 }
 
 wxListHeaderWindow::~wxListHeaderWindow()
@@ -1796,7 +1798,7 @@ wxListHeaderWindow::~wxListHeaderWindow()
 
 void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h )
 {
-#ifdef __WXGTK__
+#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
     GtkStateType state = m_parent->IsEnabled() ? GTK_STATE_NORMAL
                                                : GTK_STATE_INSENSITIVE;
 
@@ -1804,14 +1806,15 @@ void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h )
 
     gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window,
                    state, GTK_SHADOW_OUT,
-                   (GdkRectangle*) NULL, m_wxwindow, "button",
+                   (GdkRectangle*) NULL, m_wxwindow,
+                   (char *)"button", // const_cast
                    x-1, y-1, w+2, h+2);
 #elif defined( __WXMAC__  )
     const int m_corner = 1;
 
     dc->SetBrush( *wxTRANSPARENT_BRUSH );
 
-    dc->SetPen( wxPen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW ) , 1 , wxSOLID ) );
+    dc->SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ) , 1 , wxSOLID ) );
     dc->DrawLine( x+w-m_corner+1, y, x+w, y+h );  // right (outer)
     dc->DrawRectangle( x, y+h, w+1, 1 );          // bottom (outer)
 
@@ -1835,7 +1838,7 @@ void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h )
     dc->DrawLine( x+w-m_corner+1, y, x+w, y+h );  // right (outer)
     dc->DrawRectangle( x, y+h, w+1, 1 );          // bottom (outer)
 
-    wxPen pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID );
+    wxPen pen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID );
 
     dc->SetPen( pen );
     dc->DrawLine( x+w-m_corner, y, x+w-1, y+h );  // right (inner)
@@ -1865,7 +1868,7 @@ void wxListHeaderWindow::AdjustDC(wxDC& dc)
 
 void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
 {
-#ifdef __WXGTK__
+#if defined(__WXGTK__)
     wxClientDC dc( this );
 #else
     wxPaintDC dc( this );
@@ -1949,9 +1952,9 @@ void wxListHeaderWindow::DrawCurrent()
 {
     int x1 = m_currentX;
     int y1 = 0;
-    ClientToScreen( &x1, &y1 );
+    m_owner->ClientToScreen( &x1, &y1 );
 
-    int x2 = m_currentX-1;
+    int x2 = m_currentX;
     int y2 = 0;
     m_owner->GetClientSize( NULL, &y2 );
     m_owner->ClientToScreen( &x2, &y2 );
@@ -2157,7 +2160,7 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
             m_owner->OnRenameAccept();
 
         m_finished = TRUE;
-        m_owner->SetFocus(); // This doesn't work. TODO.
+        m_owner->SetFocus();
 
         return;
     }
@@ -2170,7 +2173,7 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
             wxPendingDelete.Append(this);
 
         m_finished = TRUE;
-        m_owner->SetFocus(); // This doesn't work. TODO.
+        m_owner->SetFocus();
 
         return;
     }
@@ -2191,7 +2194,7 @@ void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
     wxPoint myPos = GetPosition();
     wxSize mySize = GetSize();
     int sx, sy;
-    GetTextExtent(GetValue() + _T("M"), &sx, &sy); // FIXME: MM??
+    GetTextExtent(GetValue() + _T("MM"), &sx, &sy);
     if (myPos.x + sx > parentSize.x)
         sx = parentSize.x - myPos.x;
     if (mySize.x > sx)
@@ -2307,7 +2310,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
 
     m_highlightBrush = new wxBrush
                            (
-                            wxSystemSettings::GetSystemColour
+                            wxSystemSettings::GetColour
                             (
                                 wxSYS_COLOUR_HIGHLIGHT
                             ),
@@ -2316,7 +2319,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
 
     m_highlightUnfocusedBrush = new wxBrush
                                     (
-                                       wxSystemSettings::GetSystemColour
+                                       wxSystemSettings::GetColour
                                        (
                                            wxSYS_COLOUR_BTNSHADOW
                                        ),
@@ -2329,7 +2332,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
     InitScrolling();
     SetScrollbars( m_xScroll, m_yScroll, 0, 0, 0, 0 );
 
-    SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
+    SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ) );
 }
 
 wxListMainWindow::~wxListMainWindow()
@@ -3427,6 +3430,26 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
 extern wxWindow *g_focusWindow;
 #endif
 
+void wxListMainWindow::SetFocus()
+{
+    // VS: wxListMainWindow derives from wxPanel (via wxScrolledWindow) and wxPanel
+    //     overrides SetFocus in such way that it does never change focus from 
+    //     panel's child to the panel itself. Unfortunately, we must be able to change
+    //     focus to the panel from wxListTextCtrl because the text control should 
+    //     disappear when the user clicks outside it.
+
+    wxWindow *oldFocus = FindFocus();
+    
+    if ( oldFocus && oldFocus->GetParent() == this )
+    {
+        wxWindow::SetFocus();
+    }
+    else
+    {
+        wxScrolledWindow::SetFocus();
+    }
+}
+
 void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
 {
     // wxGTK sends us EVT_SET_FOCUS events even if we had never got