mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 09:22:07 +00:00
* Headers/Additions/GNUstepGUI/GSTheme.h: Add -tabViewContentRectForBounds:
method. * Source/GSThemeDrawing.m: * Source/NSTabView.m: Move the -contentRect implementation to GSTheme so we can delegate to GSDrawTiles, if used. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37234 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
617357136a
commit
d2c40ca934
4 changed files with 116 additions and 76 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2013-10-15 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
|
* Headers/Additions/GNUstepGUI/GSTheme.h: Add -tabViewContentRectForBounds:
|
||||||
|
method.
|
||||||
|
* Source/GSThemeDrawing.m:
|
||||||
|
* Source/NSTabView.m: Move the -contentRect implementation to GSTheme
|
||||||
|
so we can delegate to GSDrawTiles, if used.
|
||||||
|
|
||||||
2013-10-15 Eric Wasylishen <ewasylishen@gmail.com>
|
2013-10-15 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/NSTabViewItem.m (-drawLabel:inRect:): Center label vertically
|
* Source/NSTabViewItem.m (-drawLabel:inRect:): Center label vertically
|
||||||
|
|
|
@ -1147,6 +1147,10 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
||||||
- (NSRect) browserHeaderDrawingRectForCell: (NSTableHeaderCell*)cell
|
- (NSRect) browserHeaderDrawingRectForCell: (NSTableHeaderCell*)cell
|
||||||
withFrame: (NSRect)rect;
|
withFrame: (NSRect)rect;
|
||||||
|
|
||||||
|
- (NSRect) tabViewContentRectForBounds: (NSRect)aRect
|
||||||
|
tabViewType: (NSTabViewType)type
|
||||||
|
tabView: (NSTabView *)view;
|
||||||
|
|
||||||
- (void) drawTabViewRect: (NSRect)rect
|
- (void) drawTabViewRect: (NSRect)rect
|
||||||
inView: (NSView *)view
|
inView: (NSView *)view
|
||||||
withItems: (NSArray *)items
|
withItems: (NSArray *)items
|
||||||
|
|
|
@ -2011,6 +2011,104 @@ typedef enum {
|
||||||
return [img size].height;
|
return [img size].height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSRect) tabViewBackgroundRectForBounds: (NSRect)aRect
|
||||||
|
tabViewType: (NSTabViewType)type
|
||||||
|
{
|
||||||
|
const CGFloat tabHeight = [self tabHeightForType: type];
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case NSTopTabsBezelBorder:
|
||||||
|
aRect.size.height -= tabHeight;
|
||||||
|
aRect.origin.y += tabHeight;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSBottomTabsBezelBorder:
|
||||||
|
aRect.size.height -= tabHeight;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSLeftTabsBezelBorder:
|
||||||
|
aRect.size.width -= tabHeight;
|
||||||
|
aRect.origin.x += tabHeight;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSRightTabsBezelBorder:
|
||||||
|
aRect.size.width -= tabHeight;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSNoTabsBezelBorder:
|
||||||
|
case NSNoTabsLineBorder:
|
||||||
|
case NSNoTabsNoBorder:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return aRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (NSRect) tabViewContentRectForBounds: (NSRect)aRect
|
||||||
|
tabViewType: (NSTabViewType)type
|
||||||
|
tabView: (NSTabView *)view
|
||||||
|
{
|
||||||
|
NSRect cRect = [self tabViewBackgroundRectForBounds: aRect
|
||||||
|
tabViewType: type];
|
||||||
|
NSString *name = GSStringFromTabViewType(type);
|
||||||
|
GSDrawTiles *tiles = [self tilesNamed: name state: GSThemeNormalState];
|
||||||
|
|
||||||
|
if (tiles == nil)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case NSBottomTabsBezelBorder:
|
||||||
|
cRect.origin.x += 1;
|
||||||
|
cRect.origin.y += 1;
|
||||||
|
cRect.size.width -= 3;
|
||||||
|
cRect.size.height -= 2;
|
||||||
|
break;
|
||||||
|
case NSNoTabsBezelBorder:
|
||||||
|
cRect.origin.x += 1;
|
||||||
|
cRect.origin.y += 1;
|
||||||
|
cRect.size.width -= 3;
|
||||||
|
cRect.size.height -= 2;
|
||||||
|
break;
|
||||||
|
case NSNoTabsLineBorder:
|
||||||
|
cRect.origin.y += 1;
|
||||||
|
cRect.origin.x += 1;
|
||||||
|
cRect.size.width -= 2;
|
||||||
|
cRect.size.height -= 2;
|
||||||
|
break;
|
||||||
|
case NSTopTabsBezelBorder:
|
||||||
|
cRect.origin.x += 1;
|
||||||
|
cRect.origin.y += 1;
|
||||||
|
cRect.size.width -= 3;
|
||||||
|
cRect.size.height -= 2;
|
||||||
|
break;
|
||||||
|
case NSLeftTabsBezelBorder:
|
||||||
|
cRect.origin.x += 1;
|
||||||
|
cRect.origin.y += 1;
|
||||||
|
cRect.size.width -= 3;
|
||||||
|
cRect.size.height -= 2;
|
||||||
|
break;
|
||||||
|
case NSRightTabsBezelBorder:
|
||||||
|
cRect.origin.x += 1;
|
||||||
|
cRect.origin.y += 1;
|
||||||
|
cRect.size.width -= 3;
|
||||||
|
cRect.size.height -= 2;
|
||||||
|
break;
|
||||||
|
case NSNoTabsNoBorder:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cRect = [tiles contentRectForRect: cRect];
|
||||||
|
}
|
||||||
|
return cRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) drawTabViewBezelRect: (NSRect)aRect
|
- (void) drawTabViewBezelRect: (NSRect)aRect
|
||||||
tabViewType: (NSTabViewType)type
|
tabViewType: (NSTabViewType)type
|
||||||
inView: (NSView *)view
|
inView: (NSView *)view
|
||||||
|
@ -2069,42 +2167,14 @@ typedef enum {
|
||||||
const NSUInteger howMany = [items count];
|
const NSUInteger howMany = [items count];
|
||||||
int i;
|
int i;
|
||||||
int previousState = 0;
|
int previousState = 0;
|
||||||
|
const NSTabViewType type = [(NSTabView *)view tabViewType];
|
||||||
const NSRect bounds = [view bounds];
|
const NSRect bounds = [view bounds];
|
||||||
NSRect aRect = bounds;
|
NSRect aRect = [self tabViewBackgroundRectForBounds: bounds tabViewType: type];
|
||||||
|
|
||||||
const BOOL truncate = [(NSTabView *)view allowsTruncatedLabels];
|
const BOOL truncate = [(NSTabView *)view allowsTruncatedLabels];
|
||||||
const NSTabViewType type = [(NSTabView *)view tabViewType];
|
|
||||||
const CGFloat tabHeight = [self tabHeightForType: type];
|
const CGFloat tabHeight = [self tabHeightForType: type];
|
||||||
|
|
||||||
DPSgsave(ctxt);
|
DPSgsave(ctxt);
|
||||||
|
|
||||||
// Calculate the background rect
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case NSTopTabsBezelBorder:
|
|
||||||
aRect.size.height -= tabHeight;
|
|
||||||
aRect.origin.y += tabHeight;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSBottomTabsBezelBorder:
|
|
||||||
aRect.size.height -= tabHeight;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSLeftTabsBezelBorder:
|
|
||||||
aRect.size.width -= tabHeight;
|
|
||||||
aRect.origin.x += tabHeight;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightTabsBezelBorder:
|
|
||||||
aRect.size.width -= tabHeight;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSNoTabsBezelBorder:
|
|
||||||
case NSNoTabsLineBorder:
|
|
||||||
case NSNoTabsNoBorder:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self drawTabViewBezelRect: aRect
|
[self drawTabViewBezelRect: aRect
|
||||||
tabViewType: type
|
tabViewType: type
|
||||||
|
|
|
@ -405,52 +405,10 @@
|
||||||
|
|
||||||
- (NSRect) contentRect
|
- (NSRect) contentRect
|
||||||
{
|
{
|
||||||
NSRect cRect = _bounds;
|
NSRect result = [[GSTheme theme] tabViewContentRectForBounds: _bounds
|
||||||
|
tabViewType: [self tabViewType]
|
||||||
switch (_type)
|
tabView: self];
|
||||||
{
|
return result;
|
||||||
case NSBottomTabsBezelBorder:
|
|
||||||
cRect.origin.x += 1;
|
|
||||||
cRect.origin.y += 1;
|
|
||||||
cRect.size.width -= 3;
|
|
||||||
cRect.size.height -= 19;
|
|
||||||
break;
|
|
||||||
case NSNoTabsBezelBorder:
|
|
||||||
cRect.origin.x += 1;
|
|
||||||
cRect.origin.y += 1;
|
|
||||||
cRect.size.width -= 3;
|
|
||||||
cRect.size.height -= 3;
|
|
||||||
break;
|
|
||||||
case NSNoTabsLineBorder:
|
|
||||||
cRect.origin.y += 1;
|
|
||||||
cRect.origin.x += 1;
|
|
||||||
cRect.size.width -= 2;
|
|
||||||
cRect.size.height -= 2;
|
|
||||||
break;
|
|
||||||
case NSTopTabsBezelBorder:
|
|
||||||
cRect.origin.x += 1;
|
|
||||||
cRect.origin.y += 18;
|
|
||||||
cRect.size.width -= 3;
|
|
||||||
cRect.size.height -= 19;
|
|
||||||
break;
|
|
||||||
case NSLeftTabsBezelBorder:
|
|
||||||
cRect.origin.x += 21;
|
|
||||||
cRect.origin.y += 1;
|
|
||||||
cRect.size.width -= 21;
|
|
||||||
cRect.size.height -= 3;
|
|
||||||
break;
|
|
||||||
case NSRightTabsBezelBorder:
|
|
||||||
cRect.origin.x += 1;
|
|
||||||
cRect.origin.y += 1;
|
|
||||||
cRect.size.width -= 21;
|
|
||||||
cRect.size.height -= 3;
|
|
||||||
break;
|
|
||||||
case NSNoTabsNoBorder:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cRect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawing.
|
// Drawing.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue