Merge pull request #74 from gnustep/NSGridView_NSStackView_branch

NSGridView branch
This commit is contained in:
Gregory Casamento 2021-03-29 10:12:05 -04:00 committed by GitHub
commit 72d9db4e4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 1563 additions and 6 deletions

View file

@ -173,6 +173,7 @@
#import <AppKit/NSGlyphGenerator.h>
#import <AppKit/NSGradient.h>
#import <AppKit/NSGraphicsContext.h>
#import <AppKit/NSGridView.h>
#import <AppKit/NSGroupTouchBarItem.h>
#import <AppKit/NSHelpManager.h>
#import <AppKit/NSInputManager.h>

213
Headers/AppKit/NSGridView.h Normal file
View file

@ -0,0 +1,213 @@
/* Definition of class NSGridView
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 08-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSGridView_h_GNUSTEP_GUI_INCLUDE
#define _NSGridView_h_GNUSTEP_GUI_INCLUDE
#import <AppKit/NSView.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
enum {
NSGridCellPlacementInherited = 0,
NSGridCellPlacementNone,
NSGridCellPlacementLeading,
NSGridCellPlacementTop = NSGridCellPlacementLeading,
NSGridCellPlacementTrailing,
NSGridCellPlacementBottom = NSGridCellPlacementTrailing,
NSGridCellPlacementCenter,
NSGridCellPlacementFill
};
typedef NSInteger NSGridCellPlacement;
enum {
NSGridRowAlignmentInherited = 0,
NSGridRowAlignmentNone,
NSGridRowAlignmentFirstBaseline,
NSGridRowAlignmentLastBaseline
};
typedef NSInteger NSGridRowAlignment;
APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
@class NSGridColumn, NSGridRow, NSGridCell, NSArray, NSMutableArray;
@interface NSGridView : NSView
{
NSGridRowAlignment _rowAlignment;
NSMutableArray *_columns;
NSMutableArray *_rows;
NSMutableArray *_cells;
CGFloat _columnSpacing;
CGFloat _rowSpacing;
NSGridCellPlacement _xPlacement;
NSGridCellPlacement _yPlacement;
}
+ (instancetype) gridViewWithNumberOfColumns: (NSInteger)columnCount rows: (NSInteger)rowCount;
+ (instancetype) gridViewWithViews: (NSArray *)rows; // an NSArray containing an NSArray of NSViews
- (NSInteger) numberOfRows;
- (NSInteger) numberOfColumns;
- (NSGridRow *) rowAtIndex: (NSInteger)index;
- (NSInteger) indexOfRow: (NSGridRow *)row;
- (NSGridColumn *) columnAtIndex: (NSInteger)index;
- (NSInteger) indexOfColumn: (NSGridColumn *)column;
- (NSGridCell *) cellAtColumnIndex: (NSInteger)columnIndex rowIndex: (NSInteger)rowIndex;
- (NSGridCell *) cellForView: (NSView*)view;
- (NSGridRow *) addRowWithViews: (NSArray *)views;
- (NSGridRow *) insertRowAtIndex: (NSInteger)index withViews: (NSArray *)views;
- (void) moveRowAtIndex: (NSInteger)fromIndex toIndex: (NSInteger)toIndex;
- (void) removeRowAtIndex: (NSInteger)index;
- (NSGridColumn *) addColumnWithViews: (NSArray*)views;
- (NSGridColumn *) insertColumnAtIndex: (NSInteger)index withViews: (NSArray *)views;
- (void) moveColumnAtIndex: (NSInteger)fromIndex toIndex: (NSInteger)toIndex;
- (void) removeColumnAtIndex: (NSInteger)index;
- (NSGridCellPlacement) xPlacement;
- (void) setXPlacement: (NSGridCellPlacement)x;
- (NSGridCellPlacement) yPlacement;
- (void) setYPlacement: (NSGridCellPlacement)y;
- (NSGridRowAlignment) rowAlignment;
- (void) setRowAlignment: (NSGridRowAlignment)a;
- (CGFloat) rowSpacing;
- (void) setRowSpacing: (CGFloat)f;
- (CGFloat) columnSpacing;
- (void) setColumnSpacing: (CGFloat)f;
- (void) mergeCellsInHorizontalRange: (NSRange)hRange verticalRange: (NSRange)vRange;
@end
/// Cell
@interface NSGridCell : NSObject <NSCoding>
{
NSView *_contentView;
NSGridRowAlignment _rowAlignment;
NSGridCellPlacement _xPlacement;
NSGridCellPlacement _yPlacement;
id _mergeHead;
NSGridRow *_owningRow;
NSGridColumn *_owningColumn;
NSArray *_customPlacementConstraints;
}
- (NSView *) contentView;
- (void) setContentView: (NSView *)v;
+ (NSView *) emptyContentView;
// Weak references to row/column
- (NSGridRow *) row;
- (NSGridColumn *) column;
// Placement
- (NSGridCellPlacement) xPlacement;
- (void) setXPlacement: (NSGridCellPlacement)x;
- (NSGridCellPlacement) yPlacement;
- (void) setYPlacement: (NSGridCellPlacement)y;
- (NSGridRowAlignment) rowAlignment;
- (void) setRowAlignment: (NSGridRowAlignment)a;
// Constraints
- (NSArray *) customPlacementConstraints;
- (void) setCustomPlacementConstraints: (NSArray *)constraints;
@end
/// Column
@interface NSGridColumn : NSObject <NSCoding>
{
NSGridView *_gridView;
NSGridCellPlacement _xPlacement;
CGFloat _width;
CGFloat _leadingPadding;
CGFloat _trailingPadding;
BOOL _isHidden;
}
- (NSGridView *) gridView;
- (void) setGridView: (NSGridView *)gv;
- (NSInteger) numberOfCells;
- (NSGridCell *) cellAtIndex: (NSInteger)index;
- (NSGridCellPlacement) xPlacement;
- (void) setXPlacement: (NSGridCellPlacement)x;
- (CGFloat) width;
- (void) setWidth: (CGFloat)f;
- (CGFloat) leadingPadding;
- (void) setLeadingPadding: (CGFloat)f;
- (CGFloat) trailingPadding;
- (void) setTrailingPadding: (CGFloat)f;
- (BOOL) isHidden;
- (void) mergeCellsInRange: (NSRange)range;
@end
/// Row
@interface NSGridRow : NSObject <NSCoding>
{
NSGridView *_gridView;
NSGridCellPlacement _yPlacement;
CGFloat _height;
CGFloat _bottomPadding;
CGFloat _topPadding;
BOOL _isHidden;
}
- (NSGridView *) gridView;
- (void) setGridView: (NSGridView *)gv;
- (NSInteger) numberOfCells;
- (NSGridCell *)cellAtIndex: (NSInteger)index;
- (NSGridCellPlacement) yPlacement;
- (void) setYPlacement: (NSGridCellPlacement)y;
- (CGFloat) height;
- (void) setHeight: (CGFloat)f;
- (CGFloat) topPadding;
- (void) setTopPadding: (CGFloat)f;
- (CGFloat) bottomPadding;
- (void) setBottomPadding: (CGFloat)f;
- (BOOL) isHidden;
- (void) mergeCellsInRange: (NSRange)range;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSGridView_h_GNUSTEP_GUI_INCLUDE */

