diff --git a/ChangeLog b/ChangeLog index 046c8dbeb..e4daa30ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-12-10 Fred Kiefer + + * 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 * Documentation/gclose.1, diff --git a/ColorPickers/GNUmakefile b/ColorPickers/GNUmakefile index feda0cc92..14c7fe455 100644 --- a/ColorPickers/GNUmakefile +++ b/ColorPickers/GNUmakefile @@ -44,9 +44,10 @@ StandardPicker_OBJC_FILES = GSStandardColorPicker.m \ GSRGBColorPicker.m \ GSCMYKColorPicker.m \ GSHSBColorPicker.m \ - GSGrayColorPicker.m + GSGrayColorPicker.m \ + GSColorSliderCell.m NamedPicker_OBJC_FILES = GSNamedColorPicker.m -WheelPicker_OBJC_FILES = GSWheelColorPicker.m +WheelPicker_OBJC_FILES = GSWheelColorPicker.m GSColorSliderCell.m # The class to load StandardPicker_PRINCIPAL_CLASS = GSStandardColorPicker diff --git a/ColorPickers/GSCMYKColorPicker.m b/ColorPickers/GSCMYKColorPicker.m index 58e32a5f2..a228c00a2 100644 --- a/ColorPickers/GSCMYKColorPicker.m +++ b/ColorPickers/GSCMYKColorPicker.m @@ -31,16 +31,16 @@ @implementation GSCMYKColorPicker - (id)initWithPickerMask:(int)aMask - colorPanel:(NSColorPanel *)colorPanel + colorPanel:(NSColorPanel *)colorPanel { if (aMask & NSColorPanelCMYKModeMask) { NSBundle *b; self = [super initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; if (!self) - return nil; + return nil; numFields = 4; currentMode = NSColorPanelCMYKModeMask; @@ -73,7 +73,7 @@ c = [color colorUsingColorSpaceName: NSDeviceCMYKColorSpace]; [c getCyan: &cyan magenta: &magenta yellow: &yellow - black: &black alpha: &alpha]; + black: &black alpha: &alpha]; values[0] = cyan * 100; values[1] = magenta * 100; @@ -81,6 +81,20 @@ values[3] = black * 100; [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; } @@ -92,11 +106,25 @@ float black = values[3] / 100; float alpha = [_colorPanel alpha]; NSColor *c = [NSColor colorWithDeviceCyan: cyan - magenta: magenta - yellow: yellow - black: black - alpha: alpha]; + magenta: magenta + yellow: yellow + black: black + alpha: alpha]; [_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]; } diff --git a/ColorPickers/GSColorSliderCell.h b/ColorPickers/GSColorSliderCell.h new file mode 100644 index 000000000..0f8050f6c --- /dev/null +++ b/ColorPickers/GSColorSliderCell.h @@ -0,0 +1,43 @@ +/* GSColorSliderCell.h + + Copyright (C) 2007 Free Software Foundation, Inc. + + Author: Fred Kiefer + Date: December 2007 + Author: Alexander Malmberg + 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 or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef GSColorSliderCell_h +#define GSColorSliderCell_h + +#include + +@interface GSColorSliderCell : NSSliderCell +{ + int mode; + float values[3]; +} +-(void) _setColorSliderCellMode: (int)m; +-(void) _setColorSliderCellValues: (float)a : (float)b : (float)c; +@end + +#endif diff --git a/ColorPickers/GSColorSliderCell.m b/ColorPickers/GSColorSliderCell.m new file mode 100644 index 000000000..375f1e103 --- /dev/null +++ b/ColorPickers/GSColorSliderCell.m @@ -0,0 +1,194 @@ +/* GSStandardColorPicker.m + + Copyright (C) 2007 Free Software Foundation, Inc. + + Author: Fred Kiefer + Date: December 2007 + Author: Alexander Malmberg + 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 or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#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 diff --git a/ColorPickers/GSHSBColorPicker.m b/ColorPickers/GSHSBColorPicker.m index 9915d4cd0..668557243 100644 --- a/ColorPickers/GSHSBColorPicker.m +++ b/ColorPickers/GSHSBColorPicker.m @@ -31,16 +31,16 @@ @implementation GSHSBColorPicker - (id)initWithPickerMask:(int)aMask - colorPanel:(NSColorPanel *)colorPanel + colorPanel:(NSColorPanel *)colorPanel { if (aMask & NSColorPanelHSBModeMask) { NSBundle *b; self = [super initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; if (!self) - return nil; + return nil; numFields = 3; currentMode = NSColorPanelHSBModeMask; @@ -97,9 +97,9 @@ float brightness = values[2] / 100; float alpha = [_colorPanel alpha]; NSColor *c = [NSColor colorWithCalibratedHue: hue - saturation: saturation - brightness: brightness - alpha: alpha]; + saturation: saturation + brightness: brightness + alpha: alpha]; [_colorPanel setColor: c]; [(GSColorSliderCell *)[sliders[0] cell] diff --git a/ColorPickers/GSRGBColorPicker.m b/ColorPickers/GSRGBColorPicker.m index 35194d168..99a5f9a2e 100644 --- a/ColorPickers/GSRGBColorPicker.m +++ b/ColorPickers/GSRGBColorPicker.m @@ -31,15 +31,15 @@ @implementation GSRGBColorPicker - (id)initWithPickerMask:(int)aMask - colorPanel:(NSColorPanel *)colorPanel + colorPanel:(NSColorPanel *)colorPanel { if (aMask & NSColorPanelRGBModeMask) { NSBundle *b; self = [super initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; if (!self) - return nil; + return nil; b = [NSBundle bundleForClass: [self class]]; @@ -78,6 +78,16 @@ values[2] = blue * 255; [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; } @@ -88,10 +98,20 @@ float blue = values[2] / 255; float alpha = [_colorPanel alpha]; NSColor *c = [NSColor colorWithCalibratedRed: red - green: green - blue: blue - alpha: alpha]; + green: green + blue: blue + alpha: alpha]; [_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]; } diff --git a/ColorPickers/GSStandardColorPicker.h b/ColorPickers/GSStandardColorPicker.h index 32bb28c5f..0b0ddfa0d 100644 --- a/ColorPickers/GSStandardColorPicker.h +++ b/ColorPickers/GSStandardColorPicker.h @@ -29,7 +29,26 @@ #ifndef GSStandardColorPicker_h #define GSStandardColorPicker_h -@class GSTable,NSSlider,NSTextField; +#include +#include "GSColorSliderCell.h" + +@class GSTable, NSSlider, NSTextField; +@class NSBox, NSButtonCell, NSMatrix; + +@interface GSStandardColorPicker: NSColorPicker +{ + GSTable *baseView; + NSBox *pickerBox; + NSButtonCell *imageCell; + NSMatrix *pickerMatrix; + NSMutableArray *pickers; + id currentPicker; +} + +- (void) loadViews; +- (void) _showNewPicker: (id) sender; + +@end @interface GSStandardCSColorPicker: NSColorPicker { @@ -59,14 +78,5 @@ @end -@interface GSColorSliderCell : NSSliderCell -{ - int mode; - float values[3]; -} --(void) _setColorSliderCellMode: (int)m; --(void) _setColorSliderCellValues: (float)a : (float)b : (float)c; -@end - #endif diff --git a/ColorPickers/GSStandardColorPicker.m b/ColorPickers/GSStandardColorPicker.m index eb916788e..77ebd7dd6 100644 --- a/ColorPickers/GSStandardColorPicker.m +++ b/ColorPickers/GSStandardColorPicker.m @@ -36,21 +36,6 @@ #include "GSGrayColorPicker.h" #include "GSStandardColorPicker.h" -@interface GSStandardColorPicker: NSColorPicker -{ - GSTable *baseView; - NSBox *pickerBox; - NSButtonCell *imageCell; - NSMatrix *pickerMatrix; - NSMutableArray *pickers; - id currentPicker; -} - -- (void) loadViews; -- (void) _showNewPicker: (id) sender; - -@end - @implementation GSStandardColorPicker - (void) dealloc @@ -63,46 +48,46 @@ } - (id)initWithPickerMask:(int)aMask - colorPanel:(NSColorPanel *)colorPanel + colorPanel:(NSColorPanel *)colorPanel { if (aMask & (NSColorPanelRGBModeMask | NSColorPanelHSBModeMask | - NSColorPanelCMYKModeMask | NSColorPanelGrayModeMask)) + NSColorPanelCMYKModeMask | NSColorPanelGrayModeMask)) { NSColorPicker *picker; pickers = [[NSMutableArray alloc] init]; picker = [[GSGrayColorPicker alloc] initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; if (picker != nil) { - [pickers addObject: picker]; - RELEASE(picker); + [pickers addObject: picker]; + RELEASE(picker); } picker = [[GSRGBColorPicker alloc] initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; if (picker != nil) { - [pickers addObject: picker]; - RELEASE(picker); + [pickers addObject: picker]; + RELEASE(picker); } picker = [[GSCMYKColorPicker alloc] initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; if (picker != nil) { - [pickers addObject: picker]; - RELEASE(picker); + [pickers addObject: picker]; + RELEASE(picker); } picker = [[GSHSBColorPicker alloc] initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; if (picker != nil) { - [pickers addObject: picker]; - RELEASE(picker); + [pickers addObject: picker]; + RELEASE(picker); } currentPicker = [pickers lastObject]; return [super initWithPickerMask: aMask - colorPanel: colorPanel]; + colorPanel: colorPanel]; } RELEASE(self); return nil; @@ -125,29 +110,29 @@ { if ([[pickers objectAtIndex: i] supportsMode: mode]) { - [pickerMatrix selectCellWithTag: i]; - [self _showNewPicker: pickerMatrix]; - [currentPicker setMode: mode]; - break; - } + [pickerMatrix selectCellWithTag: i]; + [self _showNewPicker: pickerMatrix]; + [currentPicker setMode: mode]; + break; + } } } - (BOOL)supportsMode:(int)mode { return ((mode == NSGrayModeColorPanel) || - (mode == NSRGBModeColorPanel) || - (mode == NSCMYKModeColorPanel) || - (mode == NSHSBModeColorPanel)); + (mode == NSRGBModeColorPanel) || + (mode == NSCMYKModeColorPanel) || + (mode == NSHSBModeColorPanel)); } - (void)insertNewButtonImage:(NSImage *)newImage - in:(NSButtonCell *)newButtonCell + in:(NSButtonCell *)newButtonCell { // Store the image button cell imageCell = newButtonCell; [super insertNewButtonImage: newImage - in: newButtonCell]; + in: newButtonCell]; } - (NSView *)provideNewView:(BOOL)initialRequest @@ -194,10 +179,10 @@ [cell setBordered: YES]; pickerMatrix = [[NSMatrix alloc] initWithFrame: NSMakeRect(0,0,0,0) - mode: NSRadioModeMatrix - prototype: cell - numberOfRows: 0 - numberOfColumns: 0]; + mode: NSRadioModeMatrix + prototype: cell + numberOfRows: 0 + numberOfColumns: 0]; RELEASE(cell); [pickerMatrix setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)]; [pickerMatrix setIntercellSpacing: NSMakeSize(1, 0)]; @@ -223,17 +208,17 @@ pickerBox = [[NSBox alloc] init]; [pickerBox setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; [baseView putView: pickerBox - atRow: 0 - column: 0 - withMargins: 0]; + atRow: 0 + column: 0 + withMargins: 0]; [pickerBox setTitlePosition: NSNoTitle]; [pickerBox setBorderType: NSNoBorder]; [pickerBox setContentView: [currentPicker provideNewView: NO]]; [baseView putView: pickerMatrix - atRow: 1 - column: 0 - withMargins: 0]; + atRow: 1 + column: 0 + withMargins: 0]; { NSBox *b = [[NSBox alloc] initWithFrame: NSMakeRect(0,0,0,2)]; @@ -241,12 +226,12 @@ [b setTitlePosition: NSNoTitle]; [b setBorderType: NSGrooveBorder]; [baseView putView: b - atRow: 2 - column: 0 - withMinXMargin: 0 - maxXMargin: 0 - minYMargin: 4 - maxYMargin: 0]; + atRow: 2 + column: 0 + withMinXMargin: 0 + maxXMargin: 0 + minYMargin: 4 + maxYMargin: 0]; DESTROY(b); } } @@ -260,9 +245,9 @@ [currentPicker setColor: [_colorPanel color]]; //NSLog(@"Base View size %@", NSStringFromRect([baseView frame])); /* [baseView putView: [currentPicker provideNewView: NO] - atRow: 0 - column: 0 - withMargins: 0];*/ + atRow: 0 + column: 0 + withMargins: 0];*/ [pickerBox setContentView: [currentPicker provideNewView: NO]]; currentView = [currentPicker provideNewView: NO]; @@ -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 - (void) dealloc @@ -505,12 +326,12 @@ [s setAutoresizingMask: NSViewWidthSizable]; [baseView putView: s - atRow: numFields - i - column: 0 - withMinXMargin: 0 - maxXMargin: 0 - minYMargin: 0 - maxYMargin: i?6:2]; + atRow: numFields - i + column: 0 + withMinXMargin: 0 + maxXMargin: 0 + minYMargin: 0 + maxYMargin: i?6:2]; } if (maxValue) @@ -548,9 +369,9 @@ [hb setAutoresizingMask: NSViewWidthSizable]; [baseView putView: hb - atRow: numFields + 1 - column: 0 - withMargins: 0]; + atRow: numFields + 1 + column: 0 + withMargins: 0]; DESTROY(hb); } else @@ -573,9 +394,9 @@ DESTROY(tv); v = [[NSView alloc] initWithFrame: frame]; [baseView putView: v - atRow: numFields + 1 - column: 0 - withMargins: 0]; + atRow: numFields + 1 + column: 0 + withMargins: 0]; DESTROY(v); } @@ -589,12 +410,12 @@ [f setFrameSize: NSMakeSize([f frame].size.width * 1.5, [f frame].size.height)]; [f setDelegate: self]; [baseView putView: f - atRow: numFields - i - column: 1 - withMinXMargin: 3 - maxXMargin: 0 - minYMargin: 0 - maxYMargin: 0]; + atRow: numFields - i + column: 1 + withMinXMargin: 3 + maxXMargin: 0 + minYMargin: 0 + maxYMargin: 0]; } } @@ -606,7 +427,7 @@ return; updating = YES; - for (i = 0; i