home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pascal / qp_paint.arc / PAINT.PAS < prev   
Pascal/Delphi Source File  |  1989-05-22  |  6KB  |  109 lines

  1. {$B-,F-,I+,R+}
  2.  
  3. program Paint;
  4.  
  5. { Quick Paint graphics and object demonstration program }
  6.  
  7. { Copyright 1989
  8.   Scott Bussinger
  9.   110 South 131st Street
  10.   Tacoma, WA  98444
  11.   (206)531-8944
  12.   Compuserve 72247,2671 }
  13.  
  14. { Here's the complete object hierarchy:
  15.  
  16.   TObject - Ancestor of all object types
  17.     ├── TMouse - Access to mouse hardware
  18.     └── TWindow - A rectangular window on screen
  19.           ├── TDrawingWindow - A window scaled to coordinates of 0.00 to 1.00
  20.           │     └── TPaneWindow - A window with an icon
  21.           │           ├── TColorPane - A pane showing a selectable drawing color
  22.           │           ├── TFillPane - A pane showing a selectable fill mask
  23.           │           ├── TLinePane - A pane showing a selectable line style
  24.           │           ├── TFontPane - A pane showing a selectable text font
  25.           │           ├── TColorStylePane - A pane showing the current drawing color
  26.           │           ├── TFillStylePane - A pane showing the current fill mask
  27.           │           ├── TLineStylePane - A pane showing the current line style
  28.           │           ├── TFontStylePane - A pane showing the current text font
  29.           │           └── TToolPane - A pane showing a selectable drawing tool
  30.           │                 ├── TEraserTool - A tool to clear the drawing window
  31.           │                 ├── TQuitTool - A tool to quit the program
  32.           │                 └── TModalToolPane - Tools that change the current drawing tool
  33.           │                       ├── TPenTool - A freehand drawing tool
  34.           │                       ├── TPaintBucketTool - An area fill tool
  35.           │                       └── TRubberBandToolPane - A tool that shows a rubberband cursor
  36.           │                             ├── TLineTool - A straight line drawing tool
  37.           │                             ├── TCircleTool - A circle drawing tool
  38.           │                             ├── TFilledCircleTool - A circle drawing tool with area fill
  39.           │                             └── TRectangularRubberBandToolPane - A tool that shows a rectangular rubberband cursor
  40.           │                                   ├── TBoxTool - A rectangle drawing tool
  41.           │                                   ├── TFilledBoxTool - A rectangle drawing tool with area fill
  42.           │                                   ├── TEllipseTool - An ellipse drawing tool
  43.           │                                   ├── TFilledEllipseTool - An ellipse drawing tool with area fill
  44.           │                                   └── TTextTool - A text entry tool
  45.           └── TMultipanedWindow - A window made up of an array of smaller panes
  46.                 ├── TColorWindow - A window for choosing the drawing color
  47.                 ├── TFillWindow - A window for choosing the fill mask
  48.                 ├── TLineWindow - A window for choosing the line style
  49.                 ├── TFontWindow - A window for choosing the current font
  50.                 ├── TStyleWindow - A window for showing the current styles
  51.                 └── TToolWindow - A window for choosing the current drawing tool
  52.   }
  53.  
  54. uses CObject,CMouse,CWindow,CStyle,CTool,MSGraph,Dos;
  55.  
  56. var DrawingWindow: TDrawingWindow;
  57.     StyleWindow: TStyleWindow;
  58.     Tool: TToolPane;
  59.     ToolWindow: TToolWindow;
  60.  
  61. procedure CreateAllWindows;
  62.   { Create all of the windows on the screen }
  63.   begin
  64.   new(DrawingWindow);
  65.   DrawingWindow.Init(true,0.11,0.06,0.99,0.84);
  66.   CurrentCanvas := DrawingWindow;
  67.   CurrentCanvas.Clear;                           { Start drawing window in black }
  68.  
  69.   new(ToolWindow);
  70.   ToolWindow.Init(true,0.005,0.06,0.105,0.66);
  71.  
  72.   new(StyleWindow);
  73.   StyleWindow.Init(true,0.005,0.70,0.99,0.99);
  74.  
  75.   _SetViewport(round(0.11*VideoConfig.NumXPixels),0, { Display a screen title }
  76.                VideoConfig.NumXPixels,round(0.05*VideoConfig.NumYPixels));
  77.   _SetWindow(false,0.00,0.00,1.00,1.00);
  78.   FitText(Roman,'Quick Paint')
  79.   end;
  80.  
  81. begin
  82. CreateAllWindows;                                { Initialize all of the windows for the display }
  83. repeat
  84.   Mouse.Show;                                    { A tight polling loop to keep track of mouse }
  85.   Mouse.Update;
  86.   Tool := TToolPane(ToolWindow.CurrentPane);     { Get current painting tool so we can send messages based on mouse action }
  87.   if Mouse.GetButton(Left) = Idle then           { Let a text tool look at keyboard at every opportunity }
  88.     Tool.Idle;
  89.   if DrawingWindow.CheckMouse                    { Are we in the big drawing window? }
  90.    then
  91.     begin
  92.     Tool.SetCursor;                              { Have the tool change to the appropriate cursor shape }
  93.     case Mouse.GetButton(Left) of
  94.       Pressed: Tool.Anchor;                      { Anchor a tool when the button is first pressed }
  95.       Held: Tool.Track;                          { Some tools leave a trace after the mouse, or have a rubberband cursor }
  96.       Released: Tool.Draw                        { Letting go of the mouse button is the final trigger }
  97.       else
  98.       end
  99.     end
  100.    else
  101.     begin
  102.     Tool.ClearAnchor;                            { We moved outside of the drawing window, so disable any pending tool }
  103.     if not ToolWindow.CheckMouse and             { Check the tool window }
  104.        not StyleWindow.CheckMouse then           { Check the drawing style window }
  105.       Mouse.SetCursor(DefaultCursor)             { Change back to the normal cursor if not in any other window }
  106.     end
  107. until false                                      { Repeat forever (actually until HALT in QuitTool) }
  108. end.
  109.