mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 05:30:41 +00:00
Implement non-separated columns.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14645 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c6fdfc994b
commit
7dde67abce
3 changed files with 102 additions and 29 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2002-10-04 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSBrowser.m: Implement non-separated columns.
|
||||||
|
(-setSeparatesColumns:): Remove borders if not separated.
|
||||||
|
(-setTitled:): Return without chaging if we are not separated.
|
||||||
|
(-frameOfColumn:): Compute properly with{out} separation.
|
||||||
|
(-tile): Idem.
|
||||||
|
(-initWithFrame:): Set maxVisibleColumns to 3.
|
||||||
|
(-drawRect:): Draw properly with{out} separation.
|
||||||
|
(Patch from Serg Stoyan <stoyan@hologr.com>).
|
||||||
|
|
||||||
2002-10-03 Adam Fedor <fedor@gnu.org>
|
2002-10-03 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Headers/gnustep/gui/NSWindow.h: New _lastView ivar.
|
* Headers/gnustep/gui/NSWindow.h: New _lastView ivar.
|
||||||
|
|
|
@ -333,8 +333,7 @@ NSNibDeclarations.h \
|
||||||
NSNibLoading.h \
|
NSNibLoading.h \
|
||||||
NSSpellProtocol.h \
|
NSSpellProtocol.h \
|
||||||
NSUserInterfaceValidation.h \
|
NSUserInterfaceValidation.h \
|
||||||
PSOperators.h \
|
PSOperators.h
|
||||||
nsimage-tiff.h
|
|
||||||
|
|
||||||
# Extra DLL exports file
|
# Extra DLL exports file
|
||||||
libgnustep-gui_DLL_DEF = libgnustep-gui.def
|
libgnustep-gui_DLL_DEF = libgnustep-gui.def
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include <AppKit/NSTableHeaderCell.h>
|
#include <AppKit/NSTableHeaderCell.h>
|
||||||
#include <AppKit/NSEvent.h>
|
#include <AppKit/NSEvent.h>
|
||||||
#include <AppKit/NSWindow.h>
|
#include <AppKit/NSWindow.h>
|
||||||
|
#include <AppKit/NSBezierPath.h>
|
||||||
|
|
||||||
DEFINE_RINT_IF_MISSING
|
DEFINE_RINT_IF_MISSING
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ DEFINE_RINT_IF_MISSING
|
||||||
static float scrollerWidth; // == [NSScroller scrollerWidth]
|
static float scrollerWidth; // == [NSScroller scrollerWidth]
|
||||||
static NSTextFieldCell *titleCell;
|
static NSTextFieldCell *titleCell;
|
||||||
|
|
||||||
#define NSBR_COLUMN_SEP 6
|
#define NSBR_COLUMN_SEP 4
|
||||||
#define NSBR_VOFFSET 2
|
#define NSBR_VOFFSET 2
|
||||||
|
|
||||||
#define NSBR_COLUMN_IS_VISIBLE(i) \
|
#define NSBR_COLUMN_IS_VISIBLE(i) \
|
||||||
|
@ -1096,11 +1097,27 @@ static NSTextFieldCell *titleCell;
|
||||||
/** Sets whether to separate columns with bezeled borders. */
|
/** Sets whether to separate columns with bezeled borders. */
|
||||||
- (void) setSeparatesColumns: (BOOL)flag
|
- (void) setSeparatesColumns: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (_separatesColumns != flag)
|
NSBrowserColumn *bc;
|
||||||
|
NSScrollView *sc;
|
||||||
|
NSBorderType bt;
|
||||||
|
int i, columnCount;
|
||||||
|
|
||||||
|
// if this flag already set or browser is titled -- do nothing
|
||||||
|
if (_separatesColumns == flag || _isTitled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
columnCount = [_browserColumns count];
|
||||||
|
bt = flag ? NSBezelBorder : NSNoBorder;
|
||||||
|
for (i = 0; i < columnCount; i++)
|
||||||
{
|
{
|
||||||
_separatesColumns = flag;
|
bc = [_browserColumns objectAtIndex: i];
|
||||||
[self tile];
|
sc = [bc columnScrollView];
|
||||||
|
[sc setBorderType:bt];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_separatesColumns = flag;
|
||||||
|
[self setNeedsDisplay:YES];
|
||||||
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns YES if the title of a column is set to the string value of
|
/** Returns YES if the title of a column is set to the string value of
|
||||||
|
@ -1162,12 +1179,12 @@ static NSTextFieldCell *titleCell;
|
||||||
/** Sets whether columns display titles. */
|
/** Sets whether columns display titles. */
|
||||||
- (void) setTitled: (BOOL)flag
|
- (void) setTitled: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (_isTitled != flag)
|
if (_isTitled == flag || !_separatesColumns)
|
||||||
{
|
return;
|
||||||
|
|
||||||
_isTitled = flag;
|
_isTitled = flag;
|
||||||
[self tile];
|
[self tile];
|
||||||
[self setNeedsDisplay: YES];
|
[self setNeedsDisplay: YES];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawTitleOfColumn: (int)column
|
- (void) drawTitleOfColumn: (int)column
|
||||||
|
@ -1480,17 +1497,31 @@ static NSTextFieldCell *titleCell;
|
||||||
{
|
{
|
||||||
r.origin.x += n * NSBR_COLUMN_SEP;
|
r.origin.x += n * NSBR_COLUMN_SEP;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (column == _firstVisibleColumn)
|
||||||
|
r.origin.x = (n * _columnSize.width) + 2;
|
||||||
|
else
|
||||||
|
r.origin.x = (n * _columnSize.width) + (n + 2);
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust for horizontal scroller
|
// Adjust for horizontal scroller
|
||||||
if (_hasHorizontalScroller)
|
if (_hasHorizontalScroller)
|
||||||
{
|
{
|
||||||
r.origin.y = scrollerWidth + (2 * bs.height) + NSBR_VOFFSET;
|
if (_separatesColumns)
|
||||||
|
r.origin.y = (scrollerWidth - 2) + (2 * bs.height) + NSBR_VOFFSET;
|
||||||
|
else
|
||||||
|
r.origin.y = scrollerWidth + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Padding : _columnSize.width is rounded in "tile" method
|
// Padding : _columnSize.width is rounded in "tile" method
|
||||||
if (column == _lastVisibleColumn)
|
if (column == _lastVisibleColumn)
|
||||||
{
|
{
|
||||||
|
if (_separatesColumns)
|
||||||
r.size.width = _frame.size.width - r.origin.x;
|
r.size.width = _frame.size.width - r.origin.x;
|
||||||
|
else
|
||||||
|
r.size.width = _frame.size.width
|
||||||
|
- (r.origin.x + (2 * bs.width) + ([self numberOfVisibleColumns] - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.size.width < 0)
|
if (r.size.width < 0)
|
||||||
|
@ -1526,6 +1557,7 @@ static NSTextFieldCell *titleCell;
|
||||||
{
|
{
|
||||||
NSSize bs = _sizeForBorderType (NSBezelBorder);
|
NSSize bs = _sizeForBorderType (NSBezelBorder);
|
||||||
int i, num, columnCount, delta;
|
int i, num, columnCount, delta;
|
||||||
|
float frameWidth;
|
||||||
|
|
||||||
_columnSize.height = _frame.size.height;
|
_columnSize.height = _frame.size.height;
|
||||||
|
|
||||||
|
@ -1539,11 +1571,19 @@ static NSTextFieldCell *titleCell;
|
||||||
if (_hasHorizontalScroller)
|
if (_hasHorizontalScroller)
|
||||||
{
|
{
|
||||||
_scrollerRect.origin.x = bs.width;
|
_scrollerRect.origin.x = bs.width;
|
||||||
_scrollerRect.origin.y = bs.height;
|
|
||||||
_scrollerRect.size.width = _frame.size.width - (2 * bs.width);
|
// if (_separatesColumns)
|
||||||
|
// _scrollerRect.origin.y = bs.height;
|
||||||
|
// else
|
||||||
|
_scrollerRect.origin.y = bs.height - 1;
|
||||||
|
|
||||||
|
_scrollerRect.size.width = (_frame.size.width - (2 * bs.width)) + 1;
|
||||||
_scrollerRect.size.height = scrollerWidth;
|
_scrollerRect.size.height = scrollerWidth;
|
||||||
|
|
||||||
_columnSize.height -= scrollerWidth + (2 * bs.height) + NSBR_VOFFSET;
|
if (_separatesColumns)
|
||||||
|
_columnSize.height -= (scrollerWidth - 2) + (2 * bs.height) + NSBR_VOFFSET;
|
||||||
|
else
|
||||||
|
_columnSize.height -= scrollerWidth + (2 * bs.height);
|
||||||
|
|
||||||
if (!NSEqualRects(_scrollerRect, [_horizontalScroller frame]))
|
if (!NSEqualRects(_scrollerRect, [_horizontalScroller frame]))
|
||||||
{
|
{
|
||||||
|
@ -1598,15 +1638,11 @@ static NSTextFieldCell *titleCell;
|
||||||
|
|
||||||
// Columns
|
// Columns
|
||||||
if (_separatesColumns)
|
if (_separatesColumns)
|
||||||
{
|
frameWidth = _frame.size.width - ((columnCount - 1) * NSBR_COLUMN_SEP);
|
||||||
_columnSize.width = (int)((_frame.size.width - ((columnCount - 1)
|
|
||||||
* NSBR_COLUMN_SEP))
|
|
||||||
/ (float)columnCount);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
frameWidth = _frame.size.width - (columnCount + (2 * bs.width));
|
||||||
_columnSize.width = (int)(_frame.size.width / (float)columnCount);
|
|
||||||
}
|
_columnSize.width = (int)(frameWidth / (float)columnCount);
|
||||||
|
|
||||||
if (_columnSize.height < 0)
|
if (_columnSize.height < 0)
|
||||||
_columnSize.height = 0;
|
_columnSize.height = 0;
|
||||||
|
@ -1926,6 +1962,7 @@ static NSTextFieldCell *titleCell;
|
||||||
_lastColumnLoaded = -1;
|
_lastColumnLoaded = -1;
|
||||||
_firstVisibleColumn = 0;
|
_firstVisibleColumn = 0;
|
||||||
_lastVisibleColumn = 0;
|
_lastVisibleColumn = 0;
|
||||||
|
_maxVisibleColumns = 3;
|
||||||
[self _createColumn];
|
[self _createColumn];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -2014,14 +2051,40 @@ static NSTextFieldCell *titleCell;
|
||||||
|
|
||||||
scrollerBorderRect.origin.x = 0;
|
scrollerBorderRect.origin.x = 0;
|
||||||
scrollerBorderRect.origin.y = 0;
|
scrollerBorderRect.origin.y = 0;
|
||||||
scrollerBorderRect.size.width += 2 * bs.width;
|
scrollerBorderRect.size.width += 2 * bs.width - 1;
|
||||||
scrollerBorderRect.size.height += 2 * bs.height;
|
scrollerBorderRect.size.height += (2 * bs.height) - 1;
|
||||||
|
|
||||||
if ((NSIntersectsRect (scrollerBorderRect, rect) == YES) && _window)
|
if ((NSIntersectsRect (scrollerBorderRect, rect) == YES) && _window)
|
||||||
{
|
{
|
||||||
NSDrawGrayBezel (scrollerBorderRect, rect);
|
NSDrawGrayBezel (scrollerBorderRect, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_separatesColumns)
|
||||||
|
{
|
||||||
|
NSPoint p1,p2;
|
||||||
|
NSRect browserRect;
|
||||||
|
int i, visibleColumns;
|
||||||
|
|
||||||
|
// Columns borders
|
||||||
|
browserRect = NSMakeRect(0, 0, rect.size.width, rect.size.height);
|
||||||
|
NSDrawGrayBezel (browserRect, rect);
|
||||||
|
|
||||||
|
[[NSColor blackColor] set];
|
||||||
|
visibleColumns = [self numberOfVisibleColumns];
|
||||||
|
for (i = 1; i < visibleColumns; i++)
|
||||||
|
{
|
||||||
|
p1 = NSMakePoint((_columnSize.width * i) + 2 + (i-1),
|
||||||
|
_columnSize.height + scrollerWidth + 2);
|
||||||
|
p2 = NSMakePoint((_columnSize.width * i) + 2 + (i-1), scrollerWidth + 3);
|
||||||
|
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Horizontal scroller border
|
||||||
|
p1 = NSMakePoint(2, scrollerWidth + 2);
|
||||||
|
p2 = NSMakePoint(rect.size.width - 2, scrollerWidth + 2);
|
||||||
|
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Informs the receivers's subviews that the receiver's bounds
|
/* Informs the receivers's subviews that the receiver's bounds
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue