From 98a1e3d9347af62ef809cbe80367e55c455c584b Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Wed, 7 Feb 2007 15:43:39 +0000 Subject: [PATCH] Added NSLevelIndicator, code by Nikolaus Schaller . git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24489 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 + Headers/AppKit/AppKit.h | 7 + Headers/AppKit/NSLevelIndicator.h | 63 ++++ Headers/AppKit/NSLevelIndicatorCell.h | 85 +++++ Images/GNUmakefile | 3 +- Images/NSRatingLevelIndicator.tiff | Bin 0 -> 4892 bytes Source/GNUmakefile | 4 + Source/NSLevelIndicator.m | 146 ++++++++ Source/NSLevelIndicatorCell.m | 467 ++++++++++++++++++++++++++ 9 files changed, 785 insertions(+), 1 deletion(-) create mode 100644 Headers/AppKit/NSLevelIndicator.h create mode 100644 Headers/AppKit/NSLevelIndicatorCell.h create mode 100644 Images/NSRatingLevelIndicator.tiff create mode 100644 Source/NSLevelIndicator.m create mode 100644 Source/NSLevelIndicatorCell.m diff --git a/ChangeLog b/ChangeLog index 996cefc2e..82cb60f7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-02-07 Fred Kiefer + + * Image/NSRatingLevelIndicator.tiff, + * Headers/AppKit/NSLevelIndicatorCell.h, + * Headers/AppKit/NSLevelIndicator.h, + * Source/NSLevelIndicator.m, + * Source/NSLevelIndicatorCell.m: Add MacOS 10.4 classes. + * Headers/AppKit/AppKit.h: Publish the MacOS 10.4 classes. + * Source/GNUmakefile: Compile and install new classes and image. + Code by Nikolaus Schaller . + 2007-02-06 Matt Rice * Source/NSBrowser.m (-doClick:): Don't reselect the selected cells. diff --git a/Headers/AppKit/AppKit.h b/Headers/AppKit/AppKit.h index ec552f28c..e7de485f6 100644 --- a/Headers/AppKit/AppKit.h +++ b/Headers/AppKit/AppKit.h @@ -120,9 +120,11 @@ #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #include #include +#include #include #include #include +#include #include #include #include @@ -132,11 +134,15 @@ #include #include #include +#include #include +#include +#include #include #include #include #include +#include #include #include #include @@ -162,6 +168,7 @@ #include #include #include +#include #include #include #include diff --git a/Headers/AppKit/NSLevelIndicator.h b/Headers/AppKit/NSLevelIndicator.h new file mode 100644 index 000000000..62b3a5305 --- /dev/null +++ b/Headers/AppKit/NSLevelIndicator.h @@ -0,0 +1,63 @@ +/* -*-objc-*- + NSLevelIndicator.h + + The level indicator class + + Copyright (C) 2007 Free Software Foundation, Inc. + + Author: H. Nikolaus Schaller + Date: 2006 + + This file is part of the GNUstep GUI Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef _GNUstep_H_NSLevelIndicator +#define _GNUstep_H_NSLevelIndicator + +#include "AppKit/NSControl.h" +// For the tick mark +#include "AppKit/NSLevelIndicatorCell.h" + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) + +@interface NSLevelIndicator : NSControl +{ +} + +- (double) maxValue; +- (void) setMaxValue: (double)val; +- (double) minValue; +- (void) setMinValue: (double)val; +- (double) warningValue; +- (void) setWarningValue: (double)val; +- (double) criticalValue; +- (void) setCriticalValue: (double) val; + +- (int) numberOfMajorTickMarks; +- (int) numberOfTickMarks; +- (NSRect) rectOfTickMarkAtIndex: (int)index; +- (void) setNumberOfMajorTickMarks: (int)count; +- (void) setNumberOfTickMarks: (int)count; +- (void) setTickMarkPosition: (NSTickMarkPosition)pos; +- (NSTickMarkPosition) tickMarkPosition; +- (double) tickMarkValueAtIndex: (int)index; + +@end + +#endif /* MAC_OS_X_VERSION_10_4 */ +#endif /* _GNUstep_H_NSLevelIndicator */ diff --git a/Headers/AppKit/NSLevelIndicatorCell.h b/Headers/AppKit/NSLevelIndicatorCell.h new file mode 100644 index 000000000..7d3b7a10d --- /dev/null +++ b/Headers/AppKit/NSLevelIndicatorCell.h @@ -0,0 +1,85 @@ +/* -*-objc-*- + NSLevelIndicatorCell.h + + The level indicator cell class + + Copyright (C) 2007 Free Software Foundation, Inc. + + Author: H. Nikolaus Schaller + Date: 2006 + + This file is part of the GNUstep GUI Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef _GNUstep_H_NSLevelIndicatorCell +#define _GNUstep_H_NSLevelIndicatorCell + +#include "AppKit/NSActionCell.h" +// For the tick mark +#include "AppKit/NSSliderCell.h" + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) + +typedef enum _NSLevelIndicatorStyle +{ + NSRelevancyLevelIndicatorStyle, + NSContinuousCapacityLevelIndicatorStyle, + NSDiscreteCapacityLevelIndicatorStyle, + NSRatingLevelIndicatorStyle +} NSLevelIndicatorStyle; + +@interface NSLevelIndicatorCell : NSActionCell +{ + double _minValue; + double _maxValue; + double _warningValue; + double _criticalValue; + int _numberOfMajorTickMarks; + int _numberOfTickMarks; + NSLevelIndicatorStyle _style; + NSTickMarkPosition _tickMarkPosition; +} + +- (id)initWithLevelIndicatorStyle:(NSLevelIndicatorStyle)style; + +// value handling +- (double)criticalValue; +- (void)setCriticalValue:(double)val; +- (double)maxValue; +- (void)setMaxValue:(double)val; +- (double)minValue; +- (void)setMinValue:(double)val; +- (void)setWarningValue:(double)val; +- (double)warningValue; + + +- (NSLevelIndicatorStyle)style; +- (void)setLevelIndicatorStyle:(NSLevelIndicatorStyle)style; +- (int)numberOfMajorTickMarks; +- (void)setNumberOfMajorTickMarks:(int)count; +- (int)numberOfTickMarks; +- (void)setNumberOfTickMarks:(int)count; +- (NSTickMarkPosition)tickMarkPosition; +- (void)setTickMarkPosition:(NSTickMarkPosition) pos; +- (double)tickMarkValueAtIndex:(int)index; +- (NSRect)rectOfTickMarkAtIndex:(int)index; + +@end + +#endif /* MAC_OS_X_VERSION_10_4 */ +#endif /* _GNUstep_H_NSLevelIndicatorCell */ diff --git a/Images/GNUmakefile b/Images/GNUmakefile index fe9acb225..18ef893b4 100644 --- a/Images/GNUmakefile +++ b/Images/GNUmakefile @@ -125,7 +125,8 @@ page_landscape.tiff \ page_portrait.tiff \ MagnifyGlass.tiff \ GSSearch.tiff \ -GSStop.tiff +GSStop.tiff \ +NSRatingLevelIndicator.tiff -include GNUmakefile.preamble diff --git a/Images/NSRatingLevelIndicator.tiff b/Images/NSRatingLevelIndicator.tiff new file mode 100644 index 0000000000000000000000000000000000000000..66151b40251e2c2c0915fb7b4e12a7baf6de084a GIT binary patch literal 4892 zcmeHKdt6NE8-LDR(_IphOfI=~BP^Cg7dthQq}IKunP!H$nWj->g{4?g+I5R)kx*EK za?5QKTI-f_%eBpJ+b&UynBQ||=5V&3%l`5EZ-4K6&OG1ud7s;P-|u_Qd-(j`V8#N_ z>-F!wl9QA5fWzcP;*Z(AZ~SBaB-n-;y0HN|ny?#UCt94ICQRlH zqv5y|F4S59^hbNLnVEi`Qk6pN8LJVCJV%9$kJF0Po_vK+B98M685bth%9Ij;SSObA zl_FV;P^;2-Xl1dnWPmU5B5%|rt!jm8wVceVP--<{qek++oG_8ctw0+xl@quMW8%~! zLPG^;@`2V!T4TH7PR7bf-|U*1@9Pm+a(QvjlR4c!;6$mdHJA`fazll^#E5-K9Bstm zB%Y;JYtcqZ;uxt=gg6PYnKR`*t0jUApz?)yLhlulIm~g9d*- z)MxmJk^TXJU+{y11*6A=jtv_ZK0YE6>zy=t@|3C5qJ+^gB9S;&B9+Oe&yXt=N|k!% zOii3NK3+E~Au)0GoTQ|=U(K7BJb%H0gH#U1|$!}Z+Rd`9v~4k6cG{IP_t5&UEgH*`MTEAgK_C_NWwrts&o4YM9Z~KlNJM;4kcJ11| zXAhkT#l?q@965UI7@Y`b&z7A#XXJsA2G_2UEVywKSzsiAi30V1K51zD>lMD1jeDQm z6C8Y~XLlL1Gjsu0=nbCGABMni2!LP+g9#7?5>SE;zJe6UfGo&`y>JZ9Llx9Q6JbU;5^lr@ zB7#s5i-}Fd5u%D{VmL4cF(xwRF}5-;FrG7=nL*51%v|PmmN{!UE1s3ls$sjZr?Ruz z_c%Q`YR*xv6*rn&Z02AVZ&umLr&XT0z4=1(=N2-HdzOUdT6b*Znjxr+uinf z>#25xU0$1TdzO7s+nEmT4t4Ezx7T&>b+mE3*YSW;dMCN_=+1q4jxHRRrY^sAz2EJ2 z_gk)adOYg+q&KUNliLvYDIQ;Y?((|P&&+#Bf8~JOf%gZw3>FW`|NO_KKuX}#FNFMS!2&^P$fz+F#zura3Qvq^6S;3feA~p3=tY zW%3;5Jhf0WO50cGlwh9tV$QE~Z_m3j|H8tuMdwp4Evf#dVYy9uzm-$IU9qZkEhEck z!|aWPIe%>Foh!=QxTC6|&2GUDDf>dk?~o_>xc&sl;aD1aX%^FuE`T z7*fV^Mj_)4vlVj?Q^w3@RRibaUU1DI?rxjq_CEFvZ3`R}?Y!GV z`%4|RInM7m)oFOAuFe+DO`U6bcU&sFT<==dt-5=y>$9G$ULAUS^$B*9x~F>NdtU9! z?Dv^>T>t$8UVi2`C~a`n=dMHJhm{U@_MJWAmfuMKf3nX`LIE*)!5DVv(lEPm z+2cJTPJTIYLer$xQ-)4`6qOkrC<1YbWU*}Q44(Xn^0a!LMxzzzdf|?*pHngSJev^FJkN!m9lY4cYkWh7+kzDrm=cWr9c>J2+Lp3b?yg_-M`7qml_pSi1W&$Yb` zh1Lgq6!{zuKPo+*bYl6b>@zz{3(JbmA1p7pxZzUj75O#6_3o98H;&&*zB8!0_Fl#V z?}z0z(|&pUSoUjm9sl>O^$mY|KZ$*s){ytC=y^%wk*0#bR=$}2()(rotM$!3%@waD zuN&UXd860khZG(X4d+F}d%)aJC0A*90zZF4_kZ`NkjLYh)X;43-%_UK8_vIoPseHk z!%*T`5h|6@A^5HWJEWnbI4)qE3A@G00{MvXV~6ljYePxj_J~7fOT!}(TO*F0E({7a zVXaagLZ0g#P`^MV_76Zz`mULw3MO+|BF+;l$5Zk5$LYpVHb07l{=sPDgfG&?xrC>ei?dheSxdc6vSbYQ}uVc)@Qo zim_TMk}-QU)&HsPVBK2}zqj{E#RxRiA)%~Ik=-HIa1T1e{mp + +static Class cellClass; + +@implementation NSLevelIndicator + +/* + * Class methods + */ ++ (void) initialize +{ + if (self == [NSLevelIndicator class]) + { + // Initial version + [self setVersion: 1]; + + cellClass = [NSLevelIndicatorCell class]; + } +} + +/**

Returns the cell Class used by NSLevelIndicator. Used by subclasses.

+

See Also: +setCellClass:

+ */ ++ (Class) cellClass +{ + return cellClass; +} + +/**

Sets the cell Class used by NSLevelIndicator to factoryId. + Used by subclasses.

See Also: +setCellClass:

+ */ ++ (void) setCellClass: (Class)class +{ + cellClass = class; +} + +- (double) maxValue +{ + return [_cell maxValue]; +} + +- (void) setMaxValue: (double) val +{ + [_cell setMaxValue:val]; +} + +- (double) minValue +{ + return [_cell minValue]; +} + +- (void) setMinValue: (double)val +{ + [_cell setMinValue: val]; +} + +- (double) warningValue +{ + return [_cell warningValue]; +} + +- (void) setWarningValue: (double)val +{ + [_cell setWarningValue: val]; +} + +- (double) criticalValue +{ + return [_cell criticalValue]; +} + +- (void) setCriticalValue: (double)val +{ + [_cell setCriticalValue: val]; +} + +- (int) numberOfMajorTickMarks +{ + return [_cell numberOfMajorTickMarks]; +} + +- (void) setNumberOfMajorTickMarks: (int)count +{ + [_cell setNumberOfMajorTickMarks: count]; +} + +- (int) numberOfTickMarks +{ + return [_cell numberOfTickMarks]; +} + +- (void) setNumberOfTickMarks: (int)count +{ + [_cell setNumberOfTickMarks: count]; +} + +- (NSTickMarkPosition) tickMarkPosition +{ + return [_cell tickMarkPosition]; +} + +- (void) setTickMarkPosition: (NSTickMarkPosition)pos +{ + [_cell setTickMarkPosition:pos]; +} + +- (double) tickMarkValueAtIndex: (int)index +{ + return [_cell tickMarkValueAtIndex:index]; +} + +- (NSRect) rectOfTickMarkAtIndex: (int)index +{ + return [_cell rectOfTickMarkAtIndex:index]; +} + +@end diff --git a/Source/NSLevelIndicatorCell.m b/Source/NSLevelIndicatorCell.m new file mode 100644 index 000000000..51e7e780f --- /dev/null +++ b/Source/NSLevelIndicatorCell.m @@ -0,0 +1,467 @@ +/* + NSLevelIndicatorCell.m + + The level indicator cell class + + Copyright (C) 2007 Free Software Foundation, Inc. + + Author: H. Nikolaus Schaller + Date: 2006 + + This file is part of the GNUstep GUI Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include + +#include "AppKit/NSBezierPath.h" +#include "AppKit/NSGraphics.h" +#include "AppKit/NSImage.h" +#include "AppKit/NSLevelIndicatorCell.h" + +@implementation NSLevelIndicatorCell + +- (id) init +{ + return [self initWithLevelIndicatorStyle: NSRatingLevelIndicatorStyle]; +} + +- (id) initWithLevelIndicatorStyle: (NSLevelIndicatorStyle)style +{ + self = [super init]; + if (self) + { + [self setAlignment: NSCenterTextAlignment]; + [self setLevelIndicatorStyle: style]; + //_minValue = 0.0; + if ((style == NSContinuousCapacityLevelIndicatorStyle) || + (style == NSRelevancyLevelIndicatorStyle)) + { + _maxValue = 100.0; + } + else + { + _maxValue = 5.0; + } + [self setDoubleValue: 0.0]; + } + + return self; +} + +- (id) copyWithZone:(NSZone *) zone; +{ + NSLevelIndicatorCell *c = [super copyWithZone: zone]; + + return c; +} + +- (void) dealloc; +{ + [super dealloc]; +} + +- (NSLevelIndicatorStyle) style +{ + return _style; +} + + +- (double) maxValue +{ + return _maxValue; +} + +- (void) setMaxValue: (double)val +{ + _maxValue = val; +} + +- (double) minValue +{ + return _minValue; +} + +- (void) setMinValue:(double) val +{ + _minValue = val; +} + +- (double) criticalValue +{ + return _criticalValue; +} + +- (void) setCriticalValue: (double)val +{ + _criticalValue = val; +} + +- (double) warningValue +{ + return _warningValue; +} + +- (void) setWarningValue: (double)val +{ + _warningValue=val; +} + +- (void) setLevelIndicatorStyle: (NSLevelIndicatorStyle)style +{ + _style = style; +} + +- (int) numberOfMajorTickMarks +{ + return _numberOfMajorTickMarks; +} + +- (void) setNumberOfMajorTickMarks: (int)count +{ + _numberOfMajorTickMarks = count; +} + +- (int) numberOfTickMarks +{ + return _numberOfTickMarks; +} + +- (void) setNumberOfTickMarks: (int)count +{ + _numberOfTickMarks = count; +} + +- (NSTickMarkPosition) tickMarkPosition +{ + return _tickMarkPosition; +} + +- (void) setTickMarkPosition: (NSTickMarkPosition)pos +{ + _tickMarkPosition = pos; +} + +- (double) tickMarkValueAtIndex: (int)index +{ + if ((index < 0) || (index > _numberOfTickMarks)) + { + [NSException raise: NSRangeException + format: @"tick mark index invalid"]; + } + + return _minValue + index * (_maxValue - _minValue) / _numberOfTickMarks; +} + +- (NSRect) rectOfTickMarkAtIndex: (int)index; +{ + if ((index < 0) || (index > _numberOfTickMarks)) + { + [NSException raise: NSRangeException + format: @"tick mark index invalid"]; + } + + // FIXME: Need to cache the cell frame for this + return NSZeroRect; +} + +- (NSSize) cellSize; +{ + // FIXME: sum up all widths and use default height for controlSize + return [super cellSize]; +} + +- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView +{ + NSColor *fillColor; + double value = [self doubleValue]; + double val = (value -_minValue) / (_maxValue -_minValue); + BOOL vertical = (cellFrame.size.height > cellFrame.size.width); + + if (value < _warningValue) + fillColor = [NSColor greenColor]; + else if (value < _criticalValue) + fillColor = [NSColor yellowColor]; + else + fillColor = [NSColor redColor]; + + if (_numberOfTickMarks != 0) + { + // FIXME: this code only works for horizontal frames + float x; + float y0, y1; + float step = _numberOfTickMarks > 1 ? (cellFrame.size.width - 1.0) / (_numberOfTickMarks - 1) : 1.0; + int tick; + + if (_tickMarkPosition == NSTickMarkBelow) + { + cellFrame.origin.y += 8.0; + cellFrame.size.height -= 8.0; + y0 = 4.0; + y1 = 8.0; + } + else + { + cellFrame.size.height -= 8.0; + y0 = cellFrame.size.height; + y1 = y0 + 4.0; + } + + [[NSColor darkGrayColor] set]; + for(x = 0.0, tick = 0; tick <= _numberOfTickMarks; x += step, tick++) + { + [NSBezierPath strokeLineFromPoint: NSMakePoint(x, y0) toPoint: NSMakePoint(x, y1)]; + // FIXME: draw _numberOfMajorTickMarks thick ticks (ignore if more than _numberOfTickMarks) + } + } + + switch(_style) + { + case NSDiscreteCapacityLevelIndicatorStyle: + { + int segments = (int)(_maxValue - _minValue); + // width of one segment + float step = (segments > 0) ? ((vertical ? cellFrame.size.height : cellFrame.size.width) / segments) : 10.0; + int i; + int ifill = val * segments + 0.5; + + for( i = 0; i < segments; i++) + { + // draw segments + NSRect seg = cellFrame; + + if (vertical) + { + seg.size.height = step - 1.0; + seg.origin.y += i * step; + } + else + { + seg.size.width = step - 1.0; + seg.origin.x += i * step; + } + + if (i < ifill) + [fillColor set]; + else + // FIXME: Should not be needed. + [[NSColor controlBackgroundColor] set]; + + // we could also fill with a scaled horizontal/vertical image + NSRectFill(seg); + // draw border + [[NSColor lightGrayColor] set]; + NSFrameRect(seg); + } + break; + } + case NSContinuousCapacityLevelIndicatorStyle: + { + NSRect ind, fill; + + if (vertical) + NSDivideRect(cellFrame, &ind, &fill, cellFrame.size.height * val, NSMinYEdge); + else + NSDivideRect(cellFrame, &ind, &fill, cellFrame.size.width * val, NSMinXEdge); + + [fillColor set]; + // we could also fill with a scaled horizontal/vertical image + NSRectFill(ind); + // FIXME: Not needed + [[NSColor controlBackgroundColor] set]; + NSRectFill(fill); + // draw border + [[NSColor lightGrayColor] set]; + NSFrameRect(cellFrame); + break; + } + case NSRelevancyLevelIndicatorStyle: + { + // FIXME: Not needed + [[NSColor controlBackgroundColor] set]; + NSRectFill(cellFrame); + + [[NSColor darkGrayColor] set]; + if (vertical) + { + float y; + float yfill = val * cellFrame.size.height + 0.5; + + for (y = 0.0; y < yfill; y += 2.0) + { + [NSBezierPath strokeLineFromPoint: NSMakePoint(0.0, y) + toPoint: NSMakePoint(cellFrame.size.width, y)]; + } + } + else + { + float x; + float xfill = val * cellFrame.size.width + 0.5; + for (x = 0.0; x < xfill; x += 2.0) + { + [NSBezierPath strokeLineFromPoint: NSMakePoint(x, 0.0) + toPoint: NSMakePoint(x, cellFrame.size.height)]; + } + } + break; + } + case NSRatingLevelIndicatorStyle: + { + NSImage *indicator = [self image]; + NSSize isize; + + if (!indicator) + indicator = [NSImage imageNamed: @"NSRatingLevelIndicator"]; + + isize = [indicator size]; + + // FIXME: Not needed + [[NSColor controlBackgroundColor] set]; + NSRectFill(cellFrame); + + if (vertical) + { + int y; + + for (y = 0.0; y < (val + 0.5); y++) + { + NSPoint pos = NSMakePoint(0, y * isize.height + 2.0); + + if (pos.y >= cellFrame.size.height) + break; + + // here we can strech the image as needed by using drawInRect: + [indicator drawAtPoint: pos + fromRect: (NSRect){NSZeroPoint, isize} + operation: NSCompositeCopy + fraction:1.0]; + } + + // FIXME: Should draw place holder for the rest of the cell frame + } + else + { + int x; + + for (x = 0.0; x < (val + 0.5); x++) + { + NSPoint pos = NSMakePoint(x * isize.width + 2.0, 0.0); + + if(pos.x >= cellFrame.size.width) + break; + + [indicator drawAtPoint: pos + fromRect: (NSRect){NSZeroPoint, isize} + operation: NSCompositeCopy + fraction: 1.0]; + } + + // FIXME: Should draw place holder for the rest of the cell frame + } + } + } +} + +- (void) encodeWithCoder: (NSCoder *) aCoder +{ + [super encodeWithCoder:aCoder]; + + if ([aCoder allowsKeyedCoding]) + { + [aCoder encodeDouble: _minValue forKey: @"NSMinValue"]; + [aCoder encodeDouble: _maxValue forKey: @"NSMaxValue"]; + [aCoder encodeDouble: _warningValue forKey: @"NSWarningValue"]; + [aCoder encodeDouble: _criticalValue forKey: @"NSCriticalValue"]; + [aCoder encodeDouble: [self doubleValue] forKey: @"NSValue"]; + [aCoder encodeInt: _style forKey: @"NSIndicatorStyle"]; + [aCoder encodeInt: _numberOfMajorTickMarks forKey: @"NSNumberOfMajorTickMarks"]; + [aCoder encodeInt: _numberOfTickMarks forKey: @"NSNumberOfTickMarks"]; + [aCoder encodeInt: _tickMarkPosition forKey: @"NSTickMarkPosition"]; + } + else + { + [aCoder encodeValueOfObjCType: @encode(double) at: &_minValue]; + [aCoder encodeValueOfObjCType: @encode(double) at: &_maxValue]; + [aCoder encodeValueOfObjCType: @encode(double) at: &_warningValue]; + [aCoder encodeValueOfObjCType: @encode(double) at: &_criticalValue]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_style]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfMajorTickMarks]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfTickMarks]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_tickMarkPosition]; + } +} + +- (id) initWithCoder:(NSCoder *) aDecoder +{ + self = [super initWithCoder:aDecoder]; + + if ([aDecoder allowsKeyedCoding]) + { + if ([aDecoder containsValueForKey: @"NSMinValue"]) + { + _minValue = [aDecoder decodeDoubleForKey: @"NSMinValue"]; + } + if ([aDecoder containsValueForKey: @"NSMaxValue"]) + { + _maxValue = [aDecoder decodeDoubleForKey: @"NSMaxValue"]; + } + if ([aDecoder containsValueForKey: @"NSWarningValue"]) + { + _warningValue = [aDecoder decodeDoubleForKey: @"NSWarningValue"]; + } + if ([aDecoder containsValueForKey: @"NSCriticalValue"]) + { + _criticalValue = [aDecoder decodeDoubleForKey: @"NSCriticalValue"]; + } + if ([aDecoder containsValueForKey: @"NSValue"]) + { + [self setDoubleValue: [aDecoder decodeDoubleForKey: @"NSValue"]]; + } + if ([aDecoder containsValueForKey: @"NSIndicatorStyle"]) + { + _style = [aDecoder decodeIntForKey: @"NSIndicatorStyle"]; + } + if ([aDecoder containsValueForKey: @"NSNumberOfMajorTickMarks"]) + { + _numberOfMajorTickMarks = [aDecoder decodeIntForKey: @"NSNumberOfMajorTickMarks"]; + } + if ([aDecoder containsValueForKey: @"NSNumberOfTickMarks"]) + { + _numberOfTickMarks = [aDecoder decodeIntForKey: @"NSNumberOfTickMarks"]; + } + if ([aDecoder containsValueForKey: @"NSTickMarkPosition"]) + { + _tickMarkPosition = [aDecoder decodeIntForKey: @"NSTickMarkPosition"]; + } + } + else + { + [aDecoder decodeValueOfObjCType: @encode(double) at: &_minValue]; + [aDecoder decodeValueOfObjCType: @encode(double) at: &_maxValue]; + [aDecoder decodeValueOfObjCType: @encode(double) at: &_warningValue]; + [aDecoder decodeValueOfObjCType: @encode(double) at: &_criticalValue]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_style]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfMajorTickMarks]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfTickMarks]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_tickMarkPosition]; + } + + return self; +} + +@end