home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOTDOC.ZIP / CHAPT7.TXT < prev    next >
Encoding:
Text File  |  1991-02-11  |  29.4 KB  |  704 lines

  1.                                                                            Using
  2.                                                                          Windows
  3.  
  4.  
  5.  
  6.  
  7.          "A gentleman is a man who can play the accordian, but doesn't."
  8.  
  9.                                                                        Anonymous
  10.  
  11.  
  12.  
  13.  
  14. The Object Hierarchy
  15.  
  16.          All the objects discussed thus far are independent, i.e. no object has
  17.          any relationship with the others. However, the totWIN unit takes advan-
  18.          tage of an OOP facility known as inheritance.
  19.  
  20.          Sometimes, a program just needs a quick pop-up window to display a
  21.          message. Other times you may want to display a window which can be
  22.          moved or dragged around the screen. Furthermore, in sophisticated pro-
  23.          grams, you may want windows which can be moved and stretched by drag-
  24.          ging the lower-right window corner.
  25.  
  26.          Using traditional Pascal you might create multiple window types, one to
  27.          handle each window style. Or, you might create a single powerful window
  28.          which is capable of providing the most sophisticated window needs, but
  29.          with features that can be disabled when simple windows are required.
  30.          Both of these solutions are clumsy and usually result in wasted code.
  31.          Using OOP, we can create a basic window object, and then create a
  32.          sibling window object which inherits all the properties of the basic
  33.          window, but which has some additional features. This new window object
  34.          can also have a sibling object which inherits the properties of the
  35.          window objects from which it is derived. By linking these window
  36.          objects together, an object hierarchy is formed. Figure 7.1 illustrates
  37.          the totWIN object hierarchy.
  38.  
  39.          The four window objects have the following properties:
  40.  
  41.          WinOBJ         This basic window object paints a pop-up window on the
  42.                         display, with an optional shadow. Once the window has
  43.                         been displayed, all screen writing is restricted to
  44.                         within the window boundaries. Once the window is
  45.                         removed, the original (underlying) screen contents are
  46.                         restored, and the cursor is restored to its previous
  47.                         location and shape.
  48.  
  49.          MoveWinOBJ     This object has all the properties of the basic window,
  50.                         but the window can also be moved around the screen. This
  51.                         is useful for pop-up messages and the like, because the
  52.                         user can move the message to another location to see the
  53.                         obscured part of the display.
  54.  
  55.          ScrollWinOBJ   This object has all the properties of the moveable
  56.                         window, but the window can also have optional scroll
  57.                         bars displayed on the right and lower window edges.
  58.  
  59.  
  60. 7-2                                                                 User's Guide
  61.  
  62. --------------------------------------------------------------------------------
  63.  
  64.          StretchWinOBJ  This is the most sophisticated window object. It has all
  65.                         the properties of the other windows, but it can also be
  66.                         stretched and zoomed.
  67.  
  68. Figure 7.1                                                             [PICTURE]
  69. Window
  70. Object Hierarchy
  71.  
  72.  
  73.  
  74.          When you want to display a window, just create an instance of the
  75.          appropriate window type and call the relevant window methods. For exam-
  76.          ple, the following code fragment creates a basic pop-up window and
  77.          displays the message "Hello Mum". (The individual methods will be
  78.          discussed in detail in later sections.) When the program is executed, a
  79.          simple window is displayed, and the user can exit by pressing [KEYCAP]
  80.          or by clicking the mouse on the close [*] icon.
  81.  
  82.          program DemoWindowOne;
  83.          {DEMWI1}
  84.  
  85.          Uses DOS,CRT,
  86.               totFAST, totINPUT, totWIN;
  87.  
  88.          var
  89.            MyWindow: WinOBJ;
  90.            K: word;
  91.            X,Y: byte;
  92.          begin
  93.             Screen.Clear(white,'░'); {paint the screen}
  94.             with MyWindow do
  95.             begin
  96.                Init;
  97.                Draw;
  98.                Screen.WriteLn('Hello Mum');
  99.                Repeat
  100.                   WinGetKey(K,X,Y);
  101.                until (K = 600) or (K= 27);
  102.                Done;
  103.             end;
  104.          end.
  105.  
  106.  
  107.          The following demo program, DEMWI2.PAS, is the same as the previous
  108.          demo, except that the window instance is of type MoveWinOBJ. This pro-
  109.          gram creates a moveable window. The user can move the window by holding
  110.          down the mouse button on the top row of the window and dragging the
  111.          window. The same effect can be achieved by pressing [KEYCAP]and using
  112.          the arrow keys. Pressing [KEYCAP] ends the keyboard move operation.
  113.  
  114.          program DemoWindowTwo;
  115.          {DEMWI2 - a moveable window}
  116.  
  117.  
  118.  
  119. Using Windows                                                                7-3
  120.  
  121. --------------------------------------------------------------------------------
  122.  
  123.          Uses DOS,CRT,
  124.               totFAST, totINPUT, totWIN;
  125.  
  126.          var
  127.            MyWindow: MoveWinOBJ;
  128.            K: word;
  129.            X,Y: byte;
  130.          begin
  131.             Screen.Clear(white,'░'); {paint the screen}
  132.             with MyWindow do
  133.             begin
  134.                Init;
  135.                Draw;
  136.                Screen.WriteLn('Hello Mum');
  137.                Repeat
  138.                   WinGetKey(K,X,Y);
  139.                until (K = 600) or (K= 27);
  140.                Done;
  141.             end;
  142.          end.
  143.  
  144.  
  145.  
  146.  
  147. Window Attributes
  148.  
  149.          The color scheme used by all windows defaults to the colors defined in
  150.          the LookTOT^ instance. LookTOT^ also defines the special keys which are
  151.          used to move, stretch and zoom windows using the keyboard. By modifying
  152.          the LookTOT^ settings, you can quickly and easily change the default
  153.          window colors and special keys.
  154.  
  155.          The two LookTOT^ methods which control the windows defaults are:
  156.  
  157.  
  158.          LookTOT^.SetWindow(Border,Body,Icons,Title: byte);
  159.  
  160.          This method is used to specify the four window display attributes. All
  161.          windows have four basic color zones: the window border (where the box
  162.          is usually drawn), the main window body, the special mouse icons on the
  163.          top border, and the attributes for the title.
  164.  
  165.  
  166.          LookTOT^.SetWinKeys(Move,Stretch,Zoom: word);
  167.  
  168.          This method is used to define the keys which can be used to move,
  169.          stretch and zoom a window. By default these keys are [KEYCAP], [KEYCAP]
  170.          and [KEYCAP]. A user without a mouse must use these keys to manipulate
  171.          a window.
  172.  
  173.          Refer to the LookTOT section on page 3-12 of chapter 3: Toolkit Basics
  174.          for further information.
  175.  
  176.  
  177.  
  178. 7-4                                                                 User's Guide
  179.  
  180. --------------------------------------------------------------------------------
  181.  
  182.          You can, of course, change the default window display attributes for
  183.          any window instance. In other words, every window can have its own
  184.          unique color combinations. LookTOT^ is simply used to define the
  185.          default colors which will be used if no other colors are specified.
  186.  
  187.          Note: the special keys for window manipulation are not configurable for
  188.          each individual window. It would be confusing for the user if different
  189.          keys were used on different windows!
  190.  
  191.  
  192.  
  193.          All windows optionally support shadows. The shadow characteristics are
  194.          controlled by the global instance ShadowTOT^. Refer to page 3-13 for
  195.          further information.
  196.  
  197.  
  198.  
  199.  
  200.  
  201. Getting User Input
  202.  
  203.          In the last chapter you learned that the KEY instance is used to deter-
  204.          mine user input. If you were observant, you may also have noticed that
  205.          some of the key codes in table 6.1 represented special window actions.
  206.          For example, code 600 indicates that the user selected the close window
  207.          icon.
  208.  
  209.          If there is a window on display, and you are waiting for user input,
  210.          call the window method WinGetKey, rather than the Key.GetInput method.
  211.          Behind the scenes, WinGetKey calls Key.GetInput. The user action is
  212.          then checked to see if the user is trying to perform a window specific
  213.          task, like clicking on the close icon, or moving the window. The window
  214.          object will automatically process the key if it is a window-related
  215.          task, and adjust the key to indicate the task performed. The following
  216.          key codes indicate some window activity took place:
  217.  
  218.               600   Window closed
  219.               601   Window moved
  220.               602   Window re-sized
  221.               610   Scroll Up
  222.               611   Scroll Down
  223.               612   Scroll Left
  224.               613   Scroll Right
  225.               614   Vertical Elevator
  226.               615   Horizontal Elevator
  227.  
  228.  
  229.  
  230.           Note: if the key code indicates that the window has been re-sized or
  231.           scrolled, your application will need to refresh the window contents
  232.           as appropriate. Many of the other Toolkit units provide automatic
  233.  
  234.  
  235.  
  236. Using Windows                                                                7-5
  237.  
  238. --------------------------------------------------------------------------------
  239.  
  240.           support for displaying items like lists, files and directories in a
  241.           window. All this screen refreshing and display management is handled
  242.           for you.
  243.  
  244.  
  245.  
  246.  
  247.          The syntax of the WinGetKey method is as follows:
  248.  
  249.  
  250.          WinGetKey(var K:word; var X,Y: byte);
  251.  
  252.          This method is passed 3 variable parameters. The first parameter will
  253.          be updated with the key the user pressed, and the second two parameters
  254.          will be updated with the (X,Y) coordinates of the mouse when the action
  255.          took place. If the key code is 614 or 615 (indicating the user clicked
  256.          the mouse in the scroll bar) the  (X,Y) coordinates represent the frac-
  257.          tion (X/Y) showing how far down to scroll.
  258.  
  259.          Refer back to the example on page 7.3, and you will notice that WinGet-
  260.          Key is called until the user selects the close icon (code 600) or
  261.          presses [KEYCAP] (code 27).
  262.  
  263.  
  264.  
  265. Basic Windows
  266.  
  267.          The basic window object type is WinOBJ. Any WinOBJ instance is a static
  268.          pop-up window. Don't forget that every instance must be initialized
  269.          with the INIT method and disposed of with the DONE method. The DRAW
  270.          method is used to save the screen contents and display the window
  271.          frame. Any subsequent screen writes will be within the window. The
  272.          window can be removed with the method REMOVE, and the original screen
  273.          contents are then restored. Ordinarily, the window is automatically
  274.          removed when the DONE method is called.
  275.  
  276.          There are a variety of WinOBJ methods for setting the window character-
  277.          istics, as follows:
  278.  
  279.  
  280.          SetSize(X1,Y1,X2,Y2,Style:byte);
  281.  
  282.          When the window instance is initialized, the window is set with dimen-
  283.          sions (10,5) to (70,20) in a style of 1. The style parameter is the
  284.          same as the box style parameter discussed in chapter 5: Writing to the
  285.          Screen page 5-7. Call the method SetSize to customize the size and
  286.          style of the window.
  287.  
  288.  
  289.          SetTitle(Title:string);
  290.  
  291.          Sets the window title. The window objects support the use of the title
  292.          prefix characters, as discussed on page 5-8. If the Title is too long,
  293.          it will be truncated to fit within the window boundaries.
  294.  
  295.  
  296.  
  297. 7-6                                                                 User's Guide
  298.  
  299. --------------------------------------------------------------------------------
  300.  
  301.          SetColors(Border,Body,Title,Icons: byte);
  302.  
  303.          Use this method to customize the display attributes of the window. The
  304.          four parameters represent the combined foreground/background attributes
  305.          for the window border, window body, window title, and the close/zoom
  306.          icons respectively. If your program will be run on monochrome and color
  307.          systems, call the method Monitor^.ColorOn to decide whether to use
  308.          color or monochrome color combinations.
  309.  
  310.  
  311.          SetRemove(On:boolean);
  312.  
  313.          By default, the window is removed when the method Done is called. Use
  314.          this method to control whether the window is removed or not. Pass TRUE
  315.          to activate the window removal, or FALSE to leave the window image on
  316.          the screen when Done is called.
  317.  
  318.  
  319.          SetClose(On:boolean);
  320.  
  321.          This method controls whether the close icon [*] is drawn at the top
  322.          left of the window. Pass TRUE to enable it, or FALSE to disable it. By
  323.          default, the close icon is enabled.
  324.  
  325.  
  326.          The following example, DEMWI3.PAS, shows how to use these basic window
  327.          methods, and figure 7.2 shows the generated screen image:
  328.  
  329.          program DemoWindowThree;
  330.          {DEMWI3 - WinOBJ settings}
  331.  
  332.          Uses DOS,CRT,
  333.               totFAST, totINPUT, totWIN;
  334.  
  335.          var
  336.            MyWindow: WinOBJ;
  337.            K: word;
  338.            X,Y: byte;
  339.          begin
  340.             Screen.Clear(white,'░'); {paint the screen}
  341.             with MyWindow do
  342.             begin
  343.                Init;
  344.                SetSize(5,5,25,10,3);
  345.                SetTitle(' Greetings ');
  346.                SetClose(false);
  347.                SetRemove(false);
  348.                SetColors(94,95,89,80);
  349.                Draw;
  350.                Screen.WritePlain(1,1,'Hello Mum');
  351.                Repeat
  352.                   WinGetKey(K,X,Y);
  353.                until (K=27);
  354.  
  355.  
  356. Using Windows                                                                7-7
  357.  
  358. --------------------------------------------------------------------------------
  359.  
  360.                Done;
  361.             end;
  362.          end.
  363.  
  364.  
  365. Figure 7.2                                                              [SCREEN]
  366. A WinOBJ
  367. Example
  368.  
  369.  
  370.          The following WinOBJ function methods return information about the cur-
  371.          rent window settings:
  372.  
  373.  
  374.          GetSize(var X1,Y1,X2,Y2,Style: byte);
  375.  
  376.          This method is passed five variable parameters which are updated with
  377.          the current window coordinates and style.
  378.  
  379.  
  380.          GetX: byte;
  381.  
  382.          Returns the X coordinate of the upperleft window corner.
  383.  
  384.  
  385.          GetY: byte;
  386.  
  387.          Returns the Y coordinate of the upperleft window corner.
  388.  
  389.  
  390.          GetStyle: byte;
  391.  
  392.          Returns the window style.
  393.  
  394.  
  395.          GetBorderAttr: byte;
  396.  
  397.          Returns the display attribute of the window border.
  398.  
  399.  
  400.          GetBodyAttr: byte;
  401.  
  402.          Returns the display attribute of the main window area.
  403.  
  404.  
  405.          GetIconsAttr: byte;
  406.  
  407.          Returns the display attribute of the window close and zoom icons.
  408.  
  409.  
  410.          GetTitleAttr: byte;
  411.  
  412.          Returns the display attribute of the window title.
  413.  
  414.  
  415.          GetRemoveStatus: boolean;
  416.  
  417. 7-8                                                                 User's Guide
  418.  
  419. --------------------------------------------------------------------------------
  420.  
  421.          Returns true if the window will be removed when the Done method is
  422.          called.
  423.  
  424.  
  425.  
  426.          Once you have initialized the window and assigned the appropriate set-
  427.          tings, the window is ready to be displayed. To display the window, use
  428.          one of the following two methods:
  429.  
  430.  
  431.          Draw;
  432.  
  433.          The window is displayed, and the cursor is moved to the top left corner
  434.          of the window.
  435.  
  436.  
  437.          GrowDraw;
  438.  
  439.          This is the same as draw, except that the window g.r..o..w...s onto the
  440.          screen for a special effect.
  441.  
  442.  
  443.          Once the window has been drawn, use the standard Screen methods to
  444.          write to the window. Note that the upperleft coordinate of the inner
  445.          part of the window is (1,1). Refer to page 5-16 for a discussion of
  446.          window coordinates.
  447.  
  448.          The following method, Remove, can be used to remove the window:
  449.  
  450.  
  451.          Remove;
  452.  
  453.          Restores the original screen contents as well as the cursor location
  454.          and shape. If window coordinates were active when the window was drawn,
  455.          the previous window coordinates are restored.
  456.  
  457.  
  458.  
  459.          The Remove method is automatically called if the DONE method is called,
  460.          if the remove setting is true and if the window is still on display.
  461.          The Done method also disposes of any memory used by the window.
  462.  
  463.  
  464.  
  465. Moveable Windows
  466.  
  467.          A moveable window is like the static windows just described, except
  468.          that the user can move the window to any location on the screen. Remem-
  469.          ber that a user can move the window by holding down the left mouse
  470.          button on the top window border (making sure not to hit a window icon),
  471.          and dragging the window around the display. The same result can be
  472.          achieved by pressing the move hotkey (defined in LOOKtot^), which
  473.          defaults to [KEYCAP]. The window can then be moved by pressing the
  474.          cursor keys, and the move is completed by pressing [KEYCAP].
  475.  
  476.  
  477.  
  478. Using Windows                                                                7-9
  479.  
  480. --------------------------------------------------------------------------------
  481.  
  482.          A moveable window is created by declaring an instance of type MoveWi-
  483.          nOBJ. Moveable windows share all the properties of static windows, and
  484.          all the previously described methods are available. Moveable windows
  485.          have the following two methods which restrict window movement:
  486.  
  487.  
  488.          SetBoundary(X1,Y1,X2,Y2:byte);
  489.  
  490.          This method controls the area of the screen in which the window can be
  491.          moved. By default, this boundary is the entire screen. Use this method
  492.          to stop the user from placing the window on top of some information you
  493.          want to be displayed. For example, the following statement will keep
  494.          the window away from the top and bottom display lines:
  495.          SetBoundary(1,2,80,24);.
  496.  
  497.  
  498.          SetAllowMove(On:boolean);
  499.  
  500.          Not too surprisingly, by default, the Toolkit allows the user to move
  501.          moveable windows. This method allows you to restrict, and later, enable
  502.          window movement. Pass a False parameter to stop window movement, and a
  503.          True to enable movement. Circumstances under which you might use this
  504.          routine; you are using other Toolkit units, which themselves use move-
  505.          able windows, but you want to disable movement. For example, message,
  506.          list and browse objects.
  507.  
  508.  
  509.          Refer back to DEMWI2.PAS on page 7.3 for an example of a moveable
  510.          window.
  511.  
  512.  
  513.  
  514. Windows with Scroll Bars
  515.  
  516.          If you have run some of the larger Toolkit demo programs, you may have
  517.          noticed the scroll bars on some of the window boundaries. The scroll
  518.          bars provide a way for the user to scroll a window's contents using the
  519.          mouse. Various units in the Toolkit (discussed in later chapters) pro-
  520.          vide comprehensive support for displaying files, directories and lists
  521.          in windows with scroll bars. However, if these objects don't meet your
  522.          needs, you can build your own scrollable window using the ScrollWinOBJ
  523.          object.
  524.  
  525.          ScrollWinOBJ is a descendant of MoveWINOBJ, and so shares all the prop-
  526.          erties and methods of the moveable windows just discussed. In essence,
  527.          a scrollable window is simply a moveable window with scroll bars (see
  528.          figure 7.3).
  529.  
  530.  
  531.  
  532. Figure 7.3                                                              [SCREEN]
  533. A Scrollable
  534. Window
  535.  
  536.  
  537.  
  538.  
  539. 7-10                                                                User's Guide
  540.  
  541. --------------------------------------------------------------------------------
  542.  
  543.          Scrollable windows support both horizontal and/or vertical scroll bars,
  544.          which can be activated by calling the following method:
  545.  
  546.  
  547.          SetScrollable(Vert,Horiz:boolean);
  548.  
  549.          This method controls which scroll bars are drawn; the first parameter
  550.          controls the vertical scroll bar, and the second the horizontal one.
  551.          Pass a TRUE to instruct the window to display the scroll bars. By
  552.          default, both scroll bars are disabled, i.e. set to false.
  553.  
  554.  
  555.          The sliding elevator in the body of the scroll bar gives the user a
  556.          visual indication of which part of the data is currently being dis-
  557.          played in the window. For example, if the window is displaying a file
  558.          and the elevator is at the top of the scroll bar, the user must be
  559.          looking at the first part of the file. As the user scrolls down, the
  560.          elevator will jump down in increments. When the end of the file is
  561.          being viewed, the elevator will be at the bottom of the scroll bar.
  562.          Similary, the horizontal elevator will show the relative lateral posi-
  563.          tion of the window, e.g. how far along the line is being viewed.
  564.  
  565.          Whenever you change the contents of a scrollable window, you should
  566.          re-draw the scroll bar(s) to show the relative location of the dis-
  567.          played data. The methods DrawHorizBar and DrawVertBar are used for this
  568.          purpose. When a scroll bar is re-drawn, the Toolkit must be instructed
  569.          where to position the elevator. This is achieved by passing two parame-
  570.          ters to the drawing methods. The first parameter represents the current
  571.          value (or location), and the second is the maximum value. For example,
  572.          if you are browsing a 1000 line file, and the first line visible in the
  573.          window is 265, the passed parameters would be (265,1000).
  574.  
  575.          The syntax of the scroll bar drawing methods is as follows:
  576.  
  577.  
  578.          DrawHorizBar(Current,Max:longint);
  579.  
  580.          Draws a horizontal scroll bar at the bottom of the window and positions
  581.          the elevator based on the fraction (Current/Max).
  582.  
  583.  
  584.          DrawVertBar(Current,Max: longint);
  585.  
  586.          Draws a vertical scroll bar at the right of the window and positions
  587.          the elevator based on the fraction (Current/Max).
  588.  
  589.  
  590.  
  591.          Once you have initially displayed the window, call the method WinGet-
  592.          Key(K,X,Y); (discussed on page 7-4) to determine the user action. The
  593.          following key codes indicate some scrolling activity:
  594.  
  595.  
  596. Using Windows                                                               7-11
  597.  
  598. --------------------------------------------------------------------------------
  599.  
  600.               610   Scroll Up
  601.               611   Scroll Down
  602.               612   Scroll Left
  603.               613   Scroll Right
  604.               614   Vertical Elevator
  605.               615   Horizontal Elevator
  606.  
  607.  
  608.          You should re-draw the window contents based on the action requested by
  609.          the user. The codes 614 and 615 indicate the user clicked the left
  610.          mouse button on the body of the scroll bar. This means the user wants
  611.          to jump to a different part of the data. The X and Y parameters
  612.          returned from WinGetKey indicate which data to display. The X coordi-
  613.          nate represents the number of characters along from the top (or left)
  614.          of the scroll bar where the user clicked the mouse. The Y coordinate
  615.          indicates the total length of the scroll bar.
  616.  
  617.          For example, if the X and Y parameters are returned as 5 and 15,
  618.          respectively, you need to display the data which is 5/15ths of the way
  619.          from the top of the data. In our example of a 1000 line text file, you
  620.          would need to display the lines commencing with line 333, i.e.
  621.          (5/15)*1000.
  622.  
  623.          Having re-drawn the window contents, don't forget to re-draw the scroll
  624.          bars.
  625.  
  626.  
  627.            Note: only window styles 1 through 5 support scrollable windows.
  628.            If the style is set to any other value, the window will use style
  629.            1.
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636. Stretchable Windows
  637.  
  638.          The most flexible form of window supported by the Toolkit is called a
  639.          stretchable window. A stretchable window is a moveable window, the
  640.          dimensions of which can also be changed. A user can change the size of
  641.          a stretchable window by pressing down the left mouse button on the
  642.          lower right corner of the window and dragging the corner to the desired
  643.          location. The same result can be achieved by pressing the stretch
  644.          hotkey (defined in LOOKtot^), which defaults to [KEYCAP]. The window
  645.          can then be moved by pressing the cursor keys, and the move is com-
  646.          pleted by pressing [KEYCAP].
  647.  
  648.          A user can also zoom the window to its full size by clicking on the
  649.          zoom icon, located at the top right of the window. When the window is
  650.  
  651.  
  652.  
  653. 7-12                                                                User's Guide
  654.  
  655. --------------------------------------------------------------------------------
  656.  
  657.          fully zoomed, it can be restored to its pre-zoom dimensions by clicking
  658.          on the zoom icon a second time. The default zoom and un-zoom key is
  659.          [KEYCAP].
  660.  
  661.          To create a stretchable window, create an object instance of type
  662.          StretchWinOBJ. This object is descendant from ScrollWinOBJ and so
  663.          shares all its characteristics and methods.
  664.  
  665.          The coordinates of a full zoomed window are defined with the SetBounda-
  666.          ries method described in the previous section. The following method is
  667.          used to control the minimum window size:
  668.  
  669.  
  670.          SetMinSize(Width,Depth: byte);
  671.  
  672.          The two parameters set the minimum width and depth of the window in
  673.          characters. By default, the minimum is 10 characters wide by 5 charac-
  674.          ters deep.
  675.  
  676.  
  677.          The following method can be used to control whether the user is allowed
  678.          to stretch and zoom the window:
  679.  
  680.  
  681.          SetAllowStretch(On:boolean);
  682.  
  683.          Pass a False parameter to disable window stretching, or a True parame-
  684.          ter to enable window stretching. When stretching is disabled, the size
  685.          of the window cannot be changed with either the mouse or the keyboard.
  686.  
  687.  
  688.          Whenever a user stretches or zooms a window, the window is re-drawn
  689.          with the new dimensions, and the body of the window is cleared. You
  690.          must then rewrite the window contents, and re-draw the scroll bars.
  691.          WinGetKey will return a code of 602 if the user has re-sized the win-
  692.          dow.
  693.  
  694.          Listed below is the demo program DEMWI4.PAS which provides a framework
  695.          for building your own scrollable window routines.
  696.  
  697.          program DemoWindowFour;
  698.          {DEMWI4 - a StretchWinOBJ template}
  699.  
  700.          Uses DOS,CRT,
  701.               totFAST, totINPUT, totWIN;
  702.  
  703.          var
  704.            MyWindow: StretchWinOBJ;
  705.            K: word;
  706.            X,Y: byte;
  707.  
  708.  
  709.  
  710. Using Windows                                                               7-13
  711.  
  712. --------------------------------------------------------------------------------
  713.  
  714.          procedure ScreenRefreshProc;
  715.          {This procedure would refresh the screen contents}
  716.          begin
  717.             Screen.WritePlain(1,1,'Fresh Screen');
  718.             {...}
  719.             MyWindow.DrawHorizBar(1,100); {the parameters should reflect}
  720.             MyWindow.DrawVertBar(1,100);  {the data position of the window}
  721.          end;
  722.  
  723.          procedure ScrollUpProc;
  724.          begin
  725.          end;
  726.  
  727.          procedure ScrollDownProc;
  728.          begin
  729.          end;
  730.  
  731.          procedure ScrollLeftProc;
  732.          begin
  733.          end;
  734.  
  735.          procedure ScrollRightProc;
  736.          begin
  737.          end;
  738.  
  739.          procedure ScrollJumpVertProc(X,Y:byte);
  740.          begin
  741.          end;
  742.  
  743.          procedure ScrollJumpHorizProc(X,Y:byte);
  744.          begin
  745.          end;
  746.  
  747.          begin
  748.             Screen.Clear(white,'░'); {paint the screen}
  749.             with MyWindow do
  750.             begin
  751.                Init;
  752.                SetTitle(' Template ');
  753.                SetBoundary(1,1,80,24);
  754.                SetScrollable(true,true);
  755.                Draw;
  756.                ScreenRefreshProc;
  757.                Repeat
  758.                   WinGetKey(K,X,Y);
  759.                   case K of
  760.                   602: ScreenRefreshProc;
  761.                   610: ScrollUpProc;
  762.                   611: ScrollDownProc;
  763.                   612: ScrollLeftProc;
  764.                   613: ScrollRightProc;
  765.                   614: ScrollJumpVertProc(X,Y);
  766.  
  767.  
  768. 7-14                                                                User's Guide
  769.  
  770. --------------------------------------------------------------------------------
  771.  
  772.                   615: ScrollJumpHorizProc(X,Y);
  773.                   end;
  774.                until (K=27) or (K=600);
  775.                Done;
  776.             end;
  777.          end.
  778.  
  779.  
  780.  
  781.          In Part 2: Extending the Toolkit, techniques for creating objects
  782.          descendant from ScrollWinOBJ are discussed. Specifically, the text
  783.          describes how to create an object for scrolling a virtual screen within
  784.          a window.
  785.  
  786.  
  787.