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 >
Text File  |  1992-02-27  |  4KB  |  124 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2.  
  3. //   Module      : GraphicEditorDocument.C   Version 1.2
  4. //   LastSCCS    : 2/26/92  16:36:59
  5. //   LastEdit    : "Thu Feb 20 13:37:47 1992"
  6. //   Description : 
  7. //   Author      : 
  8. //   Copyright   : GMD Schloss Birlinghoven
  9.  
  10. META_IMPL_1(GraphicEditorDocument,GnDocument,);
  11.  
  12. GraphicEditorDocument::
  13. GraphicEditorDocument()
  14. {
  15. }
  16.  
  17. void GraphicEditorDocument ::
  18. create_windows(int new_width, int new_height)
  19. {
  20.     main_shell = new GnDocumentShell( this, new_width, new_height);
  21.     main_shell->create(GnApplication::get()->get_application_shell(), "shell");
  22.  
  23.     // Put everything in a form widget
  24.     
  25.     GnForm *form = new GnForm;
  26.     form->create(this->main_shell, "docForm");
  27.  
  28.     // Add items to the palette
  29.  
  30.     palette.add(new DrawModeItem(arrow_bits, arrow_width, arrow_height,
  31.                  eSelect));
  32.     palette.add(new DrawModeItem(rectangle_bits, rectangle_width,
  33.                  rectangle_height, eRectangle));
  34.     palette.add(new DrawModeItem(square_bits, square_width, square_height,
  35.                  eSquare));
  36.     palette.add(new DrawModeItem(ellipse_bits, ellipse_width, ellipse_height,
  37.                  eEllipse));
  38.     palette.add(new DrawModeItem(circle_bits, circle_width, circle_height,
  39.                  eCircle));
  40.     palette.add(new DrawModeItem(triangle_bits, triangle_width,
  41.                  triangle_height, eTriangle));
  42.     palette.add(new DrawModeItem(glyph_bits, glyph_width, glyph_height,
  43.                  eText));
  44.     // Configuration of the palette
  45.     
  46.     palette.setR_orientation(XmVERTICAL);
  47.     palette.setR_label_string("Select Drawing Mode");
  48.     palette.setR_leftAttachment(XmATTACH_FORM);
  49.     palette.setR_topAttachment(XmATTACH_FORM);
  50.     palette.create(form, "palette");
  51.  
  52.     GnStaticScrolledWindow *scroller = new GnStaticScrolledWindow;
  53.     scroller->setR_leftAttachment(XmATTACH_WIDGET);
  54.     scroller->setR_leftWidget(palette);
  55.     scroller->setR_rightAttachment(XmATTACH_FORM);
  56.     scroller->setR_topAttachment(XmATTACH_FORM);
  57.     scroller->setR_bottomAttachment(XmATTACH_FORM);
  58.     scroller->create(form, "scrolledWindow");
  59.     
  60.     this->main_view = new GraphicEditorView(this);
  61.     this->main_view->setR_width(1200);
  62.     this->main_view->setR_height(1200);
  63.     this->main_view->create(scroller, "mainView");
  64.     
  65.     palette.add_selectionCallback(CALLBACK(GraphicEditorView,
  66.                        ChangeMode, main_view));
  67.     
  68.     main_shell->add_menu_command("Draw", "Clear All",
  69.                  CALLBACK(GraphicEditorDocument,
  70.                       ClearAllObjects, this));
  71.     main_shell->add_menu_command("Draw", "Thin Lines",
  72.                  CALLBACK1(GraphicEditorView,
  73.                        NewLineWidth, main_view, int, 0));
  74.     main_shell->add_menu_command("Draw", "1 Pixel Lines",
  75.                  CALLBACK1(GraphicEditorView,
  76.                        NewLineWidth, main_view, int, 1));
  77.     main_shell->add_menu_command("Draw", "2 Pixel Lines",
  78.                  CALLBACK1(GraphicEditorView,
  79.                        NewLineWidth, main_view, int, 2));
  80.     main_shell->add_menu_command("Draw", "3 Pixel Lines",
  81.                  CALLBACK1(GraphicEditorView,
  82.                        NewLineWidth, main_view, int, 3));
  83.     main_shell->add_menu_command("Draw", "4 Pixel Lines",
  84.                  CALLBACK1(GraphicEditorView,
  85.                        NewLineWidth, main_view, int, 4));
  86.     main_shell->add_menu_command("Draw", "5 Pixel Lines",
  87.                  CALLBACK1(GraphicEditorView,
  88.                        NewLineWidth, main_view, int, 5));
  89. }
  90.  
  91. void GraphicEditorDocument::
  92. wipe_out()
  93. {
  94.     GnViewObjectList *list = main_view->get_view_objects();
  95.     GnViewObject     *obj;
  96.     
  97.     while( ! list->Empty() ) {
  98.     obj = list->First();
  99.         obj->deinstall(False);
  100.     delete obj;
  101.     }
  102. }
  103.  
  104. void GraphicEditorDocument ::
  105. ClearAllObjects(caddr_t )
  106. {
  107.     (new ClearAll( this ))->submit();
  108. }
  109.  
  110. XBoolean GraphicEditorDocument ::
  111. write_to_stream( ostream &ofs )
  112. {
  113.     ((GraphicEditorView*)main_view)->write_to_stream( ofs );
  114.     return True;
  115. }
  116.  
  117. XBoolean GraphicEditorDocument ::
  118. read_from_stream ( istream &ifs )
  119. {
  120.     ((GraphicEditorView*)main_view)->read_from_stream( ifs );
  121.     return True;
  122. }
  123.  
  124.