* Headers/AppKit/NSSegmentedCell.h: Added rect ivar to cache frame.

* Source/NSBundleAdditions.m: Minor formatting changes.
	* Source/NSController.m: Added ivars to encodeWithCoder:.
	* Source/NSNibBindingConnector.m: Added ivars to encodeWithCoder:.
	* Source/NSSegmentedCell.m: Changes to fully implement rendering
	of the cell.
	* Source/NSSegmentedControl.m: Changes to fully implement
	control.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25900 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2008-01-09 03:37:59 +00:00
parent 5b5447d12d
commit a70afb2bae
7 changed files with 120 additions and 16 deletions

View file

@ -1,3 +1,14 @@
2008-01-08 22:35-EST Gregory John Casamento <greg_casamento@yahoo.com>
* Headers/AppKit/NSSegmentedCell.h: Added rect ivar to cache frame.
* Source/NSBundleAdditions.m: Minor formatting changes.
* Source/NSController.m: Added ivars to encodeWithCoder:.
* Source/NSNibBindingConnector.m: Added ivars to encodeWithCoder:.
* Source/NSSegmentedCell.m: Changes to fully implement rendering
of the cell.
* Source/NSSegmentedControl.m: Changes to fully implement
control.
2008-01-08 09:42-EST Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSSegmentedCell.m: Code to draw and render text in

View file

@ -56,6 +56,7 @@ typedef enum {
unsigned int _recalcToolTips:1;
unsigned int unused:24;
} _segmentCellFlags;
int _previous_selection;
}
// Specifying number of segments...

View file

@ -186,7 +186,7 @@
@implementation NSNibControlConnector
- (void) establishConnection
{
SEL sel = NSSelectorFromString(_tag);
SEL sel = NSSelectorFromString(_tag);
[_src setTarget: _dst];
[_src setAction: sel];
@ -198,8 +198,8 @@
{
if (_src != nil)
{
NSString *selName;
SEL sel;
NSString *selName;
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[_tag substringToIndex: 1] uppercaseString],
@ -212,10 +212,10 @@
}
else
{
const char *nam = [_tag cString];
const char *type;
unsigned int size;
int offset;
const char *nam = [_tag cString];
const char *type;
unsigned int size;
int offset;
/*
* Use the GNUstep additional function to set the instance

View file

@ -53,7 +53,14 @@
- (void) encodeWithCoder: (NSCoder *)aCoder
{
// TODO
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _declared_keys forKey: @"NSDeclaredKeys"];
}
else
{
[aCoder encodeObject: _declared_keys];
}
}
- (id) initWithCoder: (NSCoder *)aDecoder

View file

@ -36,6 +36,17 @@
@implementation NSNibBindingConnector
- (id) init
{
if((self = [super init]) != nil)
{
_binding = RETAIN([NSString stringWithString: @""]);
_keyPath = RETAIN([NSString stringWithString: @""]);
_options = RETAIN([NSMutableDictionary dictionary]);
}
return self;
}
- (void) dealloc
{
RELEASE(_binding);
@ -154,9 +165,9 @@
}
else
{
[aDecoder decodeValueOfObjCType: @encode(id) at: &_binding];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyPath];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_options];
ASSIGN(_binding,[aDecoder decodeObject]);
ASSIGN(_keyPath,[aDecoder decodeObject]);
ASSIGN(_options,[aDecoder decodeObject]);
}
return self;

View file

@ -33,6 +33,7 @@
#include <AppKit/NSGraphics.h>
#include <AppKit/NSFont.h>
#include <AppKit/NSStringDrawing.h>
#include <AppKit/NSEvent.h>
@interface NSSegmentItem : NSObject
{
@ -44,6 +45,7 @@
NSString *_label;
NSString *_tool_tip;
NSImage *_image;
NSRect _frame;
}
- (BOOL) isSelected;
@ -62,6 +64,8 @@
- (void) setTag: (int)tag;
- (float) width;
- (void) setWidth: (float)width;
- (NSRect) frame;
- (void) setFrame: (NSRect)frame;
@end
@implementation NSSegmentItem
@ -163,6 +167,16 @@
_width = width;
}
- (NSRect) frame
{
return _frame;
}
- (void) setFrame: (NSRect)frame
{
_frame = frame;
}
- (void) encodeWithCoder:(NSCoder *) aCoder
{
if ([aCoder allowsKeyedCoding])
@ -245,6 +259,7 @@
_items = [[NSMutableArray alloc] initWithCapacity: 2];
_selected_segment = -1;
_previous_selection = -1;
[self setAlignment: NSCenterTextAlignment];
return self;
@ -258,6 +273,7 @@
_items = [[NSMutableArray alloc] initWithCapacity: 2];
_selected_segment = -1;
_previous_selection = -1;
[self setAlignment: NSCenterTextAlignment];
return self;
@ -319,12 +335,27 @@
- (void) setSelected: (BOOL)flag forSegment: (int)seg
{
NSSegmentItem *segment = [_items objectAtIndex: seg];
NSSegmentItem *previous = nil;
[segment setSelected: flag];
if (flag)
_selected_segment = seg;
else if (seg == _selected_segment)
_selected_segment = -1;
if(_selected_segment != -1)
{
_previous_selection = _selected_segment;
previous = [_items objectAtIndex: _previous_selection];
[previous setSelected: NO];
}
if([segment isEnabled])
{
[segment setSelected: flag];
if (flag)
{
_selected_segment = seg;
}
else if (seg == _selected_segment)
{
_selected_segment = -1;
}
}
}
- (int) selectedSegment
@ -501,6 +532,7 @@
textFrame.origin.x += x_offset;
textFrame.size.width -= x_offset;
[segment setFrame: frame];
if([segment isSelected])
{
@ -567,6 +599,7 @@
ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSSegmentImages"]);
if ([aDecoder containsValueForKey: @"NSSelectedSegment"])
_selected_segment = [aDecoder decodeIntForKey: @"NSSelectedSegment"];
_previous_selection = -1;
}
else
{
@ -576,4 +609,32 @@
return self;
}
- (void) _detectHit: (NSPoint)point
{
int count = [self segmentCount];
int i = 0;
for(i = 0; i < count; i++)
{
id segment = [_items objectAtIndex: i];
NSRect frame = [segment frame];
if(NSPointInRect(point,frame))
{
[self setSelectedSegment: i];
break;
}
}
}
- (void) stopTracking: (NSPoint)lastPoint
at: (NSPoint)stopPoint
inView: (NSView*)controlView
mouseIsUp: (BOOL)flag
{
[super stopTracking: lastPoint
at: stopPoint
inView: controlView
mouseIsUp: (BOOL)flag];
[self _detectHit: lastPoint];
}
@end

View file

@ -25,6 +25,7 @@
#include <AppKit/NSControl.h>
#include <AppKit/NSSegmentedControl.h>
#include <AppKit/NSEvent.h>
@implementation NSSegmentedControl
@ -115,4 +116,16 @@
{
return [_cell isEnabledForSegment: segment];
}
/*
- (void) mouseDown: (NSEvent *)event
{
NSPoint location = [self convertPoint: [event locationInWindow]
fromView: nil];
[super mouseDown: event];
[_cell _detectHit: location];
NSLog(@"%@",NSStringFromPoint(location));
}
*/
@end