COP4226 Assignment 3
Part I: Due Saturday, 4/1 at 6 pm.
Part I
Make sure your application is object oriented!
If you have written a helper method that has many references to the members
of a class, then perhaps there should be a method for this operation in your
class. I will be looking for object oriented design when I grade the assignment.
Create a Single Document Interface Application
-
Create a new project. Copy my
SdiBase.dll
and
SdiBase.pdb
into the application directory and add a reference
to it. The application directory is the location of your main form.
ZIP of SdiBaseSimple.
-
Create two views that extend
SdiBase.SdiView
. One view will
display text drawn in rectangles (drawing view), the other view will
show the corresonding data in a ListView
(list view).
-
Create a document that extends
SdiBase.SdiDoc
.
-
Extend the main form class from
SdiBase.SdiMainForm
.
-
Do not change my files. All changes should be in your extended classes.
MainForm
-
Dock a scrollable panel to the top of the client area.
-
Add a drawing view and a list view to this panel.
-
Dock a splitter to the scrollable panel.
-
When resizing the main form smaller, do not let the splitter disappear. When
the form is small enough so that the bottom panel is not seen, then position
the splitter so that it is visible at the bottom of the client area.
-
When enlarging the form, if the splitter is at the bottom of the client area
so that the bottom panel is not visible, then keep the splitter there until
the user moves it manually.
-
Add a status bar.
-
Be sure that the status bar is in front of the splitter and first panel.
-
Update the status bar as the user clicks in the client area.
-
Dock another scrollable panel that will fill the remaining client area.
-
Be sure that this panel is in front of the status bar, or the scrollbars
will be partially hidden by the status bar.
-
Add a drawing view and a list view to this panel.
-
Add a main menu.
-
File
-
View
-
Drawing: Switch to the drawing view for the active scrolling panel.
-
List: Switch to the drawing view for the active scrolling panel.
-
Edit
-
Default Values: Open a modal dialog where the default colors, text, font
and shear can be set.
-
Open the dialog next to the main form.
Add a data class to your project
-
Make the class serializable.
-
Add a copy constructor.
-
Add variables to the class to store a rectangle's location, size, text, colors,
font, and shear.
-
Add properties to access these variables.
-
Add a method that can be called with a graphics object to draw the rectangle.
-
Add any other variables that you need.
-
Add any other methods that you need.
In the docmuent class
-
Extend your document class from
SdiBase.SdiDoc
.
-
Create an
ArrayList
for instances of your new data class.
-
Add a member of your data class type to store the current default values.
When new rectangles are created in a drawing view, these values will be used
to define how the rectangle will look.
-
Add other members as needed. Any variable that needs to be saved, must be
in the document.
-
Add helper methods as needed, including accessors and mutators for accessing
data in the document.
-
Override the DeleteContents method. The method in the base class already
calls
UpdateAllViews
.
In the Drawing View
-
Set the total size of the view to 700 pixels by 600 pixels.
-
When the left mouse button is dragged and the down point is different from
the up point, add a new data object to the document using the current font,
background color, text color, shear and text.
-
Use the up and down points to calculate the size of the rectangle that will
be drawn.
-
Be sure that the width and height are not negative.
-
The location of the rectangle should be the upper left corner of the rectangle
that is defined by the up and down points.
-
In the paint method, draw all the current data objects in rectangles with
the given font, colors, text and shear.
In the List View
-
Set the total size of the view to 600 pixels by 350 pixels.
-
Add a ListView.
-
Add columns to the list view for the text, shear, foreground color, background
color, font, location, and size.
-
Be sure that the View property is set to
Details
.
Add a dialog
-
Initialize the dialog with the default values in the document.
-
There will be an example rectangle drawn in the dialog that will show the
effect of the changes made in the dialog.
-
The dialog will have a text box for the current text to be displayed in the
rectangle. As it changes, update the text displayed in the example rectangle.
-
There will be a button for selecting the background color.When clicked, open
a color dialog to get a color. If OK is pressed, then update the background
color of the example rectangle.
-
There will be a button for selecting the font and text color.
-
Open the font dialog so that the text color can be changed.
-
If OK is pressed, then update the font and text color used to draw the text
inside the example rectangle.
-
There will be a horizontal scrollbar that will control the horizontal shear
amount. As the scrollbar is moved, update the horizontal shear of the example
rectangle.
-
Add text to identify this scroll bar.
-
There will be a vertical scrollbar that will control the vertical shear amount.
As the scrollbar is moved, update the vertical shear of the example rectangle.
-
Add text to identify this scroll bar. The text should rotated so that it
is vertical.
-
There should be OK and Cancel buttons that have the normal
effects.
-
When the OK is clicked, update the default values in the document with the
current values from the dialog. All new rectangles will be drawn with these
values. Previously drawn rectangles will maintain their previous values.
Additional Features
-
Get a new copy of the SdiBaseSimple files. I have added polymorphic stubs
for some methods.
-
SdiView_Paint
-
SdiView_PrintPage
-
SdiView_QueryPageSettings
-
SdiView_BeginPrint
-
SdiView_EndPrint
-
Override these in your views. This will allow the mainframe to access them
without knowing the exact type of the view.
-
Add options to the File menu.
-
Open - Open a previously saved file.
-
Save - Save the data in the document to a file. Save the default values as
well as the array of data objects. If the file has already been saved, use
that name, call the save as method.
-
Save As - Save the data in the document to a file. Save the default values
as well as the array of data objects.
-
Warn the user if data will be lost. When closing the app, creating a new
file, or opening a file, give the user the chance to save the data in the
document if it has been changed since the last save or open.
-
Add a toolbar with the following icons. Each icon should perform the same
function as the corresponding menu option.
-
File New
-
File Open
-
File Save
-
Modify the drawing view.
-
If a user double-clicks in a rectangle, then open an option dialog with the
rectangle's values filled in. If the user clicks OK, then update the rectangles
data with the new options.
-
If the rectangle is sheared, be sure that double-clicking anywhere in the
sheared rectangle will open the dialog.
-
Modify the list view.
-
When the user double-clicks the text of an item, open an option dialog with
the item's values filled in. If the user clicks OK, then update the
item data with the new options.
-
Add small and large icons.
-
Have two icons in each image list.
-
Use one icon for items that have text that is more than 5 chracters, use
the other icon for shorter items.
-
Add a context menu that allows the user to choose the view mode for the list
view: Details, LargeIcon, SmallIcon, List.