Removed all ivars and cleaned up the rest.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11034 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2001-09-28 23:37:37 +00:00
parent 4be6726ebd
commit a47397006b
7 changed files with 57 additions and 423 deletions

View file

@ -1,3 +1,25 @@
2001-09-28 Fred Kiefer <FredKiefer@gmx.de>
* Header/gnustep/gui/NSPopupButton.h
Removed all ivars and cleaned up the rest.
* Source/NSPopupButton.m
Removed the specific coding code.
[mouseDown:] and [keyDown:] don't send notification, as this is
done by the cell. Also don't send our action, as the action of the
menu item is already send. Changed call order of [dismissPopUp]
and [synchronizeTitleAndSelectedItem].
In [keyDown:] send item action via [NSMenu performActionForItemAtIndex:]
* Header/gnustep/gui/NSPopupButtonCell.h
Removed unneeded ivars.
* Source/NSPopupButtonCell.m
In [encodeWithCoder:] and [initWithCoder:] also encode the menu.
* Testing
Removed this directory.
* Tools/Functions.m
Removed this file.
* Tools/GNUmakefile
Removed references to Functions.m
Wed Sep 26 23:04:57 2001 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSFileWrapper.m

View file

@ -35,25 +35,13 @@
#include <AppKit/NSButton.h>
#include <AppKit/NSMenuItem.h>
#include <AppKit/NSMenu.h>
@class NSString;
@class NSArray;
@class NSMutableArray;
@class NSMenuView;
@class NSFont;
@class NSMatrix;
@interface NSPopUpButton : NSButton <NSCoding>
@interface NSPopUpButton : NSButton
{
NSMenu *popb_menu;
BOOL popb_pullsDown;
BOOL popb_autoenableItems;
int popb_selectedItem;
id pub_target;
SEL pub_action;
BOOL is_up;
}
//
@ -96,10 +84,6 @@
- (NSRectEdge)preferredEdge;
- (void)setTitle:(NSString *)aString;
- (void)synchronizeTitleAndSelectedItem;
- (void)mouseDown:(NSEvent *)theEvent;
- (id) initWithCoder: (NSCoder*)aDecoder;
- (void) encodeWithCoder: (NSCoder*)aCoder;
@end
APPKIT_EXPORT NSString *NSPopUpButtonWillPopUpNotification;

View file

@ -46,10 +46,8 @@ typedef enum {
struct __pbcFlags {
unsigned int pullsDown: 1;
unsigned int preferredEdge: 3;
unsigned int menuIsAttached: 1;
unsigned int usesItemFromMenu: 1;
unsigned int altersStateOfSelectedItem: 1;
unsigned int decoding: 1;
unsigned int arrowPosition: 2;
} _pbcFlags;
}

View file

