home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Palettes / MiscArrowButtonPalette / MiscArrowButton.subproj / MiscArrowButton.m < prev    next >
Encoding:
Text File  |  1994-01-16  |  2.9 KB  |  136 lines

  1. /******************************************************************
  2.  * CLASS:        MiscArrowButton
  3.  *
  4.  *    See the header for more information on this class.
  5.  *
  6.  * This object is included in the MiscKit by permission from the author
  7.  * and its use is governed by the MiscKit license, found in the file
  8.  * "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  9.  * for a list of all applicable permissions and restrictions.
  10.  *******************************************************************/
  11.  
  12. #import "MiscArrowButtonCell.h"
  13. #import "MiscArrowButton.h"
  14.  
  15.  
  16. static id  myStoredCellClass;
  17.  
  18.  
  19. @implementation MiscArrowButton
  20.  
  21. + initialize
  22. {
  23.     myStoredCellClass = [MiscArrowButtonCell class];
  24.     return self;
  25. }
  26.  
  27.  
  28.  
  29. + setCellClass: classId
  30. {
  31.     myStoredCellClass = classId;
  32.     return self;
  33. }
  34.  
  35.  
  36.  
  37. - init
  38. {
  39.   NXRect frameRect;
  40.  
  41.     // create some frame since none was specified
  42.       
  43.       NXSetRect (&frameRect, 10.0, 10.0, 125.0, 25.0);
  44.     
  45.     return [self initFrame: (const NXRect *)&frameRect title: "Left" 
  46.             altTitle: "Right" tag: 0 target: nil action: NULL key: 0 
  47.             enabled: YES];
  48. }
  49.  
  50.  
  51.  
  52. - initFrame: (const NXRect *)frameRect
  53. {
  54.     return [self initFrame: frameRect title: "Left" altTitle: "Right"
  55.             tag: 0 target: nil action: NULL key: 0 enabled: YES];
  56. }
  57.  
  58.  
  59.  
  60. // The button class's designated initializer for text buttons, which
  61. // now should just call mine.
  62.  
  63. - initFrame:(const NXRect *)frameRect title:(const char *)aString
  64.         tag:(int)anInt target:anObject action:(SEL)aSelector
  65.         key:(unsigned short)charCode enabled:(BOOL)flag
  66. {
  67.     return [self initFrame: frameRect title: aString altTitle: "Right"
  68.             tag: anInt target: anObject action: aSelector 
  69.             key: charCode enabled: flag];
  70. }
  71.  
  72.  
  73.  
  74. // The designated initializer that merely adds the capability to set
  75. // the altTitle (text on the right side of the arrow) while initializing
  76. // the button.
  77.  
  78. - initFrame:(const NXRect *)frameRect title:(const char *)aString
  79.         altTitle: (const char *)altString tag:(int)anInt 
  80.         target:anObject action:(SEL)aSelector
  81.         key:(unsigned short)charCode enabled:(BOOL)flag
  82. {
  83.     [super initFrame: frameRect title: aString tag: anInt target: anObject
  84.             action: aSelector key: charCode enabled: flag];
  85.  
  86.     [self setAltTitle: altString];
  87.     [self setType: NX_TOGGLE];
  88.     [ [self setCell: [ [myStoredCellClass alloc] init] ] free];
  89.     
  90.     return self;
  91. }
  92.  
  93.  
  94.  
  95. // Used to set arrow alignment. (In previous versions, setAlignment was used
  96. // but I realized that I also needed those methods). Sorry for any 
  97. // inconvenience.
  98.  
  99. - setArrowAlignment: (int)alignment
  100. {
  101.     [ [self cell] setArrowAlignment: alignment];
  102.     return self;
  103. }
  104.  
  105.  
  106.  
  107. - (int)arrowAlignment
  108. {
  109.     return [ [self cell] arrowAlignment];
  110. }
  111.  
  112.  
  113.  
  114. // Used to tell the IB which Inspector to use for this
  115. // object. (Used only for palettes)
  116.  
  117. - (const char *)getInspectorClassName
  118. {
  119.     return "ABInspector";
  120. }
  121.  
  122.  
  123.  
  124. //  Here for when NeXT gets around to letting us have editors of our
  125. // own.
  126.  
  127. - (const char *)getEditorClassName
  128. {
  129.     return "ArrowButtonEditor";
  130. }
  131.  
  132. @end
  133.  
  134.  
  135.  
  136.