mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 15:30:38 +00:00
Added NSTab* classes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4432 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8408ebf0b7
commit
a9cce23dbb
8 changed files with 512 additions and 1 deletions
|
@ -102,6 +102,8 @@ NSSpellChecker.m \
|
|||
NSSpellServer.m \
|
||||
NSSplitView.m \
|
||||
NSStringDrawing.m \
|
||||
NSTabView.m \
|
||||
NSTabViewItem.m \
|
||||
NSText.m \
|
||||
NSTextContainer.m \
|
||||
NSTextField.m \
|
||||
|
@ -198,6 +200,8 @@ AppKit/NSSpellProtocol.h \
|
|||
AppKit/NSSpellServer.h \
|
||||
AppKit/NSSplitView.h \
|
||||
AppKit/NSStringDrawing.h \
|
||||
AppKit/NSTabView.h \
|
||||
AppKit/NSTabViewItem.h \
|
||||
AppKit/NSText.h \
|
||||
AppKit/NSTextAttachment.h \
|
||||
AppKit/NSTextContainer.h \
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect];
|
||||
is_up = NO;
|
||||
pulls_down = flag;
|
||||
selected_item = 2;
|
||||
selected_item = 0;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
194
Source/NSTabView.m
Normal file
194
Source/NSTabView.m
Normal file
|
@ -0,0 +1,194 @@
|
|||
#include <AppKit/NSTabView.h>
|
||||
|
||||
@implementation NSTabView
|
||||
- (id)initWithFrame:(NSRect)rect
|
||||
{
|
||||
[super initWithFrame:rect];
|
||||
|
||||
// setup variables
|
||||
|
||||
tab_items = [NSMutableArray new];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// tab management.
|
||||
|
||||
- (void)addTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
[tab_items insertObject:tabViewItem atIndex:[tab_items count]];
|
||||
}
|
||||
|
||||
- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
atIndex:(int)index
|
||||
{
|
||||
[tab_items insertObject:tabViewItem atIndex:index];
|
||||
}
|
||||
|
||||
- (void)removeTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
int i = [tab_items indexOfObject:tabViewItem];
|
||||
|
||||
if (i == -1)
|
||||
return;
|
||||
|
||||
[tab_items removeObjectAtIndex:i];
|
||||
}
|
||||
|
||||
- (int)indexOfTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
return [tab_items indexOfObject:tabViewItem];
|
||||
}
|
||||
|
||||
- (int)indexOfTabViewItemWithIdentifier:(id)identifier
|
||||
{
|
||||
// the spec is confusing on this method.
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (int)numberOfTabViewItems
|
||||
{
|
||||
return [tab_items count];
|
||||
}
|
||||
|
||||
- (NSTabViewItem *)tabViewItemAtIndex:(int)index
|
||||
{
|
||||
return [tab_items objectAtIndex:index];
|
||||
}
|
||||
|
||||
- (NSArray *)tabViewItems
|
||||
{
|
||||
return (NSArray *)tab_items;
|
||||
}
|
||||
|
||||
- (void)selectFirstTabViewItem:(id)sender
|
||||
{
|
||||
[self selectTabViewItemAtIndex:0];
|
||||
}
|
||||
|
||||
- (void)selectLastTabViewItem:(id)sender
|
||||
{
|
||||
[self selectTabViewItem:[tab_items lastObject]];
|
||||
}
|
||||
|
||||
- (void)selectNextTabViewItem:(id)sender
|
||||
{
|
||||
[self selectTabViewItemAtIndex:tab_selected_item+1];
|
||||
}
|
||||
|
||||
- (void)selectPreviousTabViewItem:(id)sender
|
||||
{
|
||||
[self selectTabViewItemAtIndex:tab_selected_item-1];
|
||||
}
|
||||
|
||||
- (void)selectTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
}
|
||||
|
||||
- (void)selectTabViewItemAtIndex:(int)index
|
||||
{
|
||||
}
|
||||
|
||||
- (void)takeSelectedTabViewItemFromSender:(id)sender
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setFont:(NSFont *)font
|
||||
{
|
||||
ASSIGN(tab_font, font);
|
||||
}
|
||||
|
||||
- (NSFont *)font
|
||||
{
|
||||
return tab_font;
|
||||
}
|
||||
|
||||
- (void)setTabViewType:(NSTabViewType)tabViewType
|
||||
{
|
||||
tab_type = tabViewType;
|
||||
}
|
||||
|
||||
- (NSTabViewType)tabViewType
|
||||
{
|
||||
return tab_type;
|
||||
}
|
||||
|
||||
- (void)setDrawsBackground:(BOOL)flag
|
||||
{
|
||||
tab_draws_background = flag;
|
||||
}
|
||||
|
||||
- (BOOL) drawsBackground
|
||||
{
|
||||
return tab_draws_background;
|
||||
}
|
||||
|
||||
- (void)setAllowsTruncatedLabels:(BOOL)allowTruncatedLabels
|
||||
{
|
||||
tab_truncated_label = allowTruncatedLabels;
|
||||
}
|
||||
|
||||
- (BOOL)allowsTruncatedLabels
|
||||
{
|
||||
return tab_truncated_label;
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)anObject
|
||||
{
|
||||
ASSIGN(tab_delegate, anObject);
|
||||
}
|
||||
|
||||
- (id)delegate
|
||||
{
|
||||
return tab_delegate;
|
||||
}
|
||||
|
||||
// content and size
|
||||
|
||||
- (NSSize)minimumSize
|
||||
{
|
||||
return NSZeroSize;
|
||||
}
|
||||
|
||||
- (NSRect)contentRect
|
||||
{
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
// Event handling.
|
||||
|
||||
- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Coding.
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeObject:tab_items];
|
||||
[aCoder encodeObject:tab_font];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &tab_type];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tab_draws_background];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tab_truncated_label];
|
||||
[aCoder encodeObject:tab_delegate];
|
||||
[aCoder encodeValueOfObjCType: "i" at: &tab_selected_item];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
[super initWithCoder: aDecoder];
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &tab_items];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &tab_font];
|
||||
[aDecoder decodeValueOfObjCType: @encode(NSTabViewType) at:&tab_type];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tab_draws_background];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tab_truncated_label];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &tab_delegate];
|
||||
[aDecoder decodeValueOfObjCType: "i" at: &tab_selected_item];
|
||||
|
||||
return self;
|
||||
}
|
||||
@end
|
130
Source/NSTabViewItem.m
Normal file
130
Source/NSTabViewItem.m
Normal file
|
@ -0,0 +1,130 @@
|
|||
#include <AppKit/NSTabViewItem.h>
|
||||
|
||||
@implementation NSTabViewItem
|
||||
- (id) initWithIdentifier:(id)identifier
|
||||
{
|
||||
[super init];
|
||||
|
||||
ASSIGN(item_ident, identifier);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// Set identifier.
|
||||
|
||||
- (void)setIdentifier:(id)identifier
|
||||
{
|
||||
ASSIGN(item_ident, identifier);
|
||||
}
|
||||
|
||||
- (id)identifier
|
||||
{
|
||||
return item_ident;
|
||||
}
|
||||
|
||||
// Set label for item.
|
||||
|
||||
- (void)setLabel:(NSString *)label
|
||||
{
|
||||
ASSIGN(item_label, label);
|
||||
}
|
||||
|
||||
- (NSString *)label
|
||||
{
|
||||
return item_label;
|
||||
}
|
||||
|
||||
- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel
|
||||
{
|
||||
if (shouldTruncateLabel) {
|
||||
} else {
|
||||
}
|
||||
|
||||
return NSZeroSize;
|
||||
}
|
||||
|
||||
// Set view to display when item is clicked.
|
||||
|
||||
- (void)setView:(NSView *)view
|
||||
{
|
||||
ASSIGN(item_view, view);
|
||||
}
|
||||
|
||||
- (NSView *)view
|
||||
{
|
||||
return item_view;
|
||||
}
|
||||
|
||||
// Set color of tab surface.
|
||||
|
||||
- (void)setColor:(NSColor *)color
|
||||
{
|
||||
ASSIGN(item_color, color);
|
||||
}
|
||||
|
||||
- (NSColor *)color
|
||||
{
|
||||
return item_color;
|
||||
}
|
||||
|
||||
// tab state
|
||||
|
||||
- (NSTabState)tabState
|
||||
{
|
||||
return item_state;
|
||||
}
|
||||
|
||||
// Tab view, this is the "super" view.
|
||||
|
||||
- (NSTabView *)tabView
|
||||
{
|
||||
return item_tabview;
|
||||
}
|
||||
|
||||
// First responder.
|
||||
|
||||
- (void)setInitialFirstResponder:(NSView *)view
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initialFirstResponder
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Draw item.
|
||||
|
||||
- (void)drawLabel:(BOOL)shouldTruncateLabel
|
||||
inRect:(NSRect)tabRect
|
||||
{
|
||||
// Implement in backend?
|
||||
}
|
||||
|
||||
// NSCoding protocol.
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeObject:item_ident];
|
||||
[aCoder encodeObject:item_label];
|
||||
[aCoder encodeObject:item_view];
|
||||
[aCoder encodeObject:item_color];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTabState) at: &item_state];
|
||||
[aCoder encodeObject:item_tabview];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
[super initWithCoder: aDecoder];
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &item_ident];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &item_label];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &item_view];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &item_color];
|
||||
[aDecoder decodeValueOfObjCType: @encode(NSTabState) at:&item_state];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &item_tabview];
|
||||
|
||||
return self;
|
||||
}
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue