(This file is not a reference manual, it contains a more
readable version of the CI2 header file.)



Applicable enumerated appearance attributes:
--------------------------------------------

typedef enum gprColor { GPR_WHITE, GPR_BLACK, GPR_RED,
						GPR_GREEN, GPR_BLUE, GPR_YELLOW };
typedef enum gprFill  { GPR_NONE, GPR_SOLID, GPR_LGRAY, GPR_DGRAY };
typedef enum gprAlign { GPR_BEGINNING, GPR_CENTER, GPR_END };


Applicable beavior attributes:
------------------------------

typedef unsigned int ciAttrib;

#define MARKABLE		SELECT
#define MOVEABLE		MOVE
#define RESIZEABLE		RESIZE_ANY
#define SELECTABLE		0x0400
#define ACTIVATEABLE	0x0800
#define CHANGEABLE		0x0A00

#define RESIZE_TOP_LEFT 0x0002
#define RESIZE_TOP_CENTER 0x0004
#define RESIZE_TOP_RIGHT 0x0008
#define RESIZE_CENTER_LEFT 0x0010
#define RESIZE_CENTER_RIGHT 0x020
#define RESIZE_BOTTOM_LEFT 0x040
#define RESIZE_BOTTOM_CENTER 0x080
#define RESIZE_BOTTOM_RIGHT 0x0100

#define CI_DEFAULT_ATTRIBUTES MARKABLE | MOVEABLE | RESIZEABLE

Possible object state values:
-----------------------------

typedef short ciState;

#define NORMAL			0x00
#define MARKED			SELECTED
#define PRIMARY_MARKED	PRIMARY_SELECTION
#define DISABLED		0x04

Interaction primtives for setting callbacks:
--------------------------------------------

typedef enum ciPrim { 	Mark, Move, Assign,
						Resize, Select, Activate,
						ChangeContents, ChangeData };

Misc structures and defines:
----------------------------

struct ciMethod;
struct ciClientData;

#define CI_DEFAULT_NAME "unnamedObject"
#define GPR_DEFAULT_FONT "fixed"
#define GPR_DEFAULT_COLOR GPR_BLACK
#define GPR_DEFAULT_FILL GPR_NONE

// callback clientData constants

#define CB_CI_DATA CB_XM_DATA
#define CB_CLASS_NAME ((void* )10L)

// ciClientData opcodes

#define OP_ADD 1
#define OP_REMOVE 2

// getChildren search codes

#define CH_THIS 0		// only direct children of the receiver
#define CH_SHALLOW 1	// root of each subhierarchy matching given status
#define CH_ALL 2		// all children in any depth


struct gprPoint {
    short x;
	short y;

	gprPoint()					{ x = y = 0; }
	gprPoint(int nx, int ny)	{ x = nx; y = ny; }
	gprPoint(gprPoint& p)		{ x = p.x; y = p.y; }
};


class DrawPrim : public XmRootClass {
	...
public:
	DrawPrim* addPoint(int x, int y);
	DrawPrim* setPoints(int count, ...);

	DrawPrim* setText(char* string, char* fontName = NULL);
	DrawPrim* setFont(char* fontName);

	DrawPrim* lineWidth(int n);
	DrawPrim* lineStyle(int on, int off = 0);
	DrawPrim* lineColor(gprColor c);
	DrawPrim* fillColor(gprColor c);
	DrawPrim* linePattern(gprFill f);
	DrawPrim* fillPattern(gprFill f);
	DrawPrim* textHorzAlign(gprAlign a);
	DrawPrim* textVertAlign(gprAlign a);

	bool containsPoint(gprPoint p);

	gprPoint origin();	// world relative origin
	gprPoint extent();	// world relative extent
	gprPoint corner();	// world relative corner
	gprPoint center();	// world relative center

	char* getText();
	char* getFontName();

	bool hide();
	bool show();
	bool update();

	void dumpOn(ostream&);
};

DrawPrim subclasses:
--------------------
Each constructor takes the following trailing parameters:

int lineWidth = 1,                   // for Text default = 0
gprColor color = GPR_DEFAULT_COLOR,  // valid for line and area fill
gprFill fill = GPR_DEFAULT_FILL      // valid for area fill only

class Dot : public DrawPrim {
public:
	Dot(int x, int y, <attr...>);
};

class PolyLine : public DrawPrim {
public:
	PolyLine(<attr...>);			  // setPoints() used to define path
};

class Line : public PolyLine {
public:
	Line(int x1, int y1, int x2, int y2, <attribs...>);
};

class Polygon : public DrawPrim {
public:
	Polygon(<attr...>);			  	  // setPoints() used to define path
};

class Rectangle : public DrawPrim {
public:
	Rectangle(int x, int y, int widht, int height, <attr...>);
};

class Circle : public DrawPrim {
public:
	Circle(int x, int y, int diameter, <attr...>);
};

class Ellipse : public DrawPrim {
public:
	Ellipse(int x, int y, int widht, int height, <attr...>);
};

class Text : public DrawPrim {
public:
	Text(int x, int y, char* string, char* fontName = NULL, <attr...>);
};


////////////////////////////////////////////////////////////////////////////

class CiObject : public DrawPrim {
	...
protected:
	int findMethod(char* methodName, char* parameterTypeString);
	bool registerMethod(char* methodName, cbProc memberFunc,
						char* parameterTypeString = NULL);
public:
	CiObject(DrawPrim* shape, char* name = CI_DEFAULT_NAME,
			 ciAttrib attr = CI_DEFAULT_ATTRIBUTES);
	virtual ~CiObject();

	virtual char* className()	{ return("ObjectClass"); }

	CiObject* addChild(CiObject* obj, bool createPresentation = TRUE);
	CiObject* removeChild(CiObject* obj, bool destroyPresentation = FALSE);
	CiObject* child(int index);
	int childrenCount();

	CiObject** getChildren( int getCode = CH_THIS, ciState desired = -1,
							CiObject** retArray = NULL, int* count = NULL);
	
	void changeName(char* newName);
	CiObject* setInitialOrigin(int x, int y);
	bool setAttributes(ciAttrib, bool);

	bool setCallback(ciPrim primitive, CiObject* receiver, cbProc memberFunc,
					 bool setOrReset = TRUE, bool = FALSE,
					 void* clientData = CB_OBJ_PTR);
	bool setCallback(ciPrim primitive, XmObject* receiver, cbProc memberFunc,
					 bool setOrReset = TRUE, bool = FALSE,
					 void* clientData = CB_OBJ_PTR);

	bool disable();
	bool enable();

	bool mark(bool notify = FALSE);
	bool unmark(bool notify = FALSE);;
	bool move(int new_x, int new_y, bool notify = FALSE);
	bool assign(CiObject* new_parent, int x, int y, bool notify = FALSE);
	bool resize(int new_width, int new_height, bool notify = FALSE);
	bool changeData(void* data, bool notify = FALSE);

	char* getName();
	char* getClassName();
	bool isA(char* classNameString);
	CiObject* getParent();
	XmCiWorld* getWorld();
	bool wasAssigned();
	bool wasMoved();

	gprPoint relOrigin();	// parent relative origin
	gprPoint relCorner();	// parent relative corner
	gprPoint relCenter();	// parent relative object center

	bool getState(ciState);
	void makeRelative(int& x, int& y);	// world coords to parent coords
	void makeAbsolute(int& x, int& y);	// parent coords to world coords

	void toForeground(bool redisplay = TRUE);
	void toBackground(bool redisplay = TRUE);

	void allowAssignmentOf(char*, ...);
	void denyAssignmentOf(char*, ...);
	void allowAssigningTo(char*, ...);
	void denyAssigningTo(char*, ...);

	bool msg(char*, char* = NULL, void* = NULL);
};

////////////////////////////////////////////////////////////////////////////

class XmDrawing : public XmControl {
	...
public:
	XmDrawing(char* name, int x = 0, int y = 0, int w = 0, int h = 0,
			  xmStyle style = XmSautovscroll);
	~XmDrawing();

	void setGrid(int n);
	int getGrid();
	void setBackground(gprColor);
	void setDefaultFont(char* fn);
	...
	void refresh(bool updatePrimitives = FALSE);
	virtual void clearAll(bool = FALSE);
	...
	void bell(bool = FALSE);
};

class XmCiWorld : public XmDrawing {
	...
public:
	XmCiWorld(char*, int = 0, int = 0, int = 0, int = 0);
	~XmCiWorld();

	CiObject* addChild(CiObject*);
	CiObject* removeChild(CiObject*);
	CiObject* child(int index);
	CiObject* childAt(gprPoint loc);
	int childrenCount();

	CiObject** getChildren( int code = CH_THIS, ciState = -1,
							CiObject** = NULL, int* = NULL);
	...
};

////////////////////////////////////////////////////////////////////////////

struct ciMethod {
	char* msgName;
	char* paramType;
	cbProc callback;

	ciMethod(char* n, char* pt, cbProc p);
	~ciMethod();

	bool match(char* n, char* pt);
};

struct ciClientData {
	bool* answer;
	void* clientData;
	int x, y;
	CiObject* obj;
	int operation;

	ciClientData(bool& a, void* cd, int nx, int ny, CiObject* ob, int op);

	CiObject* clientObject();
};

