mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 17:22:10 +00:00
Changed [-_userResizedTableColumn: leftWidth: rightWidth:] to
[-_userResizedTableColumn: width] for better resizing Added [-_columnOrigins] for column reordering git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10705 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
625b08dccc
commit
50f2f7ce0c
1 changed files with 104 additions and 8 deletions
|
@ -38,6 +38,7 @@
|
||||||
#import <AppKit/NSTextFieldCell.h>
|
#import <AppKit/NSTextFieldCell.h>
|
||||||
#import <AppKit/NSWindow.h>
|
#import <AppKit/NSWindow.h>
|
||||||
#import <AppKit/PSOperators.h>
|
#import <AppKit/PSOperators.h>
|
||||||
|
#import <AppKit/NSCachedImageRep.h>
|
||||||
|
|
||||||
static NSNotificationCenter *nc = nil;
|
static NSNotificationCenter *nc = nil;
|
||||||
|
|
||||||
|
@ -262,6 +263,7 @@ _isCellEditable (id delegate, NSArray *tableColumns,
|
||||||
_allowsMultipleSelection = NO;
|
_allowsMultipleSelection = NO;
|
||||||
_allowsColumnSelection = YES;
|
_allowsColumnSelection = YES;
|
||||||
_allowsColumnResizing = YES;
|
_allowsColumnResizing = YES;
|
||||||
|
_allowsColumnReordering = YES;
|
||||||
_editedColumn = -1;
|
_editedColumn = -1;
|
||||||
_editedRow = -1;
|
_editedRow = -1;
|
||||||
_selectedColumn = -1;
|
_selectedColumn = -1;
|
||||||
|
@ -717,13 +719,12 @@ _isCellEditable (id delegate, NSArray *tableColumns,
|
||||||
|
|
||||||
- (void) setAllowsColumnReordering: (BOOL)flag
|
- (void) setAllowsColumnReordering: (BOOL)flag
|
||||||
{
|
{
|
||||||
// TODO
|
_allowsColumnReordering = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) allowsColumnReordering
|
- (BOOL) allowsColumnReordering
|
||||||
{
|
{
|
||||||
// TODO
|
return _allowsColumnReordering;
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAllowsColumnResizing: (BOOL)flag
|
- (void) setAllowsColumnResizing: (BOOL)flag
|
||||||
|
@ -2842,17 +2843,112 @@ byExtendingSelection: (BOOL)flag
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _userResizedTableColumn: (int)index
|
||||||
|
width: (float)width
|
||||||
|
{
|
||||||
|
[[_tableColumns objectAtIndex: index] setWidth: width];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float *) _columnOrigins
|
||||||
|
{
|
||||||
|
return _columnOrigins;
|
||||||
|
}
|
||||||
|
/*
|
||||||
- (void) _userResizedTableColumn: (int)index
|
- (void) _userResizedTableColumn: (int)index
|
||||||
leftWidth: (float)lwidth
|
leftWidth: (float)lwidth
|
||||||
rightWidth: (float)rwidth
|
rightWidth: (float)rwidth
|
||||||
{
|
{
|
||||||
_tilingDisabled = YES;
|
[self _userResizedTableColumn: index
|
||||||
[[_tableColumns objectAtIndex: index] setWidth: lwidth];
|
width:lwidth];
|
||||||
[[_tableColumns objectAtIndex: index + 1] setWidth: rwidth];
|
|
||||||
_tilingDisabled = NO;
|
|
||||||
[self tile];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _userResizedTableColumn: (int)index
|
||||||
|
width: (float)width
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
// NSRect oldColumnRect = [self rectOfColumn: index];
|
||||||
|
// NSRect newColumnRect;
|
||||||
|
NSRect oldLeftRect, newLeftRect;
|
||||||
|
NSTableColumn *column = [_tableColumns objectAtIndex: index];
|
||||||
|
float deltaWidth = width - [column width];
|
||||||
|
NSImage *cache;
|
||||||
|
NSImageRep *rep;
|
||||||
|
|
||||||
|
_tilingDisabled = YES;
|
||||||
|
|
||||||
|
oldLeftRect.origin.x = _columnOrigins[index+1];
|
||||||
|
oldLeftRect.origin.y = _bounds.origin.y;
|
||||||
|
oldLeftRect.size.height = _bounds.size.height;
|
||||||
|
oldLeftRect.size.width = (_bounds.size.width +
|
||||||
|
_bounds.origin.x -
|
||||||
|
oldLeftRect.origin.x);
|
||||||
|
|
||||||
|
newLeftRect = oldLeftRect;
|
||||||
|
oldLeftRect = NSIntersectionRect(oldLeftRect,
|
||||||
|
[self visibleRect]);
|
||||||
|
|
||||||
|
rep =
|
||||||
|
[[NSCachedImageRep allocWithZone:[self zone]]
|
||||||
|
initWithSize:oldLeftRect.size
|
||||||
|
depth:[NSWindow defaultDepthLimit]
|
||||||
|
separate:YES
|
||||||
|
alpha:NO];
|
||||||
|
cache = [[NSImage allocWithZone:[self zone]]
|
||||||
|
initWithSize:oldLeftRect.size];
|
||||||
|
[cache addRepresentation: rep];
|
||||||
|
[cache lockFocusOnRepresentation: rep];
|
||||||
|
PScomposite(NSMinX(oldLeftRect), NSMinY(oldLeftRect),
|
||||||
|
NSWidth(oldLeftRect), NSHeight(oldLeftRect),
|
||||||
|
[[self window] gState], 0.0, 0.0, NSCompositeCopy);
|
||||||
|
[cache unlockFocus];
|
||||||
|
|
||||||
|
|
||||||
|
newLeftRect.origin.x += deltaWidth;
|
||||||
|
[column setWidth: width];
|
||||||
|
|
||||||
|
// we need to update :
|
||||||
|
// _columnOrigins
|
||||||
|
|
||||||
|
for(i = index + 1; i < _numberOfColumns; i++)
|
||||||
|
{
|
||||||
|
_columnOrigins[i] += deltaWidth;
|
||||||
|
}
|
||||||
|
// to call :
|
||||||
|
// setFrameSize on self
|
||||||
|
// setFrameSize on _headerView
|
||||||
|
{
|
||||||
|
NSSize frameSize = _frame.size; // frameSize == [self frame].size
|
||||||
|
frameSize.width += deltaWidth;
|
||||||
|
[self setFrameSize: frameSize];
|
||||||
|
if (_headerView != nil)
|
||||||
|
{
|
||||||
|
[_headerView setFrameSize:
|
||||||
|
NSMakeSize (_frame.size.width,
|
||||||
|
[_headerView frame].size.height)];
|
||||||
|
[_headerView setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// to copy what's needed
|
||||||
|
{
|
||||||
|
NSSize commonSize;
|
||||||
|
newLeftRect = NSIntersectionRect(newLeftRect, [self visibleRect]);
|
||||||
|
commonSize.width = MIN(NSWidth(newLeftRect),
|
||||||
|
NSWidth(oldLeftRect));
|
||||||
|
commonSize.height = NSHeight(newLeftRect);
|
||||||
|
[rep setSize: commonSize];
|
||||||
|
[self lockFocus];
|
||||||
|
[rep drawAtPoint: newLeftRect.origin];
|
||||||
|
[self unlockFocus];
|
||||||
|
}
|
||||||
|
[self setNeedsDisplay: NO];
|
||||||
|
|
||||||
|
// to call
|
||||||
|
// drawRect where needed...
|
||||||
|
// sleep(2);
|
||||||
|
_tilingDisabled = NO;
|
||||||
|
}
|
||||||
|
*/
|
||||||
// Return YES on success; NO if no selectable cell found.
|
// Return YES on success; NO if no selectable cell found.
|
||||||
-(BOOL) _editNextEditableCellAfterRow: (int)row
|
-(BOOL) _editNextEditableCellAfterRow: (int)row
|
||||||
column: (int)column
|
column: (int)column
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue