SBPaint Help and Documentation: ------------------------------- NOTE TO THE WISE: The HotDraw framework must be installed to use this program! General Help: Once the program is started, a toolbar will be displayed. In order to start drawing, the New Board button will need to be pressed. Then, the tools can be used on the drawing board. More drawing boards can be spawned, and graphical elements can be copied from one drawing board to the other. The tools work as follows: New Board: Spawn a new drawing board Select: Select an object so it can be resized or moved, etc Image: Capture an image of the drawing board, and make it an object. Float Object: Also known as BringToFront, this moves the depth of and object forward in comparison to the other objects on the drawing board. Sink Object: Also known as SendToBack, this moves the object back in comparison to the other objects on the drawing board. Text: This creates a text object, and waits for text input. Delete: Deletes objects from the drawing board Polyline: Create a sequence of points that will be connected by a series of line segments. Rectangle: Drag a rectangle of variable size Round Rect: Drag a rectangle of variable size that has rounded corners of varying degree Ellipse: Drag an elliptical shape Arc: Drag a circle, and then select it to edit the degree of arc. Spline: Create a sequence of points that will be connected as pivots of a spline Bezier: Create a line segment that can then be selected and the control points of the bezier cureve edited Canvas: Create an actualy drawing canvas which the following tools can be applied on Paintbrush: Also known as scribble, this allows for freehand drawing on a canvas Spray Can: Also known as a mask, this creates a spray paint like pattern on a canvas. Erase: This erases things from a canvas. The color of the primitives on a drawing board can be changed either through the right click menus, or from the menu at the top of the drawing board. The menu at the top is preferrable, because the color constants are chosen through a custom view of their color, compared to just selecting by the name of the color. Program Notes/Documented Problems: Though the program is error free and runs great, there are a few technical difficulties that should be documented. One is the saving of a drawing board when a canvas exists on it. Since the drawing board is composed of objects, the EXT and PS file format saving tools are designed only to save representations of those objects. The canvas tool creates an object that can't be saved in these formats. So, when a drawing board is saved when a canvas exists on it, an Exception occurs. This is a seemingly unavoidable problem, because the classes used for saving can't handle the representation of the canvas. The largest difference between the design document and the final product is the exclusion of custom tools and bug fixes in tools that were supplied through HotDraw. The HotDraw Tool framework at an initial design glance seemed to allow easy tool manipulation and creation. However, once we started attempting an implemention of custom tools, it turned out to be next to impossible to use HotDraw to do it. The documentation is very poor, and the code is scattered about too many classes too be able to accurately trace how a tool is really created. So, the tools in SBPaint are currently not custom, but rather are from the HotDraw framework. Future Extensions: Further extensions to the project could include the following: -A custom view to choose any color from the representable spectrum (i.e. 256 colors to choose from, or 16.8 million,etc) -Custom Tools and HotDraw tool fixes... If a more complete documentation of the HotDraw framework and state machines is ever developed, it would be more feasible to add in more tools and fix bugs in some current tools. -Extending the file saving to allow for canvas's to be saved, and possibly for BMP files to be read into background images on the drawing board. Reusable Code: The Custom View for color selection can easily be used in another program, and extended to incorporate different colors, etc. The program itself can also easily be extended to allow for the addition of tools and control functionality, by adding methods to the class OurTool and OurDC. SBPaint can be plugged into another program that might need to allow the user to draw a simple diagram, etc.. and then output it to the Smalltalk internal format, for use as the parent program sees fit. From Design Document: --------------------- User-Level Overview: Once the program is started, the toolbar will then be displayed, and it will wait for a user action. The user can then create a drawing board and start to create the desired image through the use of the tools that are located on the toolbar. More drawing boards can be spawned at at will. The typical paint program tools, which will be included in SBPaint are as follows. A few basic tools are a freehand drawing tool, a line drawing tool, a rectangle drawing tool, and a circle drawing tool. As would be expected there will be the ability to change the color of the primitives that are drawn, and the fill color can also be specified. There will be a custom MVC for changing the color of all the primitives in the drawing board. The view will display the predifined color constants specified within the Graphics-support classes, and allow the user to select the color that they want. A few more complex tools that will be included are a bezier curve drawing tool, a tool to draw ovular shapes, a text typing tool, and a spray painting tool. As in a variety of paint programs, the user will be able to save the image to disk for later viewing in other programs. The file formats that will be supported are postscript and the internal Smalltalk file format. Files saved with the internal file format will be allowed to be edited at a later time, whereas bitmaps will be only be able to be used in other programs. Painting will end when the user selects the exit option. The program will cycle through the currently open drawing boards, and ask for each one if the user wishes to save the drawing. HotDraw Framework Overview: Our application will use the HotDraw framework for the custom view in our drawing board. The main classes that we will reuse/extend are the Drawing, DrawingController, and the Tool class. The Tool class will be used to gain extra functionality, or possibly to correct any errors in the current tools. The Drawing class serves as the center of the HotDraw framework. Drawing is the model which receives messages from various HotDraw application actions. Drawing's primary purpose is to keep track of the existing figures for selection on the drawing board. Thus, drawing can ad, remove, select, and change the position of figures in its abstract model of hte picture. These actions will be apparent through modifications to the drawing view that the user sees. Of particular use is Drawing's idea of 'handles'. These handles allow methods to be invoked on existing figures within drawing in order to modify them in various ways (i.e. resizing a rectangle, or modifying them in various ways). The DrawingController, as its name implies, will handle user input. With middle or right mouse buttons, the functionality is the same. From the left mouse button or keyboard, DrawingController's actions are determined by the currently selected drawing tool. For example, if the current tool is "Freehand", dragging the mouse with the left button pressed will result in points/lines beings drawn following the motion of the mouse. On the other hand, if the "Circle" tool is selected, dragging the mouse with the left button pressed and then releasing will result in a circle which is enclosed by the box defined by the start and end points of the operation. Unlike Smalltalk controllers in general, the DrawingController class is responsible to act appropriately given the tool taht is currently selected. Normal controllers have well defined methods for handling the input. In oreder to successfully accomplish its tasks, the DrawingController class relies on Tool objects to handle most of the user input. In fact, the DrawingController passes any left button mouse click or keyboard operation to the currently selected tool. Tool class objects are used by the DrawingController class to handle tool specific commands. All of the input is handled by the tool using the processKeyboard and press methods. These methods take the user input and apply it to the Drawing class for different actions such as resizing a rectangle or adding text to the drawing board. HotDraw uses an interseting mechanism with the tool class. Unlike the immediately intuitive approach, which would be to subclass a particular tool off of a generalized tool class, a tool is divided into different componenets that are contained in a single tool class. According to the HotDraw creator, implementing tools using subclassing would result in large amounts of duplicate code. This is most noticeable in the press and pressKeyboard methods since they would always have to be overridden in all subclasses. This defeats much of the purpose of inheritance, since most of the functionality of the tools is implemented in those functions.