Add ivars

This commit is contained in:
Gregory John Casamento 2020-08-23 04:12:38 -04:00
parent dbd46a5839
commit e0df225d90
2 changed files with 114 additions and 18 deletions

View file

@ -63,9 +63,6 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
NSMutableArray *_rows;
}
- (instancetype) initWithFrame: (NSRect)frameRect;
- (instancetype) initWithCoder: (NSCoder *)coder;
+ (instancetype) gridViewWithNumberOfColumns: (NSInteger)columnCount rows: (NSInteger)rowCount;
+ (instancetype) gridViewWithViews: (NSArray *)rows; // an NSArray containing an NSArray of NSViews
@ -107,6 +104,9 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
/// Cell
@interface NSGridCell : NSObject <NSCoding>
{
NSView *_contentView;
}
- (NSView *) contentView;
- (void) setContentView: (NSView *)v;
@ -132,7 +132,15 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
/// Column
@interface NSGridColumn : NSObject <NSCoding>
{
NSGridView *_gridView;
NSMutableArray *_col;
NSGridCellPlacement _xPlacement;
CGFloat _width;
CGFloat _leadingPadding;
CGFloat _trailingPadding;
BOOL _isHidden;
}
- (NSGridView *) gridView;
- (NSInteger) numberOfCells;
- (NSGridCell *) cellAtIndex:(NSInteger)index;
@ -153,7 +161,16 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
/// Row
@interface NSGridRow : NSObject <NSCoding>
{
NSGridView *_gridView;
NSMutableArray *_row;
NSGridCellPlacement _yPlacement;
CGFloat _height;
CGFloat _bottomPadding;
CGFloat _topPadding;
BOOL _isHidden;
}
- (NSGridView *) gridView;
- (NSInteger) numberOfCells;
- (NSGridCell *)cellAtIndex:(NSInteger)index;

View file

@ -22,8 +22,21 @@
Boston, MA 02110 USA.
*/
#import <Foundation/NSArray.h>
#import "AppKit/NSGridView.h"
#import "GSFastEnumeration.h"
@interface NSGridRow (Private)
- (void) _setRow: (NSMutableArray *)row;
- (NSMutableArray *) _row;
@end
@interface NSGridColumn (Private)
- (void) _setColumn: (NSMutableArray *)col;
- (NSMutableArray *) _column;
@end
@implementation NSGridView
- (instancetype) initWithFrame: (NSRect)frameRect
@ -36,6 +49,23 @@
return self;
}
- (instancetype) initWithViews: (NSArray *)rows
{
self = [self initWithFrame: NSZeroRect];
if (self != nil)
{
NSMutableArray *mutableRows = [rows mutableCopy];
FOR_IN(NSMutableArray*, array, mutableRows)
{
[_rows addObject: array];
}
END_FOR_IN(mutableRows);
}
return self;
}
+ (instancetype) gridViewWithNumberOfColumns: (NSInteger)columnCount rows: (NSInteger)rowCount
{
NSUInteger r = 0;
@ -59,7 +89,7 @@
+ (instancetype) gridViewWithViews: (NSArray *)rows
{
return nil; // ASSIGNCOPY(_rows, rows);
return [[self alloc] initWithViews: rows];
}
- (NSInteger) numberOfRows
@ -74,7 +104,9 @@
- (NSGridRow *) rowAtIndex: (NSInteger)index
{
return nil;
NSGridRow *r = [[NSGridRow alloc] init];
[r _setRow: [_rows objectAtIndex: index]];
return r;
}
- (NSInteger) indexOfRow: (NSGridRow *)row
@ -201,17 +233,17 @@
@end
/// Cell ///
@implementation NSGridCell
- (NSView *) contentView
{
return nil;
return _contentView;
}
- (void) setContentView: (NSView *)v
{
ASSIGN(_contentView, v);
}
+ (NSView *) emptyContentView
@ -358,60 +390,107 @@
/// Row ///
@implementation NSGridRow
- (void) _setRow: (NSMutableArray *)row
{
_row = row; // weak reference;
}
- (NSMutableArray *) _row
{
return _row;
}
- (BOOL) isEqual: (NSGridRow *)r
{
if (_row == [r _row])
{
return YES;
}
else
{
NSUInteger idx = 0;
FOR_IN(NSGridCell*, cell, _row)
{
NSGridCell *otherCell = [[r _row] objectAtIndex: idx];
if (![cell isEqual: otherCell])
{
return NO;
}
idx++;
}
END_FOR_IN(_row);
}
return YES;
}
- (void) setGridView: (NSGridView *)gridView
{
_gridView = gridView; // weak reference...
}
- (NSGridView *) gridView
{
return nil;
return _gridView;
}
- (NSInteger) numberOfCells
{
return 0;
return [_row count];
}
- (NSGridCell *) cellAtIndex:(NSInteger)index
{
return nil;
return [_row objectAtIndex: index];
}
- (NSGridCellPlacement) yPlacement
{
return 0;
return _yPlacement;
}
- (void) setYPlacement: (NSGridCellPlacement)x
- (void) setYPlacement: (NSGridCellPlacement)y
{
_yPlacement = y;
}
- (CGFloat) height
{
return 0.0;
return _height;
}
- (void) setHeight: (CGFloat)f
{
_height = f;
}
- (CGFloat) topPadding
{
return 0.0;
return _topPadding;
}
- (void) setTopPadding: (CGFloat)f
{
_topPadding = f;
}
- (CGFloat) bottomPadding
{
return 0.0;
return _bottomPadding;
}
- (void) setBottomPadding: (CGFloat)f
{
_bottomPadding = f;
}
- (BOOL) isHidden
{
return NO;
return _isHidden;
}
- (void) setHidden: (BOOL)flag
{
_isHidden = flag;
}
- (void) mergeCellsInRange: (NSRange)range