]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Busy cursor don't need wxYield(), SendIdleEvents()
[wxWidgets.git] / src / generic / listctrl.cpp
index 8e7857291fd6b88294cb1960d3d50dd880dafb7e..761e8f4d9dcdeca680a0311fbc73d36c98b08e5e 100644 (file)
@@ -264,6 +264,7 @@ public:
                     const wxValidator& validator = wxDefaultValidator,
                     const wxString &name = "listctrltextctrl" );
     void OnChar( wxKeyEvent &event );
+    void OnKeyUp( wxKeyEvent &event );
     void OnKillFocus( wxFocusEvent &event );
 
 private:
@@ -315,7 +316,9 @@ public:
     void RefreshLine( wxListLineData *line );
     void OnPaint( wxPaintEvent &event );
     void HilightAll( bool on );
-    void SendNotify( wxListLineData *line, wxEventType command );
+    void SendNotify( wxListLineData *line,
+                     wxEventType command,
+                     wxPoint point = wxDefaultPosition );
     void FocusLine( wxListLineData *line );
     void UnfocusLine( wxListLineData *line );
     void SelectLine( wxListLineData *line );
@@ -1203,8 +1206,8 @@ void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h )
     
     x = dc->XLOG2DEV( x );
     
-       gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window, state, GTK_SHADOW_OUT,
-               (GdkRectangle*) NULL, m_wxwindow, "button", x-1, y-1, w+2, h+2);
+    gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window, state, GTK_SHADOW_OUT,
+                   (GdkRectangle*) NULL, m_wxwindow, "button", x-1, y-1, w+2, h+2);
 #else
     const int m_corner = 1;
 
@@ -1469,6 +1472,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl,wxTextCtrl);
 
 BEGIN_EVENT_TABLE(wxListTextCtrl,wxTextCtrl)
     EVT_CHAR           (wxListTextCtrl::OnChar)
+    EVT_KEY_UP         (wxListTextCtrl::OnKeyUp)    
     EVT_KILL_FOCUS     (wxListTextCtrl::OnKillFocus)
 END_EVENT_TABLE()
 
@@ -1522,6 +1526,21 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
     event.Skip();
 }
 
+void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
+{
+    // auto-grow the textctrl:
+    wxSize parentSize = m_owner->GetSize();
+    wxPoint myPos = GetPosition();
+    wxSize mySize = GetSize();
+    int sx, sy;
+    GetTextExtent(GetValue() + _T("MM"), &sx, &sy);
+    if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x;
+    if (mySize.x > sx) sx = mySize.x;
+    SetSize(sx, -1);
+    
+    event.Skip();
+}
+
 void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
 {
     if (!wxPendingDelete.Member(this))
@@ -1730,11 +1749,18 @@ void wxListMainWindow::HilightAll( bool on )
     }
 }
 
-void wxListMainWindow::SendNotify( wxListLineData *line, wxEventType command )
+void wxListMainWindow::SendNotify( wxListLineData *line,
+                                   wxEventType command,
+                                   wxPoint point )
 {
     wxListEvent le( command, GetParent()->GetId() );
     le.SetEventObject( GetParent() );
     le.m_itemIndex = GetIndexOfLine( line );
+
+    // set only for events which have position
+    if ( point != wxDefaultPosition )
+        le.m_pointDrag = point;
+
     line->GetItem( 0, le.m_item );
     GetParent()->GetEventHandler()->ProcessEvent( le );
 //    GetParent()->GetEventHandler()->AddPendingEvent( le );
@@ -1865,8 +1891,8 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
 
         if (m_dragCount != 3) return;
 
-        int command = wxEVT_COMMAND_LIST_BEGIN_DRAG;
-        if (event.RightIsDown()) command = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
+        int command = event.RightIsDown() ? wxEVT_COMMAND_LIST_BEGIN_RDRAG
+                                          : wxEVT_COMMAND_LIST_BEGIN_DRAG;
 
         wxListEvent le( command, GetParent()->GetId() );
         le.SetEventObject( GetParent() );
@@ -1919,7 +1945,8 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
 
     if (event.RightDown())
     {
-        SendNotify( line, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK );
+        SendNotify( line, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
+                    event.GetPosition() );
         return;
     }
 
@@ -2647,6 +2674,7 @@ void wxListMainWindow::GetItemRect( long index, wxRect &rect )
     if (index >= 0 && (size_t)index < m_lines.GetCount())
     {
         m_lines[(size_t)index].GetRect( rect );
+        this->CalcScrolledPosition(rect.x,rect.y,&rect.x,&rect.y);
     }
     else
     {
@@ -2659,18 +2687,9 @@ void wxListMainWindow::GetItemRect( long index, wxRect &rect )
 
 bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos)
 {
-    if (item >= 0 && (size_t)item < m_lines.GetCount())
-    {
-        wxRect rect;
-        m_lines[(size_t)item].GetRect( rect );
-        pos.x = rect.x;
-        pos.y = rect.y;
-    }
-    else
-    {
-       pos.x = 0;
-       pos.y = 0;
-    }
+    wxRect rect;
+    this->GetItemRect(item,rect);
+    pos.x=rect.x; pos.y=rect.y;
     return TRUE;
 }