mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Added missing Cocoa methods and a Cocoa header file.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19269 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c35f6f8821
commit
6b78af5ade
4 changed files with 249 additions and 11 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2004-05-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Header/Cocoa/Cocoa.h:
|
||||
New header file for Cocoa compatibility. Currently not installed.
|
||||
* Source/NSTableView.m:
|
||||
Implemented [selectColumnIndexes:byExtendingSelection:] and
|
||||
[selectRowIndexes:byExtendingSelection:].
|
||||
* Source/NSDocument.m:
|
||||
Implemented [runModalSavePanelForSaveOperation:..contextInfo:],
|
||||
[saveDocumentWithDelegate:didSaveSelector:contextInfo:] and
|
||||
[saveToFile:..contextInfo:]. Added call to [prepareSavePanel] in
|
||||
[fileNameFromRunningSavePanelForSaveOperation:].
|
||||
|
||||
2004-05-04 Enrico Sersale <enrico@imago.ro>
|
||||
|
||||
* Source/NSWindow.m ([NSWindow -sendEvent:]): Doesn't makeKeyAndOrderFront
|
||||
|
|
45
Headers/Cocoa/Cocoa.h
Normal file
45
Headers/Cocoa/Cocoa.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Cocoa.h
|
||||
|
||||
Cocoa compatible declarations. Not to be used in normal GNUstep code.
|
||||
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
Author: Fred Kiefer <fredkiefer@gmx.de>
|
||||
Date: 2004
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_COCOA
|
||||
#define _GNUstep_H_COCOA
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535897932384626433
|
||||
#endif
|
||||
|
||||
#if (!defined(__cplusplus) && !defined(__USE_ISOC99))
|
||||
typedef BOOL bool;
|
||||
#define false NO
|
||||
#define true YES
|
||||
#endif
|
||||
|
||||
#endif /* _GNUstep_H_COCOA */
|
|
@ -308,8 +308,6 @@
|
|||
|
||||
if (delegate != nil && shouldCloseSelector != NULL)
|
||||
{
|
||||
// FIXME: This is the only way I know to call a callback with
|
||||
// irregular arguments
|
||||
void (*meth)(id, SEL, id, BOOL, void*);
|
||||
meth = (void (*)(id, SEL, id, BOOL, void*))[delegate methodForSelector:
|
||||
shouldCloseSelector];
|
||||
|
@ -342,8 +340,6 @@
|
|||
|
||||
if (delegate != nil && callback != NULL)
|
||||
{
|
||||
// FIXME: This is the only way I know to call a callback with
|
||||
// irregular argumetns
|
||||
void (*meth)(id, SEL, id, BOOL, void*);
|
||||
meth = (void (*)(id, SEL, id, BOOL, void*))[delegate methodForSelector:
|
||||
callback];
|
||||
|
@ -515,7 +511,6 @@
|
|||
}
|
||||
|
||||
[savePanel setTitle: title];
|
||||
|
||||
|
||||
if ([self fileName])
|
||||
directory = [[self fileName] stringByDeletingLastPathComponent];
|
||||
|
@ -523,6 +518,11 @@
|
|||
directory = [controller currentDirectory];
|
||||
[savePanel setDirectory: directory];
|
||||
|
||||
if (![self prepareSavePanel: savePanel])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([self runModalSavePanel: savePanel withAccessoryView: accessory])
|
||||
{
|
||||
return [savePanel filename];
|
||||
|
@ -662,7 +662,9 @@
|
|||
[self setFileType: fileType];
|
||||
[self updateChangeCount: NSChangeCleared];
|
||||
}
|
||||
|
||||
|
||||
// FIXME: Should set the file attributes
|
||||
|
||||
if (backupFilename && ![self keepBackupFile])
|
||||
{
|
||||
[fileManager removeFileAtPath: backupFilename handler: nil];
|
||||
|
@ -716,7 +718,10 @@
|
|||
didSaveSelector: (SEL)didSaveSelector
|
||||
contextInfo: (void *)contextInfo
|
||||
{
|
||||
// FIXME
|
||||
[self runModalSavePanelForSaveOperation: NSSaveOperation
|
||||
delegate: delegate
|
||||
didSaveSelector: didSaveSelector
|
||||
contextInfo: contextInfo];
|
||||
}
|
||||
|
||||
- (void)saveToFile: (NSString *)fileName
|
||||
|
@ -725,7 +730,23 @@
|
|||
didSaveSelector: (SEL)didSaveSelector
|
||||
contextInfo: (void *)contextInfo
|
||||
{
|
||||
// FIXME
|
||||
BOOL saved = NO;
|
||||
|
||||
if (fileName != nil)
|
||||
{
|
||||
saved = [self writeWithBackupToFile: fileName
|
||||
ofType: [self fileTypeFromLastRunSavePanel]
|
||||
saveOperation: saveOperation];
|
||||
}
|
||||
|
||||
if (delegate != nil && didSaveSelector != NULL)
|
||||
{
|
||||
void (*meth)(id, SEL, id, BOOL, void*);
|
||||
meth = (void (*)(id, SEL, id, BOOL, void*))[delegate methodForSelector:
|
||||
didSaveSelector];
|
||||
if (meth)
|
||||
meth(delegate, didSaveSelector, self, saved, contextInfo);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)prepareSavePanel: (NSSavePanel *)savePanel
|
||||
|
@ -738,7 +759,15 @@
|
|||
didSaveSelector: (SEL)didSaveSelector
|
||||
contextInfo: (void *)contextInfo
|
||||
{
|
||||
// FIXME
|
||||
NSString *fileName;
|
||||
|
||||
// FIXME: Setting of the delegate of the save panel is missing
|
||||
fileName = [self fileNameFromRunningSavePanelForSaveOperation: saveOperation];
|
||||
[self saveToFile: fileName
|
||||
saveOperation: saveOperation
|
||||
delegate: delegate
|
||||
didSaveSelector: didSaveSelector
|
||||
contextInfo: contextInfo];
|
||||
}
|
||||
|
||||
- (IBAction)revertDocumentToSaved: (id)sender
|
||||
|
|
|
@ -2682,12 +2682,163 @@ byExtendingSelection: (BOOL)flag
|
|||
|
||||
- (void) selectColumnIndexes: (NSIndexSet *)indexes byExtendingSelection: (BOOL)extend
|
||||
{
|
||||
// FIXME
|
||||
BOOL empty = ([indexes firstIndex] == NSNotFound);
|
||||
BOOL changed = NO;
|
||||
unsigned int col;
|
||||
|
||||
if (!_selectingColumns)
|
||||
{
|
||||
_selectingColumns = YES;
|
||||
if (_headerView)
|
||||
{
|
||||
[_headerView setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
/* Stop editing if any */
|
||||
if (_textObject != nil)
|
||||
{
|
||||
[self validateEditing];
|
||||
[self abortEditing];
|
||||
}
|
||||
|
||||
if (extend == NO)
|
||||
{
|
||||
/* If the current selection is the one we want, just ends editing
|
||||
* This is not just a speed up, it prevents us from sending
|
||||
* a NSTableViewSelectionDidChangeNotification.
|
||||
* This behaviour is required by the specifications */
|
||||
if ([_selectedColumns isEqualToIndexSet: indexes])
|
||||
{
|
||||
if (!empty)
|
||||
{
|
||||
_selectedColumn = [indexes lastIndex];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
[self _unselectAllColumns];
|
||||
changed = YES;
|
||||
}
|
||||
|
||||
if (!empty)
|
||||
{
|
||||
if ([indexes lastIndex] >= _numberOfColumns)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Column index out of table in selectColumn"];
|
||||
}
|
||||
|
||||
/* This check is not fully correct, as both sets may contain just
|
||||
the same entry, but works according to the old specification. */
|
||||
if (_allowsMultipleSelection == NO &&
|
||||
[_selectedColumns count] + [indexes count] > 1)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Can not set multiple selection in table view when multiple selection is disabled"];
|
||||
}
|
||||
|
||||
col = [indexes firstIndex];
|
||||
while (col != NSNotFound)
|
||||
{
|
||||
if (![_selectedColumns containsIndex: col])
|
||||
{
|
||||
[self setNeedsDisplayInRect: [self rectOfColumn: col]];
|
||||
if (_headerView)
|
||||
{
|
||||
[_headerView setNeedsDisplayInRect:
|
||||
[_headerView headerRectOfColumn: col]];
|
||||
}
|
||||
changed = YES;
|
||||
}
|
||||
col = [indexes indexGreaterThanIndex: col];
|
||||
}
|
||||
[_selectedColumns addIndexes: indexes];
|
||||
_selectedColumn = [indexes lastIndex];
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
[self _postSelectionDidChangeNotification];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) selectRowIndexes: (NSIndexSet *)indexes byExtendingSelection: (BOOL)extend
|
||||
{
|
||||
// FIXME
|
||||
BOOL empty = ([indexes firstIndex] == NSNotFound);
|
||||
BOOL changed = NO;
|
||||
unsigned int row;
|
||||
|
||||
if (_selectingColumns)
|
||||
{
|
||||
_selectingColumns = NO;
|
||||
if (_headerView)
|
||||
{
|
||||
[_headerView setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
/* Stop editing if any */
|
||||
if (_textObject != nil)
|
||||
{
|
||||
[self validateEditing];
|
||||
[self abortEditing];
|
||||
}
|
||||
|
||||
if (extend == NO)
|
||||
{
|
||||
/* If the current selection is the one we want, just ends editing
|
||||
* This is not just a speed up, it prevents us from sending
|
||||
* a NSTableViewSelectionDidChangeNotification.
|
||||
* This behaviour is required by the specifications */
|
||||
if ([_selectedRows isEqualToIndexSet: indexes])
|
||||
{
|
||||
if (!empty)
|
||||
{
|
||||
_selectedRow = [indexes lastIndex];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
[self _unselectAllRows];
|
||||
changed = YES;
|
||||
}
|
||||
|
||||
if (!empty)
|
||||
{
|
||||
if ([indexes lastIndex] >= _numberOfRows)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Row index out of table in selectRow"];
|
||||
}
|
||||
|
||||
/* This check is not fully correct, as both sets may contain just
|
||||
the same entry, but works according to the old specification. */
|
||||
if (_allowsMultipleSelection == NO &&
|
||||
[_selectedRows count] + [indexes count] > 1)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Can not set multiple selection in table view when multiple selection is disabled"];
|
||||
}
|
||||
|
||||
row = [indexes firstIndex];
|
||||
while (row != NSNotFound)
|
||||
{
|
||||
if (![_selectedRows containsIndex: row])
|
||||
{
|
||||
[self setNeedsDisplayInRect: [self rectOfRow: row]];
|
||||
}
|
||||
row = [indexes indexGreaterThanIndex: row];
|
||||
}
|
||||
[_selectedRows addIndexes: indexes];
|
||||
_selectedRow = [indexes lastIndex];
|
||||
changed = YES;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
[self _postSelectionDidChangeNotification];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSIndexSet *) selectedColumnIndexes;
|
||||
|
|
Loading…
Reference in a new issue