mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Moved drawing code to GSTheme.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25976 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
186e6b0744
commit
af5036aeee
4 changed files with 33 additions and 26 deletions
|
@ -1,3 +1,9 @@
|
|||
2008-01-18 14:39-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h
|
||||
* Source/GSTheme.m
|
||||
* Source/NSSegmentedCell.m: Moved drawing code to GSTheme.
|
||||
|
||||
2008-01-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSDragView.m (-_updateAndMoveImageToCorrectPosition):
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
#include "AppKit/NSCell.h"
|
||||
// For gradient types
|
||||
#include "AppKit/NSButtonCell.h"
|
||||
|
||||
|
@ -381,7 +382,7 @@ APPKIT_EXPORT NSString *GSThemeDidDeactivateNotification;
|
|||
* cell and view.
|
||||
*/
|
||||
- (void) drawButton: (NSRect)frame
|
||||
in: (NSButtonCell*)cell
|
||||
in: (NSCell*)cell
|
||||
view: (NSView*)view
|
||||
style: (int)style
|
||||
state: (GSThemeControlState)state;
|
||||
|
|
|
@ -697,7 +697,7 @@ static NSNull *null = nil;
|
|||
@implementation GSTheme (Drawing)
|
||||
|
||||
- (void) drawButton: (NSRect)frame
|
||||
in: (NSButtonCell*)cell
|
||||
in: (NSCell*)cell
|
||||
view: (NSView*)view
|
||||
style: (int)style
|
||||
state: (GSThemeControlState)state
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSStringDrawing.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <GNUstepGUI/GSTheme.h>
|
||||
|
||||
@interface NSSegmentItem : NSObject
|
||||
{
|
||||
|
@ -338,7 +339,10 @@
|
|||
if(_selected_segment != -1)
|
||||
{
|
||||
previous = [_items objectAtIndex: _selected_segment];
|
||||
[previous setSelected: NO];
|
||||
if(_segmentCellFlags._tracking_mode == NSSegmentSwitchTrackingSelectOne)
|
||||
{
|
||||
[previous setSelected: NO];
|
||||
}
|
||||
}
|
||||
|
||||
if([segment isEnabled])
|
||||
|
@ -520,27 +524,27 @@
|
|||
withView: (NSView *)view
|
||||
{
|
||||
id segment = [_items objectAtIndex: seg];
|
||||
NSFont *font = [NSFont controlContentFontOfSize:
|
||||
[NSFont systemFontSize]];
|
||||
NSString *label = [segment label];
|
||||
NSSize textSize = [label sizeWithAttributes: [NSDictionary dictionary]];
|
||||
NSRect textFrame = frame;
|
||||
float x_offset = (frame.size.width - textSize.width) / 2;
|
||||
|
||||
GSThemeControlState state = GSThemeNormalState;
|
||||
|
||||
textFrame.origin.x += x_offset;
|
||||
textFrame.size.width -= x_offset;
|
||||
[segment setFrame: frame];
|
||||
|
||||
if([segment isSelected])
|
||||
{
|
||||
NSDrawDarkBezel(frame,frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDrawButton(frame,frame);
|
||||
state = GSThemeSelectedState;
|
||||
}
|
||||
|
||||
[font set];
|
||||
[[GSTheme theme] drawButton: frame
|
||||
in: self
|
||||
view: [self controlView]
|
||||
style: NSRegularSquareBezelStyle
|
||||
state: state];
|
||||
|
||||
[self _drawText: [segment label] inFrame: textFrame];
|
||||
}
|
||||
|
||||
|
@ -605,32 +609,28 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) _detectHit: (NSPoint)point
|
||||
- (void) stopTracking: (NSPoint)lastPoint
|
||||
at: (NSPoint)stopPoint
|
||||
inView: (NSView*)controlView
|
||||
mouseIsUp: (BOOL)flag
|
||||
{
|
||||
int count = [self segmentCount];
|
||||
int i = 0;
|
||||
|
||||
[super stopTracking: lastPoint
|
||||
at: stopPoint
|
||||
inView: controlView
|
||||
mouseIsUp: (BOOL)flag];
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
id segment = [_items objectAtIndex: i];
|
||||
NSRect frame = [segment frame];
|
||||
if(NSPointInRect(point,frame))
|
||||
if(NSPointInRect(lastPoint,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
|
||||
|
|
Loading…
Reference in a new issue