Merge pull request #240 from ethanc8/ethanc8-2

Implement various trivial methods required by GitUp
This commit is contained in:
Gregory Casamento 2024-02-10 16:10:21 -05:00 committed by GitHub
commit 580150a8c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 289 additions and 26 deletions

5
.gitignore vendored
View file

@ -61,3 +61,8 @@ DerivedData/
**/xcshareddata/WorkspaceSettings.xcsettings
# End of https://www.gitignore.io/api/xcode
compile_commands.json
**/.cache
**/.vscode

View file

@ -28,6 +28,7 @@
#ifndef _GNUstep_H_NSAlert
#define _GNUstep_H_NSAlert
#import <AppKit/NSWindow.h>
#import <AppKit/AppKitDefines.h>
#import <Foundation/NSObject.h>
@ -49,12 +50,6 @@ enum _NSAlertStyle {
};
typedef NSUInteger NSAlertStyle;
enum {
NSAlertFirstButtonReturn = 1000,
NSAlertSecondButtonReturn = 1001,
NSAlertThirdButtonReturn = 1002
};
APPKIT_EXPORT_CLASS
@interface NSAlert : NSObject
{
@ -106,6 +101,11 @@ APPKIT_EXPORT_CLASS
- (BOOL) showsHelp;
- (id) window;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_9, GS_API_LATEST)
- (void) beginSheetModalForWindow:(NSWindow *)sheetWindow
completionHandler:(GSNSWindowDidEndSheetCallbackBlock)handler;
#endif
@end

View file

@ -81,5 +81,23 @@ APPKIT_EXPORT NSAppearanceName const NSAppearanceNameLightContent;
#endif /* GS_API_MACOSX */
@protocol NSAppearanceCustomization
#if OS_API_VERSION(MAC_OS_X_VERSION_10_0, GS_API_LATEST)
@required
#if GS_HAS_DECLARED_PROPERTIES
/** Set the appearance of the reciever. Default is nil. */
@property(retain) NSAppearance* appearance;
/** Get the appearance of the reciever. If self.appearance is nil, then go up the
view hierarchy to find an appearance. If still nil, go up to NSApp. If still nil,
go up to [NSAppearance currentAppearance]. */
@property(readonly, retain) NSAppearance* effectiveAppearance;
#else
- (NSAppearance*) appearance;
- (void) setAppearance: (NSAppearance*) appearance;
- (NSAppearance*) effectiveAppearance;
#endif
#endif
@end
#endif /* _NSAppearance_h_GNUSTEP_GUI_INCLUDE */

View file

@ -41,12 +41,14 @@
#import <AppKit/NSResponder.h>
#import <AppKit/NSUserInterfaceValidation.h>
#import <AppKit/NSWindow.h>
#if defined(__cplusplus)
extern "C" {
#endif
@class NSArray;
@class NSAppearance;
@class NSDate;
@class NSError;
@class NSException;
@ -228,6 +230,7 @@ APPKIT_EXPORT_CLASS
NSWindow *_hidden_key;
NSWindow *_hidden_main;
GSInfoPanel *_infoPanel;
NSAppearance *_appearance;
NSApplicationPresentationOptions _presentationOptions;
/* This autorelease pool should only be created and used by -run, with
@ -780,16 +783,6 @@ NSShowSystemInfoPanel(NSDictionary *options);
*/
APPKIT_EXPORT NSApplication *NSApp;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
enum
{
NSModalResponseStop = -1000,
NSModalResponseAbort = -1001,
NSModalResponseContinue = -1002
};
typedef NSInteger NSModalResponse;
#endif
#if defined(__cplusplus)
}
#endif

View file

