Added the ability for GSTheme subclasses to provide custom implementations of GSWindowDecorator.

This commit is contained in:
Kyle J Cardoza 2023-09-22 21:17:15 -04:00
parent 225eea02d5
commit 7f70818be2
5 changed files with 21 additions and 5 deletions

View file

@ -235,6 +235,8 @@
#import <AppKit/NSTabView.h>
#import <AppKit/NSPrintPanel.h>
#import <AppKit/NSPageLayout.h>
// For window decorator protocol
#import <GNUstepGUI/GSWindowDecorationView.h>
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE)
@class NSArray;
@ -1586,6 +1588,13 @@ APPKIT_EXPORT_CLASS
@end
@interface GSTheme (NSWindow)
/**
* This method returns the window decorator provided by
* the current theme.
*/
- (id<GSWindowDecorator>) windowDecorator;
/**
* This method returns the standard window button for the
* given mask for the current theme.

View file

@ -67,6 +67,7 @@ APPKIT_EXPORT_CLASS
BOOL hasMenu;
BOOL hasToolbar;
}
+ (id<GSWindowDecorator>) windowDecorator;
- (id) initWithFrame: (NSRect)frame window: (NSWindow *)w;

View file

@ -109,7 +109,6 @@
if (hasCloseButton)
{
NSRect closeButtonFrame = [[GSTheme theme] closeButtonFrameForBounds: [self bounds]];
[closeButton setFrame: closeButtonFrame];
}
else

View file

@ -33,6 +33,7 @@
#import "GNUstepGUI/GSTheme.h"
#import "GNUstepGUI/GSWindowDecorationView.h"
#import "GSThemePrivate.h"
#import "GNUstepGUI/GSDisplayServer.h"
@implementation GSTheme (NSWindow)
- (NSButton *) standardWindowButton: (NSWindowButton)button
@ -86,4 +87,13 @@
{
// default implementation does nothing...
}
- (id<GSWindowDecorator>) windowDecorator
{
if ([GSCurrentServer() handlesWindowDecorations])
return [GSBackendWindowDecorationView self];
else
return [GSStandardWindowDecorationView self];
}
@end

View file

@ -64,10 +64,7 @@ static inline NSRect RectWithSizeScaledByFactor(NSRect aRect, CGFloat factor)
+ (id<GSWindowDecorator>) windowDecorator
{
if ([GSCurrentServer() handlesWindowDecorations])
return [GSBackendWindowDecorationView self];
else
return [GSStandardWindowDecorationView self];
return [[GSTheme theme] windowDecorator];
}