mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
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:
parent
25c753ed0f
commit
aecfd77282
7 changed files with 863 additions and 417 deletions
14
ChangeLog
14
ChangeLog
|
@ -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>
|
||||
|
||||
* Source/NSControl.m: Reverted to the previous version (1.61) because
|
||||
|
|
|
@ -27,9 +27,11 @@
|
|||
#ifndef _GNUstep_H_NSComboBox
|
||||
#define _GNUstep_H_NSComboBox
|
||||
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <AppKit/NSTextField.h>
|
||||
|
||||
@class NSString;
|
||||
@class NSNotification;
|
||||
|
||||
@interface NSComboBox : NSTextField
|
||||
{
|
||||
}
|
||||
|
@ -82,14 +84,13 @@
|
|||
- (void) setCompletes: (BOOL)completes;
|
||||
- (BOOL) completes;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (NSComboBoxDataSource)
|
||||
- (int) numberOfItemsInComboBox: (NSComboBox *)aComboBox;
|
||||
- (id) comboBox: (NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index;
|
||||
- (unsigned int) comboBox: (NSComboBox *)aComboBox
|
||||
indexOfItemWithStringValue: (NSString *)string;
|
||||
- (unsigned int) comboBox: (NSComboBox *)aComboBox
|
||||
indexOfItemWithStringValue: (NSString *)string;
|
||||
#ifndef STRICT_OPENSTEP
|
||||
/* text completion */
|
||||
- (NSString *) comboBox: (NSComboBox *)aComboBox
|
||||
|
|
|
@ -27,9 +27,13 @@
|
|||
#ifndef _GNUstep_H_NSComboBoxCell
|
||||
#define _GNUstep_H_NSComboBoxCell
|
||||
|
||||
#include <Foundation/NSGeometry.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
|
||||
@class NSButtonCell, NSScrollView;
|
||||
@class NSButtonCell;
|
||||
@class NSMutableArray;
|
||||
@class NSArray;
|
||||
@class NSString;
|
||||
|
||||
@interface NSComboBoxCell : NSTextFieldCell
|
||||
{
|
||||
|
@ -43,9 +47,11 @@
|
|||
NSSize _intercellSpacing;
|
||||
float _itemHeight;
|
||||
int _selectedItem;
|
||||
NSRect _lastValidFrame;
|
||||
NSRange _prevSelectedRange;
|
||||
|
||||
@private
|
||||
id _popup;
|
||||
id _popup;
|
||||
}
|
||||
|
||||
- (BOOL)hasVerticalScroller;
|
||||
|
@ -101,8 +107,8 @@
|
|||
|
||||
@interface NSObject (NSComboBoxCellDataSource)
|
||||
- (int)numberOfItemsInComboBoxCell:(NSComboBoxCell *)comboBoxCell;
|
||||
- (id)comboBoxCell:(NSComboBoxCell *)aComboBoxCell
|
||||
objectValueForItemAtIndex:(int)index;
|
||||
- (id)comboBoxCell:(NSComboBoxCell *)aComboBoxCell
|
||||
objectValueForItemAtIndex:(int)index;
|
||||
- (unsigned int)comboBoxCell:(NSComboBoxCell *)aComboBoxCell
|
||||
indexOfItemWithStringValue:(NSString *)string;
|
||||
#ifndef STRICT_OPENSTEP
|
||||
|
|
|
@ -101,6 +101,7 @@ GNUstep.tiff \
|
|||
GNUstepMenuImage.tiff \
|
||||
nsmapping.strings \
|
||||
NSComboArrow.tiff \
|
||||
common_ComboBoxEllipsis.tiff \
|
||||
common_RightTabStop.tiff \
|
||||
common_CenterTabStop.tiff \
|
||||
common_LeftTabStop.tiff \
|
||||
|
|
BIN
Images/common_ComboBoxEllipsis.tiff
Normal file
BIN
Images/common_ComboBoxEllipsis.tiff
Normal file
Binary file not shown.
|
@ -25,15 +25,9 @@
|
|||
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSComboBox.h"
|
||||
#include "AppKit/NSComboBoxCell.h"
|
||||
#include "AppKit/NSEvent.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
|
||||
@interface NSObject(MouseUpping)
|
||||
- (NSEvent *)_mouseUpEvent;
|
||||
@end
|
||||
|
||||
/*
|
||||
* Class variables
|
||||
|
@ -45,9 +39,9 @@ static NSNotificationCenter *nc;
|
|||
|
||||
@implementation NSComboBox
|
||||
|
||||
+ (void)initialize
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSComboBox class])
|
||||
if (self == [NSComboBox class]) // Is such test case really needed ?
|
||||
{
|
||||
[self setVersion: 1];
|
||||
comboBoxCellClass = [NSComboBoxCell class];
|
||||
|
@ -242,8 +236,8 @@ static NSNotificationCenter *nc;
|
|||
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
||||
if ([_delegate respondsToSelector: @selector(comboBox##notif_name:)]) \
|
||||
[nc addObserver: _delegate \
|
||||
selector: @selector(comboBox##notif_name:) \
|
||||
name: NSComboBox##notif_name##Notification object: self]
|
||||
selector: @selector(comboBox##notif_name:) \
|
||||
name: NSComboBox##notif_name##Notification object: self]
|
||||
|
||||
SET_DELEGATE_NOTIFICATION(SelectionDidChange);
|
||||
SET_DELEGATE_NOTIFICATION(SelectionIsChanging);
|
||||
|
@ -252,25 +246,17 @@ static NSNotificationCenter *nc;
|
|||
}
|
||||
|
||||
// Overridden
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
NSEvent *cEvent;
|
||||
|
||||
[_cell trackMouse: theEvent inRect: [self bounds]
|
||||
ofView: self untilMouseUp: YES];
|
||||
if ([_cell respondsToSelector: @selector(_mouseUpEvent)])
|
||||
cEvent = [_cell _mouseUpEvent];
|
||||
else
|
||||
cEvent = nil;
|
||||
if ([_cell isSelectable])
|
||||
{
|
||||
if (!cEvent)
|
||||
cEvent = [NSApp currentEvent];
|
||||
if ([cEvent type] == NSLeftMouseUp &&
|
||||
([cEvent windowNumber] == [[self window] windowNumber]))
|
||||
[NSApp postEvent: cEvent atStart: NO];
|
||||
[super mouseDown: theEvent];
|
||||
}
|
||||
BOOL clicked;
|
||||
// clicked is set to the value YES when the click occurs in the text cell
|
||||
// and to the value NO when it occurs in the button cell
|
||||
|
||||
clicked = [_cell trackMouse: theEvent inRect: [self bounds]
|
||||
ofView: self untilMouseUp: YES];
|
||||
|
||||
if (clicked)
|
||||
[super mouseDown: theEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue