ftp.nice.ch/pub/next/developer/resources/classes/PopUpMenu.0.2.s.tar.gz#/PopUpMenu/PowerMenu.h

This is PowerMenu.h in view mode; [Download] [Up]

#if !defined(PowerMenu_h_)
#define PowerMenu_h_

#import <objc/Object.h>
#import <appkit/Window.h>
#import <appkit/View.h>
#import <appkit/graphics.h>
#import <appkit/color.h>
#import <appkit/Font.h>
#import <appkit/ButtonCell.h>
#import <appkit/ActionCell.h>
#import <appkit/Text.h> // to get alignment defines


#define NX_BUTTONBUTTON 121212

@interface StupidBoxView : View
{
  id contentView;
  int border; // valid box or BUTTONBUTTON above
  float edge; // for NXDrawTiledRects()
  float hOffset, vOffset;

  NXColor foregroundColor;
  NXColor backgroundColor;
}
- init;
- initFrame:(const NXRect*)frameRect;
- drawSelf:(const NXRect*)r :(int)count;
- setContentView:nv;
- contentView;
- sizeToFit;
- setTitlePosition:(int)b;
- setBorderType:(int)b;
- setOffsets:(float)a :(float)b;
- adjustContentViewFrame:(NXRect*)r toView:v;
- setEdgeThickness:(float)e;

@end



#define MAXICONDIM 64 


// something like XmGadget
@interface PowerMenuPrimitiveCell : ActionCell
{
  float borderWidth;
  BOOL sensitive;
  BOOL isHighlighted;

  NXColor bottomShadowColor;
  NXColor highlightColor;
  float highlightThickness;
  float shadowThickness;
  NXColor topShadowColor;
}
- init;
- computeColors:(NXColor)newBackgroundColor;
// does both highlighting via NXFrameRect() and shadows
- drawInside:(const NXRect*)cellFrame inView:aView;
- drawShadow:(const NXRect*)cellFrame inView:aView;
- drawHighlight:(const NXRect*)cellFrame inView:aView;
- drawSelf:(const NXRect*)cellFrame inView:aView;
- setSensitive:(BOOL)f;
- (BOOL)sensitive;
- (BOOL)isSensitive;
- setEnabled:(BOOL)f; // same as setSensitive
- (BOOL)isEnabled;
- highlight; 
- unhighlight;
- setIsHighlighted:(BOOL)f;
- (BOOL)isHighlighted;
- highlight:(const NXRect *)cellFrame inView:controlView lit:(BOOL)flag;
- setBottomShadowColor:(NXColor)c;
- (NXColor)bottomShadowColor;
- setTopShadowColor:(NXColor)c;
- (NXColor)topShadowColor;
- setShadowThickness:(float)sst;
- (float)shadowThickness;
- setHighlightThickness:(float)sht;
- (float)highlightThickness;
- setBorderWidth:(float)bw;
- (float)borderWidth;
@end


#define NX_ARROW_UP    0
#define NX_ARROW_DOWN  1
#define NX_ARROW_LEFT  2
#define NX_ARROW_RIGHT 3

@interface PowerMenuArrowCell : PowerMenuPrimitiveCell
{
  int arrowDirection;
}
+ newUpArrow;
+ newUpArrowFromZone:(NXZone*)z;
+ newDownArrow;
+ newDownArrowFromZone:(NXZone*)z;
+ newLeftArrow;
+ newLeftArrowFromZone:(NXZone*)z;
+ newRightArrow;
+ newRightArrowFromZone:(NXZone*)z;
- init;
- setDirection:(int)newDir;
- drawInside:(const NXRect*)cellFrame inView:aView;
@end




@interface PowerMenuLabelCell : PowerMenuPrimitiveCell
{
  char *accelerator;
  char *label;

  // some stuff for handling the display of the label
  float marginBottom;
  float marginHeight;
  float marginTop;
  float marginLeft;
  float marginRight;
  float marginWidth;

  Font *font;
}
- init;
- setLabelString:(char*)newLabel;
- drawLabel:(const NXRect*)cellFrame inView:aView;
- drawInside:(const NXRect*)cellFrame inView:aView;
- drawShadow:(const NXRect*)cellFrame inView:aView;
- drawHighlight:(const NXRect*)cellFrame inView:aView;
- (const char*)label;
- free;
- setFont:font;
- font;
- getTitleRect:(NXRect*)r;
- getDrawRect:(NXRect*)r;
@end







@interface PowerMenuPushButtonCell : PowerMenuLabelCell
{
  id _target;
  SEL _msg;
}
- init;
- setTarget:t;
- target;
- setAction:(SEL)msg;
- (SEL)action;
- drawInside:(const NXRect*)cellFrame inView:aView;
@end


// assumes flipped view for drawing
@interface PowerMenuCell : PowerMenuPushButtonCell
{
  float height;
  int seqNum;
  BOOL active;
  BOOL displayable;
  NXColor inactiveForegroundColor;
  char *shortcut;
  BOOL isSeparator;
  BOOL alwaysDisplayWithForeground;
  int alignment;
  float pretendIconDim; // for good alignment 

  id submenu;
  id icon;
  int mappingDelay;

}
+ initialize;
- setAssumeIconDim:(float)f;
- setBezeled:(BOOL)f; // not allowed
- setBordered:(BOOL)f; // not allowed
- setSeparator:(BOOL)f;
- (BOOL)isSeparator;
- init;
- setLabel:(const char*)l;
- setIcon:(const char*)iconName;
- (const char*)title;
- free;
- (const char*)icon;
- submenu;
- setSubmenu:s;
- (BOOL)hasSubmenu;
- (BOOL)hasIcon;
- (const char*)label;
- (const char*)title;
- calcCellSize:(NXSize*)s;
- getPullmenuArrowRect:(NXRect*)r;
- getDrawRect:(NXRect*)r;
- getTitleRect:(NXRect*)r;
- getIconRect:(NXRect*)r;
- drawInside:(const NXRect *)cellFrame inView:controlView;
- drawLabel:(const NXRect*)cellFrame inView:aView; // override
- drawSelf:(const NXRect*)cellFrame inView:aView;
- titleOnly; // for text, but not a menu option
- blank; // for space in your menu
- separator; // only draws a solid line
@end

  

@interface PowerMenuCascadeCell : PowerMenuCell
{
  id cascadeIcon;
  NXSize cascadeIconSize;
  //float mappingDelay;
}
- init;
- drawInside:(const NXRect*)cellFrame inView:aView;
- drawCascadeIcon:(const NXRect*)cellFrame inView:aView;
- setCascadeIcon:newIcon;
- calcCellSize:(NXSize*)s;
@end



@interface CoreView : View
{
  NXColor backgroundColor;
  NXColor borderColor;
  float borderWidth;

  BOOL sensitive;
}
- initFrame:(const NXRect*)r;
- setBorderWidth:(float)f;
- (float)borderWidth;
- setBackgroundColor:(NXColor)fc;
- (NXColor)backgroundColor;
- setSensitive:(BOOL)f;
- (BOOL)sensitive;
- (BOOL)isSensitive;
@end



@interface PrimitiveView : CoreView
{
  NXColor bottomShadowColor;
  NXColor foregroundColor;
  NXColor highlightColor;
  float highlightThickness;
  float shadowThickness;
  NXColor topShadowColor;
  
}
- initFrame:(const NXRect*)r;
- drawSelf:(const NXRect*)r :(int)c;
- computeColors:(NXColor)newBackgroundColor;
- setForegroundColor:(NXColor)fc;
- (NXColor)foregroundColor;
- setShadowThickness:(float)sst;
- (float)shadowThickness;
- setHighlightThickness:(float)sht;
- (float)highlightThickness;
@end





