#import "TestView.h"
#import "PopUpMenu.h"
#import "PowerMenu.h"
#import <dpsclient/psops.h>
#import <appkit/Cell.h>
#import <appkit/color.h>

@implementation TestView



- initFrame:(const NXRect*)rect
{
  id p2, p3;
  
  [super initFrame: rect];

  // now for the real powermenu
  powermenu = [PowerMenu newPopupMenu];
  [powermenu setDefaultTarget:self];
  [powermenu setDefaultAction:@selector(selectionMade:)];

  [powermenu addSelectionAt:0];
  [[[powermenu selectionAt:0] setLabel:"blAh"] setTag:0]; 
  [powermenu addCascadeSelectionAt:1];
  [[[powermenu selectionAt:1] setLabel:"fiLe"] setTag:1]; 
  [powermenu addSelectionAt:2];
  [[[[powermenu selectionAt:2] setLabel:"Miscellaneous"] setTag:2] titleOnly];
  [powermenu addSelectionAt:3];
  [[[[powermenu selectionAt:3] setLabel:"Miscellaneous"] setTag:3] separator];
  [powermenu addSelectionAt:4];
  [[[powermenu selectionAt:4] setLabel:"Power off"] setTag:4];
  [powermenu addSelectionAt:5];
  [[[powermenu selectionAt:5] setLabel:"selection Item"] setTag:5];
  [powermenu addSelectionAt:6];
  [[[powermenu selectionAt:6] setLabel:"fiNd"] setTag:6];
	
  p2 = [PowerMenu newSubmenuOf:powermenu attachToCell:1];
  [p2 setDefaultTarget:self];
  [p2 setDefaultAction:@selector(selectionMade:)];
  [p2 addSelectionAt:0];
  [[[p2 selectionAt:0] setLabel:"saVe"] setTag: 100];
  [p2 addSelectionAt:1];
  [[[p2 selectionAt:1] setLabel:"cloSe"] setTag: 101];
  [p2 addCascadeSelectionAt:2];
  [[[p2 selectionAt:2] setLabel:"oPen"] setTag: 102];
  [p2 addSelectionAt:3];
  [[[p2 selectionAt:3] setLabel:"save as"] setTag: 103];

  p3 = [PowerMenu newSubmenuOf:p2 attachToCell:2];
  [p3 setDefaultTarget:self];
  [p3 setDefaultAction:@selector(selectionMade:)];
  [p3 addSelectionAt:0];
  [[[p3 selectionAt:0] setLabel:"please"] setTag: 200];
  [p3 addSelectionAt:1];
  [[[p3 selectionAt:1] setLabel:"HelP"] setTag: 201];
  [p3 addSelectionAt:2];
  [[[p3 selectionAt:2] setLabel:"my"] setTag: 202];
  [p3 addSelectionAt:3];
  [[[p3 selectionAt:3] setLabel:"fish"] setTag: 203];


  [powermenu dump];
  
  return self;
}



- rightMouseDown:(NXEvent*) event
{
	//[menu popUp: self];
  [powermenu popUp:self];
	return self;
}



- selectionMade: cell
{
	// to get the tag, use [cell tag]
	[textfield setStringValue: [cell title]];
	return self;
}




- drawSelf: (const NXRect*) rect :(int) numRects
{
	NXSetColor(NX_COLORBLUE);
	NXRectFill(&rect[0]);
	return self;
}


@end
