home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / OMOUSE.ZIP / OMOUSE.DEM < prev    next >
Encoding:
Text File  |  1990-02-23  |  21.1 KB  |  941 lines

  1. {
  2.  
  3.     omouse.dem
  4.     2-23-90
  5.     Demo Omouse unit in graphics mode.
  6.  
  7.     Copyright 1990
  8.     John W. Small
  9.     All rights reserved
  10.  
  11.     PSW / Power SoftWare
  12.     P.O. Box 10072
  13.     McLean, Virginia 22102 8072
  14.     (703) 759-3838
  15.  
  16. }
  17.  
  18.  
  19. program omouseDemo;
  20.  
  21.     uses crt, graph, omouse, graphtxt, polylist;
  22.  
  23.     type
  24.  
  25.         EaselPtr = ^Easel;
  26.         Easel = object(pmoList)
  27.             toolx, toolw, toolh,            { tool dimension }
  28.             toolsc, toolc,                    { Default tool color }
  29.             toolscb, toolcb,
  30.             color, background : integer;    { current tool color }
  31.             doItDrawID : pointer;            { InterTool comm }
  32.             quit : boolean;
  33.             constructor init;
  34.             procedure SelectTool(sx, sy : integer);
  35.             procedure toolDraw(toolID : pointer;    { InterTool comm }
  36.                 c, b : integer);
  37.             procedure doIt;
  38.             procedure toolDoIt(toolID : pointer);    { InterTool comm }
  39.             destructor done; virtual;
  40.             end;
  41.  
  42.         PaintToolPtr = ^PaintTool;
  43.         PaintTool = object(pmoNode)
  44.             doItDraw : boolean;
  45.             constructor init(did : boolean);
  46.             procedure draw; virtual;
  47.             procedure select; virtual;
  48.             procedure doIt; virtual;
  49.             destructor done; virtual;
  50.             end;
  51.  
  52.         TextToolPtr = ^TextTool;
  53.         TextTool = object(PaintTool)
  54.             constructor init;
  55.             procedure draw; virtual;
  56.             procedure select; virtual;
  57.             procedure doIt; virtual;
  58.             destructor done; virtual;
  59.             end;
  60.  
  61.         LineToolPtr = ^LineTool;
  62.         LineTool = object(PaintTool)
  63.             constructor init;
  64.             procedure draw; virtual;
  65.             procedure select; virtual;
  66.             procedure doIt; virtual;
  67.             destructor done; virtual;
  68.             end;
  69.  
  70.         RectToolPtr = ^RectTool;
  71.         RectTool = object(PaintTool)
  72.             constructor init;
  73.             procedure draw; virtual;
  74.             procedure select; virtual;
  75.             procedure doIt; virtual;
  76.             destructor done; virtual;
  77.             end;
  78.  
  79.         EllipseToolPtr = ^EllipseTool;
  80.         EllipseTool = object(PaintTool)
  81.             constructor init;
  82.             procedure draw; virtual;
  83.             procedure select; virtual;
  84.             procedure doIt; virtual;
  85.             destructor done; virtual;
  86.             end;
  87.  
  88.         FillToolPtr = ^FillTool;
  89.         FillTool = object(PaintTool)
  90.             constructor init;
  91.             procedure draw; virtual;
  92.             procedure select; virtual;
  93.             procedure doIt; virtual;
  94.             destructor done; virtual;
  95.             end;
  96.  
  97.         ClearToolPtr = ^ClearTool;
  98.         ClearTool = object(PaintTool)
  99.             constructor init;
  100.             procedure draw; virtual;
  101.             procedure select; virtual;
  102.             procedure doIt; virtual;
  103.             destructor done; virtual;
  104.             end;
  105.  
  106.         QuitToolPtr = ^QuitTool;
  107.         QuitTool = object(PaintTool)
  108.             constructor init;
  109.             procedure draw; virtual;
  110.             procedure select; virtual;
  111.             procedure doIt; virtual;
  112.             destructor done; virtual;
  113.             end;
  114.  
  115.         ColorToolPtr = ^ColorTool;
  116.         ColorTool = object(PaintTool)
  117.             constructor init;
  118.             procedure draw; virtual;
  119.             procedure select; virtual;
  120.             procedure doIt; virtual;
  121.             destructor done; virtual;
  122.             end;
  123.  
  124.         PaletteToolPtr = ^PaletteTool;
  125.         PaletteTool = object(PaintTool)
  126.             constructor init;
  127.             procedure draw; virtual;
  128.             procedure select; virtual;
  129.             procedure doIt; virtual;
  130.             destructor done; virtual;
  131.             end;
  132.  
  133.  
  134.     constructor Easel.init;
  135.         begin
  136.             pmoList.init;
  137.             ique(new(TextToolPtr,init));
  138.             ique(new(LineToolPtr,init));
  139.             ique(new(RectToolPtr,init));
  140.             ique(new(EllipseToolPtr,init));
  141.             ique(new(FillToolPtr,init));
  142.             ique(new(ClearToolPtr,init));
  143.             ique(new(QuitToolPtr,init));
  144.             ique(new(ColorToolPtr,init));
  145.             ique(new(PaletteToolPtr,init));
  146.             toolw := (GetMaxX + 1) div 8;
  147.             toolx := GetMaxX - toolw + 1;
  148.             toolh := (GetMaxY + 1)  div nodes;
  149.             if GetMaxColor > 3 then begin
  150.                 { Readln mode, see graphtxt }
  151.                 InputWriteMode := XORPut;
  152.                 InputRewrite := true;
  153.                 toolsc := RED;
  154.                 toolscb := LIGHTGRAY;
  155.                 toolc := BLUE;
  156.                 toolcb := LIGHTGRAY
  157.                 end
  158.             else if GetMaxColor > 1 then begin
  159.                 InputWriteMode := CopyPut;
  160.                 InputRewrite := false;
  161.                 toolsc := BLACK;
  162.                 toolscb := GetMaxColor;
  163.                 toolc := BLUE;
  164.                 toolcb := BLACK
  165.                 end
  166.             else begin
  167.                 InputWriteMode := CopyPut;
  168.                 InputRewrite := false;
  169.                 toolsc := GetMaxColor;
  170.                 toolscb := BLACK;
  171.                 toolc := BLACK;
  172.                 toolcb := GetMaxColor
  173.                 end;
  174.             color := toolc;
  175.             background := toolcb;
  176.             SetColor(background);
  177.             SetBkColor(color);
  178.             if (GetMaxX < 320) or (GetMaxY < 200) then
  179.                 SetTextStyle(SmallFont,HorizDir,4)
  180.             else
  181.                 SetTextStyle(TriplexFont,HorizDir,3);
  182.             SetTextJustify(CenterText,CenterText);
  183.             quit := false
  184.         end;
  185.  
  186.     procedure Easel.SelectTool(sx, sy : integer);
  187.         var newTool, lastToolNum : word;
  188.             y : integer;
  189.         begin
  190.             if sx > toolx then begin
  191.                 y := toolh;
  192.                 newTool := 1;
  193.                 while y < (sy + 1) do begin
  194.                     inc(y,toolh);
  195.                     inc(newTool)
  196.                     end;
  197.                 if newTool <= nodes then begin
  198.                     lastToolNum := curNum;
  199.                     doItDrawID := TypeOf(current^);
  200.                     color := toolc;
  201.                     background := toolcb;
  202.                     PaintToolPtr(current)^.draw;
  203.                     mkcur(newTool);
  204.                     if PaintToolPtr(current)^.doItDraw then
  205.                         doItDrawID := TypeOf(current^);
  206.                     color := toolsc;
  207.                     background := toolscb;
  208.                     PaintToolPtr(current)^.select;
  209.                     if not PaintToolPtr(current)^.doItDraw then begin
  210.                         mkcur(lastToolNum);
  211.                         PaintToolPtr(current)^.select
  212.                         end
  213.                     end
  214.                 end
  215.         end;
  216.  
  217.     procedure Easel.toolDraw(toolID : pointer;
  218.                 c, b : integer);
  219.         var lastTool : word;
  220.             finished : boolean;
  221.             tmpc, tmpb : integer;
  222.         begin
  223.             lastTool := curNum;
  224.             mkcur(0);
  225.             finished := false;
  226.             while not finished do
  227.                 if next then begin
  228.                     if TypeOf(current^) = toolID then begin
  229.                         tmpc := color;
  230.                         color := c;
  231.                         tmpb := background;
  232.                         background := b;
  233.                         PaintToolPtr(current)^.draw;
  234.                         color := tmpc;
  235.                         background := tmpb;
  236.                         finished := true
  237.                         end
  238.                     end
  239.                 else
  240.                     finished := true;
  241.             mkcur(lastTool)
  242.         end;
  243.  
  244.     procedure Easel.doIt;
  245.         begin
  246.             if not mouse.Present then exit;
  247.             toolDoIt(TypeOf(ClearTool));
  248.             color := toolc;
  249.             while next do
  250.                 PaintToolPtr(current)^.draw;
  251.             mkcur(1);
  252.             color := toolsc;
  253.             background := toolscb;
  254.             doItDrawID := TypeOf(current^);
  255.             PaintToolPtr(current)^.select;
  256.             MoveTo(GetMaxX div 2, GetMaxY div 2);
  257.             writeln('Easel is a primitive paint program');
  258.             writeln('used to demostrate the omouse unit.');
  259.             writeln('Press the left mouse button to select');
  260.             writeln('a paint tool.  The right mouse button');
  261.             writeln('selects the background color when the');
  262.             writeln('mouse cursor is over the palette');
  263.             writeln('colors.  Start off by clearing');
  264.             writeln('this message.');
  265.             mouse.reset;
  266.             mouse.AutoEventUpdate;
  267.             mouse.UserCount := mouse.EventCount;
  268.             mouse.show;
  269.             while not quit do begin
  270.                 while mouse.UserCount = mouse.EventCount do;
  271.                 if (mouse.x > toolx) then begin
  272.                     if mouse.LeftPressed then
  273.                         SelectTool(mouse.LastLeftPressX,
  274.                             mouse.LastLeftPressY)
  275.                     else if mouse.RightPressed then
  276.                         SelectTool(mouse.LastRightPressX,
  277.                             mouse.LastRightPressY)
  278.                     end
  279.                 else if mouse.LeftPressed then begin
  280.                     mouse.trap(0,0,toolx-1,GetMaxY);
  281.                     SetViewPort(0,0,toolx-1,GetMaxY,ClipOn);
  282.                     PaintToolPtr(current)^.doIt;
  283.                     mouse.trap(0,0,GetMaxX,GetMaxY);
  284.                     SetViewPort(0,0,GetMaxX,GetMaxY,ClipOff);
  285.                     end;
  286.                 mouse.UserCount := mouse.EventCount;
  287.                 end;
  288.         end;
  289.  
  290.     procedure Easel.toolDoIt(toolID : pointer);
  291.         var lastTool : word;
  292.             finished : boolean;
  293.         begin
  294.             lastTool := curNum;
  295.             mkcur(0);
  296.             finished := false;
  297.             while not finished do
  298.                 if next then begin
  299.                     if TypeOf(current^) = toolID then begin
  300.                         PaintToolPtr(current)^.doIt;
  301.                         finished := true
  302.                         end
  303.                     end
  304.                 else
  305.                     finished := true;
  306.             mkcur(lastTool)
  307.         end;
  308.  
  309.     destructor Easel.done;
  310.         begin
  311.             pmoList.done
  312.         end;
  313.  
  314.  
  315.  
  316.  
  317.     constructor PaintTool.init(did : boolean);
  318.         begin
  319.             doItDraw := did
  320.         end;
  321.  
  322.     procedure PaintTool.draw;
  323.         var FS : FillSettingsType;
  324.             LS : LineSettingsType;
  325.             c, y : word;
  326.         begin
  327.             mouse.hide;
  328.             with EaselPtr(list)^ do begin
  329.                 GetFillSettings(FS);
  330.                 SetFillStyle(SolidFill,background);
  331.                 GetLineSettings(LS);
  332.                 SetLineStyle(SolidLn,0,NormWidth);
  333.                 c := GetColor;
  334.                 SetColor(color);
  335.                 SetWriteMode(CopyPut);
  336.                 y := (curNum-1)*toolh;
  337.                 bar3d(toolx,y,toolx+toolw-1,y+toolh-1,
  338.                     0,false);
  339.                 SetFillStyle(FS.Pattern,FS.Color);
  340.                 SetLineStyle(LS.LineStyle,LS.Pattern,
  341.                     LS.Thickness);
  342.                 SetColor(c)
  343.                 end;
  344.             mouse.show
  345.         end;
  346.  
  347.     procedure PaintTool.select;
  348.         begin
  349.             draw
  350.         end;
  351.  
  352.     procedure PaintTool.doIt;
  353.         begin
  354.         end;
  355.  
  356.     destructor PaintTool.done;
  357.         begin
  358.         end;
  359.  
  360.  
  361.     constructor TextTool.init;
  362.         begin
  363.             PaintTool.init(true)
  364.         end;
  365.  
  366.     procedure TextTool.draw;
  367.         var c : word;
  368.         begin
  369.             mouse.hide;
  370.             PaintTool.draw;
  371.             c := GetColor;
  372.             with EaselPtr(list)^ do begin
  373.                 SetColor(color);
  374.                 OutTextXY(toolx + toolw div 2,
  375.                     (curNum-1)*toolh + toolh div 2,'T')
  376.                 end;
  377.             SetColor(c);
  378.             mouse.show
  379.         end;
  380.  
  381.     procedure TextTool.select;
  382.         begin
  383.             draw
  384.         end;
  385.  
  386.     procedure TextTool.doIt;
  387.         begin
  388.             MoveTo(mouse.LastLeftPressX,mouse.LastLeftPressY);
  389.             while mouse.LeftPressed do;
  390.             mouse.hide;
  391.             readln;
  392.             mouse.show;
  393.         end;
  394.  
  395.     destructor TextTool.done;
  396.         begin
  397.         end;
  398.  
  399.  
  400.     constructor LineTool.init;
  401.         begin
  402.             PaintTool.init(true)
  403.         end;
  404.  
  405.     procedure LineTool.draw;
  406.         var LS : LineSettingsType;
  407.             c, y : word;
  408.         begin
  409.             mouse.hide;
  410.             PaintTool.draw;
  411.             GetLineSettings(LS);
  412.             SetLineStyle(SolidLn,0,NormWidth);
  413.             c := GetColor;
  414.             with EaselPtr(list)^ do begin
  415.                 y := (curNum-1)*toolh;
  416.                 SetColor(color);
  417.                 line(toolx + toolw div 4 * 3, y + toolh div 4,
  418.                     toolx + toolw div 4, y + toolh div 4 * 3)
  419.                 end;
  420.             SetLineStyle(LS.LineStyle,LS.Pattern,
  421.                 LS.Thickness);
  422.             SetColor(c);
  423.             mouse.show
  424.         end;
  425.  
  426.     procedure LineTool.select;
  427.         begin
  428.             draw
  429.         end;
  430.  
  431.     procedure LineTool.doIt;
  432.         begin
  433.             SetWriteMode(XORPut);
  434.             mouse.UserX := mouse.x;
  435.             mouse.UserY := mouse.y;
  436.             mouse.hide;
  437.             line(mouse.LastLeftPressX,
  438.                 mouse.LastLeftPressY,
  439.                 mouse.UserX,mouse.UserY);
  440.             mouse.show;
  441.             mouse.EventMoved := 0;
  442.             while (mouse.LeftPresses >
  443.                 mouse.LeftReleases) do begin;
  444.                 if mouse.EventMoved > 0 then begin
  445.                     mouse.hide;
  446.                     line(mouse.LastLeftPressX,
  447.                         mouse.LastLeftPressY,
  448.                         mouse.UserX,mouse.UserY);
  449.                     mouse.UserX := mouse.x;
  450.                     mouse.UserY := mouse.y;
  451.                     line(mouse.LastLeftPressX,
  452.                         mouse.LastLeftPressY,
  453.                         mouse.UserX,mouse.UserY);
  454.                     mouse.show;
  455.                     mouse.EventMoved := 0;
  456.                     end;
  457.                 end;
  458.             SetWriteMode(CopyPut);
  459.             mouse.hide;
  460.             line(mouse.LastLeftPressX,
  461.                 mouse.LastLeftPressY,
  462.                 mouse.UserX,mouse.UserY);
  463.             mouse.show;
  464.         end;
  465.  
  466.     destructor LineTool.done;
  467.         begin
  468.         end;
  469.  
  470.  
  471.     constructor RectTool.init;
  472.         begin
  473.             PaintTool.init(true)
  474.         end;
  475.  
  476.     procedure RectTool.draw;
  477.         var LS : LineSettingsType;
  478.             c, y : word;
  479.         begin
  480.             mouse.hide;
  481.             PaintTool.draw;
  482.             GetLineSettings(LS);
  483.             SetLineStyle(SolidLn,0,NormWidth);
  484.             c := GetColor;
  485.             with EaselPtr(list)^ do begin
  486.                 SetColor(color);
  487.                 y := (curNum-1)*toolh;
  488.                 rectangle(toolx + toolw div 4,
  489.                     y + toolh div 4,
  490.                     toolx + toolw div 4 * 3,
  491.                     y + toolh div 4 * 3);
  492.                 end;
  493.             SetLineStyle(LS.LineStyle,Ls.Pattern,
  494.                 LS.Thickness);
  495.             SetColor(c);
  496.             mouse.show
  497.         end;
  498.  
  499.     procedure RectTool.select;
  500.         begin
  501.             draw
  502.         end;
  503.  
  504.  
  505.     procedure RectTool.doIt;
  506.         begin
  507.             SetWriteMode(XORPut);
  508.             mouse.UserX := mouse.x;
  509.             mouse.UserY := mouse.y;
  510.             mouse.hide;
  511.             Rectangle(mouse.LastLeftPressX,
  512.                 mouse.LastLeftPressY,
  513.                 mouse.UserX,mouse.UserY);
  514.             mouse.show;
  515.             mouse.EventMoved := 0;
  516.             while (mouse.LeftPresses >
  517.                 mouse.LeftReleases) do begin;
  518.                 if mouse.EventMoved > 0 then begin
  519.                     mouse.hide;
  520.                     Rectangle(mouse.LastLeftPressX,
  521.                         mouse.LastLeftPressY,
  522.                         mouse.UserX,mouse.UserY);
  523.                     mouse.UserX := mouse.x;
  524.                     mouse.UserY := mouse.y;
  525.                     Rectangle(mouse.LastLeftPressX,
  526.                         mouse.LastLeftPressY,
  527.                         mouse.UserX,mouse.UserY);
  528.                     mouse.show;
  529.                     mouse.EventMoved := 0;
  530.                     end;
  531.                 end;
  532.             SetWriteMode(CopyPut);
  533.             mouse.hide;
  534.             Rectangle(mouse.LastLeftPressX,
  535.                 mouse.LastLeftPressY,
  536.                 mouse.UserX,mouse.UserY);
  537.             mouse.show;
  538.         end;
  539.  
  540.     destructor RectTool.done;
  541.         begin
  542.         end;
  543.  
  544.  
  545.     constructor EllipseTool.init;
  546.         begin
  547.             PaintTool.init(true)
  548.         end;
  549.  
  550.     procedure EllipseTool.draw;
  551.         var LS : LineSettingsType;
  552.             c : word;
  553.         begin
  554.             mouse.hide;
  555.             PaintTool.draw;
  556.             GetLineSettings(LS);
  557.             SetLineStyle(SolidLn,0,NormWidth);
  558.             c := GetColor;
  559.             with EaselPtr(list)^ do begin
  560.                 SetColor(color);
  561.                 ellipse(toolx + toolw div 2,
  562.                     (curNum-1)*toolh + toolh div 2,
  563.                     0,360,toolw div 4, toolh div 8)
  564.                 end;
  565.             SetLineStyle(LS.LineStyle,LS.Pattern,
  566.                 LS.Thickness);
  567.             SetColor(c);
  568.             mouse.show
  569.         end;
  570.  
  571.     procedure EllipseTool.select;
  572.         begin
  573.             draw
  574.         end;
  575.  
  576.     procedure EllipseTool.doIt;
  577.         begin
  578.             SetWriteMode(XORPut);
  579.             mouse.hide;
  580.             mouse.UserX := abs(mouse.x -
  581.                 mouse.LastLeftPressX);
  582.             mouse.UserY := abs(mouse.y -
  583.                 mouse.LastLeftPressY);
  584.             Rectangle(mouse.LastLeftPressX - mouse.UserX,
  585.                 mouse.LastLeftPressY - mouse.UserY,
  586.                 mouse.LastLeftPressX + mouse.UserX,
  587.                 mouse.LastLeftPressY + mouse.UserY);
  588.             mouse.show;
  589.             mouse.EventMoved := 0;
  590.             while (mouse.LeftPresses >
  591.                 mouse.LeftReleases) do begin;
  592.                 if mouse.EventMoved > 0 then begin
  593.                     mouse.hide;
  594.                     Rectangle(mouse.LastLeftPressX - mouse.UserX,
  595.                         mouse.LastLeftPressY - mouse.UserY,
  596.                         mouse.LastLeftPressX + mouse.UserX,
  597.                         mouse.LastLeftPressY + mouse.UserY);
  598.                     mouse.UserX := abs(mouse.x -
  599.                         mouse.LastLeftPressX);
  600.                     mouse.UserY := abs(mouse.y -
  601.                         mouse.LastLeftPressY);
  602.                     Rectangle(mouse.LastLeftPressX - mouse.UserX,
  603.                         mouse.LastLeftPressY - mouse.UserY,
  604.                         mouse.LastLeftPressX + mouse.UserX,
  605.                         mouse.LastLeftPressY + mouse.UserY);
  606.                     mouse.show;
  607.                     mouse.EventMoved := 0;
  608.                     end;
  609.                 end;
  610.             mouse.hide;
  611.             Rectangle(mouse.LastLeftPressX - mouse.UserX,
  612.                 mouse.LastLeftPressY - mouse.UserY,
  613.                 mouse.LastLeftPressX + mouse.UserX,
  614.                 mouse.LastLeftPressY + mouse.UserY);
  615.             SetWriteMode(CopyPut);
  616.             Ellipse(mouse.LastLeftPressX,mouse.LastLeftPressY,
  617.                 0,360,mouse.UserX,mouse.UserY);
  618.             mouse.show;
  619.         end;
  620.  
  621.     destructor EllipseTool.done;
  622.         begin
  623.         end;
  624.  
  625.  
  626.     constructor FillTool.init;
  627.         begin
  628.             PaintTool.init(true)
  629.         end;
  630.  
  631.     procedure FillTool.draw;
  632.         var c : word;
  633.         begin
  634.             mouse.hide;
  635.             PaintTool.Draw;
  636.             c := GetColor;
  637.             with EaselPtr(list)^ do begin
  638.                 SetColor(color);
  639.                 OutTextXY(toolx + toolw div 2,
  640.                     (curNum-1)*toolh + toolh div 2,'Fill')
  641.                 end;
  642.             SetColor(c);
  643.             mouse.show
  644.         end;
  645.  
  646.     procedure FillTool.select;
  647.         var b, c : integer;
  648.         begin
  649.             with EaselPtr(list)^ do begin
  650.                 c := color;
  651.                 b := background;
  652.                 color := GetColor;
  653.                 background := GetBkColor;
  654.                 draw;
  655.                 color := c;
  656.                 background := b
  657.                 end
  658.         end;
  659.  
  660.     procedure FillTool.doIt;
  661.         begin
  662.             mouse.hide;
  663.             SetFillStyle(SolidFill,GetColor);
  664.             FloodFill(mouse.LastLeftPressX,
  665.                 mouse.LastLeftPressY,GetColor);
  666.             mouse.show;
  667.             while mouse.LeftPressed or mouse.RightPressed
  668.                 do;
  669.         end;
  670.  
  671.     destructor FillTool.done;
  672.         begin
  673.         end;
  674.  
  675.  
  676.     constructor ClearTool.init;
  677.         begin
  678.             PaintTool.init(false)
  679.         end;
  680.  
  681.     procedure ClearTool.draw;
  682.         var c : word;
  683.         begin
  684.             mouse.hide;
  685.             PaintTool.Draw;
  686.             c := GetColor;
  687.             with EaselPtr(list)^ do begin
  688.                 SetColor(color);
  689.                 OutTextXY(toolx + toolw div 2,
  690.                     (curNum-1)*toolh + toolh div 2,'Clr')
  691.                 end;
  692.             SetColor(c);
  693.             mouse.show
  694.         end;
  695.  
  696.     procedure ClearTool.select;
  697.         begin
  698.             mouse.hide;
  699.             SetFillStyle(SolidFill,GetBkColor);
  700.             bar(0,0,GetMaxX - EaselPtr(list)^.toolw,
  701.                 GetMaxY);
  702.             mouse.show
  703.         end;
  704.  
  705.     procedure ClearTool.doIt;
  706.         begin
  707.             select
  708.         end;
  709.  
  710.     destructor ClearTool.done;
  711.         begin
  712.         end;
  713.  
  714.     constructor QuitTool.init;
  715.         begin
  716.             PaintTool.init(false)
  717.         end;
  718.  
  719.     procedure QuitTool.draw;
  720.         var c : word;
  721.         begin
  722.             mouse.hide;
  723.             PaintTool.Draw;
  724.             c := GetColor;
  725.             with EaselPtr(list)^ do begin
  726.                 SetColor(color);
  727.                 OutTextXY(toolx + toolw div 2,
  728.                     (curNum-1)*toolh + toolh div 2,'Quit')
  729.                 end;
  730.             SetColor(c);
  731.             mouse.show
  732.         end;
  733.  
  734.     procedure QuitTool.select;
  735.         begin
  736.              EaselPtr(list)^.quit := true
  737.         end;
  738.  
  739.     procedure QuitTool.doIt;
  740.         begin
  741.         end;
  742.  
  743.     destructor QuitTool.done;
  744.         begin
  745.         end;
  746.  
  747.  
  748.  
  749.     constructor ColorTool.init;
  750.         begin
  751.             PaintTool.init(false)
  752.         end;
  753.  
  754.     procedure ColorTool.draw;
  755.         var LS : LineSettingsType;
  756.             FS : FillSettingsType;
  757.             y : integer;
  758.         begin
  759.             mouse.hide;
  760.             GetLineSettings(LS);
  761.             SetLineStyle(SolidLn,0,NormWidth);
  762.             GetFillSettings(FS);
  763.             SetFillStyle(SolidFill,GetBkColor);
  764.             with EaselPtr(list)^ do begin
  765.                 y := (curNum-1)*toolh;
  766.                 bar3d(toolx, y, toolx + toolw - 1,
  767.                     y + toolh - 1, 0, false);
  768.                 SetFillStyle(SolidFill,GetColor);
  769.                 bar(toolx + toolw div 4, y + toolh div 4,
  770.                     toolx + toolw div 4 * 3,
  771.                     y + toolh div 4 * 3)
  772.                 end;
  773.             SetLineStyle(LS.LineStyle,LS.Pattern,
  774.                 LS.Thickness);
  775.             SetFillStyle(FS.Pattern,FS.Color);
  776.             mouse.show
  777.         end;
  778.  
  779.     procedure ColorTool.select;
  780.         begin
  781.         end;
  782.  
  783.     procedure ColorTool.doIt;
  784.         begin
  785.             draw
  786.         end;
  787.  
  788.     destructor ColorTool.done;
  789.         begin
  790.         end;
  791.  
  792.  
  793.     constructor PaletteTool.init;
  794.         begin
  795.             PaintTool.init(false)
  796.         end;
  797.  
  798.     procedure PaletteTool.draw;
  799.         var FS : FillSettingsType;
  800.             y, h, w, c : integer;
  801.  
  802.         begin
  803.             mouse.hide;
  804.             with EaselPtr(list)^ do begin
  805.                 h := toolh div ((GetMaxColor + 1) div 2);
  806.                 w := toolw div 2;
  807.                 y := (curNum-1)*toolh;
  808.                 GetFillSettings(FS);
  809.                 for c := 0 to GetMaxColor do begin
  810.                     SetFillStyle(SolidFill,c);
  811.                     bar(toolx+(c mod 2) * w,
  812.                         y+(c div 2) * h,
  813.                         toolx+(c mod 2) * w + w,
  814.                         y+(c div 2) * h + h)
  815.                     end
  816.                 end;
  817.             SetFillStyle(FS.Pattern,FS.Color);
  818.             mouse.show
  819.         end;
  820.  
  821.     procedure PaletteTool.select;
  822.         var mx, my, y, w, h, c : integer;
  823.         begin
  824.             if mouse.LeftPressed then begin
  825.                 mx := mouse.LastLeftPressX;
  826.                 my := mouse.LastLeftPressY
  827.                 end
  828.             else begin
  829.                 mx := mouse.LastRightPressX;
  830.                 my := mouse.LastRightPressY
  831.                 end;
  832.             with EaselPtr(list)^ do begin
  833.                 y := (curNum-1)*toolh;
  834.                 h := toolh div ((GetMaxColor + 1) div 2);
  835.                 w := toolw div 2;
  836.                 c := 0;
  837.                 while (mx > (toolx + (c mod 2) * w + w)) or
  838.                     (my > (y + (c div 2) * h + h)) do
  839.                     inc(c);
  840.                 if c <= GetMaxColor then begin
  841.                     if mouse.LeftPressed then
  842.                         SetColor(c)
  843.                     else
  844.                         SetBkColor(c);
  845.                     toolDraw(TypeOf(ColorTool),GetColor,GetBkColor);
  846.                     if doItDrawID = TypeOf(FillTool) then
  847.                        toolDraw(TypeOf(FillTool),GetColor,GetBkColor);
  848.                     end
  849.                 end;
  850.             while mouse.LeftPressed or mouse.RightPressed
  851.                 do;
  852.         end;
  853.  
  854.     procedure PaletteTool.doIt;
  855.         begin
  856.         end;
  857.  
  858.     destructor PaletteTool.done;
  859.         begin
  860.         end;
  861.  
  862.  
  863.     var E : Easel;
  864.         driver, mode, error : integer;
  865.         ch : char;
  866.  
  867.     begin
  868.         if not mouse.present then begin
  869.             clrscr;
  870.             writeln('Mouse driver not installed or mouse not properly connected!');
  871.             writeln('Press "enter" to halt.');
  872.             halt;
  873.             end;
  874.         driver := detect;
  875.         InitGraph(driver,mode,'');
  876.         error := GraphResult;
  877.         if error = grOk then begin
  878.             InitGraphText;
  879.             E.init;
  880.             E.doIt;
  881.             E.done;
  882.             CloseGraph;
  883.             CloseGraphText
  884.             end
  885.         else
  886.             writeln('Graphics error: ',GraphErrorMsg(error));
  887.         TextColor(LIGHTGRAY);
  888.         TextBackground(BLACK);
  889.         clrscr;
  890.         writeln('Omouse operates in Turbo''s screen coordinates instead');
  891.         writeln('of the more confusing mouse virtual coordinates.  Omouse');
  892.         writeln('has an automatic mouse event interrupt handler so you don''t ');
  893.         writeln('have to write your own.  All of the mouse driver functions');
  894.         writeln('are supported as omouse methods.  Let''s look at the mouse');
  895.         writeln('report while operating the mouse to see some of omouse''s');
  896.         write('internal data fields.  Press "enter" to continue ...');
  897.         readln;
  898.         gotoxy(1,24);
  899.         writeln('Move the mouse to see the automatic updating of omouse data.');
  900.         write('Press any key to terminate omouse''s report.');
  901.         window(10,4,60,22);
  902.         TextColor(BLACK);
  903.         TextBackground(LIGHTGRAY);
  904.         clrscr;
  905.         mouse.reset;
  906.         mouse.trap(10,4,60,22);
  907.         mouse.x := 54; mouse.y := 19;
  908.         mouse.GotoXY;
  909.         mouse.show;
  910.         mouse.offtrap(10,4,53,18);
  911.         mouse.AutoEventUpdate;
  912.         while (not KeyPressed) do begin
  913.             gotoxy(1,1);
  914.             mouse.OffTrap(10,4,53,18);
  915.             mouse.report;
  916.             mouse.show;
  917.             delay(500);
  918.         end;
  919.         if ReadKey = #0 then ch := ReadKey;
  920.         mouse.reset;
  921.  
  922.         window(1,1,80,25);
  923.         clrscr;
  924.         writeln('If you find omouse useful and are using it in your');
  925.         writeln('applications, a registration fee of $7 is requested.');
  926.         writeln('Upon registration you will be sent source code and the');
  927.         writeln('latest examples programs on a DOS formatted 5 1/4" disk.');
  928.         writeln;
  929.         writeln('PSW / Power SoftWare');
  930.         writeln('P.O. Box 10072');
  931.         writeln('McLean, Virginia 22102 8072');
  932.         writeln('(703) 759-3838');
  933.         writeln;
  934.         writeln('That''s all folks!');
  935.         writeln;
  936.         writeln('Press enter to quit.');
  937.         readln;
  938.         TextColor(LIGHTGRAY);
  939.         TextBackground(BLACK);
  940.         clrscr
  941.     end.