More broken and ugly classes for Popup by michael. Sorry. ;-)

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4430 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Michael Silva 1999-06-19 00:31:39 +00:00
parent 27853bc47b
commit 4482beba44
9 changed files with 64 additions and 24 deletions

View file

@ -1,3 +1,15 @@
1999-06-18 Michael Hanni <mhanni@sprintmail.com>
* Images/common_Nibble.tiff: new image for NSPopUpButton.
* Source/NSPopUpButton.m: more changes. still using a subclass of
NSMenuMatrix but had to hack new methods in to make selected_item
working in the Matrix.
- drawRect: draws the correct item.
- synchronizeTitleAndSelectedItem: now informs our
NSPopUpButtonMatrix which one of its cells is "selected", i.e. on top.
* Source/NSPopUpButtonCell.m: added new file. empty class, used in
the backend currently.
1999-06-17 Michael Hanni <mhanni@sprintmail.com>
* Source/NSPopUpButton.m: half way implemented. Most still in

View file

@ -42,8 +42,10 @@
@interface NSPopUpButtonMatrix : NSMenuMatrix
{
int selected_cell;
}
- (id) initWithFrame: (NSRect)rect;
- (void) setIndexOfSelectedItem:(int)itemNum;
@end
@interface NSPopUpButton : NSButton <NSCoding>

View file

@ -0,0 +1,6 @@
#include <AppKit/NSMenuItem.h>
@interface NSPopUpButtonCell : NSMenuItem
{
}
@end

View file

@ -58,6 +58,7 @@ common_SwitchOff.tiff \
common_SliderHoriz.tiff \
common_SliderVert.tiff \
common_Tile.tiff \
common_Nibble.tiff \
common_Dimple.tiff \
common_ret.tiff \
common_WMClose.tiff \

BIN
Images/common_Nibble.tiff Normal file

Binary file not shown.

View file

@ -89,6 +89,7 @@ NSPrintInfo.m \
NSPrintOperation.m \
NSPrintPanel.m \
NSPopUpButton.m \
NSPopUpButtonCell.m \
NSResponder.m \
NSSavePanel.m \
NSScreen.m \

View file

@ -31,6 +31,7 @@
#include <gnustep/gui/config.h>
#include <Foundation/NSArray.h>
#include <AppKit/NSPopUpButton.h>
#include <AppKit/NSPopUpButtonCell.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSMenu.h>
@ -38,6 +39,8 @@
- (id) initWithFrame: (NSRect)rect
{
[super initWithFrame: rect];
selected_cell = 0;
cellSize = NSMakeSize (rect.size.width, rect.size.height);
return self;
@ -47,26 +50,34 @@
{
}
/* This is here so we can overide the use of NSMenuItem with
NSPopUpButtonCell once that cellClass is finished.
- (id <NSMenuItem>)insertItemWithTitle: (NSString*)aString
action: (SEL)aSelector
keyEquivalent: (NSString*)charCode
atIndex: (unsigned int)index
{
id menuCell = [[[NSPopUpButton cellClass] new] autorelease];
id menuCell = [[NSPopUpButtonCell new] autorelease];
NSLog(@"insertItem.\n");
[menuCell setFont: menuFont];
[menuCell setFont:[NSFont systemFontOfSize:12]];
[menuCell setTitle: aString];
[menuCell setAction: aSelector];
[menuCell setKeyEquivalent: charCode];
// [menuCell setAction: aSelector];
// [menuCell setKeyEquivalent: charCode];
[cells insertObject: menuCell atIndex: index];
return menuCell;
}
*/
- (void) setIndexOfSelectedItem:(int)itemNum
{
selected_cell = itemNum;
}
- (NSString *)titleOfSelectedItem
{
return [[cells objectAtIndex:selected_cell] title];
}
@end
//
@ -107,7 +118,7 @@ NSPopUpButtonCell once that cellClass is finished.
list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect];
is_up = NO;
pulls_down = flag;
selected_item = 0;
selected_item = 2;
return self;
}
@ -317,6 +328,10 @@ NSPopUpButtonCell once that cellClass is finished.
- (void)synchronizeTitleAndSelectedItem
{
if (!pulls_down)
[list_items setIndexOfSelectedItem:selected_item];
else
[list_items setIndexOfSelectedItem:0];
}
//
@ -363,19 +378,14 @@ NSPopUpButtonCell once that cellClass is finished.
//
- (void)drawRect:(NSRect)rect
{
id aCell;
id aCell;
aCell = [[list_items itemArray] objectAtIndex:selected_item];
if (!pulls_down)
aCell = [[list_items itemArray] objectAtIndex:selected_item];
else
aCell = [[list_items itemArray] objectAtIndex:0];
[aCell drawWithFrame:rect inView: self];
rect.origin.x = rect.size.width - 14;
rect.origin.y = rect.size.height/2 - 3;
if (pulls_down == NO)
NSDrawPopupNibble(NSMakePoint(rect.origin.x, rect.origin.y));
else
NSDrawDownArrow(NSMakePoint(rect.origin.x, rect.origin.y));
[aCell drawWithFrame:rect inView:self];
}
//

View file

@ -0,0 +1,12 @@
#include <gnustep/gui/config.h>
#include <AppKit/NSPopUpButtonCell.h>
@implementation NSPopUpButtonCell
+ (void) initialize
{
if (self == [NSPopUpButtonCell class])
[self setVersion: 1];
}
@end

View file

@ -55,10 +55,6 @@ void NSDrawGrayBezel(NSRect aRect, NSRect clipRect)
{}
void NSDrawGroove(NSRect aRect, NSRect clipRect)
{}
void NSDrawPopupNibble(NSPoint aPoint)
{}
void NSDrawDownArrow(NSPoint aPoint)
{}
void PSlineto(float x, float y)
{}
void PSmoveto(float x, float y)