@ -171,7 +171,9 @@ enum {
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
enum {
NSBackgroundStyleLight = 0,
NSBackgroundStyleNormal = 0,
NSBackgroundStyleDark = 1,
NSBackgroundStyleEmphasized = 1,
NSBackgroundStyleRaised = 2,
NSBackgroundStyleLowered = 3
};

View file

@ -91,6 +91,11 @@ enum _NSEventType {
NSApplicationDefined,
NSPeriodic,
NSCursorUpdate,
// NSEventTypeCursorUpdate = 17,
// NSEventTypeRotate = 18,
// NSEventTypeBeginGesture = 19,
// NSEventTypeEndGesture = 20,
// (not defined) = 21,
NSScrollWheel = 22,
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
NSTabletPoint,
@ -98,7 +103,46 @@ enum _NSEventType {
#endif
NSOtherMouseDown = 25,
NSOtherMouseUp,
NSOtherMouseDragged
NSOtherMouseDragged,
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
NSEventTypeLeftMouseDown = 1,
NSEventTypeLeftMouseUp = 2,
NSEventTypeRightMouseDown = 3,
NSEventTypeRightMouseUp = 4,
NSEventTypeMouseMoved = 5,
NSEventTypeLeftMouseDragged = 6,
NSEventTypeRightMouseDragged = 7,
NSEventTypeMouseEntered = 8,
NSEventTypeMouseExited = 9,
NSEventTypeKeyDown = 10,
NSEventTypeKeyUp = 11,
NSEventTypeFlagsChanged = 12,
NSEventTypeAppKitDefined = 13,
NSEventTypeSystemDefined = 14,
NSEventTypeApplicationDefined = 15,
NSEventTypePeriodic = 16,
NSEventTypeCursorUpdate = 17,
NSEventTypeRotate = 18,
NSEventTypeBeginGesture = 19,
NSEventTypeEndGesture = 20,
// (not defined) = 21,
NSEventTypeScrollWheel = 22,
NSEventTypeTabletPoint = 23,
NSEventTypeTabletProximity = 24,
NSEventTypeOtherMouseDown = 25,
NSEventTypeOtherMouseUp = 26,
NSEventTypeOtherMouseDragged = 27,
// (not defined) = 28,
NSEventTypeGesture = 29,
NSEventTypeMagnify = 30,
NSEventTypeSwipe = 31,
NSEventTypeSmartMagnify = 32,
NSEventTypeQuickLook = 33,
NSEventTypePressure = 34,
// (not defined) = 35~37
NSEventTypeDirectTouch = 37,
NSEventTypeChangeMode = 38,
#endif
};
typedef NSUInteger NSEventType;
@ -183,7 +227,17 @@ enum {
NSCommandKeyMask = 16 << 16,
NSNumericPadKeyMask = 32 << 16,
NSHelpKeyMask = 64 << 16,
NSFunctionKeyMask = 128 << 16
NSFunctionKeyMask = 128 << 16,
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
NSEventModifierFlagCapsLock = NSAlphaShiftKeyMask,
NSEventModifierFlagShift = NSShiftKeyMask,
NSEventModifierFlagControl = NSControlKeyMask,
NSEventModifierFlagOption = NSAlternateKeyMask,
NSEventModifierFlagCommand = NSCommandKeyMask,
NSEventModifierFlagNumericPad = NSNumericPadKeyMask,
NSEventModifierFlagFunction = NSFunctionKeyMask,
NSEventModifierFlagDeviceIndependentFlagsMask = NSDeviceIndependentModifierFlagsMask,
#endif
};
typedef NSUInteger NSEventModifierFlags;

View file

@ -436,9 +436,14 @@ APPKIT_EXPORT_CLASS
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
// Provided for source compatibility with GNUstep-specific code.
// This method is just an alternate name for popUpMenuPositioningItem:atLocation:inView:
- (void) popUpMenuPositionItem: (NSMenuItem *)item
atLocation: (NSPoint) point
inView: (NSView *) view;
- (void) popUpMenuPositioningItem: (NSMenuItem *)item
atLocation: (NSPoint) point
inView: (NSView *) view;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)

View file

@ -33,6 +33,7 @@
#import <AppKit/AppKitDefines.h>
#import <AppKit/NSView.h>
#import <AppKit/NSScroller.h>
enum
{
@ -76,6 +77,8 @@ APPKIT_EXPORT_CLASS
BOOL _autohidesScrollers;
NSScrollElasticity _horizScrollElasticity;
NSScrollElasticity _vertScrollElasticity;
NSScrollerStyle _scrollerStyle;
NSScrollerKnobStyle _scrollerKnobStyle;
}
/* Calculating layout */
@ -188,6 +191,19 @@ APPKIT_EXPORT_CLASS
/* Arranging components */
- (void)tile;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
/** The scroller style. By default, NSScrollerStyleDefault. */
- (NSScrollerStyle)scrollerStyle;
/** Sets the scroller style. In the default theme, this must be NSScrollerStyleDefault. */
- (void)setScrollerStyle:(NSScrollerStyle)style;
/** The scroller knob style. By default, NSScrollerStyleDefault. */
- (NSScrollerKnobStyle)scrollerKnobStyle;
/** Sets the scroller knob style. In the default theme, this must be NSScrollerKnobStyleDefault. */
- (void)setScrollerKnobStyle:(NSScrollerKnobStyle)style;
/** Shows the scrollers if they're overlay scrollers. */
- (void)flashScrollers;
#endif
@end
#endif /* _GNUstep_H_NSScrollView */

View file

@ -104,10 +104,33 @@ APPKIT_EXPORT_CLASS
unsigned control_tint: 3;
unsigned control_size: 2;
} _scFlags;
NSScrollerStyle _scrollerStyle;
NSScrollerKnobStyle _knobStyle;
}
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
+ (NSScrollerStyle)preferredScrollerStyle;
/** The scroller style. By default, NSScrollerStyleDefault.
If your theme implements other scroller styles, you must override this method.
You may use the ivar _scrollerStyle for this. */
- (NSScrollerStyle)scrollerStyle;
/** Sets the scroller style. In the default theme, this must be NSScrollerStyleDefault.
If your theme implements other scroller styles, you must override this method.
You may use the ivar _scrollerStyle for this. */
- (void)setScrollerStyle:(NSScrollerStyle)style;
/** The scroller knob style. By default, NSScrollerStyleDefault.
If your theme implements other scroller styles, you must override this method.
You may use the ivar _knobStyle for this. */
- (NSScrollerKnobStyle)knobStyle;
/** Sets the scroller knob style. In the default theme, this must be NSScrollerKnobStyleDefault.
If your theme implements other scroller knob styles, you must override this method.
You may use the ivar _scrollerKnobStyle for this. */
- (void)setKnobStyle:(NSScrollerKnobStyle)style;
#endif
#if GS_API_VERSION(013000,GS_API_LATEST)
/** Shows the scroller if it's an overlay scroller.
If your theme supports overlay scrollers, you must override this method. */
- (void)flashScroller;
#endif
//

