mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 00:00: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
a9cce23dbb
commit
5e64d4f6cb
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>
|
1999-06-19 Michael Hanni <mhanni@sprintmail.com>
|
||||||
|
|
||||||
* Images/common_Nibble.tiff: made inner gray area transparent.
|
* Images/common_Nibble.tiff: made inner gray area transparent.
|
||||||
|
|
|
@ -39,12 +39,15 @@
|
||||||
|
|
||||||
@class NSFont;
|
@class NSFont;
|
||||||
@class NSMatrix;
|
@class NSMatrix;
|
||||||
|
@class NSPopUpButton;
|
||||||
|
|
||||||
@interface NSPopUpButtonMatrix : NSMenuMatrix
|
@interface NSPopUpButtonMatrix : NSMenuMatrix
|
||||||
{
|
{
|
||||||
int selected_cell;
|
int selected_cell;
|
||||||
|
NSPopUpButton *popup_button;
|
||||||
}
|
}
|
||||||
- (id) initWithFrame: (NSRect)rect;
|
- (id) initWithFrame: (NSRect)rect;
|
||||||
|
- (void)setPopUpButton:(NSPopUpButton *)popb;
|
||||||
- (void) setIndexOfSelectedItem:(int)itemNum;
|
- (void) setIndexOfSelectedItem:(int)itemNum;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -89,5 +89,16 @@ typedef enum {
|
||||||
- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point;
|
- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSObject(NSTabViewDelegate)
|
||||||
|
/*
|
||||||
|
- (void)tabViewDidChangeNumberOfTabViewItems:(NSTabView *)tabView;
|
||||||
|
tabViewDidSelectTabViewItemtabView:didSelectTabViewItem:
|
||||||
|
tabViewShouldSelectTabViewItemtabView:shouldSelectTabViewItem:
|
||||||
|
tabViewWillSelectTabViewItemtabView:willSelectTabViewItem:
|
||||||
|
*/
|
||||||
|
@end
|
||||||
|
|
||||||
#endif // _GNUstep_H_NSTabView
|
#endif // _GNUstep_H_NSTabView
|
||||||
|
|
||||||
|
/* Notifications */
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <AppKit/NSPopUpButtonCell.h>
|
#include <AppKit/NSPopUpButtonCell.h>
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
#include <AppKit/NSMenu.h>
|
#include <AppKit/NSMenu.h>
|
||||||
|
#include <AppKit/NSFont.h>
|
||||||
|
|
||||||
@implementation NSPopUpButtonMatrix
|
@implementation NSPopUpButtonMatrix
|
||||||
- (id) initWithFrame: (NSRect)rect
|
- (id) initWithFrame: (NSRect)rect
|
||||||
|
@ -57,8 +58,6 @@
|
||||||
{
|
{
|
||||||
id menuCell = [[NSPopUpButtonCell new] autorelease];
|
id menuCell = [[NSPopUpButtonCell new] autorelease];
|
||||||
|
|
||||||
NSLog(@"insertItem.\n");
|
|
||||||
|
|
||||||
[menuCell setFont:[NSFont systemFontOfSize:12]];
|
[menuCell setFont:[NSFont systemFontOfSize:12]];
|
||||||
[menuCell setTitle: aString];
|
[menuCell setTitle: aString];
|
||||||
// [menuCell setAction: aSelector];
|
// [menuCell setAction: aSelector];
|
||||||
|
@ -78,6 +77,11 @@
|
||||||
{
|
{
|
||||||
return [[cells objectAtIndex:selected_cell] title];
|
return [[cells objectAtIndex:selected_cell] title];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setPopUpButton:(NSPopUpButton *)popb
|
||||||
|
{
|
||||||
|
ASSIGN(popup_button, popb);
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -116,6 +120,7 @@
|
||||||
{
|
{
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame:frameRect];
|
||||||
list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect];
|
list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect];
|
||||||
|
[list_items setPopUpButton:self];
|
||||||
is_up = NO;
|
is_up = NO;
|
||||||
pulls_down = flag;
|
pulls_down = flag;
|
||||||
selected_item = 0;
|
selected_item = 0;
|
||||||
|
@ -152,6 +157,19 @@
|
||||||
pub_target = anObject;
|
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
|
// Adding Items
|
||||||
//
|
//
|
||||||
|
@ -350,12 +368,10 @@
|
||||||
//
|
//
|
||||||
- (void)mouseDown:(NSEvent *)theEvent
|
- (void)mouseDown:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSLog(@"mouseDown:");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseUp:(NSEvent *)theEvent
|
- (void)mouseUp:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSLog(@"mouseUp:");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseMoved:(NSEvent *)theEvent
|
- (void)mouseMoved:(NSEvent *)theEvent
|
||||||
|
@ -364,8 +380,6 @@
|
||||||
|
|
||||||
- (NSView *)hitTest:(NSPoint)aPoint
|
- (NSView *)hitTest:(NSPoint)aPoint
|
||||||
{
|
{
|
||||||
NSLog(@"hitTest:");
|
|
||||||
|
|
||||||
// First check ourselves
|
// First check ourselves
|
||||||
// if ([self mouse:aPoint inRect:bounds]) return self;
|
// if ([self mouse:aPoint inRect:bounds]) return self;
|
||||||
if ([self mouse:aPoint inRect:[self frame]]) return self;
|
if ([self mouse:aPoint inRect:[self frame]]) return self;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <gnustep/gui/config.h>
|
#include <gnustep/gui/config.h>
|
||||||
|
#include <AppKit/NSMatrix.h>
|
||||||
#include <AppKit/NSPopUpButtonCell.h>
|
#include <AppKit/NSPopUpButtonCell.h>
|
||||||
|
|
||||||
@implementation NSPopUpButtonCell
|
@implementation NSPopUpButtonCell
|
||||||
|
@ -7,6 +8,4 @@
|
||||||
if (self == [NSPopUpButtonCell class])
|
if (self == [NSPopUpButtonCell class])
|
||||||
[self setVersion: 1];
|
[self setVersion: 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
#include <AppKit/NSColor.h>
|
||||||
|
#include <AppKit/NSImage.h>
|
||||||
#include <AppKit/NSTabView.h>
|
#include <AppKit/NSTabView.h>
|
||||||
|
#include <AppKit/PSOperators.h>
|
||||||
|
|
||||||
@implementation NSTabView
|
@implementation NSTabView
|
||||||
- (id)initWithFrame:(NSRect)rect
|
- (id)initWithFrame:(NSRect)rect
|
||||||
|
@ -8,6 +12,7 @@
|
||||||
// setup variables
|
// setup variables
|
||||||
|
|
||||||
tab_items = [NSMutableArray new];
|
tab_items = [NSMutableArray new];
|
||||||
|
tab_font = [NSFont systemFontOfSize:12];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -16,12 +21,14 @@
|
||||||
|
|
||||||
- (void)addTabViewItem:(NSTabViewItem *)tabViewItem
|
- (void)addTabViewItem:(NSTabViewItem *)tabViewItem
|
||||||
{
|
{
|
||||||
|
[tabViewItem _setTabView:self];
|
||||||
[tab_items insertObject:tabViewItem atIndex:[tab_items count]];
|
[tab_items insertObject:tabViewItem atIndex:[tab_items count]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem
|
- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem
|
||||||
atIndex:(int)index
|
atIndex:(int)index
|
||||||
{
|
{
|
||||||
|
[tabViewItem _setTabView:self];
|
||||||
[tab_items insertObject:tabViewItem atIndex:index];
|
[tab_items insertObject:tabViewItem atIndex:index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +162,38 @@
|
||||||
return NSZeroRect;
|
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.
|
// Event handling.
|
||||||
|
|
||||||
- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point
|
- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <AppKit/NSFont.h>
|
||||||
#include <AppKit/NSTabViewItem.h>
|
#include <AppKit/NSTabViewItem.h>
|
||||||
|
|
||||||
@implementation NSTabViewItem
|
@implementation NSTabViewItem
|
||||||
|
@ -36,10 +37,18 @@
|
||||||
|
|
||||||
- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel
|
- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel
|
||||||
{
|
{
|
||||||
if (shouldTruncateLabel) {
|
NSSize rSize;
|
||||||
} else {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
return NSZeroSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +85,11 @@
|
||||||
|
|
||||||
// Tab view, this is the "super" view.
|
// Tab view, this is the "super" view.
|
||||||
|
|
||||||
|
- (void)_setTabView:(NSTabView *)tabView
|
||||||
|
{
|
||||||
|
ASSIGN(item_tabview, tabView);
|
||||||
|
}
|
||||||
|
|
||||||
- (NSTabView *)tabView
|
- (NSTabView *)tabView
|
||||||
{
|
{
|
||||||
return item_tabview;
|
return item_tabview;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue