home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
g
/
gina15.zip
/
demos
/
gredit
/
GraphicEditorD
< prev
next >
Wrap
Text File
|
1992-02-27
|
4KB
|
124 lines
// This may look like C code, but it is really -*- C++ -*-
// Module : GraphicEditorDocument.C Version 1.2
// LastSCCS : 2/26/92 16:36:59
// LastEdit : "Thu Feb 20 13:37:47 1992"
// Description :
// Author :
// Copyright : GMD Schloss Birlinghoven
META_IMPL_1(GraphicEditorDocument,GnDocument,);
GraphicEditorDocument::
GraphicEditorDocument()
{
}
void GraphicEditorDocument ::
create_windows(int new_width, int new_height)
{
main_shell = new GnDocumentShell( this, new_width, new_height);
main_shell->create(GnApplication::get()->get_application_shell(), "shell");
// Put everything in a form widget
GnForm *form = new GnForm;
form->create(this->main_shell, "docForm");
// Add items to the palette
palette.add(new DrawModeItem(arrow_bits, arrow_width, arrow_height,
eSelect));
palette.add(new DrawModeItem(rectangle_bits, rectangle_width,
rectangle_height, eRectangle));
palette.add(new DrawModeItem(square_bits, square_width, square_height,
eSquare));
palette.add(new DrawModeItem(ellipse_bits, ellipse_width, ellipse_height,
eEllipse));
palette.add(new DrawModeItem(circle_bits, circle_width, circle_height,
eCircle));
palette.add(new DrawModeItem(triangle_bits, triangle_width,
triangle_height, eTriangle));
palette.add(new DrawModeItem(glyph_bits, glyph_width, glyph_height,
eText));
// Configuration of the palette
palette.setR_orientation(XmVERTICAL);
palette.setR_label_string("Select Drawing Mode");
palette.setR_leftAttachment(XmATTACH_FORM);
palette.setR_topAttachment(XmATTACH_FORM);
palette.create(form, "palette");
GnStaticScrolledWindow *scroller = new GnStaticScrolledWindow;
scroller->setR_leftAttachment(XmATTACH_WIDGET);
scroller->setR_leftWidget(palette);
scroller->setR_rightAttachment(XmATTACH_FORM);
scroller->setR_topAttachment(XmATTACH_FORM);
scroller->setR_bottomAttachment(XmATTACH_FORM);
scroller->create(form, "scrolledWindow");
this->main_view = new GraphicEditorView(this);
this->main_view->setR_width(1200);
this->main_view->setR_height(1200);
this->main_view->create(scroller, "mainView");
palette.add_selectionCallback(CALLBACK(GraphicEditorView,
ChangeMode, main_view));
main_shell->add_menu_command("Draw", "Clear All",
CALLBACK(GraphicEditorDocument,
ClearAllObjects, this));
main_shell->add_menu_command("Draw", "Thin Lines",
CALLBACK1(GraphicEditorView,
NewLineWidth, main_view, int, 0));
main_shell->add_menu_command("Draw", "1 Pixel Lines",
CALLBACK1(GraphicEditorView,
NewLineWidth, main_view, int, 1));
main_shell->add_menu_command("Draw", "2 Pixel Lines",
CALLBACK1(GraphicEditorView,
NewLineWidth, main_view, int, 2));
main_shell->add_menu_command("Draw", "3 Pixel Lines",
CALLBACK1(GraphicEditorView,
NewLineWidth, main_view, int, 3));
main_shell->add_menu_command("Draw", "4 Pixel Lines",
CALLBACK1(GraphicEditorView,
NewLineWidth, main_view, int, 4));
main_shell->add_menu_command("Draw", "5 Pixel Lines",
CALLBACK1(GraphicEditorView,
NewLineWidth, main_view, int, 5));
}
void GraphicEditorDocument::
wipe_out()
{
GnViewObjectList *list = main_view->get_view_objects();
GnViewObject *obj;
while( ! list->Empty() ) {
obj = list->First();
obj->deinstall(False);
delete obj;
}
}
void GraphicEditorDocument ::
ClearAllObjects(caddr_t )
{
(new ClearAll( this ))->submit();
}
XBoolean GraphicEditorDocument ::
write_to_stream( ostream &ofs )
{
((GraphicEditorView*)main_view)->write_to_stream( ofs );
return True;
}
XBoolean GraphicEditorDocument ::
read_from_stream ( istream &ifs )
{
((GraphicEditorView*)main_view)->read_from_stream( ifs );
return True;
}