#ifndef _OBJECTS_H_ #define _OBJECTS_H_ #include #include "mystring.h" // a forward declaration for Window class Window; // a use of inheritance--all the graphical objects are subclasses // of GraphicalObject class GraphicalObject { friend Window; protected: Am_Object graphicsObj; }; class Window : public GraphicalObject { public: // The name is optional and can be used for matching an object // created in your program with one shown in the inspector window Window(string name = "window") { graphicsObj = Am_Window.Create(name.c_str()); Am_Screen.Add_Part(graphicsObj); } // Methods for setting graphical properties void setLeft(int x) { graphicsObj.Set(Am_LEFT, x); } void setTop(int y) { graphicsObj.Set(Am_TOP, y); } void setWidth(int w) { graphicsObj.Set(Am_WIDTH, w); } void setHeight(int h) { graphicsObj.Set(Am_HEIGHT, h); } // Methods for querying graphical properties int getLeft() { return (int)graphicsObj.Get(Am_LEFT); } int getTop() { return (int)graphicsObj.Get(Am_TOP); } int getWidth() { return graphicsObj.Get(Am_WIDTH); } int getHeight() { return graphicsObj.Get(Am_HEIGHT); } // Method for adding an object to a window void addObject(GraphicalObject *obj) { graphicsObj.Add_Part(obj->graphicsObj); } }; class Line : public GraphicalObject { public: // The name is optional and can be used for matching an object // created in your program with one shown in the inspector window Line(string name = "line") { graphicsObj = Am_Line.Create(name.c_str()); } // Methods for setting graphical properties void setX1(int x) { graphicsObj.Set(Am_X1, x); } void setX2(int x) { graphicsObj.Set(Am_X2, x); } void setY1(int y) { graphicsObj.Set(Am_Y1, y); } void setY2(int y) { graphicsObj.Set(Am_Y2, y); } void setLineStyle(Am_Style line_style) { graphicsObj.Set(Am_LINE_STYLE, line_style); } // Methods for querying graphical properties int getX1() { return (int)graphicsObj.Get(Am_X1); } int getX2() { return (int)graphicsObj.Get(Am_X2); } int getY1() { return (int)graphicsObj.Get(Am_Y1); } int getY2() { return (int)graphicsObj.Get(Am_Y2); } Am_Style getLineStyle() { return (Am_Style)graphicsObj.Get(Am_LINE_STYLE); } }; class Text : public GraphicalObject { public: // The name is optional and can be used for matching an object // created in your program with one shown in the inspector window Text(string name = "text") { graphicsObj = Am_Text.Create(name.c_str()); } // Methods for setting graphical properties void setLeft(int x) { graphicsObj.Set(Am_LEFT, x); } void setTop(int y) { graphicsObj.Set(Am_TOP, y); } void setLineStyle(Am_Style line_style) { graphicsObj.Set(Am_LINE_STYLE, line_style); } void setText(string s) { graphicsObj.Set(Am_TEXT, s.c_str()); } // Methods for querying graphical properties int getLeft() { return (int)graphicsObj.Get(Am_LEFT); } int getTop() { return (int)graphicsObj.Get(Am_TOP); } int getWidth() { return graphicsObj.Get(Am_WIDTH); } int getHeight() { return graphicsObj.Get(Am_HEIGHT); } Am_Style getLineStyle() { return (Am_Style)graphicsObj.Get(Am_LINE_STYLE); } string getText() { return string((char *)(Am_String)graphicsObj.Get(Am_TEXT)); } }; #endif