Rewritten combo box implementation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19418 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
qmathe 2004-05-29 13:17:21 +00:00
parent fd77800e9a
commit 6a2a5d22e2
7 changed files with 863 additions and 417 deletions

View file

@ -1,3 +1,17 @@
2004-05-29 Quentin Mathe <qmathe@lub-internet.fr>
* Source/NSComboBox.m:
* Headers/AppKit/NSComboBox.h:
* Source/NSComboBoxCell.m:
* Headers/AppKit/NSComboBoxCell.h:
* Images/GNUmakefile:
* Images/common_ComboBoxEllipsis.tiff:
New rewritten combo box implementation (which can be called completion
box now).
Everything should work except the completion possibility which needs some
layout manager and text view changes (patches to be commited by Alexander
Malmberg).
2004-05-29 Quentin Mathe <qmathe@lub-internet.fr> 2004-05-29 Quentin Mathe <qmathe@lub-internet.fr>
* Source/NSControl.m: Reverted to the previous version (1.61) because * Source/NSControl.m: Reverted to the previous version (1.61) because

View file

@ -27,9 +27,11 @@
#ifndef _GNUstep_H_NSComboBox #ifndef _GNUstep_H_NSComboBox
#define _GNUstep_H_NSComboBox #define _GNUstep_H_NSComboBox
#include <Foundation/NSNotification.h>
#include <AppKit/NSTextField.h> #include <AppKit/NSTextField.h>
@class NSString;
@class NSNotification;
@interface NSComboBox : NSTextField @interface NSComboBox : NSTextField
{ {
} }
@ -82,14 +84,13 @@
- (void) setCompletes: (BOOL)completes; - (void) setCompletes: (BOOL)completes;
- (BOOL) completes; - (BOOL) completes;
#endif #endif
@end @end
@interface NSObject (NSComboBoxDataSource) @interface NSObject (NSComboBoxDataSource)
- (int) numberOfItemsInComboBox: (NSComboBox *)aComboBox; - (int) numberOfItemsInComboBox: (NSComboBox *)aComboBox;
- (id) comboBox: (NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index; - (id) comboBox: (NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index;
- (unsigned int) comboBox: (NSComboBox *)aComboBox - (unsigned int) comboBox: (NSComboBox *)aComboBox
indexOfItemWithStringValue: (NSString *)string; indexOfItemWithStringValue: (NSString *)string;
#ifndef STRICT_OPENSTEP #ifndef STRICT_OPENSTEP
/* text completion */ /* text completion */
- (NSString *) comboBox: (NSComboBox *)aComboBox - (NSString *) comboBox: (NSComboBox *)aComboBox

View file

@ -27,9 +27,13 @@
#ifndef _GNUstep_H_NSComboBoxCell #ifndef _GNUstep_H_NSComboBoxCell
#define _GNUstep_H_NSComboBoxCell #define _GNUstep_H_NSComboBoxCell
#include <Foundation/NSGeometry.h>
#include <AppKit/NSTextFieldCell.h> #include <AppKit/NSTextFieldCell.h>
@class NSButtonCell, NSScrollView; @class NSButtonCell;
@class NSMutableArray;
@class NSArray;
@class NSString;
@interface NSComboBoxCell : NSTextFieldCell @interface NSComboBoxCell : NSTextFieldCell
{ {
@ -43,9 +47,11 @@
NSSize _intercellSpacing; NSSize _intercellSpacing;
float _itemHeight; float _itemHeight;
int _selectedItem; int _selectedItem;
NSRect _lastValidFrame;
NSRange _prevSelectedRange;
@private @private
id _popup; id _popup;
} }
- (BOOL)hasVerticalScroller; - (BOOL)hasVerticalScroller;
@ -101,8 +107,8 @@
@interface NSObject (NSComboBoxCellDataSource) @interface NSObject (NSComboBoxCellDataSource)
- (int)numberOfItemsInComboBoxCell:(NSComboBoxCell *)comboBoxCell; - (int)numberOfItemsInComboBoxCell:(NSComboBoxCell *)comboBoxCell;
- (id)comboBoxCell:(NSComboBoxCell *)aComboBoxCell - (id)comboBoxCell:(NSComboBoxCell *)aComboBoxCell
objectValueForItemAtIndex:(int)index; objectValueForItemAtIndex:(int)index;
- (unsigned int)comboBoxCell:(NSComboBoxCell *)aComboBoxCell - (unsigned int)comboBoxCell:(NSComboBoxCell *)aComboBoxCell
indexOfItemWithStringValue:(NSString *)string; indexOfItemWithStringValue:(NSString *)string;
#ifndef STRICT_OPENSTEP #ifndef STRICT_OPENSTEP

View file

@ -101,6 +101,7 @@ GNUstep.tiff \
GNUstepMenuImage.tiff \ GNUstepMenuImage.tiff \
nsmapping.strings \ nsmapping.strings \
NSComboArrow.tiff \ NSComboArrow.tiff \
common_ComboBoxEllipsis.tiff \
common_RightTabStop.tiff \ common_RightTabStop.tiff \
common_CenterTabStop.tiff \ common_CenterTabStop.tiff \
common_LeftTabStop.tiff \ common_LeftTabStop.tiff \

Binary file not shown.

View file

@ -25,15 +25,9 @@
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include "AppKit/NSApplication.h"
#include "AppKit/NSComboBox.h" #include "AppKit/NSComboBox.h"
#include "AppKit/NSComboBoxCell.h" #include "AppKit/NSComboBoxCell.h"
#include "AppKit/NSEvent.h" #include "AppKit/NSEvent.h"
#include "AppKit/NSWindow.h"
@interface NSObject(MouseUpping)
- (NSEvent *)_mouseUpEvent;
@end
/* /*
* Class variables * Class variables
@ -45,9 +39,9 @@ static NSNotificationCenter *nc;
@implementation NSComboBox @implementation NSComboBox
+ (void)initialize + (void) initialize
{ {
if (self == [NSComboBox class]) if (self == [NSComboBox class]) // Is such test case really needed ?
{ {
[self setVersion: 1]; [self setVersion: 1];
comboBoxCellClass = [NSComboBoxCell class]; comboBoxCellClass = [NSComboBoxCell class];
@ -242,8 +236,8 @@ static NSNotificationCenter *nc;
#define SET_DELEGATE_NOTIFICATION(notif_name) \ #define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([_delegate respondsToSelector: @selector(comboBox##notif_name:)]) \ if ([_delegate respondsToSelector: @selector(comboBox##notif_name:)]) \
[nc addObserver: _delegate \ [nc addObserver: _delegate \
selector: @selector(comboBox##notif_name:) \ selector: @selector(comboBox##notif_name:) \
name: NSComboBox##notif_name##Notification object: self] name: NSComboBox##notif_name##Notification object: self]
SET_DELEGATE_NOTIFICATION(SelectionDidChange); SET_DELEGATE_NOTIFICATION(SelectionDidChange);
SET_DELEGATE_NOTIFICATION(SelectionIsChanging); SET_DELEGATE_NOTIFICATION(SelectionIsChanging);
@ -252,25 +246,17 @@ static NSNotificationCenter *nc;
} }
// Overridden // Overridden
- (void)mouseDown:(NSEvent *)theEvent - (void) mouseDown: (NSEvent*)theEvent
{ {
NSEvent *cEvent; BOOL clicked;
// clicked is set to the value YES when the click occurs in the text cell
[_cell trackMouse: theEvent inRect: [self bounds] // and to the value NO when it occurs in the button cell
ofView: self untilMouseUp: YES];
if ([_cell respondsToSelector: @selector(_mouseUpEvent)]) clicked = [_cell trackMouse: theEvent inRect: [self bounds]
cEvent = [_cell _mouseUpEvent]; ofView: self untilMouseUp: YES];
else
cEvent = nil; if (clicked)
if ([_cell isSelectable]) [super mouseDown: theEvent];
{
if (!cEvent)
cEvent = [NSApp currentEvent];
if ([cEvent type] == NSLeftMouseUp &&
([cEvent windowNumber] == [[self window] windowNumber]))
[NSApp postEvent: cEvent atStart: NO];
[super mouseDown: theEvent];
}
} }
@end @end

File diff suppressed because it is too large Load diff