mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 13:51:55 +00:00
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:
parent
b6fcb00956
commit
8408ebf0b7
9 changed files with 64 additions and 24 deletions
12
ChangeLog
12
ChangeLog
|
@ -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>
|
1999-06-17 Michael Hanni <mhanni@sprintmail.com>
|
||||||
|
|
||||||
* Source/NSPopUpButton.m: half way implemented. Most still in
|
* Source/NSPopUpButton.m: half way implemented. Most still in
|
||||||
|
|
|
@ -42,8 +42,10 @@
|
||||||
|
|
||||||
@interface NSPopUpButtonMatrix : NSMenuMatrix
|
@interface NSPopUpButtonMatrix : NSMenuMatrix
|
||||||
{
|
{
|
||||||
|
int selected_cell;
|
||||||
}
|
}
|
||||||
- (id) initWithFrame: (NSRect)rect;
|
- (id) initWithFrame: (NSRect)rect;
|
||||||
|
- (void) setIndexOfSelectedItem:(int)itemNum;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSPopUpButton : NSButton <NSCoding>
|
@interface NSPopUpButton : NSButton <NSCoding>
|
||||||
|
|
6
Headers/gnustep/gui/NSPopUpButtonCell.h
Normal file
6
Headers/gnustep/gui/NSPopUpButtonCell.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include <AppKit/NSMenuItem.h>
|
||||||
|
|
||||||
|
@interface NSPopUpButtonCell : NSMenuItem
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@end
|
|
@ -58,6 +58,7 @@ common_SwitchOff.tiff \
|
||||||
common_SliderHoriz.tiff \
|
common_SliderHoriz.tiff \
|
||||||
common_SliderVert.tiff \
|
common_SliderVert.tiff \
|
||||||
common_Tile.tiff \
|
common_Tile.tiff \
|
||||||
|
common_Nibble.tiff \
|
||||||
common_Dimple.tiff \
|
common_Dimple.tiff \
|
||||||
common_ret.tiff \
|
common_ret.tiff \
|
||||||
common_WMClose.tiff \
|
common_WMClose.tiff \
|
||||||
|
|
BIN
Images/common_Nibble.tiff
Normal file
BIN
Images/common_Nibble.tiff
Normal file
Binary file not shown.
|
@ -89,6 +89,7 @@ NSPrintInfo.m \
|
||||||
NSPrintOperation.m \
|
NSPrintOperation.m \
|
||||||
NSPrintPanel.m \
|
NSPrintPanel.m \
|
||||||
NSPopUpButton.m \
|
NSPopUpButton.m \
|
||||||
|
NSPopUpButtonCell.m \
|
||||||
NSResponder.m \
|
NSResponder.m \
|
||||||
NSSavePanel.m \
|
NSSavePanel.m \
|
||||||
NSScreen.m \
|
NSScreen.m \
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <gnustep/gui/config.h>
|
#include <gnustep/gui/config.h>
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
#include <AppKit/NSPopUpButton.h>
|
#include <AppKit/NSPopUpButton.h>
|
||||||
|
#include <AppKit/NSPopUpButtonCell.h>
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
#include <AppKit/NSMenu.h>
|
#include <AppKit/NSMenu.h>
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@
|
||||||
- (id) initWithFrame: (NSRect)rect
|
- (id) initWithFrame: (NSRect)rect
|
||||||
{
|
{
|
||||||
[super initWithFrame: rect];
|
[super initWithFrame: rect];
|
||||||
|
|
||||||
|
selected_cell = 0;
|
||||||
|
|
||||||
cellSize = NSMakeSize (rect.size.width, rect.size.height);
|
cellSize = NSMakeSize (rect.size.width, rect.size.height);
|
||||||
return self;
|
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
|
- (id <NSMenuItem>)insertItemWithTitle: (NSString*)aString
|
||||||
action: (SEL)aSelector
|
action: (SEL)aSelector
|
||||||
keyEquivalent: (NSString*)charCode
|
keyEquivalent: (NSString*)charCode
|
||||||
atIndex: (unsigned int)index
|
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 setTitle: aString];
|
||||||
[menuCell setAction: aSelector];
|
// [menuCell setAction: aSelector];
|
||||||
[menuCell setKeyEquivalent: charCode];
|
// [menuCell setKeyEquivalent: charCode];
|
||||||
|
|
||||||
[cells insertObject: menuCell atIndex: index];
|
[cells insertObject: menuCell atIndex: index];
|
||||||
|
|
||||||
return menuCell;
|
return menuCell;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
- (void) setIndexOfSelectedItem:(int)itemNum
|
||||||
|
{
|
||||||
|
selected_cell = itemNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)titleOfSelectedItem
|
||||||
|
{
|
||||||
|
return [[cells objectAtIndex:selected_cell] title];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -107,7 +118,7 @@ NSPopUpButtonCell once that cellClass is finished.
|
||||||
list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect];
|
list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect];
|
||||||
is_up = NO;
|
is_up = NO;
|
||||||
pulls_down = flag;
|
pulls_down = flag;
|
||||||
selected_item = 0;
|
selected_item = 2;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -317,6 +328,10 @@ NSPopUpButtonCell once that cellClass is finished.
|
||||||
|
|
||||||
- (void)synchronizeTitleAndSelectedItem
|
- (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
|
- (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];
|
[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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
12
Source/NSPopUpButtonCell.m
Normal file
12
Source/NSPopUpButtonCell.m
Normal 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
|
|
@ -55,10 +55,6 @@ void NSDrawGrayBezel(NSRect aRect, NSRect clipRect)
|
||||||
{}
|
{}
|
||||||
void NSDrawGroove(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 PSlineto(float x, float y)
|
||||||
{}
|
{}
|
||||||
void PSmoveto(float x, float y)
|
void PSmoveto(float x, float y)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue