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 / ViewObjectDraw < prev   
Text File  |  1992-02-27  |  1KB  |  50 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2.  
  3. //   Module      : ViewObjectDrawer.C   Version 1.2
  4. //   LastSCCS    : 2/26/92  16:37:02
  5. //   LastEdit    : "Fri Feb 21 09:30:00 1992"
  6. //   Description : 
  7. //   Author      : 
  8. //   Copyright   : GMD Schloss Birlinghoven
  9.  
  10. ViewObjectDrawer::
  11. ViewObjectDrawer( GnView *view, int x, int y )
  12. : GnMouseDownCommand( view->get_document(), view, x, y )
  13. {
  14.     view_object = 0;
  15. }
  16.  
  17. void ViewObjectDrawer ::
  18. constrain_mouse( int &x, int &y )
  19. {
  20.     x = MAX( x, start_x + 2 );
  21.     y = MAX( y, start_y + 2 );
  22. }
  23.  
  24. void ViewObjectDrawer ::
  25. doit()
  26. {
  27.     constrain_mouse(last_x, last_y);
  28.  
  29.     int wid = ABS(last_x - start_x);
  30.     int hei = ABS(last_y - start_y);
  31.         
  32.     create_view_object(wid, hei);
  33.     view_object->
  34.     setGC_line_width(((GraphicEditorView *)view)->GetDefaultLineWidth());
  35.     view_object->install(view, start_x, start_y);
  36. }
  37.  
  38. void ViewObjectDrawer ::
  39. undoit()
  40. {
  41.     view_object->deinstall();
  42. }
  43.  
  44. void ViewObjectDrawer ::
  45. redoit()
  46. {
  47.     view_object->install(view, start_x, start_y);
  48. }
  49.  
  50.