mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:50:48 +00:00
Correct Window linking problem and add support for dynamically changing
colour slides. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25710 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b3029c6bb0
commit
8ae77cbbb3
9 changed files with 406 additions and 277 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2007-12-10 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* ColorPickers/GSColorSliderCell.h,
|
||||||
|
* ColorPickers/GSColorSliderCell.m: New files split off from
|
||||||
|
GSStandardColorPicker.h and GSStandardColorPicker.m.
|
||||||
|
* ColorPickers/GNUmakefile: Add the new files.
|
||||||
|
* ColorPickers/GSStandardColorPicker.h,
|
||||||
|
* ColorPickers/GSStandardColorPicker.m: Remove split off code.
|
||||||
|
* ColorPickers/GSRGBColorPicker.m,
|
||||||
|
* ColorPickers/GSHSBColorPicker.m,
|
||||||
|
* ColorPickers/GSColorSliderCell.m: Add support for dynamically
|
||||||
|
displayed colour changes.
|
||||||
|
|
||||||
2007-12-09 Fred Kiefer <FredKiefer@gmx.de>
|
2007-12-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Documentation/gclose.1,
|
* Documentation/gclose.1,
|
||||||
|
|
|
@ -44,9 +44,10 @@ StandardPicker_OBJC_FILES = GSStandardColorPicker.m \
|
||||||
GSRGBColorPicker.m \
|
GSRGBColorPicker.m \
|
||||||
GSCMYKColorPicker.m \
|
GSCMYKColorPicker.m \
|
||||||
GSHSBColorPicker.m \
|
GSHSBColorPicker.m \
|
||||||
GSGrayColorPicker.m
|
GSGrayColorPicker.m \
|
||||||
|
GSColorSliderCell.m
|
||||||
NamedPicker_OBJC_FILES = GSNamedColorPicker.m
|
NamedPicker_OBJC_FILES = GSNamedColorPicker.m
|
||||||
WheelPicker_OBJC_FILES = GSWheelColorPicker.m
|
WheelPicker_OBJC_FILES = GSWheelColorPicker.m GSColorSliderCell.m
|
||||||
|
|
||||||
# The class to load
|
# The class to load
|
||||||
StandardPicker_PRINCIPAL_CLASS = GSStandardColorPicker
|
StandardPicker_PRINCIPAL_CLASS = GSStandardColorPicker
|
||||||
|
|
|
@ -81,6 +81,20 @@
|
||||||
values[3] = black * 100;
|
values[3] = black * 100;
|
||||||
[self _valuesChanged];
|
[self _valuesChanged];
|
||||||
|
|
||||||
|
// FIXME: No way to store black in slider cell
|
||||||
|
[(GSColorSliderCell *)[sliders[0] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[(GSColorSliderCell *)[sliders[1] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[(GSColorSliderCell *)[sliders[2] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[(GSColorSliderCell *)[sliders[3] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[sliders[0] setNeedsDisplay: YES];
|
||||||
|
[sliders[1] setNeedsDisplay: YES];
|
||||||
|
[sliders[2] setNeedsDisplay: YES];
|
||||||
|
[sliders[3] setNeedsDisplay: YES];
|
||||||
|
|
||||||
updating = NO;
|
updating = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +111,20 @@
|
||||||
black: black
|
black: black
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
[_colorPanel setColor: c];
|
[_colorPanel setColor: c];
|
||||||
|
|
||||||
|
// FIXME: No way to store black in slider cell
|
||||||
|
[(GSColorSliderCell *)[sliders[0] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[(GSColorSliderCell *)[sliders[1] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[(GSColorSliderCell *)[sliders[2] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[(GSColorSliderCell *)[sliders[3] cell]
|
||||||
|
_setColorSliderCellValues: cyan : magenta : yellow];
|
||||||
|
[sliders[0] setNeedsDisplay: YES];
|
||||||
|
[sliders[1] setNeedsDisplay: YES];
|
||||||
|
[sliders[2] setNeedsDisplay: YES];
|
||||||
|
[sliders[3] setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
43
ColorPickers/GSColorSliderCell.h
Normal file
43
ColorPickers/GSColorSliderCell.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/* GSColorSliderCell.h
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
Date: December 2007
|
||||||
|
Author: Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
Date: May 2002
|
||||||
|
|
||||||
|
This file is part of GNUstep.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3 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
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; see the file COPYING.LIB.
|
||||||
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
||||||
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GSColorSliderCell_h
|
||||||
|
#define GSColorSliderCell_h
|
||||||
|
|
||||||
|
#include <AppKit/NSSliderCell.h>
|
||||||
|
|
||||||
|
@interface GSColorSliderCell : NSSliderCell
|
||||||
|
{
|
||||||
|
int mode;
|
||||||
|
float values[3];
|
||||||
|
}
|
||||||
|
-(void) _setColorSliderCellMode: (int)m;
|
||||||
|
-(void) _setColorSliderCellValues: (float)a : (float)b : (float)c;
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
194
ColorPickers/GSColorSliderCell.m
Normal file
194
ColorPickers/GSColorSliderCell.m
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
/* GSStandardColorPicker.m
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
Date: December 2007
|
||||||
|
Author: Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
Date: May 2002
|
||||||
|
|
||||||
|
This file is part of GNUstep.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3 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
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; see the file COPYING.LIB.
|
||||||
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
||||||
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Foundation/Foundation.h>
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
#include "GSColorSliderCell.h"
|
||||||
|
|
||||||
|
#define KNOB_WIDTH 6
|
||||||
|
|
||||||
|
@implementation GSColorSliderCell : NSSliderCell
|
||||||
|
|
||||||
|
-(void) _setColorSliderCellMode: (int)m
|
||||||
|
{
|
||||||
|
mode = m;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 10:
|
||||||
|
[_titleCell setTextColor: [NSColor whiteColor]];
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
[_titleCell setTextColor: [NSColor blackColor]];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
[_titleCell setAlignment: NSLeftTextAlignment];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) _setColorSliderCellValues: (float)a : (float)b : (float)c
|
||||||
|
{
|
||||||
|
values[0] = a;
|
||||||
|
values[1] = b;
|
||||||
|
values[2] = c;
|
||||||
|
if (mode == 8 || mode == 9)
|
||||||
|
{
|
||||||
|
if (c > 0.7)
|
||||||
|
[_titleCell setTextColor: [NSColor blackColor]];
|
||||||
|
else
|
||||||
|
[_titleCell setTextColor: [NSColor whiteColor]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSRect) knobRectFlipped: (BOOL)flipped
|
||||||
|
{
|
||||||
|
NSPoint origin;
|
||||||
|
float floatValue = [self floatValue];
|
||||||
|
|
||||||
|
if (_isVertical && flipped)
|
||||||
|
{
|
||||||
|
floatValue = _maxValue + _minValue - floatValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
floatValue = (floatValue - _minValue) / (_maxValue - _minValue);
|
||||||
|
|
||||||
|
origin = _trackRect.origin;
|
||||||
|
if (_isVertical == YES)
|
||||||
|
{
|
||||||
|
origin.y += (_trackRect.size.height - KNOB_WIDTH) * floatValue;
|
||||||
|
return NSMakeRect (origin.x, origin.y, _trackRect.size.width, KNOB_WIDTH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
origin.x += (_trackRect.size.width - KNOB_WIDTH) * floatValue;
|
||||||
|
return NSMakeRect (origin.x, origin.y, KNOB_WIDTH, _trackRect.size.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) drawKnob: (NSRect)knobRect
|
||||||
|
{
|
||||||
|
[[NSColor blackColor] set];
|
||||||
|
NSDrawButton(knobRect, knobRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) drawBarInside: (NSRect)r flipped: (BOOL)flipped
|
||||||
|
{
|
||||||
|
float i, f;
|
||||||
|
|
||||||
|
if (_isVertical)
|
||||||
|
{
|
||||||
|
for (i = 0; i < r.size.height; i += 1)
|
||||||
|
{
|
||||||
|
f = (0.5 + i) / r.size.height;
|
||||||
|
if (flipped)
|
||||||
|
{
|
||||||
|
f = 1 - f;
|
||||||
|
}
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case 0: PSsetgray(f); break;
|
||||||
|
|
||||||
|
case 1: PSsetrgbcolor(f, values[1], values[2]); break;
|
||||||
|
case 2: PSsetrgbcolor(values[0], f, values[2]); break;
|
||||||
|
case 3: PSsetrgbcolor(values[0], values[1], f); break;
|
||||||
|
|
||||||
|
case 4: PSsetcmykcolor(f, values[1], values[2], 0); break;
|
||||||
|
case 5: PSsetcmykcolor(values[0], f, values[2], 0); break;
|
||||||
|
case 6: PSsetcmykcolor(values[0], values[1], f, 0); break;
|
||||||
|
case 7: PSsetcmykcolor(values[0], values[1], values[2], f); break;
|
||||||
|
|
||||||
|
case 8: PSsethsbcolor(f, values[1], values[2]); break;
|
||||||
|
case 9: PSsethsbcolor(values[0], f, values[2]); break;
|
||||||
|
case 10: PSsethsbcolor(values[0], values[1], f); break;
|
||||||
|
}
|
||||||
|
if (i + 1 < r.size.height)
|
||||||
|
PSrectfill(r.origin.x, i + r.origin.y, r.size.width, 1);
|
||||||
|
else
|
||||||
|
PSrectfill(r.origin.x, i + r.origin.y, r.size.width, r.size.height - i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < r.size.width; i += 1)
|
||||||
|
{
|
||||||
|
f = (0.5 + i) / r.size.width;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case 0: PSsetgray(f); break;
|
||||||
|
|
||||||
|
case 1: PSsetrgbcolor(f, values[1], values[2]); break;
|
||||||
|
case 2: PSsetrgbcolor(values[0], f, values[2]); break;
|
||||||
|
case 3: PSsetrgbcolor(values[0], values[1], f); break;
|
||||||
|
|
||||||
|
case 4: PSsetcmykcolor(f, values[1], values[2], 0); break;
|
||||||
|
case 5: PSsetcmykcolor(values[0], f, values[2], 0); break;
|
||||||
|
case 6: PSsetcmykcolor(values[0], values[1], f, 0); break;
|
||||||
|
case 7: PSsetcmykcolor(values[0], values[1], values[2], f); break;
|
||||||
|
|
||||||
|
case 8: PSsethsbcolor(f, values[1], values[2]); break;
|
||||||
|
case 9: PSsethsbcolor(values[0], f, values[2]); break;
|
||||||
|
case 10: PSsethsbcolor(values[0], values[1], f); break;
|
||||||
|
}
|
||||||
|
if (i + 1 < r.size.width)
|
||||||
|
PSrectfill(i, r.origin.y, 1, r.size.height);
|
||||||
|
else
|
||||||
|
PSrectfill(i, r.origin.y, r.size.width - i, r.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
[_titleCell drawInteriorWithFrame: r inView: _control_view];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||||
|
{
|
||||||
|
_isVertical = (cellFrame.size.height > cellFrame.size.width);
|
||||||
|
cellFrame = [self drawingRectForBounds: cellFrame];
|
||||||
|
|
||||||
|
cellFrame.origin.x -= 1;
|
||||||
|
cellFrame.origin.y -= 1;
|
||||||
|
cellFrame.size.width += 2;
|
||||||
|
cellFrame.size.height += 2;
|
||||||
|
|
||||||
|
_trackRect = cellFrame;
|
||||||
|
|
||||||
|
[self drawBarInside: cellFrame flipped: [controlView isFlipped]];
|
||||||
|
|
||||||
|
[self drawKnob];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) knobThickness
|
||||||
|
{
|
||||||
|
return KNOB_WIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -78,6 +78,16 @@
|
||||||
values[2] = blue * 255;
|
values[2] = blue * 255;
|
||||||
[self _valuesChanged];
|
[self _valuesChanged];
|
||||||
|
|
||||||
|
[(GSColorSliderCell *)[sliders[0] cell]
|
||||||
|
_setColorSliderCellValues: red : green : blue];
|
||||||
|
[(GSColorSliderCell *)[sliders[1] cell]
|
||||||
|
_setColorSliderCellValues: red : green : blue];
|
||||||
|
[(GSColorSliderCell *)[sliders[2] cell]
|
||||||
|
_setColorSliderCellValues: red : green : blue];
|
||||||
|
[sliders[0] setNeedsDisplay: YES];
|
||||||
|
[sliders[1] setNeedsDisplay: YES];
|
||||||
|
[sliders[2] setNeedsDisplay: YES];
|
||||||
|
|
||||||
updating = NO;
|
updating = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +102,16 @@
|
||||||
blue: blue
|
blue: blue
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
[_colorPanel setColor: c];
|
[_colorPanel setColor: c];
|
||||||
|
|
||||||
|
[(GSColorSliderCell *)[sliders[0] cell]
|
||||||
|
_setColorSliderCellValues: red : green : blue];
|
||||||
|
[(GSColorSliderCell *)[sliders[1] cell]
|
||||||
|
_setColorSliderCellValues: red : green : blue];
|
||||||
|
[(GSColorSliderCell *)[sliders[2] cell]
|
||||||
|
_setColorSliderCellValues: red : green : blue];
|
||||||
|
[sliders[0] setNeedsDisplay: YES];
|
||||||
|
[sliders[1] setNeedsDisplay: YES];
|
||||||
|
[sliders[2] setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,26 @@
|
||||||
#ifndef GSStandardColorPicker_h
|
#ifndef GSStandardColorPicker_h
|
||||||
#define GSStandardColorPicker_h
|
#define GSStandardColorPicker_h
|
||||||
|
|
||||||
|
#include <AppKit/NSColorPicker.h>
|
||||||
|
#include "GSColorSliderCell.h"
|
||||||
|
|
||||||
@class GSTable, NSSlider, NSTextField;
|
@class GSTable, NSSlider, NSTextField;
|
||||||
|
@class NSBox, NSButtonCell, NSMatrix;
|
||||||
|
|
||||||
|
@interface GSStandardColorPicker: NSColorPicker <NSColorPickingCustom>
|
||||||
|
{
|
||||||
|
GSTable *baseView;
|
||||||
|
NSBox *pickerBox;
|
||||||
|
NSButtonCell *imageCell;
|
||||||
|
NSMatrix *pickerMatrix;
|
||||||
|
NSMutableArray *pickers;
|
||||||
|
id<NSColorPickingCustom, NSColorPickingDefault> currentPicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) loadViews;
|
||||||
|
- (void) _showNewPicker: (id) sender;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface GSStandardCSColorPicker: NSColorPicker <NSColorPickingCustom>
|
@interface GSStandardCSColorPicker: NSColorPicker <NSColorPickingCustom>
|
||||||
{
|
{
|
||||||
|
@ -59,14 +78,5 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface GSColorSliderCell : NSSliderCell
|
|
||||||
{
|
|
||||||
int mode;
|
|
||||||
float values[3];
|
|
||||||
}
|
|
||||||
-(void) _setColorSliderCellMode: (int)m;
|
|
||||||
-(void) _setColorSliderCellValues: (float)a : (float)b : (float)c;
|
|
||||||
@end
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,21 +36,6 @@
|
||||||
#include "GSGrayColorPicker.h"
|
#include "GSGrayColorPicker.h"
|
||||||
#include "GSStandardColorPicker.h"
|
#include "GSStandardColorPicker.h"
|
||||||
|
|
||||||
@interface GSStandardColorPicker: NSColorPicker <NSColorPickingCustom>
|
|
||||||
{
|
|
||||||
GSTable *baseView;
|
|
||||||
NSBox *pickerBox;
|
|
||||||
NSButtonCell *imageCell;
|
|
||||||
NSMatrix *pickerMatrix;
|
|
||||||
NSMutableArray *pickers;
|
|
||||||
id<NSColorPickingCustom, NSColorPickingDefault> currentPicker;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) loadViews;
|
|
||||||
- (void) _showNewPicker: (id) sender;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation GSStandardColorPicker
|
@implementation GSStandardColorPicker
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
@ -275,170 +260,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define KNOB_WIDTH 6
|
|
||||||
|
|
||||||
@implementation GSColorSliderCell : NSSliderCell
|
|
||||||
|
|
||||||
-(void) _setColorSliderCellMode: (int)m
|
|
||||||
{
|
|
||||||
mode = m;
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 10:
|
|
||||||
[_titleCell setTextColor: [NSColor whiteColor]];
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
[_titleCell setTextColor: [NSColor blackColor]];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
[_titleCell setAlignment: NSLeftTextAlignment];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) _setColorSliderCellValues: (float)a : (float)b : (float)c
|
|
||||||
{
|
|
||||||
values[0] = a;
|
|
||||||
values[1] = b;
|
|
||||||
values[2] = c;
|
|
||||||
if (mode == 8 || mode == 9)
|
|
||||||
{
|
|
||||||
if (c>0.7)
|
|
||||||
[_titleCell setTextColor: [NSColor blackColor]];
|
|
||||||
else
|
|
||||||
[_titleCell setTextColor: [NSColor whiteColor]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSRect) knobRectFlipped: (BOOL)flipped
|
|
||||||
{
|
|
||||||
NSPoint origin;
|
|
||||||
float floatValue = [self floatValue];
|
|
||||||
|
|
||||||
if (_isVertical && flipped)
|
|
||||||
{
|
|
||||||
floatValue = _maxValue + _minValue - floatValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
floatValue = (floatValue - _minValue) / (_maxValue - _minValue);
|
|
||||||
|
|
||||||
origin = _trackRect.origin;
|
|
||||||
if (_isVertical == YES)
|
|
||||||
{
|
|
||||||
origin.y += (_trackRect.size.height - KNOB_WIDTH) * floatValue;
|
|
||||||
return NSMakeRect (origin.x, origin.y, _trackRect.size.width, KNOB_WIDTH);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
origin.x += (_trackRect.size.width - KNOB_WIDTH) * floatValue;
|
|
||||||
return NSMakeRect (origin.x, origin.y, KNOB_WIDTH, _trackRect.size.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) drawKnob: (NSRect)knobRect
|
|
||||||
{
|
|
||||||
[[NSColor blackColor] set];
|
|
||||||
NSDrawButton(knobRect, knobRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) drawBarInside: (NSRect)r flipped: (BOOL)flipped
|
|
||||||
{
|
|
||||||
float i, f;
|
|
||||||
|
|
||||||
if (_isVertical)
|
|
||||||
{
|
|
||||||
for (i = 0; i < r.size.height; i += 1)
|
|
||||||
{
|
|
||||||
f = (0.5 + i) / r.size.height;
|
|
||||||
if (flipped)
|
|
||||||
{
|
|
||||||
f = 1 - f;
|
|
||||||
}
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case 0: PSsetgray(f); break;
|
|
||||||
|
|
||||||
case 1: PSsetrgbcolor(f, 0, 0); break;
|
|
||||||
case 2: PSsetrgbcolor(0, f, 0); break;
|
|
||||||
case 3: PSsetrgbcolor(0, 0, f); break;
|
|
||||||
|
|
||||||
case 4: PSsetcmykcolor(f, 0, 0, 0); break;
|
|
||||||
case 5: PSsetcmykcolor(0, f, 0, 0); break;
|
|
||||||
case 6: PSsetcmykcolor(0, 0, f, 0); break;
|
|
||||||
case 7: PSsetcmykcolor(0, 0, 0, f); break;
|
|
||||||
|
|
||||||
case 8: PSsethsbcolor(f, values[1], values[2]); break;
|
|
||||||
case 9: PSsethsbcolor(values[0], f, values[2]); break;
|
|
||||||
case 10: PSsethsbcolor(values[0], values[1], f); break;
|
|
||||||
}
|
|
||||||
if (i + 1 < r.size.height)
|
|
||||||
PSrectfill(r.origin.x, i + r.origin.y, r.size.width, 1);
|
|
||||||
else
|
|
||||||
PSrectfill(r.origin.x, i + r.origin.y, r.size.width, r.size.height - i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (i = 0; i < r.size.width; i += 1)
|
|
||||||
{
|
|
||||||
f = (0.5 + i) / r.size.width;
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case 0: PSsetgray(f); break;
|
|
||||||
|
|
||||||
case 1: PSsetrgbcolor(f, 0, 0); break;
|
|
||||||
case 2: PSsetrgbcolor(0, f, 0); break;
|
|
||||||
case 3: PSsetrgbcolor(0, 0, f); break;
|
|
||||||
|
|
||||||
case 4: PSsetcmykcolor(f, 0, 0, 0); break;
|
|
||||||
case 5: PSsetcmykcolor(0, f, 0, 0); break;
|
|
||||||
case 6: PSsetcmykcolor(0, 0, f, 0); break;
|
|
||||||
case 7: PSsetcmykcolor(0, 0, 0, f); break;
|
|
||||||
|
|
||||||
case 8: PSsethsbcolor(f, values[1], values[2]); break;
|
|
||||||
case 9: PSsethsbcolor(values[0], f, values[2]); break;
|
|
||||||
case 10: PSsethsbcolor(values[0], values[1], f); break;
|
|
||||||
}
|
|
||||||
if (i + 1 < r.size.width)
|
|
||||||
PSrectfill(i, r.origin.y, 1, r.size.height);
|
|
||||||
else
|
|
||||||
PSrectfill(i, r.origin.y, r.size.width - i, r.size.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
[_titleCell drawInteriorWithFrame: r inView: _control_view];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
|
||||||
{
|
|
||||||
_isVertical = (cellFrame.size.height > cellFrame.size.width);
|
|
||||||
cellFrame = [self drawingRectForBounds: cellFrame];
|
|
||||||
|
|
||||||
cellFrame.origin.x -= 1;
|
|
||||||
cellFrame.origin.y -= 1;
|
|
||||||
cellFrame.size.width += 2;
|
|
||||||
cellFrame.size.height += 2;
|
|
||||||
|
|
||||||
_trackRect = cellFrame;
|
|
||||||
|
|
||||||
[self drawBarInside: cellFrame flipped: [controlView isFlipped]];
|
|
||||||
|
|
||||||
[self drawKnob];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (float) knobThickness
|
|
||||||
{
|
|
||||||
return KNOB_WIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@implementation GSStandardCSColorPicker
|
@implementation GSStandardCSColorPicker
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
@ -653,4 +474,3 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue