]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
no real change; just add the standard separator where it's missing
[wxWidgets.git] / src / generic / grid.cpp
index 418b9c901a74a5e900b18a2fab754c8262238d8e..80c7a07be70c90f851a208c38c98bc19a35ce0d9 100644 (file)
@@ -115,26 +115,26 @@ WX_DEFINE_OBJARRAY(wxGridCellWithAttrArray)
 // events
 // ----------------------------------------------------------------------------
 
-wxDEFINE_EVENT( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_CELL_RIGHT_DCLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_CELL_BEGIN_DRAG, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_ROW_SIZE, wxGridSizeEvent )
-wxDEFINE_EVENT( wxEVT_GRID_COL_SIZE, wxGridSizeEvent )
-wxDEFINE_EVENT( wxEVT_GRID_COL_MOVE, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_COL_SORT, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent )
-wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGING, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGED, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_SELECT_CELL, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_EDITOR_SHOWN, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_EDITOR_HIDDEN, wxGridEvent )
-wxDEFINE_EVENT( wxEVT_GRID_EDITOR_CREATED, wxGridEditorCreatedEvent )
+wxDEFINE_EVENT( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_CELL_RIGHT_DCLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_CELL_BEGIN_DRAG, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_ROW_SIZE, wxGridSizeEvent );
+wxDEFINE_EVENT( wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
+wxDEFINE_EVENT( wxEVT_GRID_COL_MOVE, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_COL_SORT, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent );
+wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGING, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGED, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_SELECT_CELL, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_EDITOR_SHOWN, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_EDITOR_HIDDEN, wxGridEvent );
+wxDEFINE_EVENT( wxEVT_GRID_EDITOR_CREATED, wxGridEditorCreatedEvent );
 
 // ============================================================================
 // implementation
@@ -3459,7 +3459,7 @@ void wxGrid::ChangeCursorMode(CursorMode mode,
                               wxWindow *win,
                               bool captureMouse)
 {
-#ifdef __WXDEBUG__
+#if wxUSE_LOG_TRACE
     static const wxChar *cursorModes[] =
     {
         _T("SELECT_CELL"),
@@ -3476,7 +3476,7 @@ void wxGrid::ChangeCursorMode(CursorMode mode,
                                   : win ? _T("rowLabelWin")
                                         : _T("gridWin"),
                cursorModes[m_cursorMode], cursorModes[mode]);
-#endif
+#endif // wxUSE_LOG_TRACE
 
     if ( mode == m_cursorMode &&
          win == m_winCapture &&
@@ -5976,7 +5976,7 @@ void wxGrid::SaveEditControlValue()
         wxGridCellEditor* editor = attr->GetEditor(this, row, col);
 
         wxString newval;
-        bool changed = editor->EndEdit(oldval, &newval);
+        bool changed = editor->EndEdit(row, col, this, oldval, &newval);
 
         if ( changed && SendEvent(wxEVT_GRID_CELL_CHANGING, newval) != -1 )
         {
@@ -6191,13 +6191,13 @@ wxRect wxGrid::CellToRect( int row, int col ) const
             rect.width += GetColWidth(i);
         for (i=row; i < row + cell_rows; i++)
             rect.height += GetRowHeight(i);
-    }
 
-    // if grid lines are enabled, then the area of the cell is a bit smaller
-    if (m_gridLinesEnabled)
-    {
-        rect.width -= 1;
-        rect.height -= 1;
+        // if grid lines are enabled, then the area of the cell is a bit smaller
+        if (m_gridLinesEnabled)
+        {
+            rect.width -= 1;
+            rect.height -= 1;
+        }
     }
 
     return rect;
@@ -8083,7 +8083,8 @@ void wxGrid::DeselectLine(int line, const wxGridOperations& oper)
         return;
 
     const wxGridSelectionModes mode = m_selection->GetSelectionMode();
-    if ( mode == oper.GetSelectionMode() )
+    if ( mode == oper.GetSelectionMode() ||
+            mode == wxGrid::wxGridSelectRowsOrColumns )
     {
         const wxGridCellCoords c(oper.MakeCoords(line, 0));
         if ( m_selection->IsInSelection(c) )
@@ -8201,8 +8202,10 @@ void wxGrid::ClearSelection()
     m_selectedBlockBottomRight =
     m_selectedBlockCorner = wxGridNoCellCoords;
 
-    Refresh( false, &r1 );
-    Refresh( false, &r2 );
+    if ( !r1.IsEmpty() )
+        RefreshRect(r1, false);
+    if ( !r2.IsEmpty() )
+        RefreshRect(r2, false);
 
     if ( m_selection )
         m_selection->ClearSelection();
@@ -8334,6 +8337,48 @@ wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords& topLeft,
     return resultRect;
 }
 
+void wxGrid::DoSetSizes(const wxGridSizesInfo& sizeInfo,
+                        const wxGridOperations& oper)
+{
+    BeginBatch();
+    oper.SetDefaultLineSize(this, sizeInfo.m_sizeDefault, true);
+    const int numLines = oper.GetNumberOfLines(this);
+    for ( int i = 0; i < numLines; i++ )
+    {
+        int size = sizeInfo.GetSize(i);
+        if ( size != sizeInfo.m_sizeDefault)
+            oper.SetLineSize(this, i, size);
+    }
+    EndBatch();
+}
+
+void wxGrid::SetColSizes(const wxGridSizesInfo& sizeInfo)
+{
+    DoSetSizes(sizeInfo, wxGridColumnOperations());
+}
+
+void wxGrid::SetRowSizes(const wxGridSizesInfo& sizeInfo)
+{
+    DoSetSizes(sizeInfo, wxGridRowOperations());
+}
+
+wxGridSizesInfo::wxGridSizesInfo(int defSize, const wxArrayInt& allSizes)
+{
+    m_sizeDefault = defSize;
+    for ( size_t i = 0; i < allSizes.size(); i++ )
+    {
+        if ( allSizes[i] != defSize )
+            m_customSizes[i] = allSizes[i];
+    }
+}
+
+int wxGridSizesInfo::GetSize(unsigned pos) const
+{
+    wxUnsignedToIntHashMap::const_iterator it = m_customSizes.find(pos);
+
+    return it == m_customSizes.end() ? m_sizeDefault : it->second;
+}
+
 // ----------------------------------------------------------------------------
 // drop target
 // ----------------------------------------------------------------------------