<foo.diff>

about to call it done for my changes on NSTableView.... (assuming no issues pop up/nobody wants to revert anything)

heres one last thing... (its actually multiple things)

a) currently it doesn't draw the edited cell, because NSTextFieldCell would draw right over the field editor. this makes it so that it just frames the rect if shows first responder assuming the field editor will take care of drawing
the interior.

b) NSButtonCells seem to be NSTextCellType, so the field editor gets activated on double click this has been changed to call both _trackCell: and _editColumn: then NSButtonCell overrides editWithFrame:/selectWithFrame: to do nothing

c) drawRow:... has been changed to draw the editedCell (the copy) instead of not drawing the original version of the

imho the framing of the cell is kind of ugly, and it should be taking up the entire space (its currently inset when drawing with a grid)
but thats another patch if this one looks ok








Index: NSButtonCell.m
===================================================================
--- NSButtonCell.m      (revision 24074)
+++ NSButtonCell.m      (working copy)
@@ -1745,4 +1745,25 @@
     }
 }
 
+
+/* buttons dont support editing  or selecting */
+- (void) editWithFrame: (NSRect)aRect
+                inView: (NSView*)controlView
+                editor: (NSText*)textObject
+              delegate: (id)anObject
+                 event: (NSEvent*)theEvent
+{
+  return;
+}
+
+- (void) selectWithFrame: (NSRect)aRect
+                  inView: (NSView*)controlView
+                  editor: (NSText*)textObject
+                delegate: (id)anObject
+                   start: (int)selStart
+                  length: (int)selLength
+{
+  return; 
+}
+
 @end
Index: NSTextFieldCell.m
===================================================================
--- NSTextFieldCell.m   (revision 24074)
+++ NSTextFieldCell.m   (working copy)
@@ -36,6 +36,7 @@
 #include "AppKit/NSTextFieldCell.h"
 #include "AppKit/NSText.h"
 #include "AppKit/NSEvent.h"
+#include "AppKit/NSWindow.h"
 
 static NSColor *bgCol;
 static NSColor *txtCol;
@@ -185,8 +186,22 @@
   return textObject;
 }
 
+- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
+{
+  if (_cell.shows_first_responder)
+    {
+      /* field editor should handle drawing the interior just frame it. */
+      NSDottedFrameRect(cellFrame);
+      return;
+    }
+
+  [super drawWithFrame: cellFrame inView: controlView];
+}
+
+
 - (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
 {
+  
   if (_textfieldcell_draws_background)
     {
       [_background_color set];
Index: NSTableView.m
===================================================================
--- NSTableView.m       (revision 24074)
+++ NSTableView.m       (working copy)
@@ -147,7 +147,7 @@
 @end
 
 @interface NSTableView (EventLoopHelper)
-- (void) _trackCellAtColumn:(int)column row:(int)row withEvent:(NSEvent *)ev;
+- (BOOL) _trackCellAtColumn:(int)column row:(int)row withEvent:(NSEvent *)ev;
 - (BOOL) _startDragOperationWithEvent:(NSEvent *)theEvent;
 @end
 
@@ -3264,6 +3264,7 @@
   [_editedCell setEditable: _dataSource_editable];
   [_editedCell setObjectValue: [self _objectValueForTableColumn: tb
                                     row: rowIndex]];
+  [_editedCell setShowsFirstResponder:YES];
   /* [_dataSource tableView: self
      objectValueForTableColumn: tb
      row: rowIndex]]; */
@@ -3359,7 +3360,7 @@
       return 0.01;
 }
 
-- (void) _trackCellAtColumn: (int) columnIndex
+- (BOOL) _trackCellAtColumn: (int) columnIndex
                row: (int) rowIndex
                withEvent: (NSEvent *) theEvent
 {
@@ -3367,10 +3368,11 @@
   NSCell *cell;
   NSRect cellFrame;
   id originalValue;
+  BOOL ret = NO;
 
   if (rowIndex == -1 || columnIndex == -1)
     {
-      return;
+      return NO;
     }
   
   tb = [_tableColumns objectAtIndex: columnIndex];
@@ -3406,11 +3408,13 @@
                        forTableColumn: tb
                        row: rowIndex];
        }
+      ret = YES;
     }
   RELEASE(originalValue);    
   [cell setHighlighted: NO];
   [self setNeedsDisplayInRect: cellFrame];
   RELEASE(cell);
+  return ret;
 }
 
 - (BOOL) _startDragOperationWithEvent: (NSEvent *) theEvent
@@ -3497,16 +3501,20 @@
          return;
        }
 
-      if (![self _isCellEditableColumn: _clickedColumn row: _clickedRow ])
+      /*
+       * track the mouse, then edit if this is a double click
+       * things which don't want to track shouldn't
+       * things which don't want to edit shouldn't.
+       */
+      if ([self _trackCellAtColumn: _clickedColumn
+                           row: _clickedRow
+                           withEvent: theEvent] && _clickedRow != -1)
         {
-         // Send double-action but don't edit
-         [self _trackCellAtColumn: _clickedColumn
-                           row: _clickedRow
-                           withEvent: theEvent];
-         if (_clickedRow != -1)
-           [self sendAction: _doubleAction to: _target];
+         [self sendAction: _doubleAction to: _target];
        }
-      else if (clickCount == 2) // if < 2, dont want to abort editing
+      
+      if ([self _isCellEditableColumn: _clickedColumn row: _clickedRow ]
+          && clickCount == 2) // if < 2, dont want to abort editing
         {
          // It is OK to edit column.  Go on, do it.
           [self editColumn: _clickedColumn
@@ -4888,6 +4896,12 @@
                              row: rowIndex];
          [cell drawWithFrame: drawingRect inView: self];
        }
+      else if (i == _editedColumn && rowIndex == _editedRow)
+       {
+         drawingRect = [self frameOfCellAtColumn: i
+                               row:rowIndex];
+         [_editedCell drawWithFrame: drawingRect inView: self];
+       }
     }
 }
 
_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to