]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Added some Xlib replacement functions and structures for Nano-X
[wxWidgets.git] / src / generic / listctrl.cpp
index f61435dac07279023a4b26e14c263be115ac3c0f..4ec58a8c9347fa80a468f327da9cc0c6eb18401a 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();
@@ -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,7 +1806,8 @@ 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;
@@ -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)
@@ -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->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
@@ -4580,7 +4603,7 @@ bool wxListCtrl::Create(wxWindow *parent,
         style = style | wxLC_LIST;
     }
 
-    if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
+    if ( !wxControl::Create( parent, id, pos, size, style, validator, "listctrl" ) )
         return FALSE;
 
     // don't create the inner window with the border