View file

@ -109,7 +109,13 @@ APPKIT_EXPORT_CLASS
@end
#endif
@protocol NSSplitViewDelegate <NSObject>
#if GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#else
@end
@interface NSObject (NSSplitViewDelegate)
#endif
- (void) splitView: (NSSplitView *)sender
resizeSubviewsWithOldSize: (NSSize)oldSize;

View file

@ -34,6 +34,7 @@
#define _GNUstep_H_NSView
#import <AppKit/AppKitDefines.h>
#import <AppKit/NSAppearance.h>
#import <AppKit/NSGraphicsContext.h>
#import <AppKit/NSResponder.h>
#import <AppKit/NSUserInterfaceLayout.h>
@ -129,7 +130,7 @@ extern const CGFloat NSViewNoInstrinsicMetric;
extern const CGFloat NSViewNoIntrinsicMetric;
APPKIT_EXPORT_CLASS
@interface NSView : NSResponder
@interface NSView : NSResponder <NSAppearanceCustomization>
{
NSRect _frame;
NSRect _bounds;
@ -195,6 +196,7 @@ PACKAGE_SCOPE
NSFocusRingType _focusRingType;
NSRect _autoresizingFrameError;
NSShadow *_shadow;
NSAppearance* _appearance;
}
/*

View file

@ -90,10 +90,18 @@ enum {
};
#if OS_API_VERSION(MAC_OS_X_VERSION_10_9, GS_API_LATEST)
enum {
NSModalResponseOK = 1,
NSModalResponseCancel = 0
};
typedef NSInteger NSModalResponse;
enum {
NSModalResponseOK = 1,
NSModalResponseCancel = 0,
NSModalResponseStop = -1000,
NSModalResponseAbort = -1001,
NSModalResponseContinue = -1002,
NSAlertFirstButtonReturn = 1000,
NSAlertSecondButtonReturn = 1001,
NSAlertThirdButtonReturn = 1002,
};
DEFINE_BLOCK_TYPE(GSNSWindowDidEndSheetCallbackBlock, void, NSModalResponse returnCode);
#endif
enum {
@ -862,6 +870,9 @@ PACKAGE_SCOPE
#else
- (NSWindow *) sheetParent;
#endif
- (void)beginSheet:(NSWindow *)sheet
completionHandler:(GSNSWindowDidEndSheetCallbackBlock)handler;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)

View file

@ -2049,6 +2049,15 @@ void NSBeginInformationalAlertSheet(NSString *title,
DESTROY(_window);
}
- (void) beginSheetModalForWindow:(NSWindow *)sheet
completionHandler:(GSNSWindowDidEndSheetCallbackBlock)handler
{
[self _setupPanel];
[sheet beginSheet: _window
completionHandler: handler];
DESTROY(_window);
}
- (void) _alertDidEnd: (NSWindow *)sheet
returnCode: (NSInteger)returnCode
contextInfo: (void *)contextInfo

View file

@ -62,6 +62,7 @@
#import "AppKit/AppKitExceptions.h"
#import "AppKit/NSAlert.h"
#import "AppKit/NSAppearance.h"
#import "AppKit/NSApplication.h"
#import "AppKit/NSCell.h"
#import "AppKit/NSCursor.h"
@ -3834,6 +3835,26 @@ struct _DelegateWrapper
return self;
}
- (NSAppearance*) appearance {
return _appearance;
}
- (void) setAppearance: (NSAppearance*) appearance {
ASSIGNCOPY(_appearance, appearance);
}
- (NSAppearance*) effectiveAppearance {
if (_appearance)
{
return _appearance;
}
else
{
return [NSAppearance currentAppearance];
}
}
@end /* NSApplication */

