mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
NSPopUpButton now works. NSTabView taking shape.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4436 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
24883840fc
commit
37753e0ffa
7 changed files with 101 additions and 11 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
1999-06-20 Michael Hanni <mhanni@sprintmail.com>
|
||||
|
||||
* Source/NSPopUpButton.m: hooked up all the actions and targets
|
||||
now works for popup, haven't finished pulldown yet.
|
||||
* Source/NSTabView.m: now draws the view correctly for all cases(?)
|
||||
* Source/NSTabViewItem.m: spits out correct values for string
|
||||
length, though more work is needed. No drawing, no events yet.
|
||||
|
||||
NSPopUpButton now has basic functionality, ie. it works.
|
||||
|
||||
1999-06-19 Michael Hanni <mhanni@sprintmail.com>
|
||||
|
||||
* Images/common_Nibble.tiff: made inner gray area transparent.
|
||||
|
|
|
@ -39,12 +39,15 @@
|
|||
|
||||
@class NSFont;
|
||||
@class NSMatrix;
|
||||
@class NSPopUpButton;
|
||||
|
||||
@interface NSPopUpButtonMatrix : NSMenuMatrix
|
||||
{
|
||||
int selected_cell;
|
||||
NSPopUpButton *popup_button;
|
||||
}
|
||||
- (id) initWithFrame: (NSRect)rect;
|
||||
- (void)setPopUpButton:(NSPopUpButton *)popb;
|
||||
- (void) setIndexOfSelectedItem:(int)itemNum;
|
||||
@end
|
||||
|
||||
|
|
|
@ -89,5 +89,16 @@ typedef enum {
|
|||
- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point;
|
||||
@end
|
||||
|
||||
@interface NSObject(NSTabViewDelegate)
|
||||
/*
|
||||
- (void)tabViewDidChangeNumberOfTabViewItems:(NSTabView *)tabView;
|
||||
tabViewDidSelectTabViewItemtabView:didSelectTabViewItem:
|
||||
tabViewShouldSelectTabViewItemtabView:shouldSelectTabViewItem:
|
||||
tabViewWillSelectTabViewItemtabView:willSelectTabViewItem:
|
||||
*/
|
||||
@end
|
||||
|
||||
#endif // _GNUstep_H_NSTabView
|
||||
|
||||
/* Notifications */
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <AppKit/NSPopUpButtonCell.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
|
||||
@implementation NSPopUpButtonMatrix
|
||||
- (id) initWithFrame: (NSRect)rect
|
||||
|
@ -57,8 +58,6 @@
|
|||
{
|
||||
id menuCell = [[NSPopUpButtonCell new] autorelease];
|
||||
|
||||
NSLog(@"insertItem.\n");
|
||||
|
||||
[menuCell setFont:[NSFont systemFontOfSize:12]];
|
||||
[menuCell setTitle: aString];
|
||||
// [menuCell setAction: aSelector];
|
||||
|
@ -78,6 +77,11 @@
|
|||
{
|
||||
return [[cells objectAtIndex:selected_cell] title];
|
||||
}
|
||||
|
||||
- (void)setPopUpButton:(NSPopUpButton *)popb
|
||||
{
|
||||
ASSIGN(popup_button, popb);
|
||||
}
|
||||
@end
|
||||
|
||||
//
|
||||
|
@ -116,6 +120,7 @@
|
|||
{
|
||||
[super initWithFrame:frameRect];
|
||||
list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect];
|
||||
[list_items setPopUpButton:self];
|
||||
is_up = NO;
|
||||
pulls_down = flag;
|
||||
selected_item = 0;
|
||||
|
@ -152,6 +157,19 @@
|
|||
pub_target = anObject;
|
||||
}
|
||||
|
||||
- (void)buttonSelected:(id)sender
|
||||
{
|
||||
selected_item = [self indexOfItemWithTitle:[sender title]];
|
||||
|
||||
[self synchronizeTitleAndSelectedItem];
|
||||
|
||||
[self drawRect:[self frame]];
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
if (pub_target && pub_action)
|
||||
[pub_target performSelector:pub_action withObject:self];
|
||||
}
|
||||
|
||||
//
|
||||
// Adding Items
|
||||
//
|
||||
|
@ -350,12 +368,10 @@
|
|||
//
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
{
|
||||
NSLog(@"mouseDown:");
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent *)theEvent
|
||||
{
|
||||
NSLog(@"mouseUp:");
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent *)theEvent
|
||||
|
@ -364,8 +380,6 @@
|
|||
|
||||
- (NSView *)hitTest:(NSPoint)aPoint
|
||||
{
|
||||
NSLog(@"hitTest:");
|
||||
|
||||
// First check ourselves
|
||||
// if ([self mouse:aPoint inRect:bounds]) return self;
|
||||
if ([self mouse:aPoint inRect:[self frame]]) return self;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSPopUpButtonCell.h>
|
||||
|
||||
@implementation NSPopUpButtonCell
|
||||
|
@ -7,6 +8,4 @@
|
|||
if (self == [NSPopUpButtonCell class])
|
||||
[self setVersion: 1];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSTabView.h>
|
||||
#include <AppKit/PSOperators.h>
|
||||
|
||||
@implementation NSTabView
|
||||
- (id)initWithFrame:(NSRect)rect
|
||||
|
@ -8,6 +12,7 @@
|
|||
// setup variables
|
||||
|
||||
tab_items = [NSMutableArray new];
|
||||
tab_font = [NSFont systemFontOfSize:12];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -16,12 +21,14 @@
|
|||
|
||||
- (void)addTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
[tabViewItem _setTabView:self];
|
||||
[tab_items insertObject:tabViewItem atIndex:[tab_items count]];
|
||||
}
|
||||
|
||||
- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
atIndex:(int)index
|
||||
{
|
||||
[tabViewItem _setTabView:self];
|
||||
[tab_items insertObject:tabViewItem atIndex:index];
|
||||
}
|
||||
|
||||
|
@ -155,6 +162,38 @@
|
|||
return NSZeroRect;
|
||||
}
|
||||
|
||||
// Drawing.
|
||||
|
||||
- (void)drawRect:(NSRect)rect
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
float borderThickness;
|
||||
int howMany = [tab_items count];
|
||||
|
||||
DPSgsave(ctxt);
|
||||
|
||||
switch (tab_type) {
|
||||
case NSTopTabsBezelBorder:
|
||||
rect.size.height -= 20;
|
||||
NSDrawButton(rect, rect);
|
||||
borderThickness = 2;
|
||||
break;
|
||||
case NSNoTabsBezelBorder:
|
||||
NSDrawButton(rect, rect);
|
||||
borderThickness = 2;
|
||||
break;
|
||||
case NSNoTabsLineBorder:
|
||||
NSFrameRect(rect);
|
||||
borderThickness = 1;
|
||||
break;
|
||||
case NSNoTabsNoBorder:
|
||||
borderThickness = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
DPSgrestore(ctxt);
|
||||
}
|
||||
|
||||
// Event handling.
|
||||
|
||||
- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSTabViewItem.h>
|
||||
|
||||
@implementation NSTabViewItem
|
||||
|
@ -36,10 +37,18 @@
|
|||
|
||||
- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel
|
||||
{
|
||||
if (shouldTruncateLabel) {
|
||||
} else {
|
||||
}
|
||||
NSSize rSize;
|
||||
|
||||
rSize.height = 12;
|
||||
|
||||
if (shouldTruncateLabel) {
|
||||
// what is the algo to truncate?
|
||||
rSize.width = [[item_tabview font] widthOfString:item_label];
|
||||
return rSize;
|
||||
} else {
|
||||
rSize.width = [[item_tabview font] widthOfString:item_label];
|
||||
return rSize;
|
||||
}
|
||||
return NSZeroSize;
|
||||
}
|
||||
|
||||
|
@ -76,6 +85,11 @@
|
|||
|
||||
// Tab view, this is the "super" view.
|
||||
|
||||
- (void)_setTabView:(NSTabView *)tabView
|
||||
{
|
||||
ASSIGN(item_tabview, tabView);
|
||||
}
|
||||
|
||||
- (NSTabView *)tabView
|
||||
{
|
||||
return item_tabview;
|
||||
|
|
Loading…
Reference in a new issue