mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
NSTab is now drawing, and looks nice! Fun.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4438 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
37753e0ffa
commit
42131af015
11 changed files with 159 additions and 1 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
1999-06-20 Michael Hanni <mhanni@sprintmail.com>
|
||||
|
||||
* Images/common_TabSelectedLeft.tiff
|
||||
common_TabSelectedRight.tiff
|
||||
common_TabSelectedToUnSelectedJunction.tiff
|
||||
common_TabUnSelectToSelectedJunction.tiff
|
||||
common_TabUnSelectedJunction.tiff
|
||||
common_TabUnSelectedLeft.tiff
|
||||
common_TabUnSelectedRight.tiff: all tiffs needed to draw NSTabs.
|
||||
* Source/NSTabView.m: lots of work on drawing. Should draw correct
|
||||
in almost all cases. However, without event code I can't test it
|
||||
yet.
|
||||
* Source/NSTabViewItem.m: drawing. still need to move the drawing
|
||||
of the top line out of this and move it into NSTabView's drawRect.
|
||||
|
||||
1999-06-20 Michael Hanni <mhanni@sprintmail.com>
|
||||
|
||||
* Source/NSPopUpButton.m: hooked up all the actions and targets
|
||||
|
|
|
@ -57,6 +57,13 @@ common_SwitchOn.tiff \
|
|||
common_SwitchOff.tiff \
|
||||
common_SliderHoriz.tiff \
|
||||
common_SliderVert.tiff \
|
||||
common_TabSelectedLeft.tiff \
|
||||
common_TabSelectedRight.tiff \
|
||||
common_TabSelectedToUnSelectedJunction.tiff \
|
||||
common_TabUnSelectToSelectedJunction.tiff \
|
||||
common_TabUnSelectedJunction.tiff \
|
||||
common_TabUnSelectedLeft.tiff \
|
||||
common_TabUnSelectedRight.tiff \
|
||||
common_Tile.tiff \
|
||||
common_Nibble.tiff \
|
||||
common_Dimple.tiff \
|
||||
|
|
BIN
Images/common_TabSelectedLeft.tiff
Normal file
BIN
Images/common_TabSelectedLeft.tiff
Normal file
Binary file not shown.
BIN
Images/common_TabSelectedRight.tiff
Normal file
BIN
Images/common_TabSelectedRight.tiff
Normal file
Binary file not shown.
BIN
Images/common_TabSelectedToUnSelectedJunction.tiff
Normal file
BIN
Images/common_TabSelectedToUnSelectedJunction.tiff
Normal file
Binary file not shown.
BIN
Images/common_TabUnSelectToSelectedJunction.tiff
Normal file
BIN
Images/common_TabUnSelectToSelectedJunction.tiff
Normal file
Binary file not shown.
BIN
Images/common_TabUnSelectedJunction.tiff
Normal file
BIN
Images/common_TabUnSelectedJunction.tiff
Normal file
Binary file not shown.
BIN
Images/common_TabUnSelectedLeft.tiff
Normal file
BIN
Images/common_TabUnSelectedLeft.tiff
Normal file
Binary file not shown.
BIN
Images/common_TabUnSelectedRight.tiff
Normal file
BIN
Images/common_TabUnSelectedRight.tiff
Normal file
Binary file not shown.
|
@ -2,6 +2,7 @@
|
|||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSTabView.h>
|
||||
#include <AppKit/NSTabViewItem.h>
|
||||
#include <AppKit/PSOperators.h>
|
||||
|
||||
@implementation NSTabView
|
||||
|
@ -169,6 +170,9 @@
|
|||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
float borderThickness;
|
||||
int howMany = [tab_items count];
|
||||
int i;
|
||||
NSRect previousRect;
|
||||
NSTabState previousState;
|
||||
|
||||
DPSgsave(ctxt);
|
||||
|
||||
|
@ -191,6 +195,92 @@
|
|||
break;
|
||||
}
|
||||
|
||||
for (i=0;i<howMany;i++) {
|
||||
// where da tab be at?
|
||||
NSSize s;
|
||||
NSRect r;
|
||||
NSPoint iP;
|
||||
NSTabViewItem *anItem = [tab_items objectAtIndex:i];
|
||||
NSTabState itemState;
|
||||
|
||||
if (i == 2) [anItem _setTabState:NSSelectedTab];
|
||||
|
||||
itemState = [anItem tabState];
|
||||
|
||||
s = [anItem sizeOfLabel:NO];
|
||||
NSLog(@"Label: %@ Size: %d\n", [anItem label], (int)s.width);
|
||||
|
||||
if (i == 0) {
|
||||
|
||||
iP.x = rect.origin.x;
|
||||
iP.y = rect.size.height;
|
||||
|
||||
if (itemState == NSSelectedTab)
|
||||
[[NSImage imageNamed:@"common_TabUnSelectedLeft.tiff"]
|
||||
compositeToPoint:iP operation: NSCompositeSourceOver];
|
||||
else if (itemState == NSBackgroundTab)
|
||||
[[NSImage imageNamed:@"common_TabUnSelectedLeft.tiff"]
|
||||
compositeToPoint:iP operation: NSCompositeSourceOver];
|
||||
else
|
||||
NSLog(@"Not finished yet. Luff ya.\n");
|
||||
|
||||
r.origin.x = rect.origin.x + 13;
|
||||
r.origin.y = rect.size.height;
|
||||
r.size.width = s.width;
|
||||
r.size.height = 20;
|
||||
|
||||
[anItem drawLabel:NO inRect:r];
|
||||
|
||||
previousRect = r;
|
||||
previousState = itemState;
|
||||
} else {
|
||||
iP.x = previousRect.origin.x + previousRect.size.width;
|
||||
iP.y = rect.size.height;
|
||||
|
||||
if (itemState == NSSelectedTab) {
|
||||
iP.y -= 1;
|
||||
[[NSImage imageNamed:@"common_TabUnSelectToSelectedJunction.tiff"]
|
||||
compositeToPoint:iP operation: NSCompositeSourceOver];
|
||||
}
|
||||
else if (itemState == NSBackgroundTab) {
|
||||
if (previousState == NSSelectedTab) {
|
||||
iP.y -= 1;
|
||||
[[NSImage imageNamed:@"common_TabSelectedToUnSelectedJunction.tiff"]
|
||||
compositeToPoint:iP operation: NSCompositeSourceOver];
|
||||
iP.y += 1;
|
||||
} else {
|
||||
[[NSImage imageNamed:@"common_TabUnSelectedJunction.tiff"]
|
||||
compositeToPoint:iP operation: NSCompositeSourceOver];
|
||||
}
|
||||
}
|
||||
else
|
||||
NSLog(@"Not finished yet. Luff ya.\n");
|
||||
|
||||
r.origin.x = iP.x + 13;
|
||||
r.origin.y = rect.size.height;
|
||||
r.size.width = s.width;
|
||||
r.size.height = 20;
|
||||
|
||||
[anItem drawLabel:NO inRect:r];
|
||||
|
||||
previousRect = r;
|
||||
previousState = itemState;
|
||||
}
|
||||
|
||||
if (i == howMany-1) {
|
||||
iP.x += s.width + 13;
|
||||
|
||||
if ([anItem tabState] == NSSelectedTab)
|
||||
[[NSImage imageNamed:@"common_TabSelectedRight.tiff"]
|
||||
compositeToPoint:iP operation: NSCompositeSourceOver];
|
||||
else if ([anItem tabState] == NSBackgroundTab)
|
||||
[[NSImage imageNamed:@"common_TabUnSelectedRight.tiff"]
|
||||
compositeToPoint:iP operation: NSCompositeSourceOver];
|
||||
else
|
||||
NSLog(@"Not finished yet. Luff ya.\n");
|
||||
}
|
||||
}
|
||||
|
||||
DPSgrestore(ctxt);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSTabViewItem.h>
|
||||
#include <AppKit/PSOperators.h>
|
||||
|
||||
@implementation NSTabViewItem
|
||||
- (id) initWithIdentifier:(id)identifier
|
||||
|
@ -7,6 +9,7 @@
|
|||
[super init];
|
||||
|
||||
ASSIGN(item_ident, identifier);
|
||||
item_state = NSBackgroundTab;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -83,6 +86,11 @@
|
|||
return item_state;
|
||||
}
|
||||
|
||||
- (void)_setTabState:(NSTabState)tabState
|
||||
{
|
||||
item_state = tabState;
|
||||
}
|
||||
|
||||
// Tab view, this is the "super" view.
|
||||
|
||||
- (void)_setTabView:(NSTabView *)tabView
|
||||
|
@ -111,7 +119,45 @@
|
|||
- (void)drawLabel:(BOOL)shouldTruncateLabel
|
||||
inRect:(NSRect)tabRect
|
||||
{
|
||||
// Implement in backend?
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
NSRect lRect;
|
||||
NSRect fRect;
|
||||
|
||||
DPSgsave(ctxt);
|
||||
|
||||
DPSsetlinewidth(ctxt, 1);
|
||||
DPSsetgray(ctxt, 1);
|
||||
|
||||
fRect = tabRect;
|
||||
|
||||
fRect.size.height -= 5;
|
||||
|
||||
if (item_state == NSSelectedTab) {
|
||||
fRect.origin.y -= 1;
|
||||
fRect.size.height += 1;
|
||||
[[NSColor lightGrayColor] set];
|
||||
NSRectFill(fRect);
|
||||
} else if (item_state == NSBackgroundTab) {
|
||||
[[NSColor lightGrayColor] set];
|
||||
NSRectFill(fRect);
|
||||
} else {
|
||||
NSRectFill(fRect);
|
||||
}
|
||||
|
||||
DPSsetgray(ctxt, 1);
|
||||
DPSmoveto(ctxt, tabRect.origin.x, tabRect.origin.y+16);
|
||||
DPSrlineto(ctxt, tabRect.size.width, 0);
|
||||
DPSstroke(ctxt);
|
||||
|
||||
lRect = tabRect;
|
||||
lRect.origin.y += 3;
|
||||
[[item_tabview font] set];
|
||||
|
||||
DPSsetgray(ctxt, 0);
|
||||
DPSmoveto(ctxt, lRect.origin.x, lRect.origin.y);
|
||||
DPSshow(ctxt, [item_label cString]);
|
||||
|
||||
DPSgrestore(ctxt);
|
||||
}
|
||||
|
||||
// NSCoding protocol.
|
||||
|
|
Loading…
Reference in a new issue