@interface PowerMenu : Window
{
  BOOL inited;
  id view;
  id matrix; // really the PowerMenuView 
  id boxView;
  Window *window; // really just self, old code needs it
  float defaultCellWidth;
  float defaultCellHeight;
  id defaultTarget;
  SEL defaultMsg;

  id attachedMenu; // used during mouse navigation
  id supermenu; // if nil then root menu, else submenu to some menu
  int lastrow;
  int lastItem;
  BOOL shouldLoop;
  int lastSelection;

  BOOL cellsAreDirty;
  BOOL cellsNeedDisplay;

  NXPoint popupPoint;
}
+ newPopupMenu;
+ newPopupMenuFromZone:(NXZone*)zone;
+ newSubmenuOf:theSupermenu attachToCell:(int)cellIndex;
+ newSubmenuOf:theSupermenu attachToCell:(int)cellIndex fromZone:(NXZone*)zone;

- setDefaultAction:(SEL)msg;
- setDefaultTarget:t;
- setTarget:t;
- selectionAt:(int)index; // returns a menu cell
- addSelectionAt:(int)index;
- addCascadeSelectionAt:(int)index;
- (Font*)defaultFont;
- init;
- window;
- popUp:senderView; // should be view where mouse action occurred
- popDown:sender;
- setMenuPopupPoint:(const NXPoint*)p;
- setMenuCellClass:newClass;
- recache;
- dump;
- defaultTarget;
- (SEL)defaultAction;
- cellAt:(int)row :(int)col;
- getLocation:(NXPoint *)theLocation forSubmenu:aSubmenu;;
- (BOOL)trackMouse:(NXPoint*)viewPoint ofView: aView;
- (BOOL)rightMouseUp:(NXPoint*)viewPoint ofView:aView;
- getLocation:(NXPoint *)theLocation forSubmenu:aSubmenu;
- setSupermenu:sm;
- supermenu;
- addSubmenu:sm toSelection:(int)i;
@end



// This will mostly act like a matrix
@interface PowerMenuView : PrimitiveView
{
  id menu;

  float minimumMenuHeight;
  float minimumMenuWidth;

  float pullmenuIconWidth;

  BOOL drawButtonBorder;

  float *topOfCells; // a cache for speedy mouse ops
  PowerMenuCell **cells;
  int numCells;

  id menuCellClass;
  id cascadeMenuCellClass;

  float defaultCellWidth;
  float defaultCellHeight;
  id defaultTarget;
  SEL defaultMsg;
  Font *defaultFont;

  BOOL cellsAreDirty;

  int selectedCol;
  int selectedRow;
  id selectedCell;
}
- defaultFont;
- recache;
- setMenuCellClass:newClass;
- setCascadeMenuCellClass:newClass;
- addCascadeSelectionAt:(int)index;
- addSelectionAt:(int)index;
- makeCellAt:(int)row :(int)col;
- selectedCell;
- selectCellAt:(int)row :(int)col;
- selectCell:c;
- initFrame:(const NXRect*)r;
- drawSelf:(const NXRect*)r :(int)c;
- setMenu:m;
- menu;
- highlightCellAt:(int)r :(int)c lit:(BOOL)f;
- getCellFrame:(NXRect*)rect at:(int)r :(int)c;
- sizeToFit;
- sizeToCells;
- getRow:(int *)row andCol:(int *)col ofCell:aCell;
- getRow:(int *)row andCol:(int *)col forPoint:(const NXPoint *)aPoint;
- cellAt:(int)row :(int)col;
@end


@interface PowerMenuBar : PrimitiveView
{
  id cell; // the title cell
  NXRect cellRect;
}
- initFrame:(const NXRect*)r;
- drawSelf:(const NXRect*)r :(int)c;
- mouseDown:(NXEvent*)e;
- setCell:newCell;
- cell;
@end






#endif


These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.