View file

@ -1,4 +1,4 @@
MISSING HEADERS ( * = difficult, - = quick, + = placeholder )
MISSING HEADERS ( * = difficult, - = quick, + = placeholder, x = won't do )
---
> NSATSTypesetter.h +
> NSCollectionViewCompositionalLayout.h *
@ -12,11 +12,10 @@ MISSING HEADERS ( * = difficult, - = quick, + = placeholder )
> NSDraggingSession.h -
> NSFilePromiseProvider.h -
> NSFilePromiseReceiver.h -
> NSGlyphInfo.h
> NSGridView.h *
> NSGlyphInfo.h -
> NSItemProvider.h +
> NSMenuToolbarItem.h -
> NSOpenGLLayer.h
> NSOpenGLLayer.h *
> NSStackView.h *
> NSTableCellView.h *
> NSTableRowView.h *

View file

@ -115,6 +115,7 @@ NSFontManager.m \
NSFontPanel.m \
NSForm.m \
NSFormCell.m \
NSGridView.m \
NSGroupTouchBarItem.m \
NSMagnificationGestureRecognizer.m \
NSPanGestureRecognizer.m \
@ -445,6 +446,7 @@ NSGradient.h \
NSGroupTouchBarItem.h \
NSGlyphGenerator.h \
NSGraphicsContext.h \
NSGridView.h \
NSHelpPanel.h \
NSHelpManager.h \
NSImage.h \

View file

@ -41,6 +41,7 @@
#import "AppKit/NSCell.h"
#import "AppKit/NSClipView.h"
#import "AppKit/NSFormCell.h"
#import "AppKit/NSGridView.h"
#import "AppKit/NSImage.h"
#import "AppKit/NSMatrix.h"
#import "AppKit/NSMenu.h"
@ -201,7 +202,10 @@ static NSArray *XmlBoolDefaultYes = nil;
@"NSMutableArray", @"allowedToolbarItems",
@"NSMutableArray", @"defaultToolbarItems",
@"NSMutableArray", @"rowTemplates",
@"NSMutableArray", @"constraints",
@"NSMutableArray", @"constraints",
@"NSMutableArray", @"rows",
@"NSMutableArray", @"columns",
@"NSMutableArray", @"gridCells",
@"NSSegmentItem", @"segment",
@"NSCell", @"customCell",
@"NSCustomObject5", @"customObject",
@ -227,7 +231,8 @@ static NSArray *XmlBoolDefaultYes = nil;
RETAIN(ClassNamePrefixes);
XmlReferenceAttributes = [NSArray arrayWithObjects: @"headerView", @"initialItem",
@"selectedItem", @"firstItem", @"secondItem", nil];
@"selectedItem", @"firstItem", @"secondItem",
@"row", @"column", nil];
RETAIN(XmlReferenceAttributes);
XmlConnectionRecordTags = [NSArray arrayWithObjects: @"action", @"outlet", @"binding", nil];
@ -287,6 +292,24 @@ static NSArray *XmlBoolDefaultYes = nil;
@"string", @"NS.relative",
@"canPropagateSelectedChildViewControllerTitle",
@"NSTabViewControllerCanPropagateSelectedChildViewControllerTitle",
@"rowAlignment", @"NSGrid_alignment",
@"rowSpacing", @"NSGrid_rowSpacing",
@"columnSpacing", @"NSGrid_columnSpacing",
@"hidden", @"NSGrid_hidden",
@"leadingPadding", @"NSGrid_leadingPadding",
@"bottomPadding", @"NSGrid_bottomPadding",
@"trailingPadding", @"NSGrid_trailingPadding",
@"topPadding", @"NSGrid_topPadding",
@"width", @"NSGrid_width",
@"height", @"NSGrid_height",
@"xPlacement", @"NSGrid_xPlacement",
@"yPlacement", @"NSGrid_yPlacement",
@"rows", @"NSGrid_rows",
@"columns", @"NSGrid_columns",
@"gridCells", @"NSGrid_cells",
@"contentView", @"NSGrid_content",
@"row", @"NSGrid_owningRow",
@"column", @"NSGrid_owningColumn",
nil];
RETAIN(XmlKeyMapTable);
@ -335,6 +358,9 @@ static NSArray *XmlBoolDefaultYes = nil;
// decoding the integer flag masks...
XmlKeyToDecoderSelectorMap =
[NSDictionary dictionaryWithObjectsAndKeys:
@"decodeXPlacementForElement:", @"NSGrid_xPlacement",
@"decodeYPlacementForElement:", @"NSGrid_yPlacement",
@"decodeRowAlignmentForElement:", @"NSGrid_alignment",
@"decodeIntercellSpacingHeightForElement:", @"NSIntercellSpacingHeight",
@"decodeIntercellSpacingWidthForElement:", @"NSIntercellSpacingWidth",
@"decodeColumnAutoresizingStyleForElement:", @"NSColumnAutoresizingStyle",
@ -2917,6 +2943,79 @@ didStartElement: (NSString*)elementName
return num;
}
- (id) _decodePlacementForObject: (id)obj
{
NSGridRowAlignment alignment = NSGridCellPlacementNone;
if ([obj isEqualToString: @"inherited"])
{
alignment = NSGridCellPlacementInherited;
}
else if ([obj isEqualToString: @"leading"])
{
alignment = NSGridCellPlacementLeading;
}
else if ([obj isEqualToString: @"top"])
{
alignment = NSGridCellPlacementTop;
}
else if ([obj isEqualToString: @"trailing"])
{
alignment = NSGridCellPlacementTrailing;
}
else if ([obj isEqualToString: @"bottom"])
{
alignment = NSGridCellPlacementBottom;
}
else if ([obj isEqualToString: @"center"])
{
alignment = NSGridCellPlacementCenter;
}
else if ([obj isEqualToString: @"fill"])
{
alignment = NSGridCellPlacementFill;
}
else // if not specified then assume none...
{
alignment = NSGridCellPlacementNone;
}
return [NSNumber numberWithInteger: alignment];
}
- (id) decodeXPlacementForElement: (GSXibElement *)element
{
id obj = [element attributeForKey: @"xPlacement"];
return [self _decodePlacementForObject: obj];
}
- (id) decodeYPlacementForElement: (GSXibElement *)element
{
id obj = [element attributeForKey: @"yPlacement"];
return [self _decodePlacementForObject: obj];
}
- (id) decodeRowAlignmentForElement: (GSXibElement *)element
{
id obj = [element attributeForKey: @"rowAlignment"];
NSGridRowAlignment alignment = NSGridRowAlignmentNone;
if ([obj isEqualToString: @"inherited"])
{
alignment = NSGridRowAlignmentInherited;
}
else if ([obj isEqualToString: @"firstBaseline"])
{
alignment = NSGridRowAlignmentFirstBaseline;
}
else if ([obj isEqualToString: @"lastBaseline"])
{
alignment = NSGridRowAlignmentLastBaseline;
}
else
{
alignment = NSGridRowAlignmentNone;
}
return [NSNumber numberWithInteger: alignment];
}
- (id) objectForXib: (GSXibElement*)element
{
id object = [super objectForXib: element];

1241
Source/NSGridView.m Normal file

File diff suppressed because it is too large Load diff

View file

@ -842,6 +842,8 @@ NSString *NSTextInputContextKeyboardSelectionDidChangeNotification =
NSPasteboardTypeTextFinderOptionKey const NSTextFinderCaseInsensitiveKey = @"NSTextFinderCaseInsensitiveKey";
NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingTypeKey = @"NSTextFinderMatchingTypeKey";
CGFloat const NSGridViewSizeForContent = 0.0;
extern void __objc_gui_force_linking (void);
void