Initial implementation of NSBrowser and NSBrowserCell.

Numerous bug fixes.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2596 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Scott Christley 1997-10-31 01:24:08 +00:00
parent 88a15677eb
commit 8b0975e122
18 changed files with 1553 additions and 143 deletions

View file

@ -1,3 +1,36 @@
Thu Oct 30 15:51:43 1997 Scott Christley <scottc@net-community.com>
* GNUmakefile: Add Tools directory.
* Headers/gnustep/gui/NSBrowser.h: Initial implementation.
* Headers/gnustep/gui/NSBrowserCell.h: Initial implementation.
* Source/NSBrowser.m: Initial implementation.
* Source/NSBrowserCell.m: Initial implementation.
* Documentation/news.tmpl.texi: Update.
* Documentation/status.tmpl.texi: Update.
* Source/NSCell.m (-initImageCell:, -initTextCell:): init super.
* Source/NSClipView.m (-init): Set background to gray as we may not
have a window yet.
* Source/NSMatrix.m: Fix column and row range checks.
* Source/NSTextFieldCell.m (-copyWithZone:): Set draws
background flag for new cell.
* Source/NSView.m: Reset subview needs display variables
when view is removed from superview.
* Source/GNUmakefile: Add NSPasteboard.m.
* Testing/GNUmakefile: Use test.make
* Testing/GNUmakefile.postamble: Remove install code.
* Testing/GNUmakefile.preamble: Add directory and library.
* Tools/GNUmakefile: Make system root the default install dir.
* Tools/GNUmakefile.postamble: Install after instead of before.
* Tools/GNUmakefile.preamble: Add directory and library.
Wed Oct 29 12:22:22 1997 Ovidiu Predescu <ovidiu@net-community.com>
Bug fixes for NSForm and NSFormCell from Benhur Stein

View file

