
/* Generated by Interface Builder */

#import "PolyInspector.h"
#import "ListMatrix.h"
#import "TGIFCell.h"
#import <appkit/Application.h>
#import <appkit/Matrix.h>
#import <appkit/NXCursor.h>
#import <appkit/ScrollView.h>
#import <appkit/Window.h>
#import <objc/List.h>

// import command cell objects
#import "CmdBgcolor.h"
#import "CmdBgnpoly.h"
#import "CmdCircle.h"
#import "CmdComment.h"
#import "CmdDraw.h"
#import "CmdEndpoly.h"
#import "CmdFgcolor.h"
#import "CmdFps.h"
#import "CmdHold.h"
#import "CmdMove.h"
#import "CmdNewframe.h"
#import "CmdVertex.h"

#import "AbsPoly.h"

@implementation PolyInspector
- displayMatrix:aMatrix
{
  [aMatrix sizeToCells];
  [aMatrix display];
  return self;
}

- initMatrix
{
  NXRect aRect, bRect;
  NXSize cellSpacing={0.0,0.0}, cellSize;
  
  [poly_view getFrame:&aRect];
  [ScrollView getContentSize:&(bRect.size) forFrameSize:&(aRect.size)
   horizScroller:YES vertScroller:YES borderType:NX_BEZEL];
  
  poly_matrix = [[ListMatrix alloc] initFrame:&bRect mode:NX_LISTMODE
		   cellClass:[TGIFCell class] numRows:0 numCols:1];
  [poly_matrix setIntercell:&cellSpacing];
  [poly_matrix allowEmptySel:YES];
  [poly_matrix setControlDrag:YES];
  
  [poly_matrix getCellSize:&cellSize];
  cellSize.width = NX_WIDTH(&bRect);
  [poly_matrix setCellSize:&cellSize];
  [poly_matrix sizeToCells];
  [poly_matrix setAutosizeCells:YES];
  [poly_matrix setAutoscroll:YES];
  
  [poly_view setDocView:poly_matrix];
  [[poly_matrix superview] setAutoresizeSubviews:YES];
  [poly_matrix setAutosizing:NX_WIDTHSIZABLE];
  
  [poly_matrix setBackgroundGray:NX_LTGRAY];
  [poly_matrix setCellBackgroundGray:NX_LTGRAY];
  [poly_view setBackgroundGray:NX_LTGRAY];
  
  [poly_view setDocCursor:NXArrow];
  [poly_matrix setTarget:self];
  [self displayMatrix:poly_matrix];
  return self;
}

- init
{
  [super init];
  [NXApp loadNibSection:"PolyInspector.nib" owner:self withNames:NO];
  [self initMatrix];
  return self;
}

- addRowTo:newCell
{
  int rc, cc;
  [poly_matrix getNumRows:&rc numCols:&cc];
  [poly_matrix addRow];
  [poly_matrix putCell:newCell at:rc :0];  
  return self;
}

- inspect:aPoly
{
  int rc, cc,i;
  id cellList;

  [poly_matrix getNumRows:&rc numCols:&cc];
  for(i=0;i<rc;i++)
    [poly_matrix removeRowAt:0 andFree:NO];

  cellList=[aPoly commandList];
  for(i=0;i<[cellList count];i++)
    [self addRowTo:[cellList objectAt:i]];
  [self displayMatrix:poly_matrix];
  return self;
}

- window { return poly_window; }
@end
