2003-07-31 23:52:10 +00:00
|
|
|
/*
|
|
|
|
NSPopUpButtonCell.h
|
|
|
|
|
|
|
|
Cell for Popup list class
|
|
|
|
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Michael Hanni <mhanni@sprintmail.com>
|
|
|
|
Date: 1999
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
2005-05-26 02:52:46 +00:00
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-31 23:52:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GNUstep_H_NSPopUpButtonCell
|
|
|
|
#define _GNUstep_H_NSPopUpButtonCell
|
|
|
|
|
|
|
|
#include <AppKit/NSMenuItem.h>
|
2006-03-26 17:58:19 +00:00
|
|
|
#include <AppKit/NSMenuItemCell.h>
|
|
|
|
|
|
|
|
APPKIT_EXPORT NSString*NSPopUpButtonCellWillPopUpNotification;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
@class NSMenu;
|
|
|
|
|
|
|
|
typedef enum {
|
2006-03-26 17:58:19 +00:00
|
|
|
NSPopUpNoArrow = 0,
|
|
|
|
NSPopUpArrowAtCenter = 1,
|
|
|
|
NSPopUpArrowAtBottom = 2
|
2003-07-31 23:52:10 +00:00
|
|
|
} NSPopUpArrowPosition;
|
|
|
|
|
|
|
|
@interface NSPopUpButtonCell : NSMenuItemCell
|
|
|
|
{
|
|
|
|
id <NSMenuItem> _selectedItem;
|
|
|
|
struct __pbcFlags {
|
|
|
|
unsigned int pullsDown: 1;
|
|
|
|
unsigned int preferredEdge: 3;
|
|
|
|
unsigned int usesItemFromMenu: 1;
|
|
|
|
unsigned int altersStateOfSelectedItem: 1;
|
|
|
|
unsigned int arrowPosition: 2;
|
|
|
|
} _pbcFlags;
|
|
|
|
}
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
// Initialization
|
|
|
|
/**
|
|
|
|
* Initialize with stringValue and pullDown. If pullDown is YES, the
|
|
|
|
* reciever will be a pulldown button.
|
|
|
|
*/
|
|
|
|
- (id) initTextCell: (NSString*)stringValue pullsDown: (BOOL)flag;
|
|
|
|
|
|
|
|
// Selection processing
|
|
|
|
/**
|
|
|
|
* The currently selected item in the reciever.
|
|
|
|
*/
|
|
|
|
- (id <NSMenuItem>) selectedItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index of the currently selected item in the reciever.
|
|
|
|
*/
|
|
|
|
- (int) indexOfSelectedItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Synchronizes the title and the selected item. This sets
|
|
|
|
* the selected item to the title of the reciever.
|
|
|
|
*/
|
|
|
|
- (void) synchronizeTitleAndSelectedItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select item in the reciever.
|
|
|
|
*/
|
|
|
|
- (void) selectItem: (id <NSMenuItem>)item;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select item at the given index.
|
|
|
|
*/
|
|
|
|
- (void) selectItemAtIndex: (int)index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select the item with the given title.
|
|
|
|
*/
|
|
|
|
- (void) selectItemWithTitle: (NSString*)title;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set title to aString.
|
|
|
|
*/
|
|
|
|
- (void) setTitle: (NSString*)aString;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
// Getters and setters.
|
|
|
|
/**
|
|
|
|
* Set the menu for the popup.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) setMenu: (NSMenu*)menu;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the menu for the popup.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (NSMenu*) menu;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Set to YES to make the popup button a pull-down style control.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) setPullsDown: (BOOL)flag;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES, if this is a pull-down
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (BOOL) pullsDown;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Set to YES, if the items are to be autoenabled.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) setAutoenablesItems: (BOOL)flag;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES, if the items are autoenabled.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (BOOL) autoenablesItems;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Set the preferred edge as described by edge. This is used
|
|
|
|
* to determine the edge which will open the popup when the screen
|
|
|
|
* is small.
|
|
|
|
*/
|
|
|
|
- (void) setPreferredEdge: (NSRectEdge)preferredEdge;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the preferred edge.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (NSRectEdge) preferredEdge;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Set to YES, if the reciever should use a menu item for its title. YES
|
|
|
|
* is the default.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) setUsesItemFromMenu: (BOOL)flag;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES, if the reciever uses a menu item for its title.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (BOOL) usesItemFromMenu;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Set to YES, if the state of the menu item selected in the reciever
|
|
|
|
* should be changed when it's selected.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) setAltersStateOfSelectedItem: (BOOL)flag;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return YES, if the reciever changes the state of the item chosen by
|
|
|
|
* the user.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (BOOL) altersStateOfSelectedItem;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Returns the current arrow position of the reciever.
|
|
|
|
*/
|
|
|
|
- (NSPopUpArrowPosition) arrowPosition;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current arrow position of the reciever.
|
|
|
|
*/
|
|
|
|
- (void) setArrowPosition: (NSPopUpArrowPosition)pos;
|
|
|
|
|
|
|
|
// Item management
|
|
|
|
/**
|
|
|
|
* Add an item to the popup with title.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) addItemWithTitle: (NSString*)title;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a number of items to the reciever using the provided itemTitles array.
|
|
|
|
*/
|
|
|
|
- (void) addItemsWithTitles: (NSArray*)titles;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds an item with the given title at index. If an item already exists at
|
|
|
|
* index, it, and all items after it are advanced one position. Index needs
|
|
|
|
* to be within the valid range for the array of items in the popup button.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) insertItemWithTitle: (NSString*)title atIndex: (int)index;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a given item based on its title.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) removeItemWithTitle: (NSString*)title;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a given item based on its index, must be a valid index within the
|
|
|
|
* range for the item array of this popup.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) removeItemAtIndex: (int)index;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Purges all items from the popup.
|
|
|
|
*/
|
|
|
|
- (void) removeAllItems;
|
|
|
|
|
|
|
|
// Referencing items...
|
|
|
|
/**
|
|
|
|
* Item array of the reciever.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (NSArray*) itemArray;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of items in the reciever.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (int) numberOfItems;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Return the index of item in the item array of the reciever.
|
|
|
|
*/
|
|
|
|
- (int) indexOfItem: (id<NSMenuItem>)item;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index of the item with the given title.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (int) indexOfItemWithTitle: (NSString*)title;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index of the item with a tag equal to aTag.
|
|
|
|
*/
|
|
|
|
- (int) indexOfItemWithTag: (int)tag;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index of the item whose menu item's representedObject is equal to obj.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (int) indexOfItemWithRepresentedObject: (id)obj;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Index of the item in the reciever whose target and action
|
|
|
|
* are equal to aTarget and actionSelector.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (int) indexOfItemWithTarget: (id)aTarget andAction: (SEL)actionSelector;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Return the item at index.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (id <NSMenuItem>) itemAtIndex: (int)index;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Return the item with title.
|
|
|
|
*/
|
|
|
|
- (id <NSMenuItem>) itemWithTitle: (NSString*)title;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Return the item listed last in the reciever.
|
|
|
|
*/
|
|
|
|
- (id <NSMenuItem>) lastItem;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
// Title management
|
|
|
|
/**
|
|
|
|
* Set item title at the given index in the reciever.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (NSString*) itemTitleAtIndex: (int)index;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array containing all of the current item titles.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (NSArray*) itemTitles;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the title of the currently selected item in the reciever.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (NSString*) titleOfSelectedItem;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Attach popup
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) attachPopUpWithFrame: (NSRect)cellFrame inView: (NSView*)controlView;
|
2006-03-26 17:58:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dismiss the reciever.
|
|
|
|
*/
|
2003-07-31 23:52:10 +00:00
|
|
|
- (void) dismissPopUp;
|
|
|
|
|
2006-03-26 17:58:19 +00:00
|
|
|
/**
|
|
|
|
* Perform the click operation with the given frame and controlView.
|
|
|
|
*/
|
|
|
|
- (void) performClickWithFrame: (NSRect)frame inView: (NSView*)controlView;
|
2003-07-31 23:52:10 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
#endif // _GNUstep_H_NSPopUpButtonCell
|