home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / uidemo / graphic2 / appwin.cxx next >
C/C++ Source or Header  |  1995-04-08  |  3KB  |  105 lines

  1.  
  2.  
  3. #include "ui/lineseg.h"
  4. #include "ui/piewedge.h"
  5. #include "ui/chord.h"
  6. #include "ui/arc.h"
  7. #include "ui/ellipse.h"
  8. #include "ui/dsplsurf.h"
  9. #include "appwin.h"
  10.  
  11.  
  12. AppWindow::AppWindow()
  13. : UI_CompositeVObject (NULL, NULL, FALSE, UI_Rectangle (10, 50, 425, 400))
  14. {
  15.     Title () = "YACL graphics demo 2";
  16. }
  17.  
  18.  
  19. bool AppWindow::Paint ()
  20. {
  21.     Draw ();
  22.     return TRUE;
  23. }
  24.  
  25. #include <iostream.h> // DEBUG
  26. void AppWindow::Draw ()
  27. {
  28.     Background (UIColor_White);
  29.     CreateDisplaySurface ();
  30.  
  31.     UI_Rectangle r;
  32.     UI_DisplaySurface& sfc = *(DisplaySurface());
  33.  
  34.     UI_Rectangle area = sfc.DrawingArea ();
  35.     area.Origin (UI_Point (0, 0));
  36.     sfc.ColorRectangle (area, UIColor_White);
  37.     UI_Pen& pen = sfc.Pen ();
  38.     UI_Brush& brush = sfc.Brush();
  39.     UI_Font& font = sfc.Font();
  40.  
  41.     brush.Color (UIColor_Blue); brush.Pattern (UIBrush_Solid);
  42.     pen.Color (UIColor_Red);
  43.     sfc.DrawEllipse   (UI_Rectangle (150, 20,  100, 60),
  44.                        (UID_DrawOptions) (UID_Outline | UID_Fill));
  45.  
  46.     pen.Thickness (1);
  47.     pen.Color (UIColor_Black);
  48.     pen.Pattern (UIPen_Dot);
  49.     sfc.DrawLine (UI_Point (20,  20), UI_Point (80,  20));
  50.     pen.Pattern (UIPen_Dash);
  51.     sfc.DrawLine (UI_Point (20,  40), UI_Point (80,  40));
  52.     pen.Pattern (UIPen_Solid);
  53.     sfc.DrawLine (UI_Point (20,  60), UI_Point (80,  60));
  54.  
  55.     font = UI_FontDesc (UIFont_Courier, 12, UIFont_Underline);
  56.     sfc.WriteString ("An ellipse", UI_Rectangle (270, 20, 145, 30));
  57.  
  58.     brush.Color   (UI_Color (0, 1, 1)); // Cyan
  59.     sfc.DrawRectangle (UI_Rectangle (150, 90, 100, 60),
  60.                        (UID_DrawOptions) (UID_Outline | UID_Fill));
  61.     font = UI_FontDesc (UIFont_Times,   12, UIFont_Italic | UIFont_BoldFace);
  62.     sfc.WriteString ("A rectangle", UI_Rectangle (270, 100, 145, 40));
  63.  
  64.  
  65.     pen.Thickness (2);
  66.     pen.Color (UIColor_Green); 
  67.     sfc.DrawLine (UI_Point (20,  90), UI_Point (80,  90));
  68.     pen.Color (UIColor_Red);
  69.     sfc.DrawLine (UI_Point (20, 110), UI_Point (80, 110));
  70.     pen.Color (UIColor_Blue);
  71.     sfc.DrawLine (UI_Point (20, 130), UI_Point (80, 130));
  72.  
  73.     pen.Color (UIColor_MediumGray);
  74.     font = UI_FontDesc (UIFont_Helvetica, 12, UIFont_BoldFace);
  75.     sfc.WriteString ("A few lines", UI_Rectangle (20, 150, 120, 40));
  76.  
  77.     font = UI_FontDesc (UIFont_Times, 12, UIFont_StrikeOut |
  78.                         UIFont_BoldFace);
  79.     sfc.WriteString ("Struck out text", UI_Rectangle (20, 200, 130, 40));
  80.  
  81.     pen.Thickness (1);
  82.  
  83.     brush.Color (UI_Color (UIColor_Green)); 
  84.     pen.Color   (UI_Color (UIColor_Red));
  85.     r = UI_Rectangle (150, 180, 100, 60);
  86.     UI_PieWedge p (r, 60*64, 100*64);
  87.     sfc.DrawPieWedge (p, (UID_DrawOptions) (UID_Outline | UID_Fill));
  88.     font = UI_FontDesc (UIFont_Times, 14, UIFont_BoldFace);
  89.     sfc.WriteString ("A PieWedge", UI_Rectangle (270, 200, 145, 40));
  90.  
  91.     brush.Color   (UI_Color (UIColor_MediumGray)); 
  92.     pen.Color   (UI_Color (UIColor_Red));
  93.     r = UI_Rectangle (150, 240, 100, 60);
  94.     UI_Chord c (r, 60*64, 110*64);
  95.     sfc.DrawChord (c, (UID_DrawOptions) (UID_Outline | UID_Fill));
  96.     sfc.WriteString ("A Chord", UI_Rectangle (270, 250, 145, 40));
  97.  
  98.     r = UI_Rectangle (150, 300, 100, 60);
  99.     UI_Arc arc (r, 60*64, 249*64);
  100.     arc.DrawOn (sfc);
  101.     sfc.WriteString ("An arc", UI_Rectangle (270, 320, 145, 40));
  102.  
  103.     DestroyDisplaySurface ();
  104. }
  105.