mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-24 18:31:20 +00:00
NSSegmentedCell themeing support
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29435 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b53c941c37
commit
e6c79f2fb8
7 changed files with 115 additions and 9 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2010-01-28 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/GSThemeDrawing.m:
|
||||
* Source/NSSegmentedCell.m:
|
||||
* Source/NSSegmentedControl.m:
|
||||
* Headers/AppKit/NSSegmentedCell.h:
|
||||
* Headers/AppKit/NSSegmentedControl.h:
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
Add GSTheme method for NSSegmentedCell drawing.
|
||||
Implemented segmentStyle and setSegmentStyle: methods.
|
||||
|
||||
2010-01-28 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSButtonCell.m -isOpaque: Return NO if the button cell has a
|
||||
|
|
|
@ -224,6 +224,8 @@
|
|||
#include <AppKit/NSImageCell.h>
|
||||
// For scroller constants
|
||||
#include <AppKit/NSScroller.h>
|
||||
// For segmented control style constants
|
||||
#include <AppKit/NSSegmentedControl.h>
|
||||
|
||||
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE)
|
||||
@class NSArray;
|
||||
|
@ -823,6 +825,16 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
*/
|
||||
- (void) drawStepperHighlightDownButton: (NSRect)aRect;
|
||||
|
||||
// NSSegmentedControl drawing methods
|
||||
|
||||
- (void) drawSegmentedControlSegment: (NSCell *)cell
|
||||
withFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
style: (NSSegmentStyle)style
|
||||
state: (GSThemeControlState)state
|
||||
roundedLeft: (BOOL)roundedLeft
|
||||
roundedRight: (BOOL)roundedRight;
|
||||
|
||||
/**
|
||||
* In some themes it may be necessary to override the drawing
|
||||
* of an image a button cell and replace it with a rendered
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define _GNUstep_H_NSSegmentedCell
|
||||
|
||||
#include <AppKit/NSActionCell.h>
|
||||
#include <AppKit/NSSegmentedControl.h>
|
||||
|
||||
// tracking types...
|
||||
typedef enum {
|
||||
|
@ -52,9 +53,11 @@ typedef enum {
|
|||
unsigned int _tracking_mode:3;
|
||||
unsigned int _trimmed_labels:1;
|
||||
unsigned int _drawing:1;
|
||||
unsigned int _style:1;
|
||||
unsigned int unused1:2;
|
||||
unsigned int _recalcToolTips:1;
|
||||
unsigned int unused:24;
|
||||
unsigned int unused2:3;
|
||||
unsigned int _style:8;
|
||||
unsigned int unused3:13;
|
||||
} _segmentCellFlags;
|
||||
}
|
||||
|
||||
|
@ -95,5 +98,12 @@ typedef enum {
|
|||
- (void) drawSegment: (int)segment
|
||||
inFrame: (NSRect)frame
|
||||
withView: (NSView *)view;
|
||||
|
||||
// Setting the style of the segments
|
||||
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||
- (void)setSegmentStyle:(NSSegmentStyle)style;
|
||||
- (NSSegmentStyle)segmentStyle;
|
||||
#endif
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,18 @@
|
|||
#define _GNUstep_H_NSSegmentedControl
|
||||
|
||||
#include <AppKit/NSControl.h>
|
||||
#include <AppKit/NSSegmentedCell.h>
|
||||
|
||||
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||
typedef enum _NSSegmentStyle {
|
||||
NSSegmentStyleAutomatic = 0,
|
||||
NSSegmentStyleRounded = 1,
|
||||
NSSegmentStyleTexturedRounded = 2,
|
||||
NSSegmentStyleRoundRect = 3,
|
||||
NSSegmentStyleTexturedSquare = 4,
|
||||
NSSegmentStyleCapsule = 5,
|
||||
NSSegmentStyleSmallSquare = 6
|
||||
} NSSegmentStyle;
|
||||
#endif
|
||||
|
||||
@interface NSSegmentedControl : NSControl
|
||||
|
||||
|
@ -54,5 +65,11 @@
|
|||
- (void) setEnabled: (BOOL)flag forSegment: (int)segment;
|
||||
- (BOOL) isEnabledForSegment: (int)segment;
|
||||
|
||||
// Setting the style of the segments
|
||||
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||
- (void)setSegmentStyle:(NSSegmentStyle)style;
|
||||
- (NSSegmentStyle)segmentStyle;
|
||||
#endif
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -660,6 +660,23 @@
|
|||
[self drawStepperDownButton: downRect];
|
||||
}
|
||||
|
||||
// NSSegmentedControl drawing methods
|
||||
|
||||
- (void) drawSegmentedControlSegment: (NSCell *)cell
|
||||
withFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
style: (NSSegmentStyle)style
|
||||
state: (GSThemeControlState)state
|
||||
roundedLeft: (BOOL)roundedLeft
|
||||
roundedRight: (BOOL)roundedRight
|
||||
{
|
||||
[[GSTheme theme] drawButton: cellFrame
|
||||
in: cell
|
||||
view: controlView
|
||||
style: NSRegularSquareBezelStyle
|
||||
state: state];
|
||||
}
|
||||
|
||||
- (void) drawImage: (NSImage *)image
|
||||
inButtonCell: (NSButtonCell *) cell
|
||||
withFrame: (NSRect) aRect
|
||||
|
|
|
@ -545,6 +545,8 @@
|
|||
NSRect textFrame = frame;
|
||||
float x_offset = (frame.size.width - textSize.width) / 2;
|
||||
GSThemeControlState state = GSThemeNormalState;
|
||||
BOOL roundedLeft = NO;
|
||||
BOOL roundedRight = NO;
|
||||
|
||||
textFrame.origin.x += x_offset;
|
||||
textFrame.size.width -= x_offset;
|
||||
|
@ -555,12 +557,19 @@
|
|||
state = GSThemeSelectedState;
|
||||
}
|
||||
|
||||
[[GSTheme theme] drawButton: frame
|
||||
in: self
|
||||
view: [self controlView]
|
||||
style: NSRegularSquareBezelStyle
|
||||
state: state];
|
||||
if (seg == 0)
|
||||
roundedLeft = YES;
|
||||
|
||||
if (seg == ([_items count] - 1))
|
||||
roundedRight = YES;
|
||||
|
||||
[[GSTheme theme] drawSegmentedControlSegment: self
|
||||
withFrame: frame
|
||||
inView: [self controlView]
|
||||
style: [self segmentStyle]
|
||||
state: state
|
||||
roundedLeft: roundedLeft
|
||||
roundedRight: roundedRight];
|
||||
[self _drawText: [segment label] inFrame: textFrame];
|
||||
}
|
||||
|
||||
|
@ -587,6 +596,17 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Setting the style of the segments
|
||||
- (void)setSegmentStyle:(NSSegmentStyle)style
|
||||
{
|
||||
_segmentCellFlags._style = style;
|
||||
}
|
||||
|
||||
- (NSSegmentStyle)segmentStyle
|
||||
{
|
||||
return _segmentCellFlags._style;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
@ -596,11 +616,15 @@
|
|||
[aCoder encodeObject: _items forKey: @"NSSegmentImages"];
|
||||
if (_selected_segment != -1)
|
||||
[aCoder encodeInt: _selected_segment forKey: @"NSSelectedSegment"];
|
||||
[aCoder encodeInt: _segmentCellFlags._style forKey: @"NSSegmentStyle"];
|
||||
}
|
||||
else
|
||||
{
|
||||
int style;
|
||||
[aCoder encodeObject: _items];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &_selected_segment];
|
||||
style = _segmentCellFlags._style;
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &style];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,12 +639,16 @@
|
|||
if ([aDecoder containsValueForKey: @"NSSegmentImages"])
|
||||
ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSSegmentImages"]);
|
||||
if ([aDecoder containsValueForKey: @"NSSelectedSegment"])
|
||||
_selected_segment = [aDecoder decodeIntForKey: @"NSSelectedSegment"];
|
||||
_selected_segment = [aDecoder decodeIntForKey: @"NSSelectedSegment"];
|
||||
_segmentCellFlags._style = [aDecoder decodeIntForKey: @"NSSegmentStyle"];
|
||||
}
|
||||
else
|
||||
{
|
||||
int style;
|
||||
ASSIGN(_items,[aDecoder decodeObject]);
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &_selected_segment];
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &style];
|
||||
_segmentCellFlags._style = style;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <AppKit/NSControl.h>
|
||||
#include <AppKit/NSSegmentedControl.h>
|
||||
#include <AppKit/NSSegmentedCell.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
|
||||
static Class segmentedControlCellClass;
|
||||
|
@ -133,6 +134,16 @@ static Class segmentedControlCellClass;
|
|||
return [_cell isEnabledForSegment: segment];
|
||||
}
|
||||
|
||||
- (void)setSegmentStyle:(NSSegmentStyle)style
|
||||
{
|
||||
[_cell setSegmentStyle: style];
|
||||
}
|
||||
|
||||
- (NSSegmentStyle)segmentStyle
|
||||
{
|
||||
return [_cell segmentStyle];
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) mouseDown: (NSEvent *)event
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue