home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / MiscKit1.2.6 / Palettes / MiscCircularSlider / MiscCircularSlider.subproj / MiscCircularSlider.m < prev    next >
Encoding:
Text File  |  1994-03-26  |  3.1 KB  |  151 lines

  1. //
  2. //    MiscCircularSlider.m -- a cover for the MiscCircularSliderCell class
  3. //        Written by Vince DeMarco and Don Yacktman, 
  4. //        Copyright (c) 1994 by Vince DeMarco and Don Yacktman.
  5. //                Version 1.0  All rights reserved.
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This object is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. // This was created by modifying Vince's CircularSlider class and
  15. // merging it with Don's RotationSlider class.  Here's the info
  16. // from the original files.
  17. /*
  18.  *    Filename: CircularSlider.m
  19.  *    Created : Sat 24 21:25:44 1991
  20.  *    Author  : Vince DeMarco <vince@whatnxt.cuc.ab.ca>
  21.  *    LastEditDate Was "Mon Sep  6 16:32:15 1993"
  22.  *
  23.  *    Version 2.0
  24.  */
  25. //    RotationSlider.m -- written by Don Yacktman
  26. //    Copyright 1993 by Don Yacktman.  All rights reserved.
  27.  
  28. #import "MiscCircularSlider.h"
  29.  
  30. static id MiscCircularSliderCellClass;
  31.  
  32. @implementation MiscCircularSlider
  33.  
  34. + initialize
  35. {
  36.     if (self == [MiscCircularSlider class]) {
  37.         MiscCircularSliderCellClass = [MiscCircularSliderCell class];
  38.         // the default class
  39.     }
  40.     return self;
  41. }
  42.  
  43. + setCellClass:classId
  44. {
  45.     MiscCircularSliderCellClass = classId;
  46.     return self;
  47. }
  48.  
  49. - initFrame:(NXRect *)nf
  50. {
  51.     [super initFrame:nf];
  52.     [[self setCell:[[MiscCircularSliderCellClass alloc] init]] free];
  53.     return self;
  54. }
  55.  
  56. - setBezeled:(BOOL)value
  57. {
  58.     BOOL old = [cell isBezeled];
  59.     [cell setBezeled:value];
  60.     if (old != value) [self display];
  61.     return self;
  62. }
  63.  
  64. - (BOOL)isBezeled
  65. {
  66.     return [cell isBezeled];
  67. }
  68.  
  69. - setBordered:(BOOL)value
  70. {
  71.     BOOL old = [cell isBordered];
  72.     [cell setBordered:value];
  73.     if (old != value) [self display];
  74.     return self;
  75. }
  76.  
  77. - (BOOL)isBordered
  78. {
  79.     return [cell isBordered];
  80. }
  81.  
  82. - setJumpToMousePoint:(BOOL)aBOOL
  83. {
  84.     [cell setJumpToMousePoint:aBOOL];
  85.     return self;
  86. }
  87.  
  88. - (BOOL)jumpToMousePoint
  89. {
  90.     return [cell jumpToMousePoint];
  91. }
  92.  
  93. - setHidden:(BOOL)aBOOL
  94. {
  95.     BOOL old = [cell hidden];
  96.     [cell setHidden:aBOOL];
  97.     if (aBOOL != old) [self display];
  98.     return self;
  99. }
  100.  
  101. - (BOOL)hidden
  102. {
  103.     return (BOOL)[cell hidden];
  104. }
  105.  
  106. - setSliderStyle:(MiscCircularSliderStyle)style
  107. {
  108.     MiscCircularSliderStyle old = [cell sliderStyle];
  109.     [cell setSliderStyle:style];
  110.     if (style != old) [self display];
  111.     return self;
  112. }
  113.  
  114. - (MiscCircularSliderStyle)sliderStyle
  115. {
  116.     return (MiscCircularSliderStyle)[cell sliderStyle];
  117. }
  118.  
  119. - setSliderPathWidth:(float)value
  120. {
  121.     [cell setSliderPathWidth:value];
  122.     return self;
  123. }
  124.  
  125. - (float)sliderPathWidth
  126. {
  127.     return [cell sliderPathWidth];
  128. }
  129.  
  130. @end
  131.  
  132.  
  133. @implementation MiscCircularSlider(Compatability)
  134.  
  135. // Two covers to make sure we implement the methods that were used by Vince's
  136. // CircularSlider.  This way, code that used that slider will still work as
  137. // it did before with this new class dropped in instead.
  138.  
  139. - setDrawAsPieChart:(BOOL)aBOOL
  140. {
  141.     return [self setSliderStyle:
  142.             (aBOOL ? MISC_PIECHART_STYLE : MISC_DIAL_STYLE)];
  143. }
  144.  
  145. - (BOOL)drawAsPieChart
  146. {
  147.     return (BOOL)([self sliderStyle] == MISC_PIECHART_STYLE);
  148. }
  149.  
  150. @end
  151.