@ -13,6 +13,13 @@ The currently released version of the library is @samp{@value{GNUSTEP-GUI-VERSIO
@itemize @bullet
@item
NSBrowser and NSBrowserCell have been implemented. There is one odd
display artifact; lists which are smaller than the browser column area
have the list justified to the bottom of the column versus the top of
the column. This is actually an issue with NSMatrix and will be
remedied when flip views are implemented.
@item
Two important optimizations that speed up the displaying of views and flushing
of windows have been implemented. Only the views that need display and those

View file

@ -61,9 +61,13 @@ Many of the methods have code, but whether the class
is usable depends upon how much implementation has been done in the
backend.
@item NSBrowser:: [2]
@item NSBrowser:: [9]
There is an odd display artifact; lists which are smaller than the
browser column area have the list justified to the bottom of the column
versus the top of the column. This is actually an issue with NSMatrix
and will be remedied when flip views are implemented.
@item NSBrowserCell:: [2]
@item NSBrowserCell:: [9]
@item NSButton:: [9]
Repeat intervals have been implemented.

View file

@ -32,7 +32,7 @@ include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
#
# The list of subproject directories
#
SUBPROJECTS = Source Images Testing
SUBPROJECTS = Source Images Tools Testing
-include GNUmakefile.preamble

View file

@ -3,7 +3,7 @@
Control to display and select from hierarchal lists
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
@ -41,6 +41,33 @@
@interface NSBrowser : NSControl <NSCoding>
{
// Attributes
Class _browserCellClass;
id _browserCellPrototype;
id _browserMatrixClass;
NSString *_pathSeparator;
BOOL _isLoaded;
BOOL _allowsBranchSelection;
BOOL _allowsEmptySelection;
BOOL _allowsMultipleSelection;
BOOL _reusesColumns;
int _maxVisibleColumns;
float _minColumnWidth;
BOOL _separatesColumns;
BOOL _takesTitleFromPreviousColumn;
BOOL _isTitled;
BOOL _hasHorizontalScroller;
NSScroller *_horizontalScroller;
BOOL _acceptsArrowKeys;
BOOL _sendsActionOnArrowKeys;
id _browserDelegate;
BOOL _passiveDelegate;
SEL _doubleAction;
NSMutableArray *_browserColumns;
id _titleCell;
NSSize _columnSize;
int _lastColumnLoaded;
int _firstVisibleColumn;
int _lastVisibleColumn;
}
//
@ -208,7 +235,10 @@
- (int)browser:(NSBrowser *)sender
numberOfRowsInColumn:(int)column;
- (BOOL)browser:(NSBrowser *)sender
selectCell:(NSString *)title
selectCellWithString:(NSString *)title
inColumn:(int)column;
- (BOOL)browser:(NSBrowser *)sender
selectRow:(int)row
inColumn:(int)column;
- (NSString *)browser:(NSBrowser *)sender
titleOfColumn:(int)column;

View file

@ -32,10 +32,20 @@
#include <AppKit/NSCell.h>
@class NSImage;
@class NSTextFieldCell;
@interface NSBrowserCell : NSCell <NSCoding>
{
// Attributes
NSImage *_alternateImage;
NSCell *_branchImage;
NSCell *_highlightBranchImage;
NSTextFieldCell *_browserText;
BOOL _isLeaf;
BOOL _isLoaded;
// reserved for the backend
void *_be_bfc_reserved;
}
//

View file

@ -76,6 +76,7 @@ NSMenuItem.m \
NSOpenPanel.m \
NSPageLayout.m \
NSPanel.m \
NSPasteboard.m \
NSPrinter.m \
NSPrintInfo.m \
NSPrintOperation.m \
@ -102,7 +103,6 @@ TrackingRectangle.m \
PSMatrix.m \
tiff.m \
externs.m
# NSPasteboard.m
libgnustep-gui_HEADER_FILES_DIR = ../Headers
libgnustep-gui_HEADER_FILES_INSTALL_DIR = /gnustep/gui

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@
Cell class for the NSBrowser
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
@ -28,7 +28,42 @@
#include <gnustep/gui/config.h>
#include <AppKit/NSBrowserCell.h>
#include <AppKit/NSTextFieldCell.h>
#include <AppKit/NSImage.h>
// Class variables
static NSImage *branch_image;
static NSImage *highlight_image;
// Private methods
@interface NSBrowserCell (Private)
- (void)setBranchImageCell:aCell;
- (void)setHighlightBranchImageCell:aCell;
- (void)setTextFieldCell:aCell;
@end
@implementation NSBrowserCell (Private)
- (void)setBranchImageCell:aCell
{
_branchImage = aCell;
}
- (void)setHighlightBranchImageCell:aCell
{
_highlightBranchImage = aCell;
}
- (void)setTextFieldCell:aCell
{
_browserText = aCell;
}
@end
//
// NSBrowserCell implementation
//
@implementation NSBrowserCell
//
@ -40,6 +75,10 @@
{
// Initial version
[self setVersion:1];
// The default images
branch_image = [NSImage imageNamed: @"common_ArrowRight"];
highlight_image = [NSImage imageNamed: @"common_ArrowRightH"];
}
}
@ -48,59 +87,177 @@
//
+ (NSImage *)branchImage
{
return nil;
return branch_image;
}
+ (NSImage *)highlightedBranchImage
{
return nil;
return highlight_image;
}
//
// Instance methods
//
- init
{
return [self initTextCell: @"aTitle"];
}
- initTextCell:(NSString *)aString
{
[super initTextCell: aString];
// Our image cells
_branchImage = [[NSCell alloc] initImageCell: [NSBrowserCell branchImage]];
_highlightBranchImage = [[NSCell alloc] initImageCell:
[NSBrowserCell highlightedBranchImage]];
// Our text cell
_browserText = [[NSTextFieldCell alloc] initTextCell: aString];
[_browserText setEditable: NO];
[_browserText setBordered: NO];
[_browserText setDrawsBackground: YES];
_alternateImage = nil;
_isLeaf = NO;
_isLoaded = NO;
return self;
}
- (void)dealloc
{
[_branchImage release];
[_highlightBranchImage release];
[_alternateImage release];
[_browserText release];
[super dealloc];
}
- (id)copyWithZone:(NSZone*)zone
{
NSBrowserCell* c = [super copyWithZone:zone];
// Copy the image cells
[c setBranchImageCell: [_branchImage copy]];
[c setHighlightBranchImageCell: [_branchImage copy]];
[c setAlternateImage: _alternateImage];
// Copy the text cell
[c setTextFieldCell: [_browserText copy]];
[c setLeaf: _isLeaf];
[c setLoaded: NO];
return c;
}
//
// Accessing Graphic Attributes
//
- (NSImage *)alternateImage
{
return nil;
return _alternateImage;
}
- (void)setAlternateImage:(NSImage *)anImage
{}
{
[anImage retain];
[_alternateImage release];
_alternateImage = anImage;
// Set the image in our highlight cell
if (_alternateImage)
[_highlightBranchImage setImage: _alternateImage];
else
[_highlightBranchImage setImage: [NSBrowserCell highlightedBranchImage]];
}
//
// Placing in the Browser Hierarchy
//
- (BOOL)isLeaf
{
return NO;
return _isLeaf;
}
- (void)setLeaf:(BOOL)flag
{}
{
_isLeaf = flag;
}
//
// Determining Loaded Status
//
- (BOOL)isLoaded
{
return NO;
return _isLoaded;
}
- (void)setLoaded:(BOOL)flag
{}
{
_isLoaded = flag;
}
//
// Setting State
//
- (void)reset
{}
{
cell_highlighted = NO;
cell_state = NO;
}
- (void)set
{}
{
cell_highlighted = YES;
cell_state = YES;
}
//
// Setting the NSCell's Value
//
- (double)doubleValue
{
return [_browserText doubleValue];
}
- (float)floatValue;
{
return [_browserText floatValue];
}
- (int)intValue
{
return [_browserText intValue];
}
- (NSString *)stringValue
{
return [_browserText stringValue];
}
- (void)setDoubleValue:(double)aDouble
{
[_browserText setDoubleValue: aDouble];
}
- (void)setFloatValue:(float)aFloat
{
[_browserText setFloatValue: aFloat];
}
- (void)setIntValue:(int)anInt
{
[_browserText setIntValue: anInt];
}
- (void)setStringValue:(NSString *)aString
{
[_browserText setStringValue: aString];
}
//
// NSCoding protocol
@ -108,12 +265,24 @@
- (void)encodeWithCoder:aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject: _browserText];
[aCoder encodeObject: _branchImage];
[aCoder encodeObject: _highlightBranchImage];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
}
- initWithCoder:aDecoder
{
[super initWithCoder:aDecoder];
_browserText = [aDecoder decodeObject];
_branchImage = [aDecoder decodeObject];
_highlightBranchImage = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
return self;
}