View file

@ -1445,9 +1445,9 @@ static BOOL menuBarVisible = YES;
[menu _rightMouseDisplay: event];
}
- (void) popUpMenuPositionItem: (NSMenuItem *)item
atLocation: (NSPoint) point
inView: (NSView *) view
- (void) popUpMenuPositioningItem: (NSMenuItem *)item
atLocation: (NSPoint) point
inView: (NSView *) view
{
NSRect cellFrame = [view convertRect: [view bounds] toView: nil];
NSWindow *w = [view window];
@ -1465,6 +1465,15 @@ static BOOL menuBarVisible = YES;
selectedItem: selectedItem];
}
- (void) popUpMenuPositionItem: (NSMenuItem *)item
atLocation: (NSPoint) point
inView: (NSView *) view
{
[self popUpMenuPositioningItem: item
atLocation: point
inView: view];
}
/*
* NSObject Protocol
*/

View file

@ -1831,6 +1831,28 @@ GSOppositeEdge(NSRectEdge edge)
}
}
- (NSScrollerStyle)scrollerStyle {
return _scrollerStyle;
}
- (void)setScrollerStyle:(NSScrollerStyle)style {
[[self horizontalScroller] setScrollerStyle:style];
[[self verticalScroller] setScrollerStyle:style];
_scrollerStyle = style;
}
- (NSScrollerKnobStyle)scrollerKnobStyle {
return _scrollerKnobStyle;
}
- (void)setScrollerKnobStyle:(NSScrollerKnobStyle)style {
[[self horizontalScroller] setKnobStyle:style];
[[self verticalScroller] setKnobStyle:style];
_scrollerKnobStyle = style;
}
- (void)flashScrollers {
[[self horizontalScroller] flashScroller];
[[self verticalScroller] flashScroller];
}
@end
@implementation NSScrollView (GSPrivate)

View file

@ -139,6 +139,24 @@ static float buttonsOffset = 1.0; // buttonsWidth = sw - 2*buttonsOffset
return NSScrollerStyleLegacy;
}
- (NSScrollerStyle)scrollerStyle {
// FIXME: we should support other scroller styles.
return NSScrollerStyleLegacy;
}
- (void)setScrollerStyle:(NSScrollerStyle)style {
if(style == NSScrollerStyleOverlay) NSWarnLog(@"GNUstep does not support overlay scrollbars.");
}
- (NSScrollerKnobStyle)knobStyle {
// FIXME: We should set this as an ivar so themes can use this.
return NSScrollerKnobStyleDefault;
}
- (void)setKnobStyle:(NSScrollerKnobStyle)style {
NSWarnLog(@"GNUstep does not support custom scroller knob styles.");
}
- (void)flashScroller {
}
- (BOOL) isFlipped
{
return YES;

View file

@ -72,6 +72,7 @@
#import "AppKit/NSView.h"
#import "AppKit/NSWindow.h"
#import "AppKit/NSWorkspace.h"
#import "AppKit/NSAppearance.h"
#import "AppKit/PSOperators.h"
#import "GNUstepGUI/GSDisplayServer.h"
#import "GNUstepGUI/GSTrackingRect.h"
@ -5256,6 +5257,30 @@ static NSView* findByTag(NSView *view, NSInteger aTag, NSUInteger *level)
return 0;
}
/* Implement NSAppearanceCustomization */
- (NSAppearance*) appearance {
return _appearance;
}
- (void) setAppearance: (NSAppearance*) appearance {
ASSIGNCOPY(_appearance, appearance);
}
- (NSAppearance*) effectiveAppearance {
if (_appearance)
{
return _appearance;
}
else if ([self superview])
{
return [[self superview] effectiveAppearance];
}
else
{
return [NSAppearance currentAppearance];
}
}
@end
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)

View file

@ -5952,6 +5952,30 @@ current key view.<br />
return nil;
}
- (void)beginSheet:(NSWindow *)sheet
completionHandler:(GSNSWindowDidEndSheetCallbackBlock)handler {
// FIXME
NSInteger ret;
[sheet setParentWindow: self];
self->_attachedSheet = sheet;
[[NSNotificationCenter defaultCenter]
postNotificationName: NSWindowWillBeginSheetNotification
object: self];
ret = [NSApp runModalForWindow: sheet
relativeToWindow: self];
CALL_BLOCK(handler, ret);
[sheet close];
self->_attachedSheet = nil;
[sheet setParentWindow: nil];
[[NSNotificationCenter defaultCenter]
postNotificationName: NSWindowDidEndSheetNotification
object: self];
}
- (CGFloat) backingScaleFactor
{
return 1.0;