@ -28,15 +28,13 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <gnustep/gui/config.h>
#import <Foundation/Foundation.h>
#include <AppKit/NSMenu.h>
#include <Foundation/Foundation.h>
#include <AppKit/NSPopUpButton.h>
#include <AppKit/NSPopUpButtonCell.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSMenu.h>
#include <AppKit/NSMenuItem.h>
#include <AppKit/NSMenuView.h>
#include <AppKit/NSFont.h>
/*
* class variables
@ -88,7 +86,7 @@ Class _nspopupbuttonCellClass = 0;
- (id) initWithFrame: (NSRect)frameRect
pullsDown: (BOOL)flag
{
[super initWithFrame: frameRect];
self = [super initWithFrame: frameRect];
[self setPullsDown: flag];
return self;
@ -147,15 +145,6 @@ Class _nspopupbuttonCellClass = 0;
[self synchronizeTitleAndSelectedItem];
}
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
{
NSMenu *m = [self menu];
if (m != nil)
return [m performKeyEquivalent: theEvent];
return NO;
}
- (void) removeAllItems
{
[_cell removeAllItems];
@ -292,12 +281,6 @@ Class _nspopupbuttonCellClass = 0;
[self setNeedsDisplay: YES];
}
- (void) sizeToFit
{
[[popb_menu menuRepresentation] sizeToFit];
[super sizeToFit];
}
- (BOOL) resignFirstResponder
{
[_cell dismissPopUp];
@ -311,20 +294,25 @@ Class _nspopupbuttonCellClass = 0;
[super resignKeyWindow];
}
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
{
NSMenu *m = [self menu];
if (m != nil)
return [m performKeyEquivalent: theEvent];
return NO;
}
- (void) mouseDown: (NSEvent*)theEvent
{
NSMenuView *mr = [[_cell menu] menuRepresentation];
NSWindow *menuWindow = [mr window];
NSEvent *e;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSPoint p;
NSWindow *menuWindow = [mr window];
if ([self isEnabled] == NO)
return;
[nc postNotificationName: NSPopUpButtonWillPopUpNotification
object: self];
// Attach the popUp
[_cell attachPopUpWithFrame: _bounds
inView: self];
@ -339,21 +327,17 @@ Class _nspopupbuttonCellClass = 0;
modifierFlags: [theEvent modifierFlags]
timestamp: [theEvent timestamp]
windowNumber: [menuWindow windowNumber]
context: nil // TODO ?
context: [theEvent context]
eventNumber: [theEvent eventNumber]
clickCount: [theEvent clickCount]
pressure: [theEvent pressure]];
[menuWindow sendEvent: e];
// Update our selected item
[self synchronizeTitleAndSelectedItem];
// Dismiss the popUp
[_cell dismissPopUp];
// Send action to target
[super sendAction: [self action]
to: [self target]];
// Update our selected item
[self synchronizeTitleAndSelectedItem];
}
- (void) keyDown: (NSEvent*)theEvent
@ -375,14 +359,13 @@ Class _nspopupbuttonCellClass = 0;
case NSCarriageReturnCharacter:
case ' ':
{
if ([[[_cell menu] window] isVisible] == NO)
NSMenuView *menuView;
menuView = [[_cell menu] menuRepresentation];
if ([[menuView window] isVisible] == NO)
{
int selectedIndex;
[[NSNotificationCenter defaultCenter]
postNotificationName: NSPopUpButtonWillPopUpNotification
object: self];
// Attach the popUp
[_cell attachPopUpWithFrame: _bounds
inView: self];
@ -390,26 +373,18 @@ Class _nspopupbuttonCellClass = 0;
selectedIndex = [self indexOfSelectedItem];
if (selectedIndex > -1)
[[[_cell menu] menuRepresentation]
setHighlightedItemIndex: selectedIndex];
[menuView setHighlightedItemIndex: selectedIndex];
}
else
{
// Update our selected item
[self synchronizeTitleAndSelectedItem];
[[_cell menu] performActionForItemAtIndex:
[self indexOfSelectedItem]];
// Dismiss the popUp
[_cell dismissPopUp];
{
id selectedItem = [self selectedItem];
[NSApp sendAction: [selectedItem action]
to: [selectedItem target]
from: selectedItem];
}
[super sendAction: [self action]
to: [self target]];
// Update our selected item
[self synchronizeTitleAndSelectedItem];
}
}
return;
@ -464,59 +439,12 @@ Class _nspopupbuttonCellClass = 0;
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
int i;
BOOL f;
id c;
/*
* Don't encode all the cell information!
*/
c = RETAIN([self cell]);
[super encodeWithCoder: aCoder];
[self setCell: c];
RELEASE(c);
f = [self pullsDown];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &f];
[aCoder encodeObject: [self itemArray]];
i = [self indexOfSelectedItem];
[aCoder encodeValueOfObjCType: @encode(int) at: &i];
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
NSArray *dItems;
int dSelected;
BOOL dPull;
unsigned i;
id aCell;
[super initWithCoder: aDecoder];
/*
* Set a newly created cell.
*/
aCell = [[[self class] cellClass] new];
[self setCell: aCell];
RELEASE(aCell);
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &dPull];
[self setPullsDown: dPull];
dItems = [aDecoder decodeObject];
for (i = 0; i < [dItems count]; i++)
{
NSMenuItem *dItem = [dItems objectAtIndex: i];
NSMenuItem *item;
[self addItemWithTitle: [dItem title]];
item = [self itemAtIndex: i];
[item setTarget: [dItem target]];
[item setAction: [dItem action]];
[item setEnabled: [dItem isEnabled]];
[item setTag: [dItem tag]];
[item setKeyEquivalent: [dItem keyEquivalent]];
}
[aDecoder decodeValueOfObjCType: @encode(int) at: &dSelected];
[self selectItemAtIndex: dSelected];
[self synchronizeTitleAndSelectedItem];
return self;
return [super initWithCoder: aDecoder];
}
@end

