mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Initial implementation of new GSTheme hooks and default implementations.
This commit is contained in:
parent
0b2f0a4e54
commit
81b59ad0a0
6 changed files with 80 additions and 10 deletions
|
@ -1501,6 +1501,36 @@ withRepeatedImage: (NSImage*)image
|
|||
*/
|
||||
- (void) updateMenu: (NSMenu *)menu forWindow: (NSWindow *)window;
|
||||
- (void) updateAllWindowsWithMenu: (NSMenu *) menu;
|
||||
|
||||
/**
|
||||
* Modifies the given NSRect for use by NSMenu to position and size
|
||||
* the displayed menu. The default implementation simply returns
|
||||
* the original NSRect unmodified.
|
||||
*/
|
||||
- (NSRect) modifyRect: (NSRect)aRect
|
||||
forMenu: (NSMenu *)aMenu
|
||||
isHorizontal: (BOOL) horizontal;
|
||||
|
||||
/**
|
||||
* Modifies the proposed default width for a menu title in the given NSMenuView.
|
||||
* The default implementation simply returns the proposed width unmodified.
|
||||
*/
|
||||
- (float) proposedTitleWidth: (float)proposedWidth
|
||||
forMenuView: (NSMenuView *)aMenuView;
|
||||
|
||||
/**
|
||||
* Modifies the proposed key equivalent string for the menu item. The default
|
||||
* implementation simply returns the proposed string unmodified.
|
||||
*/
|
||||
- (NSString *) keyForKeyEquivalent: (NSString *)aString;
|
||||
|
||||
/**
|
||||
* Modifies the proposed menu item title. The default implementation simply
|
||||
* returns the proposed string unmodified.
|
||||
*/
|
||||
- (NSString *) proposedTitle: (NSString *)title
|
||||
forMenuItem: (NSMenuItem *)menuItem;
|
||||
|
||||
@end
|
||||
|
||||
@interface GSTheme (OpenSavePanels)
|
||||
|
@ -1594,6 +1624,5 @@ APPKIT_EXPORT_CLASS
|
|||
- (NSImage *) highlightedBranchImage;
|
||||
@end
|
||||
|
||||
|
||||
#endif /* OS_API_VERSION */
|
||||
#endif /* _GNUstep_H_GSTheme */
|
||||
|
|
|
@ -175,5 +175,29 @@
|
|||
return YES; // override whether or not to show the icon in the menu.
|
||||
}
|
||||
|
||||
- (NSRect) modifyRect: (NSRect)aRect
|
||||
forMenu: (NSMenu *)aMenu
|
||||
isHorizontal: (BOOL) horizontal;
|
||||
{
|
||||
return aRect;
|
||||
}
|
||||
|
||||
- (float) proposedTitleWidth: (float)proposedWidth
|
||||
forMenuView: (NSMenuView *)aMenuView
|
||||
{
|
||||
return proposedWidth;
|
||||
}
|
||||
|
||||
- (NSString *) keyForKeyEquivalent: (NSString *)aString
|
||||
{
|
||||
return aString;
|
||||
}
|
||||
|
||||
- (NSString *) proposedTitle: (NSString *)title
|
||||
forMenuItem: (NSMenuItem *)menuItem
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -471,16 +471,22 @@ static BOOL menuBarVisible = YES;
|
|||
|
||||
- (void) _setGeometry
|
||||
{
|
||||
NSPoint origin;
|
||||
|
||||
if (_menu.horizontal == YES)
|
||||
{
|
||||
NSRect screenFrame = [[NSScreen mainScreen] frame];
|
||||
origin = NSMakePoint (0, screenFrame.size.height
|
||||
- [_aWindow frame].size.height);
|
||||
origin.y += screenFrame.origin.y;
|
||||
[_aWindow setFrameOrigin: origin];
|
||||
[_bWindow setFrameOrigin: origin];
|
||||
|
||||
NSRect proposedFrame = NSMakeRect(0,
|
||||
screenFrame.size.height -
|
||||
[_aWindow frame].size.height +
|
||||
screenFrame.origin.y,
|
||||
screenFrame.size.width,
|
||||
[_aWindow frame].size.height);
|
||||
proposedFrame = [[GSTheme theme] modifyRect: proposedFrame
|
||||
forMenu: self
|
||||
isHorizontal: YES];
|
||||
|
||||
[_aWindow setFrame: proposedFrame display: NO];
|
||||
[_bWindow setFrame: proposedFrame display: NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -510,7 +516,7 @@ static BOOL menuBarVisible = YES;
|
|||
|
||||
if ((_aWindow != nil) && ([_aWindow screen] != nil))
|
||||
{
|
||||
origin = NSMakePoint(0, [[_aWindow screen] visibleFrame].size.height
|
||||
NSPoint origin = NSMakePoint(0, [[_aWindow screen] visibleFrame].size.height
|
||||
- [_aWindow frame].size.height);
|
||||
|
||||
[_aWindow setFrameOrigin: origin];
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#import "AppKit/NSMenuItem.h"
|
||||
#import "AppKit/NSMenu.h"
|
||||
#import "GSBindingHelpers.h"
|
||||
#import "GNUstepGUI/GSTheme.h"
|
||||
|
||||
static BOOL usesUserKeyEquivalents = NO;
|
||||
static Class imageClass;
|
||||
|
@ -264,7 +265,12 @@ static Class imageClass;
|
|||
|
||||
- (NSString*) title
|
||||
{
|
||||
return _title;
|
||||
NSString *proposedTitle = _title;
|
||||
|
||||
proposedTitle = [[GSTheme theme] proposedTitle: proposedTitle
|
||||
forMenuItem: self];
|
||||
|
||||
return proposedTitle;
|
||||
}
|
||||
|
||||
- (BOOL) isSeparatorItem
|
||||
|
|
|
@ -290,6 +290,8 @@ static NSString *commandKeyString = @"#";
|
|||
(shift != NO) ? shiftKeyString : @"",
|
||||
(m & NSCommandKeyMask) ? commandKeyString : @"",
|
||||
key];
|
||||
|
||||
key = [[GSTheme theme] keyForKeyEquivalent: key];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -791,6 +791,9 @@ static float menuBarHeight = 0.0;
|
|||
NSMenuItemCell *aCell = [self menuItemCellForItemAtIndex: i];
|
||||
float titleWidth = [aCell titleWidth];
|
||||
|
||||
titleWidth = [[GSTheme theme] proposedTitleWidth: titleWidth
|
||||
forMenuView: self];
|
||||
|
||||
if ([aCell imageWidth])
|
||||
{
|
||||
titleWidth += [aCell imageWidth] + GSCellTextImageXDist;
|
||||
|
|
Loading…
Reference in a new issue