View file

@ -98,6 +98,8 @@
- (id)initImageCell:(NSImage *)anImage
{
[super init];
[self _init];
// Not an image class --then forget it
@ -113,6 +115,8 @@
- (id)initTextCell:(NSString *)aString
{
[super init];
[self _init];
cell_font = [[NSFont userFontOfSize:12] retain];

View file

@ -59,7 +59,7 @@
{
[super init];
[self setAutoresizesSubviews:YES];
[self setBackgroundColor:[[self window] backgroundColor]];
[self setBackgroundColor:[NSColor lightGrayColor]];
return self;
}

View file

@ -132,7 +132,7 @@ static void growMatrix (tMatrix m, int numRows, int numCols)
/* Grow the existing rows to numCols */
for (i = 0; i < numRows; i++) {
m->matrix[i] = realloc (m->matrix[i], numCols * sizeof (BOOL));
for (j = m->allocatedCols; j < numCols; j++)
for (j = m->allocatedCols - 1; j < numCols; j++)
m->matrix[i][j] = NO;
}
m->allocatedCols = numCols;
@ -422,9 +422,9 @@ static int mouseDownFlags = 0;
int i;
/* Grow the matrix if necessary */
if (column > numCols)
if (column >= numCols)
[self renewRows:(numRows == 0 ? 1 : numRows) columns:column];
else if (numRows == 0) {
if (numRows == 0) {
numRows = 1;
[cells addObject:[NSMutableArray array]];
}
@ -443,9 +443,9 @@ static int mouseDownFlags = 0;
int i;
/* Grow the matrix if necessary */
if (column > numCols)
if (column >= numCols)
[self renewRows:(numRows == 0 ? 1 : numRows) columns:column];
else if (numRows == 0) {
if (numRows == 0) {
numRows = 1;
[cells addObject:[NSMutableArray array]];
}
@ -465,9 +465,9 @@ static int mouseDownFlags = 0;
int i;
/* Grow the matrix if necessary */
if (row > numRows)
if (row >= numRows)
[self renewRows:row columns:(numCols == 0 ? 1 : numCols)];
else if (numCols == 0)
if (numCols == 0)
numCols = 1;
[cells insertObject:[NSMutableArray arrayWithCapacity:numCols] atIndex:row];
@ -485,9 +485,9 @@ static int mouseDownFlags = 0;
- (void)insertRow:(int)row withCells:(NSArray*)cellArray
{
/* Grow the matrix if necessary */
if (row > numRows)
if (row >= numRows)
[self renewRows:row columns:(numCols == 0 ? 1 : numCols)];
else if (numCols == 0)
if (numCols == 0)
numCols = 1;
[cells insertObject:[cellArray subarrayWithRange:NSMakeRange(0, numCols)]

View file

@ -99,6 +99,7 @@
[c setBackgroundColor: background_color];
[c setTextColor: text_color];
[c setDrawsBackground: draw_background];
return c;
}

View file

@ -883,18 +883,30 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
- (void)_removeSubviewFromViewsThatNeedDisplay:(NSView*)view
{
// If no subviews need to be displayed then
// then view must not be among them
if (!_subviewsThatNeedDisplay)
return;
/* Remove view from the list of subviews that need display */
if (_subviewsThatNeedDisplay == view)
_subviewsThatNeedDisplay = view->_nextSiblingSubviewThatNeedsDisplay;
{
_subviewsThatNeedDisplay = view->_nextSiblingSubviewThatNeedsDisplay;
[view _recursivelyResetNeedsDisplayInAllViews];
}
else {
NSView* currentView;
for (currentView = _subviewsThatNeedDisplay;
currentView->_nextSiblingSubviewThatNeedsDisplay;
currentView && currentView->_nextSiblingSubviewThatNeedsDisplay;
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay)
if (currentView->_nextSiblingSubviewThatNeedsDisplay == view)
currentView->_nextSiblingSubviewThatNeedsDisplay
{
currentView->_nextSiblingSubviewThatNeedsDisplay
= view->_nextSiblingSubviewThatNeedsDisplay;
[view _recursivelyResetNeedsDisplayInAllViews];
break;
}
}
}
@ -934,6 +946,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
currentView = nextView;
}
_subviewsThatNeedDisplay = NULL;
_nextSiblingSubviewThatNeedsDisplay = NULL;
}
- (void)_displayNeededViews

View file

@ -1,13 +1,40 @@
#
# Testing level makefile for GNUstep GUI Library
#
# Copyright (C) 1997 Free Software Foundation, Inc.
#
# Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
#
# 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.
#
# If you are interested in a warranty or support for this source code,
# contact Scott Christley at scottc@net-community.com
#
# 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.
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
# The application to be compiled
TOOL_NAME = testpb
TEST_TOOL_NAME = testpb
# The source files to be compiled
testpb_OBJC_FILES = testpb.m
-include GNUmakefile.preamble
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/tool.make
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/test.make
-include GNUmakefile.postamble

View file

@ -15,8 +15,7 @@
# after-all::
# Things to do before installing
before-install::
$(INSTALL) -m 05755 gpbs $(GNUSTEP_SYSTEM_ROOT)/Tools
# before-install::
# Things to do after installing
# after-install::

View file

@ -27,10 +27,10 @@ ADDITIONAL_INCLUDE_DIRS += -I../Headers -I$(GNUSTEP_SYSTEM_ROOT)/Headers
# ADDITIONAL_LDFLAGS +=
# Additional library directories the linker should search
ADDITIONAL_LIB_DIRS +=
ADDITIONAL_LIB_DIRS += -L../Source/$(GNUSTEP_OBJ_DIR)
# Additional libraries when linking tools
ADDITIONAL_TOOL_LIBS += -lgnustep-gui
ADDITIONAL_TOOL_LIBS += -lgnustep-gui -ltiff
# Additional libraries when linking applications
ADDITIONAL_GUI_LIBS +=

View file

@ -1,3 +1,32 @@
#
# Tools level makefile for GNUstep GUI Library
#
# Copyright (C) 1997 Free Software Foundation, Inc.
#
# Author: Scott Christley <scottc@net-community.com>
#
# 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.
#
# If you are interested in a warranty or support for this source code,
# contact Scott Christley at scottc@net-community.com
#
# 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.
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
# The application to be compiled