View file

@ -600,19 +600,16 @@ static NSImage *_pbc_image[2];
int flag;
[super encodeWithCoder: aCoder];
[aCoder encodeObject: _menu];
[aCoder encodeConditionalObject: _selectedItem];
flag = _pbcFlags.pullsDown;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.preferredEdge;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.menuIsAttached;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.usesItemFromMenu;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.altersStateOfSelectedItem;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.decoding;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
}
@ -620,22 +617,19 @@ static NSImage *_pbc_image[2];
- (id) initWithCoder: (NSCoder*)aDecoder
{
int flag;
[super initWithCoder: aDecoder];
self = [super initWithCoder: aDecoder];
_menu = [aDecoder decodeObject];
_selectedItem = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
_pbcFlags.pullsDown = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
_pbcFlags.preferredEdge = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
_pbcFlags.menuIsAttached = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
_pbcFlags.usesItemFromMenu = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
_pbcFlags.altersStateOfSelectedItem = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
_pbcFlags.decoding = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
_pbcFlags.arrowPosition = flag;
return self;

View file

@ -1,292 +0,0 @@
/*
Functions.m
Copyright (C) 1998 Free Software Foundation, Inc.
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Date: November 1998
This file is part of the GNUstep Project
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
You should have received a copy of the GNU General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <Foundation/NSObject.h>
#include <Foundation/NSGeometry.h>
#include <AppKit/NSGraphics.h>
#include <AppKit/NSGraphicsContext.h>
#include <AppKit/NSCStringText.h>
#include <AppKit/NSEvent.h>
/*
* Dummy definitions provided here to avoid errors when not linking with
* a back end.
*/
@interface GMModel : NSObject
@end
@implementation GMModel
@end
@interface GMUnarchiver : NSObject
@end
@implementation GMUnarchiver
@end
@interface NSWindowView : NSObject
@end
@implementation NSWindowView
@end
@interface GPSDrawContext : NSObject
@end
@implementation GPSDrawContext
@end
/*
* Should not be needed anymore
*/
#if 0
BOOL initialize_gnustep_backend(void)
{
return YES;
}
void NSHighlightRect(NSRect aRect)
{}
void NSRectClip(NSRect aRect)
{}
void NSRectFill(NSRect aRect)
{}
void NSFrameRect(NSRect aRect)
{}
void NSEraseRect(NSRect aRect)
{}
void NSDrawButton(NSRect aRect, NSRect clipRect)
{}
void NSDrawGrayBezel(NSRect aRect, NSRect clipRect)
{}
void NSDrawGroove(NSRect aRect, NSRect clipRect)
{}
void NSDrawPopupNibble(NSPoint aPoint)
{}
void NSDrawDownArrow(NSPoint aPoint)
{}
void NSDottedFrameRect(NSRect aRect)
{}
/* Dummy wraps */
unsigned int GSWDefineAsUserObj(NSGraphicsContext *ctxt) {return 0;}
void GSWViewIsFlipped(NSGraphicsContext *ctxt, BOOL flipped) {}
void NSDrawWhiteBezel(NSRect aRect, NSRect clipRect)
{
}
void NSDrawBezel(NSRect aRect, NSRect clipRect)
{
}
NSRect NSDrawTiledRects(NSRect boundsRect, NSRect clipRect,
const NSRectEdge *sides, const float *grays, int count)
{
return NSZeroRect;
}
const NSWindowDepth *NSAvailableWindowDepths(void)
{
return NULL;
}
NSWindowDepth NSBestDepth(NSString *colorSpace,
int bitsPerSample, int bitsPerPixel,
BOOL planar, BOOL *exactMatch)
{
return 0;
}
int NSBitsPerPixelFromDepth(NSWindowDepth depth)
{
return 0;
}
int NSBitsPerSampleFromDepth(NSWindowDepth depth)
{
return 0;
}
NSString *NSColorSpaceFromDepth(NSWindowDepth depth)
{
return nil;
}
int NSNumberOfColorComponents(NSString *colorSpaceName)
{
return 0;
}
BOOL NSPlanarFromDepth(NSWindowDepth depth)
{
return NO;
}
NSColor *NSReadPixel(NSPoint location)
{
return nil;
}
unsigned short NSEditorFilter(unsigned short theChar,
int flags, NSStringEncoding theEncoding)
{
return 0;
}
unsigned short NSFieldFilter(unsigned short theChar,
int flags, NSStringEncoding theEncoding)
{
return 0;
}
int NSDrawALine(id self, NSLayInfo *layInfo)
{
return 0;
}
int NSScanALine(id self, NSLayInfo *layInfo)
{
return 0;
}
void NSTextFontInfo(id fid,
float *ascender, float *descender,
float *lineHeight)
{}
NSData * NSDataWithWordTable(const unsigned char *smartLeft,
const unsigned char *smartRight,
const unsigned char *charClasses,
const NSFSM *wrapBreaks,
int wrapBreaksCount,
const NSFSM *clickBreaks,
int clickBreaksCount,
BOOL charWrap)
{
return nil;
}
void NSReadWordTable(NSZone *zone,
NSData *data,
unsigned char **smartLeft,
unsigned char **smartRight,
unsigned char **charClasses,
NSFSM **wrapBreaks,
int *wrapBreaksCount,
NSFSM **clickBreaks,
int *clickBreaksCount,
BOOL *charWrap)
{}
//
// Array Allocation Functions for Use by the NSText Class
//
NSTextChunk *NSChunkCopy(NSTextChunk *pc, NSTextChunk *dpc)
{
return NULL;
}
NSTextChunk *NSChunkGrow(NSTextChunk *pc, int newUsed)
{
return NULL;
}
NSTextChunk *NSChunkMalloc(int growBy, int initUsed)
{
return NULL;
}
NSTextChunk *NSChunkRealloc(NSTextChunk *pc)
{
return NULL;
}
NSTextChunk *NSChunkZoneCopy(NSTextChunk *pc,
NSTextChunk *dpc,
NSZone *zone)
{
return NULL;
}
NSTextChunk *NSChunkZoneGrow(NSTextChunk *pc, int newUsed, NSZone *zone)
{
return NULL;
}
NSTextChunk *NSChunkZoneMalloc(int growBy, int initUsed, NSZone *zone)
{
return NULL;
}
NSTextChunk *NSChunkZoneRealloc(NSTextChunk *pc, NSZone *zone)
{
return NULL;
}
void NSCopyBitmapFromGState(int srcGstate, NSRect srcRect, NSRect destRect)
{
}
void NSCopyBits(int srcGstate, NSRect srcRect, NSPoint destPoint)
{
}
void NSDrawBitmap(NSRect rect,
int pixelsWide,
int pixelsHigh,
int bitsPerSample,
int samplesPerPixel,
int bitsPerPixel,
int bytesPerRow,
BOOL isPlanar,
BOOL hasAlpha,
NSString *colorSpaceName,
const unsigned char *const data[5])
{
}
void NSBeep(void)
{
}
//
// Draw a Distinctive Outline around Linked Data
//
void NSFrameLinkRect(NSRect aRect, BOOL isDestination)
{
}
float NSLinkFrameThickness(void)
{
return 0;
}
// Color Functions
NSWindowDepth GSWindowDepthForScreen(int screen) {}
const NSWindowDepth *GSAvailableDepthsForScreen(int screen) {}
#endif

View file

@ -39,11 +39,11 @@ TOOL_NAME = make_services set_show_service
SERVICE_NAME = example GSspell
# The source files to be compiled
gpbs_OBJC_FILES = gpbs.m Functions.m
make_services_OBJC_FILES = make_services.m Functions.m
set_show_service_OBJC_FILES = set_show_service.m Functions.m
gpbs_OBJC_FILES = gpbs.m
make_services_OBJC_FILES = make_services.m
set_show_service_OBJC_FILES = set_show_service.m
example_OBJC_FILES = example.m Functions.m
example_OBJC_FILES = example.m
GSspell_OBJC_FILES = GSspell.m