home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TEGLP.ZIP / TEGLDOC.ZIP / TEGLDISK.PRN < prev    next >
Encoding:
Text File  |  1990-06-28  |  499.7 KB  |  16,280 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                            TEGL Windows Toolkit II
  23.                                 Release 1.10
  24.  
  25.  
  26.                         Programmer's Reference Guide
  27.                           for TURBO PASCAL 5.0/5.5
  28.                             and QUICK PASCAL 1.0
  29.  
  30.  
  31.  
  32.                 Copyright (C) 1990, TEGL Systems Corporation
  33.                              All rights reserved
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.                                          TEGL Systems Corporation
  51.                                          Suite 780, 789 West Pender Street
  52.                                          Vancouver, British Columbia
  53.                                          Canada V6C 1H2
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. TEGL Windows Toolkit II
  67.  
  68. LICENSE AGREEMENT
  69.  
  70. TEGL software products are protected under both Canada copyright
  71. law and international treaty provisions.
  72.  
  73. You have the non-exclusive right to use the enclosed software under the
  74. following terms and conditions.
  75.  
  76. You may use this software on a single machine, for both personal and
  77. business use; and may make copies of the software solely for backup
  78. purposes. Other than this you agree to use this software "like a book",
  79. meaning the software may be used by any number of people and may be moved
  80. from one computer to another so long as there is no possibility of it being
  81. used by more than one person at one time.
  82.  
  83. Programs that you write and compile using the TEGL Windows Toolkit may be
  84. used, given away, or sold without additional license or fees as long as
  85. all copies of such programs bear a copyright notice. By "copyright notice"
  86. we mean either your own copyright notice or if you prefer, the following
  87. statement, "Created using TEGL Windows Toolkit, copyright (C) 1989, 1990,
  88. TEGL Systems Corporation. All rights reserved".
  89.  
  90. Included on the TEGL Windows Toolkit diskettes are a number of support
  91. files that contain encoded hardware and font information used by the
  92. standard graphic unit. These files are proprietary to TEGL. You may use
  93. these files with the programs you create with the TEGL Windows Toolkit for
  94. your own personal or business use.  To the extent the programs you write
  95. and compile using the TEGL Windows Toolkit make use of these support files,
  96. you may distribute in combination with such programs, provided you do not
  97. use, give away, or sell these support files separately, and all copies of
  98. your programs bear a copyright notice.
  99.  
  100. The Complete Games Toolkit  diskettes provide a demonstration on how to use
  101. the various features of the TEGL Windows Toolkit.  They are intended for
  102. educational purposes only.  TEGL grants you the right to edit or modify
  103. these game programs for your own use but you may not give away, sell,
  104. repackage, loan, or redistribute them as part of any program, in executable
  105. object or source code form.  You may, however, incorporate miscellaneous
  106. sample program routines into your programs, as long as the resulting
  107. programs do no substantially duplicate all or part of a game program in
  108. appearance or functionality and all copies of all such programs bear a
  109. copyright notice.
  110.  
  111. Limited Warranty:
  112.  
  113. With respect to the physical diskette and physical documentation enclosed
  114. herein TEGL warrants same to be free of defects and materials and
  115. workmanship for a period of one year from the date of purchase.
  116.  
  117. TEGL will replace defective Software or documentation upon notice within
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. the warranty period of defects.  Remedy for breach of this warranty shall
  126. be limited to replacement and shall not encompass any other damages,
  127. including, without limitation, loss or business profits, business
  128. interruption, pecuniary loss, and special incidental, consequential, or
  129. other similar claims. This limited warranty is void if failure of the
  130. Software has resulted from accident, abuse, or misapplication.  Any
  131. replacement Software will be warranted for the remainder of the original
  132. warrantly period.
  133.  
  134. TEGL specifically disclaims all other warranties, express, implied, or
  135. statutory, including but not limited to implied warranties of
  136. merchantability and fitness for a particular purpose with respect to the
  137. Software and documentation.  In no event shall TEGL be liable for any loss
  138. of business profit or any other commercial damage including but not limited
  139. to special, incidental, consequential, or other damages.
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.                              Table of Contents
  183.  
  184.                               TABLE OF CONTENTS
  185.  SPECIAL NOTE for documentation on disk..................... 13
  186.  Acknowledgements........................................... 14
  187.  Chapter 1 - Introduction................................... 15
  188.    Programming with TEGL Windows Toolkit.................... 15
  189.    The Components of TEGL Windows Toolkit................... 15
  190.    What's On your disks..................................... 16
  191.    Installing TEGL Windows on your system................... 18
  192.    Development System Requirements.......................... 18
  193.    Compiling with Turbo Pascal.............................. 18
  194.    Compiling with Quick Pascal.............................. 18
  195.    How to use this Reference Manual......................... 18
  196.       TEGLSupervisor Procedure.............................. 19
  197.    Program Framework........................................ 19
  198.    Frames or Windows?....................................... 21
  199.    How to Contact TEGL Systems Corporation.................. 21
  200.  Chapter 2 - TEGL Easy...................................... 22
  201.    What TEGL Windows Toolkit can do......................... 22
  202.    Event-Driven Code........................................ 22
  203.    Attaching your Function to an Event...................... 23
  204.    Frames................................................... 24
  205.    Menus.................................................... 24
  206.    A Minimum TEGL Program................................... 25
  207.    Adding Menus (Top Down Design)........................... 25
  208.    Adding your First Event.................................. 27
  209.    TEGLEasy................................................. 29
  210.       ActiveButton Procedure................................ 29
  211.       ColToX Function....................................... 30
  212.       ErrMess Procedure..................................... 30
  213.       FitFrame Procedure.................................... 31
  214.       FrameFromIcon Procedure............................... 31
  215.       FrameText Procedure................................... 32
  216.       GetMousey Function.................................... 32
  217.       GetYesNo Function..................................... 33
  218.       EasyTEGL Procedure.................................... 33
  219.       LastCol Function...................................... 34
  220.       LastRow Function...................................... 34
  221.       OutFrameTextXY Procedure.............................. 34
  222.       Quit Event............................................ 35
  223.       QuickFrame Procedure.................................. 35
  224.       RestoreFont Procedure................................. 36
  225.       RowToY Function....................................... 36
  226.       SelectEasyFont Procedure.............................. 37
  227.       SetEasyFont Procedure................................. 37
  228.  Chapter 3 - Icons.......................................... 38
  229.    The ICON Editor.......................................... 38
  230.       The Main Bar Menu..................................... 38
  231.       Editing............................................... 38
  232.       The Drawing Bar Menu.................................. 38
  233.    ICON Constants........................................... 41
  234.       Putpict Procedure..................................... 41
  235.    ICON Assembler Procedures................................ 42
  236.  
  237.  Programmer's Reference Guide       - 4 -         TEGL Windows Toolkit
  238.  
  239.  
  240.  
  241.  
  242.  
  243.                              Table of Contents
  244.  
  245.    ICON Utilities........................................... 42
  246.       ICONDEF............................................... 42
  247.       ICONLIB............................................... 43
  248.       ICONINC............................................... 43
  249.       ICONASM............................................... 43
  250.    ICONS in TEGLIcon Unit................................... 44
  251.  Chapter 4 - Frames......................................... 45
  252.    Creating, Manipulating, and Dropping Frames.............. 45
  253.       CountFrames Function.................................. 45
  254.       FrameExist Function................................... 45
  255.       PushImage Procedure................................... 46
  256.       PopImage Procedure.................................... 47
  257.       RotateStackImage Procedure............................ 47
  258.       RotateUnderStackImage Procedure....................... 48
  259.       DropStackImage Procedure.............................. 49
  260.       HideImage Procedure................................... 50
  261.       ShowImage Procedure................................... 51
  262.       ShowCoordinates Event................................. 52
  263.    Preparing a Frame for Update............................. 52
  264.       PrepareForPartialUpdate Procedure..................... 52
  265.       PrepareForUpdate Function............................. 53
  266.       CommitUpdate Procedure................................ 54
  267.    Moving a Frame........................................... 55
  268.       FrameSelectAndMove Function........................... 55
  269.       SetAutoRotate Procedure............................... 56
  270.       SetMoveRestrictions Procedure......................... 57
  271.       SetFrameMobility Procedure............................ 57
  272.       SetMoveFrameCallProc Procedure........................ 58
  273.       MoveStackImage Procedure.............................. 59
  274.       MoveFrame Procedure................................... 60
  275.    Low Level Frame Functions................................ 60
  276.       UnLinkFS Procedure.................................... 60
  277.       LinkFS Procedure...................................... 61
  278.       LinkUnderFS Procedure................................. 62
  279.       CreateImageBuffer Procedure........................... 63
  280.       DropImageBuffer Procedure............................. 64
  281.       GetFSImage Function................................... 65
  282.       PutFSImage Procedure.................................. 66
  283.       FreeImageBuffer Procedure............................. 67
  284.       GetPartialFrontImage Function......................... 67
  285.       GetFrontImage Function................................ 68
  286.       PageInFS Procedure.................................... 68
  287.       LockImage Procedure................................... 69
  288.       PageOutFS Procedure................................... 70
  289.       SetImageCoordinates Procedure......................... 70
  290.       PageOutImageStack Function............................ 71
  291.       UnLockImage Procedure................................. 71
  292.       UnUseImage Procedure.................................. 72
  293.       UseImage Procedure.................................... 72
  294.    Mouse Click Areas........................................ 73
  295.       DefineMouseClickArea Procedure........................ 73
  296.       FindMouseClickPtr Function............................ 75
  297.  
  298.  Programmer's Reference Guide       - 5 -         TEGL Windows Toolkit
  299.  
  300.  
  301.  
  302.  
  303.  
  304.                              Table of Contents
  305.  
  306.       ResetMSClickActive Procedure.......................... 77
  307.       ResetMSClickCallProc Procedure........................ 79
  308.       ResetMouseClicks Procedure............................ 80
  309.       ResetMSClickSense Procedure........................... 81
  310.    Keyboard................................................. 83
  311.       ClearKeyBoardBuf Procedure............................ 83
  312.       ClearTEGLKeyBoardBuf Procedure........................ 83
  313.       DefineGlobalKeyClickArea Procedure.................... 83
  314.       DefineLocalKeyClickArea Procedure..................... 84
  315.       DropKeyClick Procedure................................ 85
  316.       FindKeyClickPtr Function.............................. 85
  317.       ResetKeyClickCallProc Procedure....................... 85
  318.  Chapter 5 - Menus.......................................... 87
  319.    Creating a Menu.......................................... 87
  320.    Creating a entry text list............................... 87
  321.       CreateOptionMenu Function............................. 89
  322.       DefineOptions Procedure............................... 90
  323.       CreateShadowOM Function............................... 91
  324.       ResizeOptionMenu Procedure............................ 92
  325.       ToggleCheckMark Procedure............................. 93
  326.       ToggleEntryStatus Procedure........................... 93
  327.       ReplaceOptionText Procedure........................... 94
  328.       ToggleOptionBar Procedure............................. 95
  329.       SetOptionMenuColors Procedure......................... 96
  330.       SetOptionMenuBorderColor Procedure.................... 96
  331.       SetHideSubMenu Procedure.............................. 97
  332.    Creating a Bar Menu...................................... 97
  333.       CreateBarMenu Procedure............................... 98
  334.       OutBarOption Procedure................................ 98
  335.       SetBarTextColor Procedure............................. 99
  336.       SetBarMenuColor Procedure............................. 99
  337.       SetBarBorderColor Procedure...........................100
  338.       SetBarBorderOff Procedure.............................100
  339.       SetBarShadowtext Procedure............................101
  340.       SetBarFillStyle Procedure.............................101
  341.       SetBarMenuMargin Procedure............................102
  342.    Icon Option Menus........................................102
  343.       DefineOptionClickArea Procedure.......................102
  344.       ResetOptionMenuEvents Procedure.......................103
  345.  Chapter 6 - Mouse, Keyboard and Timer Handlers.............105
  346.    Interrupts...............................................105
  347.       SwapTEGLIntrOff Procedure.............................105
  348.       SwapTEGLIntrOn Procedure..............................106
  349.    Mouse Emulation..........................................106
  350.       MCursorOff Procedure..................................106
  351.       MCursorOn Procedure...................................107
  352.       MSetPos Procedure.....................................107
  353.    Standard Mouse Functions.................................107
  354.       ShowMouse Procedure...................................108
  355.       HideMouse Procedure...................................108
  356.       SetMousePosition Procedure............................108
  357.       CursorShape Procedure.................................109
  358.  
  359.  Programmer's Reference Guide       - 6 -         TEGL Windows Toolkit
  360.  
  361.  
  362.  
  363.  
  364.  
  365.                              Table of Contents
  366.  
  367.       SetMouseHotSpot Procedure.............................110
  368.       SetMouseColor Procedure...............................111
  369.       MousePosition function................................111
  370.       GetButtonReleaseInfo Procedure........................112
  371.       GetButtonPressInfo Procedure..........................112
  372.       ClearButtonInfo Procedure.............................113
  373.       SetMouseMinMax Procedure..............................113
  374.       FrozenMouse Procedure.................................114
  375.       FreezeMouse function..................................114
  376.       UnFreezeMouse Procedure...............................115
  377.       SetMouseSensitivity Procedure.........................116
  378.       GetMouseSensitivity Procedure.........................116
  379.       SetKeyBoardMouse Procedure............................117
  380.       SetKBSteps Procedure..................................117
  381.       GetKBSteps Procedure..................................118
  382.    Timer Functions..........................................118
  383.       SwapTimerOut Procedure................................119
  384.       SwapTimerIn Procedure.................................119
  385.       SetTimerStart Procedure...............................119
  386.       ResetTimerFlag Procedure..............................120
  387.       DropTimerCount Procedure..............................120
  388.       TimerSwtich Procedure.................................121
  389.    Keyboard Interrupt Events................................121
  390.    Keyboard Scan Codes......................................122
  391.       AddCaptureKey Procedure...............................122
  392.       DeleteCaptureKey Procedure............................123
  393.       TEGLReadkey Function..................................123
  394.       TEGLKeyPressed Function...............................124
  395.       NilKeyCallProc Function...............................124
  396.    Keyboard Miscellaneous...................................125
  397.       SetShiftKeys Procedure................................125
  398.    Show Button Status.......................................125
  399.       ShowButtonStatus Event................................125
  400.  Chapter 7 - Assembly Language Graphics.....................127
  401.    Setting Video Modes......................................127
  402.       CGA640x200x2 Procedure................................128
  403.       EGA640x350x16 Procedure...............................128
  404.       Herc720x200x2 Procedure...............................128
  405.       SetVideoChoices.......................................129
  406.       SVGA800x600x16........................................129
  407.       VGA640x480x16 Procedure...............................129
  408.       VideoAutoDetect.......................................130
  409.       VideoID...............................................130
  410.    Graphic Primitives.......................................131
  411.       FastLine Procedure....................................131
  412.       Putpixs Procedure.....................................132
  413.       Getpixs Function......................................132
  414.       Getbiti Procedure.....................................133
  415.       Putbiti Procedure.....................................133
  416.       BigImageSize Function.................................134
  417.       SetAPage Procedure....................................134
  418.       SetVPage Procedure....................................135
  419.  
  420.  Programmer's Reference Guide       - 7 -         TEGL Windows Toolkit
  421.  
  422.  
  423.  
  424.  
  425.  
  426.                              Table of Contents
  427.  
  428.       FlipAPage Procedure...................................135
  429.       FlipVPage Procedure...................................136
  430.       VideoPage Function....................................136
  431.    New Graphic Primitives...................................137
  432.       Extractpixs Function..................................137
  433.       ExtractIMG Procedure..................................137
  434.       OverlayIMG Procedure..................................138
  435.       SwapBytes Procedure...................................138
  436.    Graphic Derivatives......................................138
  437.       XORCornerBox Procedure................................139
  438.       XORBox Procedure......................................139
  439.    Icon Graphics............................................139
  440.       Putpict Procedure.....................................139
  441.       PictSize Procedure....................................140
  442.       Abort Procedure.......................................140
  443.  Chapter 8 - Special Effects................................142
  444.    Screen Backdrop..........................................142
  445.       ClearTEGLScreen Procedure.............................142
  446.       SetTEGLBorderShow Procedure...........................143
  447.       SetTEGLBackColor Procedure............................143
  448.       SetTEGLBorderColor Procedure..........................144
  449.       SetTEGLFillPattern Procedure..........................145
  450.       SetTEGLFillStyle Procedure............................145
  451.    Creating Shadow Boxes....................................146
  452.       ShadowBox Procedure...................................146
  453.       ShadowBoxText Procedure...............................147
  454.       SetShadowColor Procedure..............................147
  455.       SetShadowBorderColor Procedure........................148
  456.       SetShadowFillPattern Procedure........................148
  457.       SetShadowFillStyle Procedure..........................149
  458.    Creating Shadow Text.....................................150
  459.       Shadowtext Procedure..................................150
  460.       SetShadowTextType Procedure...........................150
  461.       SetShadowTextShadow Procedure.........................151
  462.       SetShadowTextHighlight Procedure......................152
  463.       ShadowTextHighlightOFF Procedure......................152
  464.    Other text effects.......................................153
  465.       ExtendTextXY Procedure................................153
  466.       ShiftTextXY Procedure.................................153
  467.    Buttons..................................................154
  468.       DefineButtonClick Procedure...........................154
  469.       DefineLongButtonClick Procedure.......................154
  470.       DefineUserButtonClick Procedure.......................155
  471.       PutUserButtonClick Procedure..........................155
  472.    Explosions...............................................156
  473.       CollapseToIconShow Event..............................156
  474.       CollapseToMsClick Event...............................156
  475.       ExplodeFromIconHide...................................157
  476.       ExplodeFromMsClick Procedure..........................157
  477.    Moving and Transforming XOR Boxes........................158
  478.       MoveBox Procedure.....................................158
  479.       ZipToBox Procedure....................................159
  480.  
  481.  Programmer's Reference Guide       - 8 -         TEGL Windows Toolkit
  482.  
  483.  
  484.  
  485.  
  486.  
  487.                              Table of Contents
  488.  
  489.       ZipFromBox Procedure..................................159
  490.    Icon Button..............................................160
  491.       DrawLongButton Procedure..............................160
  492.  Chapter 9 - Writing Events.................................162
  493.    Mouse Awareness..........................................162
  494.       FindFrame Function....................................162
  495.       CheckMouseClickPos Function...........................164
  496.       CheckForMouseSelect Function..........................165
  497.    Special Effects..........................................167
  498.       PressButton Procedure.................................167
  499.       VisualButtonPress Function............................169
  500.  Chapter 10 - Animation.....................................171
  501.    Animation Overview.......................................172
  502.    Animation OOPS Methods...................................174
  503.       Origin Procedure Method...............................174
  504.       GetOrigin Procedure Method............................175
  505.       Destination Function Method...........................175
  506.       ResetFrame Procedure Method...........................176
  507.       Sequence Procedure Method.............................177
  508.       ResetSequence Procedure Method........................177
  509.       AddFrame Procedure Method.............................178
  510.       CurrentFrameNumber Function Method....................179
  511.       AnimateInit Procedure Method..........................179
  512.       Animate Procedure Method..............................180
  513.       Complete Procedure Method.............................180
  514.    Example Animation........................................180
  515.  Chapter 11 - Writing Text..................................183
  516.    TEGLWrt Variables........................................183
  517.    Bit-mapped Fonts.........................................183
  518.    Creating Your Own Bit-mapped Fonts.......................183
  519.    TEGLWrt Functions and Procedures.........................183
  520.       OutTEGLTextXY Procedure...............................184
  521.       TEGLTextWidth Function................................184
  522.       TEGLCharWidth Function................................185
  523.       TEGLCharHeight Function...............................185
  524.       TEGLWrtChar Procedure.................................186
  525.       SetProportional Procedure.............................186
  526.       SetTEGLFont Procedure.................................186
  527.       UnderLineChar Function................................187
  528.    Showing ALL Fonts FONTTEST.PAS...........................187
  529.       FontName Function.....................................187
  530.       ShowOneFont Event.....................................188
  531.       ShowFonts Event.......................................188
  532.  Chapter 12 - Event Library.................................189
  533.    The File Selector........................................189
  534.       SelectaFile function..................................189
  535.    String Editing Dialog....................................191
  536.       EditString Procedure..................................191
  537.    Mouse Sensitivity Dialogue Window........................191
  538.       SetMouseSense Procedure...............................192
  539.    Bells & Whistles, Sound Unit.............................192
  540.       AskSoundSense Event...................................192
  541.  
  542.  Programmer's Reference Guide       - 9 -         TEGL Windows Toolkit
  543.  
  544.  
  545.  
  546.  
  547.  
  548.                              Table of Contents
  549.  
  550.       Beep Procedure........................................193
  551.       SlideBeep Procedure...................................193
  552.       SoundSwitch Procedure.................................194
  553.  Chapter 13 - Virtual Memory Manager........................195
  554.    Heap Management..........................................195
  555.    The Turbo Pascal Heap Manager............................195
  556.    The TEGL Heap Manager....................................196
  557.    The TEGL Heap Error Function.............................196
  558.    The TEGL Heap Manager Functions..........................197
  559.       TEGLGetMem Procedure..................................197
  560.       TEGLFreeMem Procedure.................................198
  561.    Expanded Memory Manager (EMM)............................198
  562.    Expanded Memory Functions................................199
  563.       EmmInstalled function.................................199
  564.       EMSPagesAvailable function............................200
  565.       AllocateExpandedMemoryPages function..................200
  566.       MapExpandedMemoryPages function.......................201
  567.       GetPageFrameBaseAddress function......................201
  568.       DeallocateExpandedMemoryPages function................202
  569.       GetVersionNumber function.............................202
  570.       GetHandleCountUsed function...........................203
  571.       GetPagesOwnedByHandle function........................203
  572.    Expanded Memory Test Program.............................204
  573.    A RAM Disk Driver........................................207
  574.       EMSOpen function......................................207
  575.       EMSSeek procedure.....................................208
  576.       EMSBlockWrite procedure...............................209
  577.       EMSBlockRead procedure................................209
  578.       EMSClose procedure....................................210
  579.    Virtual Disk Heap........................................211
  580.       VDskOpenHeapFile function.............................211
  581.       VEMSOpenHeapFile function.............................212
  582.       VDSKGetMem function...................................213
  583.       VDSKFreeMem procedure.................................214
  584.       VDSKWriteHeapData procedure...........................214
  585.       VDSKReadHeapData procedure............................215
  586.       VDskCloseHeapFile procedure...........................215
  587.    The Virtual Heap Error Function..........................216
  588.    The Virtual Memory Manager...............................216
  589.       UseHardDisk procedure.................................217
  590.       MoveFromVirtual procedure.............................217
  591.       MoveToVirtual function................................218
  592.       FreeVirtual procedure.................................218
  593.       CloseVirtual procedure................................219
  594.       TEGLMaxAvail Function.................................219
  595.       VirtualMemUsed Function...............................219
  596.    The Virtual Memory Error Function........................220
  597.    Resolving Fragments......................................220
  598.       ReserveHugeMinimum procedure..........................221
  599.  Sizing and Sliders.........................................223
  600.       DefineResizeClickArea Procedure.......................223
  601.       DefineResizeMinMax Procedure..........................224
  602.  
  603.  Programmer's Reference Guide       - 10 -         TEGL Windows Toolkit
  604.  
  605.  
  606.  
  607.  
  608.  
  609.                              Table of Contents
  610.  
  611.       DefineSliderArea Procedure............................224
  612.       DropSliders Procedure.................................225
  613.       FindSliderFS Function.................................225
  614.       ResizeFrame Procedure.................................226
  615.       SelectAndMoveFrame Event..............................226
  616.       SetSlidePosition Procedure............................227
  617.  Miscellaneous Functions....................................228
  618.       CheckCtrlBreak Procedure..............................228
  619.       CheckCtrlBreakFS Procedure............................228
  620.       DropTimerTick Procedure...............................229
  621.       NilUnitProc Event.....................................229
  622.       OverLapArea Function..................................230
  623.       SetTimerTick Procedure................................230
  624.  TGraph.....................................................231
  625.       Bar Procedure.........................................232
  626.       CloseGraph Procedure..................................232
  627.       DetectGraph Procedure.................................233
  628.       GetBkColor Function...................................233
  629.       GetColor Function.....................................233
  630.       GetFillPattern Procedure..............................234
  631.       GetGraphMode Function.................................234
  632.       GetMaxX Function......................................235
  633.       GetMaxY Function......................................235
  634.       GetTextSettings Procedure.............................235
  635.       ImageSize Function \ TGraph...........................236
  636.       GraphResult Function..................................236
  637.       InitGraph Procedure...................................236
  638.       Line Procedure........................................237
  639.       OutTextXY Procedure...................................237
  640.       Rectangle Procedure...................................238
  641.       RestoreCrtMode Procedure \ TGraph.....................238
  642.       SetBkColor Procedure..................................238
  643.       SetColor Procedure....................................239
  644.       SetFillPattern Procedure..............................239
  645.       SetFillStyle Procedure................................239
  646.       SetTextJustify Procedure..............................240
  647.  APPENDICES.................................................241
  648.    Video Buffers............................................241
  649.    Windows..................................................241
  650.    Frames...................................................241
  651.    A Frame Stack............................................242
  652.    A Simple Window Manager..................................242
  653.    Partial Image Update.....................................244
  654.    Refined Partial Image Update.............................244
  655.    A Refined Partial Image Update Algorithm.................245
  656.    A Quick Run through the algorithm........................246
  657.    Turbo Pascal Heap Manager................................248
  658.    TEGL Heap Manager........................................252
  659.    Combining the best of both Heap Managers (Coexisting)....255
  660.    Variables, Types and Const...............................257
  661.       ActivePage Word Typed Const...........................257
  662.       CallProc Procedure Type...............................257
  663.  
  664.  Programmer's Reference Guide       - 11 -         TEGL Windows Toolkit
  665.  
  666.  
  667.  
  668.  
  669.  
  670.                              Table of Contents
  671.  
  672.       FG* Const.............................................257
  673.       Jagged Word Typed Const...............................257
  674.       MSClick Boolean Const.................................258
  675.       MSSense Boolean Const.................................258
  676.       RmwBits Word Typed Const..............................258
  677.    Conditional Compilation..................................258
  678.  INDEX......................................................261
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  Programmer's Reference Guide       - 12 -         TEGL Windows Toolkit
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733. SPECIAL NOTE for documentation on disk
  734.  
  735. You have received Version II of the TEGL Windows Toolkit. The
  736. documentation that you are reading is supplied on disk. We will have a
  737. printed manual in the near future and it will be somewhat different that
  738. what you are looking at now.
  739.  
  740. Because we wanted everyone to be able to read this manual and be able to
  741. print it out we have not embedded any special control characters in it
  742. with the exception of formfeeds at page breaks.
  743.  
  744. In this manual you will notice that at times there are references to
  745. things like ctrlkey or keydown or something discriptive but somewhat odd.
  746. Please, be imaginative, these will be icons when the manual is printed.
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  Programmer's Reference Guide       - 13 -         TEGL Windows Toolkit
  787.  
  788.  
  789.  
  790.  
  791.  
  792.                            Acknowledgements
  793.  
  794. Acknowledgements
  795. ___________________________________________________________________________
  796.  
  797. In this manual references are made to several products
  798.  
  799.  
  800.      IBM is a registered trademarks of International Business
  801.      Machines Inc.
  802.  
  803.      MS-DOS and Windows are registered trademarks of Microsoft
  804.      Inc.
  805.  
  806.      MacIntosh is a registered trademark of Apple Computer Inc.
  807.  
  808.      Turbo Pascal is a registered trademake of Borland International.
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  Programmer's Reference Guide       - 14 -         TEGL Windows Toolkit
  848.  
  849.  
  850.  
  851.  
  852.  
  853.                         Chapter 1 - Introduction
  854.  
  855.  
  856. INTRODUCTION
  857. ___________________________________________________________________________
  858.  
  859. Welcome to the world of the Graphic User Interface (GUI) in a DOS
  860. environment. This book, The programmers reference guide to TEGL
  861. Windows Toolkit II, will provide you with the basics (and more) for
  862. getting started with using the TEGL Windows Toolkit.
  863.  
  864. TEGL Windows is a comprehensive GUI toolkit for the simplest to the most
  865. complex system programming projects. In order to exploit all the
  866. advantages of this toolkit, we encourage you to experiment and to try the
  867. examples as listed in this manual.
  868.  
  869. Programming with TEGL Windows Toolkit
  870.  
  871. TEGL Windows Toolkit provides the framework to make programs easy to use.
  872. If you are new to programming you will find the Toolkit fun and fast to
  873. use. Experienced programmers will find their development time reduced by
  874. using the Toolkit.
  875.  
  876. TEGL Windows Toolkit provides graphics that can communicate information
  877. more effectively than text. For example, the graphical image of a folder
  878. suggests that it contains documents, drawings, and even other folders.
  879.  
  880. TEGL Windows Toolkit also Provides functions that can build interactive
  881. applications. Interactive means a type of user interface where a
  882. significant portion of the design and development effort goes into making
  883. the program user friendly.
  884.  
  885. TEGL Windows Toolkit is based on event handling. Events are such things as
  886. a key being pressed on the keyboard; a timer signaling that some amount of
  887. time has elapsed; a message indicating that the user has selected a
  888. particular item from the menu or has selected an icon. A particularly
  889. useful capability of this is that while the TEGLSupervisor is waiting
  890. for one of these events to occur, you can set the timer to signal a
  891. background task such as an internal print spooler. This limited
  892. multitasking capability makes it easier to build very interactive
  893. programs.
  894.  
  895. TEGL Windows Toolkit supports only a single application running at any
  896. given time. The necessary code is linked into the final application code.
  897. TEGL Windows Toolkit uses little RAM, requiring only 50k of the executable
  898. program when all features are used.
  899.  
  900. The Components of TEGL Windows Toolkit
  901.  
  902. Now that you have a rough idea of what the TEGL Windows Toolkit is,
  903. let's explore the components in more detail. The purpose of this section
  904. is to give you an overall understanding of how to use the toolkit in your
  905. program.
  906.  
  907.  
  908.  Programmer's Reference Guide       - 15 -         TEGL Windows Toolkit
  909.  
  910.  
  911.  
  912.  
  913.  
  914.                         Chapter 1 - Introduction
  915.  
  916. TEGL Windows Toolkit is subdivided into a set of libraries: multitasking
  917. kernel; windowing screen manager; mouse, keyboard and timer handler; a
  918. virtual heap manager; drop down and pop-up menu events; and an animation
  919. unit.
  920.  
  921. TEGL Windows Toolkit provides a GUI to a computer running under DOS. This
  922. interface is used in a number of entertainment products produced by TEGL
  923. Systems Corporation (TSC). As TSC designed and built the entertainment
  924. products, TEGL was created to build a set of software routines that were
  925. needed by the games. TSC gathered these routines into modules, each
  926. categorized by their overall function. For instance, all the routines that
  927. manipulate windows form the TEGLUnit. Similarly, all the drop-down menus
  928. and menu bars form TEGLMenu.
  929.  
  930. TEGL Windows Toolkit comprises the tools that were developed in writing
  931. the first TSC applications. These tools are now available for developing
  932. any application.
  933.  
  934. The modules are categorized by the kind of functions they deliver;
  935. TEGLintr handles the mouse, keyboard and timer interrupts; TEGLMenu
  936. provides drop down menus and menu bars; Animate provides icon animation;
  937. and VIRTMem provides the virtual heap for almost unlimited windowing
  938. ability.
  939.  
  940. TEGLUnit provides a high level integration between window frames,
  941. mouse click areas, keyboard handler, timer interrupts, virtual memory, and
  942. multitasking kernel.
  943.  
  944. What's On your disks
  945. The distribution disks that come with this manual include the complete
  946. library of routines used by some of the game products produced by TEGL
  947. Systems Corporation.
  948.  
  949. For your reference, here's a summary of most of the files on disks:
  950.  
  951. README
  952.                    This file contains any last-minute notes and
  953.                    corrections, type README at the system prompt to
  954.                    view the file. You may print this file on your printer
  955.                    for future reference once you review the material.
  956. TEGLUNIT.PAS
  957.                    This is the window manager that provides the graphical
  958.                    interface support for the other units. This module
  959.                    provides the event supervisor and the frame/stack
  960.                    coordinator.
  961. TEGLMENU.PAS
  962.                    This unit provides the drop down menu interface.
  963. TEGLGRPH.PAS
  964.                    This unit provides shadow boxes, shadow texts,
  965.                    exploding and imploding boxes, pop-down/pop-up icon
  966.                    buttons, etc..
  967. TEGLICON.PAS
  968.  
  969.  Programmer's Reference Guide       - 16 -         TEGL Windows Toolkit
  970.  
  971.  
  972.  
  973.  
  974.  
  975.                         Chapter 1 - Introduction
  976.  
  977.                    A library of standard icons; key OK, key CANCEL,
  978.                    key NEXT, key LAST.
  979. TEGLINTR.PAS, TEGLINTR.ASM
  980.                    Integration of keyboard and mouse handler.  This unit
  981.                    provides the standard mouse routines which integrates
  982.                    the keyboard cursor keys and the mouse to provide a
  983.                    seamless dual control of the mouse cursor; with or
  984.                    without a mouse driver.
  985. FASTGRPH.PAS *.ASM
  986.                    Fast assembly language graphics routines. This is the
  987.                    core of the graphical routines that provide the
  988.                    foundation for pop-down menus and movable windows.
  989.                    This unit includes functions that interfaces with the
  990.                    FASTGRPH and the ANIMATE unit, to allow the recognition
  991.                    of video paging.
  992. TEGLFONT.PAS FNT*.pas
  993.                    Crisp proportional Bit-Mapped screen fonts, ranging
  994.                    from 6 to 24 pixels in height.
  995. VIRTMEM.PAS
  996.                    Virtual memory handler that interfaces with TEGLUNIT.
  997.                    This unit automatically pages out images from memory to
  998.                    EMS, hard disk, or floppy (depending on availability),
  999.                    when memory is at a premium. Also implements the far
  1000.                    heap for allocating data structures larger than 64K.
  1001. SELECTFL.PAS
  1002.                    A standard event unit that may be used by any
  1003.                    application program to provide a dialogue window in
  1004.                    selecting file names from a list of file on disk.
  1005. SENSEMS.PAS
  1006.                    A standard event unit that provides a dialogue window
  1007.                    that allows a user to adjust the sensitivity of a
  1008.                    mouse.
  1009. SOUNDUNT.PAS
  1010.                    A standard event unit that allows a user to adjust the
  1011.                    duration and the sound output of a tone.
  1012. SWITCHES.INC
  1013.                    Conditional compilaton directive are contained in this
  1014.                    file.
  1015. ANIMATE.PAS
  1016.                    A unit that allows icons to be animated.
  1017. TEGL.PAS
  1018.                    A demonstration program that uses many of the features
  1019.                    of the TEGL Windows Toolkit.
  1020. FONTTEST.PAS
  1021.                    A demonstration event unit that displays all available
  1022.                    fonts in movable windows. Used in tegl.pas (sample
  1023.                    program).
  1024. DEBUGUNT.PAS
  1025.                    A demonstration event unit that displays general
  1026.                    information regarding windows and the number of times
  1027.                    the mouse button has been pressed.
  1028. SAM*.PAS
  1029.  
  1030.  Programmer's Reference Guide       - 17 -         TEGL Windows Toolkit
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.                         Chapter 1 - Introduction
  1037.  
  1038.                    Some of the  sample programs in this guide are provided
  1039.                    in ready-to-compile form.
  1040. EXECSWAP.PAS
  1041.                    A utility unit that swaps a pascal program from memory
  1042.                    to enable another program to execute. This unit makes
  1043.                    it practical to execute a DOS shell with programs that
  1044.                    are using all of memory.
  1045.  
  1046.  
  1047. Installing TEGL Windows on your system
  1048. The complete TEGL Toolkit is approximately 3 megabytes of source code
  1049. when expanded. Therefore, a hard disk is required for the installation.
  1050.  
  1051. At the DOS prompt, type INSTALL, and follow the instructions.
  1052.  
  1053. Development System Requirements
  1054. You must have 640k RAM, a hard disk drive, and an EGA/VGA (256K), CGA, or
  1055. Hercules graphics card and appropriate monitor on an IBM PC or compatible
  1056. computer. In our development, we've used an IBM PC AT with 2.5MB RAM, 72MB
  1057. hard disk, and a paradise VGA 256k card with a NEC/MultiSync 3D. We've
  1058. also tested all our examples on an IBM PC XT with 640k RAM, a 20MB hard
  1059. disk, and a ATI VIP VGA graphics adapter card with an IBM 8513 VGA color
  1060. monitor.
  1061.  
  1062. Compiling with Turbo Pascal
  1063.  
  1064. TEGL Windows Toolkit requires Borland's Turbo Pascal Version 5.0, as a
  1065. minimum, to compile the units. The Animate unit requires the object
  1066. oriented programming facilities provided by Version 5.5.
  1067.  
  1068. Refer to the Turbo Pascal Reference Manual for including and using units
  1069. within programs, as well as setting up the environment for referencing the
  1070. units.
  1071.  
  1072. Compiling with Quick Pascal
  1073.  
  1074. TEGL Windows works with Microsoft Quick Pascal Version 1.0.
  1075.  
  1076. Quick Pascal's integrated environment cannot be used to compile
  1077. applications using the Toolkit. It runs out of memory. The command-line
  1078. compiler must be used.
  1079.  
  1080. If you intend to use the MSGraph unit then you must define the symbol
  1081. Quick in the file switches.inc. See the appendix Conditional
  1082. Compilation for furthur information.
  1083.  
  1084. How to use this Reference Manual
  1085.  
  1086. This manual is organized in a presentation manner to lead you through the
  1087. concepts of the TEGL Windows Toolkit II.
  1088.  
  1089. Each Procedure and Function is shown seperately with its name, parameter
  1090.  
  1091.  Programmer's Reference Guide       - 18 -         TEGL Windows Toolkit
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.                         Chapter 1 - Introduction
  1098.  
  1099. list, the unit it is declared in, and other references. For a start here is
  1100. the main entry point into the TEGL Windows Toolkit II.
  1101.  
  1102.  
  1103. ___________________________________________________________________________
  1104.  
  1105. TEGLSupervisor Procedure                                           TEGLUNIT
  1106. ___________________________________________________________________________
  1107.  
  1108.  
  1109.  
  1110. Function
  1111.                    Main entry point.
  1112. Declaration
  1113.                    TEGLSupervisor; 
  1114. Remarks
  1115.                    This should be the last statement in your main program
  1116.                    block.
  1117. Example
  1118.  
  1119.  
  1120.   BEGIN
  1121.     { -- all the setup code for menus etc. goes first }
  1122.     TEGLSupervisor;
  1123.   END.
  1124.  
  1125.  
  1126.  
  1127.  
  1128. Program Framework
  1129.  
  1130. Most of the examples presented throughout this manual will require the following
  1131. minimal skeletal Pascal framework before the example code will compile and
  1132. execute. A few of the examples given are complete programs.
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138. { samshell.pas }
  1139. {$F+}  { -- far code model is required for any functions that }
  1140.        { -- are to be used as Event Handlers }
  1141.  
  1142. Uses
  1143.     dos,
  1144.     graph,
  1145.  
  1146.     virtmem,
  1147.     fastgrph,
  1148.     TEGLIntr,
  1149.     TEGLICON,
  1150.     TEGLGRPH,
  1151.  
  1152.  Programmer's Reference Guide       - 19 -         TEGL Windows Toolkit
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.                         Chapter 1 - Introduction
  1159.  
  1160.     TEGLUnit,
  1161.     TEGLMenu,
  1162.     TEGLEasy
  1163.     SenseMs,
  1164.     DebugUnt;
  1165.  
  1166.  
  1167. { -- insert variables here }
  1168.  
  1169.  
  1170. { -- insert procedures and functions here }
  1171.  
  1172.  
  1173.  
  1174. BEGIN
  1175.    EasyTEGL;
  1176.  
  1177.    { -- insert the example code here }
  1178.    { -- press Ctrl-Break to exit program }
  1179.  
  1180.  
  1181.    { -- control is then passed to the supervisor }
  1182.  
  1183.    TEGLSupervisor;
  1184. END.
  1185.  
  1186.  
  1187.  
  1188.  
  1189. Once control has been turned over to the supervisor then the only way to
  1190. exit a program is by a menu selection or icon that halts the program. Most
  1191. of the example programs don't have this so you must press Ctrl-Break to
  1192. exit. When Ctrl-Break is pressed then program control is turned over to
  1193. an Event Handler. In the case of the sample programs control is passed to
  1194. Quit in TEGLEasy.
  1195.  
  1196. An Event Handler, as covered in Chapter 4, is usually attached to an icon,
  1197. menu selection, or in this case the Ctrl-Break handler. The Ctrl-Break
  1198. handler, when attached to an exit event, allows the program to exit
  1199. gracefully by pressing ctrlkeyscrlock which is the break key on
  1200. most keyboards.
  1201.  
  1202. Chapter 2 provides a foundation to using the TEGL Windows Toolkit by using
  1203. a few program examples. Chapter 3 shows you how to create an icon using
  1204. the icon editor, and how to integrate and use the icons in your program.
  1205. Chapter 4 is heart of the windowing system, which uses most of the other
  1206. functions provided by the other units. In Chapter 5 we delve further into
  1207. how the TEGLMenu works along with TEGLUnit to provide the
  1208. standard drop-down menus and exploding windows. In Chapters 6 through 8,
  1209. we discuss some of the graphic and mouse primitives that the TEGLUnit
  1210. uses. You may use some of these routines independently of TEGL. In Chapter
  1211. 10 we explore the Animation unit along with a sample application that
  1212.  
  1213.  Programmer's Reference Guide       - 20 -         TEGL Windows Toolkit
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.                         Chapter 1 - Introduction
  1220.  
  1221. animates a button icon. Chapter 11 looks at writing text to a window using
  1222. bit-mapped fonts. Finally, in Chapter 12, we look at the Virtual Memory
  1223. handler and how to use VM within an application. The Appendices provide
  1224. greater details on the TEGL Windows Toolkit and the philosophy behind the
  1225. design.
  1226.  
  1227. Frames or Windows?
  1228.  
  1229. In this manual the word frame is used often. A frame is our term for
  1230. the implementation of a window. All the identifiers in the toolkit use
  1231. frame, not window. You can use these terms interchangeably.
  1232.  
  1233. How to Contact TEGL Systems Corporation
  1234. If you have any comments or suggestions, you may contact us by
  1235. writing to
  1236.  
  1237. TEGL Systems Corporation
  1238. 780 - 789 West Pender Street
  1239. Vancouver, British Columbia
  1240. Canada, V6C 1H2
  1241.  
  1242. or phone us at
  1243.  
  1244. (604) 669-2577
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  Programmer's Reference Guide       - 21 -         TEGL Windows Toolkit
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.                          Chapter 2 - TEGL Easy
  1281.  
  1282. TEGL Easy
  1283. ___________________________________________________________________________
  1284.  
  1285. The TEGL Windows Toolkit provides tools to assist you in creating an
  1286. eye-appealing, functional and intuitive graphical interface to your
  1287. programs.
  1288.  
  1289. There is no fixed format that you must follow when using the TEGL Windows
  1290. Toolkit. Screen handling, menus, or push button icons are a function of
  1291. your program design and not a mandatory function of the TEGL Windows
  1292. Toolkit.  However, the tools are provided so you can use emulate the 
  1293. look and feel of most popular windowing packages without locking you
  1294. into a ridged menu system.
  1295.  
  1296. What TEGL Windows Toolkit can do
  1297.  
  1298. Overlapping windows are handled without having the application program
  1299. redraw the window whenever that window is uncovered. This removes the
  1300. complexity of having to redraw, which is necessary with some windowing
  1301. systems. The only time a window has to be redrawn is when it is re-sized.
  1302.  
  1303. The overhead in maintaining graphic images in memory is offset by the virtual
  1304. memory manager which automatically swaps the images to EMS and/or disk when
  1305. more memory is needed. Even with memory swapping, application programs are
  1306. faster and smaller than those written for other windowing environments.
  1307.  
  1308. TEGL handles all mouse and keyboard activities, including all selections
  1309. of a menu items and  clicks on a mouse click area. When the user wants to
  1310. move a window for instance, the TEGLSupervisor handles all of the
  1311. user interaction from the clicks of the right mouse button on a window to
  1312. when the button is released to indicate the new position. When the button
  1313. is released, and MoveFrameCallProc has been installed for that window,
  1314.  the TEGLSupervisor will call your application procedure with the new
  1315. location. Your application can either move the frame by calling 
  1316. MoveStackImage or not do so, depending on whatever it determines is
  1317. appropriate.
  1318.  
  1319.  
  1320. Event-Driven Code
  1321.  
  1322. While it is possible to write your application in a serial manner using
  1323. TEGL Windows by polling the keyboard to see if a key has been pressed, or
  1324. checking the mouse if the mouse has been clicked on an icon or menu, it is
  1325. much more efficient to write using Event-Driven programming.
  1326. Event-driven programming is a style of building programs that makes for
  1327. extremely interactive applications.
  1328.  
  1329. An event is simply the automatic calling of one of your application's
  1330. procedures that is triggered by an action such as the mouse cursor
  1331. overlapping with an icon on the screen. This type of event handling
  1332. removes the complex checking of keyboards and mouse devices from the
  1333. central program and allows for an almost parallel (multitasking) type of
  1334.  
  1335.  Programmer's Reference Guide       - 22 -         TEGL Windows Toolkit
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.                          Chapter 2 - TEGL Easy
  1342.  
  1343. program to be created.
  1344.  
  1345. Your choice in programming will determine whether your program responds to
  1346. the user in a sequential mode where one action must be completed before
  1347. proceeding to the next, or multiple activities that may be completed at
  1348. the user's leisure.
  1349.  
  1350. A good example of multiple event handling is a program that simulates a
  1351. calculator. Each key of the calculator pad is tied together with a 
  1352. Mouse Click Area event-handler (ie. a pascal function) that handles that
  1353. particular key.  With the selection of one of the numeric icon keys, the
  1354. supervisor activates the appropriate event-handler which either adds,
  1355. multiplies, subtracts, or divides the digits. On completion of the
  1356. event-handler's task, the control is returned back to the supervisor to
  1357. await for other events.  Other event-handlers, such as notepads, will
  1358. continue to respond to keyboard or mouse actions along with the activities
  1359. on the calculator.
  1360.  
  1361. An Event is a powerful concept. Hypertext on the MacIntosh is based on a
  1362. similar structure. By associating an event with a word, image, or icon,
  1363. you can chain a series of events together. One event may lead to another?
  1364.  
  1365. The number of icon/events that can be created is limited only by available
  1366. memory.
  1367.  
  1368.  
  1369. Attaching your Function to an Event
  1370.  
  1371. There are six (6) basic types of events that the TEGLSupervisor
  1372. recognizes. The following will provide a brief discussion on event
  1373. handling.
  1374.  
  1375.  
  1376. {bo Mouse Click Area}
  1377.  
  1378. This event occurs whenever the mouse cursor overlaps a defined mouse click
  1379. area on the screen.  Depending on the activation sense, the supervisor may
  1380. call the event-handler only if the left button is clicked (activation
  1381. sense set to MsClick), or if the mouse cursor passes over the defined
  1382. mouse click area (activation sense set to MsSense). The most common use of
  1383. a mouse click area is the association of an icon with an event-handler.
  1384.  
  1385. {bo Click and Drag}
  1386.  
  1387. This event is associated with the movement of a window. Control is passed
  1388. to the Event-handler after a new frame position has been selected. One use
  1389. of this type of event processing is the dragging of an icon-frame to the
  1390. trash can (like the MacIntosh).
  1391.  
  1392. {bo Expand and Shrink}
  1393.  
  1394. This event is associated with the sizing of a window. Control is passed to
  1395.  
  1396.  Programmer's Reference Guide       - 23 -         TEGL Windows Toolkit
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.                          Chapter 2 - TEGL Easy
  1403.  
  1404. the Event-handler after a new frame size has been selected. We use this
  1405. type of event to re-size a window.
  1406.  
  1407. {bo Keyboard Events}
  1408.  
  1409. To accommodate systems without a mouse. The Keyboard Event allows you to
  1410. tie the keyboard to any normal mouse-click-area event handler.
  1411.  
  1412. {bo Timer Ticks}
  1413.  
  1414. The PC has an internal timer that interrupts the activities of any running
  1415. program 18 times a second.  This interruption is transparent to the
  1416. operating system and is used mainly to update the system clock.
  1417.  
  1418. The TEGL unit uses this timer to provide a flag for the interval of timed
  1419. events. An event-handler may be defined to occur at resolutions up to 18
  1420. times a second or several hours later.
  1421.  
  1422. {bo Ctrl-Break}
  1423.  
  1424. The Ctrl-Break event is usually tied with the event-handler QUIT, but,
  1425. like any Event, you may write your own to perform a a different task when
  1426. a Ctrl-Break event occurs.
  1427.  
  1428.  
  1429.  
  1430. Frames
  1431.  
  1432. TEGL is a window manager or more correctly a FRAME STACK coordinator. A
  1433. frame is any defined region of the screen.  By stacking two or more frames
  1434. on the screen, the supervisor monitors the location of the frames and
  1435. ensures that each frame retains it's own entity.
  1436.  
  1437. Once a frame is created, the frame area can be cleared and drawn with any
  1438. graphic functions provided by the Turbo Pascal language or any other
  1439. graphical functions provided by other library packages. However, the
  1440. responsibility of drawing within the window is with the program.
  1441.  
  1442. Use the x, y, x1, y1 coordinates provided within the frame record
  1443. when drawing to the window.
  1444.  
  1445. Menus
  1446.  
  1447. The TEGL Menus are actually event-handlers that have been written to
  1448. accommodate drop-down menus, menu selections, lists within a frame, etc.
  1449.  
  1450. The menus require a list of items and related events to be created. The
  1451. list may then be attached to a bar menu using the OutBarOption, which
  1452. is simply a frame with multiple horizontal mouse click defines.
  1453.  
  1454. When TEGLSupervisor senses the mouse overlapping with one of the bar
  1455. menu selections, an internal BarOptionMenu event is called and a
  1456.  
  1457.  Programmer's Reference Guide       - 24 -         TEGL Windows Toolkit
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.                          Chapter 2 - TEGL Easy
  1464.  
  1465. search is made to find the list that is related to the selection. A menu
  1466. window is then created and displayed using the list. The menu window is
  1467. simply another frame with multiple mouse click defines.
  1468.  
  1469.  
  1470. A Minimum TEGL Program
  1471.  
  1472. The following demo program, prints out the message q Hello World! to a small
  1473. movable window. Note: this one doesn't require the minimum shell that we
  1474. described in the Introduction.
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480. { samc0201.pas }
  1481.  
  1482. Uses
  1483.     dos,
  1484.     graph,
  1485.     virtmem,
  1486.     fastgrph,
  1487.     TEGLIntr,
  1488.     TEGLWrt,
  1489.     TEGLICON,
  1490.     TEGLGRPH,
  1491.     TEGLUnit,
  1492.     TEGLMenu,
  1493.     TEGLEasy;
  1494.  
  1495.  
  1496. BEGIN
  1497.    EasyTEGL;
  1498.  
  1499.    PushImage(100,100,200,120);
  1500.    Shadowbox(100,100,200,120);
  1501.    setcolor(black);
  1502.    OutTEGLTextXY(105,105,'Hello World!');
  1503.  
  1504.    TEGLSupervisor;
  1505. END.
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513. Adding Menus (Top Down Design)
  1514.  
  1515. A powerful feature in programming with TEGL Windows is the ability to
  1516. visually see your application develop. Top down design is a methodology
  1517.  
  1518.  Programmer's Reference Guide       - 25 -         TEGL Windows Toolkit
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.                          Chapter 2 - TEGL Easy
  1525.  
  1526. where the layout and menu designs are created first and the functional
  1527. aspect of the program created later. Program stubs are used as place
  1528. markers to indicate the required function.
  1529.  
  1530. Adding a drop down menu and connecting the event later is a simple
  1531. task with TEGL Windows.
  1532.  
  1533.  
  1534.  
  1535. { samc0202.pas }
  1536.  
  1537.  
  1538. VAR
  1539.   om1, om2 : OptionMPtr;
  1540.  
  1541.  
  1542.  
  1543. FUNCTION GetMsSense(FS:imagestkptr; Ms: msclickptr) : WORD;
  1544.   BEGIN
  1545.     SetMouseSense(fs^.x,fs^.y);
  1546.     GetMsSense := 1;
  1547.   END;
  1548.  
  1549.  
  1550.  
  1551. BEGIN
  1552.  
  1553.    EasyTEGL;
  1554.  
  1555.  
  1556.    om1 := CreateOptionMenu(@Font14);
  1557.    DefineOptions(om1,' Open ',true,NilUnitProc);
  1558.    DefineOptions(om1,'--',false,NilUnitProc);
  1559.    DefineOptions(om1,' Quit ',true,Quit);
  1560.  
  1561.    om2 := CreateOptionMenu(@Font14);
  1562.    DefineOptions(om2,' Memory ',true,ShowCoordinates);
  1563.    DefineOptions(om2,' Mouse Sensitivity ',true,GetMsSense);
  1564.  
  1565.    CreateBarMenu(0,0,getmaxx);
  1566.    OutBarOption(' File ',om1);
  1567.    OutBarOption(' Utility ',om2);
  1568.  
  1569.  
  1570.    TEGLSupervisor;
  1571. END.
  1572.  
  1573.  
  1574.  
  1575.  
  1576. The events ShowoneFont and ShowFonts are defined in FONTTest,
  1577. ShowCoordinates and ShowButtonStatus are both defined in
  1578.  
  1579.  Programmer's Reference Guide       - 26 -         TEGL Windows Toolkit
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.                          Chapter 2 - TEGL Easy
  1586.  
  1587. DebugUnt, AskMouseSense is defined in SenseMS, and Quit
  1588. is defined in TEGLEasy.
  1589.  
  1590. ExitOption already exists as a event in the example above.
  1591.  
  1592. The rest of the menu selection are all defined to NilUnitProc which
  1593. is a program event stub that does nothing.
  1594.  
  1595. Adding events as you go along is easy, now that the menu is set up.
  1596.  
  1597. Adding your First Event
  1598.  
  1599. The following is an event that opens a window and writes a message.
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606. { samc0203.pas }
  1607. FUNCTION InfoOption(FS:imagestkptr; Ms: MsClickPtr) : WORD;
  1608.    VAR
  1609.       x,y,x1,y1  : WORD;
  1610.       IFS            : ImageStkPtr;
  1611.    BEGIN
  1612.       Hidemouse;
  1613.  
  1614.       x  := 200;
  1615.       y  := 120;
  1616.       x1 := x+340;
  1617.       y1 := y+100;
  1618.  
  1619.       PushImage(x,y,x1,y1);
  1620.       IFS := StackPtr;
  1621.  
  1622.       SetColor(White);
  1623.       ShadowBox(x,y,x1,y1);
  1624.       SetColor(Black);
  1625.       OutTEGLtextxy(x+5,y+5,'TEGL Windows Toolkit II');
  1626.       OutTEGLtextxy(x+5,y+5+TEGLCharHeight,
  1627.           'Jan 1,1990, Program Written by Richard Tom');
  1628.  
  1629.       ShowMouse;
  1630.  
  1631.       InfoOption := 1;
  1632.    END;
  1633.  
  1634.  
  1635. Then change the menu declaration line to add InfoOption like so:
  1636.  
  1637.      DefineOptions(om1,'Info...',TRUE,InfoOption);
  1638.  
  1639.  
  1640.  Programmer's Reference Guide       - 27 -         TEGL Windows Toolkit
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.                          Chapter 2 - TEGL Easy
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652. You may notice that the event returns to the TEGLSupervisor leaving
  1653. the window on the screen.
  1654.  
  1655. We can refined this procedure by adding a while loop to wait for the user
  1656. to click on a icon. The CheckforMouseSelect(IFS) will return a
  1657. MouseClickPos once the user has selected the OK icon. While we are
  1658. changing the event, we might as well add in an expanding and shrinking box
  1659. effect.
  1660.  
  1661. The new event listing.
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667. { samc0204.pas }
  1668. FUNCTION InfoOption(FS:imagestkptr; Ms: msclickptr) : WORD;
  1669.    VAR
  1670.       x,y,x1,y1      : word;
  1671.       ifs                : ImageStkPtr;
  1672.       ax,ay,ax1,ay1  : word;
  1673.       option         : word;
  1674.    BEGIN
  1675.       HideMouse;
  1676.  
  1677.       x  := 200;
  1678.       y  := 120;
  1679.       x1 := x+340;
  1680.       y1 := y+100;
  1681.  
  1682.       ax := Ms^.ms.x+FS^.x;
  1683.       ay := Ms^.ms.y+FS^.y;
  1684.       ax1 := Ms^.ms.x1+FS^.x;
  1685.       ay1 := Ms^.ms.y1+FS^.y;
  1686.  
  1687.  
  1688.       PushImage(x,y,x1,y1);
  1689.       IFS := stackptr;
  1690.  
  1691.       ZipToBox(ax,ay,ax1,ay1,x,y,x1,y1);
  1692.  
  1693.       SetColor(White);
  1694.       ShadowBox(x,y,x1,y1);
  1695.  
  1696.       SetColor(Black);
  1697.       OutTEGLtextxy(x+5,y+5,'TEGL Windows Toolkit II');
  1698.       OutTEGLtextxy(x+5,y+5+TEGLCharHeight,
  1699.         'Jan. 1, 1990, Program Written by Richard Tom');
  1700.  
  1701.  Programmer's Reference Guide       - 28 -         TEGL Windows Toolkit
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.                          Chapter 2 - TEGL Easy
  1708.  
  1709.  
  1710.       PutPict(x+280,y+75,@ImageOk,Black);
  1711.       DefineMouseClickArea(IFS,280,75,280+35,75+12,TRUE,
  1712.         NilUnitProc,MSClick);
  1713.       SetMousePosition(x+290,y+85);
  1714.       ShowMouse;
  1715.  
  1716.       WHILE CheckforMouseSelect(IFS)=NIL DO;
  1717.  
  1718.       HideMouse;
  1719.       DropStackImage(ifs);
  1720.       ZipFromBox(ax,ay,ax1,ay1,ifs^.x,ifs^.y,ifs^.x1,ifs^.y1);
  1721.       ShowMouse;
  1722.  
  1723.       InfoOption := 1;
  1724.    END;
  1725.  
  1726.  
  1727.  
  1728.  
  1729. TEGLEasy
  1730.  
  1731.  
  1732.  
  1733.  
  1734. ___________________________________________________________________________
  1735.  
  1736. ActiveButton Procedure                                             TEGLEASY
  1737. ___________________________________________________________________________
  1738.  
  1739.  
  1740. Function
  1741.                    Makes a button/frame.
  1742. Declaration
  1743.                    ActiveButton(x,y: Word; s : String; P : CallProc); 
  1744. Remarks
  1745.                    This is for creating a button which is attacted to a
  1746.                    frame that is the same size as the button. P the
  1747.                    event can then have as the first statement
  1748.                    FrameFromIcon to make a dramatic button to frame
  1749.                    transition.
  1750. Restrictions
  1751.                    If the ImageStkPtr is required then save the
  1752.                    StackPtr immediately after calling ActiveButton.
  1753. See also
  1754.                    ExplodeFromIconHide, CollapseToIconShow. 
  1755. Example
  1756.  
  1757.  
  1758.   ActiveButton(1,1,'?',HelpEvent);
  1759.  
  1760.  
  1761.  
  1762.  Programmer's Reference Guide       - 29 -         TEGL Windows Toolkit
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.                          Chapter 2 - TEGL Easy
  1769.  
  1770.  
  1771.  
  1772.  
  1773. ___________________________________________________________________________
  1774.  
  1775. ColToX Function                                                    TEGLEASY
  1776. ___________________________________________________________________________
  1777.  
  1778.  
  1779. Function
  1780.                    Calculates the X coordinate for a text col.
  1781. Declaration
  1782.                    ColToX(Col : Integer) : Integer; 
  1783. Remarks
  1784.                    This is used to treat the graphics display as if it
  1785.                    were in text mode to make it easy to place a
  1786.                    succession of characters.
  1787. Restrictions
  1788.                    The calculation is made using the currently selected
  1789.                    font.
  1790. See also
  1791.                    RowToY, SetTEGLFont, SetEasyFont.
  1792.  
  1793.  
  1794.  
  1795. ___________________________________________________________________________
  1796.  
  1797. ErrMess Procedure                                                  TEGLEASY
  1798. ___________________________________________________________________________
  1799.  
  1800.  
  1801. Function
  1802.                    Display an error message.
  1803. Declaration
  1804.                    ErrMess(x,y : Word; s : String); 
  1805. Remarks
  1806.                    The error message s is displayed in a frame at
  1807.                    coordinates x,y. The frame is sized to the message
  1808.                    and is moved to keep within the confines of the screen.
  1809.  
  1810.                    The frame is displayed until the 'OK' button in the
  1811.                    lower right corner is clicked.
  1812. See also
  1813.                    GetYesNo.
  1814. Example
  1815.  
  1816.  
  1817.   Error(100,100,'You must enter a file name first');
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  Programmer's Reference Guide       - 30 -         TEGL Windows Toolkit
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.                          Chapter 2 - TEGL Easy
  1830.  
  1831.  
  1832. ___________________________________________________________________________
  1833.  
  1834. FitFrame Procedure                                                 TEGLEASY
  1835. ___________________________________________________________________________
  1836.  
  1837.  
  1838. Function
  1839.                    Creates coordinates that fit on the physical screen.
  1840. Declaration
  1841.                    FitFrame(VAR x,y,width,height: Word); 
  1842. Remarks
  1843.                    x,y are the desired upper left coordinates for a
  1844.                    frame. Width and Height are the desired width
  1845.                    and height in pixels for the frame. If the starting
  1846.                    coordinates would cause the frame to extend beyond the
  1847.                    bounds of the screen then they are decremented until the
  1848.                    frame will fit. If width or height are greater
  1849.                    than their corresponding GetMaxX or GetMaxY then
  1850.                    they are set to the maximum screen size.
  1851.  
  1852.                    The lower right coordinates are returned in width=x1,
  1853.                    and height=y1.
  1854. See also
  1855.                    QuickFrame.
  1856.  
  1857.  
  1858.  
  1859. ___________________________________________________________________________
  1860.  
  1861. FrameFromIcon Procedure                                            TEGLEASY
  1862. ___________________________________________________________________________
  1863.  
  1864.  
  1865. Function
  1866.                    Opens a frame in an event that was called from a click
  1867.                    on a icon.
  1868. Declaration
  1869.                    FrameFromIcon(ifs: ImageStkPtr; ms: MsClickPtr;
  1870.                      x,y,x1,y1 : Word); 
  1871. Remarks
  1872.                    This would be the first statement in an event that is
  1873.                    attached to an icon or button created with active
  1874.                    button.
  1875.  
  1876.                    This procedure will hide the icon then display an
  1877.                    exploding wire box from the icon location to the
  1878.                    coordinates x,y,x1,y1 where a frame is opened and
  1879.                    cleared. An OK button is placed in the lower right
  1880.                    corner of the frame and it is attached to
  1881.                    CollapseToIconShow which will close the frame when
  1882.                    it is clicked on.
  1883.  
  1884.  Programmer's Reference Guide       - 31 -         TEGL Windows Toolkit
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.                          Chapter 2 - TEGL Easy
  1891.  
  1892. See also
  1893.                    ActiveButton, ExplodeFromIconHide
  1894.  
  1895.  
  1896.  
  1897. ___________________________________________________________________________
  1898.  
  1899. FrameText Procedure                                                TEGLEASY
  1900. ___________________________________________________________________________
  1901.  
  1902.  
  1903. Function
  1904.                    Writes text to a frame using row, column coordinates
  1905.                    simulating text mode.
  1906. Declaration
  1907.                    FrameText(ifs : ImageStkPtr; Row,Col : Integer;
  1908.                      s : String); 
  1909. Remarks
  1910.                    ifs is the frame to write to. Row and Col
  1911.                    are the row and column locations relative to the frame.
  1912.                    That is, row 1, col 1, is the upper left corner of the
  1913.                    frame. Note the coordinates are the reverse of graphics
  1914.                    coordinates where column comes first.
  1915. Restrictions
  1916.                    The text display is based upon the current font. Swithing
  1917.                    fonts will cause uneven text.
  1918. Example
  1919.  
  1920.  
  1921. VAR ifs : ImageStkPtr;
  1922.   QuickFrame(ifs,100,100,200,50);
  1923.   FrameText(ifs,2,2,'Hello World');
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929. ___________________________________________________________________________
  1930.  
  1931. GetMousey Function                                                 TEGLEASY
  1932. ___________________________________________________________________________
  1933.  
  1934.  
  1935. Function
  1936.                    Waits for a mouse click and returns the number.
  1937. Declaration
  1938.                    GetMousey(ifs: ImageStkPtr): Word; 
  1939. Remarks
  1940.                    ifs is the frame where we are waiting for a mouse
  1941.                    click to occur. The mouse click number is returned.
  1942.  
  1943.  
  1944.  
  1945.  Programmer's Reference Guide       - 32 -         TEGL Windows Toolkit
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.                          Chapter 2 - TEGL Easy
  1952.  
  1953.  
  1954. ___________________________________________________________________________
  1955.  
  1956. GetYesNo Function                                                  TEGLEASY
  1957. ___________________________________________________________________________
  1958.  
  1959.  
  1960. Function
  1961.                    Gets a yes or no response.
  1962. Declaration
  1963.                    GetYesNo(x,y: Word; s : String): Boolean; 
  1964. Remarks
  1965.                    x,y are the coordinates to display the frame. S
  1966.                    is the question to ask, allowing that the only answer
  1967.                    can be Yes or No. The frame has a yes and no button
  1968.                    displayed in the lower right corner.
  1969.  
  1970.                    This function returns TRUE if Yes is clicked and FALSE
  1971.                    if No is clicked.
  1972. Example
  1973.  
  1974.  
  1975.   IF GetYesNo(100,100,'Do you want to erase the file') THEN
  1976.     BEGIN
  1977.       { -- erase the file }
  1978.     END
  1979.   ELSE ; { -- cancel the command }
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985. ___________________________________________________________________________
  1986.  
  1987. EasyTEGL Procedure                                                 TEGLEASY
  1988. ___________________________________________________________________________
  1989.  
  1990.  
  1991. Function
  1992.                    Does the necessary startup for the toolkit.
  1993. Declaration
  1994.                    EasyTEGL; 
  1995. Remarks
  1996.                    This procedure should be called at the very start of
  1997.                    your program. It sets up some default values and clears
  1998.                    the screen.
  1999.  
  2000.                    When you have become familiar with the start-up
  2001.                    requirements of the TEGL Windows Toolkit then you can
  2002.                    write your own initialization procedure.
  2003.  
  2004.  
  2005.  
  2006.  Programmer's Reference Guide       - 33 -         TEGL Windows Toolkit
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.                          Chapter 2 - TEGL Easy
  2013.  
  2014.  
  2015. ___________________________________________________________________________
  2016.  
  2017. LastCol Function                                                   TEGLEASY
  2018. ___________________________________________________________________________
  2019.  
  2020.  
  2021. Function
  2022.                    Returns the last column of a frame as if it were in
  2023.                    text mode.
  2024. Declaration
  2025.                    LastCol(ifs : ImageStkPtr): Integer; 
  2026. Remarks
  2027.                    The calculation is based upon the currently selected
  2028.                    font.
  2029. Restrictions
  2030.                    Does not allow for BGI fonts.
  2031. See also
  2032.                    LastRow, ColToX, RowToY.
  2033.  
  2034.  
  2035.  
  2036. ___________________________________________________________________________
  2037.  
  2038. LastRow Function                                                   TEGLEASY
  2039. ___________________________________________________________________________
  2040.  
  2041.  
  2042. Function
  2043.                    Returns the last row of a frame as if it were in text
  2044.                    mode.
  2045. Declaration
  2046.                    LastRow(ifs : ImageStkPtr): Integer; 
  2047. Remarks
  2048.                    The calculation is based upon the currently selected
  2049.                    font.
  2050. Restrictions
  2051.                    Does not allow for BGI fonts.
  2052. See also
  2053.                    LastCol, ColToX, RowToY.
  2054.  
  2055.  
  2056.  
  2057. ___________________________________________________________________________
  2058.  
  2059. OutFrameTextXY Procedure                                           TEGLEASY
  2060. ___________________________________________________________________________
  2061.  
  2062.  
  2063. Function
  2064.                    Writes text to frame relative coordinates.
  2065. Declaration
  2066.  
  2067.  Programmer's Reference Guide       - 34 -         TEGL Windows Toolkit
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.                          Chapter 2 - TEGL Easy
  2074.  
  2075.                    OutFrameTextXY(ifs : ImageStkPtr; x,y: Word; s : String); 
  2076. Remarks
  2077.                    Uses the currently selected font.
  2078. Restrictions
  2079.                    Does not work with BGI fonts.
  2080. See also
  2081.                    FrameText.
  2082.  
  2083.  
  2084.  
  2085. ___________________________________________________________________________
  2086.  
  2087. Quit Event                                                         TEGLEASY
  2088. ___________________________________________________________________________
  2089.  
  2090.  
  2091. Function
  2092.                    Halts program.
  2093. Declaration
  2094.                    Quit(ifs: ImageStkPtr; ms: MsClickPtr): Word; 
  2095. Remarks
  2096.                    Control break is set to this event by default in
  2097.                    EasyTEGL.
  2098.  
  2099.  
  2100.   SetCtrlBreakFS(Quit);
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106. ___________________________________________________________________________
  2107.  
  2108. QuickFrame Procedure                                               TEGLEASY
  2109. ___________________________________________________________________________
  2110.  
  2111.  
  2112. Function
  2113.                    Pushes an image and clears the frame.
  2114. Declaration
  2115.                    QuickFrame(VAR ifs : ImageStkPtr; x,y,width,
  2116.                      height: Word); 
  2117. Remarks
  2118.                    x,y are the desired upper left coordinates, width
  2119.                    and height are the size of the frame. Coordinates
  2120.                    are adjusted to fit the physical screen.
  2121.  
  2122.                    After calling QuickFrame the fields x,y,x1,y1
  2123.                    of the ImageStkPtr can be examined to determine the
  2124.                    actual frame coordinates.
  2125. See also
  2126.                    FitFrame.
  2127.  
  2128.  Programmer's Reference Guide       - 35 -         TEGL Windows Toolkit
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.                          Chapter 2 - TEGL Easy
  2135.  
  2136. Example
  2137.  
  2138.  
  2139.  
  2140. VAR ifs : ImageStkPtr;
  2141.  
  2142.   QuickFrame(ifs,100,100,200,150);
  2143.   FrameText(2,2,'This is too TEGL easy!');
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149. ___________________________________________________________________________
  2150.  
  2151. RestoreFont Procedure                                              TEGLEASY
  2152. ___________________________________________________________________________
  2153.  
  2154.  
  2155. Function
  2156.                    Restores the current font.
  2157. Declaration
  2158.                    RestoreFont; 
  2159. Remarks
  2160.                    The current font is saved when SelectEasyFont is
  2161.                    called.
  2162.  
  2163.  
  2164.  
  2165. ___________________________________________________________________________
  2166.  
  2167. RowToY Function                                                    TEGLEASY
  2168. ___________________________________________________________________________
  2169.  
  2170.  
  2171. Function
  2172.                    Calculates the Y coordinate for a text row.
  2173. Declaration
  2174.                    RowToY(Row : Integer): Integer; 
  2175. Remarks
  2176.                    This is used to treat the graphics display as if it were
  2177.                    in text mode and make it easier to place succeeding rows
  2178.                    of text on the screen.
  2179. Restrictions
  2180.                    The calculation is based on the current font.
  2181. See also
  2182.                    ColToX, LastCol, LastRow, FrameText
  2183.  
  2184.  
  2185.  
  2186. ___________________________________________________________________________
  2187.  
  2188.  
  2189.  Programmer's Reference Guide       - 36 -         TEGL Windows Toolkit
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.                          Chapter 2 - TEGL Easy
  2196.  
  2197. SelectEasyFont Procedure                                           TEGLEASY
  2198. ___________________________________________________________________________
  2199.  
  2200.  
  2201. Function
  2202.                    Changes the font.
  2203. Declaration
  2204.                    SelectEasyFont; 
  2205. Remarks
  2206.                    The font used after this call is selected by previous
  2207.                    call to SetEasyFont.
  2208. See also
  2209.                    RestoreFont.
  2210.  
  2211.  
  2212.  
  2213. ___________________________________________________________________________
  2214.  
  2215. SetEasyFont Procedure                                              TEGLEASY
  2216. ___________________________________________________________________________
  2217.  
  2218.  
  2219. Function
  2220.                    Set the font used by the TEGLEasy Unit.
  2221. Declaration
  2222.                    SetEasyFont(p : Pointer); 
  2223. Remarks
  2224.                    Some of the routines in TEGLEasy write to the screen.
  2225.                    This font is used by these routines.
  2226. See also
  2227.                    SelectEasyFont, RestoreFont
  2228. Example
  2229.  
  2230.  
  2231.   SetEasyFont(@CountDwn);
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  Programmer's Reference Guide       - 37 -         TEGL Windows Toolkit
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.                           Chapter 3 - Icons
  2257.  
  2258.  
  2259. ICONS
  2260. ___________________________________________________________________________
  2261.  
  2262. Icons are pictures that represent objects. This Icon image diskdrve
  2263. represents a diskette.
  2264.  
  2265. Icons are the mainstay of GUI's.
  2266.  
  2267. The TEGL
  2268. Windows Toolkit provides the tools that can create and manipulate icons up
  2269. to a 100 x 100 pixels in size. By placing an icon within a window frame,
  2270. they may be attached directly to an TEGL event to provide graphical menu
  2271. selections, animated to provide visual feedback, displayed as graphic
  2272. images like the TEGL Deck of Cards, or used to display a company logo.
  2273.  
  2274. The ICON Editor
  2275.  
  2276. Included in TEGL Windows is a powerful icon editor that utilizes the full
  2277. power of the tookit to provide you with fast, flexible and easy icon file
  2278. editing. The source code for the icon editor is also included so you can
  2279. expand and modify it to suit your needs.
  2280.  
  2281. The Main Bar Menu
  2282. Open ICONDEF File
  2283.  
  2284. Opens an existing ICON.DEF file, or creates a new DEF file. To create a new
  2285. DEF file, type in the name of the DEF file in the filename box and click on
  2286. key OK.
  2287.  
  2288. Quit
  2289. Quits the icon editor. NOTE: The icon editor does not prompt you to save your
  2290. files.
  2291.  
  2292.  
  2293. Editing
  2294. The mouse cursor changes to cross-hairs when the cursor enters the
  2295. icon drawing area. Pressing the mouse left button will place a pixel at
  2296. the current coordinates. Pressing the mouse right button will erase the pixel.
  2297. You can hold the mouse left or right button, while moving the mouse to
  2298. draw or erase a series of pixels.
  2299.  
  2300. The drawing bar at the bottom of the drawing area has two functions. Press
  2301. and hold the right mouse button on the drawing bar to drag the drawing
  2302. area to a new location. Click with the left mouse button on the drawing
  2303. bar to select from the drawing menu.
  2304.  
  2305. The Drawing Bar Menu
  2306.  
  2307. SAVE
  2308.  
  2309. Saves the file with the filename displayed on the drawing bar.
  2310.  
  2311.  Programmer's Reference Guide       - 38 -         TEGL Windows Toolkit
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.                           Chapter 3 - Icons
  2318.  
  2319.  
  2320. SAVE AS
  2321.  
  2322. Saves the file with a new filename.
  2323.  
  2324. SAVE AND EXIT ICON FILE
  2325. Saves the file with the filename displayed on the drawing bar and closes
  2326. the editing area for the file.
  2327.  
  2328. CREATE PASCAL CONSTANTS
  2329. Creates a pascal constants file with the extension q .CON for including
  2330. in a program.
  2331.  
  2332. COPY IMAGE AREA
  2333.  
  2334. Copies an area into the internal IMAGE AREA. When this option is active a
  2335. scissors icon appears on the drawing bar. Click once with the left mouse
  2336. button to mark the upper left corner of the area to copy. Move the mouse
  2337. cursor to the bottom right corner of the area to copy and click again on
  2338. the left mouse button. When the scissors disappear, the area has been
  2339. copied to the internal IMAGE AREA.
  2340.  
  2341. CUT IMAGE AREA
  2342.  
  2343. Copies an area into an internal IMAGE AREA and clears the Icon area to the
  2344. background color.  When this option is active a scissors icon appears on
  2345. the drawing bar.  Click once with the left mouse button to mark the upper
  2346. left corner of the area to cut.  Move the mouse cursor to the bottom right
  2347. corner of the area and click again on the left mouse button.  When both
  2348. the scissors disappear and the area is cleared, then the area has been
  2349. copied to the internal IMAGE AREA.
  2350.  
  2351. FILL IMAGE AREA
  2352. Fills an area with the current pixel color. Bits that are already set on
  2353. are not overwritten. When this option is active, a coffee mug icon appears
  2354. on the drawing bar.  Click once with the left mouse button to mark the
  2355. upper left corner of the area to fill.  Move the mouse cursor to the
  2356. bottom right corner of the area and click again on the left mouse button.
  2357. The coffee mug disappears when the area is filled with current pixel
  2358. color.
  2359.  
  2360. PASTE IMAGE AREA
  2361.  
  2362. Paste the copied/cut area from the internal IMAGE AREA to the icon drawing
  2363. area. When this option is active, a glue bottle icon appears on the
  2364. drawing bar. Click once at the position where the image is to be pasted.
  2365. The pasted image overwrites any pixels on the drawing area.
  2366.  
  2367. MERGE IMAGE AREA
  2368.  
  2369. Merges the copied/cut area from the internal IMAGE AREA to the icon
  2370. drawing area. When this option is active, a glue bottle icon appears on
  2371.  
  2372.  Programmer's Reference Guide       - 39 -         TEGL Windows Toolkit
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.                           Chapter 3 - Icons
  2379.  
  2380. the drawing bar. Click once at the position where the image is to
  2381. be merged. The merged image only writes to empty pixel areas.
  2382.  
  2383. OVERLAY IMAGE AREA
  2384.  
  2385. Overlays the copied/cut area from the internal IMAGE AREA to the icon
  2386. drawing area. When this option is active, a glue bottle icon appears on
  2387. the drawing bar. Click once at the position where the image is to
  2388. be overlayed. The overlay image only writes to active pixels.
  2389.  
  2390. ROTATE IMAGE AREA 45 DEGREES
  2391.  
  2392. Rotates the internal IMAGE AREA by 45 degrees.
  2393.  
  2394. ROTATE IMAGE AREA 90 DEGREES
  2395.  
  2396. Rotates the internal IMAGE AREA by 90 degrees.
  2397.  
  2398. REDUCE IMAGE AREA
  2399.  
  2400. Shrinks the image within the internal IMAGE AREA by 50%. The algorithm
  2401. deletes every second pixel.
  2402.  
  2403. REVERSE IMAGE AREA
  2404.  
  2405. Reverses the image within the internal IMAGE AREA from left to right.
  2406.  
  2407. PIXEL COLOR
  2408.  
  2409. Pick the current pixel color from a palette of 16 colors.
  2410.  
  2411. BACKGROUND COLOR
  2412.  
  2413. Pick the current background color from a palette of 16 colors.
  2414.  
  2415. CHANGE PIXELS COLOR
  2416.  
  2417. Change all pixels with color m to another color n. Where m
  2418. and n are selected from a palette of 16 colors. To cancel the command
  2419. without changing any pixel colors, select the same color for both m
  2420. and n.
  2421.  
  2422. ERASE COLOR PIXELS
  2423.  
  2424. Erases all pixels with the selected pixel color. The color is selected
  2425. from a palette of 16 colors.
  2426.  
  2427. EXPLODE ICON IMAGE
  2428. Enlarges the drawing area. The largest size is a ratio of 3 to 1 (3 pixels
  2429. representing 1 pixel).
  2430.  
  2431. IMPLODE ICON IMAGE
  2432.  
  2433.  Programmer's Reference Guide       - 40 -         TEGL Windows Toolkit
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.                           Chapter 3 - Icons
  2440.  
  2441. Shrinks the drawing area.
  2442.  
  2443. CLEAR ICON IMAGE
  2444. Clears the drawing area.
  2445.  
  2446. RELOAD ICON FILE
  2447. Reloads the original icon file.
  2448.  
  2449. EXIT ICON FILE
  2450. Finishes the editing of a icon file.
  2451.  
  2452. You can open as many editing windows at once as you like. The internal
  2453. IMAGE AREA is common to all the edit windows that are open. Consequently,
  2454. whatever is in the internal IMAGE AREA can be pasted to any edit window.
  2455. This allows for the building of icons from small pieces, or copying an
  2456. icon to transform it to something different.
  2457.  
  2458.  
  2459. ICON Constants
  2460.  
  2461. Select from the Drawing Bar Menu CREATE PASCAL CONSTANTS, to generate
  2462. constants for including in your program. If you have a large number of
  2463. icons for generating constants, you can use the program ICONINC to
  2464. generate all icons in a one pass.
  2465.  
  2466.  
  2467. ___________________________________________________________________________
  2468.  
  2469. Putpict Procedure                                                  FASTGRPH
  2470. ___________________________________________________________________________
  2471.  
  2472.  
  2473. Function
  2474. Puts the defined icon to the specified screen area.
  2475. Declaration
  2476. Putpict (x,y:word; buf:pointer;n:word)
  2477. Remarks
  2478. x, y defines the upper left corner of the screen area for placing the
  2479. icon image.
  2480.  
  2481. buf points to the defined icon image.
  2482.  
  2483. n defines the color change for any pixel that is black within the
  2484. icon.
  2485.  
  2486. Example
  2487.  
  2488.  
  2489. const
  2490.   ImageMYICON : array [0..1566] of byte =
  2491.        ($1D,$06,$83,$01,$5B,  $02,$ ._._._._. 
  2492.  
  2493.  
  2494.  Programmer's Reference Guide       - 41 -         TEGL Windows Toolkit
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.                           Chapter 3 - Icons
  2501.  
  2502.   PutPict(10,25,@ImageMYICON,black);
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508. ICON Assembler Procedures
  2509.  
  2510. A drawback of Turbo Pascal is the size of the data area, which limits the
  2511. number of icons that can be included as constants.
  2512.  
  2513. The program ICONASM provides a second method that allows you to add
  2514. large icon images to your program (eg. the TEGL Deck of Cards).
  2515.  
  2516. ICONASM generates a Pascal procedure in assembler. Turbo Assembler is
  2517. required to assemble the file to object code. You may then create a TPU
  2518. that will link the icon procedure into your pascal program.
  2519.  
  2520.  
  2521.  
  2522. procedure ImageMyICON(x,y:word;n:word);
  2523. {$L MyIcon.obj}
  2524.  
  2525.  
  2526.  
  2527. To display the icon, use the icon procedure name (your icon name prefixed
  2528. with Image).
  2529.  
  2530.  
  2531.  
  2532. imageMyIcon(10,25,black);
  2533.  
  2534.  
  2535.  
  2536. Note that these procedures must always be declared as far calls. If you
  2537. make them part of the interface of a unit then it is done automatically
  2538. but if you are using any directly in your program or accessing them
  2539. locally in a unit then be sure and use the {$F+} directive.
  2540.  
  2541. ICON Utilities
  2542.  
  2543. ICONDEF
  2544.  
  2545. ICONDEF is a utility program that allows you to strip the .DEF files
  2546. from a turbo pascal source file, include file or Assembler file, provided
  2547. that the commented {.. prefix is still a part of your constants.
  2548.  
  2549. Be careful that the Input filename is not the same as one of the
  2550. definition files. Using a suffix other then .DEF will ensure that the
  2551. include file is not overwritten while extracting. However, any filenames
  2552. that do end in .DEF should be copied to a subdirectory if you are not sure
  2553. about the ICON definition names.
  2554.  
  2555.  Programmer's Reference Guide       - 42 -         TEGL Windows Toolkit
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.                           Chapter 3 - Icons
  2562.  
  2563.  
  2564.  
  2565.  
  2566.   Syntax:  ICONDEF MYFILE.INC
  2567.  
  2568.   Where:   MYFILE.INC is the include file generated by ICONINC
  2569.            or any file that embeds the include file.
  2570.  
  2571.  
  2572.  
  2573. ICONLIB
  2574.  
  2575. ICONLIB is for assisting the programmer in combining the definition
  2576. files into a single library file for maintenance. Use ICONDEF to extract.
  2577.  
  2578.  
  2579.  
  2580.   Syntax:  ICONLIB *[.DEF] MYPROG.DLB
  2581.  
  2582.   Where:   *[.DEF] may use any DOS wild-card specifications.
  2583.            MYPROG.DLB may be any library filename.
  2584.  
  2585.  
  2586.  
  2587. ICONINC
  2588. ICONINC  helps the ICON Editor in generating a large number of Turbo
  2589. Pascal ICON constants. Multiple icon definitions may be output to a single
  2590. include file.
  2591.  
  2592.  
  2593.  
  2594.   Syntax:  ICONDEF *[.DEF] MYFILE.INC
  2595.  
  2596.   Where:   *[.DEF] may use any DOS wildcards specifications.
  2597.            MYFILE.INC may be any include filename.
  2598.  
  2599.  
  2600.  
  2601. ICONASM
  2602.  
  2603. ICONASM is for assisting the ICON Editor in generating procedures
  2604. from icon definition files. Multiple procedures may be output to a single
  2605. asm file.
  2606.  
  2607.  
  2608.  
  2609.   Syntax:  ICONASM *[.DEF] MYPROG.ASM
  2610.  
  2611.   Where:   *[.DEF] may use any DOS wildcards specifications.
  2612.            MYPROG.ASM may be any assembler filename.
  2613.  
  2614.  
  2615.  
  2616.  Programmer's Reference Guide       - 43 -         TEGL Windows Toolkit
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.                           Chapter 3 - Icons
  2623.  
  2624.  
  2625. ICONS in TEGLIcon Unit
  2626.  
  2627. There are a number of icons that have been created and are available in
  2628. TEGLIcon unit. You can use these icons by simply including the unit
  2629. in your USES statement.
  2630.  
  2631.  
  2632. ImageCREDITS
  2633.  
  2634. TEGL Windows Toolkit II
  2635.  
  2636. ImageTRASH
  2637.                    A trash can
  2638. ImageOK
  2639.                    OK button
  2640. ImageCANCEL
  2641.                    Cancel button
  2642. ImageBLANKBUT
  2643.                    A blank button for creating your own
  2644. ImageLBUT ImageMBUT ImageRBUT
  2645.                   Used by DrawLongButon to create an extra long button
  2646.                   icon.
  2647. ImageDOWN
  2648.                    Down arrow.
  2649. ImageUP
  2650.                    Up arrow.
  2651. ImageRIGHT
  2652.                    Right arrow.
  2653. ImageLEFT
  2654.                    Left arrow.
  2655. ImageR
  2656.                    Registered Trademark. reg
  2657. ImageC
  2658.                    Copyright. copyright
  2659. ImageTIGER
  2660.                    A TEGL tiger.
  2661. ImageLAST
  2662.                    Last button.
  2663. ImageNEXT
  2664.                    Next button.
  2665. ImageQUESTION
  2666.                    Question Button.
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  Programmer's Reference Guide       - 44 -         TEGL Windows Toolkit
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.                           Chapter 4 - Frames
  2684.  
  2685. Frames
  2686. ___________________________________________________________________________
  2687.  
  2688. The power and speed of TEGL Windows is most apparent when handling frames.
  2689. By automatically saving and restoring overlapping images, TEGL Windows
  2690. is a very powerful tool for creating the illusion of separate multiple
  2691. windows.
  2692.  
  2693. Creating, Manipulating, and Dropping Frames
  2694.  
  2695.  
  2696. ___________________________________________________________________________
  2697.  
  2698. CountFrames Function                                               TEGLUNIT
  2699. ___________________________________________________________________________
  2700.  
  2701.  
  2702.  
  2703. Function
  2704.                    Returns the number of frames currently on the
  2705.                    stack.
  2706. Declaration
  2707.                    CountFrames: Word; 
  2708.  
  2709.  
  2710.  
  2711.  
  2712. ___________________________________________________________________________
  2713.  
  2714. FrameExist Function                                                TEGLUNIT
  2715. ___________________________________________________________________________
  2716.  
  2717.  
  2718.  
  2719. Function
  2720.                    Determines if a frame is on the frame stack.
  2721. Declaration
  2722.                    FrameExist(ifs : ImageStkPtr): Boolean
  2723. Remarks
  2724.                    If ifs exists then it contains the address
  2725.                    of one of the frames on the stack.
  2726. Example
  2727.  
  2728.  
  2729.   IF FrameExist(ifs) THEN
  2730.     DropStackImage(ifs);
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  Programmer's Reference Guide       - 45 -         TEGL Windows Toolkit
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.                           Chapter 4 - Frames
  2745.  
  2746. ___________________________________________________________________________
  2747.  
  2748. PushImage Procedure                                                TEGLUNIT
  2749. ___________________________________________________________________________
  2750.  
  2751.  
  2752.  
  2753. Function
  2754.                    Used to save the background image before clearing and
  2755.                    drawing new images in this area. Equivalent to opening
  2756.                    a window area.
  2757.  
  2758. Declaration
  2759.                    PushImage(X,Y,X1,Y1 : word)
  2760. Remarks
  2761.                    Windows are created by pushing and popping the
  2762.                    background image. X, Y, X1, Y1 are absolute
  2763.                    coordinates starting with 0,0 at the upper left corner
  2764.                    of the screen to GetMaxX, GetMaxY at the lower right
  2765.                    corner.
  2766. Restrictions
  2767.                    Saving large images can require a lot of memory even
  2768.                    with the Virtual Memory Manager. If a program is
  2769.                    expected to use most of memory it would be sensible to
  2770.                    include specific checks on memory requirements and
  2771.                    availability before performing a PushImage.
  2772.  
  2773.                    A full screen in EGA mode (640 x 350) requires about
  2774.                    110K of memory, in VGA mode (640 x 480) the requiment
  2775.                    is about 150K.
  2776. See also
  2777.                    PopImage, DropStackImage, RotateStackImage,
  2778.                    RotateUnderStackImage
  2779. Example
  2780.                    The following will create a shadowed box on the upper
  2781.                    left screen area. Use the right mouse button to drag
  2782.                    the box around.
  2783.  
  2784.  
  2785.  
  2786. { samc0401.pas }
  2787. PushImage(1,1,100,100);
  2788. ShadowBox(1,1,100,100);
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795. ___________________________________________________________________________
  2796.  
  2797. PopImage Procedure                                                 TEGLUNIT
  2798.  
  2799.  Programmer's Reference Guide       - 46 -         TEGL Windows Toolkit
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.                           Chapter 4 - Frames
  2806.  
  2807. ___________________________________________________________________________
  2808.  
  2809.  
  2810. Function
  2811.                    Used to restore the top background image after a
  2812.                    PushImage.  Equivalent to closing a window area.
  2813. Declaration
  2814.                    PopImage
  2815. Remarks
  2816.                    Restores the uppermost image area created by PushImage.
  2817.  
  2818. See also
  2819.                    PushImage, DropStackImage, RotateStackImage,
  2820.                    RotateUnderStackImage
  2821. Example
  2822.                    This example waits until a mouse button is pressed then
  2823.                    calls PopImage to restore the background image.
  2824.  
  2825.  
  2826. { samc0402.pas }
  2827.   PushImage(1,1,100,100);
  2828.   ShadowBox(1,1,100,100);
  2829.  
  2830.   WHILE Mouse_Buttons = 0 DO;
  2831.   PopImage;
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838. ___________________________________________________________________________
  2839.  
  2840. RotateStackImage Procedure                                         TEGLUNIT
  2841. ___________________________________________________________________________
  2842.  
  2843.  
  2844. Function
  2845.                    Rotates a frame forward or backward relative to the
  2846.                    frames on the screen.
  2847. Declaration
  2848.                    RotateStackImage(var Frame1,Frame2)
  2849. Remarks
  2850.                    Frames may be rotated to the foreground to allow user
  2851.                    input or updates, etc.
  2852.  
  2853.                    A frame may be rotated as the first frame using
  2854.                    RotateUnderStackImage.
  2855.  
  2856.                    In order to access an image that is not the most recent
  2857.                    PushImage you must save the Global Variable 
  2858.                    StackPtr right after the PushImage. The saved
  2859.  
  2860.  Programmer's Reference Guide       - 47 -         TEGL Windows Toolkit
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.                           Chapter 4 - Frames
  2867.  
  2868.                    pointer may be used to manipulate the frame.
  2869. Restrictions
  2870.                    A frame can only be rotated above a known frame. To
  2871.                    rotate a frame below another frame on the stack, use
  2872.                    the RotateUnderStackImage routine.
  2873. See also
  2874.                    PushImage, PopImage, DropStackImage
  2875. Example
  2876.                    The following example creates two overlapping frames
  2877.                    and waits for a click of a mouse button before
  2878.                    rotating the bottom frame to the top.
  2879.  
  2880.  
  2881. { samc0403.pas }
  2882. VAR fs : ImageStkPtr;
  2883.  
  2884.   PushImage(1,1,100,100);
  2885.   ShadowBox(1,1,100,100);
  2886.   FS := stackptr;
  2887.  
  2888.   PushImage(50,50,150,150);
  2889.   ShadowBox(50,50,150,150);
  2890.  
  2891.   WHILE Mouse_Buttons = 0 DO;
  2892.  
  2893.   RotateStackImage(fs,stackptr);
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899. ___________________________________________________________________________
  2900.  
  2901. RotateUnderStackImage Procedure                                    TEGLUNIT
  2902. ___________________________________________________________________________
  2903.  
  2904.  
  2905. Function
  2906.                    Rotates a frame forward or backward relative to the
  2907.                    frames on the screen. Rotates a frame below Frame2.
  2908. Declaration
  2909.                    RotateUnderStackImage(VAR Frame1,Frame2)
  2910. Remarks
  2911.  
  2912.                    In order to access an image that is not the most recent
  2913.                    PushImage you must save the Global Variable 
  2914.                    StackPtr right after the PushImage. The saved
  2915.                    pointer may be used to manipulate the frame.
  2916. Restrictions
  2917.                    A frame can only be rotated below a known frame. To
  2918.                    rotate a frame above another frame on the stack, use
  2919.                    the RotateStackImage.
  2920.  
  2921.  Programmer's Reference Guide       - 48 -         TEGL Windows Toolkit
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.                           Chapter 4 - Frames
  2928.  
  2929. See also
  2930.                    PushImage, PopImage, DropStackImage
  2931. Example
  2932.                    The following example creates two overlapping frames
  2933.                    and awaits for a click of a mouse button before
  2934.                    rotating the Top frame under the second frame.
  2935.  
  2936.  
  2937. { samc0404.pas }
  2938. VAR FS : ImageStkPtr;
  2939.  
  2940.   PushImage(1,1,100,100);
  2941.   ShadowBox(1,1,100,100);
  2942.   FS := StackPtr;
  2943.  
  2944.   PushImage(50,50,150,150);
  2945.   ShadowBox(50,50,150,150);
  2946.  
  2947.   WHILE Mouse_Buttons = 0 DO;
  2948.  
  2949.   RotateUnderStackImage(StackPtr,fs);
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956. ___________________________________________________________________________
  2957.  
  2958. DropStackImage Procedure                                           TEGLUNIT
  2959. ___________________________________________________________________________
  2960.  
  2961.  
  2962. Function
  2963.                    Used to close a frame that is not necessarily the
  2964.                    topmost image on the stack. Equivalent to closing a
  2965.                    window area.
  2966. Declaration
  2967.                    DropStackImage(VAR Frame: ImageStkPtr)
  2968. Remarks
  2969.                    Restores an image area created by PushImage.
  2970.  
  2971.                    In order to access an image that is not the most recent
  2972.                    PushImage you must save the Global Variable 
  2973.                    StackPtr right after the PushImage. The saved
  2974.                    pointer may be used to manipulate the frame.
  2975. See also
  2976.                    PushImage, PopImage, RotateStackImage,
  2977.                    RotateUnderStackImage
  2978. Example
  2979.                    The following example creates two overlapping frames
  2980.                    and awaits for a click of a mouse button before
  2981.  
  2982.  Programmer's Reference Guide       - 49 -         TEGL Windows Toolkit
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.                           Chapter 4 - Frames
  2989.  
  2990.                    dropping the bottom frame from the screen.
  2991.  
  2992.  
  2993. { samc0405.pas }
  2994. VAR fs : ImageStkPtr;
  2995.  
  2996.   PushImage(1,1,100,100);
  2997.   ShadowBox(1,1,100,100);
  2998.   fs := StackPtr;
  2999.  
  3000.   PushImage(50,50,150,150);
  3001.   ShadowBox(50,50,150,150);
  3002.  
  3003.   WHILE Mouse_Buttons = 0 DO;
  3004.  
  3005.   DropStackImage(fs);
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012. ___________________________________________________________________________
  3013.  
  3014. HideImage Procedure                                                TEGLUNIT
  3015. ___________________________________________________________________________
  3016.  
  3017.  
  3018. Function
  3019.                    Hides an Image Frame from the screen but retains the
  3020.                    current stack position and frontal image.
  3021. Declaration
  3022.                    HideImage(VAR Frame)
  3023. Remarks
  3024.                    This procedure may be used in a variety of ways.
  3025.                    Blinking a frame by alternating between HideImage and
  3026.                    ShowImage. Moving a frame from one location to another.
  3027. See also
  3028.                    ShowImage
  3029. Example
  3030.                    The following example blinks a frame continuously until
  3031.                    a mouse button is pressed.
  3032.  
  3033.  
  3034.  
  3035. { samc0406.pas }
  3036. VAR fs : ImageStkPtr;
  3037.     i  : word;
  3038.  
  3039.   PushImage(1,1,50,50);
  3040.   ShadowBox(1,1,50,50);
  3041.   fs := StackPtr;
  3042.  
  3043.  Programmer's Reference Guide       - 50 -         TEGL Windows Toolkit
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.                           Chapter 4 - Frames
  3050.  
  3051.  
  3052.   i := 20000;
  3053.   REPEAT
  3054.      dec(i);
  3055.      IF i=10000 THEN
  3056.         HideImage(fs);
  3057.      IF i=0 then
  3058.         BEGIN
  3059.           ShowImage(fs,fs^.x,fs^.y);
  3060.           i := 20000;
  3061.         END;
  3062.   UNTIL Mouse_Buttons<>0;
  3063.  
  3064.   IF i<=10000 THEN
  3065.     ShowImage(fs,fs^.x,fs^.y);
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073. ___________________________________________________________________________
  3074.  
  3075. ShowImage Procedure                                                TEGLUNIT
  3076. ___________________________________________________________________________
  3077.  
  3078.  
  3079. Function
  3080.                    Shows a Hidden Image Frame.
  3081. Declaration
  3082.                    HideImage(VAR Frame)
  3083. See also
  3084.                    HideImage
  3085. Example
  3086.                    The following example moves a frame from one location
  3087.                    to another when a mouse button is pressed.
  3088.  
  3089.  
  3090. { samc0407.pas }
  3091. VAR fs : ImageStkPtr;
  3092.  
  3093.   PushImage(1,1,100,100);
  3094.   ShadowBox(1,1,100,100);
  3095.   fs := StackPtr;
  3096.  
  3097.   PushImage(50,50,150,150);
  3098.   ShadowBox(50,50,150,150);
  3099.  
  3100.   WHILE Mouse_Buttons = 0 DO;
  3101.  
  3102.   HideImage(fs);
  3103.  
  3104.  Programmer's Reference Guide       - 51 -         TEGL Windows Toolkit
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.                           Chapter 4 - Frames
  3111.  
  3112.   ShowImage(fs,fs^.x+100,fs^.y+100);
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120. ___________________________________________________________________________
  3121.  
  3122. ShowCoordinates Event                                              DEBUGUNT
  3123. ___________________________________________________________________________
  3124.  
  3125.  
  3126. Function
  3127.                    A TEGL Event that displays the coordinates of a frame.
  3128. Declaration
  3129.                    ShowCoordinates(ifs : ImageStkPtr; Ms : MsClickPtr): Word;
  3130. Remarks
  3131.                    This event displays the coordinates of a frame.
  3132.  
  3133.  
  3134. Preparing a Frame for Update
  3135.  
  3136.  
  3137. ___________________________________________________________________________
  3138.  
  3139. PrepareForPartialUpdate Procedure                                  TEGLUNIT
  3140. ___________________________________________________________________________
  3141.  
  3142.  
  3143. Function
  3144.                    Prepares a portion of a frame for output. Removes all
  3145.                    overlapping images above the partial area that is being
  3146.                    updated on the screen.
  3147. Declaration
  3148.                    PrepareForPartialUpdate(VAR Frame; X,Y,X1,
  3149.                    Y1: word)
  3150. Remarks
  3151.                    X,Y,X1,Y1 are absolute coordinates starting with 0,0 at
  3152.                    the upper left corner of the screen to GetMaxX, GetMaxY
  3153.                    at the lower right corner.
  3154. Restrictions
  3155.                    The coordinates must be within the absolute frame
  3156.                    coordinates. Use the current Frame coordinates +
  3157.                    offsets to obtain the correct absolute coordinates.
  3158.  
  3159.                    PrepareForPartialUpdate and PrepareForUpdate can
  3160.                    be used on multiple frames (provided the update areas
  3161.                    do not overlap) but must be matched by an equal number
  3162.                    of calls to CommitUpdate.
  3163. See also
  3164.  
  3165.  Programmer's Reference Guide       - 52 -         TEGL Windows Toolkit
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.                           Chapter 4 - Frames
  3172.  
  3173.                    PrepareForUpdate, CommitUpdate
  3174. Example
  3175.                    The following example creates two overlapping frames
  3176.                    and awaits for a click of a mouse button before drawing
  3177.                    a circle on the bottom frame.
  3178.  
  3179.  
  3180. { samc0408.pas }
  3181. VAR FS,LsPtr : ImageStkPtr;
  3182.  
  3183.   PushImage(1,1,100,100);
  3184.   ShadowBox(1,1,100,100);
  3185.   fs := StackPtr;
  3186.  
  3187.   PushImage(50,50,150,150);
  3188.   ShadowBox(50,50,150,150);
  3189.  
  3190.   WHILE Mouse_Buttons = 0 DO;
  3191.  
  3192.   PrepareForPartialUpdate(fs,fs^.x,fs^.y,fs^.x1,fs^.y1);
  3193.   SetColor(Blue);
  3194.   Circle(fs^.x+48,fs^.y+45,40);
  3195.   CommitUpdate;
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202. ___________________________________________________________________________
  3203.  
  3204. PrepareForUpdate Function                                          TEGLUNIT
  3205. ___________________________________________________________________________
  3206.  
  3207.  
  3208. Function
  3209.                    Prepares a frame for output. Removes all overlapping
  3210.                    images above the frame area that is being updated on
  3211.                    the screen.
  3212. Declaration
  3213.                    PrepareForUpdate(VAR Frame)
  3214. Remarks
  3215.                    Identical to PrepareForPartialUpdate, except the
  3216.                    current Frame Coordinates are passed automatically.
  3217. Restrictions
  3218.                    PrepareForPartialUpdate and PrepareForUpdate can
  3219.                    be used on multiple frames (provided the update areas
  3220.                    do not overlap) but must be matched by an equal number
  3221.                    of calls to CommitUpdate.
  3222. See also
  3223.                    PrepareforPartialUpdate, CommitUpdate
  3224. Example
  3225.  
  3226.  Programmer's Reference Guide       - 53 -         TEGL Windows Toolkit
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.                           Chapter 4 - Frames
  3233.  
  3234.                    The following example creates two overlapping frames
  3235.                    and awaits for a click of a mouse button before drawing
  3236.                    a circle on the bottom frame.
  3237.  
  3238.  
  3239. { samc0409.pas }
  3240. VAR fs : ImageStkPtr;
  3241.  
  3242.   PushImage(1,1,100,100);
  3243.   ShadowBox(1,1,100,100);
  3244.   fs := StackPtr;
  3245.  
  3246.   PushImage(50,50,150,150);
  3247.   ShadowBox(50,50,150,150);
  3248.  
  3249.   WHILE Mouse_Buttons = 0 DO;
  3250.  
  3251.   PrepareForUpdate(fs);
  3252.   SetColor(blue);
  3253.   Circle(fs^.x+48,fs^.y+45,40);
  3254.   CommitUpdate;
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261. ___________________________________________________________________________
  3262.  
  3263. CommitUpdate Procedure                                             TEGLUNIT
  3264. ___________________________________________________________________________
  3265.  
  3266.  
  3267. Function
  3268.                    Commits update. Replaces all overlapping images above
  3269.                    the frame area that was being updated on the screen.
  3270. Declaration
  3271.                    CommitUpdate;
  3272. Remarks
  3273.                    CommitUpdate must be used to close the functions
  3274.                    PrepareForPartialUpdate and PrepareForUpdate.
  3275. Restrictions
  3276.                    CommitUpdate must be called an equal number of
  3277.                    times for each PrepareForPartialUpdate and 
  3278.                    PrepareForUpdate.
  3279. See also
  3280.                    PrepareForPartialUpdate, PrepareForUpdate
  3281. Example
  3282.                    The following example creates two overlapping frames
  3283.                    and awaits for a click of a mouse button before drawing
  3284.                    a circle on the bottom frame.
  3285.  
  3286.  
  3287.  Programmer's Reference Guide       - 54 -         TEGL Windows Toolkit
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.                           Chapter 4 - Frames
  3294.  
  3295.  
  3296. {samc0410.pas }
  3297. VAR FS : ImageStkPtr;
  3298.  
  3299.   PushImage(1,1,100,100);
  3300.   ShadowBox(1,1,100,100);
  3301.   fs := StackPtr;
  3302.  
  3303.   PushImage(50,50,150,150);
  3304.   ShadowBox(50,50,150,150);
  3305.  
  3306.   WHILE Mouse_Buttons = 0 DO;
  3307.  
  3308.   PrepareForUpdate(fs);
  3309.   SetColor(blue);
  3310.   Circle(fs^.x+48,fs^.y+45,40);
  3311.   CommitUpdate;
  3312.  
  3313.  
  3314.  
  3315.  
  3316. Moving a Frame
  3317.  
  3318.  
  3319. ___________________________________________________________________________
  3320.  
  3321. FrameSelectAndMove Function                                        TEGLUNIT
  3322. ___________________________________________________________________________
  3323.  
  3324.  
  3325. Function
  3326.                    Allows a frame to be moved. This routine is normally
  3327.                    called by the TEGL supervisor when the right mouse
  3328.                    button is held down and the mouse cursor is positioned
  3329.                    over a frame.
  3330.  
  3331. Declaration
  3332.                    FrameSelectAndMove(mxpos,mypos : word): ImageStkPtr;
  3333. Result type
  3334.                    Returns a pointer to the frame that the mouse had
  3335.                    selected and moved.
  3336. Remarks
  3337.                    The movement of the Frame is under the control of the
  3338.                    user until the mouse button is released. To move a
  3339.                    frame under program control, use MoveStackImage.
  3340.  
  3341. Restrictions
  3342.                    This function returns immediately if neither mouse
  3343.                    button is held down on entry.
  3344.  
  3345. See also
  3346.                    SetMoveRestrictions, SetFrameMobility,
  3347.  
  3348.  Programmer's Reference Guide       - 55 -         TEGL Windows Toolkit
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.                           Chapter 4 - Frames
  3355.  
  3356.                    SetMoveFrameCallProc, MoveStackImage
  3357. Example
  3358.                    The following example displays a green mouse cursor and
  3359.                    calls FrameSelectAndMove whenever the right mouse
  3360.                    button is pressed. The routine exits and changes the
  3361.                    mouse cursor back to white when the left mouse button
  3362.                    is pressed.
  3363.  
  3364.  
  3365. VAR FS : ImageStkPtr;
  3366.  
  3367.   PushImage(1,1,100,100);
  3368.   ShadowBox(1,1,100,100);
  3369.   fs := StackPtr;
  3370.  
  3371.   ShowMouse;
  3372.   SetMouseColor(green);
  3373.   REPEAT
  3374.     IF Mouse_Buttons=2 THEN
  3375.       fs := FrameSelectAndMove(Mouse_Xcoord,Mouse_Ycoord);
  3376.   UNTIL Mouse_Buttons = 1;
  3377.   SetMouseColor(white);
  3378.  
  3379.  
  3380.  
  3381.  
  3382.  
  3383. ___________________________________________________________________________
  3384.  
  3385. SetAutoRotate Procedure                                            TEGLUNIT
  3386. ___________________________________________________________________________
  3387.  
  3388.  
  3389. Function
  3390.                    Sets the frame stack auto rotate function.
  3391. Declaration
  3392.                    SetAutoRotate(OnOff: Boolean); 
  3393. Remarks
  3394.                    Auto rotate is normally set to FALSE. That is, a frame
  3395.                    will not automatically rotate to the top of the stack.
  3396.                    When set to TRUE any frame that is partially covered
  3397.                    will be moved to the top of the stack when
  3398.                    TEGLSupervisor detects a left mouse button click
  3399.                    anywhere on the frame.
  3400. Example
  3401.  
  3402.  
  3403.   { -- after this frames jump to the top with a click of the mouse }
  3404.   SetAutoRotate(TRUE);
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  Programmer's Reference Guide       - 56 -         TEGL Windows Toolkit
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.                           Chapter 4 - Frames
  3416.  
  3417.  
  3418.  
  3419.  
  3420. ___________________________________________________________________________
  3421.  
  3422. SetMoveRestrictions Procedure                                      TEGLUNIT
  3423. ___________________________________________________________________________
  3424.  
  3425.  
  3426. Function
  3427.                    Sets the minimum and maximum coordinates that a frame
  3428.                    may be moved.
  3429. Declaration
  3430.                    SetMoveRestrictions(sh VAR frame; x,y,x1,y1:
  3431.                    word)
  3432. Remarks
  3433.                    Sets the area that a frame is restricted to when
  3434.                    FrameSelectAndMove is called.
  3435. Restrictions
  3436.                    The restriction does not apply when a frame is moved
  3437.                    using MoveStackImage.
  3438. See also
  3439.                    FrameSelectAndMove, SetFrameMobility,
  3440.                    SetMoveFrameCallProc, MoveStackImage
  3441. Example
  3442.                    The following sets the frame mobility to the upper half
  3443.                    of the screen. Use the right mouse button to move the
  3444.                    frame around.
  3445.  
  3446.  
  3447.   PushImage(1,1,100,100);
  3448.   ShadowBox(1,1,100,100);
  3449.   SetMoveRestrictions(StackPtr,0,0,GetmaxX,GetmaxY div 2);
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457. ___________________________________________________________________________
  3458.  
  3459. SetFrameMobility Procedure                                         TEGLUNIT
  3460. ___________________________________________________________________________
  3461.  
  3462.  
  3463. Function
  3464.                    Toggles the ability for a frame to move.
  3465. Declaration
  3466.                    SetFrameMobility(sh VAR frame;  movable:
  3467.                    boolean)
  3468. Remarks
  3469.  
  3470.  Programmer's Reference Guide       - 57 -         TEGL Windows Toolkit
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.                           Chapter 4 - Frames
  3477.  
  3478.                    When the mobility of a frame is set to off (false), the
  3479.                    frame outline will move when FrameSelectAndMove is
  3480.                    called, however, the frame is not moved to the new
  3481.                    location when the mouse button is released.
  3482.  
  3483.                    The default frame mobility is ON (true).
  3484. Restrictions
  3485.                    The mobility toggle has no effect when a frame is moved
  3486.                    using MoveStackImage.
  3487. See also
  3488.                    FrameSelectAndMove, SetMoveRestrictions,
  3489.                    SetMoveFrameCallProc, MoveStackImage
  3490. Example
  3491.                    The following example toggles a frames mobility to off.
  3492.  
  3493.  
  3494.  
  3495.   PushImage(1,1,100,100);
  3496.   ShadowBox(1,1,100,100);
  3497.   SetFrameMobility(StackPtr,false);
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.  
  3504. ___________________________________________________________________________
  3505.  
  3506. SetMoveFrameCallProc Procedure                                     TEGLUNIT
  3507. ___________________________________________________________________________
  3508.  
  3509.  
  3510. Function
  3511.                    An event process that is called after an frame has been
  3512.                    dragged to a new screen position.
  3513. Declaration
  3514.                    SetMoveFrameCallProc(sh VAR frame : ImageStkPtr;
  3515.                      P : CallProc);
  3516. Remarks
  3517.                    Can be used for the trash can effect, originating with
  3518.                    the MacIntosh, by which file icons are dragged to the
  3519.                    trash can to be deleted from the system.
  3520.  
  3521.                    The event may check the MouseClickPos Record (fields
  3522.                    MS.X, MS.Y, MS.X1, and MS.Y1) for the new frame
  3523.                    location and whether they overlap the desired frame.
  3524. Restrictions
  3525.                    If you wish for the frame to move to the new location,
  3526.                    the event must call MoveStackImage before returning.
  3527. See also
  3528.                    FrameSelectAndMove, SetMoveRestrictions,
  3529.                    SetFrameMobility, MoveStackImage
  3530.  
  3531.  Programmer's Reference Guide       - 58 -         TEGL Windows Toolkit
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.                           Chapter 4 - Frames
  3538.  
  3539. Example
  3540.                    The following is a very simple Event Handler that
  3541.                    simply closes the frame if the frame is moved.
  3542.  
  3543.  
  3544. Function Poof(Frame:ImageStkPtr; MouseClickPos : MsClickPtr) : Word;
  3545.    BEGIN
  3546.       HideMouse;
  3547.       DropStackImage(frame);
  3548.       ShowMouse;
  3549.       Poof := 0;
  3550.    END;
  3551.  
  3552.   PushImage(1,1,100,100);
  3553.   ShadowBox(1,1,100,100);
  3554.   SetMoveFrameCallProc(StackPtr,Poof);
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561. ___________________________________________________________________________
  3562.  
  3563. MoveStackImage Procedure                                           TEGLUNIT
  3564. ___________________________________________________________________________
  3565.  
  3566.  
  3567. Function
  3568.                    Move a frame to a new screen location.
  3569. Declaration
  3570.                    MoveStackImage(sh VAR Frame; x,y : word)
  3571. Remarks
  3572.                    Used to move a frame under Program control to a new
  3573.                    screen location. X and Y are absolute coordinates that
  3574.                    specify the upper left corner of the frame at the new
  3575.                    location.
  3576. Restrictions
  3577.                    The coordinates are not validated, so care must be
  3578.                    taken to ensure that the resulting coordinates of the
  3579.                    lower right corner falls within the screen area.
  3580. See also
  3581.                    FrameSelectAndMove, SetMoveRestrictions,
  3582.                    SetFrameMobility, SetFrameCallProc
  3583. Example
  3584.                    The following example moves a smaller frame under
  3585.                    another larger frame to demonstrate the integrity of
  3586.                    stacked images.
  3587.  
  3588.  
  3589. VAR fs : ImageStkPtr;
  3590.     i  : word;
  3591.  
  3592.  Programmer's Reference Guide       - 59 -         TEGL Windows Toolkit
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.                           Chapter 4 - Frames
  3599.  
  3600.  
  3601.   PushImage(1,1,20,20);
  3602.   ShadowBox(1,1,20,20);
  3603.   fs := StackPtr;
  3604.  
  3605.   PushImage(50,50,150,150);
  3606.   ShadowBox(50,50,150,150);
  3607.  
  3608.   FOR i:=1 to 100 DO
  3609.     MoveStackImage(fs,fs^.x+2,fs^.y+2);
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616. ___________________________________________________________________________
  3617.  
  3618. MoveFrame Procedure                                                TEGLUNIT
  3619. ___________________________________________________________________________
  3620.  
  3621.  
  3622.  
  3623. Function
  3624.                    Moves an Xor wire frame from one location to
  3625.                    another.
  3626. Declaration
  3627.                    MoveFrame(VAR fx,fy,fx1,fy1 : Integer;
  3628.                      rx,ry,rx1,ry1: Integer; Color: Integer); 
  3629. Remarks
  3630.                    This only moves a wire frame not the actual frame.
  3631.                    The mouse button must be held down on entry or this
  3632.                    function returns immediately. rx,ry,rx1,ry1 are
  3633.                    the starting coordinates. fx,fy,fx1,fy1 are the
  3634.                    coordinates when the mouse button is released.
  3635.                    Color is the wireframe color.
  3636.  
  3637.  
  3638. Low Level Frame Functions
  3639.  
  3640.  
  3641. ___________________________________________________________________________
  3642.  
  3643. UnLinkFS Procedure                                                 TEGLUNIT
  3644. ___________________________________________________________________________
  3645.  
  3646.  
  3647. Function
  3648.                    Disconnects a frame from the stack.
  3649. Declaration
  3650.                    UnLinkFS(sh VAR Frame)
  3651. Remarks
  3652.  
  3653.  Programmer's Reference Guide       - 60 -         TEGL Windows Toolkit
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.                           Chapter 4 - Frames
  3660.  
  3661.                    UnLinkFS allows you to disconnect a frame from the
  3662.                    Image stack to stop any further actions by the frame
  3663.                    manager.
  3664.  
  3665.                    This procedure is used throughout the window management
  3666.                    routines. It is provided as an external routine only
  3667.                    for specialized needs.
  3668. Restrictions
  3669.                    This procedure should be used in conjunction with 
  3670.                    HideImage, ShowImage, CreateImageBuffer, 
  3671.                    DropImageBuffer, and LinkFS.
  3672.  
  3673.                    If you unlink a frame from the stack without first
  3674.                    hiding the frame, the stack manager will not
  3675.                    acknowledge the existence of the frame and will
  3676.                    overwrite the unlinked frame area.
  3677. See also
  3678.                    LinkFS, LinkUnderFS
  3679. Example
  3680.                    The following example hides the frame before unlinking
  3681.                    and dropping the image.
  3682.  
  3683.  
  3684. VAR FS : ImageStkPtr;
  3685.  
  3686.   PushImage(1,1,100,100);
  3687.   ShadowBox(1,1,100,100);
  3688.   fs := StackPtr;
  3689.  
  3690.   PushImage(50,50,150,150);
  3691.   ShadowBox(50,50,150,150);
  3692.  
  3693.   WHILE Mouse_Buttons = 0 DO;
  3694.  
  3695.   HideImage(fs);
  3696.   UnLinkFS(fs);
  3697.   DropImageBuffer(fs);
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705. ___________________________________________________________________________
  3706.  
  3707. LinkFS Procedure                                                   TEGLUNIT
  3708. ___________________________________________________________________________
  3709.  
  3710.  
  3711. Function
  3712.                    Reconnects a frame to the stack.
  3713.  
  3714.  Programmer's Reference Guide       - 61 -         TEGL Windows Toolkit
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.                           Chapter 4 - Frames
  3721.  
  3722. Declaration
  3723.                    LinkFS(sh VAR Frame1,Frame2)
  3724. Remarks
  3725.                    LinkFS reconnects Frame1 with the Frame stack, above
  3726.                    Frame2.
  3727.  
  3728.                    This procedure is used throughout the window management
  3729.                    routines. It is provided as an external routine only
  3730.                    for specialized needs.
  3731. Restrictions
  3732.                    This procedure should be used in conjunction with 
  3733.                    HideImage, ShowImage, CreateImageBuffer, 
  3734.                    DropImageBuffer, and UnLinkFS.
  3735. See also
  3736.                    UnLinkFS, LinkUnderFS
  3737. Example
  3738.                    The following example performs the same function as 
  3739.                    RotateStackImage.
  3740.  
  3741.  
  3742. VAR FS : ImageStkPtr;
  3743.  
  3744.   PushImage(1,1,100,100);
  3745.   ShadowBox(1,1,100,100);
  3746.   fs := StackPtr;
  3747.  
  3748.   PushImage(50,50,150,150);
  3749.   ShadowBox(50,50,150,150);
  3750.  
  3751.   WHILE Mouse_Buttons = 0 DO;
  3752.  
  3753.   HideImage(fs);
  3754.   UnLinkFS(fs);
  3755.   LinkFS(fs,StackPtr);
  3756.   ShowImage(fs,fs^.x,fs^.y);
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764. ___________________________________________________________________________
  3765.  
  3766. LinkUnderFS Procedure                                              TEGLUNIT
  3767. ___________________________________________________________________________
  3768.  
  3769.  
  3770. Function
  3771.                    Reconnects a frame with the frame stack, below the
  3772.                    specified frame.
  3773. Declaration
  3774.  
  3775.  Programmer's Reference Guide       - 62 -         TEGL Windows Toolkit
  3776.  
  3777.  
  3778.  
  3779.  
  3780.  
  3781.                           Chapter 4 - Frames
  3782.  
  3783.                    LinkUnderFS(sh VAR Frame1,Frame2)
  3784. Remarks
  3785.                    LinkUnderFS reconnects Frame1 below Frame2.
  3786.  
  3787.                    This procedure is used throughout the window management
  3788.                    routines. It is provided as an external routine only
  3789.                    for specialized needs.
  3790. Restrictions
  3791.                    This procedure should be used in conjunction with 
  3792.                    HideImage, ShowImage, CreateImageBuffer, 
  3793.                    DropImageBuffer, and UnLinkFS.
  3794. See also
  3795. UnLinkFS, LinkFS
  3796. Example
  3797.                    The following example performs the same function as 
  3798.                    RotateUnderStackImage.
  3799.  
  3800.  
  3801. VAR fs1,fs2 : ImageStkPtr;
  3802.  
  3803.   PushImage(1,1,100,100);
  3804.   ShadowBox(1,1,100,100);
  3805.   fs1 := StackPtr;
  3806.  
  3807.   PushImage(50,50,150,150);
  3808.   ShadowBox(50,50,150,150);
  3809.   fs2 := StackPtr;
  3810.  
  3811.   WHILE Mouse_Buttons = 0 DO;
  3812.  
  3813.   HideImage(fs2);
  3814.   UnLinkFS(fs2);
  3815.   LinkUnderFS(fs2,fs1);
  3816.   ShowImage(fs2,fs2^.x,fs2^.y);
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824. ___________________________________________________________________________
  3825.  
  3826. CreateImageBuffer Procedure                                        TEGLUNIT
  3827. ___________________________________________________________________________
  3828.  
  3829.  
  3830. Function
  3831.                    Allocates an Image buffer (frame) on the Heap.
  3832. Declaration
  3833.                    CreateImageBuffer(VAR Frame; x,y,x1,y1:word)
  3834. Remarks
  3835.  
  3836.  Programmer's Reference Guide       - 63 -         TEGL Windows Toolkit
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.                           Chapter 4 - Frames
  3843.  
  3844.                    This procedure is used throughout the window management
  3845.                    routines. It is provided as an external routine only
  3846.                    for specialized needs.
  3847. Restrictions
  3848.                    This procedure should be used in conjunction with 
  3849.                    HideImage, ShowImage, CreateImageBuffer, 
  3850.                    DropImageBuffer, and UnLinkFS.
  3851. See also
  3852.                    DropImageBuffer
  3853. Example
  3854.                    The following example performs the same function as 
  3855.                    PushImage.
  3856.  
  3857.  
  3858. VAR FS : ImageStkPtr;
  3859.  
  3860.   CreateImageBuffer(fs,1,1,100,100);
  3861.   LinkFs(fs,StackPtr);
  3862.   GetBiti(1,1,100,100,fs^.imagesave);
  3863.  
  3864.   ShadowBox(1,1,100,100);
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871. ___________________________________________________________________________
  3872.  
  3873. DropImageBuffer Procedure                                          TEGLUNIT
  3874. ___________________________________________________________________________
  3875.  
  3876.  
  3877. Function
  3878.                    Frees the memory used by the frame on the heap.
  3879. Declaration
  3880.                    DropImageBuffer(VAR Frame)
  3881. Remarks
  3882.                    This procedure is used throughout the window management
  3883.                    routines. It is provided as an external routine only
  3884.                    for specialized needs.
  3885. Restrictions
  3886.                    This procedure should be used in conjunction with 
  3887.                    HideImage, ShowImage, CreateImageBuffer, 
  3888.                    DropImageBuffer, and UnLinkFS.
  3889. See also
  3890.                    CreateImageBuffer
  3891. Example
  3892.                    The following example performs the same function as 
  3893.                    PopImage.
  3894.  
  3895.  
  3896.  
  3897.  Programmer's Reference Guide       - 64 -         TEGL Windows Toolkit
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.                           Chapter 4 - Frames
  3904.  
  3905. VAR FS : ImageStkPtr;
  3906.  
  3907.   PushImage(1,1,100,100);
  3908.   ShadowBox(1,1,100,100);
  3909.   fs := StackPtr;
  3910.  
  3911.   WHILE Mouse_Buttons = 0 DO;
  3912.  
  3913.   UnlinkFS(fs);
  3914.   DropImageBuffer(fs);
  3915.  
  3916.  
  3917.  
  3918.  
  3919.  
  3920.  
  3921.  
  3922. ___________________________________________________________________________
  3923.  
  3924. GetFSImage Function                                                TEGLUNIT
  3925. ___________________________________________________________________________
  3926.  
  3927.  
  3928. Function
  3929.                    Retrieves the screen image within a stacked frame.
  3930. Declaration
  3931.                    GetFSImage(Frame)
  3932. Result type
  3933.                    Returns a (non-stacked) frame containing the screen
  3934.                    image and other related frame information.
  3935. Remarks
  3936.                    The (non-stacked) frame may be used for replication or
  3937.                    it can be merged with other frames.
  3938. See also
  3939.                    PutFSImage
  3940. Example
  3941.                    The following example creates a single frame and
  3942.                    replicates the frame.
  3943.  
  3944.  
  3945.  
  3946. VAR FS,TS : ImageStkPtr;
  3947.  
  3948.   PushImage(1,1,100,100);
  3949.   ShadowBox(1,1,100,100);
  3950.   fs := StackPtr;
  3951.  
  3952.   ts := GetFSImage(fs);
  3953.   PushImage(51,51,150,150);
  3954.   PutFSImage(51,51,ts,FGNORM);
  3955.   DropImageBuffer(ts);
  3956.  
  3957.  
  3958.  Programmer's Reference Guide       - 65 -         TEGL Windows Toolkit
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.                           Chapter 4 - Frames
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971. ___________________________________________________________________________
  3972.  
  3973. PutFSImage Procedure                                               TEGLUNIT
  3974. ___________________________________________________________________________
  3975.  
  3976.  
  3977. Function
  3978.                    Places the frame saved image anywhere on the screen.
  3979. Declaration
  3980.                    PutFSImage(x,y,Frame,RWBITS)
  3981. Remarks
  3982.                    RWBITS are constants defined in EGAGRAPH which
  3983.                    defines how the images are placed on the screen.
  3984.  
  3985. FGNorn
  3986.                    replaces screen area with frame image
  3987. FGAnd
  3988.                    AND's screen area with frame image. Toggles off screen
  3989.                    areas that do no have a frame image. Creates an outline
  3990.                    of the frame image.
  3991. FGOr
  3992.                    OR's screen area with frame image. Toggles on empty
  3993.                    screen areas that have a frame image. Creates a solid
  3994.                    frame image.
  3995. FGXor
  3996.                    XOR's screen area with frame image.
  3997. FGNot
  3998.                    Inverts frame image and replaces screen area with
  3999.                    image.
  4000.  
  4001. See also
  4002. GetFSImage
  4003. Example
  4004.                    The following example creates a single frame and
  4005.                    replicates the frame.
  4006.  
  4007.  
  4008. VAR fs,ts : ImageStkPtr;
  4009.     i    : word;
  4010.  
  4011.   PushImage(1,1,100,100);
  4012.   ShadowBox(1,1,100,100);
  4013.   fs := StackPtr;
  4014.  
  4015.   ts := GetFSImage(fs);
  4016.  
  4017.   FOR i:=1 to 20 DO
  4018.  
  4019.  Programmer's Reference Guide       - 66 -         TEGL Windows Toolkit
  4020.  
  4021.  
  4022.  
  4023.  
  4024.  
  4025.                           Chapter 4 - Frames
  4026.  
  4027.     BEGIN
  4028.       PushImage(1+i*10,1+i*10,100+i*10,100+i*10);
  4029.       PutFSImage(1+i*10,1+i*10,ts,FGNOT);
  4030.     END;
  4031.  
  4032.   DropImageBuffer(ts);
  4033.  
  4034.  
  4035.  
  4036.  
  4037.  
  4038. ___________________________________________________________________________
  4039.  
  4040. FreeImageBuffer Procedure                                          TEGLUNIT
  4041. ___________________________________________________________________________
  4042.  
  4043.  
  4044.  
  4045. Function
  4046.                    Frees up the memory allocated for a frame buffer.
  4047. Declaration
  4048.                    FreeImageBuffer(VAR ifs : ImageStkPtr); 
  4049. Remarks
  4050.                    This is generally an internal function. Do not use
  4051.                    it unless you have a clear understanding of inner
  4052.                    workings of the frame stack.
  4053.  
  4054.  
  4055.  
  4056. ___________________________________________________________________________
  4057.  
  4058. GetPartialFrontImage Function                                      TEGLUNIT
  4059. ___________________________________________________________________________
  4060.  
  4061.  
  4062.  
  4063. Function
  4064.                    Gets the partial image of a frame and returns a
  4065.                    pointer to a temporary buffer.
  4066. Declaration
  4067.                    GetPartialFrontImage(Frame: ImageStkPtr;
  4068.                      x,y,x1,y1 : Word) : ImageStkPtr; 
  4069. Remarks
  4070.                    This is a safer way to get the partial
  4071.                    image of a frame than using GetBiti.
  4072.                    Overlapping frames are partially removed and
  4073.                    then restored before returning.
  4074.  
  4075.  
  4076.  
  4077.  
  4078. ___________________________________________________________________________
  4079.  
  4080.  Programmer's Reference Guide       - 67 -         TEGL Windows Toolkit
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.                           Chapter 4 - Frames
  4087.  
  4088.  
  4089. GetFrontImage Function                                             TEGLUNIT
  4090. ___________________________________________________________________________
  4091.  
  4092.  
  4093.  
  4094. Function
  4095.                    Get the image of a frame and returns a pointer to
  4096.                    a temporary buffer.
  4097. Declaration
  4098.                    GetFrontImage(ifs : ImageStkPtr): ImageStkPtr;
  4099. Remarks
  4100.                    This is a safer way to get the image of a
  4101.                    frame than using GetBiti. Overlapping
  4102.                    frames are partially removed and then restored
  4103.                    before returning.
  4104.  
  4105.  
  4106.  
  4107. ___________________________________________________________________________
  4108.  
  4109. PageInFS Procedure                                                 TEGLUNIT
  4110. ___________________________________________________________________________
  4111.  
  4112.  
  4113.  
  4114. Function
  4115.                    Read an image into memory.
  4116. Declaration
  4117.                    PageInFS(VAR ifs : ImageStkPtr); 
  4118. Remarks
  4119.                    If the image is already in memory then no action
  4120.                    is taken.
  4121. See also
  4122.                    PageOutFS.
  4123. Example
  4124.                    This example checks to see if the image is in
  4125.                    memory first before attempting to read it in.
  4126.                    Note that PageInFS check this automatically
  4127.                    before reading in an image.
  4128.  
  4129.  
  4130.   IF ifs^.ImagePageOut THEN    { -- the image is not in memory }
  4131.     PageInFS(ifs);
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137. ___________________________________________________________________________
  4138.  
  4139. LockImage Procedure                                                TEGLUNIT
  4140.  
  4141.  Programmer's Reference Guide       - 68 -         TEGL Windows Toolkit
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.                           Chapter 4 - Frames
  4148.  
  4149. ___________________________________________________________________________
  4150.  
  4151.  
  4152.  
  4153. Function
  4154.                    Locks an frame image into memory.
  4155. Declaration
  4156.                    LockImage(VAR ifs : ImageStkPtr); 
  4157. Remarks
  4158.                    The image is read into memory if required. The
  4159.                    lock is maintained until a specific call is made
  4160.                    to UnLockImage.
  4161.  
  4162.                    Lock image can be used where it is desirable to
  4163.                    replicate an image on the screen repeatedly. After
  4164.                    it is locked then it can be placed on the screen
  4165.                    with a call to PutBiti.
  4166. Restrictions
  4167.                    This should be used with caution especially if you
  4168.                    are locking in a large image. You can fragment the
  4169.                    heap and the Virtual Memory Manager may not be able
  4170.                    to allocate a large enough memory block for
  4171.                    subsequent image swaps.
  4172. See also
  4173.                    UnLockImage, UseImage, UnUseImage
  4174. Example
  4175.                    If the image is less than 64k then it can be copied
  4176.                    to Turbo's heap and then the image can be unlocked
  4177.                    reducing the chance of a heap error.
  4178.  
  4179.  
  4180.  
  4181. VAR ifs : ImageStackPtr;
  4182.     buf : Pointer;
  4183.  
  4184.   PushImage(100,100,300,150);
  4185.   ifs := StackPtr;
  4186.   ShadowBox(100,100,300,150);
  4187.   { -- do something with the frame }
  4188.   { -- then lock it so its not swapped out }
  4189.   LockImage(ifs);
  4190.   { -- allocate memory on Turbo's Heap }
  4191.   GetMem(buf,ifs^.ImageSize);
  4192.   { -- move it there }
  4193.   buf^ := ifs^.imagesave;
  4194.   { -- unlock the image }
  4195.   UnLockImage(ifs):
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  Programmer's Reference Guide       - 69 -         TEGL Windows Toolkit
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.                           Chapter 4 - Frames
  4209.  
  4210. ___________________________________________________________________________
  4211.  
  4212. PageOutFS Procedure                                                TEGLUNIT
  4213. ___________________________________________________________________________
  4214.  
  4215.  
  4216.  
  4217. Function
  4218.                    Page out a frame image.
  4219. Declaration
  4220.                    PageOutFS(VAR ifs : ImageStkPtr); 
  4221. Remarks
  4222.                    If the image is successfully paged out to
  4223.                    EMS or disk then TEGLFreeMem is called
  4224.                    to free up the memory used.
  4225. Restrictions
  4226.                    If ifs is in use, or locked or already
  4227.                    paged out then no action is taken.
  4228. See also
  4229.                    PageInFS.
  4230. Example
  4231.  
  4232.  
  4233.  
  4234.   PageOutFS(ifs);
  4235.   IF ifs^.ImagePageOut THEN { -- success }
  4236.     ELSE ; { -- failure }
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242. ___________________________________________________________________________
  4243.  
  4244. SetImageCoordinates Procedure                                      TEGLUNIT
  4245. ___________________________________________________________________________
  4246.  
  4247.  
  4248.  
  4249. Function
  4250.                    Sets the frame pointer to a new set of coordinates.
  4251. Declaration
  4252.                    SetImageCoordinates(VAR ifs : ImageStkPtr;
  4253.                      x,y,x1,y1 : Word); 
  4254. Remarks
  4255.                    A frame's coordinates should not be changed if it is
  4256.                    visible.
  4257.  
  4258.  
  4259.  
  4260. ___________________________________________________________________________
  4261.  
  4262.  
  4263.  Programmer's Reference Guide       - 70 -         TEGL Windows Toolkit
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.                           Chapter 4 - Frames
  4270.  
  4271. PageOutImageStack Function                                         TEGLUNIT
  4272. ___________________________________________________________________________
  4273.  
  4274.  
  4275.  
  4276. Function
  4277.                    Requests the virtual memory manager to page out
  4278.                    images to make a chunk of memory available.
  4279. Declaration
  4280.                    PageOutImageStack(Mem : LongInt) : Boolean 
  4281. Remarks
  4282.                    Mem is the amount of memory required. A large
  4283.                    value for Mem will result in all image buffers
  4284.                    being paged out. This function returns true if the
  4285.                    amount of memory requested has been freed.
  4286. Restrictions
  4287.                    Large amounts of memory are required to process
  4288.                    image swapping. If you allocate too much and don't
  4289.                    free it up as quickly as possible you may get a
  4290.                    heap error.
  4291.  
  4292. Example
  4293.  
  4294.  
  4295.   { -- force all imagebuffers to disk }
  4296.   IF PageOutImageStack(512000) THEN;   { -- ignore result }
  4297.   { -- do whatever needs that much memory }
  4298.   SuperSortMemUse(MaxAvail);
  4299.   SuperSort;
  4300.   { -- release it before working with windows again }
  4301.   SuperSortFreeMem;
  4302.  
  4303.  
  4304.  
  4305.  
  4306.  
  4307.  
  4308. ___________________________________________________________________________
  4309.  
  4310. UnLockImage Procedure                                              TEGLUNIT
  4311. ___________________________________________________________________________
  4312.  
  4313.  
  4314.  
  4315. Function
  4316.                    Unlocks a frame image.
  4317. Declaration
  4318.                    UnLockImage(VAR ifs : ImageStkPtr); 
  4319. Remarks
  4320.                    Unlock simply sets a flag in the ImageStkPtr.
  4321.                    After unlocking, the Virtual Memory Manager can
  4322.                    swap the image to EMS or Disk as required. If the
  4323.  
  4324.  Programmer's Reference Guide       - 71 -         TEGL Windows Toolkit
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.                           Chapter 4 - Frames
  4331.  
  4332.                    image wasn't locked then no action is taken.
  4333. Restrictions
  4334.                    See restrictions for LockImage.
  4335. See also
  4336.                    LockImage, UseImage, UnUseImage.
  4337. Example
  4338.                    See example for LockImage.
  4339.  
  4340.  
  4341.  
  4342.  
  4343. ___________________________________________________________________________
  4344.  
  4345. UnUseImage Procedure                                               TEGLUNIT
  4346. ___________________________________________________________________________
  4347.  
  4348.  
  4349.  
  4350. Function
  4351.                    Flags a frame image as no longer in use.
  4352. Declaration
  4353.                    UnUseImage(VAR ifs : ImageStkPtr); 
  4354. Remarks
  4355.                    This should be called as soon as possible after
  4356.                    a UseImage to keep as much memory free for
  4357.                    the Virtual Memory Manager.
  4358. See also
  4359.                    UseImage, LockImage, UnLockImage.
  4360. Example
  4361.  
  4362.  
  4363.   UseImage(ifs);
  4364.   { -- do something with it }
  4365.  
  4366.   { -- then let the memory manager swap it out if required }
  4367.   UnUseImage(ifs);
  4368.  
  4369.  
  4370.  
  4371.  
  4372.  
  4373.  
  4374. ___________________________________________________________________________
  4375.  
  4376. UseImage Procedure                                                 TEGLUNIT
  4377. ___________________________________________________________________________
  4378.  
  4379.  
  4380.  
  4381. Function
  4382.                    Makes an image available for use.
  4383. Declaration
  4384.  
  4385.  Programmer's Reference Guide       - 72 -         TEGL Windows Toolkit
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.                           Chapter 4 - Frames
  4392.  
  4393.                    UseImage(VAR ifs : ImageStkPtr); 
  4394. Remarks
  4395.                    The frame image is read into memory if not
  4396.                    already then and then flagged as being in
  4397.                    use.
  4398. Restrictions
  4399.                    If you do PrepareForUpdate then the
  4400.                    in use flag is set to false.
  4401. See also
  4402.                    UnUseImage, LockImage, UnLockImage.
  4403. Example
  4404.  
  4405.  
  4406.   UseImage(ifs);
  4407.   { -- do something with it }
  4408.  
  4409.   { -- then let the memory manager swap it out if required }
  4410.   UnUseImage(ifs);
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417. Mouse Click Areas
  4418.  
  4419. Mouse click areas are those places on the screen where we sense if the
  4420. mouse pointer has passed over or has been clicked on. Frames can have
  4421. mouse click areas on them that are, of course, only available if the frame
  4422. is visible and the mouse click area is uncovered.
  4423.  
  4424. The sensitivity of the mouse click area has two levels. The most sensitive
  4425. is MsSense where just having the mouse pointer pass over the area
  4426. causes an action. The other level is MsClick where the mouse pointer
  4427. must be over the mouse click area and the left mouse button has been
  4428. pressed.
  4429.  
  4430.  
  4431.  
  4432. ___________________________________________________________________________
  4433.  
  4434. DefineMouseClickArea Procedure                                     TEGLUNIT
  4435. ___________________________________________________________________________
  4436.  
  4437.  
  4438.  
  4439. Function
  4440.                    Attaches an sensitive area of a frame to an event
  4441.                    function.
  4442. Declaration
  4443.                    DefineMouseClickArea(VAR ifs : ImageStkPtr; x,y,x1,y1:
  4444.                      Integer; Active : Boolean; P : CallProc, Sense: Boolean);
  4445.  
  4446.  Programmer's Reference Guide       - 73 -         TEGL Windows Toolkit
  4447.  
  4448.  
  4449.  
  4450.  
  4451.  
  4452.                           Chapter 4 - Frames
  4453.  
  4454. Remarks
  4455.                    ifs is any ImageStkPtr. The x, y, x1, y1 are coordinates
  4456.                    relative to a frame. This means that the upper left
  4457.                    corner of a frame is considered 0,0.
  4458.  
  4459.                    Active is a boolean flag to indicate whether the Mouse
  4460.                    Click Area is an active entry True or a place holder
  4461.                    False in a list of mouse clicks. A place holder is
  4462.                    simply a defined entry with no action recognized.
  4463.  
  4464.                    p is the event to call when the Mouse Click Area
  4465.                    is activated, either by the mouse pointer passing by
  4466.                    the click areas or a mouse click occurring on an click
  4467.                    area.
  4468.  
  4469.                    NilUnitProc may be used to define a no-event
  4470.                    handler. This may be used in conjunction with the
  4471.                    functions FindFrame and CheckMouseClickPos to
  4472.                    check for the respective mouse click activation.
  4473.  
  4474.                    NilUnitProc may also be used as a temporary
  4475.                    parameter. Use ResetMSClickCallProc to add the proper
  4476.                    event handler later.
  4477.  
  4478.                    Sense is either MSSense or MSClick. MSSense activates
  4479.                    the event handler whenever the mouse cursor passes over
  4480.                    the defined mouse click areas. MSClick requires the
  4481.                    right mouse button to be pressed while the mouse cursor
  4482.                    is on the mouse click area.
  4483. Restrictions
  4484.                    The number of mouse click areas is limited only by
  4485.                    memory. Overlapping click area take priority over
  4486.                    underlying click areas.
  4487.  
  4488.                    The coordinates of a Mouse click area must reside
  4489.                    within the Frame, otherwise the click areas are not
  4490.                    recognized.
  4491. See also
  4492.                    FindMouseClickPtr, ResetMouseClicks,
  4493.                    ResetMSClickSense, ResetMSClickCallProc,
  4494.                    ResetMSClickActive, CheckMouseClickPos
  4495. Example
  4496.                    The following example creates a frame that attaches an
  4497.                    'OK' icon with an Event Handler called DropBoxOption
  4498.                    which simply closes the frame and exits.
  4499.  
  4500.                    The function CheckforMouseSelect is used to create
  4501.                    the illusion of a button being pressed when clicked on.
  4502.  
  4503.  
  4504.  
  4505. Function DropBoxOption(Frame:ImageStkPtr; MouseClickPos: MSClickPtr):WORD;
  4506.  
  4507.  Programmer's Reference Guide       - 74 -         TEGL Windows Toolkit
  4508.  
  4509.  
  4510.  
  4511.  
  4512.  
  4513.                           Chapter 4 - Frames
  4514.  
  4515.    BEGIN
  4516.       IF CheckforMouseSelect(Frame)<>nil then
  4517.         BEGIN
  4518.            Hidemouse;
  4519.            DropStackImage(Frame);
  4520.            ShowMouse;
  4521.         END;
  4522.  
  4523.       DropBoxOption := 0;
  4524.    END;
  4525.  
  4526.   PushImage(1,1,100,100);
  4527.   ShadowBox(1,1,100,100);
  4528.   PutPict(50,80,@ImageOk,black);
  4529.   DefineMouseClickArea(StackPtr,50,80,50+35,80+12,true,
  4530.     DropBoxOption,MSClick);
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536. ___________________________________________________________________________
  4537.  
  4538. FindMouseClickPtr Function                                         TEGLUNIT
  4539. ___________________________________________________________________________
  4540.  
  4541.  
  4542. Function
  4543.                    Searches for a Mouse Click Pointer associated with a
  4544.                    Mouse Click Number.
  4545. Declaration
  4546.                    FindMouseClickPtr(VAR ifs : ImageStkPtr; Clicknumber:
  4547.                     Word);
  4548. Result type
  4549.                    Returns a mouse click pointer (MSClickPtr), pointing to
  4550.                    a Mouse Click Record.
  4551. Remarks
  4552.                    Click Numbers are in the order that you define the
  4553.                    Mouse Click areas. The first DefineMouseClickArea is
  4554.                    known as Click Number 1, the second is Click Number 2,
  4555.                    etc..
  4556.  
  4557.                    In certain instances it is easier to advance through
  4558.                    the mouse click areas by Click Numbers. However, most
  4559.                    functions, including the calling of Events, pass the
  4560.                    Mouse Click Pointer.
  4561.  
  4562.                    To translate a Mouse Click Pointer back to a Click
  4563.                    Number, use the Mouse Click Pointer fields ie.
  4564.                    ClickNumber := MouseClickPos^.ClickNumber where
  4565.                    MouseClickPos is of type MSClickPtr.
  4566. Restrictions
  4567.  
  4568.  Programmer's Reference Guide       - 75 -         TEGL Windows Toolkit
  4569.  
  4570.  
  4571.  
  4572.  
  4573.  
  4574.                           Chapter 4 - Frames
  4575.  
  4576.                    FindMouseClickPtr returns a Nil if the clicknumber is
  4577.                    not found. Compare the resulting MSClickPtr with Nil
  4578.                    before referencing the record.
  4579. See also
  4580.                    DefineMouseClickPtr, ResetMouseClicks,
  4581.                    ResetMSClickSense, ResetMSClickCallProc,
  4582.                    ResetMSClickActive, CheckMouseClickPos
  4583. Example
  4584.                    The following example defines an array of 100 Mouse
  4585.                    Click Areas. You may click with the left mouse button
  4586.                    on the individual tiles to produce a sound, or on the
  4587.                    'OK' to produce a series of sounds.
  4588.  
  4589.                    The function FindMouseClickPtr is used within the
  4590.                    event handler PlayAllNotes to translate a random
  4591.                    click number into a note.
  4592.  
  4593.                    The function CheckforMouseSelect is used to create
  4594.                    the illusion of a button being pressed when clicked on.
  4595.  
  4596.  
  4597.  
  4598.  
  4599. VAR x,y : word;
  4600.  
  4601. Function PlayOneNote(Frame:ImageStkPtr;
  4602.            MouseClickPos: MSClickPtr):WORD;
  4603.    BEGIN
  4604.       ToggleOptionBar(Frame,MouseClickPos,nil);
  4605.       Beep(MouseClickPos^.clicknumber*10,1,100);
  4606.       ToggleOptionBar(Frame,nil,MouseClickPos);
  4607.       PlayOneNote := 0;
  4608.    END;
  4609.  
  4610. Function PlayAllNotes(Frame:ImageStkPtr;
  4611.            MouseClickPos: MSClickPtr):WORD;
  4612.    VAR i,rs : word;
  4613.    BEGIN
  4614.       IF CheckforMouseSelect(Frame)<>nil THEN
  4615.         BEGIN
  4616.            FOR i:=1 to 30 DO
  4617.               rs := PlayOneNote(Frame,FindMouseClickPtr(Frame,
  4618.                 random(100)+1));
  4619.         END;
  4620.       PlayAllNotes := 0;
  4621.    END;
  4622.  
  4623.   PushImage(1,1,107,124);
  4624.   ShadowBox(1,1,107,124);
  4625.  
  4626.   FOR x:=0 to 9 DO
  4627.     FOR y:=0 to 9 DO
  4628.  
  4629.  Programmer's Reference Guide       - 76 -         TEGL Windows Toolkit
  4630.  
  4631.  
  4632.  
  4633.  
  4634.  
  4635.                           Chapter 4 - Frames
  4636.  
  4637.       BEGIN
  4638.         ShadowBox(StackPtr^.x+3+x*10,StackPtr^.y+3+y*10,
  4639.           StackPtr^.x+3+10+x*10,StackPtr^.y+3+10+y*10);
  4640.         DefineMouseClickArea(StackPtr,3+x*10,3+y*10,
  4641.           3+x*10+6,3+y*10+6,true,PlayOneNote,MSClick);
  4642.       END;
  4643.  
  4644.   Putpict(StackPtr^.x+50,StackPtr^.y+105,@imageok,black);
  4645.   DefineMouseClickArea(StackPtr,50,105,50+35,105+12,true,
  4646.     PlayAllNotes,MSClick);
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652. ___________________________________________________________________________
  4653.  
  4654. ResetMSClickActive Procedure                                       TEGLUNIT
  4655. ___________________________________________________________________________
  4656.  
  4657.  
  4658. Function
  4659.                    Resets the active flag to indicate whether a Mouse
  4660.                    Click Area Entry is active or inactive.
  4661. Declaration
  4662.                    ResetMSClickActive(VAR ifs: ImageStkPtr;
  4663.                      MouseClickNumber : Word; Active : Boolean); 
  4664. Remarks
  4665.                    The MouseClickNumber is in the order that you defined
  4666.                    the Mouse Click areas. The first DefineMouseClickArea
  4667.                    is known as MouseClickNumber 1, the second is
  4668.                    MouseClickNumber 2, etc..
  4669.  
  4670.                    Active is a boolean flag to indicate whether the Mouse
  4671.                    Click Area is an active entry (True) or a place holder
  4672.                    (False) in a list of mouse clicks. A place holder is
  4673.                    simple a defined entry with no action recognized.
  4674. Restrictions
  4675.                    If the MouseClickNumber is invalid, the flag is not
  4676.                    updated.
  4677. See also
  4678.                    DefineMouseClickPtr, ResetMouseClicks,
  4679.                    FindMouseClickPtr, ResetMSClickSense,
  4680.                    ResetMSClickCallProc, CheckMouseClickPos
  4681. Example
  4682.                    This example creates an array of 10 buttons which all
  4683.                    point to the same Event Handler SwitchOn. The
  4684.                    active flag for a pressed button is turned off to
  4685.                    prevent multiple calls to SwitchOn, until another
  4686.                    button is pressed. ResetMSClickActive is used
  4687.                    within SwitchOn to toggle the button Active state.
  4688.  
  4689.  
  4690.  Programmer's Reference Guide       - 77 -         TEGL Windows Toolkit
  4691.  
  4692.  
  4693.  
  4694.  
  4695.  
  4696.                           Chapter 4 - Frames
  4697.  
  4698.  
  4699.  
  4700.  
  4701. VAR x,y : word;
  4702.  
  4703. function SwitchOn(Frame:ImageStkPtr;
  4704.            MouseClickPos: MsClickPtr) : word;
  4705.    VAR i  : word;
  4706.        ms : msclickptr;
  4707.    BEGIN
  4708.       Beep(1500,1,10);
  4709.  
  4710.       FOR i:=1 to Frame^.MSClickCount DO
  4711.         BEGIN
  4712.           MS := FindMouseClickPtr(Frame,i);
  4713.           IF NOT MS^.MSActive THEN
  4714.             BEGIN
  4715.               HideMouse;
  4716.               PutPict(Frame^.x+MS^.ms.x,Frame^.y+MS^.ms.y,
  4717.                 @imageBlankBut,black);
  4718.               ResetMSClickActive(Frame,MS^.ClickNumber,true);
  4719.               ShowMouse;
  4720.             END;
  4721.         END;
  4722.  
  4723.       HideMouse;
  4724.       PutPict(Frame^.x+MouseClickPos^.ms.x,
  4725.         Frame^.y+MouseClickPos^.ms.y,@ImageOk,black);
  4726.       ShowMouse;
  4727.       PressButton(Frame,MouseClickPos);
  4728.       ResetMSClickActive(Frame,MouseClickPos^.ClickNumber,false);
  4729.  
  4730.       SwitchOn := 1;
  4731.    END;
  4732.  
  4733.   PushImage(1,1,100,100);
  4734.   ShadowBox(1,1,100,100);
  4735.  
  4736.   FOR x:=0 to 1 DO
  4737.      FOR y:=0 to 4 DO
  4738.         BEGIN
  4739.           Putpict(StackPtr^.x+6+x*42,StackPtr^.y+6+y*18,
  4740.             @imageBlankBut,black);
  4741.           DefineMouseClickArea(StackPtr,5+x*42,5+y*18,
  4742.             5+x*42+35,5+y*18+12,true,SwitchOn,MSClick);
  4743.         END;
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749. ___________________________________________________________________________
  4750.  
  4751.  Programmer's Reference Guide       - 78 -         TEGL Windows Toolkit
  4752.  
  4753.  
  4754.  
  4755.  
  4756.  
  4757.                           Chapter 4 - Frames
  4758.  
  4759.  
  4760. ResetMSClickCallProc Procedure                                     TEGLUNIT
  4761. ___________________________________________________________________________
  4762.  
  4763.  
  4764. Function
  4765.                    Changes the Event Handler for a Mouse click to another
  4766.                    Event Handler.
  4767. Declaration
  4768.                    ResetMSClickCallProc(ifs : ImageStkPtr; MouseClickNumber:
  4769.                      Word; P : CallProc);
  4770. Remarks
  4771.                    MouseClickNumbers are in the order that you define the
  4772.                    Mouse Click areas. The first DefineMouseClickArea is
  4773.                    known as MouseClickNumber 1, the second is
  4774.                    MouseClickNumber 2, etc..
  4775.  
  4776.                    p is the event to pass control to when the mouse
  4777.                    click area is actived.
  4778.  
  4779.                    NilUnitProc may be used to define a no-event
  4780.                    handler. This may be used in conjunction with the
  4781.                    functions FindFrame and CheckMouseClickPos to
  4782.                    check for the respective mouse click activation.
  4783.  
  4784.                    NilUnitProc may also be used to deactivate an
  4785.                    event handler.
  4786. See also
  4787.                    DefineMouseClickPtr, ResetMouseClicks,
  4788.                    FindMouseClickPtr, ResetMSClickSense,
  4789.                    ResetMSClickActive, CheckMouseClickPos
  4790. Example
  4791.                    This example switches between two events that play a
  4792.                    different series of sounds. The function 
  4793.                    CheckforMouseSelect is used to create the illusion of
  4794.                    a button being pressed when clicked on.
  4795.  
  4796.  
  4797.  
  4798. function FirstSong(Frame:ImageStkPtr;
  4799.            MouseClickPos: MsClickPtr): word; FORWARD;
  4800.  
  4801. function SecondSong(Frame:ImageStkPtr;
  4802.            MouseClickPos: MsClickPtr): word;
  4803.    BEGIN
  4804.       IF CheckforMouseSelect(Frame)<>nil THEN
  4805.         BEGIN
  4806.            Beep(1500,5,100);
  4807.            ResetMSClickCallProc(frame,
  4808.              MouseClickPos^.ClickNumber,FirstSong);
  4809.         END;
  4810.       SecondSong := 1;
  4811.  
  4812.  Programmer's Reference Guide       - 79 -         TEGL Windows Toolkit
  4813.  
  4814.  
  4815.  
  4816.  
  4817.  
  4818.                           Chapter 4 - Frames
  4819.  
  4820.    END;
  4821.  
  4822. function FirstSong(Frame:ImageStkPtr;
  4823.            MouseClickPos: msclickptr) : word;
  4824.    BEGIN
  4825.       IF CheckforMouseSelect(Frame)<>nil THEN
  4826.         BEGIN
  4827.            SlideBeep(500,1500,2);
  4828.            ResetMSClickCallProc(frame,
  4829.              MouseClickPos^.ClickNumber,SecondSong);
  4830.         END;
  4831.       FirstSong := 1;
  4832.    END;
  4833.  
  4834.   PushImage(1,1,100,100);
  4835.   ShadowBox(1,1,100,100);
  4836.   Putpict(StackPtr^.x+51,StackPtr^.y+81,@ImageOk,black);
  4837.   DefineMouseClickArea(StackPtr,50,80,50+35,80+12,
  4838.     true,FirstSong,MSClick);
  4839.  
  4840.  
  4841.  
  4842.  
  4843.  
  4844.  
  4845. ___________________________________________________________________________
  4846.  
  4847. ResetMouseClicks Procedure                                         TEGLUNIT
  4848. ___________________________________________________________________________
  4849.  
  4850.  
  4851. Function
  4852.                    Removes a chain of mouse click areas from a frame.
  4853. Declaration
  4854.                    ResetMouseClicks(Frame,ClickPtr:MSClickPtr)
  4855. Remarks
  4856.                    The ClickPtr parameter is the last click pointer from
  4857.                    where the remainder of the chain of click areas will be
  4858.                    removed.
  4859.  
  4860.                    A parameter of Nil removes the Mouse Click Area
  4861.                    chain completely.
  4862. Restrictions
  4863.                    The ClickPtr should be a valid Mouse Click Ptr. Use 
  4864.                    FindMouseClickPtr to locate a valid pointer.
  4865.  
  4866.                    If ClickPtr is invalid, the parameter will be treated
  4867.                    as Nil.
  4868. See also
  4869.                    DefineMouseClickPtr, FindMouseClickPtr,
  4870.                    ResetMSClickSense, ResetMSClickCallProc,
  4871.                    ResetMSClickActive, CheckMouseClickPos
  4872.  
  4873.  Programmer's Reference Guide       - 80 -         TEGL Windows Toolkit
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.                           Chapter 4 - Frames
  4880.  
  4881. Example
  4882.                    The following example displays a varying number of bars
  4883.                    that can be selected. The Event Handler 
  4884.                    ShowBarList plays a sound corresponding to the bar
  4885.                    selected and clears the frame and re-displays a new
  4886.                    series of bars.
  4887.  
  4888.  
  4889.  
  4890. Function ShowBarList(Frame:ImageStkPtr;
  4891.            MouseClickPos: MSClickPtr):WORD; FORWARD;
  4892.  
  4893. Procedure ShowVaryList(fs:ImageStkPtr; N:word);
  4894.    VAR y : word;
  4895.    BEGIN
  4896.       ResetMouseClicks(fs,nil);
  4897.       FOR y:=0 to n DO
  4898.         BEGIN
  4899.            ShadowBox(fs^.x+5,fs^.y+3+y*10,fs^.x1-8,fs^.y+3+10+y*10);
  4900.            DefineMouseClickArea(StackPtr,5,3+y*10,
  4901.              fs^.x1-fs^.x-10,3+y*10+6,true,ShowBarList,MSClick);
  4902.         END;
  4903.    END;
  4904.  
  4905. Function ShowBarList(Frame:ImageStkPtr;
  4906.            MouseClickPos: MSClickPtr):WORD;
  4907.    BEGIN
  4908.       ToggleOptionBar(Frame,MouseClickPos,nil);
  4909.       Beep(MouseClickPos^.clicknumber*30,10,100);
  4910.       HideMouse;
  4911.       ShadowBox(frame^.x,frame^.y,frame^.x1,frame^.y1);
  4912.       ShowVaryList(frame,random(10)+1);
  4913.       ShowMouse;
  4914.    END;
  4915.  
  4916.   PushImage(1,1,107,124);
  4917.   ShadowBox(1,1,107,124);
  4918.   ShowVaryList(StackPtr,random(10)+1);
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925. ___________________________________________________________________________
  4926.  
  4927. ResetMSClickSense Procedure                                        TEGLUNIT
  4928. ___________________________________________________________________________
  4929.  
  4930.  
  4931. Function
  4932.                    Resets the Sense parameter associated with a Mouse
  4933.  
  4934.  Programmer's Reference Guide       - 81 -         TEGL Windows Toolkit
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.                           Chapter 4 - Frames
  4941.  
  4942.                    Click Area.
  4943. Declaration
  4944.                    ResetMSClickSense(VAR ifs : ImageStkPtr; NewSense :
  4945.                      Boolean;)
  4946. Remarks
  4947.                    NewSense is either MSSense or MSClick. MSSense
  4948.                    activates the event handler whenever the mouse cursor
  4949.                    passes over the defined mouse click areas. MSClick
  4950.                    requires the right mouse button to be pressed while the
  4951.                    mouse cursor is on the mouse click area.
  4952. Restrictions
  4953.                    ResetMSClickSense resets the Sense type for the chain
  4954.                    of all Mouse Clicks. If you have a mixture of different
  4955.                    senses, use a combination of FindMouseClickPtr and
  4956.                    field settings to reset the sense.
  4957. See also
  4958.                    DefineMouseClickPtr, ResetMouseClicks,
  4959.                    FindMouseClickPtr, ResetMSClickCallProc,
  4960.                    ResetMSClickActive, CheckMouseClickPos
  4961. Example
  4962.                    The following example requires a menu selection to
  4963.                    toggle between the menu dropping down automatically or
  4964.                   requiring a mouse clickon the menu bar.
  4965.  
  4966.  
  4967.  
  4968. VAR  OM1         : OptionMptr;
  4969.      ToggleSense : boolean;
  4970.  
  4971. Function ToggleClickSense(Frame:ImageStkPtr;
  4972.            MouseClickPos: MsClickPtr) : word;
  4973.    VAR MenuBarFS   : ImageStkPtr;
  4974.    BEGIN
  4975.       MenubarFS := Frame^.RelatedStack;
  4976.  
  4977.       ToggleSense := NOT ToggleSense;
  4978.       ResetMSClickSense(MenubarFS,ToggleSense);
  4979.  
  4980.       ToggleClickSense := 1;
  4981.    END;
  4982.  
  4983.   OM1 := CreateOptionMenu(@FONT14);
  4984.   DefineOptions(OM1,'Toggle Click Sense',true,ToggleClickSense);
  4985.  
  4986.   FONTTABLE := @FONT14;
  4987.   CreateBarMenu(0,0,639);
  4988.     OutBarOption(' ToggleBar  ',OM1);
  4989.     OutBarOption(' ToggleTwo  ',OM1);
  4990.   ToggleSense := MSSense;
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  Programmer's Reference Guide       - 82 -         TEGL Windows Toolkit
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.                           Chapter 4 - Frames
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007. Keyboard
  5008.  
  5009.  
  5010. ___________________________________________________________________________
  5011.  
  5012. ClearKeyBoardBuf Procedure                                         TEGLUNIT
  5013. ___________________________________________________________________________
  5014.  
  5015.  
  5016.  
  5017. Function
  5018.                    Clears the hardware keyboard buffer.
  5019. Declaration
  5020.                    ClearKeyBoardBuf; 
  5021. See also
  5022.                    ClearTEGLKeyBoardBuf.
  5023.  
  5024.  
  5025.  
  5026.  
  5027. ___________________________________________________________________________
  5028.  
  5029. ClearTEGLKeyBoardBuf Procedure                                     TEGLUNIT
  5030. ___________________________________________________________________________
  5031.  
  5032.  
  5033.  
  5034. Function
  5035.                    Clears the software buffer maintained by the
  5036.                    Toolkit.
  5037. Declaration
  5038.                    ClearTEGLKeyBoardBuf; 
  5039. Remarks
  5040.                    This will discard all pending keystrokes.
  5041.  
  5042.  
  5043.  
  5044. ___________________________________________________________________________
  5045.  
  5046. DefineGlobalKeyClickArea Procedure                                 TEGLUNIT
  5047. ___________________________________________________________________________
  5048.  
  5049.  
  5050.  
  5051. Function
  5052.                    Flexible keycode assignment.
  5053. Declaration
  5054.                    DefineGlobalKeyClickArea(ifs : ImageStkPtr;
  5055.  
  5056.  Programmer's Reference Guide       - 83 -         TEGL Windows Toolkit
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.                           Chapter 4 - Frames
  5063.  
  5064.                      ms : MsClickPtr; KeyCode : Word; RepeatKey: Boolean;
  5065.                        p : CallProc); 
  5066. Remarks
  5067.                    ifs is the frame and ms is the mouse click
  5068.                    area the key is assigned to, these are passed to 
  5069.                    p.
  5070.  
  5071.                    If ifs and ms are set to nil then the frame
  5072.                    and mouse click area that the mouse pointer is over are
  5073.                    passed to p. If the mouse pointer is not over a
  5074.                    frame then Nil is passed to p.
  5075.  
  5076.                    If RepeatKey is set True then addition key presses
  5077.                    are buffered, otherwise, they are discarded.
  5078.  
  5079.                    A special case for this routine is passing 0 as the
  5080.                    keycode parameter. In this case any key that is not
  5081.                    being trapped for will activate p. The key pressed
  5082.                    can be determined by using ReadKey.
  5083. Restrictions
  5084.                    Only the most recently declared key is trapped if a key
  5085.                    is trapped more than once.
  5086. See also
  5087.                    DefineLocalKeyClickArea.
  5088.  
  5089.  
  5090.  
  5091. ___________________________________________________________________________
  5092.  
  5093. DefineLocalKeyClickArea Procedure                                  TEGLUNIT
  5094. ___________________________________________________________________________
  5095.  
  5096.  
  5097.  
  5098. Function
  5099.                    Assign a keycode to a frame and mouse click area.
  5100. Declaration
  5101.                    DefineLocalKeyClickArea(fs : ImageStkPtr;
  5102.                      ms : MsClickPtr; KeyCode : Word; RepeatKey: Boolean:
  5103.                        p : CallProc);  
  5104. Remarks
  5105.                    ifs is the frame and ms is the mouse click
  5106.                    area the key is assigned to, these are passed to p.
  5107.  
  5108.                    If RepeatKey is set TRUE then addition key presses
  5109.                    are buffered otherwise they are discarded.
  5110.  
  5111.                    Within a frame DefineLocalKeyClickArea has
  5112.                    prioritry over DefineGlobalKeyClickArea.
  5113. See also
  5114.                    DefineGlobalKeyClickArea.
  5115.  
  5116.  
  5117.  Programmer's Reference Guide       - 84 -         TEGL Windows Toolkit
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.                           Chapter 4 - Frames
  5124.  
  5125.  
  5126.  
  5127. ___________________________________________________________________________
  5128.  
  5129. DropKeyClick Procedure                                             TEGLUNIT
  5130. ___________________________________________________________________________
  5131.  
  5132.  
  5133.  
  5134. Function
  5135.                    Removes a key trap.
  5136. Declaration
  5137.                    DropKeyClick(ifs : ImageStkPtr; KeyCode: Word;
  5138.                      p : CallProc): 
  5139. Remarks
  5140.                    If ifs is not Nil then the frame's local key
  5141.                    stack is searched first. If the key is not found then
  5142.                    the search proceeds to the global key stack.
  5143.  
  5144.                    p must match the CallProc that the key was
  5145.                    originally assigned to.
  5146.  
  5147.  
  5148.  
  5149. ___________________________________________________________________________
  5150.  
  5151. FindKeyClickPtr Function                                           TEGLUNIT
  5152. ___________________________________________________________________________
  5153.  
  5154.  
  5155.  
  5156. Function
  5157.                    Locates a key assignment.
  5158. Declaration
  5159.                    FindKeyClickPtr(ifs : ImageStkPtr; Keycode: Word) :
  5160.                      KeyClickPtr;
  5161. Remarks
  5162.                    If ifs is not Nil then the frame's local key stack
  5163.                    is searched first. If the key is not found then the
  5164.                    search proceeds to the global key stack 
  5165.                    KeyStackPtr.
  5166.  
  5167.                    If the KeyCode is not found then NIL is returned.
  5168.  
  5169.  
  5170.  
  5171. ___________________________________________________________________________
  5172.  
  5173. ResetKeyClickCallProc Procedure                                    TEGLUNIT
  5174. ___________________________________________________________________________
  5175.  
  5176.  
  5177.  
  5178.  Programmer's Reference Guide       - 85 -         TEGL Windows Toolkit
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.                           Chapter 4 - Frames
  5185.  
  5186.  
  5187. Function
  5188.                    Changes the CallProc a key is assigned to.
  5189. Declaration
  5190.                    ResetKeyClickCallProc(ifs : ImageStkPtr; Keycode: Word;
  5191.                      p : CallProc); 
  5192. Remarks
  5193.                    If ifs is not NIL then the frame's local key stack
  5194.                    is searched first. If the key is not found then the
  5195.                    search proceeds to the global key stack 
  5196.                    KeyStackPtr.
  5197.  
  5198.                    If KeyCode is not found then no action is taken.
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  Programmer's Reference Guide       - 86 -         TEGL Windows Toolkit
  5240.  
  5241.  
  5242.  
  5243.  
  5244.  
  5245.                           Chapter 5 - Menus
  5246.  
  5247.  
  5248. Drop Down, Pop Up Menus
  5249. ___________________________________________________________________________
  5250.  
  5251. The Menu unit is good example of an event library that you can add to the
  5252. power of TEGL Windows. The generic pull-down or drop-down menus provides a
  5253. wide range of menu architecture that will meet most application needs.
  5254.  
  5255. A Menu event uses the standard OutTEGLTextXY and DefineMouseClickArea
  5256. procedures to list and to create additional mouse click areas on the
  5257. screen.
  5258.  
  5259. Even though the menu unit is comprehensive, TEGL Windows is not limited to
  5260. a standard architecture of menus. The menu unit may be used as an example
  5261. in creating other types of menu events; such as hanging menus which are
  5262. not dependent on a bar type selection; or an icon menu, that when clicked
  5263. on explodes to display a box full of icons that can be selected from.
  5264.  
  5265. The entries for the menu unit are created and linked at run-time. The
  5266. entries may be manipulated, copied, or deleted as required within the
  5267. program. In comparison, some systems offer a external menu compiler which
  5268. links the menu with the program at compile time. The advantages to an
  5269. external menu compiler are minimal, and it adds another step in creating a
  5270. menu system.
  5271.  
  5272. The advantages to creating dynamic menus at run-time, is the ability to
  5273. create a menu system that is based on an external text file (ie.  the menu
  5274. text selections may be stored in a text file and read in at run-time to
  5275. create a menu).
  5276.  
  5277. Creating a Menu
  5278.  
  5279. Creating a bar menu is a two step process. The first is to create the
  5280. entry text list that is associated with a option menu. The second is the
  5281. creation of the menu bar from which option menus may be selected. You may
  5282. use the first step by itself to attach an Option Entry list to icon,
  5283. instead of a bar.
  5284.  
  5285.  
  5286. Creating a entry text list
  5287.  
  5288. An entry text list is simply an linked chain of text entries, with a root
  5289. entry for each text list.
  5290.  
  5291.  
  5292. +-----------+      +-----------+--+       +-----------+--+
  5293. |AnchorOMPtr|----->|OptionMenu |01|------>|OptionMenu |02|----->nil
  5294. +-----------+      +-----+-----+--+       +-----+-----+--+
  5295.                          *                      *
  5296.                    +-----------+--+       +-----------+--+
  5297.                    |OptionEntry|01|       |OptionEntry|01|
  5298.                    +-----+-----+--+       +-----+-----+--+
  5299.  
  5300.  Programmer's Reference Guide       - 87 -         TEGL Windows Toolkit
  5301.  
  5302.  
  5303.  
  5304.  
  5305.  
  5306.                           Chapter 5 - Menus
  5307.  
  5308.                          *                      *
  5309.                    +-----------+--+       +-----------+--+
  5310.                    |OptionEntry|02|       |OptionEntry|02|
  5311.                    +-----+-----+--+       +-----+-----+--+
  5312.                          *                      *
  5313.                    +-----------+--+            nil
  5314.                    |OptionEntry|03|
  5315.                    +-----+-----+--+
  5316.                          *
  5317.                         nil
  5318.  
  5319.         +--------------------------------------------------+
  5320.         |  OptionMenu  = record                            |
  5321.         |                   NextOM         : OptionMPtr;+  |
  5322.         |                   numofentries   : word;      |  |
  5323. ------->|                   maxwidth       : word;      +--|----------->
  5324.         |                   padding        : word;         |
  5325.         |                   fonttype       : pointer;      |
  5326.         |            +----- FirstEntry     : OptionEPtr;   |
  5327.         |            |      CurrentEntry   : OptionEPtr;   |
  5328.         |            |   end;                              |
  5329.         |            +------------+                        |
  5330.         +-------------------------|------------------------+
  5331.                                   *
  5332.         +-----------------------------------------------+--+
  5333.         |  OptionEntry = record                         |01|
  5334.         |            +----- NextOE         : OptionEPtr;+--|
  5335.         |            |      entryline      : string[40];   |
  5336.         |            |      entryactive    : boolean;      |
  5337.         |            |      entrycolor     : integer;      |
  5338.         |            |      entrycallproc  : callproc;     |
  5339.         |            |   end;                              |
  5340.         |            +------------+                        |
  5341.         +-------------------------|------------------------+
  5342.                                   *
  5343.  
  5344. OM is a short form for an OptionMenu record. This is the header
  5345. or the root entry for an entry list. The header contains information
  5346. regarding the number of entries, the maximum width of the entries, the
  5347. amount of padding on left and right when displayed and the font type that
  5348. is used. By duplicating the header with a different set of parameters, an
  5349. Option Entry list may be chained to two or more headers to allow for
  5350. different fonts.
  5351.  
  5352.                    +-----------+      +-----------+
  5353.               ---->|OptionMenu |----->|OptionMenu |--->
  5354.                    +-----+-----+      +-----+-----+
  5355.                          |                  |
  5356.                          |------------------+
  5357.                          |
  5358.                          *
  5359.                    +-----------+
  5360.  
  5361.  Programmer's Reference Guide       - 88 -         TEGL Windows Toolkit
  5362.  
  5363.  
  5364.  
  5365.  
  5366.  
  5367.                           Chapter 5 - Menus
  5368.  
  5369.                    |OptionEntry|
  5370.                    +-----+-----+
  5371.                          *
  5372.  
  5373. OE is a short form for an OptionEntry record. There is no limit
  5374. to the number of OE records that a list can contain, with the
  5375. exception that the number of entries cannot be greater than the size of
  5376. the screen when the OE list is displayed. This is a limitation of the
  5377. ListOptionMenu procedure within the Menu unit and the screen vertical
  5378. size, rather then a maximum entry limitation. The ListOptionMenu
  5379. event could be modified to accommodate lists greater then the screen size
  5380. by displaying a portion of a list and adding another event to display the
  5381. remainder.
  5382.  
  5383. The OE record contains the entry (text) line, as well as information
  5384. on whether the entry line is active or inactive (place holder), its color,
  5385. and the event that is called when it is selected.
  5386.  
  5387.  
  5388.  
  5389. ___________________________________________________________________________
  5390.  
  5391. CreateOptionMenu Function                                          TEGLMENU
  5392. ___________________________________________________________________________
  5393.  
  5394.  
  5395. Function
  5396.                    Creates an Option Menu header.
  5397. Declaration
  5398.                    CreateOptionMenu(Fonttype:pointer): OptionMPtr;
  5399. Result type
  5400.                    Returns an Option Menu pointer type.
  5401. Remarks
  5402.                    Fonttype is one of the fonts in the font library.
  5403.  
  5404.                    The option menu header is used to build and reference
  5405.                    the Option Entry list. Use this OM pointer
  5406.                    when calling the procedure DefineOptions.
  5407. Restrictions
  5408.                    To create multiple OM headers with different fonts
  5409.                    on a single OE list, use CreateShadowOM to
  5410.                    automatically create and link the OE list to a
  5411.                    new OM header.
  5412. See also
  5413.                    DefineOptions, CreateShadowOM
  5414. Example
  5415.  
  5416.  
  5417.  
  5418. var OM1, OM2 : optionmptr;
  5419.  
  5420.   OM1 := CreateOptionMenu(@font14);
  5421.  
  5422.  Programmer's Reference Guide       - 89 -         TEGL Windows Toolkit
  5423.  
  5424.  
  5425.  
  5426.  
  5427.  
  5428.                           Chapter 5 - Menus
  5429.  
  5430.  
  5431.   OM2 := CreateOptionMenu(@script);
  5432.  
  5433.  
  5434.  
  5435.  
  5436.  
  5437.  
  5438.  
  5439. ___________________________________________________________________________
  5440.  
  5441. DefineOptions Procedure                                            TEGLMENU
  5442. ___________________________________________________________________________
  5443.  
  5444.  
  5445. Function
  5446.                    Adds Option Entries to an Option Menu.
  5447. Declaration
  5448.                    DefineOptions(var OM; EntryStr:string; Active: boolean;
  5449.                      p : callproc); 
  5450. Remarks
  5451.                    The OM pointer must be defined by 
  5452.                    CreateOptionMenu before Option Entries may be
  5453.                    added.
  5454.  
  5455.                    EntryStr is the text string to be displayed when
  5456.                    the Option menu is opened. The EntryStr has two
  5457.                    types of control character which may be embedded as
  5458.                    part of the string. The q - is used to display a
  5459.                    dotted separator line between options. To underline a
  5460.                    character or a series of characters, add the value of
  5461.                    128 to the ascii value. The underline character is only
  5462.                    valid for characters that do not have descenders.
  5463.  
  5464.                    Active specifies whether this entry is active (can
  5465.                    be selected) or not active. Inactive entries are
  5466.                    displayed as jagged characters.
  5467.  
  5468.                    p defines the Event that is associated with
  5469.                    this menu entry. The p is attached automatically
  5470.                    to the option entry when the option menu is displayed.
  5471.  
  5472. Restrictions
  5473.                    There are no limitations on the number of entries that
  5474.                    can be defined under a single OM header. However,
  5475.                    too many entries will list past the bottom of the screen.
  5476. See also
  5477.                    CreateOptionMenu, CreateShadowOM, UnderLineChar
  5478.  
  5479. Example
  5480.  
  5481.  
  5482.  
  5483.  Programmer's Reference Guide       - 90 -         TEGL Windows Toolkit
  5484.  
  5485.  
  5486.  
  5487.  
  5488.  
  5489.                           Chapter 5 - Menus
  5490.  
  5491.  
  5492. var OM1 : optionmptr;
  5493.  
  5494. OM1 := CreateOptionMenu(@font14);
  5495. DefineOptions(OM1,'DeskTop Info...',true,InfoOption);
  5496. DefineOptions(OM1,'--',false,nilunitproc);
  5497. DefineOptions(OM1,'Calculator',true,nilunitproc);
  5498. DefineOptions(OM1,'Clock',true,nilunitproc);
  5499. DefineOptions(OM1,'Snapshot',true,nilunitproc);
  5500.  
  5501.  
  5502.  
  5503.  
  5504.  
  5505.  
  5506.  
  5507. ___________________________________________________________________________
  5508.  
  5509. CreateShadowOM Function                                            TEGLMENU
  5510. ___________________________________________________________________________
  5511.  
  5512.  
  5513. Function
  5514.                    Creates a duplicate Option Menu Header with a different
  5515.                    Font type.
  5516. Declaration
  5517.                    CreateShadowOM(OM:OptionMPtr; Fonttype:pointer) :
  5518.                      OptionMPtr;
  5519.  
  5520. Result type
  5521.                    Returns an new Option Menu pointer type.
  5522. Remarks
  5523.                    OM must be an existing OptionMenu pointer.
  5524.                    Fonttype is one of the fonts in the font library.
  5525. Restrictions
  5526.                    The original OM pointer must be defined by 
  5527.                    CreateOptionMenu before a duplicate Option Menu
  5528.                    header may be created.
  5529. See also
  5530.                    CreateOptionMenu, ResizeOptionMenu
  5531. Example
  5532.  
  5533.  
  5534.  
  5535. var OM1,OM2 : optionmptr;
  5536.  
  5537. OM1 := CreateOptionMenu(@font14);
  5538. DefineOptions(OM1,'DeskTop Info...',true,InfoOption);
  5539. DefineOptions(OM1,'--',false,nilunitproc);
  5540. DefineOptions(OM1,'Calculator',true,nilunitproc);
  5541. DefineOptions(OM1,'Clock',true,nilunitproc);
  5542. DefineOptions(OM1,'Snapshot',true,nilunitproc);
  5543.  
  5544.  Programmer's Reference Guide       - 91 -         TEGL Windows Toolkit
  5545.  
  5546.  
  5547.  
  5548.  
  5549.  
  5550.                           Chapter 5 - Menus
  5551.  
  5552.  
  5553.  
  5554. OM2 := CreateShadowOM(OM1,@Script);
  5555.  
  5556.  
  5557.  
  5558.  
  5559.  
  5560.  
  5561.  
  5562. ___________________________________________________________________________
  5563.  
  5564. ResizeOptionMenu Procedure                                         TEGLMENU
  5565. ___________________________________________________________________________
  5566.  
  5567.  
  5568. Function
  5569.                    Allows an Option Menu header to recalculate the
  5570.                    size of the option menu window when changing the font
  5571.                    type.
  5572. Declaration
  5573.                    ResizeOptionMenu(OM:OptionMPtr; Fonttype:
  5574.                    pointer)
  5575. Remarks
  5576.                    OM must be an existing OptionMenu pointer.
  5577.                    Fonttype is one of the fonts in the font library.
  5578. See also
  5579.                    CreateOptionMenu, CreateShadowOM
  5580. Example
  5581.  
  5582.  
  5583.  
  5584. var OM1 : optionmptr;
  5585.  
  5586. OM1 := CreateOptionMenu(@font14);
  5587. DefineOptions(OM1,'DeskTop Info...',true,InfoOption);
  5588. DefineOptions(OM1,'--',false,nilunitproc);
  5589. DefineOptions(OM1,'Calculator',true,nilunitproc);
  5590. DefineOptions(OM1,'Clock',true,nilunitproc);
  5591. DefineOptions(OM1,'Icon Display',true,Icons);
  5592.  
  5593. ResizeOptionMenu(OM1,@Script);
  5594. { -- Changes the font type @Font14 to @Script}
  5595.  
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601.  
  5602. ___________________________________________________________________________
  5603.  
  5604.  
  5605.  Programmer's Reference Guide       - 92 -         TEGL Windows Toolkit
  5606.  
  5607.  
  5608.  
  5609.  
  5610.  
  5611.                           Chapter 5 - Menus
  5612.  
  5613. ToggleCheckMark Procedure                                          TEGLMENU
  5614. ___________________________________________________________________________
  5615.  
  5616.  
  5617. Function
  5618.                    Changes the first character of an entry string to 0x30
  5619.                    (check mark) or a 0x32 (space).
  5620. Declaration
  5621.                    ToggleCheckMark(OMNum,OENum : word; status:boolean);
  5622. Remarks
  5623.                    OMNum is the position of the Option Menu header
  5624.                    relative to the AnchorOMPtr. OENum is the
  5625.                    position of the Option Entry relative to the OM
  5626.                    header.
  5627.  
  5628.                    Status of True will change the first character
  5629.                    of the entry to a checkmark, False will change the
  5630.                    character to a space.
  5631. See also
  5632.                    ToggleEntryStatus, ReplaceOptionText
  5633. Example
  5634.  
  5635.  
  5636.  
  5637. var OM1 : optionmptr;
  5638.  
  5639. OM1 := CreateOptionMenu(@font14);
  5640. DefineOptions(OM1,'  Show as Icons ',true,ViewOptionToggle);
  5641. DefineOptions(OM1,'  Show as Text  ',true,ViewOptionToggle);
  5642. DefineOptions(OM1,'-',false,nilunitproc);
  5643. DefineOptions(OM1,'  Sort by Name  ',true,ViewOptionToggle);
  5644. DefineOptions(OM1,'  Sort by Date  ',true,ViewOptionToggle);
  5645. DefineOptions(OM1,'  Sort by Size  ',true,ViewOptionToggle);
  5646. DefineOptions(OM1,'  Sort by Type  ',true,ViewOptionToggle);
  5647.  
  5648. ToggleCheckMark(1,7,TRUE);
  5649. {puts a check mark at the front of Sort by Type}
  5650.  
  5651.  
  5652.  
  5653.  
  5654.  
  5655.  
  5656.  
  5657. ___________________________________________________________________________
  5658.  
  5659. ToggleEntryStatus Procedure                                        TEGLMENU
  5660. ___________________________________________________________________________
  5661.  
  5662.  
  5663. Function
  5664.                    Sets an Option entry to active or not active.
  5665.  
  5666.  Programmer's Reference Guide       - 93 -         TEGL Windows Toolkit
  5667.  
  5668.  
  5669.  
  5670.  
  5671.  
  5672.                           Chapter 5 - Menus
  5673.  
  5674. Declaration
  5675.                    ToggleEntryStatus(OMNum,OENum:word; status:
  5676.                    boolean)
  5677. Remarks
  5678.                    OMNum is the position of the Option Menu header
  5679.                    relative to the AnchorOMPtr.
  5680.  
  5681.                    OENum is the position of the Option Entry relative
  5682.                    to the OM header.
  5683.  
  5684.                    Status of True will set the entry as active,
  5685.                    False will set the entry to nonactive. Active
  5686.                    specifies whether this entry is active (can be
  5687.                    selected) or nonactive. Nonactive entries are displayed
  5688.                    as jagged characters.
  5689.  
  5690. See also
  5691.                    ToggleCheckMark, ReplaceOptionText
  5692. Example
  5693.  
  5694.  
  5695.  
  5696. var OM1 : optionmptr;
  5697.  
  5698. OM1 := CreateOptionMenu(@font14);
  5699. DefineOptions(OM1,'DeskTop Info...',true,InfoOption);
  5700. DefineOptions(OM1,'--',false,nilunitproc);
  5701. DefineOptions(OM1,'Calculator',true,nilunitproc);
  5702. DefineOptions(OM1,'Clock',true,nilunitproc);
  5703. DefineOptions(OM1,'Snapshot',true,Snapshot);
  5704.  
  5705. ToggleEntryStatus(1,5,FALSE); {toggles Snapshot off}
  5706.  
  5707.  
  5708.  
  5709.  
  5710.  
  5711.  
  5712.  
  5713. ___________________________________________________________________________
  5714.  
  5715. ReplaceOptionText Procedure                                        TEGLMENU
  5716. ___________________________________________________________________________
  5717.  
  5718.  
  5719. Function
  5720.                    Replaces Option entry string by another text string.
  5721. Declaration
  5722.                    ReplaceOptionText(OMNum,OENum : word; EntryStr:
  5723.                    string)
  5724. Remarks
  5725.                    OMNum is the position of the Option Menu header
  5726.  
  5727.  Programmer's Reference Guide       - 94 -         TEGL Windows Toolkit
  5728.  
  5729.  
  5730.  
  5731.  
  5732.  
  5733.                           Chapter 5 - Menus
  5734.  
  5735.                    relative to the AnchorOMPtr.
  5736.  
  5737.                    OENum is the position of the Option Entry relative
  5738.                    to the OM header.
  5739.  
  5740.                    EntryStr is a replacement text string that will be
  5741.                    displayed when the Option menu is opened. The 
  5742.                    EntryStr has two types of control character which may
  5743.                    be embedded as part of the string. The q - is used to
  5744.                    display a dotted separator line between options. To
  5745.                    underline a character or a series of characters, add
  5746.                    the value of 128 to the ascii value. The underline
  5747.                    character only works with characters that do not have
  5748.                    descenders.
  5749.  
  5750. See also
  5751.                    ToggleCheckMark, ToggleEntryStatus
  5752. Example
  5753.  
  5754.  
  5755.  
  5756. VAR OM1 : optionmptr;
  5757.  
  5758.   OM1 := CreateOptionMenu(@font14);
  5759.   DefineOptions(OM1,'DeskTop Info...',true,InfoOption);
  5760.   DefineOptions(OM1,'--',false,nilunitproc);
  5761.   DefineOptions(OM1,'Calculator',true,nilunitproc);
  5762.   DefineOptions(OM1,'Clock',true,nilunitproc);
  5763.   DefineOptions(OM1,'Icon Display',true,Icons);
  5764.  
  5765.   { -- Replaces "Icon Display" with "Text Display"}
  5766.   ReplaceOptionText(1,5,"Text Display");
  5767.  
  5768.  
  5769.  
  5770.  
  5771.  
  5772.  
  5773. ___________________________________________________________________________
  5774.  
  5775. ToggleOptionBar Procedure                                          TEGLUNIT
  5776. ___________________________________________________________________________
  5777.  
  5778.  
  5779. Function
  5780.                    Inverts mouse click areas.
  5781. Declaration
  5782.                    ToggleOptionBar(ifs : ImageStkPtr;
  5783.                      Opt,LastOpt: MsClickPtr);
  5784. Remarks
  5785.                    Opt and LastOpt mouse click areas are
  5786.                    inverted. It is assumed that LastOpt has
  5787.  
  5788.  Programmer's Reference Guide       - 95 -         TEGL Windows Toolkit
  5789.  
  5790.  
  5791.  
  5792.  
  5793.  
  5794.                           Chapter 5 - Menus
  5795.  
  5796.                    already been inverted and this call would return
  5797.                    it to normal.
  5798.  
  5799.  
  5800.  
  5801.  
  5802. ___________________________________________________________________________
  5803.  
  5804. SetOptionMenuColors Procedure                                      TEGLMENU
  5805. ___________________________________________________________________________
  5806.  
  5807.  
  5808. Function
  5809.                    Changes the menu entry colors.
  5810. Declaration
  5811.                    SetOptionMenuColors(activecolor,inactivecolor:word);
  5812. Remarks
  5813.                    activecolor is the text color for active entries.
  5814.  
  5815.                    inactivecolor is the text color for entries that
  5816.                    are currently inactive but have entry positions within
  5817.                    the menu.
  5818. See also
  5819.                    SetOptionMenuBorderColor
  5820. Example
  5821.  
  5822.  
  5823.   SetOptionMenuColors(Black,LightGray);
  5824.  
  5825.  
  5826.  
  5827.  
  5828.  
  5829. ___________________________________________________________________________
  5830.  
  5831. SetOptionMenuBorderColor Procedure                                 TEGLMENU
  5832. ___________________________________________________________________________
  5833.  
  5834.  
  5835. Function
  5836.                    Changes the color of the option menu border.
  5837. Declaration
  5838.                    SetOptionMenuBorderColors(color:word)
  5839. Remarks
  5840.                    color is the color of the border.
  5841. See also
  5842.                    SetOptionMenuColors
  5843. Example
  5844.  
  5845.  
  5846.   SetOptionMenuBorderColor(white);
  5847.  
  5848.  
  5849.  Programmer's Reference Guide       - 96 -         TEGL Windows Toolkit
  5850.  
  5851.  
  5852.  
  5853.  
  5854.  
  5855.                           Chapter 5 - Menus
  5856.  
  5857.  
  5858.  
  5859.  
  5860.  
  5861. ___________________________________________________________________________
  5862.  
  5863. SetHideSubMenu Procedure                                           TEGLMENU
  5864. ___________________________________________________________________________
  5865.  
  5866.  
  5867.  
  5868. Function
  5869.                    Toggles the hiding of sub menus.
  5870. Declaration
  5871.                    SetHideSubMenu(OnOff : Boolean);
  5872. Remarks
  5873.                    Default is true. When a submenu is pulled down from a
  5874.                    bar menu it is normally hidden when a selection is
  5875.                    made. If set to false then the pulldown is left
  5876.                    displayed until the selection that was made returns.
  5877. Example
  5878.  
  5879.  
  5880.   SetHideSubMenu(True);
  5881.  
  5882.  
  5883.  
  5884.  
  5885.  
  5886. Creating a Bar Menu
  5887.  
  5888. A bar menu is one of the more popular methods of creating a user interface.
  5889. As mentioned before, a bar menu is simply another event with the event
  5890. handler set to BarOptionMenu. BarOptionMenu is activated
  5891. whenever the mouse cursor passes by the one of the defined mouse click
  5892. areas on the bar.
  5893.  
  5894. When BarOptionMenu is activated, OptionMenuSelection is called
  5895. in place of the TEGLSupervisor.
  5896.  
  5897. There are three activities within a menu system that require a rewrite of
  5898. the TEGLSupervisor. OptionMenuSelection checks if
  5899.  
  5900.  
  5901.      The mouse is clicked outside the menu bar or menu window thus closing
  5902.      any active menus and returning back to the TEGL supervisor.
  5903.  
  5904.      Sensing the mouse cursor movement to another bar entry, thus closing
  5905.      any active menu and opening another menu window.
  5906.  
  5907.      Sensing the mouse cursor moving to another entry within a menu and
  5908.      highlighting the entry.
  5909.  
  5910.  Programmer's Reference Guide       - 97 -         TEGL Windows Toolkit
  5911.  
  5912.  
  5913.  
  5914.  
  5915.  
  5916.                           Chapter 5 - Menus
  5917.  
  5918.  
  5919.  
  5920.  
  5921. ___________________________________________________________________________
  5922.  
  5923. CreateBarMenu Procedure                                            TEGLMENU
  5924. ___________________________________________________________________________
  5925.  
  5926.  
  5927. Function
  5928.                    Creates a Bar window frame.
  5929. Declaration
  5930.                    CreateBarMenu(x,y,ln:word)
  5931. Remarks
  5932.                    x, y is the position of the bar menu frame.
  5933.  
  5934.                    ln is the pixel length of the bar.
  5935. See also
  5936.                    OutBarOption
  5937. Example
  5938.  
  5939.  
  5940.   CreateBarMenu(0,0,GetMaxX);
  5941.  
  5942.  
  5943.  
  5944.  
  5945.  
  5946.  
  5947. ___________________________________________________________________________
  5948.  
  5949. OutBarOption Procedure                                             TEGLMENU
  5950. ___________________________________________________________________________
  5951.  
  5952.  
  5953. Function
  5954.                    Attaches an option menu (list) to a displayed text
  5955.                    string on the BAR.
  5956. Declaration
  5957.                    OutBarOption(EntryStr:string; OM:OptionMptr)
  5958. Remarks
  5959.                    EntryStr is the bar text header that is associated
  5960.                    with the OM list.
  5961.  
  5962.                    OM is the Option Menu header returned from
  5963.                    CreateOptionMenu.
  5964. See also
  5965.                    CreateBarMenu
  5966. Example
  5967.  
  5968.  
  5969.  
  5970.  
  5971.  Programmer's Reference Guide       - 98 -         TEGL Windows Toolkit
  5972.  
  5973.  
  5974.  
  5975.  
  5976.  
  5977.                           Chapter 5 - Menus
  5978.  
  5979. VAR OM1 : optionmptr;
  5980.  
  5981.   OM1 := CreateOptionMenu(@font14);
  5982.   DefineOptions(OM1,'  Show as Icons ',true,ViewOptionToggle);
  5983.   DefineOptions(OM1,'  Show as Text  ',true,ViewOptionToggle);
  5984.   DefineOptions(OM1,'-',false,nilunitproc);
  5985.   DefineOptions(OM1,'  Sort by Name  ',true,ViewOptionToggle);
  5986.   DefineOptions(OM1,'  Sort by Date  ',true,ViewOptionToggle);
  5987.   DefineOptions(OM1,'  Sort by Size  ',true,ViewOptionToggle);
  5988.   DefineOptions(OM1,'  Sort by Type  ',true,ViewOptionToggle);
  5989.  
  5990.   CreateBarMenu(0,0,639);
  5991.   OutBarOption(' Options ',OM1);
  5992.  
  5993.  
  5994.  
  5995.  
  5996.  
  5997. ___________________________________________________________________________
  5998.  
  5999. SetBarTextColor Procedure                                          TEGLMENU
  6000. ___________________________________________________________________________
  6001.  
  6002.  
  6003. Function
  6004.                    Changes the default text color on the bar.
  6005. Declaration
  6006.                    SetBarTextColor(color:word)
  6007. Remarks
  6008.                    color is the default text color on the bar.
  6009. See also
  6010.                    SetBarMenuColor, SetBarBorderColor
  6011. Example
  6012.  
  6013.  
  6014.   SetBarTextColor(green);
  6015.  
  6016.  
  6017.  
  6018.  
  6019.  
  6020. ___________________________________________________________________________
  6021.  
  6022. SetBarMenuColor Procedure                                          TEGLMENU
  6023. ___________________________________________________________________________
  6024.  
  6025.  
  6026. Function
  6027.                    Changes the bar color.
  6028. Declaration
  6029.                    SetBarMenuColor(color:word)
  6030. Remarks
  6031.  
  6032.  Programmer's Reference Guide       - 99 -         TEGL Windows Toolkit
  6033.  
  6034.  
  6035.  
  6036.  
  6037.  
  6038.                           Chapter 5 - Menus
  6039.  
  6040.                    color is the default color for the bar.
  6041. See also
  6042.                    SetBarMenuColor, SetBarBorderColor
  6043. Example
  6044.  
  6045.  
  6046.   SetBarMenuColor(blue);
  6047.  
  6048.  
  6049.  
  6050.  
  6051.  
  6052. ___________________________________________________________________________
  6053.  
  6054. SetBarBorderColor Procedure                                        TEGLMENU
  6055. ___________________________________________________________________________
  6056.  
  6057.  
  6058. Function
  6059.                    Changes the bar border color and toggles the border on.
  6060.  
  6061. Declaration
  6062.                    SetBarBorderColor(color:word)
  6063. Remarks
  6064.                    color is the default border color for the bar.
  6065. See also
  6066.                    SetBarTextColor, SetBarBorderOff
  6067. Example
  6068.  
  6069.  
  6070.   SetBarBorderColor(green);
  6071.  
  6072.  
  6073.  
  6074.  
  6075.  
  6076. ___________________________________________________________________________
  6077.  
  6078. SetBarBorderOff Procedure                                          TEGLMENU
  6079. ___________________________________________________________________________
  6080.  
  6081.  
  6082. Function
  6083.                    Toggles the bar border off.
  6084. Declaration
  6085.                    SetBarBorderOff
  6086. Remarks
  6087.                    SetBarBorderColor resets the border on.
  6088. See also
  6089.                    SetBarBorderColor, SetBarTextColor
  6090. Example
  6091.  
  6092.  
  6093.  Programmer's Reference Guide       - 100 -         TEGL Windows Toolkit
  6094.  
  6095.  
  6096.  
  6097.  
  6098.  
  6099.                           Chapter 5 - Menus
  6100.  
  6101.  
  6102.   SetBarBorderOff;
  6103.  
  6104.  
  6105.  
  6106.  
  6107.  
  6108. ___________________________________________________________________________
  6109.  
  6110. SetBarShadowtext Procedure                                         TEGLMENU
  6111. ___________________________________________________________________________
  6112.  
  6113.  
  6114. Function
  6115.                    Toggles Bar Shadow Text on/off.
  6116. Declaration
  6117.                    SetBarShadowtext(OnOff:boolean)
  6118. Remarks
  6119.                    OnOff is a boolean type, where TRUE is on and
  6120.                    FALSE is off.
  6121. Example
  6122.  
  6123.  
  6124.   SetBarShadowText(True);
  6125.  
  6126.  
  6127.  
  6128.  
  6129.  
  6130. ___________________________________________________________________________
  6131.  
  6132. SetBarFillStyle Procedure                                          TEGLMENU
  6133. ___________________________________________________________________________
  6134.  
  6135.  
  6136. Function
  6137.                    Sets the Bar Fill Style.
  6138. Declaration
  6139.                    SetBarFillStyle(pattern:word)
  6140. Remarks
  6141.                    Sets the pattern for the bar. The fill patterns are
  6142.                    defined by constants in the Graph unit.
  6143.  
  6144.                    Pattern is a numeric type.
  6145. See also
  6146.                    SetFillStyle (Graph Unit).
  6147. Example
  6148.  
  6149.  
  6150.   SetBarFillStyle(BkSlashFill);
  6151.  
  6152.  
  6153.  
  6154.  Programmer's Reference Guide       - 101 -         TEGL Windows Toolkit
  6155.  
  6156.  
  6157.  
  6158.  
  6159.  
  6160.                           Chapter 5 - Menus
  6161.  
  6162.  
  6163.  
  6164.  
  6165. ___________________________________________________________________________
  6166.  
  6167. SetBarMenuMargin Procedure                                         TEGLMENU
  6168. ___________________________________________________________________________
  6169.  
  6170.  
  6171.  
  6172. Function
  6173.                    Sets the left margin on the barmenu.
  6174. Declaration
  6175.                    SetBarMenuMargin(Margin: Word);
  6176. Remarks
  6177.                    Margin is the desired left margin where the menu
  6178.                    selections start at. This value is in pixels and the
  6179.                    default is 16.
  6180.  
  6181.                    Can be used if a icon or some symbol should be displayed
  6182.                    at the extreme left of the menu.
  6183. Example
  6184.  
  6185.  
  6186.   SetBarMenuMargin(32);
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  
  6192. Icon Option Menus
  6193.  
  6194. Optionally you can attach a menu to an icon or an area of a frame.
  6195.  
  6196. The following procedure adds a drop down menu to any frame area.
  6197.  
  6198.  
  6199. ___________________________________________________________________________
  6200.  
  6201. DefineOptionClickArea Procedure                                    TEGLMENU
  6202. ___________________________________________________________________________
  6203.  
  6204.  
  6205. Function
  6206.                    Attaches an option menu (list) to a frame or icon area.
  6207. Declaration
  6208.                    DefineOptionClickArea(var ifs; x,y,x1,y1:word; OM:OptionMPtr;
  6209.                      Sense:boolean; OMType:byte)
  6210. Remarks
  6211.                    ifs is any ImageStkPtr.  The x, y, x1, y1 are
  6212.                    coordinates relative to a frame.  This means that the
  6213.                    upper left corner of a frame is considered 0,0.
  6214.  
  6215.  Programmer's Reference Guide       - 102 -         TEGL Windows Toolkit
  6216.  
  6217.  
  6218.  
  6219.  
  6220.  
  6221.                           Chapter 5 - Menus
  6222.  
  6223.  
  6224.                    OM is the Option Menu header returned from
  6225.                    CreateOptionMenu.
  6226.  
  6227.                    Sense is either MSSense or MSClick.  MSSense
  6228.                    activates the menu event handler whenever the mouse
  6229.                    cursor passes over the defined mouse click
  6230.                    areas.MSClick requires the right mouse button to be
  6231.                    pressed while the mouse cursor is on the mouse click
  6232.                    area.
  6233.  
  6234.                    OMType is the enumerated type of UpperRight,
  6235.                    UpperLeft, LowerRight, and LowerLeft, which specifies
  6236.                    whether the menu pop-down at the upper right or upper
  6237.                    left corner, or pop-up at the lower right or lower left
  6238.                    corner.
  6239. See also
  6240.                    DefineMouseClickArea, ResetOptionMenuEvents
  6241. Example
  6242.  
  6243.  
  6244.  
  6245. VAR OM1 : optionmptr;
  6246.  
  6247.   OM1 := CreateOptionMenu(@font14);
  6248.   DefineOptions(OM1,'  Show as Icons ',true,ViewOptionToggle);
  6249.   DefineOptions(OM1,'  Show as Text  ',true,ViewOptionToggle);
  6250.   DefineOptions(OM1,'-',false,nilunitproc);
  6251.   DefineOptions(OM1,'  Sort by Name  ',true,ViewOptionToggle);
  6252.   DefineOptions(OM1,'  Sort by Date  ',true,ViewOptionToggle);
  6253.   DefineOptions(OM1,'  Sort by Size  ',true,ViewOptionToggle);
  6254.   DefineOptions(OM1,'  Sort by Type  ',true,ViewOptionToggle);
  6255.  
  6256.   PushImage(530,320,624,340);
  6257.   PutPict(530,320,@ImageCredits,black);
  6258.   DefineOptionClickArea(StackPtr,0,0,93,19,OM1,MSClick,
  6259.     LowerRight);
  6260.  
  6261.  
  6262.  
  6263.  
  6264.  
  6265.  
  6266. ___________________________________________________________________________
  6267.  
  6268. ResetOptionMenuEvents Procedure                                    TEGLMENU
  6269. ___________________________________________________________________________
  6270.  
  6271.  
  6272. Function
  6273.                    Eliminates duplicate menu events where the frame has
  6274.                    been closed.
  6275.  
  6276.  Programmer's Reference Guide       - 103 -         TEGL Windows Toolkit
  6277.  
  6278.  
  6279.  
  6280.  
  6281.  
  6282.                           Chapter 5 - Menus
  6283.  
  6284. Declaration
  6285.                    ResetOptionMenuEvents
  6286. Remarks
  6287.                    The Menu unit keeps track of menu to frame attachments.
  6288.                    In most cases the attachment is permanent, that is,
  6289.                    until the program terminates. However in some cases,
  6290.                    like the icon editor, the menu to frame attachment
  6291.                    changes every time the icon editor explodes or implodes
  6292.                    an icon image. Since the Menu unit has no way of
  6293.                    knowing whether the attachment still exists, a special
  6294.                    procedure was created to eliminate duplicate or
  6295.                    nonexistent event relationships.
  6296.  
  6297.                    The only problem with not calling 
  6298.                    ResetOptionMenuEvents would be an accumulation of menu
  6299.                    events for non-existing frames. Eventually the heap
  6300.                    area will overflow.
  6301. See also
  6302.                    DefineOptionClickArea
  6303. Example
  6304.  
  6305.  
  6306.  
  6307. VAR OM1 : Optionmptr;
  6308.  
  6309. OM1 := CreateOptionMenu(@font14);
  6310. DefineOptions(OM1,'  Show as Icons ',true,ViewOptionToggle);
  6311. DefineOptions(OM1,'  Show as Text  ',true,ViewOptionToggle);
  6312. DefineOptions(OM1,'-',false,nilunitproc);
  6313. DefineOptions(OM1,'  Sort by Name  ',true,ViewOptionToggle);
  6314. DefineOptions(OM1,'  Sort by Date  ',true,ViewOptionToggle);
  6315. DefineOptions(OM1,'  Sort by Size  ',true,ViewOptionToggle);
  6316. DefineOptions(OM1,'  Sort by Type  ',true,ViewOptionToggle);
  6317.  
  6318. PushImage(530,320,624,340);
  6319. PutPict(530,320,@imagecredits,black);
  6320. DefineOptionClickArea(StackPtr,0,0,93,19,OM1,MSClick,LowerRight);
  6321. PopImage;
  6322.  
  6323. PushImage(530,320,624,340);
  6324. PutPict(530,320,@imagecredits,black);
  6325. DefineOptionClickArea(stackptr,0,0,93,19,OM1,MSClick,LowerRight);
  6326. ResetOptionMenuEvents;
  6327.  
  6328.  
  6329.  
  6330.  
  6331.  
  6332.  
  6333.  
  6334.  
  6335.  
  6336.  
  6337.  Programmer's Reference Guide       - 104 -         TEGL Windows Toolkit
  6338.  
  6339.  
  6340.  
  6341.  
  6342.  
  6343.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6344.  
  6345.  
  6346. Interrupt Handlers (TEGLIntr)
  6347. ___________________________________________________________________________
  6348.  
  6349. The mouse is perhaps one of the most outlandish devices ever conceived as
  6350. an interface for computer system (at least in programming it). However, in
  6351. the world of GUI, the mouse is a mandatory device.
  6352.  
  6353. Programming for a mouse is a programmer's nightmare, simply because it
  6354. adds another level of interfacing.  Conceptually, keyboard and mice do not
  6355. mix.  As an example, the mouse is dependent on screen location and whether
  6356. the user had clicked the mouse at a specific location on the screen and
  6357. whether that location was on an icon.  The keyboard, on the other hand, is
  6358. almost a direct path between pressing a key and executing a subroutine
  6359. (ie. if keypress then do something).
  6360.  
  6361. The programmer is required to write two separate routines for the same
  6362. function to handle this mix of interfaces. As well, some systems do not
  6363. have a mouse, so you cannot rely on the mouse pointer being available on
  6364. all systems.
  6365.  
  6366. TEGL Windows Toolkit, of  course, provides an almost seamless integration
  6367. of the two devices. On systems without a mouse, TEGL will emulate the
  6368. mouse by using the cursor keys on the numeric keypad. On systems with a
  6369. mouse, the cursor keys may be used simultaneously to move the mouse cursor
  6370. around. A key may also be attached to an icon/event, having the same
  6371. effect as the mouse clicking on the icon.
  6372.  
  6373.  
  6374. Interrupts
  6375. The TEGLIntr unit is comprised of four captured interrupts: The keyboard
  6376. interrupt (int $09), the mouse subroutine interrupt (function 12), the
  6377. timer interrupt (int $08) and the control break handler (int $1B).
  6378.  
  6379. SwapTEGLIntrOff and SwapTEGLIntrON should be called just before
  6380. and after a call to Exec to restore and then to recapture interrupt
  6381. vectors.
  6382.  
  6383.  
  6384. ___________________________________________________________________________
  6385.  
  6386. SwapTEGLIntrOff Procedure                                          TEGLINTR
  6387. ___________________________________________________________________________
  6388.  
  6389.  
  6390. Function
  6391.                    Restores all interrupts to the original saved vectors.
  6392. Declaration
  6393.                    SwapTEGLIntrOff
  6394. Remarks
  6395.                    All interrupts are
  6396.                    initially turned on.
  6397.  
  6398.  Programmer's Reference Guide       - 105 -         TEGL Windows Toolkit
  6399.  
  6400.  
  6401.  
  6402.  
  6403.  
  6404.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6405.  
  6406. See also
  6407.                    SwapTEGLIntrOn
  6408.  
  6409.  
  6410.  
  6411. ___________________________________________________________________________
  6412.  
  6413. SwapTEGLIntrOn Procedure                                           TEGLINTR
  6414. ___________________________________________________________________________
  6415.  
  6416.  
  6417. Function
  6418.                    Saves and initialize the required TEGL interrupts.
  6419. Declaration
  6420.                    SwapTEGLIntrOn
  6421. Restrictions
  6422.                    SwapTEGLIntrOn cannot be called more then once in
  6423.                    succession, otherwise the system will hang.
  6424. See also
  6425.                    SwapTEGLIntrOn
  6426.  
  6427. Mouse Emulation
  6428.  
  6429. The mouse cursor is an internal function of the TEGL mouse unit, rather
  6430. than using the cursor provided by the mouse driver. This way a mouse
  6431. cursor is always available even on systems that do not have a mouse.
  6432.  
  6433. The support for the emulated mouse is identical, in all respects, to the
  6434. actual mouse driver.
  6435.  
  6436. In order to provide a seamless integration of the mouse and keyboard,
  6437. the Mouse function 12 interrupt $33 is used to capture the mouse hardware
  6438. interrupts, and keyboard interrupt $09 is used to capture key codes.
  6439. Since both are hardware interrupts, a KBMouseBusy flag is used to
  6440. serialize any conflict if both interrupts occurs at the same time.
  6441.  
  6442. The emulated mouse cursor is controled by the following primitives. They
  6443. may be used ONLY if the MouseShow flag is false, otherwise
  6444. you may find mouse droppings on the screen.
  6445.  
  6446.  
  6447. ___________________________________________________________________________
  6448.  
  6449. MCursorOff Procedure                                               TEGLINTR
  6450. ___________________________________________________________________________
  6451.  
  6452.  
  6453. Function
  6454.                    Switches the Emulated Mouse Cursor off.
  6455. Declaration
  6456.                    MCursorOff
  6457. Restrictions
  6458.  
  6459.  Programmer's Reference Guide       - 106 -         TEGL Windows Toolkit
  6460.  
  6461.  
  6462.  
  6463.  
  6464.  
  6465.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6466.  
  6467.                    Use ONLY when MouseShow flag is False.
  6468. See also
  6469.                    MCursorOn, MSetPos
  6470.  
  6471.  
  6472.  
  6473. ___________________________________________________________________________
  6474.  
  6475. MCursorOn Procedure                                                TEGLINTR
  6476. ___________________________________________________________________________
  6477.  
  6478.  
  6479. Function
  6480.                    Switches the Emulated Mouse Cursor on.
  6481. Declaration
  6482.                    MCursorOn(Xpos,Ypos : Word);
  6483. Remarks
  6484.                    Xpos, Ypos is the relative screen coordinates from
  6485.                    the upper left corner of 0,0.
  6486. Restrictions
  6487.                    Use ONLY when MouseShow flag is False.
  6488. See also
  6489.                    MCursorOff, MSetPos
  6490.  
  6491.  
  6492.  
  6493. ___________________________________________________________________________
  6494.  
  6495. MSetPos Procedure                                                  TEGLINTR
  6496. ___________________________________________________________________________
  6497.  
  6498.  
  6499. Function
  6500.                    Sets a new position for the Emulated Mouse Cursor.
  6501. Declaration
  6502.                    MSetPos(XPos, YPos: Word);
  6503. Remarks
  6504.                    xpos, ypos is the relative screen coordinates from
  6505.                    the upper left corner of 0,0.
  6506. Restrictions
  6507.                    The emulated mouse cursor must be on before setting a
  6508.                    new position.
  6509.  
  6510.                    Use ONLY when MouseShow flag is False.
  6511. See also
  6512.                    MCursorOff, MCursorOn
  6513.  
  6514.  
  6515.  
  6516. Standard Mouse Functions
  6517.  
  6518.  
  6519.  
  6520.  Programmer's Reference Guide       - 107 -         TEGL Windows Toolkit
  6521.  
  6522.  
  6523.  
  6524.  
  6525.  
  6526.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6527.  
  6528. ___________________________________________________________________________
  6529.  
  6530. ShowMouse Procedure                                                TEGLINTR
  6531. ___________________________________________________________________________
  6532.  
  6533.  
  6534. Function
  6535.                    Display a mouse cursor at current Mouse_Xcoord,
  6536.                    Mouse_Ycoord.
  6537. Declaration
  6538.                    ShowMouse;
  6539. See also
  6540.                    HideMouse, SetMousePosition, CursorShape
  6541.  
  6542.  
  6543.  
  6544. ___________________________________________________________________________
  6545.  
  6546. HideMouse Procedure                                                TEGLINTR
  6547. ___________________________________________________________________________
  6548.  
  6549.  
  6550. Function
  6551.                    Hides mouse cursor.
  6552. Declaration
  6553.                    HideMouse
  6554. See also
  6555.                    ShowMouse, SetMousePosition, CursorShape
  6556.  
  6557.  
  6558.  
  6559. ___________________________________________________________________________
  6560.  
  6561. SetMousePosition Procedure                                         TEGLINTR
  6562. ___________________________________________________________________________
  6563.  
  6564.  
  6565. Function
  6566.                    Sets x,y coordinates of mouse cursor.
  6567. Declaration
  6568.                    SetMousePosition(MouseX,MouseY : word)
  6569. Remarks
  6570.                    MouseX, MouseY are relative coordinates from the
  6571.                    upper left corner of the screen 0,0.
  6572. See also
  6573.                    ShowMouse, HideMouse, CursorShape
  6574.  
  6575.  
  6576.  
  6577. ___________________________________________________________________________
  6578.  
  6579. CursorShape Procedure                                              TEGLINTR
  6580.  
  6581.  Programmer's Reference Guide       - 108 -         TEGL Windows Toolkit
  6582.  
  6583.  
  6584.  
  6585.  
  6586.  
  6587.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6588.  
  6589. ___________________________________________________________________________
  6590.  
  6591.  
  6592. Function
  6593.                    Sets the mouse cursor shape.
  6594. Declaration
  6595.                    CursorShape(Shape:Masktype)
  6596. Remarks
  6597.                    Sets the mouse cursor shape to the bit pattern
  6598.                    specified in Shape.
  6599.  
  6600.                    Masktype is predefined as follows:
  6601.  
  6602.  
  6603.    type
  6604.        MaskType = array[0..1, 0..15] of word;
  6605.  
  6606.  
  6607.  
  6608. The mouse shape is based on the underlying byte values contained in the
  6609. Shape array. The Shape array is 64 bytes long, with the first
  6610. 32 bytes corresponding to a 16 by 16 screen mask, and the remaining 32
  6611. bytes corresponding to a 16 by 16 cursor mask. The first 32 bytes are
  6612. ANDed to the screen, followed by ORing the second 32 bytes
  6613. with the screen pixels to create the final mouse image.
  6614.  
  6615. For example the PointingHand Masktype is defined as a constant as
  6616. follows:
  6617.  
  6618.  
  6619.  
  6620.    PointingHand: MaskType =
  6621.      (($E1FF,$E1FF,$E1FF,$E1FF,$E1ff,$E000,$E000,$e000,   { Screen Mask }
  6622.        $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000),
  6623.  
  6624.       ($1E00,$1200,$1200,$1200,$1200,$13ff,$1249,$1249,   { Cursor Mask }
  6625.        $1249,$9001,$9001,$9001,$8001,$8001,$8001,$FFFF));
  6626.  
  6627.  
  6628.  
  6629. The resulting type is:
  6630.  
  6631.            Screen Mask
  6632.  
  6633.            1110000111111111     =  $E1FF
  6634.            1110000111111111     =  $E1FF
  6635.            1110000111111111     =  $E1FF
  6636.            1110000111111111     =  $E1FF
  6637.            1110000111111111     =  $E1FF
  6638.            1110000000000000     =  $E100
  6639.            1110000000000000     =  $E100
  6640.            1110000000000000     =  $E100
  6641.  
  6642.  Programmer's Reference Guide       - 109 -         TEGL Windows Toolkit
  6643.  
  6644.  
  6645.  
  6646.  
  6647.  
  6648.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6649.  
  6650.            0000000000000000     =  $0000
  6651.            0000000000000000     =  $0000
  6652.            0000000000000000     =  $0000
  6653.            0000000000000000     =  $0000
  6654.            0000000000000000     =  $0000
  6655.            0000000000000000     =  $0000
  6656.            0000000000000000     =  $0000
  6657.            0000000000000000     =  $0000
  6658.  
  6659.  
  6660.            Cursor Mask
  6661.  
  6662.            0001111000000000     =  $1E00
  6663.            0001001000000000     =  $1200
  6664.            0001001000000000     =  $1200
  6665.            0001001000000000     =  $1200
  6666.            0001001000000000     =  $1200
  6667.            0001001111111111     =  $13FF
  6668.            0001001001001001     =  $1249
  6669.            0001001001001001     =  $1249
  6670.            0001001001001001     =  $1249
  6671.            1001000000000001     =  $9001
  6672.            1001000000000001     =  $9001
  6673.            1000000000000001     =  $8001
  6674.            1000000000000001     =  $8001
  6675.            1000000000000001     =  $8001
  6676.            1000000000000001     =  $8001
  6677.            1111111111111111     =  $FFFF
  6678.  
  6679.  
  6680. There are 5 masktype constants defined in the TEGLIntr unit. They
  6681. are: Pointing Hand, HourGlass, Standard, DiagCross, and CheckMark.
  6682.  
  6683. See also
  6684.                    ShowMouse, HideMouse, SetMouseHotSpot
  6685.  
  6686.  
  6687.  
  6688. ___________________________________________________________________________
  6689.  
  6690. SetMouseHotSpot Procedure                                          TEGLINTR
  6691. ___________________________________________________________________________
  6692.  
  6693.  
  6694. Function
  6695.                    Sets the cursor hot-spot values relative to the
  6696.                    upper-left corner of the mouse cursor image.
  6697. Declaration
  6698.                    SetMouseHotSpot(x,y : word)
  6699. Remarks
  6700.                    x, y are relative coordinates from the upper left
  6701.                    corner of the mouse cursor image 0,0.
  6702.  
  6703.  Programmer's Reference Guide       - 110 -         TEGL Windows Toolkit
  6704.  
  6705.  
  6706.  
  6707.  
  6708.  
  6709.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6710.  
  6711. See also
  6712.                    CursorShape
  6713.  
  6714.  
  6715.  
  6716. ___________________________________________________________________________
  6717.  
  6718. SetMouseColor Procedure                                            TEGLINTR
  6719. ___________________________________________________________________________
  6720.  
  6721.  
  6722. Function
  6723.                    Sets the mouse cursor color.
  6724. Declaration
  6725.                    SetMouseColor(Color:word)
  6726. Remarks
  6727.                    Sets the current Mouse Cursor Color to Color.
  6728.                    Available colors are defined in the Graph Unit.
  6729. See also
  6730.                    CursorShape
  6731.  
  6732.  
  6733.  
  6734. ___________________________________________________________________________
  6735.  
  6736. MousePosition function                                             TEGLINTR
  6737. ___________________________________________________________________________
  6738.  
  6739.  
  6740. Function
  6741.                    Gets the Mouse Cursor coordinates and button
  6742.                    information.
  6743. Declaration
  6744.                    MousePosition(VAR MouseX,MouseY : Word) : Word;
  6745. Result type
  6746.                    Returns the mouse button status. Left button - 1, Right
  6747.                    button - 2, both buttons - 3.
  6748. Remarks
  6749.                    MouseX,MouseY are relative coordinates from the
  6750.                    upper left corner of the screen (0,0).
  6751.  
  6752.                    This function is no longer required in version 2.00,
  6753.                    since the the information above are provided in the
  6754.                    global variables Mouse_XCoord, Mouse_YCoord and
  6755.                    Mouse_Buttons respectively.
  6756. See also
  6757.                    GetButtonReleaseInfo, GetButtonPressInfo,
  6758.                    ClearButtonInfo
  6759. Example
  6760.  
  6761.  
  6762.  
  6763.  
  6764.  Programmer's Reference Guide       - 111 -         TEGL Windows Toolkit
  6765.  
  6766.  
  6767.  
  6768.  
  6769.  
  6770.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6771.  
  6772. VAR mp,x,y : Word;
  6773.  
  6774.   mp := MousePosition(x,y);
  6775.   IF Integer(mp) = -3 THEN   { -- Both buttons down }
  6776.     BEGIN
  6777.     END;
  6778.  
  6779.  
  6780.  
  6781.  
  6782.  
  6783. ___________________________________________________________________________
  6784.  
  6785. GetButtonReleaseInfo Procedure                                     TEGLINTR
  6786. ___________________________________________________________________________
  6787.  
  6788.  
  6789. Function
  6790.                    Gets the Mouse Cursor button release information.
  6791. Declaration
  6792.                    GetButtonReleaseInfo(Button:word; VAR ButtonStat,
  6793.                    ButtonRelease,Xpos,Ypos:word)
  6794. Remarks
  6795.                    Button specifies for which button information is
  6796.                    required.
  6797.  
  6798.                    ButtonStat is the current button status
  6799.                    information.
  6800.  
  6801.                    ButtonRelease is the number of times the button
  6802.                    has been released.
  6803.  
  6804.                    Xpos, Ypos specifies the coordinates where the
  6805.                    button was last released.
  6806.  
  6807.                    The information is reset back to zero after the
  6808.                    information has been read.
  6809. See also
  6810.                    MousePosition, GetButtonPressInfo,
  6811.                    ClearButtonInfo
  6812.  
  6813.  
  6814.  
  6815. ___________________________________________________________________________
  6816.  
  6817. GetButtonPressInfo Procedure                                       TEGLINTR
  6818. ___________________________________________________________________________
  6819.  
  6820.  
  6821. Function
  6822.                    Gets the Mouse Cursor button press information.
  6823. Declaration
  6824.  
  6825.  Programmer's Reference Guide       - 112 -         TEGL Windows Toolkit
  6826.  
  6827.  
  6828.  
  6829.  
  6830.  
  6831.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6832.  
  6833.                    GetButtonPressInfo(Button : word; VAR ButtonStat,
  6834.                      ButtonRelease,Xpos,Ypos:word)
  6835. Remarks
  6836.                    Button specifies for which button information is
  6837.                    required.
  6838.  
  6839.                    ButtonStat is the current button status
  6840.                    information.
  6841.  
  6842.                    ButtonPress is the number of times the button has
  6843.                    been pressed.
  6844.  
  6845.                    Xpos,Ypos specifies the coordinates where the
  6846.                    button was last pressed.
  6847.  
  6848.                    The information is reset back to zero after the
  6849.                    information has been read.
  6850. See also
  6851.                    MousePosition, GetButtonReleaseInfo,
  6852.                    ClearButtonInfo
  6853.  
  6854.  
  6855.  
  6856. ___________________________________________________________________________
  6857.  
  6858. ClearButtonInfo Procedure                                          TEGLINTR
  6859. ___________________________________________________________________________
  6860.  
  6861.  
  6862. Function
  6863.                    Clears the Mouse button info counters.
  6864. Declaration
  6865.                    ClearButtonInfo;
  6866. See also
  6867.                    GetButtonReleaseInfo, GetButtonPressInfo
  6868.  
  6869.  
  6870.  
  6871. ___________________________________________________________________________
  6872.  
  6873. SetMouseMinMax Procedure                                           TEGLINTR
  6874. ___________________________________________________________________________
  6875.  
  6876.  
  6877. Function
  6878.                    Sets the Mouse Cursor minimum and maximum coordinates.
  6879. Declaration
  6880.                    SetMouseMinMax(MinX,MinY,MaxX,MaxY:word)
  6881. Remarks
  6882.                    MinX, MinY are the minimum relative coordinates
  6883.                    that the mouse may travel. MaxX, MaxY are the
  6884.                    maximum relative coordinates that the mouse may travel.
  6885.  
  6886.  Programmer's Reference Guide       - 113 -         TEGL Windows Toolkit
  6887.  
  6888.  
  6889.  
  6890.  
  6891.  
  6892.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6893.  
  6894.  
  6895. See also
  6896.                    SetMousePosition
  6897.  
  6898.  
  6899.  
  6900.  
  6901. ___________________________________________________________________________
  6902.  
  6903. FrozenMouse Procedure                                              TEGLINTR
  6904. ___________________________________________________________________________
  6905.  
  6906.  
  6907. Function
  6908.                    Prevents the mouse from moving when updating the
  6909.                    screen.
  6910. Declaration
  6911.                    FrozenMouse
  6912. Remarks
  6913.                    Certain EGA registers cannot be read reliably. Rather
  6914.                    then attempting to read and restore the register with
  6915.                    each movement of the mouse, it is more economical to
  6916.                    simply freeze the mouse, while the screen is being
  6917.                    updated.
  6918.  
  6919.                    FrozenMouse retains a counter on the number of times
  6920.                    the mouse is frozen. In order to unfreeze the mouse,
  6921.                    the same number of UnFreeze calls must be made.
  6922. Restrictions
  6923.                    FrozenMouse may be used if the screen update is
  6924.                    temporary (ie. XorBox), or the second EGA page is being
  6925.                    updated. Care must be taken that the mouse cursor is
  6926.                    not overlapping the updated area, otherwise mouse
  6927.                    droppings may result.
  6928. See also
  6929.                    FreezeMouse, UnFreezeMouse
  6930.  
  6931.  
  6932.  
  6933.  
  6934. ___________________________________________________________________________
  6935.  
  6936. FreezeMouse function                                               TEGLINTR
  6937. ___________________________________________________________________________
  6938.  
  6939.  
  6940. Function
  6941.                    Prevents the mouse from moving or being overwritten
  6942.                    when updating the screen.
  6943. Declaration
  6944.                    FreezeMouse(x,y,x1,y1:word)
  6945. Result type
  6946.  
  6947.  Programmer's Reference Guide       - 114 -         TEGL Windows Toolkit
  6948.  
  6949.  
  6950.  
  6951.  
  6952.  
  6953.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  6954.  
  6955.                    Returns the last MouseShow status.
  6956. Remarks
  6957.                    Certain EGA registers cannot be read reliably. Rather
  6958.                    then attempting to read and restore the register with
  6959.                    each movement of the mouse, it is more economical to
  6960.                    simply freeze the mouse, while the screen is being
  6961.                    updated.
  6962.  
  6963.                    FreezeMouse differs from FrozenMouse in that
  6964.                    a check is made on whether the mouse cursor overlaps
  6965.                    the updated area. If the mouse cursor overlaps the
  6966.                    update area, the mouse is hidden until UnFreeze
  6967.                    displays the mouse.
  6968.  
  6969.                    FreezeMouse also retains a counter on the number
  6970.                    of times the mouse is frozen. In order to unfreeze the
  6971.                    mouse, the same number of UnFreeze calls must be
  6972.                    made.
  6973.  
  6974. Restrictions
  6975.                    FrozenMouse may be used if the screen update is
  6976.                    temporary (ie. XorBox), or if the second EGA video page
  6977.                    is being updated.
  6978. See also
  6979. FrozenMouse, UnFreezeMouse
  6980.  
  6981.  
  6982.  
  6983. ___________________________________________________________________________
  6984.  
  6985. UnFreezeMouse Procedure                                            TEGLINTR
  6986. ___________________________________________________________________________
  6987.  
  6988.  
  6989. Function
  6990.                    Releases the mouse from a frozen or freeze status.
  6991. Declaration
  6992.                    UnFreezeMouse(Mshow:boolean)
  6993. Remarks
  6994.                    Mshow is the mouse show status returned from
  6995.                    FreezeMouse, or use the global MouseShow flag if
  6996.                    FrozenMouse was called.
  6997.  
  6998.                    FreezeMouse and FrozenMouse retain a counter
  6999.                    on the number of times the mouse is frozen. In order to
  7000.                    unfreeze the mouse, the same number of UnFreeze
  7001.                    calls must be made.
  7002. See also
  7003.                    FrozenMouse, FreezeMouse
  7004.  
  7005.  
  7006.  
  7007.  
  7008.  Programmer's Reference Guide       - 115 -         TEGL Windows Toolkit
  7009.  
  7010.  
  7011.  
  7012.  
  7013.  
  7014.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7015.  
  7016. ___________________________________________________________________________
  7017.  
  7018. SetMouseSensitivity Procedure                                      TEGLINTR
  7019. ___________________________________________________________________________
  7020.  
  7021.  
  7022. Function
  7023.                    Sets the mouse-to-cursor movement sensitivity.
  7024. Declaration
  7025.                    SetMouseSensitivity(Xsense,Ysense,Threshold:
  7026.                    word)
  7027. Remarks
  7028.                    Xsense defines the horizontal movement
  7029.                    sensitivity.
  7030.  
  7031.                    Ysense defines the vertical movement sensitivity.
  7032.  
  7033.                    The sensitivity numbers range from 1 through 100, where
  7034.                    50 specifies the default mickey factor of 1. The
  7035.                    mouse-to-cursor movement is more sensitive at higher
  7036.                    numbers.
  7037.  
  7038.                    The threshold parameter sets the ratio at which
  7039.                    the mouse-to-cursor movement is doubled. This range of
  7040.                    this parameter is also 1 through 100. The lower the
  7041.                    threshold, the more sensitive the mouse.
  7042. See also
  7043.                    GetMouseSensitivity
  7044.  
  7045.  
  7046.  
  7047. ___________________________________________________________________________
  7048.  
  7049. GetMouseSensitivity Procedure                                      TEGLINTR
  7050. ___________________________________________________________________________
  7051.  
  7052.  
  7053. Function
  7054.                    Returns the mouse-to-cursor movement sensitivity
  7055.                    scaling factors previously set by SetMouseSensitivty.
  7056. Declaration
  7057.                    GetMouseSensitivity(VAR Xsense,Ysense,
  7058.                      Threshold:word)
  7059. Remarks
  7060.                    Xsense defines the horizontal movement
  7061.                    sensitivity.
  7062.  
  7063.                    Ysense defines the vertical movement sensitivity.
  7064.  
  7065.                    The sensitivity numbers range from 1 through 100, where
  7066.                    50 specifies the default mickey factor of 1. The
  7067.                    mouse-to-cursor movement is more sensitive at higher
  7068.  
  7069.  Programmer's Reference Guide       - 116 -         TEGL Windows Toolkit
  7070.  
  7071.  
  7072.  
  7073.  
  7074.  
  7075.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7076.  
  7077.                    numbers.
  7078.  
  7079.                    The threshold parameter is the ratio at which the
  7080.                    mouse-to-cursor movement is doubled. This range of this
  7081.                    parameter is also 1 through 100. The lower the
  7082.                    threshold, the more sensitive the mouse.
  7083. See also
  7084.                    SetMouseSensitivity
  7085.  
  7086.  
  7087.  
  7088.  
  7089. ___________________________________________________________________________
  7090.  
  7091. SetKeyBoardMouse Procedure                                         TEGLINTR
  7092. ___________________________________________________________________________
  7093.  
  7094.  
  7095. Function
  7096.                    Toggles the keyboard mouse on or off.
  7097. Declaration
  7098.                    SetKeyBoardMouse(ON_OFF : boolean)
  7099. Remarks
  7100.                    The cursor keys leftarrow downarrow uparrow
  7101.                    rightarrow, on the keyboard, may be used to emulate
  7102.                    the mouse movements. SetKeyBoardMouse(FALSE)
  7103.                    will turn off the emulation, to allow GetCh to
  7104.                    retrieve the keycode.
  7105. Restrictions
  7106.                    SetKeyBoardMouse will have no effect on TEGL's
  7107.                    keyboard events, (ie. the cursor keys may be assigned
  7108.                    functions by means of AddCaptureKey), which will
  7109.                    have priority over the keyboard mouse.
  7110. See also
  7111.                    SetKBSteps, GetKBSteps
  7112.  
  7113.  
  7114.  
  7115. ___________________________________________________________________________
  7116.  
  7117. SetKBSteps Procedure                                               TEGLINTR
  7118. ___________________________________________________________________________
  7119.  
  7120.  
  7121. Function
  7122.                    Sets the amount of pixel movement with each cursor key
  7123.                    press.
  7124. Declaration
  7125.                    SetKBSteps(xsteps,ysteps,sfxsteps,sfysteps:
  7126.                    word)
  7127. Remarks
  7128.                    xsteps, ysteps are the positive incremental values
  7129.  
  7130.  Programmer's Reference Guide       - 117 -         TEGL Windows Toolkit
  7131.  
  7132.  
  7133.  
  7134.  
  7135.  
  7136.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7137.  
  7138.                    for moving the mouse cursor to the next position.
  7139.                    Initial values are (x=12,y=8).
  7140.  
  7141.                    sfxsteps, sfysteps are the positive incremental
  7142.                    value for moving the mouse cursor to the next position
  7143.                    when using the shiftkey in conjunction with the
  7144.                    leftarrow downarrow uparrow rightarrow keys.
  7145.                    Initial values are (x=2,y=1).
  7146. Restrictions
  7147.                    SetKBSteps will have no effect on TEGL's keyboard
  7148.                    events, (ie.  the cursor keys may be assigned functions
  7149.                    by means of AddCaptureKey), which will have
  7150.                    priority over the keyboard mouse.
  7151. See also
  7152.                    SetKeyBoardMouse, GetKBSteps
  7153.  
  7154.  
  7155.  
  7156. ___________________________________________________________________________
  7157.  
  7158. GetKBSteps Procedure                                               TEGLINTR
  7159. ___________________________________________________________________________
  7160.  
  7161.  
  7162. Function
  7163.                    Returns the pixel movement value set for the keyboard
  7164.                    mouse.
  7165. Declaration
  7166.                    GetKBSteps(xsteps,ysteps,sfxsteps,sfysteps:
  7167.                    word)
  7168. Remarks
  7169.                    xsteps, ysteps are the positive horizontal and
  7170.                    vertical step increments.
  7171.  
  7172.                    sfxsteps, sfysteps are the positive horizontal and
  7173.                    vertical step increments when using the shiftkey in
  7174.                    conjunction with the leftarrow downarrow uparrow
  7175.                    rightarrow keys.
  7176. See also
  7177.                    SetKeyBoardMouse, SetKBSteps
  7178.  
  7179.  
  7180.  
  7181.  
  7182. Timer Functions
  7183.  
  7184. A timer tick has the standard resolution of interrupting any process
  7185. within the system, 18 times a second.  TEGL Windows uses the captured
  7186. timer interrupt to decrement counters and set a flag when the counter is
  7187. zero. TEGLSupervisor monitors the status of the flag and calls the
  7188. attached event when the flag is set.  Thus timed events are processed
  7189. outside the critical timer tick interrupt.
  7190.  
  7191.  Programmer's Reference Guide       - 118 -         TEGL Windows Toolkit
  7192.  
  7193.  
  7194.  
  7195.  
  7196.  
  7197.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7198.  
  7199.  
  7200. Timer events may be used as clocks, background tasks, print spoolers etc.
  7201.  
  7202.  
  7203. ___________________________________________________________________________
  7204.  
  7205. SwapTimerOut Procedure                                             TEGLINTR
  7206. ___________________________________________________________________________
  7207.  
  7208.  
  7209. Function
  7210.                    Restores the original timer vectors.
  7211. Declaration
  7212.                    SwapTimerOut
  7213. Remarks
  7214.                    Use SwapTimerOut if you need to turn the timer
  7215.                    off.
  7216. See also
  7217.                    SwapTimerIn
  7218.  
  7219.  
  7220.  
  7221. ___________________________________________________________________________
  7222.  
  7223. SwapTimerIn Procedure                                              TEGLINTR
  7224. ___________________________________________________________________________
  7225.  
  7226.  
  7227. Function
  7228.                    Captures the original timer vectors and sets the
  7229.                    interrupt vectors to point at TEGL's timer function.
  7230. Declaration
  7231.                    SwapTimerIn
  7232. Remarks
  7233.                    The timer interrupt is originally swapped in.
  7234. Restrictions
  7235.                    SwapTimerIn cannot be called more then once in
  7236.                    succession, otherwise the system will hang.
  7237. See also
  7238.                    SwapTimerIn
  7239.  
  7240.  
  7241.  
  7242. ___________________________________________________________________________
  7243.  
  7244. SetTimerStart Procedure                                            TEGLINTR
  7245. ___________________________________________________________________________
  7246.  
  7247.  
  7248. Function
  7249.                    Sets the timer value of timepiece counter.
  7250. Declaration
  7251.  
  7252.  Programmer's Reference Guide       - 119 -         TEGL Windows Toolkit
  7253.  
  7254.  
  7255.  
  7256.  
  7257.  
  7258.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7259.  
  7260.                    SetTimerStart(VAR Timepiece : TimeRecPtr;
  7261.                      Timeset: Word)
  7262. Remarks
  7263.                    Timepiece is of the type TimeRecPtr. If 
  7264.                    Timepiece is set to Nil, a timepiece record is
  7265.                    created and initialized to timeset.
  7266.  
  7267.                    Timeset is a word value counter. A value of 18 is
  7268.                    equivalent of 1 second.
  7269. See also
  7270.                    ResetTimerFlag
  7271.  
  7272.  
  7273.  
  7274. ___________________________________________________________________________
  7275.  
  7276. ResetTimerFlag Procedure                                           TEGLINTR
  7277. ___________________________________________________________________________
  7278.  
  7279.  
  7280. Function
  7281.                    Resets the flag that indicates the completion of a
  7282.                    cycle. A cycle is when the counter reaches zero and is
  7283.                    reset back to its original value.
  7284. Declaration
  7285.                    ResetTimerFlag(Timepiece:TimeRecPtr)
  7286. Remarks
  7287.                    Timepiece is of the type TimeRecPtr. 
  7288.                    timepiece is created by SetTimerStart.
  7289. See also
  7290.                    SetTimerStart
  7291.  
  7292.  
  7293.  
  7294. ___________________________________________________________________________
  7295.  
  7296. DropTimerCount Procedure                                           TEGLINTR
  7297. ___________________________________________________________________________
  7298.  
  7299.  
  7300. Function
  7301.                    Deletes a timepiece record from the timer event
  7302.                    chain.
  7303. Declaration
  7304.                    DropTimerCount(Timepiece : TimeRecPtr)
  7305. Remarks
  7306.                    Timepiece is of the type TimeRecPtr. 
  7307.                    Timepiece is created by SetTimerStart.
  7308. See also
  7309.                    SetTimerStart
  7310.  
  7311.  
  7312.  
  7313.  Programmer's Reference Guide       - 120 -         TEGL Windows Toolkit
  7314.  
  7315.  
  7316.  
  7317.  
  7318.  
  7319.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7320.  
  7321.  
  7322. ___________________________________________________________________________
  7323.  
  7324. TimerSwtich Procedure                                              TEGLINTR
  7325. ___________________________________________________________________________
  7326.  
  7327.  
  7328. Function
  7329.                    Toggles the timer handler on or off.
  7330. Declaration
  7331.                    TimerSwitch(onoff:boolean)
  7332. Remarks
  7333.                    onoff sets the status on whether the timer event
  7334.                    chain is scanned and decremented. A boolean value of
  7335.                    FALSE stops the counters from being decremented. A
  7336.                    boolean value of TRUE resets the counters back to
  7337.                    their original values and causes the counters within
  7338.                    the timer event chain to be decremented 18 times a
  7339.                    second.
  7340.  
  7341.                    TimerSwitch does not remove the timer interrupt
  7342.                    vectors.
  7343. See also
  7344.                    SwapTimerOut, SwapTimerIn
  7345.  
  7346.  
  7347.  
  7348. Keyboard Interrupt Events
  7349.  
  7350. There are two levels at which the keyboard interrupt may be used. At the
  7351. higher Keyboard Event level (monitored by the TEGLSupervisor),
  7352. complete events, like swapping rotating windows, may be attached to a key
  7353. on the keyboard. However, at the lower level setting the keycall
  7354. parameter in AddCaptureKey to point at a key handler allows low level
  7355. functions like positioning the mouse cursor to be performed.
  7356.  
  7357. A good example of a key handler is the default mouse click handler.
  7358. The enterkey is used to automatically position the mouse cursor on the
  7359. first defined mouse click area and simulates the holding down of the mouse
  7360. right button, until the key is released.
  7361.  
  7362. The higher Keyboard Event level is set with a call to 
  7363. DefineLocalKeyClickArea and DefineGlobalKeyClickArea within 
  7364. TEGLUnit.  The keycall parameter in AddCaptureKey is set to 
  7365. NilKeyCallProc. Instead of calling an external callproc, the keys are
  7366. stacked in a keyboard buffer that is monitored by the TEGLSupervisor.
  7367.  
  7368. This TEGL keyboard buffer is separate from the normal keyboard buffer. The
  7369. TEGLKeyPressed and TEGLReadKey functions are provided to check
  7370. and read captured keys.
  7371.  
  7372. Note: The keyboard handler uses scan codes rather then translated Ascii
  7373.  
  7374.  Programmer's Reference Guide       - 121 -         TEGL Windows Toolkit
  7375.  
  7376.  
  7377.  
  7378.  
  7379.  
  7380.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7381.  
  7382. codes.
  7383.  
  7384.  
  7385. Keyboard Scan Codes
  7386.  
  7387. $01 esckey                 $20 key D                    $40 key F6
  7388. $02 key 1key !           $21 key F                    $41 key F7
  7389. $03 key 2key @           $22 key G                    $42 key F8
  7390. $04 key 3key #           $23 key H                    $43 key F9
  7391. $05 key 4key $           $24 key J                    $44 f10
  7392. $06 key 5key %           $25 key K                    $45 numlock
  7393. $07 key 6key ^           $26 key L                    $46 scrlock
  7394. $08 key 7key &           $27 ; :                        $47 homekey key 7
  7395. $09 key 8key *           $28 ' "                        $48 uparrow key 8
  7396. $0A key 9key (           $29 ` ~                        $49 pgupkey key 9
  7397. $0B key 0key )           $2A shiftkey Left            $4A key -
  7398. $0C {key -} _               $2B {key }                   $4B {leftarrow} {key 4}
  7399. $0D key =key +           $2C key Z                    $4C key 5
  7400. $0E backspace              $2D key X                    $4D rightarrow key 6
  7401. $0F forwtabbacktab       $2E key C                    $4E key +
  7402. $10 key Q                  $2F key V                    $4F endkey key 1
  7403. $11 key W                  $30 key B                    $50 downarrow key 2
  7404. $12 key E                  $31 key N                    $51 pgdnkey key 3
  7405. $13 key R                  $32 key M                    $52 inskey key 0
  7406. $14 key T                  $33 key ,key <             $53 delkey key .
  7407. $15 key Y                  $34 key .key >             $54 sysreq
  7408. $16 key U                  $35 key /key ?             $85 bigfrontF11keyback
  7409. $17 key I                  $36 shiftkey Right           $86 bigfrontF12keyback
  7410. $18 key O                  $37 prtsckeykey *
  7411. $19 key P                  $38 altkey
  7412. $1A [ {                     $39 {spacebar}
  7413. $1B ] }                     $3A {capslock}
  7414. $1C enterkey               $3B key F1
  7415. $1D ctrlkey                $3C key F2
  7416. $1E key A                  $3D key F3
  7417. $1F key S                  $3E key F4
  7418. _                    $3F key F5
  7419.  
  7420.  
  7421.  
  7422. ___________________________________________________________________________
  7423.  
  7424. AddCaptureKey Procedure                                            TEGLINTR
  7425. ___________________________________________________________________________
  7426.  
  7427.  
  7428. Function
  7429.                    Adds a keyboard scancode to the keyboard handler for
  7430.                    capturing, or for processing immediately when the key
  7431.                    is pressed.
  7432. Declaration
  7433.                    AddCaptureKey(Keycode:word;Repeatkey:Koolean;
  7434.  
  7435.  Programmer's Reference Guide       - 122 -         TEGL Windows Toolkit
  7436.  
  7437.  
  7438.  
  7439.  
  7440.  
  7441.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7442.  
  7443.                      Keycall:keybrdcallproc)
  7444. Remarks
  7445.                    Keycode is the scan code of the keys on the
  7446.                    keyboard. This is different from the ascii code that is
  7447.                    usually translated and passed by DOS. Use the scancode
  7448.                    value listed in the scancode table.
  7449.  
  7450.                    Repeatkey is set to TRUE if the key is
  7451.                    expected to repeat. False if the key must be
  7452.                    released before generating another interrupt.
  7453.  
  7454.                    Keycall is the key call procedure when the
  7455.                    keyboard handler captures the key. If keycall is
  7456.                    set to NilKeyCallProc the scancode of the capture
  7457.                    key is added to the TEGL keyboard buffer.
  7458.  
  7459.                    AddCaptureKey can stack the same scan code any
  7460.                    number of times, however, only the most recent entry in
  7461.                    the Scancode chain is used.
  7462. See also
  7463.                    DeleteCaptureKey
  7464.  
  7465.  
  7466.  
  7467. ___________________________________________________________________________
  7468.  
  7469. DeleteCaptureKey Procedure                                         TEGLINTR
  7470. ___________________________________________________________________________
  7471.  
  7472.  
  7473. Function
  7474.                    Removes a keyboard scancode from the keyboard scancode
  7475.                    chain.
  7476. Declaration
  7477.                    DeleteCaptureKey(Keycode : Word)
  7478. Remarks
  7479.                    Keycode is the scan code of the keys on the
  7480.                    keyboard. This is different from the ascii code that is
  7481.                    usually translated and passed by DOS.
  7482.  
  7483.                    If the same scan code is stacked more then once the
  7484.                    most recent entry in the Scancode chain is deleted.
  7485. See also
  7486.                    AddCaptureKey
  7487.  
  7488.  
  7489.  
  7490. ___________________________________________________________________________
  7491.  
  7492. TEGLReadkey Function                                               TEGLINTR
  7493. ___________________________________________________________________________
  7494.  
  7495.  
  7496.  Programmer's Reference Guide       - 123 -         TEGL Windows Toolkit
  7497.  
  7498.  
  7499.  
  7500.  
  7501.  
  7502.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7503.  
  7504.  
  7505. Function
  7506.                    Reads a scan code from the TEGL keyboard buffer.
  7507. Declaration
  7508.                    TEGLReadkey
  7509. Result type
  7510.                    Returns the first captured scan code in the TEGL
  7511.                    keyboard buffer.
  7512. Restrictions
  7513.                    Use TEGLKeyPressed to check if any scan codes are
  7514.                    in the TEGL keyboard buffer.
  7515. See also
  7516.                    TEGLKeyPressed
  7517.  
  7518.  
  7519.  
  7520. ___________________________________________________________________________
  7521.  
  7522. TEGLKeyPressed Function                                            TEGLINTR
  7523. ___________________________________________________________________________
  7524.  
  7525.  
  7526. Function
  7527.                    Returns True if a scan code is captured; False
  7528.                    otherwise.
  7529. Declaration
  7530.                    TEGLKeyPressed
  7531. Result type
  7532.                    Boolean
  7533. Remarks
  7534.                    The scan code is added to the TEGL keyboard buffer.
  7535. See also
  7536.                    TEGLReadKey
  7537.  
  7538.  
  7539.  
  7540. ___________________________________________________________________________
  7541.  
  7542. NilKeyCallProc Function                                            TEGLINTR
  7543. ___________________________________________________________________________
  7544.  
  7545.  
  7546. Function
  7547.                    Dummy function to use a place holder.
  7548. Declaration
  7549.                     NillKeyCallProc
  7550. Returns
  7551.                    Boolean.
  7552. Remarks
  7553.                    This function always returns false.
  7554. See also
  7555.                    AddCaptureKey.
  7556.  
  7557.  Programmer's Reference Guide       - 124 -         TEGL Windows Toolkit
  7558.  
  7559.  
  7560.  
  7561.  
  7562.  
  7563.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7564.  
  7565.  
  7566.  
  7567. Keyboard Miscellaneous
  7568.  
  7569.  
  7570. ___________________________________________________________________________
  7571.  
  7572. SetShiftKeys Procedure                                             TEGLINTR
  7573. ___________________________________________________________________________
  7574.  
  7575.  
  7576. Function
  7577.                    Toggles the Shift flags on/off.
  7578. Declaration
  7579.                    SetShiftKeys(ShiftFlag:byte; OnOff:boolean)
  7580. Remarks
  7581.                    Shiftflag may be one of the types as follows:
  7582.  
  7583.  
  7584.    TYPE
  7585.        Sk_RightShift  = $01;
  7586.        Sk_LeftShift   = $02;
  7587.        Sk_CtrlShift   = $04;
  7588.        Sk_AltShift    = $08;
  7589.        Sk_ScrollLock  = $10;
  7590.        Sk_NumLock     = $20;
  7591.        Sk_CapsLock    = $40;
  7592.        Sk_InsLock     = $80;
  7593.  
  7594.  
  7595.                    OnOff sets the above bits to on True or off
  7596.                    False.
  7597.  
  7598.  
  7599. Show Button Status
  7600.  
  7601. The TEGL.PAS demonstration program uses the DEBUGUNT.PAS unit to
  7602. display the mouse button status through a menu selection.
  7603.  
  7604.  
  7605. ___________________________________________________________________________
  7606.  
  7607. ShowButtonStatus Event                                             FONTTEST
  7608. ___________________________________________________________________________
  7609.  
  7610.  
  7611. Function
  7612.                    An Event that displays the mouse button status.
  7613. Remarks
  7614.                    Information is displayed on the number of times the
  7615.                    mouse buttons have been pressed and released. Shows the
  7616.                    last coordinates where the mouse button was pressed and
  7617.  
  7618.  Programmer's Reference Guide       - 125 -         TEGL Windows Toolkit
  7619.  
  7620.  
  7621.  
  7622.  
  7623.  
  7624.                Chapter 6 - Mouse, Keyboard and Timer Handlers
  7625.  
  7626.                    the coordinates where the mouse button was released.
  7627.  
  7628.  
  7629.  
  7630.  
  7631.  
  7632.  
  7633.  
  7634.  
  7635.  
  7636.  
  7637.  
  7638.  
  7639.  
  7640.  
  7641.  
  7642.  
  7643.  
  7644.  
  7645.  
  7646.  
  7647.  
  7648.  
  7649.  
  7650.  
  7651.  
  7652.  
  7653.  
  7654.  
  7655.  
  7656.  
  7657.  
  7658.  
  7659.  
  7660.  
  7661.  
  7662.  
  7663.  
  7664.  
  7665.  
  7666.  
  7667.  
  7668.  
  7669.  
  7670.  
  7671.  
  7672.  
  7673.  
  7674.  
  7675.  
  7676.  
  7677.  
  7678.  
  7679.  Programmer's Reference Guide       - 126 -         TEGL Windows Toolkit
  7680.  
  7681.  
  7682.  
  7683.  
  7684.  
  7685.                 Chapter 7 - Assembly Language Graphics
  7686.  
  7687.  
  7688. Assembler Graphics
  7689. ___________________________________________________________________________
  7690.  
  7691. The FASTGRPH unit is the engine that provides the speed that is seen
  7692. in the TEGL Windows Toolkit. Most of the graphics tools are written in
  7693. assembler, with some of the noncritical support routines written in
  7694. Pascal.
  7695.  
  7696. Between the FASTGRPH and TGRAPH units programs can be made that
  7697. require no other graphic support.
  7698.  
  7699. Graphics primitives are accessed through procedural pointers. When a
  7700. graphics mode is selected (EGA640x350x16 etc...) the pointers are
  7701. initialized point at the correct support routines. Graphics primitives
  7702. cannot be called before a graphics mode is selected. If they are called
  7703. then the program will probably crash severely and a reset may be required.
  7704.  
  7705.  
  7706. Setting Video Modes
  7707.  
  7708. The following Types and Consts relate to detecting and selecting video
  7709. modes.
  7710.  
  7711. The VidID type is passed as a parameter to VideoID to determine the
  7712. graphics equipment available.
  7713.  
  7714.      VidID = RECORD
  7715.        Video0Type   : Byte;
  7716.        Display0Type : Byte;
  7717.        Video1Type   : Byte;
  7718.        Display1Type : Byte;
  7719.      END;
  7720.  
  7721. The graphics adaptor card detected is returned in the Video0Type field.
  7722. Here are a list of the Constants and values and whether they are
  7723. currently supported by the toolkit.
  7724.  
  7725.      TG_None   = $00;    no graphics adaptor 
  7726.      TG_MDA    = $01;    monochome display, not supported 
  7727.      TG_CGA    = $02;    Color graphics, supported 
  7728.      TG_EGA    = $03;    Enhanced graphics, supported 
  7729.      TG_MCGA   = $04;    Multicolor graphics array, not supported 
  7730.      TG_VGA    = $05;    Video graphics array, not supported 
  7731.      TG_HGC    = $80;    Hercules graphics, supported 
  7732.      TG_HGCPlus= $81;    Hercules plus, not supported 
  7733.      TG_InColor= $82;    Hercules incolor, no supported 
  7734.  
  7735.  
  7736.  
  7737. ___________________________________________________________________________
  7738.  
  7739.  
  7740.  Programmer's Reference Guide       - 127 -         TEGL Windows Toolkit
  7741.  
  7742.  
  7743.  
  7744.  
  7745.  
  7746.                 Chapter 7 - Assembly Language Graphics
  7747.  
  7748. CGA640x200x2 Procedure                                             FASTGRPH
  7749. ___________________________________________________________________________
  7750.  
  7751.  
  7752. Function
  7753.                    Sets the video mode to 640 x 200 in 2 colors.
  7754. Declaration
  7755.                    CGA640x200x2
  7756. Remarks
  7757.                    This procedure switches to graphics mode and sets the
  7758.                    pointers for the graphics primitives.
  7759. See also
  7760.                    Herc720x348x2, EGA640x350x16, VGA640x480x16.
  7761.  
  7762.  
  7763.  
  7764.  
  7765. ___________________________________________________________________________
  7766.  
  7767. EGA640x350x16 Procedure                                            FASTGRPH
  7768. ___________________________________________________________________________
  7769.  
  7770.  
  7771. Function
  7772.                    Sets the video mode to 640 x 350 in 16 colors.
  7773. Declaration
  7774.                    EGA640x350x16
  7775. Remarks
  7776. See also
  7777.                    VGA640x480x16, Graph Unit
  7778.  
  7779.  
  7780.  
  7781. ___________________________________________________________________________
  7782.  
  7783. Herc720x200x2 Procedure                                            FASTGRPH
  7784. ___________________________________________________________________________
  7785.  
  7786.  
  7787. Function
  7788.                    Sets the video mode to 720 x 200 in 2 colors.
  7789. Declaration
  7790.                    Herc720x348x2
  7791. Remarks
  7792.                    This procedure switches to graphics mode and sets the
  7793.                    pointers for the graphics primitives.
  7794. See also
  7795.                    CGA640x200x2, EGA640x350x16, VGA640x480x16.
  7796.  
  7797.  
  7798.  
  7799. ___________________________________________________________________________
  7800.  
  7801.  Programmer's Reference Guide       - 128 -         TEGL Windows Toolkit
  7802.  
  7803.  
  7804.  
  7805.  
  7806.  
  7807.                 Chapter 7 - Assembly Language Graphics
  7808.  
  7809.  
  7810. SetVideoChoices                                                    FASTGRPH
  7811. ___________________________________________________________________________
  7812.  
  7813.  
  7814.  
  7815. Function
  7816.                    Sets the allowable video modes.
  7817. Declaration
  7818.                    SetVideoChoices(VMode : Word; Accept : Boolean);
  7819. Remarks
  7820.                    By default all video modes are acceptable. Certain
  7821.                    programs may not support all video modes.
  7822. See also
  7823.                    VideoID, VideoAutoDetect.
  7824. Example
  7825.                    This statement would cause the program to abort if
  7826.                    it were run on a machine which only supported CGA
  7827.                    graphics.
  7828.  
  7829.  
  7830.   SetVideoChoices(TG_CGA,FALSE);
  7831.  
  7832.  
  7833.  
  7834.  
  7835.  
  7836. ___________________________________________________________________________
  7837.  
  7838. SVGA800x600x16                                                     FASTGRPH
  7839. ___________________________________________________________________________
  7840.  
  7841.  
  7842. Function
  7843.                    Sets the video mode to 800 x 600 in 2 colors.
  7844. Declaration
  7845.                    SVGA800x600x16;
  7846. Remarks
  7847.                    Requires hardware and screen that provide super VGA
  7848.                    resolutions.
  7849. See also
  7850.                    CGA640x200x2, EGA640x350x16, Herc720x348x2,
  7851.                      VGA640x480x16
  7852.  
  7853.  
  7854.  
  7855.  
  7856. ___________________________________________________________________________
  7857.  
  7858. VGA640x480x16 Procedure                                            FASTGRPH
  7859. ___________________________________________________________________________
  7860.  
  7861.  
  7862.  Programmer's Reference Guide       - 129 -         TEGL Windows Toolkit
  7863.  
  7864.  
  7865.  
  7866.  
  7867.  
  7868.                 Chapter 7 - Assembly Language Graphics
  7869.  
  7870.  
  7871. Function
  7872.                    Sets the video mode to 640 x 480 in 16 colors.
  7873. Declaration
  7874.                    VGA640x480x16
  7875. Remarks
  7876.                    This procedure switches to graphics mode and sets the
  7877.                    pointers for the graphics primitives.
  7878. Restrictions
  7879.                    Requires a VGA card and monitor.
  7880. See also
  7881.                    CGA640x200x2, EGA640x350x16, Herc720x348x2.
  7882.  
  7883.  
  7884.  
  7885. ___________________________________________________________________________
  7886.  
  7887. VideoAutoDetect                                                    FASTGRPH
  7888. ___________________________________________________________________________
  7889.  
  7890.  
  7891.  
  7892. Function
  7893.                    Detects the graphics equipment and switches to graphics
  7894.                    mode if available.
  7895. Declaration
  7896.                    VideoAutoDetect;
  7897. Remarks
  7898.                    Selects the highest resolution that is available and
  7899.                    supported.
  7900.  
  7901.                    The global variable InitDriverCode can be
  7902.                    examinded to determine the video mode set.
  7903. See also
  7904.                    VideoID
  7905.  
  7906.  
  7907.  
  7908. ___________________________________________________________________________
  7909.  
  7910. VideoID                                                            FASTGRPH
  7911. ___________________________________________________________________________
  7912.  
  7913.  
  7914.  
  7915. Function
  7916.                    Detects the graphics equipment available.
  7917. Declaration
  7918.                    VideoID(VAR v : VidID);
  7919. Remarks
  7920.                    Graphics equipment is only detected. The current
  7921.                    video mode is not changed.
  7922.  
  7923.  Programmer's Reference Guide       - 130 -         TEGL Windows Toolkit
  7924.  
  7925.  
  7926.  
  7927.  
  7928.  
  7929.                 Chapter 7 - Assembly Language Graphics
  7930.  
  7931.  
  7932.  
  7933.  
  7934. Graphic Primitives
  7935.  
  7936. Turbo Pascal offers a rich set of graphics commands, that work with almost
  7937. any video display. However, the drawback to the flexibility of Turbo
  7938. Pascal's BGI Graphics is the speed at which the graphics are displayed.
  7939.  
  7940. To provide a toolset that could operate quickly, the following assembler
  7941. graphic routines were written to replace the ones offered by TP.
  7942.  
  7943. Other then the documented restrictions you may freely mix and match
  7944. Turbo's graphic routines with TEGL's.
  7945.  
  7946. The following constants are defined in the FASTGRPH unit and may be
  7947. assigned to RMWBITS to define the type of binary operation between
  7948. each byte in the line and the corresponding bytes on the screen.
  7949.  
  7950.    VAR
  7951.        RMWBITS    : WORD;
  7952.  
  7953.    TYPE
  7954.        FGNORM     = 0;
  7955.        FGAND      = $08;
  7956.        FGOR       = $10;
  7957.        FGXOR      = $18;
  7958.        FGNOT      = $80;
  7959.  
  7960.  
  7961.  
  7962.  
  7963. ___________________________________________________________________________
  7964.  
  7965. FastLine Procedure                                                 FASTGRPH
  7966. ___________________________________________________________________________
  7967.  
  7968.  
  7969. Function
  7970.                    Draws a line from (x,y) to (x1,y2).
  7971. Declaration
  7972.                    FastLine (x,y,x1,y2,n:word)
  7973. Remarks
  7974.                    Sets the global variable RMWBITS to the
  7975.                    appropriate mode for drawing the line.
  7976.  
  7977.                    x,y specifies the line starting coordinates.
  7978.  
  7979.                    x1,y1 specifies the line ending coordinates.
  7980.  
  7981.                    n specifies the color of the line.
  7982.  
  7983.  
  7984.  Programmer's Reference Guide       - 131 -         TEGL Windows Toolkit
  7985.  
  7986.  
  7987.  
  7988.  
  7989.  
  7990.                 Chapter 7 - Assembly Language Graphics
  7991.  
  7992.                    Fastline will only draw a continuous line. 
  7993.                    SetLineStyle, SetColor and SetWriteMode has no
  7994.                    effect on Fastline.
  7995. See also
  7996.                    Turbo Pascal Reference Manual sh Line
  7997.  
  7998.  
  7999.  
  8000. ___________________________________________________________________________
  8001.  
  8002. Putpixs Procedure                                                  FASTGRPH
  8003. ___________________________________________________________________________
  8004.  
  8005.  
  8006. Function
  8007.                    Plots a pixel at x,y.
  8008. Declaration
  8009.                    PutPixs (x,y,n:word)
  8010. Remarks
  8011.                    Plots a point in the color defined by n at (x,y).
  8012.  
  8013.                    Set the global variable RMWBITS to the appropriate
  8014.                    mode for plotting the pixel.
  8015.  
  8016.                    Putpixs replaces the PutPixel routine in the Graph
  8017.                    Unit.
  8018. See also
  8019.                    Getpixs, Turbo Pascal Reference Manual sh
  8020.                    PutPixel
  8021.  
  8022.  
  8023.  
  8024. ___________________________________________________________________________
  8025.  
  8026. Getpixs Function                                                   FASTGRPH
  8027. ___________________________________________________________________________
  8028.  
  8029.  
  8030. Function
  8031.                    Return the pixel value at x,y.
  8032. Declaration
  8033.                    Getpixs (x,y:word)
  8034. Result type
  8035.                    Word.
  8036. Remarks
  8037.                    Gets the pixel color at (x,y).
  8038.  
  8039.                    Getpixs replaces the GetPixel routine in the Graph
  8040.                    Unit.
  8041. See also
  8042.                    Putpixs, Turbo Pascal Reference Manual sh
  8043.                    GetPixel
  8044.  
  8045.  Programmer's Reference Guide       - 132 -         TEGL Windows Toolkit
  8046.  
  8047.  
  8048.  
  8049.  
  8050.  
  8051.                 Chapter 7 - Assembly Language Graphics
  8052.  
  8053.  
  8054.  
  8055.  
  8056.  
  8057. ___________________________________________________________________________
  8058.  
  8059. Getbiti Procedure                                                  FASTGRPH
  8060. ___________________________________________________________________________
  8061.  
  8062.  
  8063. Function
  8064.                    Copies the specified screen image into a buffer.
  8065. Declaration
  8066.                    Getbiti(x,y,x1,y1:word;buffer:pointer)
  8067. Remarks
  8068.                    x,y,x1,y1 defines a rectangular region on the screen.
  8069.  
  8070.                    buffer is a memory area that may be allocated by
  8071.                    GetMem or TEGLGetMem.
  8072.  
  8073.                    Getbiti replaces the GetImage routine in the Graph
  8074.                    Unit.  By using TEGLGetmem with BigImageSize,
  8075.                    Getbiti will allow saving of images larger than 64k.
  8076. Restrictons
  8077.                    The saved image structure of Getbiti and 
  8078.                    Putbiti is different than what Turbo Pascal's 
  8079.                    GetImage and PutImage use.
  8080. See also
  8081.                    Putbiti, BigImageSize
  8082.  
  8083.  
  8084.  
  8085. ___________________________________________________________________________
  8086.  
  8087. Putbiti Procedure                                                  FASTGRPH
  8088. ___________________________________________________________________________
  8089.  
  8090.  
  8091. Function
  8092.                     Copies the buffer to the specified screen area.
  8093. Declaration
  8094.                     Putbiti(x,y : word; buffer : pointer; RMWbits : word)
  8095. Remarks
  8096.                    x,y defines the upper left corner of the screen
  8097.                    area for placing the saved image.
  8098.  
  8099.                    buffer is the image buffer that contains a copy of
  8100.                    the screen image saved previously by Getbiti.
  8101.  
  8102.                    RMWbits defines the type of binary operation
  8103.                    between the saved image and the corresponding bytes on
  8104.                    the screen.
  8105.  
  8106.  Programmer's Reference Guide       - 133 -         TEGL Windows Toolkit
  8107.  
  8108.  
  8109.  
  8110.  
  8111.  
  8112.                 Chapter 7 - Assembly Language Graphics
  8113.  
  8114.  
  8115.                    Putbiti replaces the PutImage routine in the Graph
  8116.                    Unit.  By using TEGLGetmem with BigImageSize,
  8117.                     Putbiti will allow the saving and restoring of
  8118.                    images larger then 64k.
  8119. Restrictons
  8120.                    The saved image structure of Getbiti and 
  8121.                    Putbiti is different than what Turbo Pascal's 
  8122.                    GetImage and PutImage use.
  8123. See also
  8124.                    Getbiti, BigImageSize
  8125.  
  8126.  
  8127.  
  8128. ___________________________________________________________________________
  8129.  
  8130. BigImageSize Function                                              FASTGRPH
  8131. ___________________________________________________________________________
  8132.  
  8133.  
  8134. Function
  8135.                    Calculates the size of the image buffer.
  8136. Declaration
  8137.                    BigImageSize(x,y,x1,y1:word) : LongInt
  8138. Result type
  8139.                    Longint.
  8140. Remarks
  8141.                    x,y,x1,y1 defines the rectangular coordinates that
  8142.                    will be used for Getbiti.
  8143.  
  8144.                    BigImageSize replaces Turbo Pascal's 
  8145.                    ImageSize routine. By using TEGLGetmem with 
  8146.                    BigImageSize, image buffers may be larger then 64k.
  8147. See also
  8148.                    Getbiti, Putbiti
  8149.  
  8150.  
  8151.  
  8152. ___________________________________________________________________________
  8153.  
  8154. SetAPage Procedure                                                 FASTGRPH
  8155. ___________________________________________________________________________
  8156.  
  8157.  
  8158. Function
  8159.                    Sets the active page for graphics output.
  8160. Declaration
  8161.                    SetAPage(pagenum:word)
  8162. Remarks
  8163.                    Makes pagenum the active graphics page. All output,
  8164.                     including those from Turbo Pascal's graphics routines,
  8165.                    will be directed to pagenum.
  8166.  
  8167.  Programmer's Reference Guide       - 134 -         TEGL Windows Toolkit
  8168.  
  8169.  
  8170.  
  8171.  
  8172.  
  8173.                 Chapter 7 - Assembly Language Graphics
  8174.  
  8175.  
  8176.                    Only two pages are supported with the EGA's
  8177.                    640 x 350 x 16 mode.
  8178.  
  8179.                    SetAPage replaces the Turbo Pascal's 
  8180.                    SetActivePage procedure.
  8181. See also
  8182.                    SetVPage, FlipAPage, FlipVPage, VideoPage
  8183.  
  8184.  
  8185.  
  8186. ___________________________________________________________________________
  8187.  
  8188. SetVPage Procedure                                                 FASTGRPH
  8189. ___________________________________________________________________________
  8190.  
  8191.  
  8192. Function
  8193.                    Sets the visual graphics page number.
  8194. Declaration
  8195.                    SetVPage(pagenum:word)
  8196. Remarks
  8197.                    Makes pagenum the visual graphics page. All output,
  8198.                    including that from Turbo Pascals's graphics routines,
  8199.                    will still be directed to the active pagenum.
  8200.  
  8201.                    Only two pages are supported with the EGA's
  8202.                    640 x 350 x 16 mode.
  8203.  
  8204.                    SetVPage replaces the TP's SetVisualPage
  8205.                    procedure.
  8206. See also
  8207.                    SetAPage, FlipAPage, FlipVPage, VideoPage
  8208.  
  8209.  
  8210.  
  8211. ___________________________________________________________________________
  8212.  
  8213. FlipAPage Procedure                                                FASTGRPH
  8214. ___________________________________________________________________________
  8215.  
  8216.  
  8217. Function
  8218. Flips the active page to the alternate page.
  8219. Declaration
  8220. FlipAPage
  8221. Remarks
  8222.                    Makes the alternate page the active graphics page. All
  8223.                    output, including that from Turbo Pascal's graphics
  8224.                    routines, will be directed to the new active page.
  8225.  
  8226.                    Only two pages are supported with the EGA's 640 x 350 x
  8227.  
  8228.  Programmer's Reference Guide       - 135 -         TEGL Windows Toolkit
  8229.  
  8230.  
  8231.  
  8232.  
  8233.  
  8234.                 Chapter 7 - Assembly Language Graphics
  8235.  
  8236.                    16 mode. If the current active page is (1), 
  8237.                    FlipAPage will set the active page to (2). The reverse
  8238.                    is true, if the current active page is (2).
  8239.  
  8240.                    FlipAPage does not have an equivalent in the 
  8241.                    Graph Unit.
  8242. See also
  8243.                    SetAPage, SetVPage, FlipVPage, VideoPage
  8244.  
  8245.  
  8246.  
  8247. ___________________________________________________________________________
  8248.  
  8249. FlipVPage Procedure                                                FASTGRPH
  8250. ___________________________________________________________________________
  8251.  
  8252.  
  8253. Function
  8254.                    Flips the visual page to the alternate page.
  8255. Declaration
  8256.                    FlipVPage
  8257. Remarks
  8258.                    Makes the alternate page the visual graphics page.
  8259.  
  8260.                    Only two pages are supported with EGA's 640 x 350 x 16.
  8261.                    If the current visual page is (1), FlipVPage will
  8262.                    set the visual page to (2). The reverse is true, if the
  8263.                    current visual page is (2).
  8264.  
  8265.                    FlipVPage does not have an equivalent in the 
  8266.                    Graph Unit.
  8267. See also
  8268.                    SetAPage, SetVPage, FlipAPage, VideoPage
  8269.  
  8270.  
  8271.  
  8272. ___________________________________________________________________________
  8273.  
  8274. VideoPage Function                                                 FASTGRPH
  8275. ___________________________________________________________________________
  8276.  
  8277.  
  8278. Function
  8279.                    Returns the current Visual page.
  8280. Declaration
  8281.                    VideoPage
  8282. Result type
  8283.                    Word.
  8284. Remarks
  8285.                    Returns the current visual graphics page.
  8286.  
  8287.                    Only two pages are supported with the EGA's
  8288.  
  8289.  Programmer's Reference Guide       - 136 -         TEGL Windows Toolkit
  8290.  
  8291.  
  8292.  
  8293.  
  8294.  
  8295.                 Chapter 7 - Assembly Language Graphics
  8296.  
  8297.                    640 x 350 x 16 mode.
  8298.  
  8299.                    VideoPage does not have an equivalent in the 
  8300.                    Graph Unit.
  8301. See also
  8302.                    SetAPage, SetVPage, FlipAPage, FlipVPage
  8303.  
  8304.  
  8305.  
  8306. New Graphic Primitives
  8307.  
  8308. The TEGL Windows Tookit's ability to display fast graphics is, in a way,
  8309. just the tip of the iceberg. The following routines provide functions to
  8310. extract and overlay buffered images before displaying the final results on
  8311. the screen.
  8312.  
  8313. Some of these routines may be used to create a virtual image (an image
  8314. larger then the size of the screen). The only limitation at this time is
  8315. the need for graphic primitives that will draw to a buffered image.
  8316.  
  8317.  
  8318.  
  8319. ___________________________________________________________________________
  8320.  
  8321. Extractpixs Function                                               FASTGRPH
  8322. ___________________________________________________________________________
  8323.  
  8324.  
  8325. Function
  8326.                    Return the pixel value at x,y within an image
  8327.                    buffer.
  8328. Declaration
  8329.                    Extractpixs (x,y:word; buffer:pointer)
  8330. Result type
  8331.                    Word
  8332. Remarks
  8333.                    Gets the pixel color at (x,y) within the saved
  8334.                    image buffer.
  8335.  
  8336.  
  8337.  
  8338. ___________________________________________________________________________
  8339.  
  8340. ExtractIMG Procedure                                               FASTGRPH
  8341. ___________________________________________________________________________
  8342.  
  8343.  
  8344. Function
  8345.                    Extracts an image area x,y,x1,y1 from buff2
  8346.                    to buff1.
  8347. Declaration
  8348.                    ExtractIMG(x,y,x1,y1:word;buff1,buff2:pointer)
  8349.  
  8350.  Programmer's Reference Guide       - 137 -         TEGL Windows Toolkit
  8351.  
  8352.  
  8353.  
  8354.  
  8355.  
  8356.                 Chapter 7 - Assembly Language Graphics
  8357.  
  8358. Remarks
  8359.                    Returns a partial image in buff1 from buff2.
  8360. See also
  8361.                    OverlayIMG, PutBiti, GetBiti
  8362.  
  8363.  
  8364.  
  8365.  
  8366. ___________________________________________________________________________
  8367.  
  8368. OverlayIMG Procedure                                               FASTGRPH
  8369. ___________________________________________________________________________
  8370.  
  8371.  
  8372. Function
  8373.                    Overlays image buff1 to buff2 at x,y
  8374.                    offsets.
  8375. Declaration
  8376.                    OverlayIMG(x,y:word;buff1,buff2:pointer)
  8377. Remarks
  8378.                    Overlays an image in buff1 to buff2.
  8379. See also
  8380.                    ExtractIMG, PutBiti, GetBiti
  8381.  
  8382.  
  8383.  
  8384. ___________________________________________________________________________
  8385.  
  8386. SwapBytes Procedure                                                FASTGRPH
  8387. ___________________________________________________________________________
  8388.  
  8389.  
  8390. Function
  8391.                    Swaps two buffers.
  8392. Declaration
  8393.                    SwapBytes(buff1,buff2:pointer; bytestoswap:longint)
  8394.  
  8395. Remarks
  8396.                    Swaps the images within buff1 with buff2.
  8397.  
  8398.  
  8399.  
  8400. Graphic Derivatives
  8401.  
  8402. The following are some fast common routines to create XOR boxes that
  8403. can be erased simply by calling the routine again.
  8404.  
  8405. XORing pixels to the screen has the unique feature that when the same
  8406. pixel is XORed to the same location a second time the pixel is restored to
  8407. it's original look.
  8408.  
  8409. The XOR box routines here allow boxes to flit and dance across the screen
  8410.  
  8411.  Programmer's Reference Guide       - 138 -         TEGL Windows Toolkit
  8412.  
  8413.  
  8414.  
  8415.  
  8416.  
  8417.                 Chapter 7 - Assembly Language Graphics
  8418.  
  8419. without (if used correctly) changing any of the underlying display.
  8420.  
  8421.  
  8422.  
  8423. ___________________________________________________________________________
  8424.  
  8425. XORCornerBox Procedure                                             FASTGRPH
  8426. ___________________________________________________________________________
  8427.  
  8428.  
  8429. Function
  8430.                    Creates box corners only.
  8431. Declaration
  8432.                    XORCornerBox (x,y,x1,y1,color : integer)
  8433. Remarks
  8434.                    x,y,x1,y1 are the coordinates of a rectangle.
  8435.  
  8436.                    This routine is used in Ziptobox and Zipfrombox
  8437.                    to create the shrinking and expanding corner images.
  8438.  
  8439.  
  8440.  
  8441. ___________________________________________________________________________
  8442.  
  8443. XORBox Procedure                                                   FASTGRPH
  8444. ___________________________________________________________________________
  8445.  
  8446.  
  8447. Function
  8448.                    Draws a (xor) rectangle.
  8449. Declaration
  8450.                    XORBox (x,y,x1,y1,color : integer)
  8451. Remarks
  8452.                    (x,y) define the upper left corner of a rectangle,
  8453.                    and (x1,y1)  define the lower right corner.
  8454.                    Coordinates must be within the physical screen.
  8455.  
  8456.                    This  routine is used in MoveFrame to move an (xor)
  8457.                    box image around.
  8458.  
  8459.  
  8460. Icon Graphics
  8461.  
  8462.  
  8463. ___________________________________________________________________________
  8464.  
  8465. Putpict Procedure                                                  FASTGRPH
  8466. ___________________________________________________________________________
  8467.  
  8468.  
  8469. Function
  8470.                    Puts an icon to a specified screen area.
  8471.  
  8472.  Programmer's Reference Guide       - 139 -         TEGL Windows Toolkit
  8473.  
  8474.  
  8475.  
  8476.  
  8477.  
  8478.                 Chapter 7 - Assembly Language Graphics
  8479.  
  8480. Declaration
  8481.                    Putpict (x,y:word; buf:pointer;n:word)
  8482. Remarks
  8483.                    x,y defines the upper left corner of the screen
  8484.                    area for placing the icon image.
  8485.  
  8486.                    buf points to the icon image.
  8487.  
  8488.                    n is the default color for any pixel that is
  8489.                    black within the icon.
  8490. Restrictions
  8491.                    Icons are stored in a unique fashion, these are not
  8492.                    bit images in the conventional sense. Icons are created
  8493.                    and maintained using the Icon Editor and support
  8494.                    programs.
  8495. See also
  8496.                    PictSize, Icon Editor.
  8497.  
  8498.  
  8499. ___________________________________________________________________________
  8500.  
  8501. PictSize Procedure                                                 FASTGRPH
  8502. ___________________________________________________________________________
  8503.  
  8504.  
  8505. Function
  8506.                    Gets the width and height in pixels of an icon image.
  8507. Declaration
  8508.                    PictSize(VAR Width,Height: Word; Buffer: Pointer);
  8509. Remarks
  8510.                    Buffer must point to a valid icon image.
  8511. See also
  8512.                    PutPict, Icon Editor.
  8513.  
  8514.  
  8515.  
  8516. ___________________________________________________________________________
  8517.  
  8518. Abort Procedure                                                    FASTGRPH
  8519. ___________________________________________________________________________
  8520.  
  8521.  
  8522. Function
  8523.                    Closes the graphics system and displays the message
  8524.                    string.
  8525. Declaration
  8526.                    Abort(Msg : string)
  8527. Remarks
  8528.                    This routine is defined in Fastgrph because of the
  8529.                    need for closing the graphics system and returning to
  8530.                    text mode before the message can be displayed.
  8531.  
  8532.  
  8533.  Programmer's Reference Guide       - 140 -         TEGL Windows Toolkit
  8534.  
  8535.  
  8536.  
  8537.  
  8538.  
  8539.                 Chapter 7 - Assembly Language Graphics
  8540.  
  8541.  
  8542.  
  8543.  
  8544.  
  8545.  
  8546.  
  8547.  
  8548.  
  8549.  
  8550.  
  8551.  
  8552.  
  8553.  
  8554.  
  8555.  
  8556.  
  8557.  
  8558.  
  8559.  
  8560.  
  8561.  
  8562.  
  8563.  
  8564.  
  8565.  
  8566.  
  8567.  
  8568.  
  8569.  
  8570.  
  8571.  
  8572.  
  8573.  
  8574.  
  8575.  
  8576.  
  8577.  
  8578.  
  8579.  
  8580.  
  8581.  
  8582.  
  8583.  
  8584.  
  8585.  
  8586.  
  8587.  
  8588.  
  8589.  
  8590.  
  8591.  
  8592.  
  8593.  
  8594.  Programmer's Reference Guide       - 141 -         TEGL Windows Toolkit
  8595.  
  8596.  
  8597.  
  8598.  
  8599.  
  8600.                      Chapter 8 - Special Effects
  8601.  
  8602.  
  8603. Special Effects
  8604. ___________________________________________________________________________
  8605.  
  8606. The TEGLGrph unit has a nice collection of graphic effects that may
  8607. be used to create 3D characters, shadow boxes, long icon buttons, etc..
  8608.  
  8609. These routines may be combined with Turbo Pascal's BGI fonts and graphics for even
  8610. more effects.
  8611.  
  8612. We suggest that if you build other graphic effects they should support a
  8613. standard parameter list. Specifically coordinates should be ordered
  8614. x, y, x1, y where x, y are the upper left coordinates and
  8615. x1, y1 are the lower right coordinates of an area on the screen.
  8616.  
  8617.  
  8618. Screen Backdrop
  8619.  
  8620. The backdrop is normally the full physical screen filled with a color and
  8621. pattern to give the effect of a mat. On this mat we place icons and open
  8622. up windows. It's like the velvet mat a Jeweler uses to show off gem stones.
  8623.  
  8624. The backdrop does not require a window frame to draw on.
  8625.  
  8626.  
  8627. ___________________________________________________________________________
  8628.  
  8629. ClearTEGLScreen Procedure                                          TEGLGRPH
  8630. ___________________________________________________________________________
  8631.  
  8632.  
  8633. Function
  8634.                    Clears the screen to the backdrop pattern.
  8635. Declaration
  8636.                    ClearTEGLScreen
  8637. Remarks
  8638.                    Fills the complete screen using the bitmask found in
  8639.                    TEGLBackPattern or TEGLFillStyle with the
  8640.                    background color of TEGLBackColor. Completes the
  8641.                    clearing by placing a border if TEGLBorderShow is
  8642.                    TRUE in the color of TEGLBorderColor.
  8643.  
  8644.                    The default is a gray matted area with white borders.
  8645. Restrictions
  8646.                    Must be in Graphics mode.
  8647. See also
  8648.                    SetTEGLBorderShow, SetTEGLBackColor,
  8649.                    SetTEGLBorderColor, SetTEGLFillPattern,
  8650.                    SetTEGLFillStyle
  8651. Example
  8652.  
  8653.  
  8654.  
  8655.  Programmer's Reference Guide       - 142 -         TEGL Windows Toolkit
  8656.  
  8657.  
  8658.  
  8659.  
  8660.  
  8661.                      Chapter 8 - Special Effects
  8662.  
  8663.   EGA640x350x16;        { -- Sets the graphics mode }
  8664.   SetMouseMinMax(0,0,GetMaxX,GetMaxY);
  8665.  
  8666.   ClearTEGLScreen;
  8667.  
  8668.  
  8669.  
  8670.  
  8671.  
  8672. ___________________________________________________________________________
  8673.  
  8674. SetTEGLBorderShow Procedure                                        TEGLGRPH
  8675. ___________________________________________________________________________
  8676.  
  8677.  
  8678. Function
  8679.                    Sets the switch on whether a border should be drawn or
  8680.                    not drawn after the bar fill.
  8681. Declaration
  8682.                    SetTEGLBorderShow(BorderShow:boolean)
  8683. Remarks
  8684.                    Switches the border on=TRUE or off=FALSE when
  8685.                    TEGLClearScreen is called.
  8686.  
  8687.                    The default is on TRUE.
  8688. Restrictions
  8689.                    Must be called before calling TEGLClearScreen.
  8690. See also
  8691.                    TEGLClearScreen, SetTEGLBackColor,
  8692.                    SetTEGLBorderColor, SetTEGLFillPattern,
  8693.                    SetTEGLFillStyle
  8694. Example
  8695.  
  8696.  
  8697.   SetTEGLBorderShow(FALSE);
  8698.   ClearTEGLScreen;
  8699.  
  8700.  
  8701.  
  8702.  
  8703.  
  8704. ___________________________________________________________________________
  8705.  
  8706. SetTEGLBackColor Procedure                                         TEGLGRPH
  8707. ___________________________________________________________________________
  8708.  
  8709.  
  8710. Function
  8711.                    Sets the color of the backdrop.
  8712. Declaration
  8713.                    SetTEGLBackColor(BackColor:word)
  8714. Remarks
  8715.  
  8716.  Programmer's Reference Guide       - 143 -         TEGL Windows Toolkit
  8717.  
  8718.  
  8719.  
  8720.  
  8721.  
  8722.                      Chapter 8 - Special Effects
  8723.  
  8724.                    Sets the background color for the backdrop to 
  8725.                    BackColor.
  8726.  
  8727.                    The default is WHITE.
  8728. Restrictions
  8729.                    Must be called before calling TEGLClearScreen.
  8730. See also
  8731.                    TEGLClearScreen, SetTEGLBorderShow,
  8732.                    SetTEGLBorderColor, SetTEGLFillPattern,
  8733.                    SetTEGLFillStyle
  8734. Example
  8735.  
  8736.  
  8737.   SetTEGLBackColor(GREEN);
  8738.   ClearTEGLScreen;
  8739.  
  8740.  
  8741.  
  8742.  
  8743.  
  8744. ___________________________________________________________________________
  8745.  
  8746. SetTEGLBorderColor Procedure                                       TEGLGRPH
  8747. ___________________________________________________________________________
  8748.  
  8749.  
  8750. Function
  8751.                    Sets the border color of the backdrop.
  8752. Declaration
  8753.                    SetTEGLBorderColor(BorderColor:word)
  8754. Remarks
  8755.                    Sets the border color for the backdrop to 
  8756.                    BorderColor.
  8757.  
  8758.                    The default is WHITE.
  8759. Restrictions
  8760.                    Must be called before calling TEGLClearScreen.
  8761. See also
  8762.                    TEGLClearScreen, SetTEGLBorderShow,
  8763.                    SetTEGLBackColor, SetTEGLFillPattern, SetTEGLFillStyle
  8764.  
  8765. Example
  8766.  
  8767.  
  8768. SetTEGLBorderColor(BROWN);
  8769. ClearTEGLScreen;
  8770.  
  8771.  
  8772.  
  8773.  
  8774.  
  8775. ___________________________________________________________________________
  8776.  
  8777.  Programmer's Reference Guide       - 144 -         TEGL Windows Toolkit
  8778.  
  8779.  
  8780.  
  8781.  
  8782.  
  8783.                      Chapter 8 - Special Effects
  8784.  
  8785.  
  8786. SetTEGLFillPattern Procedure                                       TEGLGRPH
  8787. ___________________________________________________________________________
  8788.  
  8789.  
  8790. Function
  8791.                    Sets the Fill pattern for the backdrop.
  8792. Declaration
  8793.                    SetTEGLFillPattern(backpattern:FillPatternType)
  8794.  
  8795. Remarks
  8796.                    Sets the fill pattern for the backdrop to 
  8797.                    backpattern.
  8798.  
  8799.                    The default is defined as a constant:
  8800.  
  8801.  
  8802. CONST
  8803.   TEGLBackPattern : FillPatternType =
  8804.   ($AA,$55,$AA,$55,$AA,$55,$AA,$55);
  8805.  
  8806.  
  8807. Restrictions
  8808.                    Must be called befor calling TEGLClearScreen.
  8809. See also
  8810.                    TEGLClearScreen, SetTEGLBorderShow,
  8811.                    SetTEGLBackColor, SetTEGLBorderColor, SetTEGLFillStyle
  8812.  
  8813. Example
  8814.  
  8815.  
  8816.  
  8817. CONST
  8818.    MyPattern : FillPatternType =
  8819.      ($FF,$22,$FF,$22,$FF,$22,$FF,$22);
  8820.  
  8821.   SetTEGLFillPattern(MyPattern);
  8822.   ClearTEGLScreen;
  8823.  
  8824.  
  8825.  
  8826.  
  8827.  
  8828.  
  8829. ___________________________________________________________________________
  8830.  
  8831. SetTEGLFillStyle Procedure                                         TEGLGRPH
  8832. ___________________________________________________________________________
  8833.  
  8834.  
  8835. Function
  8836.                    Sets the Fill style for the backdrop.
  8837.  
  8838.  Programmer's Reference Guide       - 145 -         TEGL Windows Toolkit
  8839.  
  8840.  
  8841.  
  8842.  
  8843.  
  8844.                      Chapter 8 - Special Effects
  8845.  
  8846. Declaration
  8847.                    SetTEGLFillStyle(pattern:word)
  8848. Remarks
  8849.                    Sets the fill style to pattern.
  8850.  
  8851.                    Use one of the predefined fill styles in the Graph
  8852.                    Unit.
  8853.  
  8854.                    Setting the fill style cancels the user defined
  8855.                    pattern.
  8856. Restrictions
  8857.                    Must be called before calling TEGLClearScreen.
  8858. See also
  8859.                    TEGLClearScreen, SetTEGLBorderShow,
  8860.                    SetTEGLBackColor, SetTEGLBorderColor,
  8861.                    SetTEGLFillPattern
  8862. Example
  8863.  
  8864.  
  8865.   SetTEGLFillPattern(SolidFill);
  8866.   ClearTEGLScreen;
  8867.  
  8868.  
  8869.  
  8870.  
  8871.  
  8872. Creating Shadow Boxes
  8873.  
  8874. A shadow box is a simple rectangular that has a shadow edge to give a
  8875. 3-dimensional effect.  A shadow box is the quickest method to clear a
  8876. window after PushImage.
  8877.  
  8878.  
  8879. ___________________________________________________________________________
  8880.  
  8881. ShadowBox Procedure                                                TEGLGRPH
  8882. ___________________________________________________________________________
  8883.  
  8884.  
  8885. Function
  8886.                    Creates a 3-D type box at the rectangular area defined
  8887.                    by x, y, x1, y1.
  8888. Declaration
  8889.                    ShadowBox(x,y,x1,y1 : word)
  8890. Remarks
  8891.                    x, y, x1, y1 defines the rectangular area for the
  8892.                    ShadowBox.
  8893.  
  8894.                    The default Bar SOLID fill color is 
  8895.                    WHITE with BLACK borders and BLACK shadow.
  8896. See also
  8897.                    SetShadowColor, SetShadowBorderColor,
  8898.  
  8899.  Programmer's Reference Guide       - 146 -         TEGL Windows Toolkit
  8900.  
  8901.  
  8902.  
  8903.  
  8904.  
  8905.                      Chapter 8 - Special Effects
  8906.  
  8907.                    SetShadowFillPattern, SetShadowFillStyle
  8908. Example
  8909.  
  8910.  
  8911.   PushImage(100,100,200,200);
  8912.   ShadowBox(100,100,200,200);
  8913.  
  8914.  
  8915.  
  8916.  
  8917.  
  8918. ___________________________________________________________________________
  8919.  
  8920. ShadowBoxText Procedure                                            TEGLGRPH
  8921. ___________________________________________________________________________
  8922.  
  8923.  
  8924. Function
  8925.                    Outputs a text string within a ShadowBox.
  8926. Declaration
  8927.                    ShadowBoxText(x,y,txtlen:word; textstr:string)
  8928. See also
  8929.                    ShadowBox
  8930. Example
  8931.  
  8932.  
  8933.   ShadowBoxText(100,100,200,'TEGL Systems Corporation');
  8934.  
  8935.  
  8936.  
  8937.  
  8938.  
  8939. ___________________________________________________________________________
  8940.  
  8941. SetShadowColor Procedure                                           TEGLGRPH
  8942. ___________________________________________________________________________
  8943.  
  8944.  
  8945. Function
  8946.                    Sets the Bar fill color.
  8947. Declaration
  8948.                    SetShadowColor(bcolor:word)
  8949. Remarks
  8950.                    bcolor defines the ShadowBox color.
  8951.  
  8952.                    The default Bar fill color is WHITE.
  8953. See also
  8954.                    ShadowBox, SetShadowBorderColor,
  8955.                    SetShadowFillPattern, SetShadowFillStyle
  8956. Example
  8957.  
  8958.  
  8959.  
  8960.  Programmer's Reference Guide       - 147 -         TEGL Windows Toolkit
  8961.  
  8962.  
  8963.  
  8964.  
  8965.  
  8966.                      Chapter 8 - Special Effects
  8967.  
  8968.  
  8969. PushImage(100,100,200,200);
  8970.   SetShadowColor(red);
  8971.   ShadowBox(100,100,200,200);
  8972.  
  8973.  
  8974.  
  8975.  
  8976.  
  8977. ___________________________________________________________________________
  8978.  
  8979. SetShadowBorderColor Procedure                                     TEGLGRPH
  8980. ___________________________________________________________________________
  8981.  
  8982.  
  8983. Function
  8984.                    Sets the ShadowBox border color.
  8985. Declaration
  8986.                    SetShadowBorderColor(bcolor:word)
  8987. Remarks
  8988.                    bcolor defines the ShadowBox border color.
  8989.  
  8990.                    The default border color is BLACK.
  8991. See also
  8992.                    ShadowBox, SetShadowColor, SetShadowFillPattern,
  8993.                    SetShadowFillStyle
  8994. Example
  8995.  
  8996.  
  8997.  
  8998.   PushImage(100,100,200,200);
  8999.   SetShadowBorderColor(LIGHTGRAY);
  9000.   ShadowBox(100,100,200,200);
  9001.  
  9002.  
  9003.  
  9004.  
  9005.  
  9006. ___________________________________________________________________________
  9007.  
  9008. SetShadowFillPattern Procedure                                     TEGLGRPH
  9009. ___________________________________________________________________________
  9010.  
  9011.  
  9012. Function
  9013.                    Sets the bar fill pattern for ShadowBox.
  9014. Declaration
  9015.                    SetShadowFillPattern(backpattern:
  9016.                    FillPatternType)
  9017. Remarks
  9018.                    backpattern is of the type FillPatternType
  9019.  
  9020.  
  9021.  Programmer's Reference Guide       - 148 -         TEGL Windows Toolkit
  9022.  
  9023.  
  9024.  
  9025.  
  9026.  
  9027.                      Chapter 8 - Special Effects
  9028.  
  9029.  
  9030. CONST
  9031.   MyShadowPattern : FillPatternType =
  9032.     ($AA,$55,$AA,$55,$AA,$55,$AA,$55);
  9033.  
  9034.  
  9035.  
  9036.                    The default fill pattern is SOLIDFILL which is
  9037.                    defined in the Graph Unit.
  9038. See also
  9039.                    ShadowBox, SetShadowColor,
  9040.                    SetShadowBorderColor, SetShadowFillStyle
  9041. Example
  9042.  
  9043.  
  9044.  
  9045. CONST
  9046.   MyShadowPattern : FillPatternType =
  9047.     ($AA,$55,$AA,$55,$AA,$55,$AA,$55);
  9048.  
  9049.   PushImage(100,100,200,200);
  9050.   SetShadowFillPattern(MyShadowPattern);
  9051.   ShadowBox(100,100,200,200);
  9052.  
  9053.  
  9054.  
  9055.  
  9056.  
  9057. ___________________________________________________________________________
  9058.  
  9059. SetShadowFillStyle Procedure                                       TEGLGRPH
  9060. ___________________________________________________________________________
  9061.  
  9062.  
  9063. Function
  9064.                    Sets the bar fill style for ShadowBox.
  9065. Declaration
  9066.                    SetShadowFillStyle(pattern:word)
  9067. Remarks
  9068.                    pattern is of one of the predefined type in TP's
  9069.                    Graph unit.
  9070.  
  9071.                    The default fill style is SOLIDFILL.
  9072. See also
  9073.                    ShadowBox, SetShadowColor, SetShadowBorderColor,
  9074.                    SetShadowFillPattern
  9075. Example
  9076.  
  9077.  
  9078. PushImage(100,100,200,200);
  9079. SetShadowFillStyle(LineFill);
  9080. ShadowBox(100,100,200,200);
  9081.  
  9082.  Programmer's Reference Guide       - 149 -         TEGL Windows Toolkit
  9083.  
  9084.  
  9085.  
  9086.  
  9087.  
  9088.                      Chapter 8 - Special Effects
  9089.  
  9090.  
  9091.  
  9092.  
  9093.  
  9094.  
  9095. Creating Shadow Text
  9096.  
  9097. Shadow text enhances the normal BGI fonts by writing the text string
  9098. several times with a slight shift of the x,y coordinates on each write.
  9099.  
  9100. This simple method provides a 3-D quality to any BGI or TEGL font.
  9101.  
  9102.  
  9103.  
  9104. ___________________________________________________________________________
  9105.  
  9106. Shadowtext Procedure                                               TEGLGRPH
  9107. ___________________________________________________________________________
  9108.  
  9109.  
  9110. Function
  9111.                    Displays a shadowed textstr at (x,y).
  9112. Declaration
  9113.                    Shadowtext(x,y,color:word; textstr:string)
  9114. Remarks
  9115.                    x,y specifies the coordinates for displaying the
  9116.                    textstr.
  9117.  
  9118.                    color specifies the color of the textstr.
  9119.  
  9120.                    Shadowtext is affected by SetTextStyle,
  9121.                    SetTextJustify and SetUserCharSize in the 
  9122.                    Graph Unit.
  9123. See also
  9124.                    SetShadowTextType, SetShadowTextShadow,
  9125.                    SetShadowTextHighlight, ShadowTextHighlightOFF
  9126. Example
  9127.  
  9128.  
  9129.   ShadowText(100,100,LightCyan,'TEGL Systems Corporation');
  9130.  
  9131.  
  9132.  
  9133.  
  9134.  
  9135.  
  9136. ___________________________________________________________________________
  9137.  
  9138. SetShadowTextType Procedure                                        TEGLGRPH
  9139. ___________________________________________________________________________
  9140.  
  9141.  
  9142.  
  9143.  Programmer's Reference Guide       - 150 -         TEGL Windows Toolkit
  9144.  
  9145.  
  9146.  
  9147.  
  9148.  
  9149.                      Chapter 8 - Special Effects
  9150.  
  9151. Function
  9152.                    Sets the shadow text font type.
  9153. Declaration
  9154.                    SetShadowTextType(texttype:pointer)
  9155. Remarks
  9156.                    texttype is a pointer to one of the TEGL fonts. If
  9157.                    texttype is set to nil, ShadowText uses 
  9158.                    OutTextXY in the Graph Unit.
  9159. See also
  9160.                    ShadowText, SetShadowTextShadow,
  9161.                    SetShadowTextHighlight, ShadowTextHighlightOFF
  9162. Example
  9163.  
  9164.  
  9165. SetShadowTextType(@Script);
  9166. ShadowText(100,100,LightCyan,'TEGL Systems Corporation');
  9167.  
  9168.  
  9169.  
  9170.  
  9171.  
  9172. ___________________________________________________________________________
  9173.  
  9174. SetShadowTextShadow Procedure                                      TEGLGRPH
  9175. ___________________________________________________________________________
  9176.  
  9177.  
  9178. Function
  9179.                    Sets the shadow color for ShadowText.
  9180. Declaration
  9181.                    SetShadowTextShadow(color:word)
  9182. Remarks
  9183.                    color is the shadow color when displaying the
  9184.                    shadowed text.
  9185.  
  9186.                    The default shadow color is BLACK.
  9187. See also
  9188.                    ShadowText, SetShadowTextType,
  9189.                    SetShadowTextHighlight, ShadowTextHighlightOFF
  9190. Example
  9191.  
  9192.  
  9193. SetShadowTextShadow(lightgray);
  9194. ShadowText(100,100,LightCyan,'TEGL Systems Corporation');
  9195.  
  9196.  
  9197.  
  9198.  
  9199.  
  9200. ___________________________________________________________________________
  9201.  
  9202. SetShadowTextHighlight Procedure                                   TEGLGRPH
  9203.  
  9204.  Programmer's Reference Guide       - 151 -         TEGL Windows Toolkit
  9205.  
  9206.  
  9207.  
  9208.  
  9209.  
  9210.                      Chapter 8 - Special Effects
  9211.  
  9212. ___________________________________________________________________________
  9213.  
  9214.  
  9215. Function
  9216.                    Sets the highlighted color for ShadowText.
  9217. Declaration
  9218.                    SetShadowTextHighlight(color:word)
  9219. Remarks
  9220.                    color is the highlighted color when displaying the
  9221.                    shadowed text. Normally, ShadowText toggles the
  9222.                    high bit of color to achieve the different
  9223.                    shadings.
  9224. See also
  9225.                    ShadowText, SetShadowTextType,
  9226.                    SetShadowTextShadow, ShadowTextHighlightOFF
  9227. Example
  9228.  
  9229.  
  9230.   SetShadowTextHighlight(blue);
  9231.   ShadowText(100,100,LightCyan,'TEGL Systems Corporation');
  9232.  
  9233.  
  9234.  
  9235.  
  9236.  
  9237. ___________________________________________________________________________
  9238.  
  9239. ShadowTextHighlightOFF Procedure                                   TEGLGRPH
  9240. ___________________________________________________________________________
  9241.  
  9242.  
  9243. Function
  9244.                    Resets the highlight color set by 
  9245.                    SetShadowTextHighlight.
  9246. Declaration
  9247.                    ShadowTextHighlightOFF
  9248. Remarks
  9249.                    Switches off the highlight color set by 
  9250.                    SetShadowTextHighlight.
  9251. See also
  9252.                    ShadowText, SetShadowTextType,
  9253.                    SetShadowTextShadow, SetShadowTextHighlight
  9254. Example
  9255.  
  9256.  
  9257.   SetShadowTextHighlight(blue);
  9258.   ShadowText(100,100,LightCyan,'TEGL Systems Corporation');
  9259.   ShadowTextHighlightOFF;
  9260.   ShadowText(100,120,LightCyan,'TEGL Systems Corporation');
  9261.  
  9262.  
  9263.  
  9264.  
  9265.  Programmer's Reference Guide       - 152 -         TEGL Windows Toolkit
  9266.  
  9267.  
  9268.  
  9269.  
  9270.  
  9271.                      Chapter 8 - Special Effects
  9272.  
  9273.  
  9274. Other text effects
  9275.  
  9276.  
  9277. ___________________________________________________________________________
  9278.  
  9279. ExtendTextXY Procedure                                             TEGLGRPH
  9280. ___________________________________________________________________________
  9281.  
  9282.  
  9283. Function
  9284.                    Makes embossed text.
  9285. Declaration
  9286.                    ExtendTextXY(X,Y : Word; S : String); 
  9287. Restrictions
  9288.                    Does not work with BGI fonts.
  9289. Example
  9290.  
  9291.  
  9292. VAR ifs : ImageStkPtr;
  9293.  
  9294.   QuickFrame(ifs,100,100,300,150);
  9295.   OutTEGLTextXY(105,105,'Normal Text');
  9296.   ExtendTextXY(105,125,'FAT TEXT');
  9297.  
  9298.  
  9299.  
  9300.  
  9301.  
  9302. ___________________________________________________________________________
  9303.  
  9304. ShiftTextXY Procedure                                              TEGLGRPH
  9305. ___________________________________________________________________________
  9306.  
  9307.  
  9308. Function
  9309.                    Writes text with a leading white edge.
  9310. Declaration
  9311.                    ShiftTextXY(X,Y : Word; S : String);
  9312. Restrictions
  9313.                    Does not work with BGI fonts.
  9314. Remarks
  9315.                    X and Y are absolute screen coordinates, S
  9316.                    is the string to display.
  9317. Example
  9318.  
  9319.  
  9320. VAR ifs : ImageStkPtr;
  9321.  
  9322.   SetShadowColor(LightGray);
  9323.   QuickFrame(ifs,100,100,300,150);
  9324.   OutTEGLTextXY(105,105,'Normal Text');
  9325.  
  9326.  Programmer's Reference Guide       - 153 -         TEGL Windows Toolkit
  9327.  
  9328.  
  9329.  
  9330.  
  9331.  
  9332.                      Chapter 8 - Special Effects
  9333.  
  9334.   ShiftTextXY(105,125,'Shifted Text');
  9335.  
  9336.  
  9337.  
  9338.  
  9339. Buttons
  9340.  
  9341.  
  9342. ___________________________________________________________________________
  9343.  
  9344. DefineButtonClick Procedure                                        TEGLGRPH
  9345. ___________________________________________________________________________
  9346.  
  9347.  
  9348.  
  9349. Function
  9350.                    Displays an icon, sets mouse click area and attaches it
  9351.                    to an Event.
  9352. Declaration
  9353.                    DefineButtonClick(ifs : ImageStkPtr; x,y : Word;
  9354.                      button : Pointer; p : CallProc); 
  9355. Remarks
  9356.                    Ifs is the frame the icon is placed on. Button can
  9357.                    be any icon image. P is the Event to pass control to
  9358.                    when the icon is clicked on.
  9359.  
  9360.                    P can be set to CollapseToIconShow or
  9361.                    CollapseToMsClick if the button is for closing a frame.
  9362. Example
  9363.  
  9364.  
  9365.   DefineButtonClick(ifs,150,200,@ImageOK,CollapseToIconShow);
  9366.  
  9367.  
  9368.  
  9369.  
  9370.  
  9371. ___________________________________________________________________________
  9372.  
  9373. DefineLongButtonClick Procedure                                    TEGLGRPH
  9374. ___________________________________________________________________________
  9375.  
  9376.  
  9377.  
  9378. Function
  9379.                    Displays a long button with text, sets mouse click area,
  9380.                    and attaches it to an event.
  9381. Declaration
  9382.                    DefineLongButtonClick(ifs : ImageStkPtr; x,y,ln : Word;
  9383.                      msg : String; p : CallProc); 
  9384. Remarks
  9385.                    Ifs is the frame the button is placed on. x,y are the
  9386.  
  9387.  Programmer's Reference Guide       - 154 -         TEGL Windows Toolkit
  9388.  
  9389.  
  9390.  
  9391.  
  9392.  
  9393.                      Chapter 8 - Special Effects
  9394.  
  9395.                    coordinates to place the button at. Ln is the length of
  9396.                    the message in pixels (depends on currently selected
  9397.                    font) and msg is the text to place inside the button.
  9398.                    P is the event to activate when the button is clicked on.
  9399. Example
  9400.  
  9401.  
  9402.   DefineLongButtonClick(ifs,100,150,35,'Quit',CollapseToMsClick);
  9403.  
  9404.  
  9405.  
  9406.  
  9407.  
  9408. ___________________________________________________________________________
  9409.  
  9410. DefineUserButtonClick Procedure                                    TEGLGRPH
  9411. ___________________________________________________________________________
  9412.  
  9413.  
  9414.  
  9415. Function
  9416.                    Displays a button with text, sets mouse click area, and
  9417.                    attaches it to an event.
  9418. Declaration
  9419.                    DefineUserButtonClick(ifs : ImageStkPtr; x,y : Word;
  9420.                      msg : String; p : CallProc); 
  9421. Remarks
  9422.                    Ifs is the frame the button is placed on. x,y are
  9423.                    the coordinates to place the button at and msg is
  9424.                    the text to place inside the button. P is the
  9425.                    event to activate when the button is clicked on.
  9426. Restrictons
  9427.                    Msg cannot be more than about 4 characters. This is
  9428.                    dependant on the currently selected font.
  9429. Example
  9430.  
  9431.  
  9432.   DefineUserButtonClick(ifs,100,150,'Quit',CollapseToMsClick);
  9433.  
  9434.  
  9435.  
  9436.  
  9437.  
  9438.  
  9439. ___________________________________________________________________________
  9440.  
  9441. PutUserButtonClick Procedure                                       TEGLGRPH
  9442. ___________________________________________________________________________
  9443.  
  9444.  
  9445.  
  9446. Function
  9447.  
  9448.  Programmer's Reference Guide       - 155 -         TEGL Windows Toolkit
  9449.  
  9450.  
  9451.  
  9452.  
  9453.  
  9454.                      Chapter 8 - Special Effects
  9455.  
  9456.                    Draws a button at the coordinates with a message.
  9457. Declaration
  9458.                    PutUserButtonClick(ifs : ImageStkPtr; x,y : Word;
  9459.                      msg : String) 
  9460. Restrictions
  9461.                    Msg cannot be more than about 4 charcters, depends
  9462.                    upon the currently selected font.
  9463. Remarks
  9464.                    This routine just displays a button, no mouse click
  9465.                    area is defined.
  9466.  
  9467.  
  9468. Explosions
  9469.  
  9470.  
  9471. ___________________________________________________________________________
  9472.  
  9473. CollapseToIconShow Event                                           TEGLGRPH
  9474. ___________________________________________________________________________
  9475.  
  9476.  
  9477. Function
  9478.                    Collapse a frame and restore the icon it came from.
  9479. Declaration
  9480.                    CollapseToIconShow(ifs : ImageStkPtr; ms : MsClickPtr) :
  9481.                      Word;
  9482. Restrictions
  9483.                    Should only be attached to a frame created after a call
  9484.                    to ExplodeToIconShow.
  9485. Remarks
  9486.                    After opening a frame from a ExplodeToIconShow, this
  9487.                    Event can be attached to a button within the frame. When
  9488.                    this button is clicked on, the frame will collapse and zip
  9489.                    to the original icon location and restore the icon.
  9490. See also
  9491.                    ExplodeToIconShow,DefineButtonClick.
  9492.  
  9493.  
  9494.  
  9495. ___________________________________________________________________________
  9496.  
  9497. CollapseToMsClick Event                                            TEGLGRPH
  9498. ___________________________________________________________________________
  9499.  
  9500.  
  9501. Function
  9502.                    Collapse a frame and zip back to the original mouse click
  9503.                    position.
  9504. Declaration
  9505.                    CollapseToMsClick(ifs : ImageStkPtr; ms : MsClickPtr):
  9506.                       Word;
  9507. Restrictions
  9508.  
  9509.  Programmer's Reference Guide       - 156 -         TEGL Windows Toolkit
  9510.  
  9511.  
  9512.  
  9513.  
  9514.  
  9515.                      Chapter 8 - Special Effects
  9516.  
  9517.                    Should only be attacted to a frame created after a call
  9518.                    to ExplodeFromMsClick.
  9519. Remarks
  9520.                    After opening a frame from a ExplodeFromMsClick, this
  9521.                    Event can be attached to a button within the frame. When
  9522.                    this button is clicked on, the frame will collapse and zip
  9523.                    to the original defined mouse click area.
  9524. See also
  9525.                    ExplodeFromMsClick, DefineButtonClick.
  9526.  
  9527.  
  9528.  
  9529. ___________________________________________________________________________
  9530.  
  9531. ExplodeFromIconHide                                                TEGLGRPH
  9532. ___________________________________________________________________________
  9533.  
  9534.  
  9535. Function
  9536.                    Hides the icon, zips and opens a new frame.
  9537. Declaration
  9538.                    ExplodeFromIconHide(ifs : ImageStkPtr; ms: MouseClickPtr;
  9539.                      x,y,x1,y1 : Word);
  9540. Restrictions
  9541.                    The icon exploded from must be in a frame of its own
  9542.                    for this to look right.
  9543. Remarks
  9544.                    ifs and ms are the parameters passed to an event.
  9545.                    x,y,x1,y1 are the coordinates where a new frame is
  9546.                    to be opened. After a call to this procedure a new frame is
  9547.                    created. Save the Global Variable StackPtr if you wish to
  9548.                    manipulate the new frame.
  9549. See also
  9550.                    CollapseToIconShow, DefineButtonClick.
  9551.  
  9552.  
  9553.  
  9554. ___________________________________________________________________________
  9555.  
  9556. ExplodeFromMsClick Procedure                                       TEGLGRPH
  9557. ___________________________________________________________________________
  9558.  
  9559.  
  9560. Function
  9561.                    Zips from a mouse click location to a new frame
  9562.                    position.
  9563. Declaration
  9564.                    ExplodeFromMsClick(ifs : ImageStkPtr; ms : MouseClickPos;
  9565.                      x,y,x1,y1 : Word); 
  9566. Remarks
  9567.                    ifs and ms are the parameters passed to an event.
  9568.                    x,y,x1,y1 are the coordinates where a new frame is
  9569.  
  9570.  Programmer's Reference Guide       - 157 -         TEGL Windows Toolkit
  9571.  
  9572.  
  9573.  
  9574.  
  9575.  
  9576.                      Chapter 8 - Special Effects
  9577.  
  9578.                    to be opened. After a call to this procedure a new frame is
  9579.                    created. Save the Global Variable StackPtr if you wish to
  9580.                    manipulate the new frame.
  9581. See also
  9582.                    CollapseToMsClick, DefineUserButtonClick.
  9583.  
  9584.  
  9585. Moving and Transforming XOR Boxes
  9586.  
  9587.  
  9588. ___________________________________________________________________________
  9589.  
  9590. MoveBox Procedure                                                  TEGLGRPH
  9591. ___________________________________________________________________________
  9592.  
  9593.  
  9594. Function
  9595.                    Moves a (XOR) wire frame from x, y to ax, ay.
  9596.  
  9597. Declaration
  9598.                    MoveBox(ax,ay,x,y,x1,y1 : integer)
  9599. Remarks
  9600.                    x, y, x1, y1 specify the coordinates of the
  9601.                    starting (XOR) wire frame.
  9602.  
  9603.                    ax, ay are the upper left coordinates of the
  9604.                    ending position of the (XOR) wire frame.
  9605.  
  9606.                    The box movement is divided into 6 steps which is added
  9607.                    or subtracted from the originating position until it
  9608.                    reaches the destination.
  9609.  
  9610.                    The global variable ZipDuration may be changed to
  9611.                    set the delay between each movement step.
  9612. See also
  9613.                    XORBox, XORCornerBox, ZipToBox, ZipFromBox
  9614. Example
  9615.                    A wire frame box 50(w) x 50(h) is moveed from 100,100
  9616.                    to 500,280.
  9617.  
  9618.  
  9619.  
  9620.   MoveBox(500,280,100,100,150,150);
  9621.  
  9622.  
  9623.  
  9624.  
  9625.  
  9626. ___________________________________________________________________________
  9627.  
  9628. ZipToBox Procedure                                                 TEGLGRPH
  9629. ___________________________________________________________________________
  9630.  
  9631.  Programmer's Reference Guide       - 158 -         TEGL Windows Toolkit
  9632.  
  9633.  
  9634.  
  9635.  
  9636.  
  9637.                      Chapter 8 - Special Effects
  9638.  
  9639.  
  9640.  
  9641. Function
  9642.                    Creates a moving and expanding (XOR) wire frame from
  9643.                    ax, ay, ax1, ay1 to x, y, x1, y1.
  9644. Declaration
  9645.                    ZipToBox(ax,ay,ax1,ay1,x,y,x1,y1 : integer)
  9646. Remarks
  9647.                    ax, ay, ax1, ay1 specifies the rectangular
  9648.                    coordinates of the starting (XOR) wire frame.
  9649.  
  9650.                    x, y, x1, y1 specifies the rectangular coordinates
  9651.                    of the ending (XOR) wire frame.
  9652.  
  9653.                    The box is moved from (ax,ay) to (x,y) using 
  9654.                    MoveBox before the box is transformed (expanded).
  9655.                    The transformation is divided into 6 steps which is
  9656.                    added or subtracted from (ax,ay,ax1,ay1) until the size
  9657.                    equals (x,y,x1,y1).
  9658.  
  9659.                    The global variable ZipDuration may be changed to
  9660.                    set the delay between each movement step.
  9661. See also
  9662.                    XORBox, XORCornerBox, MoveBox, ZipFromBox
  9663. Example
  9664.                    A wire frame box 50(w) x 50(h) at (100,100) will be
  9665.                    visually moved and expanded to a box 100(w) x 100(h) at
  9666.                    400,200.
  9667.  
  9668.  
  9669. ZipToBox(100,100,150,150,400,100,500,200);
  9670.  
  9671.  
  9672.  
  9673.  
  9674.  
  9675. ___________________________________________________________________________
  9676.  
  9677. ZipFromBox Procedure                                               TEGLGRPH
  9678. ___________________________________________________________________________
  9679.  
  9680.  
  9681. Function
  9682.                    Creates a shrinking and moving (XOR) wire frame from
  9683.                    x, y, x1, y1 to ax, ay, ax1, ay1.
  9684. Declaration
  9685.                    ZipFromBox(ax,ay,ax1,ay1,x,y,x1,y1 : integer)
  9686. Remarks
  9687.                    x, y, x1, y1 specifies the rectangular coordinates
  9688.                    of the starting (XOR) wire frame.
  9689.  
  9690.                    ax, ay, ax1, ay1 specifies the rectangular
  9691.  
  9692.  Programmer's Reference Guide       - 159 -         TEGL Windows Toolkit
  9693.  
  9694.  
  9695.  
  9696.  
  9697.  
  9698.                      Chapter 8 - Special Effects
  9699.  
  9700.                    coordinates of the ending (XOR) wire frame.
  9701.  
  9702.                    The box is transformed by dividing the transformation
  9703.                    steps into 6 steps which is added or subtracted from (x,
  9704.                    y,x1,y1) until the size equals (ax,ay,ax1,ay1). The box
  9705.                    is then moved from (x,y) to (ax,ay) using MoveBox.
  9706.  
  9707.                    The global variable ZipDuration may be changed to
  9708.                    set the delay between each movement step.
  9709. See also
  9710.                    XORBox, XORCornerBox, MoveBox, ZipFromBox
  9711. Example
  9712.                    A wire frame box 100(w) x 100(h) at (x=400,y=200) will
  9713.                    be visually shrunk and moved to a box 50(w) x 50(h) at
  9714.                    (x=100,y=100).
  9715.  
  9716.  
  9717. ZipFromBox(100,100,150,150,400,100,500,200);
  9718.  
  9719.  
  9720.  
  9721.  
  9722.  
  9723. Icon Button
  9724.  
  9725.  
  9726. ___________________________________________________________________________
  9727.  
  9728. DrawLongButton Procedure                                           TEGLGRPH
  9729. ___________________________________________________________________________
  9730.  
  9731.  
  9732. Function
  9733.                    Creates an icon button of size ln at (x,y).
  9734. Declaration
  9735.                    DrawLongButton(x,y,ln : word)
  9736. Remarks
  9737.                    x,y specifies the coordinates for the icon button.
  9738.                    ln specifies the length of the icon button in
  9739.                    pixels.
  9740. Example
  9741.  
  9742.  
  9743. DrawLongButton(x,y,200);
  9744. fonttable := @font14;
  9745. setcolor(white);
  9746. outtegltextxy(x+15,y+1,'TEGL Systems Corporation');
  9747.  
  9748.  
  9749.  
  9750.  
  9751.  
  9752.  
  9753.  Programmer's Reference Guide       - 160 -         TEGL Windows Toolkit
  9754.  
  9755.  
  9756.  
  9757.  
  9758.  
  9759.  
  9760.  
  9761.  
  9762.  
  9763.  
  9764.  
  9765.  
  9766.  
  9767.  
  9768.  
  9769.  
  9770.  
  9771.  
  9772.  
  9773.  
  9774.  
  9775.  
  9776.  
  9777.  
  9778.  
  9779.  
  9780.  
  9781.  
  9782.  
  9783.  
  9784.  
  9785.  
  9786.  
  9787.  
  9788.  
  9789.  
  9790.  
  9791.  
  9792.  
  9793.  
  9794.  
  9795.  
  9796.  
  9797.  
  9798.  
  9799.  
  9800.  
  9801.  
  9802.  
  9803.  
  9804.  
  9805.  
  9806.  
  9807.  
  9808.  
  9809.  
  9810.  
  9811.  
  9812.  
  9813.  
  9814.  Programmer's Reference Guide       - 161 -         TEGL Windows Toolkit
  9815.  
  9816.  
  9817.  
  9818.  
  9819.  
  9820.                       Chapter 9 - Writing Events
  9821.  
  9822.  
  9823. Writing Events
  9824. ___________________________________________________________________________
  9825.  
  9826. All Event-handlers must use the following header definition.
  9827.  
  9828.  
  9829. {$F+}
  9830. function MyEvents(Frame:imagestkptr; MouseClickPos: msclickptr) : word;
  9831. {$F-}
  9832.  
  9833.  
  9834.  
  9835. This is the declaration of a CallProc. Note the far call directive.
  9836. If you write an event that does not used the far call directive you will
  9837. be unable to use it as a parameter. The compiler will give an error message
  9838. 143 of q Invalid procedure or function reference.
  9839.  
  9840.  
  9841. Mouse Awareness
  9842.  
  9843.  
  9844. ___________________________________________________________________________
  9845.  
  9846. FindFrame Function                                                 TEGLUNIT
  9847. ___________________________________________________________________________
  9848.  
  9849.  
  9850. Function
  9851.                    Searches through the Frame stack for the first frame
  9852.                    that overlaps the coordinates passed as a parameter.
  9853. Declaration
  9854.                    FindFrame(mxpos,mypos:word)
  9855. Result type
  9856.                    Pointer.
  9857. Remarks
  9858.                    Returns a ImageStkPtr if the parameters overlap
  9859.                    one of the frames, otherwise returns Nil for no match.
  9860.  
  9861.                    FindFrame is used by the TEGLSupervisor, but is
  9862.                    provided as an external procedure to allow for
  9863.                    specialize routines that may be used to replace the
  9864.                    TEGLSupervisor.
  9865. Restrictions
  9866.                    FindFrame starts the scan from the top of the stack,
  9867.                    thereby returning the first frame found that overlaps
  9868.                    the parameters.
  9869. See also
  9870.                    CheckMouseClickPos
  9871. Example
  9872.                    The following example creates 250 random boxes and
  9873.                    monitors the position of the mouse pointer to see if it
  9874.  
  9875.  Programmer's Reference Guide       - 162 -         TEGL Windows Toolkit
  9876.  
  9877.  
  9878.  
  9879.  
  9880.  
  9881.                       Chapter 9 - Writing Events
  9882.  
  9883.                    overlaps one of the boxes. The timer tick routine is
  9884.                    used to blink the overlapped box, once every second.
  9885.  
  9886.  
  9887. Var i       : word;
  9888.     fs1,fs2  : imagestkptr;
  9889.  
  9890. function BlinkBox(Frame:imagestkptr;
  9891.            MouseClickPos: msclickptr) : word;
  9892.    BEGIN
  9893.       if fs1<>nil then
  9894.         begin
  9895.            hidemouse;
  9896.  
  9897.            If fs1^.ImageActive then
  9898.               hideimage(fs1)
  9899.            else
  9900.               Showimage(fs1,fs1^.x,fs1^.y);
  9901.  
  9902.            showmouse;
  9903.         end;
  9904.  
  9905.       beep(10000,1,1);
  9906.       ResetTimerFlag;
  9907.       BlinkBox := 1;
  9908.    end;
  9909.  
  9910. procedure CreateRandomBox(x,y:word);
  9911.    begin
  9912.       PushImage(x,y,x+20,y+20);
  9913.       shadowbox(x,y,x+20,y+20);
  9914.    end;
  9915.  
  9916. for i:=1 to 250 do
  9917.    createrandombox(random(600),random(320));
  9918.  
  9919. fs1 := stackptr;
  9920. SetTimerTick(18,BlinkBox);
  9921. repeat
  9922.    if mouse_buttons<>0 then
  9923.       fs2 := frameselectandmove(mouse_xcoord,mouse_ycoord)
  9924.    else
  9925.       fs2 := findframe(mouse_xcoord,mouse_ycoord);
  9926.  
  9927.    if (fs2<>nil) and (fs1<>fs2) then
  9928.       begin
  9929.         If (not fs1^.ImageActive) then
  9930.            i:=blinkbox(nil,nil);
  9931.         fs1 := fs2;
  9932.       end;
  9933.  
  9934.    checkctrlbreak;
  9935.  
  9936.  Programmer's Reference Guide       - 163 -         TEGL Windows Toolkit
  9937.  
  9938.  
  9939.  
  9940.  
  9941.  
  9942.                       Chapter 9 - Writing Events
  9943.  
  9944. until false;
  9945.  
  9946.  
  9947.  
  9948.  
  9949.  
  9950. ___________________________________________________________________________
  9951.  
  9952. CheckMouseClickPos Function                                        TEGLUNIT
  9953. ___________________________________________________________________________
  9954.  
  9955.  
  9956. Function
  9957.                    Compares all Mouse click defines within a frame, for a
  9958.                    match with the current mouse coordinates.
  9959. Declaration
  9960.                    CheckMouseClickPos(Frame,mxpos,mypos:word)
  9961. Result type
  9962.                    Pointer.
  9963. Remarks
  9964.                    Returns a MSClickPtr type if mouse coordinates
  9965.                    matches one of the mouse click defines, otherwise
  9966.                    returns Nil for no match.
  9967.  
  9968.                    CheckMouseClickPos is normally an internal procedure,
  9969.                    used by the TEGLSupervisor. The Mouse Click position
  9970.                    information is normally provided as the second
  9971.                    parameter of an event, whenever an event is called.
  9972.  
  9973.                    However, CheckMouseClickPos may be used to rewrite the
  9974.                    TEGLSupervisor or used to determine if the Mouse Click
  9975.                    position has changed.
  9976. Restrictions
  9977.                    FindFrame should be used first, to check if another
  9978.                    frame is overlapping the current frame, before using
  9979.                    CheckMouseClickPos.
  9980. See also
  9981.                    DefineMouseClickPtr, ResetMouseClicks,
  9982.                    FindMouseClickPtr, ResetMSClickSense,
  9983.                    ResetMSClickCallProc, ResetMSClickActive
  9984. Example
  9985.                    The following example defines an array of 100 Mouse
  9986.                    Click Areas which uses CheckMouseClickPos to establish
  9987.                    the mouse location within the frame.
  9988.  
  9989.  
  9990. var x,y : word;
  9991.  
  9992. Function PlayAllNotes(Frame:ImageStkPtr;
  9993.            MouseClickPos: MSClickPtr):WORD;
  9994.    var ms   : msclickptr;
  9995.    BEGIN
  9996.  
  9997.  Programmer's Reference Guide       - 164 -         TEGL Windows Toolkit
  9998.  
  9999.  
  10000.  
  10001.  
  10002.  
  10003.                       Chapter 9 - Writing Events
  10004.  
  10005.       while findframe(mouse_xcoord,mouse_ycoord)=frame do
  10006.         begin
  10007.            ms := CheckMouseClickPos(frame,mouse_xcoord,
  10008.                    mouse_ycoord);
  10009.            if ms<>nil then
  10010.               sound(ms^.clicknumber*10);
  10011.         end;
  10012.  
  10013.       nosound;
  10014.       PlayAllNotes := 0;
  10015.    END;
  10016.  
  10017. PushImage(1,1,107,124);
  10018. shadowbox(1,1,107,124);
  10019. DefineMouseClickArea(stackptr,1,1,107,124,true,PlayAllNotes,MSSense);
  10020.  
  10021. for x:=0 to 9 do
  10022.    for y:=0 to 9 do
  10023.       begin
  10024.         shadowbox(stackptr^.x+3+x*10,stackptr^.y+3+y*10,
  10025.           stackptr^.x+3+10+x*10,stackptr^.y+3+10+y*10);
  10026.         DefineMouseClickArea(stackptr,3+x*10,3+y*10,3+x*10+6,
  10027.           3+y*10+6,true,nilunitproc,MSClick);
  10028.       end;
  10029.  
  10030.  
  10031.  
  10032.  
  10033.  
  10034.  
  10035.  
  10036. ___________________________________________________________________________
  10037.  
  10038. CheckForMouseSelect Function                                       TEGLUNIT
  10039. ___________________________________________________________________________
  10040.  
  10041.  
  10042. Function
  10043.                    Checks if one of the mouse click areas within a frame
  10044.                    has been selected.
  10045. Declaration
  10046.                    CheckforMouseSelect(frame)
  10047. Result type
  10048.                    Returns the Mouse Click Pointer if mouse button was
  10049.                    released while the mouse cursor overlaps a button icon.
  10050.  
  10051. Remarks
  10052.                    This procedure may be used when only the Frame is known
  10053.                    and the program is waiting for the user to click on one
  10054.                    of a series of unknown icons.
  10055.  
  10056.                    CheckForMouseSelect may be used within an event to wait
  10057.  
  10058.  Programmer's Reference Guide       - 165 -         TEGL Windows Toolkit
  10059.  
  10060.  
  10061.  
  10062.  
  10063.  
  10064.                       Chapter 9 - Writing Events
  10065.  
  10066.                    on a multiple button type icon replies from the user.
  10067.  
  10068.                    If PressButtonFlag is true, then visualbuttonpress is
  10069.                    called to simulate the pressing of a button icon.
  10070. Restrictions
  10071.                    If PressButtonFlag is true, the restrictions for
  10072.                    VisualButtonPress should be followed. If the icon does
  10073.                    not have a black fringe, set PressButtonFlag to false.
  10074. See also
  10075.                    PressButton, VisualButtonPress
  10076. Example
  10077.                    The following example creates (8) button type icons,
  10078.                    which calls up a window that displays two choices, 
  10079.                    Cancel or OK. The event waits until one of the
  10080.                    choices are made before returning to TEGLSupervisor.
  10081.  
  10082.  
  10083. var x,y : word;
  10084.  
  10085. function DemoCancelOK(Frame:imagestkptr;
  10086.            MouseClickPos: msclickptr) : word;
  10087.    begin
  10088.       if visualbuttonpress(frame,MouseClickPos) then
  10089.         begin
  10090.            hidemouse;
  10091.  
  10092.            PushImage(frame^.x,frame^.y,frame^.x+100,frame^.y+50);
  10093.            shadowbox(frame^.x,frame^.y,frame^.x+100,frame^.y+50);
  10094.  
  10095.            Putpict(frame^.x+6,frame^.y+6,@imageCancel,black);
  10096.            DefineMouseClickArea(stackptr,6,6,6+35,6+12,true,
  10097.              nilunitproc,MSClick);
  10098.  
  10099.            Putpict(frame^.x+12+35,frame^.y+6,@imageOK,black);
  10100.            DefineMouseClickArea(stackptr,12+35,6,12+35+35,6+12,
  10101.              true,nilunitproc,MSClick);
  10102.  
  10103.            showmouse;
  10104.            repeat
  10105.               mouseClickPos := CheckforMouseSelect(stackptr);
  10106.            until MouseClickPos<>nil;
  10107.  
  10108.            if MouseClickPos^.Clicknumber=1 then
  10109.               SlideBeep(100,500,3)
  10110.            else
  10111.               Beep(800,3,100);
  10112.  
  10113.            hidemouse;
  10114.            popimage;
  10115.            showmouse;
  10116.         end;
  10117.  
  10118.  
  10119.  Programmer's Reference Guide       - 166 -         TEGL Windows Toolkit
  10120.  
  10121.  
  10122.  
  10123.  
  10124.  
  10125.                       Chapter 9 - Writing Events
  10126.  
  10127.       DemoCancelOK := 1;
  10128.    end;
  10129.  
  10130. PushImage(1,1,100,100);
  10131. shadowbox(1,1,100,100);
  10132.  
  10133. for x:=0 to 1 do
  10134.    for y:=0 to 4 do
  10135.       begin
  10136.         Putpict(stackptr^.x+6+x*42,stackptr^.y+6+y*18,
  10137.           @imageBlankBut,black);
  10138.         DefineMouseClickArea(stackptr,5+x*42,5+y*18,5+x*42+35,
  10139.           5+y*18+12,true,DemoCancelOK,MSClick);
  10140.       end;
  10141.  
  10142.  
  10143.  
  10144.  
  10145.  
  10146. Special Effects
  10147.  
  10148.  
  10149. ___________________________________________________________________________
  10150.  
  10151. PressButton Procedure                                              TEGLUNIT
  10152. ___________________________________________________________________________
  10153.  
  10154.  
  10155. Function
  10156.                    Simulates the pressing of a button type icon. The
  10157.                    actual routine simply shifts the icon down and to the
  10158.                    right by two pixels.
  10159. Declaration
  10160.                    PressButton(fs,mouseopt:msclickptr)
  10161. Remarks
  10162.                    This procedure is used mainly by VisualButtonPress to
  10163.                    simulate the action of a electronic button switch.
  10164.  
  10165.                    PressButton may be used to create the illusion of a
  10166.                    button left in the down position.
  10167. Restrictions
  10168.                    You are required to redraw the button if you need the
  10169.                    button in the up position.
  10170.  
  10171.                    This routine only works with icons that have a black
  10172.                    fringe of two pixels wide on the right and bottom of
  10173.                    the icon. The defined mouse click area should not
  10174.                    include this shadow area ie. x1 and y1 is less two
  10175.                    pixels.
  10176. See also
  10177.                    VisualButtonPress, CheckForMouseSelect
  10178. Example
  10179.  
  10180.  Programmer's Reference Guide       - 167 -         TEGL Windows Toolkit
  10181.  
  10182.  
  10183.  
  10184.  
  10185.  
  10186.                       Chapter 9 - Writing Events
  10187.  
  10188.                    The following example creates (8) button type icons and
  10189.                    toggles the buttons on/off whenever the icon is clicked
  10190.                    upon.
  10191.  
  10192.  
  10193. var x,y : word;
  10194.  
  10195. function SwitchOff(Frame:imagestkptr;
  10196.            MouseClickPos: msclickptr) : word; forward;
  10197.  
  10198. function SwitchOn(Frame:imagestkptr;
  10199.            MouseClickPos: msclickptr) : word;
  10200.    begin
  10201.       Beep(1500,1,10);
  10202.       PressButton(Frame,MouseClickPos);
  10203.       ResetMSClickCallProc(Frame,MouseClickPos^.ClickNumber,SwitchOff);
  10204.       while Mouse_Buttons<>0 do;
  10205.       SwitchOn := 1;
  10206.    end;
  10207.  
  10208. function SwitchOff(Frame:imagestkptr;
  10209.            MouseClickPos: msclickptr) : word;
  10210.    begin
  10211.       Beep(1500,1,10);
  10212.       hidemouse;
  10213.       Putpict(Frame^.x+MouseClickPos^.ms.x,
  10214.              Frame^.y+MouseClickPos^.ms.y,@imageBlankBut,black);
  10215.  
  10216.       showmouse;
  10217.       ResetMSClickCallProc(Frame,MouseClickPos^.ClickNumber,
  10218.         SwitchOn);
  10219.       while Mouse_Buttons<>0 do;
  10220.       SwitchOff := 1;
  10221.    end;
  10222.  
  10223. PushImage(1,1,100,100);
  10224. shadowbox(1,1,100,100);
  10225.  
  10226. for x:=0 to 1 do
  10227.    for y:=0 to 4 do
  10228.       begin
  10229.         Putpict(stackptr^.x+6+x*42,stackptr^.y+6+y*18,
  10230.           @imageBlankBut,black);
  10231.         DefineMouseClickArea(stackptr,5+x*42,5+y*18,
  10232.           5+x*42+35,5+y*18+12,true,SwitchOn,MSClick);
  10233.       end;
  10234.  
  10235.  
  10236.  
  10237.  
  10238.  
  10239.  
  10240.  
  10241.  Programmer's Reference Guide       - 168 -         TEGL Windows Toolkit
  10242.  
  10243.  
  10244.  
  10245.  
  10246.  
  10247.                       Chapter 9 - Writing Events
  10248.  
  10249. ___________________________________________________________________________
  10250.  
  10251. VisualButtonPress Function                                         TEGLUNIT
  10252. ___________________________________________________________________________
  10253.  
  10254.  
  10255. Function
  10256.                    Performs the pressing and releasing of a button type
  10257.                    icon, controlled by the holding down of the left mouse
  10258.                    button. Returns when either the user releases the left
  10259.                    mouse button or the mouse cursor wanders off the
  10260.                    defined mouse click area.
  10261. Declaration
  10262.                    VisualButtonPress(frame,mouseopt:msclickptr)
  10263. Result type
  10264.                    Returns true if mouse button was released while the
  10265.                    mouse cursor overlaps with the button icon.
  10266. Remarks
  10267.                    This procedure may be used whenever the Frame and the
  10268.                    Mouse Click Option is known. If the program is waiting
  10269.                    for the user to click on one of a series of unknown
  10270.                    icons, use CheckForMouseSelect to do an automatic Frame
  10271.                    and Mouse click Option search.
  10272.  
  10273.                    VisualButtonPress is excellent as an entry routine for
  10274.                    an event, since the frame and mouse click position are
  10275.                    known.
  10276. Restrictions
  10277.                    This routine only works with icons that has a black
  10278.                    fringe of two pixels wide on the right and bottom of
  10279.                    the icon. The defined mouse click area should not
  10280.                    include this shadow area ie. x1 and y1 is less two
  10281.                    pixels.
  10282. See also
  10283.                    PressButton, CheckForMouseSelect
  10284. Example
  10285.                    The following example creates (8) button type icons,
  10286.                    allowing the mouse cursor to glide over (while the
  10287.                    buttons simulates the on/off motions). A series of
  10288.                    beeps are sounded when the mouse button is released
  10289.                    with the mouse cursor is on a button.
  10290.  
  10291.  
  10292. var x,y : word;
  10293.  
  10294. function SwitchOn(Frame:imagestkptr;
  10295.            MouseClickPos: msclickptr) : word;
  10296.    begin
  10297.       Beep(1500,1,10);
  10298.       if VisualButtonPress(Frame,MouseClickPos) then
  10299.         slidebeep(500,4000,2);
  10300.       SwitchOn := 1;
  10301.  
  10302.  Programmer's Reference Guide       - 169 -         TEGL Windows Toolkit
  10303.  
  10304.  
  10305.  
  10306.  
  10307.  
  10308.                       Chapter 9 - Writing Events
  10309.  
  10310.    end;
  10311.  
  10312. PushImage(1,1,100,100);
  10313. shadowbox(1,1,100,100);
  10314.  
  10315. for x:=0 to 1 do
  10316.    for y:=0 to 4 do
  10317.       begin
  10318.         Putpict(stackptr^.x+6+x*42,stackptr^.y+6+y*18,
  10319.           @imageBlankBut,black);
  10320.         DefineMouseClickArea(stackptr,5+x*42,5+y*18,
  10321.           5+x*42+35,5+y*18+12,true,SwitchOn,MSClick);
  10322.       end;
  10323.  
  10324.  
  10325.  
  10326.  
  10327.  
  10328.  
  10329.  
  10330.  
  10331.  
  10332.  
  10333.  
  10334.  
  10335.  
  10336.  
  10337.  
  10338.  
  10339.  
  10340.  
  10341.  
  10342.  
  10343.  
  10344.  
  10345.  
  10346.  
  10347.  
  10348.  
  10349.  
  10350.  
  10351.  
  10352.  
  10353.  
  10354.  
  10355.  
  10356.  
  10357.  
  10358.  
  10359.  
  10360.  
  10361.  
  10362.  
  10363.  Programmer's Reference Guide       - 170 -         TEGL Windows Toolkit
  10364.  
  10365.  
  10366.  
  10367.  
  10368.  
  10369.                         Chapter 10 - Animation
  10370.  
  10371.  
  10372. Animation
  10373. ___________________________________________________________________________
  10374.  
  10375. The Animation unit provides the tools to animate a series of icons.
  10376. Combined with the Icon Editor, an event can come to life.
  10377.  
  10378. Animation in its simplest form is the sequential display of frames.  A
  10379. frame in the sense of the animator is a single still image that is
  10380. displayed.  By linking a series of frames, animation is achieved by
  10381. displaying each frame in sequence.
  10382.  
  10383. Using Object-Oriented Programming (OOP), the animation is as simple
  10384. as declaring a object, initializing the object, then animating the object.
  10385.  
  10386. The description for each of the functions and procedures in this
  10387. chapter is slightly different from the other chapters. Since the 
  10388. Animation unit is written in OOPS, the description refers to 
  10389. objects and methods. When referencing an object's method the object name
  10390. is prefixed to the method using the dot "." . The dot is used with objects
  10391. just as it is with records.
  10392.  
  10393. As an example:
  10394.  
  10395.  
  10396.  
  10397. VAR
  10398.   BounceIcon     : animateobject;
  10399.  
  10400.   BounceIcon.ResetFrame(1);
  10401.   BounceIcon.animateinit;
  10402.   BounceIcon.origin(604,wy);
  10403.   BounceIcon.animate(BounceIcon.destination(wx,wy));
  10404.  
  10405.  
  10406.  
  10407. The methods are ResetFrame, AnimateInit, Origin, Animate and 
  10408. Destination. The object is BounceIcon. An object's methods and data
  10409. can also be accessed using WITH.
  10410.  
  10411. The above example may also be expressed as:
  10412.  
  10413.  
  10414.  
  10415. VAR
  10416.   BounceIcon     : animateobject;
  10417.  
  10418.   WITH BounceIcon DO
  10419.     BEGIN
  10420.       ResetFrame(1);
  10421.       Animateinit;
  10422.       Origin(604,wy);
  10423.  
  10424.  Programmer's Reference Guide       - 171 -         TEGL Windows Toolkit
  10425.  
  10426.  
  10427.  
  10428.  
  10429.  
  10430.                         Chapter 10 - Animation
  10431.  
  10432.       Animate(Destination(wx,wy));
  10433.     END;
  10434.  
  10435.  
  10436.  
  10437.  
  10438. Animation Overview
  10439.  
  10440. Animating a series of icons is relatively easy with the methods in the 
  10441. Animation unit. The hardest part is creating the series of icons and
  10442. coordinating the movement differences between them.
  10443.  
  10444. The first step is to declare an object of AnimateObject. Here
  10445. BounceIcon is declared as the object type AnimateObject.
  10446.  
  10447.  
  10448.   VAR BounceIcon     : AnimateObject;
  10449.  
  10450.  
  10451.  
  10452. The data within the object BounceIcon must be initialize before we can
  10453. begin adding frame sequences.  To initialize an object of BounceIcon,
  10454. use the method Init.
  10455.  
  10456.  
  10457.   BounceIcon.Init;
  10458.  
  10459.  
  10460.  
  10461. The next step is to add an icon frame to the object.  The method AddFrame
  10462. adds an icon frame sequence to the object.  The parameters are from left to
  10463. right; the icon constant, defined in TEGLIcon Unit; (-15,0) the horizontal
  10464. and vertical travel offset, respectively, on completion of this frame
  10465. sequence; (14,37) the height and width of the icon; (10) the duration in
  10466. (milliseconds) before progressing to the next sequence; (0,0) the sound in
  10467. hertz, and duration; (black) the color replacement for any black pixels in the
  10468. icon. In this case, black replaces black.
  10469.  
  10470.  
  10471.  
  10472.   BounceIcon.AddFrame(@imageblankbut,-15,0,14,37,10,0,0,black);
  10473.  
  10474.  
  10475.  
  10476. An object can have a number of different frame sequences.  In our example,
  10477. we need two sequences; a sequence for animating from the right side of the
  10478. screen to the left side and a sequence for animating from the left to the
  10479. right.  Thus we will label the above frame as Sequence 1. The labels
  10480. are arbitrary numbers ranging from 0 to 65535. However, you must use this
  10481. label to switch to the appropriate sequence when the frames are animated.
  10482.  
  10483.  
  10484.  
  10485.  Programmer's Reference Guide       - 172 -         TEGL Windows Toolkit
  10486.  
  10487.  
  10488.  
  10489.  
  10490.  
  10491.                         Chapter 10 - Animation
  10492.  
  10493.  
  10494.   BounceIcon.sequence(1);
  10495.  
  10496.  
  10497.  
  10498. Use the method ResetSequence to reset the counters within the
  10499. object before creating the second sequence.  We then assign the second
  10500. sequence the arbitrary number of 2.  The only difference between this
  10501. AddFrame and the last AddFrame is the horizontal travel offset.
  10502. Instead of -15, the value is positive, thus adding to the x coordinate.
  10503.  
  10504.  
  10505.  
  10506.   BounceIcon.ResetSequence;
  10507.   BounceIcon.AddFrame(@imageblankbut,15,0,14,37,10,0,0,black);
  10508.   BounceIcon.sequence(2);
  10509.  
  10510.  
  10511.  
  10512. The method AnimateInit, replicates the first screen to the second
  10513. screen.
  10514.  
  10515.  
  10516.  
  10517.   BounceIcon.AnimateInit;
  10518.  
  10519.  
  10520.  
  10521. Set the animation origin. In our test program, we will set the icon to the
  10522. middle of the screen.
  10523.  
  10524.  
  10525.  
  10526.   BounceIcon.Origin(GetMaxx div 2,GetMaxy div 2);
  10527.  
  10528.  
  10529.  
  10530. To animate the frames, we use the method Animate. Animate
  10531. displays the frames until the requested frame count is reached. Since
  10532. we have only one frame to animate within each sequence, the animator
  10533. will loop using the same frame until it satisfies the requested frame
  10534. count.
  10535.  
  10536. However, since we are working with coordinates, we do not know how many
  10537. frames it would take to move the icon across the screen. The method 
  10538. Destination will perform a test run on the sequence until one of the
  10539. coordinates is satisfied and passes back a count of the frames needed to
  10540. reach the destination. Thus, we can use the method Destination with
  10541. the method Animate to finally animate the icon.
  10542.  
  10543.  
  10544.  
  10545.  
  10546.  Programmer's Reference Guide       - 173 -         TEGL Windows Toolkit
  10547.  
  10548.  
  10549.  
  10550.  
  10551.  
  10552.                         Chapter 10 - Animation
  10553.  
  10554.   BounceIcon.sequence(1);
  10555.   BounceIcon.Animate(BounceIcon.Destination(36,0));
  10556.  
  10557.  
  10558.  
  10559. Animating from left to right.
  10560.  
  10561.  
  10562.   BounceIcon.sequence(2);
  10563.   BounceIcon.Animate(BounceIcon.Destination(560,0));
  10564.  
  10565.  
  10566.  
  10567. Try experimenting with the example program.  You can use the same icon to
  10568. add a few more frames to each sequence.  Vary the travel offsets to see
  10569. the effect. However, be careful that the resulting travel distance should
  10570. reach the destination, otherwise the animator will loop forever trying to
  10571. reach a false destination. As well, the method Destination provides
  10572. only an approximate count of frames to reach the destination. The actual
  10573. destination coordinate will depend on the travel offset values on each
  10574. frame added or subtracted from the origin.
  10575.  
  10576.  
  10577. Animation OOPS Methods
  10578.  
  10579.  
  10580. ___________________________________________________________________________
  10581.  
  10582. Origin Procedure Method                                             ANIMATE
  10583. ___________________________________________________________________________
  10584.  
  10585.  
  10586. Function
  10587.                    Sets the animated object's starting origin.
  10588. Declaration
  10589.                    Origin(ox,oy:word)
  10590. Remarks
  10591.                    Sets where the first frame will be displayed.
  10592. See also
  10593.                    GetOrigin, Destination
  10594. Example
  10595.  
  10596.  
  10597. VAR apple : AnimateObject;
  10598.  
  10599. apple.origin(100,100);
  10600.  
  10601.  
  10602.  
  10603.  
  10604.  
  10605.  
  10606.  
  10607.  Programmer's Reference Guide       - 174 -         TEGL Windows Toolkit
  10608.  
  10609.  
  10610.  
  10611.  
  10612.  
  10613.                         Chapter 10 - Animation
  10614.  
  10615. ___________________________________________________________________________
  10616.  
  10617. GetOrigin Procedure Method                                          ANIMATE
  10618. ___________________________________________________________________________
  10619.  
  10620.  
  10621. Function
  10622.                    Gets the animated object's current coordinates.
  10623. Declaration
  10624.                    GetOrigin(VAR lastox,lastoy:integer)
  10625. Remarks
  10626.                    Returns the current coordinate from where Animate
  10627.                    will proceed from.
  10628.  
  10629.                    The Origins of an animated object will change
  10630.                    depending on the travel offset defined in each
  10631.                    animation frame.
  10632. See also
  10633.                    Origin, Destination
  10634. Example
  10635.  
  10636.  
  10637. VAR Apple       : AnimateObject;
  10638.     lastx,lasty : word;
  10639.  
  10640. Apple.Animate(5);
  10641. Apple.GetOrigin(lastx,lasty);
  10642.  
  10643.  
  10644.  
  10645.  
  10646.  
  10647.  
  10648. ___________________________________________________________________________
  10649.  
  10650. Destination Function Method                                         ANIMATE
  10651. ___________________________________________________________________________
  10652.  
  10653.  
  10654. Function
  10655.                    Returns a count on the number of frames that is needed
  10656.                    for animating before the sequence gets the destination
  10657.                    coordinates dx,dy.
  10658. Declaration
  10659.                    GetOrigin(VAR lastox,lastoy:integer)
  10660. Result type
  10661.                    word. frame count.
  10662. Remarks
  10663.                    Destination will return a count if either x
  10664.                    or y coordinates of the origin is less then or
  10665.                    greater then the destination dx,dy coordinates.
  10666.  
  10667.  
  10668.  Programmer's Reference Guide       - 175 -         TEGL Windows Toolkit
  10669.  
  10670.  
  10671.  
  10672.  
  10673.  
  10674.                         Chapter 10 - Animation
  10675.  
  10676.                    Destination is only an approximation of the number
  10677.                    of frames required to complete the travel distance. The
  10678.                    actual movement is dependent on each frame and its
  10679.                    travel offsets.
  10680. See also
  10681.                    Origin, GetOrigin
  10682. Example
  10683.  
  10684.  
  10685. VAR apple       : AnimateObject;
  10686.  
  10687.   Apple.Animate(Apple.Destination(300,300));
  10688.  
  10689.  
  10690.  
  10691.  
  10692.  
  10693.  
  10694. ___________________________________________________________________________
  10695.  
  10696. ResetFrame Procedure Method                                         ANIMATE
  10697. ___________________________________________________________________________
  10698.  
  10699.  
  10700. Function
  10701.                    Resets a sequence to begin at any frame number.
  10702. Declaration
  10703.                    ResetFrame(startframe : word)
  10704. Remarks
  10705.                    if startframe is greater then the number of frames
  10706.                    in the sequence, the sequence is set at the last frame.
  10707.  
  10708.                    startframe of 0 will reset the sequence back to
  10709.                    the beginning.
  10710. See also
  10711.                    Sequence
  10712. Example
  10713.  
  10714.  
  10715.  
  10716. VAR Apple       : AnimateObject;
  10717.  
  10718. Apple.ResetFrame(0);
  10719. Apple.Animate(5);
  10720.  
  10721.  
  10722.  
  10723.  
  10724.  
  10725. ___________________________________________________________________________
  10726.  
  10727. Sequence Procedure Method                                           ANIMATE
  10728.  
  10729.  Programmer's Reference Guide       - 176 -         TEGL Windows Toolkit
  10730.  
  10731.  
  10732.  
  10733.  
  10734.  
  10735.                         Chapter 10 - Animation
  10736.  
  10737. ___________________________________________________________________________
  10738.  
  10739.  
  10740. Function
  10741.                    Sets the sequence pointer.
  10742. Declaration
  10743.                    Sequence(seqnum:word)
  10744. Remarks
  10745.                    seqnum is any number associated with a sequence of
  10746.                    frames. If the sequence number does not exist, the
  10747.                    method will assume that a new sequence will be created.
  10748.  
  10749.                    Creating a new sequence, simply records the seqnum
  10750.                    and the start frame. So creating a sequence can occur
  10751.                    anytime after adding the first frame. You can continue
  10752.                    to add frames after Sequence. Use 
  10753.                    ResetSequence to clear and start a new sequence.
  10754. See also
  10755.                    ResetSequence, ResetFrame
  10756. Example
  10757.  
  10758.  
  10759. VAR Apple       : AnimateObject;
  10760.  
  10761.   Apple.init;
  10762.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10763.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10764.   Apple.sequence(88);
  10765.  
  10766.   Apple.ResetSequence;
  10767.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10768.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10769.   Apple.sequence(99);
  10770.  
  10771.   Apple.sequence(88);
  10772.   Apple.animate(5);
  10773.  
  10774.  
  10775.  
  10776.  
  10777.  
  10778. ___________________________________________________________________________
  10779.  
  10780. ResetSequence Procedure Method                                      ANIMATE
  10781. ___________________________________________________________________________
  10782.  
  10783.  
  10784. Function
  10785.                    Sets the internal data pointers firstframe and 
  10786.                    currentframe to nil.
  10787. Declaration
  10788.                    ResetSequence
  10789.  
  10790.  Programmer's Reference Guide       - 177 -         TEGL Windows Toolkit
  10791.  
  10792.  
  10793.  
  10794.  
  10795.  
  10796.                         Chapter 10 - Animation
  10797.  
  10798. Remarks
  10799.                    ResetSequence will reset the internal data
  10800.                    pointers to nil. This will allow a new sequence to
  10801.                    begin.
  10802. Restrictions
  10803.                    Use the method Sequence to save the data pointers,
  10804.                    otherwise all created frames will be lost.
  10805. See also
  10806.                    ResetSequence, ResetFrame
  10807. Example
  10808.  
  10809.  
  10810. VAR apple       : AnimateObject;
  10811.  
  10812.   Apple.init;
  10813.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10814.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10815.   Apple.sequence(88);
  10816.  
  10817.   Apple.ResetSequence;
  10818.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10819.   Apple.addframe(@imageapple,mx,my,ht,wd,dl,hz,hzdl,color);
  10820.   Apple.sequence(99);
  10821.  
  10822.   Apple.sequence(88);
  10823.   Apple.animate(5);
  10824.  
  10825.  
  10826.  
  10827.  
  10828.  
  10829. ___________________________________________________________________________
  10830.  
  10831. AddFrame Procedure Method                                           ANIMATE
  10832. ___________________________________________________________________________
  10833.  
  10834.  
  10835. Function
  10836.                    Add a animation frame.
  10837. Declaration
  10838.                    AddFrame(pp:pointer; mx,my: integer; ht,wd,dy,hz,
  10839.                    hzdy,co:word)
  10840. Remarks
  10841.                    AddFrame is the icon definition pointer.
  10842.  
  10843.                    mx,my is the travel offsets that are added to the
  10844.                    origin after the icon is displayed.
  10845.  
  10846.                    ht,wd is the height and width of the icon. These
  10847.                    parameters are used to save the background image before
  10848.                    drawing the icon.
  10849.  
  10850.  
  10851.  Programmer's Reference Guide       - 178 -         TEGL Windows Toolkit
  10852.  
  10853.  
  10854.  
  10855.  
  10856.  
  10857.                         Chapter 10 - Animation
  10858.  
  10859.                    dy is the delay in milliseconds after displaying
  10860.                    the image.
  10861.  
  10862.                    hz,hzdy is the frequency of the frame sound, and
  10863.                    hzdy is the duration. If the duration of hzdy is
  10864.                    longer then the image dy, then dy is used for
  10865.                    the frame and the sound is left on after the frame
  10866.                    ends.
  10867.  
  10868.                    co is the replacement color for the BLACK
  10869.                    color pixels defined in the icon.
  10870. Restrictions
  10871.                    Use the method Sequence to save the data pointers,
  10872.                    otherwise all created frames will be lost.
  10873. See also
  10874. ResetSequence, ResetFrame
  10875. Example
  10876.  
  10877.  
  10878. VAR apple       : AnimateObject;
  10879.  
  10880.   Apple.Init;
  10881.   Apple.Addframe(@imageblankbut,-15,0,14,37,10,0,0,black);
  10882.   Apple.Animate(5);
  10883.  
  10884.  
  10885.  
  10886.  
  10887.  
  10888. ___________________________________________________________________________
  10889.  
  10890. CurrentFrameNumber Function Method                                  ANIMATE
  10891. ___________________________________________________________________________
  10892.  
  10893.  
  10894. Function
  10895.                    Returns the current frame number.
  10896. Declaration
  10897.                    CurrentFrameNumber
  10898. Result type
  10899.                    word.
  10900. See also
  10901.                    ResetFrame
  10902.  
  10903.  
  10904.  
  10905. ___________________________________________________________________________
  10906.  
  10907. AnimateInit Procedure Method                                        ANIMATE
  10908. ___________________________________________________________________________
  10909.  
  10910.  
  10911.  
  10912.  Programmer's Reference Guide       - 179 -         TEGL Windows Toolkit
  10913.  
  10914.  
  10915.  
  10916.  
  10917.  
  10918.                         Chapter 10 - Animation
  10919.  
  10920. Function
  10921.                    Replicates the first active screen page to the second
  10922.                    in preparation for animating.
  10923. Declaration
  10924.                    AnimateInit
  10925. See also
  10926.                    ResetFrame
  10927.  
  10928.  
  10929.  
  10930. ___________________________________________________________________________
  10931.  
  10932. Animate Procedure Method                                            ANIMATE
  10933. ___________________________________________________________________________
  10934.  
  10935.  
  10936. Function
  10937.                    Begins the Animation Sequence.
  10938. Declaration
  10939.                    Animate(numframe : word)
  10940. Remarks
  10941.                    numframe is the number of frames to animate. If
  10942.                    the number of frames in a sequence is less then the
  10943.                    requested numframe, then the sequence loops to the
  10944.                    beginning.
  10945. Restrictions
  10946.                    Since animate uses two video pages, the method 
  10947.                    AnimateInit must be called to replicate the first page
  10948.                    to the second.
  10949. See also
  10950.                    ResetFrame, Destination
  10951.  
  10952.  
  10953.  
  10954. ___________________________________________________________________________
  10955.  
  10956. Complete Procedure Method                                           ANIMATE
  10957. ___________________________________________________________________________
  10958.  
  10959.  
  10960. Function
  10961.                    Closes the Animation Sequence.
  10962. Declaration
  10963.                    Complete
  10964. Remarks
  10965.                    Complete toggles the sound off and resets the
  10966.                    frame to the beginning.
  10967.  
  10968.  
  10969.  
  10970. Example Animation
  10971.  
  10972.  
  10973.  Programmer's Reference Guide       - 180 -         TEGL Windows Toolkit
  10974.  
  10975.  
  10976.  
  10977.  
  10978.  
  10979.                         Chapter 10 - Animation
  10980.  
  10981.  
  10982.  
  10983.  
  10984. {$F+}
  10985. USES Graph,crt,SoundUnt,FastGrph,TEGLUnit,Animate,TEGLIcon;
  10986.  
  10987. VAR BounceIcon   : AnimateObject;
  10988.  
  10989. BEGIN
  10990.    EGA640x350x16;
  10991.  
  10992.    setfillStyle(widedotfill,lightgray);
  10993.    bar(0,0,getmaxx,getmaxy);
  10994.  
  10995.    with BounceIcon do
  10996.       begin
  10997.         init;
  10998.         addframe(@imageblankbut,-15,-3,14,37,10,0,0,black);
  10999.         addframe(@imageblankbut,-15,3,14,37,10,0,0,black);
  11000.         addframe(@imageblankbut,-15,3,14,37,10,0,0,black);
  11001.         addframe(@imageblankbut,-15,-3,14,37,10,0,0,black);
  11002.         sequence(1);
  11003.  
  11004.         ResetSequence;
  11005.         addframe(@imageblankbut,15,-3,14,37,10,0,0,black);
  11006.         addframe(@imageblankbut,15,3,14,37,10,0,0,black);
  11007.         addframe(@imageblankbut,15,3,14,37,10,0,0,black);
  11008.         addframe(@imageblankbut,15,-3,14,37,10,0,0,black);
  11009.         sequence(2);
  11010.  
  11011.         Animateinit;
  11012.         Origin(getmaxx div 2,getmaxy div 2);
  11013.  
  11014.         ClearKeyBoardBuf;
  11015.         while not keypressed do
  11016.            begin
  11017.               sequence(1);
  11018.               ResetFrame(0);
  11019.               Animate(Destination(36,0));
  11020.               Beep(1500,1,1);
  11021.  
  11022.               sequence(2);
  11023.               ResetFrame(0);
  11024.               Animate(Destination(560,0));
  11025.               Beep(1500,1,1);
  11026.            end;
  11027.       end;
  11028.  
  11029.    ABORT('BYE...');
  11030. END.
  11031.  
  11032.  
  11033.  
  11034.  Programmer's Reference Guide       - 181 -         TEGL Windows Toolkit
  11035.  
  11036.  
  11037.  
  11038.  
  11039.  
  11040.                         Chapter 10 - Animation
  11041.  
  11042.  
  11043.  
  11044.  
  11045.  
  11046.  
  11047.  
  11048.  
  11049.  
  11050.  
  11051.  
  11052.  
  11053.  
  11054.  
  11055.  
  11056.  
  11057.  
  11058.  
  11059.  
  11060.  
  11061.  
  11062.  
  11063.  
  11064.  
  11065.  
  11066.  
  11067.  
  11068.  
  11069.  
  11070.  
  11071.  
  11072.  
  11073.  
  11074.  
  11075.  
  11076.  
  11077.  
  11078.  
  11079.  
  11080.  
  11081.  
  11082.  
  11083.  
  11084.  
  11085.  
  11086.  
  11087.  
  11088.  
  11089.  
  11090.  
  11091.  
  11092.  
  11093.  
  11094.  
  11095.  Programmer's Reference Guide       - 182 -         TEGL Windows Toolkit
  11096.  
  11097.  
  11098.  
  11099.  
  11100.  
  11101.                       Chapter 11 - Writing Text
  11102.  
  11103.  
  11104. Writing Text
  11105. ___________________________________________________________________________
  11106.  
  11107. TEGL Windows Toolkit provides the tools to write to the screen using
  11108. proportional bit-mapped fonts. Fonts may be as small as 5 pixels high and
  11109. 3 pixels wide or as large as 24 pixels high and 8 pixels wide.
  11110.  
  11111. Both BGI vector fonts and TEGL bit-mapped fonts may be used together.
  11112. Like TP's OutTextXY procedure, TEGLOutTextXY is affected by
  11113. the SetTextJustify procedure. To turn off the Proportional
  11114. print, use the procedure SetProportional(false).
  11115.  
  11116. TEGLWrt Variables
  11117.  
  11118. Bit-mapped Fonts
  11119.  
  11120. There are 25 bit-mapped fonts available in the TEGLWrt unit.
  11121. They are:
  11122.  
  11123. FONT09, FONT14, COUNTDWN, OENGLISH, SCRIPT, OCR, FRAKTUR, ITALIC, GEORGIAN,
  11124. APLS7, PC9, GAELIC, LITALIC, PC24, PC3270, M3270, EGA09, FUTURE, BROADWAY,
  11125. SCRIPT2, LCDFONT, LIGHT14, BRDWX19, SANSX19, WNDWX19, LIGHT9.
  11126.  
  11127. To select a font, just pass the address to SetTEGLFont.
  11128. i.e. SetTEGLFont(@COUNTDN).
  11129.  
  11130. Creating Your Own Bit-mapped Fonts
  11131.  
  11132. You can create and add your own fonts by modifying the assembler files
  11133. then assembling the new font to to an object file.  Each bit in a byte
  11134. represents a pixel of the font.
  11135.  
  11136. The format of a TEGL font is:
  11137.  
  11138.  
  11139.  
  11140.     1 byte header - indicating the height of the font.
  11141.  
  11142.     Each character is:
  11143.     1 byte  - proportional font width
  11144.     n bytes - defined by the 1 byte header
  11145.  
  11146.  
  11147.  
  11148.  
  11149. TEGLWrt Functions and Procedures
  11150.  
  11151.  
  11152. ___________________________________________________________________________
  11153.  
  11154. OutTEGLTextXY Procedure                                            FASTGRPH
  11155.  
  11156.  Programmer's Reference Guide       - 183 -         TEGL Windows Toolkit
  11157.  
  11158.  
  11159.  
  11160.  
  11161.  
  11162.                       Chapter 11 - Writing Text
  11163.  
  11164. ___________________________________________________________________________
  11165.  
  11166.  
  11167. Function
  11168.                    Writes mystr to the graphics screen at x,y.
  11169. Declaration
  11170.                    OutTEGLTextXY(x,y : integer; mystr : string)
  11171. Remarks
  11172.                    OutTEGLTextXY is affected by the justification
  11173.                    settings set by SetTextJustify and color by 
  11174.                    SetColor.
  11175.  
  11176.                    x,y is the coordinates of the graphic screen.
  11177.  
  11178.                    mystr is the text string for output.
  11179.  
  11180.                    FontTable is a global variable which is used to
  11181.                    set the pointer to an internal font table.
  11182. See also
  11183.                    TEGLWrtChar
  11184. Example
  11185.  
  11186.  
  11187.   SetTextJustify(CenterText,CenterText);
  11188.   SetColor(green);
  11189.   SetTEGLFont(@Script);
  11190.   OutTEGLTextXY(100,100,'TEGL Systems Corporation');
  11191.  
  11192.  
  11193.  
  11194.  
  11195.  
  11196.  
  11197. ___________________________________________________________________________
  11198.  
  11199. TEGLTextWidth Function                                             FASTGRPH
  11200. ___________________________________________________________________________
  11201.  
  11202.  
  11203. Function
  11204.                    Returns the proportional width of mystr.
  11205. Declaration
  11206.                    TEGLTextWidth(mystr : string)
  11207. Result type
  11208.                    integer size of mystr.
  11209. Remarks
  11210.                    TEGLTextWidth will scan and total the exact number
  11211.                    of pixels mystr will occupy.
  11212. Restrictions
  11213.                    Any unprintable characters will not be included in the
  11214.                    final size.
  11215. See also
  11216.  
  11217.  Programmer's Reference Guide       - 184 -         TEGL Windows Toolkit
  11218.  
  11219.  
  11220.  
  11221.  
  11222.  
  11223.                       Chapter 11 - Writing Text
  11224.  
  11225.                    TEGLCharWidth, TEGLCharHeight
  11226.  
  11227.  
  11228.  
  11229. ___________________________________________________________________________
  11230.  
  11231. TEGLCharWidth Function                                             FASTGRPH
  11232. ___________________________________________________________________________
  11233.  
  11234.  
  11235. Function
  11236.                    Returns the proportional width of a character.
  11237. Declaration
  11238.                    TEGLCharWidth(c : word)
  11239. Result type
  11240.                    Word.
  11241. Remarks
  11242.                    c is the ordinal value of the character.
  11243.  
  11244.                    TEGLCharWidth will return a value based on the
  11245.                    currently selected font.
  11246. Restrictions
  11247.                    Characters outside the 28-126 ascii code will return a
  11248.                    invalid size.
  11249. See also
  11250.                    TEGLTextWidth, TEGLCharHeight
  11251.  
  11252.  
  11253.  
  11254. ___________________________________________________________________________
  11255.  
  11256. TEGLCharHeight Function                                            FASTGRPH
  11257. ___________________________________________________________________________
  11258.  
  11259.  
  11260. Function
  11261.                    Returns the height of the proportional font.
  11262. Declaration
  11263.                    TEGLCharHeight
  11264. Result type
  11265.                    Word.
  11266. Remarks
  11267.                    TEGLCharHeight will return to the first byte in
  11268.                    the font table which is the height of the current font.
  11269. See also
  11270.                    TEGLTextWidth, TEGLCharWidth
  11271.  
  11272.  
  11273.  
  11274. ___________________________________________________________________________
  11275.  
  11276. TEGLWrtChar Procedure                                              FASTGRPH
  11277.  
  11278.  Programmer's Reference Guide       - 185 -         TEGL Windows Toolkit
  11279.  
  11280.  
  11281.  
  11282.  
  11283.  
  11284.                       Chapter 11 - Writing Text
  11285.  
  11286. ___________________________________________________________________________
  11287.  
  11288.  
  11289. Function
  11290.                    Writes a single character to the graphics screen.
  11291. Declaration
  11292.                    TEGLWrtChar (c,x,y,color:word)
  11293. Remarks
  11294.                    x,y specifies the coordinates for writing the
  11295.                    character.
  11296.  
  11297.                    c is the ascii code of the character. Valid
  11298.                    character range is 28-126.
  11299.  
  11300.                    color is color of the output character.
  11301. See also
  11302.                    TEGLOutTextXY
  11303.  
  11304.  
  11305.  
  11306.  
  11307. ___________________________________________________________________________
  11308.  
  11309. SetProportional Procedure                                          FASTGRPH
  11310. ___________________________________________________________________________
  11311.  
  11312.  
  11313. Function
  11314.                    Switch Proportional font on or off.
  11315. Declaration
  11316.                    SetProportional(onoff:boolean)
  11317. Remarks
  11318.                    Default is proportional font on TRUE. If
  11319.                    proportional font is off FALSE, the spacing is 8
  11320.                    bits.
  11321.  
  11322.  
  11323.  
  11324. ___________________________________________________________________________
  11325.  
  11326. SetTEGLFont Procedure                                              FASTGRPH
  11327. ___________________________________________________________________________
  11328.  
  11329.  
  11330. Function
  11331.                    Sets the font to use in subsequent calls to
  11332.                    OutTEGLTextXY.
  11333. Declaration
  11334.                    SetTEGLFont(P : Pointer);
  11335. Remarks
  11336.                    This procedure simply sets the FontTable variable
  11337.                    to the address in P.
  11338.  
  11339.  Programmer's Reference Guide       - 186 -         TEGL Windows Toolkit
  11340.  
  11341.  
  11342.  
  11343.  
  11344.  
  11345.                       Chapter 11 - Writing Text
  11346.  
  11347.  
  11348.  
  11349.  
  11350. ___________________________________________________________________________
  11351.  
  11352. UnderLineChar Function                                             FASTGRPH
  11353. ___________________________________________________________________________
  11354.  
  11355.  
  11356. Function
  11357.                    Returns the character with the high bit set.
  11358. Declaration
  11359.                    UnderLineChar(c : Char): Char;
  11360. Remarks
  11361.                    OutTEGLTextXY detects characters with the high bit
  11362.                    set and underlines them.
  11363. Restrictions
  11364.                    Underline does not work with TEGLWrtChar.
  11365.  
  11366.                    Underline does not work on characters with decenders.
  11367.  
  11368.  
  11369. Showing ALL Fonts FONTTEST.PAS
  11370.  
  11371. The TEGLSam.PAS demonstration program uses the FontTest unit to
  11372. display all available fonts, or, individual fonts by selecting from a menu.
  11373.  
  11374.  
  11375. ___________________________________________________________________________
  11376.  
  11377. FontName Function                                                  FONTTEST
  11378. ___________________________________________________________________________
  11379.  
  11380.  
  11381. Function
  11382.                    Returns the name of a font.
  11383. Declaration
  11384.                    FontName(fontnum:word);
  11385. Result type
  11386.                    string.
  11387. Remarks
  11388.                    FontName is used to build the menu for selective
  11389.                    display of fonts.
  11390. See also
  11391.                    ShowOneFont, ShowFonts
  11392.  
  11393.  
  11394.  
  11395. ___________________________________________________________________________
  11396.  
  11397. ShowOneFont Event                                                  FONTTEST
  11398. ___________________________________________________________________________
  11399.  
  11400.  Programmer's Reference Guide       - 187 -         TEGL Windows Toolkit
  11401.  
  11402.  
  11403.  
  11404.  
  11405.  
  11406.                       Chapter 11 - Writing Text
  11407.  
  11408.  
  11409.  
  11410. Function
  11411.                    An Event that displays a font based on
  11412.                    MouseClickPos^.ClickNumber.
  11413. Remarks
  11414.                    FontName is used to build the menu for selective
  11415.                    display of fonts. The entries are positional, thereby
  11416.                    each menu MouseClickPos selection corresponds to a
  11417.                    fontnumber.
  11418. See also
  11419.                    FontName, ShowFonts
  11420.  
  11421.  
  11422.  
  11423. ___________________________________________________________________________
  11424.  
  11425. ShowFonts Event                                                    FONTTEST
  11426. ___________________________________________________________________________
  11427.  
  11428.  
  11429. Function
  11430.                    A TEGL Event that displays all fonts.
  11431. Declaration
  11432.                    ShowFonts(Frame:imagestkptr; Ms: MsClickPtr) : word;
  11433. Remarks
  11434.                    A TEGL Event that displays all the available fonts and
  11435.                    their respective names.
  11436. See also
  11437.                    FontName, ShowOneFont
  11438.  
  11439.  
  11440.  
  11441.  
  11442.  
  11443.  
  11444.  
  11445.  
  11446.  
  11447.  
  11448.  
  11449.  
  11450.  
  11451.  
  11452.  
  11453.  
  11454.  
  11455.  
  11456.  
  11457.  
  11458.  
  11459.  
  11460.  
  11461.  Programmer's Reference Guide       - 188 -         TEGL Windows Toolkit
  11462.  
  11463.  
  11464.  
  11465.  
  11466.  
  11467.                       Chapter 12 - Event Library
  11468.  
  11469. Event Library
  11470. ___________________________________________________________________________
  11471.  
  11472. Although we call it a library, the Event's covered here span over several
  11473. units.
  11474.  
  11475. The event library contains events that may be used immediately in
  11476. programming an application.
  11477.  
  11478. The File Selector
  11479.  
  11480. The file selector SelectaFile provides a dialogue event, that
  11481. displays the files of a directory and lets the user select one of the
  11482. existing files or enter a new file name.
  11483.  
  11484. The file selector dialogue box allows the user to choose any displayed file
  11485. either by clicking on the file name and then clicking on the OK button or by
  11486. clicking on the selection area and typing in the filename.
  11487.  
  11488. To change directories, position the mouse cursor at a directory filename
  11489. and click or click at the bar at the top of the file selector window and
  11490. type in the directory path.
  11491.  
  11492. SelectaFile will return the full file name, including the directory
  11493. prefix, for the file selected.  If the Cancel button was clicked
  11494. or no file was selected, the file name returned will be an empty string.
  11495.  
  11496.  
  11497. ___________________________________________________________________________
  11498.  
  11499. SelectaFile function                                               SELECTFL
  11500. ___________________________________________________________________________
  11501.  
  11502.  
  11503. Function
  11504.                    Provides a file selection dialogue that allows a user
  11505.                    to choose or create a new filename.
  11506. Declaration
  11507.                    Selectafile(x,y:word; var path,fileselected:
  11508.                    string)
  11509. Result type
  11510.                    boolean. True if a file was selected. False if no file
  11511.                    was selected or the mouse clicked on the cancel button.
  11512.  
  11513. Remarks
  11514.                    x,y is the coordinates where the file selection
  11515.                    dialogue will be displayed.
  11516.  
  11517.                    path is the original directory path specification.
  11518.                    Use a global string variable to retain the last
  11519.                    directory path.
  11520.  
  11521.  
  11522.  Programmer's Reference Guide       - 189 -         TEGL Windows Toolkit
  11523.  
  11524.  
  11525.  
  11526.  
  11527.  
  11528.                       Chapter 12 - Event Library
  11529.  
  11530.                    fileselected will contain the selected path and
  11531.                    filename, if the function returns True.
  11532. Example
  11533.  
  11534.  
  11535.  
  11536. function FileSelect(Frame:imagestkptr;
  11537.            MouseClickPos: msclickptr) : word;
  11538.    var x,y,x1,y1      : word;
  11539.        IFS            : imagestkptr;
  11540.        selected       : boolean;
  11541.        selectedfile   : string;
  11542.    begin
  11543.       selected := selectafile(100,100,path,selectedfile);
  11544.  
  11545.       hidemouse;
  11546.       x  := 10;
  11547.       y  := 60;
  11548.       x1 := x+500;
  11549.       y1 := y+100;
  11550.  
  11551.       PushImage(x,y,x1,y1);
  11552.       IFS := stackptr;
  11553.       shadowbox(x,y,x1,y1);
  11554.       setcolor(black);
  11555.  
  11556.       if not selected then
  11557.          outTEGLtextxy(x+5,y+3,'No file were selected.')
  11558.       else
  11559.         begin
  11560.            outTEGLtextxy(x+5,y+3,'The file selected is:');
  11561.            FONTTABLE := @FONT09;
  11562.            outTEGLtextxy(x+5,y+17,selectedfile);
  11563.            FONTTABLE := @font14;
  11564.         end;
  11565.  
  11566.       Putpict(x+280,y+75,@imageok,black);
  11567.       DefineMouseClickArea(IFS,280,75,280+35,75+12,true,
  11568.         nilunitproc,MSCLICK);
  11569.       setmouseposition(x+290,y+85);
  11570.       showmouse;
  11571.  
  11572.       while CheckforMouseSelect(IFS)=nil do;
  11573.  
  11574.       hidemouse;
  11575.       dropstackimage(ifs);
  11576.       showmouse;
  11577.       fileselectionoption := 1;
  11578.    end;
  11579.  
  11580.  
  11581.  
  11582.  
  11583.  Programmer's Reference Guide       - 190 -         TEGL Windows Toolkit
  11584.  
  11585.  
  11586.  
  11587.  
  11588.  
  11589.                       Chapter 12 - Event Library
  11590.  
  11591.  
  11592. String Editing Dialog
  11593.  
  11594. The EditString procedure provides a facility for getting text input
  11595. from the user.  The file selector uses this routine to get a new filename.
  11596.  
  11597.  
  11598. ___________________________________________________________________________
  11599.  
  11600. EditString Procedure                                               SELECTFL
  11601. ___________________________________________________________________________
  11602.  
  11603.  
  11604. Function
  11605.                    Provides string input facility.
  11606. Declaration
  11607.                    EditString(fs:imagestkptr; x,y,maxlen : word;
  11608.                    var textstr : string)
  11609. Remarks
  11610.                    fs is of the type imagestkptr, created by 
  11611.                    pushimage.
  11612.  
  11613.                    x,y is the relative coordinates from the upper
  11614.                    left of fs where a blinking vertical bar and text
  11615.                    input will be displayed.
  11616.  
  11617.                    maxlen is the number of maximum number of input
  11618.                    characters.
  11619.  
  11620.                    textstr is the user input string.
  11621. Restrictions
  11622.                    String editing should be on the topmost window.
  11623. Example
  11624.  
  11625.  
  11626. VAR mystring;
  11627.  
  11628.   pushimage(100,100,150,150);
  11629.   FONTTABLE := @FONT14;
  11630.   Editstring(stackptr,5,5,12,mystring);
  11631.  
  11632.  
  11633.  
  11634.  
  11635.  
  11636. Mouse Sensitivity Dialogue Window
  11637.  
  11638. The mouse sensitivity dialogue box allows the user to change the horizontal,
  11639. vertical and threshold settings of the mouse. The dialogue box consists of
  11640. radio type buttons that can adjust the numeric counters.
  11641.  
  11642.  
  11643.  
  11644.  Programmer's Reference Guide       - 191 -         TEGL Windows Toolkit
  11645.  
  11646.  
  11647.  
  11648.  
  11649.  
  11650.                       Chapter 12 - Event Library
  11651.  
  11652. ___________________________________________________________________________
  11653.  
  11654. SetMouseSense Procedure                                             SENSEMS
  11655. ___________________________________________________________________________
  11656.  
  11657.  
  11658. Function
  11659.                    Provides a mouse sensitivity dialogue window that
  11660.                    allows the user to change the sensitivity setting of
  11661.                    the mouse.
  11662. Declaration
  11663.                    SetMouseSense(x,y:word)
  11664. Remarks
  11665.                    x,y is the coordinates where the SetMouseSense
  11666.                    dialogue will be displayed.
  11667. Restrictions
  11668.                    The dialogue does not check if the mouse is present.
  11669. Example
  11670.  
  11671.  
  11672. function AskMouseSense(Frame:imagestkptr;
  11673.            MouseClickPos: msclickptr) : word;
  11674.    begin
  11675.       SetMouseSense(160,75);
  11676.       AskMouseSense := 1;
  11677.    end;
  11678.  
  11679.  
  11680.  
  11681.  
  11682.  
  11683. Bells & Whistles, Sound Unit
  11684.  
  11685. The AskSoundSense dialogue window allows the user to change the duration
  11686. of the beeps and whistle settings of the sound unit. The dialogue box consists
  11687. of radio type buttons that can adjust the numeric counters.
  11688.  
  11689.  
  11690. ___________________________________________________________________________
  11691.  
  11692. AskSoundSense Event                                                SOUNDUNT
  11693. ___________________________________________________________________________
  11694.  
  11695.  
  11696. Function
  11697.                    A sound duration dialogue event
  11698. Remarks
  11699.                    An event that displays a dialogue box that permits the
  11700.                    user to set the sound duration for beeps and whistles.
  11701.  
  11702.  
  11703.  
  11704.  
  11705.  Programmer's Reference Guide       - 192 -         TEGL Windows Toolkit
  11706.  
  11707.  
  11708.  
  11709.  
  11710.  
  11711.                       Chapter 12 - Event Library
  11712.  
  11713. ___________________________________________________________________________
  11714.  
  11715. Beep Procedure                                                     SOUNDUNT
  11716. ___________________________________________________________________________
  11717.  
  11718.  
  11719. Function
  11720.                    Toggles the sound on for a specific tone and 
  11721.                    duration for n times.
  11722. Declaration
  11723.                    beep(tone,n,duration:integer)
  11724. Remarks
  11725.                    tone specifies the frequency of the emitted sound
  11726.                    in hertz.
  11727.  
  11728.                    n specifies the number of times the sound it
  11729.                    toggle on and off.
  11730.  
  11731.                    duration specifies the length in milliseconds of
  11732.                    the sound.
  11733. See also
  11734.                    SlideBeep, SoundSwitch
  11735. Example
  11736.  
  11737.  
  11738.  
  11739. beep(1000,3,100);
  11740.  
  11741.  
  11742.  
  11743.  
  11744.  
  11745.  
  11746. ___________________________________________________________________________
  11747.  
  11748. SlideBeep Procedure                                                SOUNDUNT
  11749. ___________________________________________________________________________
  11750.  
  11751.  
  11752. Function
  11753.                    Performs a sliding type of sound. Whistle type.
  11754. Declaration
  11755.                    slidebeep(tone1,tone2,n:integer)
  11756. Remarks
  11757.                    tone1 specifies the initial frequency of the
  11758.                    emitted sound in hertz. tone2 specifies the second
  11759.                    frequency from which tone1 steps towards.
  11760.  
  11761.                    n specifies the number of times the slide beep
  11762.                    occurs.
  11763. See also
  11764.                    Beep, SoundSwitch
  11765.  
  11766.  Programmer's Reference Guide       - 193 -         TEGL Windows Toolkit
  11767.  
  11768.  
  11769.  
  11770.  
  11771.  
  11772.                       Chapter 12 - Event Library
  11773.  
  11774. Example
  11775.  
  11776.  
  11777. slidebeep(1000,2000,2);
  11778.  
  11779.  
  11780.  
  11781.  
  11782.  
  11783. ___________________________________________________________________________
  11784.  
  11785. SoundSwitch Procedure                                              SOUNDUNT
  11786. ___________________________________________________________________________
  11787.  
  11788.  
  11789. Function
  11790.                    Switches the sound function on/off.
  11791. Declaration
  11792.                    SoundSwitch(OnOff:boolean)
  11793. Remarks
  11794.                    OnOff switches the sound on True or off 
  11795.                    False.
  11796. See also
  11797.                    Beep, SlideBeep
  11798.  
  11799.  
  11800.  
  11801.  
  11802.  
  11803.  
  11804.  
  11805.  
  11806.  
  11807.  
  11808.  
  11809.  
  11810.  
  11811.  
  11812.  
  11813.  
  11814.  
  11815.  
  11816.  
  11817.  
  11818.  
  11819.  
  11820.  
  11821.  
  11822.  
  11823.  
  11824.  
  11825.  
  11826.  
  11827.  Programmer's Reference Guide       - 194 -         TEGL Windows Toolkit
  11828.  
  11829.  
  11830.  
  11831.  
  11832.  
  11833.                  Chapter 13 - Virtual Memory Manager
  11834.  
  11835. Virtual Memory Manager
  11836. ___________________________________________________________________________
  11837. Graphical images, by their nature, require a tremendous amount of memory
  11838. to store and manipulate. Combine this with the DOS limitation of 640k,
  11839. writing applications using a graphical environment can be limiting.
  11840.  
  11841. Virtual Memory is a concept by which less expensive mass storage devices
  11842. (ie. hard disk) may be used as though it were an extension of memory. Then
  11843. memory is only limited by the size of the hard disk.
  11844.  
  11845. The TEGL virtual memory manager may be used within your application
  11846. program independent of its use within the TEGL window manager.
  11847.  
  11848. In this chapter, we provide technical information for advanced
  11849. programmers. We'll cover topics such as the Virtual Memory Manager, Turbo
  11850. Pascal's heap manager, Expanded Memory Manager, calling conventions, and
  11851. more.
  11852.  
  11853. The Turbo Pascal Heap manager is covered in greater detail in the Turbo
  11854. Pascal Reference Guide, Chapter 15, Inside Turbo Pascal.
  11855.  
  11856.  
  11857. Heap Management
  11858. With Window Management routines, the memory requirement is unknown. If we
  11859. were to attempt to ensure that memory is available for every window that
  11860. is created within the program, we would have an unwieldy and unjustifiably
  11861. large program. In actual fact, any modest application would require much
  11862. more memory than is available.
  11863.  
  11864. Rather then attempting to reserve a fixed amount of memory space, which
  11865. places a limitation on the program, the heap provides the facility of
  11866. allocating memory dynamically. The heap permits us to allocate memory only
  11867. when it is required and to release the memory when the task is completed.
  11868.  
  11869. The Turbo Pascal Heap Manager
  11870.  
  11871. In Turbo Pascal the heap is all the remaining memory that is left when
  11872. a program is executed.
  11873.  
  11874. Memory is allocated from the heap starting with the lowest part of the
  11875. heap growing upwards. The bottom of the heap is stored in the variable 
  11876. HeapOrg. Each time a block of memory is allocated on the heap (via New
  11877. or GetMem), the heap manage moves HeapPtr upward by the size of
  11878. the requested block.
  11879.  
  11880. The top of the heap, or the maximum size of the heap is controlled by the
  11881. variable FreePtr. It does not point directly at the maximum top,
  11882. rather it points at the start of the free pointer chain.
  11883.  
  11884. The free pointer chain grows downward as memory blocks are freed. Adjacent
  11885. memory blocks are always combined to form larger blocks.
  11886.  
  11887.  
  11888.  Programmer's Reference Guide       - 195 -         TEGL Windows Toolkit
  11889.  
  11890.  
  11891.  
  11892.  
  11893.  
  11894.                  Chapter 13 - Virtual Memory Manager
  11895.  
  11896. The maximum size of a single block of memory, using Turbo Pascal's heap
  11897. manager, is 65519 bytes.
  11898.  
  11899. The TEGL Heap Manager
  11900. The TEGL Heap Manager allows us to allocate memory blocks that are greater
  11901. than 64k. A full EGA screen image (640x350 -16 colors) is approximately
  11902. 109k.
  11903.  
  11904. When a memory request is made to the TEGL Heap Manager, the manager will
  11905. attempt to allocate memory between HeapPtr and FreePtr first,
  11906. before attempting to find space on the free space list.
  11907.  
  11908. Turbo Pascal Heap manager differs from the TEGL Heap Manager in that TP
  11909. will search through the free space chain and reuses the first available
  11910. memory block that can accommodate the request.
  11911.  
  11912. If memory allocation is less then 64k, use Turbo Pascal's GETMem and
  11913. Freemem.
  11914.  
  11915. Use the TEGL Heap Manager sparingly, as this will reduce the amount of
  11916. memory managed by the virtual memory handler (see Resolving Fragments in this
  11917. chapter).
  11918.  
  11919. The TEGL Heap Error Function
  11920. The HugeHeapError variable allows you to install a heap error function,
  11921. which gets called whenever the TEGL heap manager cannot complete an allocation
  11922. request. HugeHeapError is a pointer that points to a function with the
  11923. following header:
  11924.  
  11925.  
  11926.  
  11927.     {$F+} {sh function} ReturnHeapError(size: longint) : word;  {$F-}
  11928.  
  11929.  
  11930.  
  11931. The TEGL heap error function is installed by assigning its address to the
  11932. HugeHeapError variable:
  11933.  
  11934.  
  11935.  
  11936.     HugeHeapError := ReturnHeapError;
  11937.  
  11938.  
  11939.  
  11940. The TEGL heap error function gets called whenever a call to TEGLGetMem
  11941. cannot complete the request. The Size parameter contains the size of
  11942. the block that could not be allocated, and the TEGL heap error function
  11943. should attempt to free a block of at least that size.
  11944.  
  11945. Depending on its success, the TEGL heap error function may return a 1 or 2.
  11946. A return of 2 indicates success and causes a retry (which could also cause
  11947. another call to the TEGL heap error function). A return of any other value
  11948.  
  11949.  Programmer's Reference Guide       - 196 -         TEGL Windows Toolkit
  11950.  
  11951.  
  11952.  
  11953.  
  11954.  
  11955.                  Chapter 13 - Virtual Memory Manager
  11956.  
  11957. will cause TEGLGetMem to return a nil pointer.
  11958.  
  11959. The standard TEGL heap error function always returns a 1, causing
  11960. TEGLGetMem to return a Nil pointer.
  11961.  
  11962. TEGLUnit sets the heap error function to point to the virtual memory
  11963. manager. Don't use the heap error function if you are using TEGLUnit,
  11964. the virtual memory handler depends on this function to know when its time
  11965. to start paging out window buffers.
  11966.  
  11967. The TEGL Heap Manager Functions
  11968.  
  11969.  
  11970. ___________________________________________________________________________
  11971.  
  11972. TEGLGetMem Procedure                                                VIRTMEM
  11973. ___________________________________________________________________________
  11974.  
  11975.  
  11976. Function
  11977.                    Returns a pointer to a memory block of the specified
  11978.                    size.
  11979. Declaration
  11980.                    TEGLGetMem(var Pt: pointer; size: LongInt);
  11981. Remarks
  11982.                    Pt is a pointer variable of any pointer type. Size is a
  11983.                    longint specifying the size, in bytes, of the memory
  11984.                    block to allocate.
  11985.  
  11986.                    If there isn't enough free space on the heap to
  11987.                    allocate the memory block, Pt is set to nil. A user
  11988.                    defined run-time error procedure can be used to
  11989.                    intercept any heap errors (see HugeHeapError).
  11990.  
  11991.                    TEGLGetMem is compatible with Turbo Pascal's Memory
  11992.                    manager and may be used interchangeably.
  11993. Restrictions
  11994.                    There are actually no restrictions on the size of the
  11995.                    largest block that can be allocated, however, DOS
  11996.                    limits you to the remaining memory after the program is
  11997.                    loaded.
  11998. See also
  11999.                    TEGLFreeMem
  12000. Example
  12001.                    Allocates and frees a 128k buffer.
  12002.  
  12003.  
  12004. Uses VirtMem;
  12005.  
  12006. Var buffer : pointer;
  12007.  
  12008. begin
  12009.  
  12010.  Programmer's Reference Guide       - 197 -         TEGL Windows Toolkit
  12011.  
  12012.  
  12013.  
  12014.  
  12015.  
  12016.                  Chapter 13 - Virtual Memory Manager
  12017.  
  12018.   TEGLGetMem(buffer,131072);
  12019.   TEGLFreeMem(buffer,131072);
  12020. end.
  12021.  
  12022.  
  12023.  
  12024.  
  12025.  
  12026. ___________________________________________________________________________
  12027.  
  12028. TEGLFreeMem Procedure                                               VIRTMEM
  12029. ___________________________________________________________________________
  12030.  
  12031.  
  12032. Function
  12033.                    Frees a memory block and returns the memory back to the
  12034.                    heap manager.
  12035. Declaration
  12036.                    TEGLFreeMem(var Pt: pointer; size: LongInt);
  12037. Remarks
  12038.                    Pt is a pointer variable of any pointer type that was
  12039.                    previously assigned by the GetMem or TEGLGetMem
  12040.                    procedure. Size is a longint specifying the size of the
  12041.                    memory block, in bytes, to be freed; it must be 
  12042.                    exactly the same number of bytes previously allocated
  12043.                    to that memory block by GetMem or TEGLGetMem.
  12044.                    TEGLFreeMem returns the memory region to the heap.
  12045.  
  12046.                    TEGLFreeMem is compatible with Turbo Pascal's Memory
  12047.                    manager and may be used interchangeably with GetMem or
  12048.                    TEGLGetMem (see Resolving Fragments for
  12049.                    restrictions).
  12050. Restrictions
  12051.                    You can use TEGLFreeMem to free memory blocks that were
  12052.                    allocated by Turbo Pascal's Getmem. However, TEGLFreeMem
  12053.                    organizes the free space pointer chain in a sorted
  12054.                    order in order to minimize any free space
  12055.                    fragmentation. If ReserveHugeMinimum is used to
  12056.                    partition the heap, use the respective counterparts to
  12057.                    allocated and free the memory (GetMem/FreeMem,
  12058.                    TEGLGetMem/TEGLFreeMem).
  12059. See also
  12060.                    TEGLGetMem
  12061.  
  12062.  
  12063. Expanded Memory Manager (EMM)
  12064.  
  12065. The Expanded Memory Manager is a device driver that controls and manages
  12066. expanded memory and application programs that use expanded memory.
  12067.  
  12068. Expanded memory is memory beyond DOS's 640K-byte limit.  The Expanded
  12069. Memory specification (EMS) supports up to 32M bytes of expanded memory.
  12070.  
  12071.  Programmer's Reference Guide       - 198 -         TEGL Windows Toolkit
  12072.  
  12073.  
  12074.  
  12075.  
  12076.  
  12077.                  Chapter 13 - Virtual Memory Manager
  12078.  
  12079. Because the 8086, 8088, and 80286 (in real mode) microprocessors can
  12080. physically address only 1M byte of memory, they access expanded memory
  12081. through a window in their physical address range.
  12082.  
  12083. This is similar to a book, where pages within the book can retain data.
  12084. However, just like a book, if you wish to retrieve the data, you must
  12085. supply the page number.  As well, when you first create the book
  12086. (returning a handle) the initial number of pages must be specified.  If
  12087. you require more pages after the initial allocation, a new book must be
  12088. created (Version 3.2 EMS did not provide a function that allows you to
  12089. expand the initial allocation with the same handle).
  12090.  
  12091. There are approximately 30 EMS functions calls available with EMS Version
  12092. 4.0; as documented in the specification produced jointly by Lotus
  12093. Development Corporation, Intel Corporation, and Microsoft Corporation.  A
  12094. copy of this documentation (Part number 300275-005) October, 1987, can be
  12095. obtained from Intel Corporation, 3065 Bowers Avenue, Santa Clara, CA
  12096. 95051.
  12097.  
  12098. However, EMM Version 3.2 is still widely used as the driver on most systems,
  12099. and therefore we are limited in terms of compatibility, to the number of
  12100. functions that may be used.
  12101.  
  12102.  
  12103. Expanded Memory Functions
  12104.  
  12105.  
  12106. ___________________________________________________________________________
  12107.  
  12108. EmmInstalled function                                               VIRTMEM
  12109. ___________________________________________________________________________
  12110.  
  12111.  
  12112. Function
  12113.                    Returns an installed status on the Expanded Memory
  12114.                    Manager.
  12115. Declaration
  12116.                    EmmInstalled
  12117. Result type
  12118.                    Returns a boolean status of true, if an EMM driver is
  12119.                    installed on the system, false if not installed.
  12120. Remarks
  12121.                    This function uses the address that is found in the Int
  12122.                    67H vector to inspect the device header of the presumed
  12123.                    EMM. If the EMM is present, the name field at offset
  12124.                    0AH of the device header will contain the string
  12125.                    EMMXXXX0.
  12126.  
  12127.  
  12128.  
  12129.  
  12130. ___________________________________________________________________________
  12131.  
  12132.  Programmer's Reference Guide       - 199 -         TEGL Windows Toolkit
  12133.  
  12134.  
  12135.  
  12136.  
  12137.  
  12138.                  Chapter 13 - Virtual Memory Manager
  12139.  
  12140.  
  12141. EMSPagesAvailable function                                          VIRTMEM
  12142. ___________________________________________________________________________
  12143.  
  12144.  
  12145. Function
  12146.                    Obtains the total number of expanded memory pages
  12147.                    present in the systems, and the number of those pages
  12148.                    that are not already allocated.
  12149. Declaration
  12150.                    EMSPagesAvailable (Var TotalEMSPages,
  12151.                    PagesAvailable: Word)
  12152. Result type
  12153.                    Returns a return code of 0 if EMM software is
  12154.                    successful. A return code other then 0 indicates a
  12155.                    possible error in the EMM software or a memory hardware
  12156.                    error.
  12157. Remarks
  12158.                    This function may be used to determine the number of
  12159.                    pages available before allocating EMS pages.
  12160.  
  12161.  
  12162.  
  12163.  
  12164. ___________________________________________________________________________
  12165.  
  12166. AllocateExpandedMemoryPages function                                VIRTMEM
  12167. ___________________________________________________________________________
  12168.  
  12169.  
  12170. Function
  12171.                    Allocates the requested number of pages (16k per page)
  12172.                    and returns a handle that is used to reference the
  12173.                    allocated pages.
  12174. Declaration
  12175.                    AllocateExpandedMemoryPages(PagesNeeded:Word;
  12176.                    Var Handle:Word)
  12177. Result type
  12178.                    Returns a return code of 0 if EMM software is
  12179.                    successful. A return code of $88 indicates that the
  12180.                    requested sh PagesNeeded is greater then the number
  12181.                    of pages that is currently available in the system.
  12182. See also
  12183.                    MapExpandedMemoryPages, GetPageFrameBaseAddress,
  12184.                    DeallocateExpandedMemoryPages
  12185.  
  12186.  
  12187.  
  12188.  
  12189. ___________________________________________________________________________
  12190.  
  12191. MapExpandedMemoryPages function                                     VIRTMEM
  12192.  
  12193.  Programmer's Reference Guide       - 200 -         TEGL Windows Toolkit
  12194.  
  12195.  
  12196.  
  12197.  
  12198.  
  12199.                  Chapter 13 - Virtual Memory Manager
  12200.  
  12201. ___________________________________________________________________________
  12202.  
  12203.  
  12204. Function
  12205.                    Maps one of the logical pages of expanded memory
  12206.                    assigned to a handle onto one of the four physical
  12207.                    pages within the EMM's page frame.
  12208. Declaration
  12209.                    MapExpandedMemoryPages(Handle,LogicalPage,
  12210.                    PhysicalPage: Word)
  12211. Result type
  12212.                    Returns a return code of 0 if EMM software is
  12213.                    successful. A return code of $8A indicates that the
  12214.                    logical page requested to be mapped is outside the
  12215.                    range of pages that is currently assigned to the
  12216.                    handle.
  12217. Remarks
  12218.                    A logical page is one page from the range of pages that
  12219.                    were allocated through the sh
  12220.                    AllocateExpandedMemoryPages procedure. The
  12221.                    logical-page number must be in the range 
  12222.                    {0_._._._n_-_1}}, where {it n} is the number of
  12223.                    logical pages previously allocated.
  12224.  
  12225.                    A physical page is one of four 16k byte pages, in the
  12226.                    range of 0-3, that may viewed as the window to the
  12227.                    expanded memory. Use sh GetPageFrameBaseAddress to
  12228.                    obtain the segment address to the physical window.
  12229. See also
  12230.                    AllocateExpandedMemoryPages,
  12231.                    GetPageFrameBaseAddress, DeallocateExpandedMemoryPages
  12232.  
  12233.  
  12234.  
  12235.  
  12236.  
  12237. ___________________________________________________________________________
  12238.  
  12239. GetPageFrameBaseAddress function                                    VIRTMEM
  12240. ___________________________________________________________________________
  12241.  
  12242.  
  12243. Function
  12244.                    Returns the segment address of the page frame used by
  12245.                    the Expanded Memory Manager.
  12246. Declaration
  12247.                    GetPageFrameBaseAddress(Var PageFrameAddress:
  12248.                    Word)
  12249. Result type
  12250.                    Returns a return code of 0 if EMM software is
  12251.                    successful. A return code other then 0 indicates a
  12252.                    possible error in the EMM software or a memory hardware
  12253.  
  12254.  Programmer's Reference Guide       - 201 -         TEGL Windows Toolkit
  12255.  
  12256.  
  12257.  
  12258.  
  12259.  
  12260.                  Chapter 13 - Virtual Memory Manager
  12261.  
  12262.                    error.
  12263. Remarks
  12264.                    This is only the segment address of the physical page
  12265.                    frame. Use offsets of $0000 for physical page 0, offset
  12266.                    of $4000 for page 1, offset of $8000 for page 2 and
  12267.                    offset of $C000 for page 3.
  12268. See also
  12269.                    AllocateExpandedMemoryPages,
  12270.                    MapExpandedMemoryPages, DeallocateExpandedMemoryPages
  12271.  
  12272.  
  12273.  
  12274.  
  12275. ___________________________________________________________________________
  12276.  
  12277. DeallocateExpandedMemoryPages function                              VIRTMEM
  12278. ___________________________________________________________________________
  12279.  
  12280.  
  12281. Function
  12282.                    Deallocates (releases) the pages of expanded memory
  12283.                    currently assigned to a handle.
  12284. Declaration
  12285.                    DeallocateExpandedMemoryPages (Handle: Word)
  12286. Result type
  12287.                    Returns a return code of 0 if EMM software is
  12288.                    successful.
  12289. Remarks
  12290.                    This function notifies the Expanded Memory Manager that
  12291.                    the application will not be making further use of the
  12292.                    allocated expanded memory pages. This function would
  12293.                    typically be called by a program just before performing
  12294.                    an exit.
  12295. See also
  12296.                    AllocateExpandedMemoryPages,
  12297.                    MapExpandedMemoryPages, GetPageFrameBaseAddress.
  12298.  
  12299.  
  12300.  
  12301.  
  12302. ___________________________________________________________________________
  12303.  
  12304. GetVersionNumber function                                           VIRTMEM
  12305. ___________________________________________________________________________
  12306.  
  12307.  
  12308. Function
  12309.                    Returns the EMM Version Number in a string format. A
  12310.                    handle.
  12311. Declaration
  12312.                    GetVersionNumber(Var VersionString: string)
  12313. Result type
  12314.  
  12315.  Programmer's Reference Guide       - 202 -         TEGL Windows Toolkit
  12316.  
  12317.  
  12318.  
  12319.  
  12320.  
  12321.                  Chapter 13 - Virtual Memory Manager
  12322.  
  12323.                    Returns a return code of 0 if EMM software is
  12324.                    successful. A return code other then 0 indicates a
  12325.                    possible error in the EMM software or a memory hardware
  12326.                    error.
  12327. Remarks
  12328.                    This function returns a EMM Version Number that may be
  12329.                    used to check if the installed EMM will support the
  12330.                    requested functions. However since Version 4.00 of the
  12331.                    expanded memory specification is downward compatible
  12332.                    with Version 3.2, this function is only useful as
  12333.                    information.
  12334.  
  12335.  
  12336.  
  12337. ___________________________________________________________________________
  12338.  
  12339. GetHandleCountUsed function                                         VIRTMEM
  12340. ___________________________________________________________________________
  12341.  
  12342.  
  12343. Function
  12344.                    Returns the number of total handles used by all
  12345.                    applications. a handle.
  12346. Declaration
  12347.                    GetHandleCountUsed (var NumberOfHandles: Word)
  12348. Result type
  12349.                    Returns a return code of 0 if EMM software is
  12350.                    successful. A return code other then 0 indicates a
  12351.                    possible error in the EMM software or a memory hardware
  12352.                    error.
  12353. Remarks
  12354.                    The number of available handles depends on the
  12355.                    parameters used to start up the EMM driver, as well as
  12356.                    the number of handles in use by other resident or
  12357.                    multitasking software. The upper limit in Version 4.00
  12358.                    is 255 handles with a lower limit of 32. If the
  12359.                    returned number of handles is zero, the EMM is idle and
  12360.                    none of the expanded memory is in use.
  12361.  
  12362.  
  12363.  
  12364. ___________________________________________________________________________
  12365.  
  12366. GetPagesOwnedByHandle function                                      VIRTMEM
  12367. ___________________________________________________________________________
  12368.  
  12369.  
  12370. Function
  12371.                    Returns the number of expanded memory pages allocated
  12372.                    to a specific EMM handle.
  12373. Declaration
  12374.                    GetPagesOwnedByHandle (Handle: Word; Var
  12375.  
  12376.  Programmer's Reference Guide       - 203 -         TEGL Windows Toolkit
  12377.  
  12378.  
  12379.  
  12380.  
  12381.  
  12382.                  Chapter 13 - Virtual Memory Manager
  12383.  
  12384.                    PagesOwned:word):
  12385. Result type
  12386.                    Returns a return code of 0 if EMM software is
  12387.                    successful.
  12388. Remarks
  12389.                    An EMM handle never has zero pages of memory allocated
  12390.                    to it.
  12391.  
  12392.  
  12393. Expanded Memory Test Program
  12394.  
  12395.  
  12396.  
  12397.  
  12398. program EmsTest;
  12399.  
  12400. uses VirtMem;
  12401.  
  12402. Var
  12403.   EmmHandle,
  12404.   PageFrameBaseAddress,
  12405.   PagesNeeded,
  12406.   PhysicalPage,
  12407.   LogicalPage,
  12408.   Offset,
  12409.   ErrorCode,
  12410.   PagesEMSAvailable,
  12411.   TotalHandleCount,
  12412.   PagesOwned,
  12413.   TotalEMSPages,
  12414.   AvailableEMSPages: Word;
  12415.  
  12416.   VersionNumber,
  12417.   PagesNumberString: string;
  12418.  
  12419.   Verify: Boolean;
  12420.  
  12421.   DataPtr : pointer;
  12422.  
  12423.  
  12424. FUNCTION HexString(I : word) : string;
  12425.    FUNCTION HexByte(B : byte) : string;
  12426.       const HexDigit : ARRAY[0..15] OF Char = '0123456789ABCDEF';
  12427.       BEGIN
  12428.        HexByte := HexDigit[B SHR 4]+HexDigit[B AND $F];
  12429.       END;
  12430.    BEGIN
  12431.      HexString := HexByte(Hi(I))+HexByte(Lo(I));
  12432.    END;
  12433.  
  12434. Procedure Error(ErrorMessage: string; ErrorNumber: Word);
  12435.    Begin
  12436.  
  12437.  Programmer's Reference Guide       - 204 -         TEGL Windows Toolkit
  12438.  
  12439.  
  12440.  
  12441.  
  12442.  
  12443.                  Chapter 13 - Virtual Memory Manager
  12444.  
  12445.       Writeln(ErrorMessage);
  12446.       Writeln('  ErrorNumber = ',HexString(ErrorNumber) );
  12447.       Writeln('EMS test program aborting.');
  12448.       Halt(1);
  12449.    end;
  12450.  
  12451. Begin
  12452.   { Determine if the Expanded Memory Manager is installed }
  12453.   If not (EmmInstalled) then
  12454.     Error('The LIM Expanded Memory Manager is not installed.',255);
  12455.  
  12456.   { Get Version number}
  12457.   ErrorCode:= GetVersionNumber(VersionNumber);
  12458.   If ErrorCode<>0 then
  12459.     Error('Error trying to get the EMS version number ',Errorcode);
  12460.   Writeln('LIM Expanded Memory Manager, version ',VersionNumber);
  12461.   Writeln;
  12462.  
  12463.   { Get the expanded memory page frame address }
  12464.   ErrorCode:= GetPageFrameBaseAddress(PageFrameBaseAddress);
  12465.   If ErrorCode<>0 then
  12466.     Error('Error trying to get the base Page Frame Address.',ErrorCode);
  12467.   Writeln('The base address of the EMS page frame is - '+
  12468.          HexString(PageFrameBaseAddress) );
  12469.   Writeln;
  12470.  
  12471.   { Get Available pages. }
  12472.   ErrorCode:= EMSPagesAvailable(TotalEMSPages,AvailableEMSPages);
  12473.   If ErrorCode<>0 then
  12474.     Error('Error in determining available EMS pages.',Errorcode);
  12475.   Writeln('There are ',TotalEMSPages,' pages present in this system.');
  12476.   Writeln('  ',AvailableEMSPages,' of those pages are available.');
  12477.   Writeln;
  12478.  
  12479.   { Get Handle Count }
  12480.   ErrorCode:= GetHandleCountUsed(TotalHandleCount);
  12481.   If ErrorCode<>0 then
  12482.     Error('Error in getting the Handle Count Used.',ErrorCode);
  12483.  
  12484.   { Determine if there are enough pages for this application.}
  12485.   PagesNeeded:=1;
  12486.   If PagesNeeded>AvailableEMSPages then
  12487.      Begin
  12488.        Str(PagesNeeded,PagesNumberString);
  12489.        Error('We need '+PagesNumberString+' EMS pages. ' +
  12490.             'There are not that many available.',ErrorCode);
  12491.      end;
  12492.  
  12493.   { Allocate expanded memory pages for our usage }
  12494.   ErrorCode:= AllocateExpandedMemoryPages(PagesNeeded,EmmHandle);
  12495.   Str(PagesNeeded,PagesNumberString);
  12496.   If ErrorCode<>0 then
  12497.  
  12498.  Programmer's Reference Guide       - 205 -         TEGL Windows Toolkit
  12499.  
  12500.  
  12501.  
  12502.  
  12503.  
  12504.                  Chapter 13 - Virtual Memory Manager
  12505.  
  12506.     Error('Error in allocating '+PagesNumberString+
  12507.          ' pages for usage.',ErrorCode);
  12508.   Writeln(PagesNeeded,' EMS page(s) allocated for the EMS test program.');
  12509.   Writeln;
  12510.  
  12511.   { Map in the required logical pages to the physical pages }
  12512.   LogicalPage :=0;
  12513.   PhysicalPage:=0;
  12514.   ErrorCode:=MapExpandedMemoryPages(EmmHandle,LogicalPage,PhysicalPage);
  12515.   If ErrorCode<>0 then
  12516.     Error('Error in mapping logical pages onto physical pages.',ErrorCode);
  12517.   Writeln('Logical Page ',LogicalPage,
  12518.          ' successfully mapped onto Physical Page ',PhysicalPage);
  12519.   Writeln;
  12520.  
  12521.   { Get the number of pages for our handle }
  12522.   ErrorCode:= GetPagesOwnedByHandle(EmmHandle,PagesOwned);
  12523.   If ErrorCode<>0 then
  12524.     Error('Error in getting number of pages Owned by handle.',ErrorCode);
  12525.   Writeln('The Total Handle Count is ',TotalHandleCount,
  12526.          ' and the number of Pages owned is ',PagesOwned,'.');
  12527.   Writeln;
  12528.  
  12529.  
  12530.   { Write a test pattern to expanded memory }
  12531.   For Offset:=0 to 16382 do
  12532.     Mem[PageFrameBaseAddress:Offset]:=Offset mod 256;
  12533.  
  12534.   { Make sure that what is in EMS memory is what we just wrote }
  12535.   Writeln('Testing EMS memory.');
  12536.  
  12537.   Offset:=1;
  12538.   Verify:=True;
  12539.   while (Offset<=16382) and (Verify=True) do
  12540.      Begin
  12541.        If Mem[PageFrameBaseAddress:Offset]<>Offset mod 256 then
  12542.           Verify:=False;
  12543.        Offset:=Succ(Offset);
  12544.      end;
  12545.  
  12546.   { If it isn't report the error }
  12547.   If not Verify then
  12548.     Error('What was written to EMS memory was not found during '+
  12549.          'memory verification  test.',0);
  12550.   Writeln('EMS memory test successful.');
  12551.   Writeln;
  12552.  
  12553.  
  12554.   { Return the expanded memory pages back to the EMS memory pool }
  12555.   ErrorCode:=DeallocateExpandedMemoryPages(EmmHandle);
  12556.   If ErrorCode<>0 then
  12557.     Error('EMS test program was unable to deallocate '+
  12558.  
  12559.  Programmer's Reference Guide       - 206 -         TEGL Windows Toolkit
  12560.  
  12561.  
  12562.  
  12563.  
  12564.  
  12565.                  Chapter 13 - Virtual Memory Manager
  12566.  
  12567.          'the EMS pages in use.',ErrorCode);
  12568.   Writeln(PagesNeeded,' page(s) deallocated.');
  12569.  
  12570.   Writeln;
  12571.   Writeln('EMS test program completed.');
  12572. end.
  12573.  
  12574.  
  12575.  
  12576.  
  12577. A RAM Disk Driver
  12578.  
  12579. Expanded Memory (EMS), in its architecture of multiple pages, is limited
  12580. in its use as a direct access heap without complex programming. However,
  12581. one of the simplest ways to take advantage of EMS, is to create a EMS ram
  12582. disk.
  12583.  
  12584. The following EMS RAM Disk functions provides the basics for storing and
  12585. retrieving a file from EMS memory.
  12586.  
  12587.  
  12588. ___________________________________________________________________________
  12589.  
  12590. EMSOpen function                                                    VIRTMEM
  12591. ___________________________________________________________________________
  12592.  
  12593.  
  12594. Function
  12595.                    Opens an EMS Ram Disk file.
  12596. Declaration
  12597.                    EMSOpen(MinimumPages:word)
  12598. Result type
  12599.                    EMSOpen returns a variable of type EMSFile.
  12600. Remarks
  12601.                    EMSFile is predeclared as follows:
  12602.  
  12603.  
  12604. type
  12605.   EMSBlockPtr = ^EMSBlock;
  12606.   EMSBlock    = Record
  12607.            nextblockptr  : EMSblockPtr;
  12608.            Handle        : word;        {Multiple handles}
  12609.            EMSPage       : word;        {Pages allocated}
  12610.         end;
  12611.  
  12612.   EMSFile     = ^EMSFileRec;
  12613.   EMSFileRec  = Record
  12614.            PageOffset    : word;     {current offset within page}
  12615.            BaseAddress   : word;
  12616.            EMSPosition   : longint;
  12617.            TotalPages    : word;     {Total number of 16k pages}
  12618.            RootBlkPtr    : EMSBlockPtr;
  12619.  
  12620.  Programmer's Reference Guide       - 207 -         TEGL Windows Toolkit
  12621.  
  12622.  
  12623.  
  12624.  
  12625.  
  12626.                  Chapter 13 - Virtual Memory Manager
  12627.  
  12628.         end;
  12629.  
  12630.  
  12631.  
  12632.                    The BaseAddress and PageOffset forms the
  12633.                    pointer to the physical expanded memory page. The 
  12634.                    EMSPosition field is the current RAM disk file
  12635.                    position. TotalPages is the total number of
  12636.                    expanded memory pages allocated for this EMS Ram file.
  12637.                    The RootBlkPtr points to the first EMS Block
  12638.                    pointer.
  12639.  
  12640.                    The MinimumPages parameter specifies the initial
  12641.                    allocation, however if more pages are required, as you
  12642.                    write to the EMS Ram file, pages are automatically
  12643.                    allocated as needed. Additional EMS handles and Pages
  12644.                    information are stored in separate EMS Block records
  12645.                    and are chained together.
  12646.  
  12647.                    EMS_Status will return a 0 if the EMS ram file is
  12648.                    allocated successfully; otherwise, it will return a
  12649.                    nonzero error code.
  12650. See also
  12651.                    EMSClose
  12652.  
  12653.  
  12654.  
  12655. ___________________________________________________________________________
  12656.  
  12657. EMSSeek procedure                                                   VIRTMEM
  12658. ___________________________________________________________________________
  12659.  
  12660.  
  12661. Function
  12662.                    Moves the current position of an EMS RAM file to a
  12663.                    specified byte component.
  12664. Declaration
  12665.                    EMSSeek(var EMSRamFile:EMSFile; Position:
  12666.                    longint)
  12667. Remarks
  12668.                    EMSRamFile is the record type returned by EMSOpen, and
  12669.                    Position is an expression of type longint. The current
  12670.                    EMS Ram file position is moved to the offset 
  12671.                    Position. In order to expand the expanded memory pages
  12672.                    allocated, it is possible to EMSSeek any size
  12673.                    beyond the last byte; thus EMSSeek(myramfile,
  12674.                    98304) will automatically allocate, if required, a
  12675.                    total of 6 pages.
  12676.  
  12677.                    EMS_Status will return a 0 if the operation was
  12678.                    successful; otherwise, it will return a nonzero error
  12679.                    code.
  12680.  
  12681.  Programmer's Reference Guide       - 208 -         TEGL Windows Toolkit
  12682.  
  12683.  
  12684.  
  12685.  
  12686.  
  12687.                  Chapter 13 - Virtual Memory Manager
  12688.  
  12689. Restrictions
  12690.                    EMS Ram file must be open.
  12691. See also
  12692.                    EMSBlockWrite, EMSBlockRead, EMSOpen, EMSClose
  12693.  
  12694.  
  12695.  
  12696. ___________________________________________________________________________
  12697.  
  12698. EMSBlockWrite procedure                                             VIRTMEM
  12699. ___________________________________________________________________________
  12700.  
  12701.  
  12702. Function
  12703.                    Writes the information pointed to by the Buffer pointer
  12704.                    to the EMS Ram file.
  12705. Declaration
  12706.                    EMSBlockWrite(var EMSRamFile:EMSFile; buffer:
  12707.                    pointer; bytestowrite:longint)
  12708. Remarks
  12709.                    EMSRamFile is the record type returned by sh
  12710.                    EMSOpen, Buffer is any pointer type, and 
  12711.                    Bytestowrite is an expression of type longint.
  12712.  
  12713.                    EMSBlockWrite writes bytestowrite bytes to
  12714.                    the EMSRamFile. Bytestowrite may be greater
  12715.                    than (64k). EMSBlockWrite will automatically
  12716.                    allocate additional EMS Memory pages if the current EMS
  12717.                    Ram file position plus Bytestowrite exceeds the
  12718.                    currently allocated expanded memory pages.
  12719.  
  12720.                    The current EMS Ram file position is advanced by 
  12721.                    Bytestowrite on completion of EMSBlockWrite.
  12722.  
  12723.                    EMS_Status will return a 0 if the operation was
  12724.                    successful; otherwise, it will return a nonzero error
  12725.                    code.
  12726. Restrictions
  12727.                    EMS Ram file must be open.
  12728. See also
  12729.                    EMSSeek, EMSBlockRead, EMSOpen, EMSClose
  12730.  
  12731.  
  12732.  
  12733. ___________________________________________________________________________
  12734.  
  12735. EMSBlockRead procedure                                              VIRTMEM
  12736. ___________________________________________________________________________
  12737.  
  12738.  
  12739. Function
  12740.                    Reads from the EMS Ram file to memory pointed to by the
  12741.  
  12742.  Programmer's Reference Guide       - 209 -         TEGL Windows Toolkit
  12743.  
  12744.  
  12745.  
  12746.  
  12747.  
  12748.                  Chapter 13 - Virtual Memory Manager
  12749.  
  12750.                    buffer pointer.
  12751. Declaration
  12752.                    EMSBlockRead(var EMSRamFile:EMSFile; buffer:
  12753.                    pointer; bytestoread:longint)
  12754. Remarks
  12755.                    EMSRamFile is the record type returned by sh
  12756.                    EMSOpen, Buffer is any pointer type, and 
  12757.                    Bytestoread is an expression of type longint.
  12758.  
  12759.                    EMSBlockRead reads bytestoread bytes to the
  12760.                    memory area pointed to by Buffer. Bytestoread
  12761.                    may be greater than (64k). EMSBlockRead will read
  12762.                    past the end of Ram file and automatically allocate
  12763.                    additional EMS Memory pages if the current EMS Ram file
  12764.                    position plus Bytestoread exceeds the currently
  12765.                    allocated expanded memory pages.
  12766.  
  12767.                    The current EMS Ram file position is advanced by 
  12768.                    Bytestoread on completion of EMSBlockRead.
  12769.  
  12770.                    EMS_Status will return a 0 if the operation was
  12771.                    successful; otherwise, it will return a nonzero error
  12772.                    code.
  12773. Restrictions
  12774.                    EMS Ram file must be open.
  12775. See also
  12776.                    EMSBlockWrite, EMSSeek, EMSOpen, EMSClose
  12777.  
  12778.  
  12779.  
  12780. ___________________________________________________________________________
  12781.  
  12782. EMSClose procedure                                                  VIRTMEM
  12783. ___________________________________________________________________________
  12784.  
  12785.  
  12786. Function
  12787.                    Close an Open EMS Ram file.
  12788. Declaration
  12789.                    EMSClose(var EMSRamFile:EMSFile)
  12790. Remarks
  12791.                    EMSRamFile is the record type returned by sh
  12792.                    EMSOpen.
  12793.  
  12794.                    EMS_Status will return a 0 if the operation was
  12795.                    successful; otherwise, it will return a nonzero error
  12796.                    code.
  12797. See also
  12798.                    EMSOpen
  12799.  
  12800.  
  12801.  
  12802.  
  12803.  Programmer's Reference Guide       - 210 -         TEGL Windows Toolkit
  12804.  
  12805.  
  12806.  
  12807.  
  12808.  
  12809.                  Chapter 13 - Virtual Memory Manager
  12810.  
  12811. Virtual Disk Heap
  12812.  
  12813. A virtual Disk Heap allows you to simulate a heap using a sequential file.
  12814. Allocating and freeing space within the Virtual Disk Heap are
  12815. automatically maintained, with all the flexibility of a real memory heap
  12816. manager and the unlimited space of a hard disk. The virtual Disk Heap
  12817. manager has the ability to reuse free space, as well as merging adjacent
  12818. free space fragments.
  12819.  
  12820. In addition the virtual disk heap (disk mode) can be used as a simple
  12821. graphical image database manager. The stored images may be retrieved later
  12822. by referring to a unique signature that you provide.
  12823.  
  12824.  
  12825. ___________________________________________________________________________
  12826.  
  12827. VDskOpenHeapFile function                                           VIRTMEM
  12828. ___________________________________________________________________________
  12829.  
  12830.  
  12831. Function
  12832.                    Opens a heap file on disk.
  12833. Declaration
  12834.                    VDskOpenHeapFile(VDskFileName : string;
  12835.                    VDskAttribute:word)
  12836. Result type
  12837.                    VDskOpenHeapFile returns a variable of type 
  12838.                    VDskFile.
  12839. Remarks
  12840.                    VDskFileName is a string type expression that
  12841.                    contains the name of heap file and VDskAttribute
  12842.                    is the attribute that is associated with the file. The
  12843.                    following VDskAttribute constants are declared:
  12844.  
  12845.  
  12846. CONST
  12847.   VDskReadWrite = 1;
  12848.   VDskTemporary = 2;
  12849.  
  12850.  
  12851.                    VDskOpenHeapFile will create a new file if the
  12852.                    file does not exist. If VDskReadWrite is specified,
  12853.                     the file is not erased when the file is closed. if
  12854.                    VDskAttribute is set to VDskTemporary, the file is
  12855.                    automatically erased when the file is closed.
  12856.  
  12857.                    VDSKFile is declared as follows:
  12858.  
  12859.  
  12860. type
  12861.   VDskFreePtr         = ^VDskFreeRecord;
  12862.   VDskFreeRecord      = Record
  12863.  
  12864.  Programmer's Reference Guide       - 211 -         TEGL Windows Toolkit
  12865.  
  12866.  
  12867.  
  12868.  
  12869.  
  12870.                  Chapter 13 - Virtual Memory Manager
  12871.  
  12872.                    NextVDskFree : VDskFreePtr;
  12873.                    StartBlock   : longint;
  12874.                    EndBlock     : longint;
  12875.                    Signature    : Signate;
  12876.                    BlockFree    : boolean;
  12877.                 end;
  12878.  
  12879.   VDskFile            = ^VDskFileRecord;
  12880.   VDskFileRecord      = Record
  12881.                    VDskFreePtrChain : VDskFreePtr;
  12882.                    VDskTopOfFile    : longint;
  12883.                    VDskAttribute    : word;
  12884.                    Case EMSType : boolean of
  12885.                       false : (VDskHeapFile: File);
  12886.                       true  : (VEMSHeapFile: EMSFile);
  12887.                 end;
  12888.  
  12889.  
  12890.  
  12891.                    VDskFreePtrChain maintains a complete list of all
  12892.                    blocks that are allocated and freed.  Information
  12893.                    regarding each block are stored in a chain of 
  12894.                    VDskFreeRecord.  The VDskTopOfFile is the
  12895.                    position of the end of the heap file.  If there are no
  12896.                    free space fragments before the end of the heap file to
  12897.                    satisfy the requested block size, space is allocated
  12898.                    starting at VDskTopOfFile.  VDskAttribute is
  12899.                    the passed parameter when the file was opened.  The 
  12900.                    EMSType sets the variant portion to either disk or EMS
  12901.                    memory.
  12902.  
  12903.                    StartBlock and EndBlock is the starting and
  12904.                    ending address of the allocated or freed block,
  12905.                    respectively.  Signature is a unique type of a 4
  12906.                    character string that can be used as a search string to
  12907.                    locate an address of a block.  Blockfree indicates
  12908.                    whether the block is allocated or free.
  12909.  
  12910.                    VDSKStatus will return a 0 if the operation was
  12911.                    successful; otherwise, it will return a nonzero error
  12912.                    code.
  12913. See also
  12914.                    VEMSOpenHeapFile, VDskCloseHeapFile
  12915.  
  12916.  
  12917.  
  12918.  
  12919. ___________________________________________________________________________
  12920.  
  12921. VEMSOpenHeapFile function                                           VIRTMEM
  12922. ___________________________________________________________________________
  12923.  
  12924.  
  12925.  Programmer's Reference Guide       - 212 -         TEGL Windows Toolkit
  12926.  
  12927.  
  12928.  
  12929.  
  12930.  
  12931.                  Chapter 13 - Virtual Memory Manager
  12932.  
  12933.  
  12934. Function
  12935.                    Opens a heap file in EMS.
  12936. Declaration
  12937.                    VEMSOpenHeapFile
  12938. Result type
  12939.                    VEMSOpenHeapFile returns a variable of type 
  12940.                    VDskFile.
  12941. Remarks
  12942.                    VEMSOpenHeapFile creates the same structure as 
  12943.                    VDskOpenHeapFile, with the EMSType set to EMS
  12944.                    memory.
  12945.  
  12946.                    VDSKStatus will return a 0 if the EMS operation was
  12947.                    successful; otherwise, it will return a nonzero error
  12948.                    code.
  12949. See also
  12950.                    VDSKOpenHeapFile, VDskCloseHeapFile
  12951.  
  12952.  
  12953.  
  12954.  
  12955. ___________________________________________________________________________
  12956.  
  12957. VDSKGetMem function                                                 VIRTMEM
  12958. ___________________________________________________________________________
  12959.  
  12960.  
  12961. Function
  12962.                    Allocates a block within the virtual heap memory and
  12963.                    returns a virtual heap address.
  12964. Declaration
  12965.                    VDskGetMem(var VDskPacket:VDskFile; HeapSize:
  12966.                    longint; signature:Signate)
  12967. Result type
  12968.                    VDSKGetMem returns a virtual heap address of
  12969.                    longint.
  12970. Remarks
  12971.                    VDSKStatus will return a 0 if the virtual heap
  12972.                    allocation was successfull; otherwise, it will return a
  12973.                    nonzero error code.
  12974. Restrictions
  12975.                    The Virtual Heap memory must be opened.
  12976. See also
  12977.                    VDSKFreeMem, VDskWriteHeapData,
  12978.                    VDskReadHeapData
  12979.  
  12980.  
  12981.  
  12982.  
  12983. ___________________________________________________________________________
  12984.  
  12985.  
  12986.  Programmer's Reference Guide       - 213 -         TEGL Windows Toolkit
  12987.  
  12988.  
  12989.  
  12990.  
  12991.  
  12992.                  Chapter 13 - Virtual Memory Manager
  12993.  
  12994. VDSKFreeMem procedure                                               VIRTMEM
  12995. ___________________________________________________________________________
  12996.  
  12997.  
  12998. Function
  12999.                    Frees the virtual heap memory pointed to by the 
  13000.                    VDskHeapPtr.
  13001. Declaration
  13002.                    VDskFreeMem(var VDskPacket:VDskFile; VDskHeapPtr:
  13003.                    longint)
  13004. Remarks
  13005.                    VDskPacket is the record type returned by 
  13006.                    VEMSOpenHeapFile or VDskOpenHeapFile. The 
  13007.                    VDskHeapPtr must be the virtual disk pointer from 
  13008.                    VDskGetMem.
  13009.  
  13010.                    VDSKStatus will return a 0 if the virtual heap
  13011.                    de-allocation was successful; otherwise, it will return
  13012.                    a nonzero error code.
  13013. Restrictions
  13014.                    The Virtual Heap memory must be opened.
  13015. See also
  13016.                    VDSKGetMem, VDskWriteHeapData, VDskReadHeapData
  13017.  
  13018.  
  13019.  
  13020.  
  13021. ___________________________________________________________________________
  13022.  
  13023. VDSKWriteHeapData procedure                                         VIRTMEM
  13024. ___________________________________________________________________________
  13025.  
  13026.  
  13027. Function
  13028.                    Writes the data from memory pointed to by the 
  13029.                    DataPtr to an allocated virtual heap memory 
  13030.                    VDskHeapPtr.
  13031. Declaration
  13032.                    VDskWriteHeapData(var VDskPacket:VDskFile;
  13033.                    DataPtr:pointer; VDskHeapPtr:longint)
  13034. Remarks
  13035.                    VDskPacket is the record type returned by 
  13036.                    VEMSOpenHeapFile or VDskOpenHeapFile. The 
  13037.                    DataPtr is of a pointer type that points to a memory
  13038.                    buffer that will be written out to the virtual heap.
  13039.                    The VDskHeapPtr must be the virtual heap pointer
  13040.                    created from VDskGetMem.
  13041.  
  13042.                    VDSKStatus will return a 0 if writing to the virtual
  13043.                    heap was successful; otherwise, it will return a
  13044.                    nonzero error code.
  13045. Restrictions
  13046.  
  13047.  Programmer's Reference Guide       - 214 -         TEGL Windows Toolkit
  13048.  
  13049.  
  13050.  
  13051.  
  13052.  
  13053.                  Chapter 13 - Virtual Memory Manager
  13054.  
  13055.                    The Virtual Heap memory must be opened.
  13056. See also
  13057.                    VDSKGetMem, VDskFreeMem, VDskReadHeapData
  13058.  
  13059.  
  13060.  
  13061. ___________________________________________________________________________
  13062.  
  13063. VDSKReadHeapData procedure                                          VIRTMEM
  13064. ___________________________________________________________________________
  13065.  
  13066.  
  13067. Function
  13068.                    Reads the data from the virtual heap memory to a memory
  13069.                    area pointed to by the DataPtr.
  13070. Declaration
  13071.                    VDskReadHeapData(var VDskPacket:VDskFile;
  13072.                    DataPtr:pointer; VDskHeapPtr:longint)
  13073. Remarks
  13074.                    VDskPacket is the record type returned by 
  13075.                    VEMSOpenHeapFile or VDskOpenHeapFile. The 
  13076.                    DataPtr is of a pointer type that points to a memory
  13077.                    buffer that will be overwritten by the transfer of data
  13078.                    from the virtual heap. The VDskHeapPtr must be the
  13079.                    virtual heap pointer created from VDskGetMem.
  13080.  
  13081.                    VDSKStatus will return a 0 if writing to the virtual
  13082.                    heap was successful; otherwise, it will return a
  13083.                    nonzero error code.
  13084. Restrictions
  13085.                    The Virtual Heap memory must be opened.
  13086. See also
  13087.                    VDSKGetMem, VDskFreeMem, VDskWriteHeapData
  13088.  
  13089.  
  13090.  
  13091.  
  13092. ___________________________________________________________________________
  13093.  
  13094. VDskCloseHeapFile procedure                                         VIRTMEM
  13095. ___________________________________________________________________________
  13096.  
  13097.  
  13098. Function
  13099.                    Closes a virtual heap.
  13100. Declaration
  13101.                    VDskCloseHeapFile(var VDskPacket:VDskFile)
  13102. Remarks
  13103.                    VDskPacket is the record type returned by 
  13104.                    VEMSOpenHeapFile or VDskOpenHeapFile.
  13105.  
  13106.                    VDSKStatus will return a 0 if the virtual heap
  13107.  
  13108.  Programmer's Reference Guide       - 215 -         TEGL Windows Toolkit
  13109.  
  13110.  
  13111.  
  13112.  
  13113.  
  13114.                  Chapter 13 - Virtual Memory Manager
  13115.  
  13116.                    operation was successful; otherwise, it will return a
  13117.                    nonzero error code.
  13118. See also
  13119.                    VEMSOpenHeapFile, VDskOpenHeapFile
  13120.  
  13121.  
  13122. The Virtual Heap Error Function
  13123.  
  13124. The VDskError variable allows you to install a virtual heap error
  13125. function, which gets called whenever the TEGL heap manager cannot complete
  13126. an allocation request. VDskError is a pointer that points to a
  13127. function with the following header:
  13128.  
  13129.  
  13130.  
  13131.     {$F+} {sh function} ReturnHeapError(code: longint) : word;  {$F-}
  13132.  
  13133.  
  13134.  
  13135. The virtual heap error function is installed by assigning its address to
  13136. the VDskError variable:
  13137.  
  13138.  
  13139.  
  13140.     VDskError := ReturnHeapError;
  13141.  
  13142.  
  13143.  
  13144. The virtual heap error function gets called whenever any virtual function
  13145. calls is unable to complete the request. The code parameter contains
  13146. a code indicating which virtual heap function is in error. Check 
  13147. VDSKStatus to determine the severity of the error.
  13148.  
  13149. The standard virtual heap error function is set to return to the calling
  13150. procedure.
  13151.  
  13152. If you are using the Virtual memory manager (next section), use the
  13153. virtual memory error function rather then this error function to intercept
  13154. virtual errors. The virtual memory manager relies on the standard q
  13155. return to the calling procedure to check VDSKStatus to indicate
  13156. whether to write to EMS or disk file.
  13157.  
  13158. The Virtual Memory Manager
  13159.  
  13160. The virtual memory manager is in constant use by TEGL windows to provide
  13161. memory extensions for graphical images. Your program may use the virtual
  13162. memory functions as an external heap, with the restriction that you do
  13163. close the virtual memory file.
  13164.  
  13165. The following virtual memory functions will automatically select the
  13166. storage medium when moving data to virtual memory. The data is moved to
  13167. expanded memory if adequate space can be found, otherwise the data is
  13168.  
  13169.  Programmer's Reference Guide       - 216 -         TEGL Windows Toolkit
  13170.  
  13171.  
  13172.  
  13173.  
  13174.  
  13175.                  Chapter 13 - Virtual Memory Manager
  13176.  
  13177. moved to one of the mass storage mediums. Both storage medium (EMS and
  13178. Hard disk) are used if available.
  13179.  
  13180.  
  13181.  
  13182. ___________________________________________________________________________
  13183.  
  13184. UseHardDisk procedure                                               VIRTMEM
  13185. ___________________________________________________________________________
  13186.  
  13187.  
  13188. Function
  13189.                    This function forces the virtual memory manager to use
  13190.                    the hard disk as virtual memory, even if EMS is
  13191.                    available.
  13192. Declaration
  13193.                    UseHardDisk(yesno:boolean)
  13194. Remarks
  13195.                    if the yesno is true, then the virtual memory
  13196.                    manager will ignore the installed EMS, and only use the
  13197.                    hard disk.
  13198.  
  13199.                    VDSKStatus will return a 0 if the virtual memory
  13200.                    operation was successful; otherwise, it will return a
  13201.                    nonzero error code.
  13202.  
  13203.  
  13204.  
  13205. ___________________________________________________________________________
  13206.  
  13207. MoveFromVirtual procedure                                           VIRTMEM
  13208. ___________________________________________________________________________
  13209.  
  13210.  
  13211. Function
  13212.                    Moves a block of data from virtual back to normal
  13213.                    memory.
  13214. Declaration
  13215.                    MoveFromVirtual(DataPtr:pointer; VirtualHeapPtr:
  13216.                    longint)
  13217. Remarks
  13218.                    The DataPtr is any memory block allocated by 
  13219.                    GetMem or TEGLGetMem. VirtualHeapPtr is of
  13220.                    the type longint, which is the address supplied by 
  13221.                    MovetoVirtual.
  13222.  
  13223.                    VDSKStatus will return a 0 if the virtual memory
  13224.                    operation was successful; otherwise, it will return a
  13225.                    nonzero error code.
  13226. See also
  13227.                    MoveToVirtual, FreeVirtual
  13228.  
  13229.  
  13230.  Programmer's Reference Guide       - 217 -         TEGL Windows Toolkit
  13231.  
  13232.  
  13233.  
  13234.  
  13235.  
  13236.                  Chapter 13 - Virtual Memory Manager
  13237.  
  13238.  
  13239.  
  13240. ___________________________________________________________________________
  13241.  
  13242. MoveToVirtual function                                              VIRTMEM
  13243. ___________________________________________________________________________
  13244.  
  13245.  
  13246. Function
  13247.                    Moves a block of data from memory to virtual memory.
  13248. Declaration
  13249.                    MoveToVirtual(DataPtr:pointer; HeapSize:
  13250.                    longint)
  13251. Result type
  13252.                    MoveToVirtual returns a longint type, which is a
  13253.                    physical address of the virtual block.
  13254. Remarks
  13255.                    The DataPtr is any memory block allocated by 
  13256.                    GetMem or TEGLGetMem. HeapSize is of the
  13257.                    type longint, which is the size of the memory block
  13258.                    that you are moving to virtual memory.
  13259.  
  13260.                    MoveToVirtual will automatically allocate EMS
  13261.                    memory pages and open any virtual memory files (if
  13262.                    needed) if this is the first time call to this
  13263.                    procedure.
  13264.  
  13265.                    VDSKStatus will return a 0 if the virtual memory
  13266.                    operation was successful; otherwise, it will return a
  13267.                    nonzero error code.
  13268. See also
  13269.                    MoveFromVirtual, FreeVirtual
  13270.  
  13271.  
  13272.  
  13273. ___________________________________________________________________________
  13274.  
  13275. FreeVirtual procedure                                               VIRTMEM
  13276. ___________________________________________________________________________
  13277.  
  13278.  
  13279. Function
  13280.                    Frees the virtual memory back to the virtual memory
  13281.                    pool for reuse.
  13282. Declaration
  13283.                    FreeVirtual(VirtualHeapPtr:longint)
  13284. Remarks
  13285.                    VirtualHeapPtr is of the type longint, which is
  13286.                    the address supplied by MovetoVirtual.
  13287.  
  13288.                    VDSKStatus will return a 0 if the virtual memory
  13289.                    operation was successful; otherwise, it will return a
  13290.  
  13291.  Programmer's Reference Guide       - 218 -         TEGL Windows Toolkit
  13292.  
  13293.  
  13294.  
  13295.  
  13296.  
  13297.                  Chapter 13 - Virtual Memory Manager
  13298.  
  13299.                    nonzero error code.
  13300. See also
  13301.                    MoveToVirtual, MoveFromVirtual
  13302.  
  13303.  
  13304.  
  13305. ___________________________________________________________________________
  13306.  
  13307. CloseVirtual procedure                                              VIRTMEM
  13308. ___________________________________________________________________________
  13309.  
  13310.  
  13311. Function
  13312.                    Closes the virtual memory manager.
  13313. Declaration
  13314.                    CloseVirtual
  13315. Remarks
  13316.                    CloseVirtual shuts the operation of the virtual
  13317.                    memory manager. The shut down procedure includes
  13318.                    releasing allocated expanded memory pages and closing
  13319.                    external virtual files.
  13320.  
  13321.                    VDSKStatus will return a 0 if the virtual memory
  13322.                    operation was successful; otherwise, it will return a
  13323.                    nonzero error code.
  13324. Restrictions
  13325.                    The procedure should not be called if the TEGLUnit is
  13326.                    used.
  13327.  
  13328.  
  13329.  
  13330. ___________________________________________________________________________
  13331.  
  13332. TEGLMaxAvail Function                                               VIRTMEM
  13333. ___________________________________________________________________________
  13334.  
  13335.  
  13336. Function
  13337.                    Returns the size of the largest block available in the
  13338.                    upper heap.
  13339. Declaration
  13340.                    TEGLMaxAvail : LongInt; 
  13341.  
  13342.  
  13343.  
  13344. ___________________________________________________________________________
  13345.  
  13346. VirtualMemUsed Function                                             VIRTMEM
  13347. ___________________________________________________________________________
  13348.  
  13349.  
  13350. Function
  13351.  
  13352.  Programmer's Reference Guide       - 219 -         TEGL Windows Toolkit
  13353.  
  13354.  
  13355.  
  13356.  
  13357.  
  13358.                  Chapter 13 - Virtual Memory Manager
  13359.  
  13360.                    Returns the amount of virtual memory allocated.
  13361. Declaration
  13362.                    VirtualMemUsed : LongInt; 
  13363. Remarks
  13364.                    This is the total of virual memory allocated. On some
  13365.                    systems this can be a combination of both EMS and
  13366.                    Disk memory.
  13367.  
  13368.  
  13369. The Virtual Memory Error Function
  13370. The VirtualError variable allows you to install a virtual memory
  13371. error function, which gets called whenever the virtual memory manager
  13372. cannot complete a virtual function request. VirtualError is a pointer
  13373. that points to a function with the following header:
  13374.  
  13375.  
  13376.  
  13377.     {$F+} {sh function} ReturnVirtualError(code: longint) : word;  {$F-}
  13378.  
  13379.  
  13380.  
  13381. The virtual memory error function is installed by assigning its address to
  13382. the VirtualError variable:
  13383.  
  13384.  
  13385.  
  13386.     VDskError := ReturnVirtualError;
  13387.  
  13388.  
  13389.  
  13390. The virtual memory error function gets called whenever any virtual
  13391. function calls is unable to complete the request. The code parameter
  13392. contains a code indicating which virtual heap function is in error. Check
  13393. VDSKStatus to determine the severity of the error.
  13394.  
  13395. The standard virtual memory error function is set to return to the calling
  13396. procedure.
  13397.  
  13398.  
  13399. Resolving Fragments
  13400. The memory used by the heap is a dynamic and volatile part of your program.
  13401. Memory is constantly allocated and de-allocated by the window manager along
  13402. with allocation of dynamic variables, free space records, frame records,
  13403. mouse click records, etc.
  13404.  
  13405. Although the virtual memory manager will provide almost unlimited windows,
  13406. the concept is still limited by the number of window records that will fit
  13407. in memory and whether the memory is contiguous or fragmented by allocated
  13408. memory not under the control of the virtual memory manager.
  13409.  
  13410. Fragmentation occurs, when free memory blocks are separated by allocated
  13411. blocks. Since certain allocated memory blocks cannot be moved or
  13412.  
  13413.  Programmer's Reference Guide       - 220 -         TEGL Windows Toolkit
  13414.  
  13415.  
  13416.  
  13417.  
  13418.  
  13419.                  Chapter 13 - Virtual Memory Manager
  13420.  
  13421. de-allocated, fragmentation can cut down the largest block size available
  13422. from the heap.
  13423.  
  13424. Without a proper control on memory fragmentation, an out of space error
  13425. can still occur even when the virtual memory manager pages out all window
  13426. images.
  13427.  
  13428. In order for the virtual memory Manager to provide large contiguous memory
  13429. on the heap, two memory managers are used to partition the main heap
  13430. memory.  The normal Turbo Pascal heap manager is used to allocate simple
  13431. memory blocks like frame information and virtual pointer information.  The
  13432. second, is the TEGL heap manager, used by the window manager to allocated
  13433. large image buffers.
  13434.  
  13435. The function ReserveHugeMinimum partitions the heap memory into
  13436. two parts by allocating a single byte between the minimum and upper memory.
  13437. Normal allocations using Turbo Pascal Getmem will default to the lower areas by
  13438. the methods that TP's uses to allocate memory. Turbo pascal will begin using
  13439. the upper area when all lower memory area is used, thus it is not a restriction
  13440. on TP's Getmem.
  13441. TEGLGetMem will only allocate memory from the upper areas.
  13442.  
  13443. ReserveHugeMinimum provides an elegant solution, that allows both
  13444. memory managers to coexist.
  13445.  
  13446.  
  13447. ___________________________________________________________________________
  13448.  
  13449. ReserveHugeMinimum procedure                                        VIRTMEM
  13450. ___________________________________________________________________________
  13451.  
  13452.  
  13453. Function
  13454.                    Partition the heap memory into lower and upper areas to
  13455.                    reduce fragmentation.
  13456. Declaration
  13457.                    ReserveHugeMinimum(MinimumSize : longint)
  13458. Remarks
  13459.                    MinimumSize is of the type longint, which is the
  13460.                    size calculated by adding (60 bytes for a window
  13461.                    record) + the average mouse click and key
  13462.                    clicks areas per window (20 bytes per each defined
  13463.                    click) multiplied by the maximum number of window
  13464.                    records opened at the same time + 4000 bytes (overhead
  13465.                    for the virtual memory manager) plus any heap memory
  13466.                    requirements by the application.
  13467.  
  13468.                    You are not expected to calculate the exact 
  13469.                    MinimumSize, but as a general rule of thumb, it seems
  13470.                    that 12k is effective for most applications.
  13471.  
  13472.  
  13473.  
  13474.  Programmer's Reference Guide       - 221 -         TEGL Windows Toolkit
  13475.  
  13476.  
  13477.  
  13478.  
  13479.  
  13480.                  Chapter 13 - Virtual Memory Manager
  13481.  
  13482.  
  13483.  
  13484.  
  13485.  
  13486.  
  13487.  
  13488.  
  13489.  
  13490.  
  13491.  
  13492.  
  13493.  
  13494.  
  13495.  
  13496.  
  13497.  
  13498.  
  13499.  
  13500.  
  13501.  
  13502.  
  13503.  
  13504.  
  13505.  
  13506.  
  13507.  
  13508.  
  13509.  
  13510.  
  13511.  
  13512.  
  13513.  
  13514.  
  13515.  
  13516.  
  13517.  
  13518.  
  13519.  
  13520.  
  13521.  
  13522.  
  13523.  
  13524.  
  13525.  
  13526.  
  13527.  
  13528.  
  13529.  
  13530.  
  13531.  
  13532.  
  13533.  
  13534.  
  13535.  Programmer's Reference Guide       - 222 -         TEGL Windows Toolkit
  13536.  
  13537.  
  13538.  
  13539.  
  13540.  
  13541.                        Chapter 14 - Sizing and Sliders
  13542.  
  13543. Sizing and Sliding
  13544.  
  13545. The chapter has the procedures and functions that give the core for
  13546. resizing frames and attachings sliders to them.
  13547.  
  13548. A slider is a moveable switch. They are quite often used to indicate up
  13549. and down or left to right scrolls (as in a text editor). They can be
  13550. attached to a window but are seperate, that is, they must be disposed of
  13551. seperately.
  13552.  
  13553. Resizing frames adds a degree of complexity to maintaining frames in that
  13554. the contents of the frame are lost when it is resized. Consequently, you
  13555. need to code an event that specifically redraws a frame after resizing.
  13556.  
  13557. Resizable frames with slider bars require more work. It is up to the
  13558. programmer to dispose of and then reattach new sliders to a frame after
  13559. a resize. This presumably is all done within the event that redraws the
  13560. window. This is not impossible, just careful thought is required when
  13561. making these kinds of frames. The results will speak for themselves.
  13562.  
  13563.  
  13564. ___________________________________________________________________________
  13565.  
  13566. DefineResizeClickArea Procedure                                    TEGLSPEC
  13567. ___________________________________________________________________________
  13568.  
  13569.  
  13570. Function
  13571.                    Sets a mouse click area for resizing a frame.
  13572. Declaration
  13573.                    DefineResizeClickArea(ifs : ImageStkPtr;
  13574.                      x,y,x1,y1 : Word; ResizeProc : CallProc);  
  13575. Remarks
  13576.                    The ResizeProc must be defined. You cannot pass a
  13577.                    NIL pointer. When a frame is resized its image is
  13578.                    disposed and must be redrawn.
  13579.  
  13580. See also
  13581.                    DefineResizeMinMax.
  13582. Example
  13583.  
  13584.  
  13585.   DefineResizeClickArea(ifs,1,1,10,6,ReDrawEditor);
  13586.  
  13587.  
  13588.  
  13589.  
  13590.  
  13591.  
  13592. ___________________________________________________________________________
  13593.  
  13594. DefineResizeMinMax Procedure                                       TEGLSPEC
  13595.  
  13596.  Programmer's Reference Guide       - 223 -         TEGL Windows Toolkit
  13597.  
  13598.  
  13599.  
  13600.  
  13601.  
  13602.                        Chapter 14 - Sizing and Sliders
  13603.  
  13604. ___________________________________________________________________________
  13605.  
  13606.  
  13607.  
  13608. Function
  13609.                    Sets the minimum and maximum that a frame can be
  13610.                    resized to.
  13611. Declaration
  13612.                    DefineResizeMinMax(ifs : ImageStkPtr; MinW,
  13613.                      MinH,MaxW,MaxH : Word); 
  13614. Remarks
  13615.                    MinW is the minimum width the frame is allowed if
  13616.                    resized. MinH is the minimum height, MaxW is the
  13617.                    maximum width, and MaxH is maximum height. Values
  13618.                    are in pixels.
  13619. See also
  13620.                    DefineResizeClickArea.
  13621. Example
  13622.  
  13623.  
  13624.   DefineResizeMinMax(ifs,200,100,400,200);
  13625.  
  13626.  
  13627.  
  13628.  
  13629.  
  13630. ___________________________________________________________________________
  13631.  
  13632. DefineSliderArea Procedure                                         TEGLSPEC
  13633. ___________________________________________________________________________
  13634.  
  13635.  
  13636. Function
  13637.                    Defines slider area.
  13638. Declaration
  13639.                    DefineSliderArea(ifs : ImageStkPtr; x,y,x1,y1,
  13640.                      minx,miny,maxx,maxy: Word; SlideAction : CallProc); 
  13641. Remarks
  13642.                    ifs is the frame the slider is attached to. x,y,
  13643.                    x1, y1 is the slider click area. minx, miny, maxx, maxy
  13644.                    are the bounds the slider can be moved in. Coordinates
  13645.                    are frame relative. SlideAction is the event that is
  13646.                    called when the slider is moved.
  13647.  
  13648.                    The MsClickPtr that is passed to SlideAction contains
  13649.                    the new slider position. These coordinates can be used to
  13650.                    determine the correct action to taken.
  13651. Restrictions
  13652.                    This procedure only sets the area for the slider and its
  13653.                    bounds. It is up to the programmer to draw the slider bar
  13654.                    and the slider. The slider bar must be drawn before the
  13655.                    call to DefineSliderArea. Then after draw this the
  13656.  
  13657.  Programmer's Reference Guide       - 224 -         TEGL Windows Toolkit
  13658.  
  13659.  
  13660.  
  13661.  
  13662.  
  13663.                        Chapter 14 - Sizing and Sliders
  13664.  
  13665.                    slider. The toolkit will look after moving the slider
  13666.                    once it has been drawn.
  13667. See also
  13668.                    SetSlidePostion
  13669. Example
  13670.  
  13671.  
  13672.  
  13673.  
  13674.  
  13675.  
  13676.  
  13677. ___________________________________________________________________________
  13678.  
  13679. DropSliders Procedure                                              TEGLSPEC
  13680. ___________________________________________________________________________
  13681.  
  13682.  
  13683. Function
  13684.                    Removes all sliders from a frame.
  13685. Declaration
  13686.                    DropSliders(ifs : ImageStkPtr); 
  13687. Remarks
  13688.                    DropSliders should be called before you drop a
  13689.                    frame or resize it.
  13690. Restrictions
  13691. See also
  13692. Example
  13693.  
  13694.  
  13695.   DropSliders(ifs);
  13696.  
  13697.  
  13698.  
  13699.  
  13700.  
  13701.  
  13702. ___________________________________________________________________________
  13703.  
  13704. FindSliderFS Function                                              TEGLSPEC
  13705. ___________________________________________________________________________
  13706.  
  13707.  
  13708. Function
  13709.                    Finds a slider on a frame.
  13710. Declaration
  13711.                    FindSliderFS(ifs : ImageStackPtr; ms : MsClickPtr):
  13712.                      SliderPtr; 
  13713. Remarks
  13714.                    Returns the SliderPtr associated with ms on the
  13715.                    frame. This can be used from within an event that is
  13716.                    called when a slider is moved. With the SliderPtr
  13717.  
  13718.  Programmer's Reference Guide       - 225 -         TEGL Windows Toolkit
  13719.  
  13720.  
  13721.  
  13722.  
  13723.  
  13724.                        Chapter 14 - Sizing and Sliders
  13725.  
  13726.                    you can determine the relative position of the slider
  13727.                    without having to examine any other variables.
  13728. Restrictions
  13729. See also
  13730. Example
  13731.  
  13732.  
  13733.  
  13734.  
  13735.  
  13736.  
  13737.  
  13738. ___________________________________________________________________________
  13739.  
  13740. ResizeFrame Procedure                                              TEGLSPEC
  13741. ___________________________________________________________________________
  13742.  
  13743.  
  13744. Function
  13745.                    Allocates a new buffer for a frame.
  13746. Declaration
  13747.                    ResizeFrame(ifs : ImageStkPtr; x,y,x1,y1 : Word);
  13748. Remarks
  13749.                    x, y, x1, y1 are the new coordinates of the frame.
  13750. Restrictions
  13751.                    The frame image is hidden then disposed.
  13752. See also
  13753.                    DefineResizeMinMax
  13754. Example
  13755.  
  13756.  
  13757.  
  13758.  
  13759.  
  13760.  
  13761.  
  13762.  
  13763. ___________________________________________________________________________
  13764.  
  13765. SelectAndMoveFrame Event                                           TEGLSPEC
  13766. ___________________________________________________________________________
  13767.  
  13768.  
  13769. Function
  13770.                    An event that allows the frame to be moved.
  13771. Declaration
  13772.                    SelectAndMoveFrame(ifs: ImageStkPtr; ms: MsClickPtr):
  13773.                      Word; 
  13774. Remarks
  13775.                    Note that this is an event. You would not directly call
  13776.                    it but rather would pass it with a DefineMouseClickArea.
  13777. See also
  13778.  
  13779.  Programmer's Reference Guide       - 226 -         TEGL Windows Toolkit
  13780.  
  13781.  
  13782.  
  13783.  
  13784.  
  13785.                        Chapter 14 - Sizing and Sliders
  13786.  
  13787.                    DefineMouseClickArea.
  13788. Example
  13789.  
  13790.  
  13791.   { -- the top 10 pixels across the frame ifs is set to SelectAndMoveFrame }
  13792.  
  13793.   DefineMouseClickArea(ifs,0,0,ifs^.x1,10,TRUE,SelectAndMoveFrame,MSClick);
  13794.  
  13795.  
  13796.  
  13797.  
  13798.  
  13799. ___________________________________________________________________________
  13800.  
  13801. SetSlidePosition Procedure                                         TEGLSPEC
  13802. ___________________________________________________________________________
  13803.  
  13804.  
  13805.  
  13806. Function
  13807.                    Moves a slider to a new position.
  13808. Declaration
  13809.                    SetSlidePosition(ifs : ImageStkPointer; x,y : Word);
  13810. Remarks
  13811.                    x,y are relative coordinates within the frame and
  13812.                    must be within the slider bar.
  13813. See also
  13814.                    DefineSliderArea.
  13815.  
  13816.  
  13817.  
  13818.  
  13819.  
  13820.  
  13821.  
  13822.  
  13823.  
  13824.  
  13825.  
  13826.  
  13827.  
  13828.  
  13829.  
  13830.  
  13831.  
  13832.  
  13833.  
  13834.  
  13835.  
  13836.  
  13837.  
  13838.  
  13839.  
  13840.  Programmer's Reference Guide       - 227 -         TEGL Windows Toolkit
  13841.  
  13842.  
  13843.  
  13844.  
  13845.  
  13846.                            Miscellaneous Functions
  13847.  
  13848. Miscellaneous Functions
  13849. ___________________________________________________________________________
  13850.  
  13851.  
  13852. ___________________________________________________________________________
  13853.  
  13854. CheckCtrlBreak Procedure                                           TEGLUNIT
  13855. ___________________________________________________________________________
  13856.  
  13857.  
  13858.  
  13859. Function
  13860.                    Checks task handler.
  13861. Declaration
  13862.                    CheckCtrlBreak; 
  13863. Remarks
  13864.                    Normally this routine does not have to be called, but
  13865.                    if you have section of code that is going through a
  13866.                    long loop you should insert it there.
  13867.  
  13868.                    If your program has events that are activated after a
  13869.                    certain number of timer ticks have passed then a call
  13870.                    to CheckCtrlBreak will allow their processing.
  13871.  
  13872.                    The TEGL Windows Toolkit does not process timer
  13873.                    interrupt tasks directly, rather a flag is set and
  13874.                    the task is performed when it is safe (ie. no frames
  13875.                    are being updated and no memory swaps are begin
  13876.                    processed).
  13877. Example
  13878.  
  13879.  
  13880.  
  13881. VAR x : LongInt;
  13882.  
  13883.   FOR x := 1 TO 20000000 DO
  13884.     BEGIN
  13885.       { -- do your stuff }
  13886.       CheckCtrlBreak;   { --  allow processing of other tasks }
  13887.     END;
  13888.  
  13889.  
  13890.  
  13891.  
  13892.  
  13893. ___________________________________________________________________________
  13894.  
  13895. CheckCtrlBreakFS Procedure                                         TEGLUNIT
  13896. ___________________________________________________________________________
  13897.  
  13898.  
  13899.  
  13900.  
  13901.  Programmer's Reference Guide       - 228 -         TEGL Windows Toolkit
  13902.  
  13903.  
  13904.  
  13905.  
  13906.  
  13907.                            Miscellaneous Functions
  13908.  
  13909. Function
  13910.                    Sets an event to call when Ctrl-Break is pressed.
  13911. Declaration
  13912.                    CheckCtrlBreakFS(p : CallProc); 
  13913. Remarks
  13914.                    P is an event and works like any other. You can
  13915.                    determine within it what processing should take place
  13916.                    (Halt, Continue, Close files, etc..).
  13917. Example
  13918.                    See InitTEGL in TEGLEasy.
  13919.  
  13920.  
  13921.  
  13922. ___________________________________________________________________________
  13923.  
  13924. DropTimerTick Procedure                                            TEGLUNIT
  13925. ___________________________________________________________________________
  13926.  
  13927.  
  13928.  
  13929. Function
  13930.                    Removes an event set with SetTimerTick.
  13931. Declaration
  13932.                    DropTimerTick(Ticks : Word; P : CallProc); 
  13933. Remarks
  13934.                    Both Ticks and P must be identical to the
  13935.                    orginal call for the event to be removed.
  13936. See also
  13937.                    SetTimerTick.
  13938. Example
  13939.  
  13940.  
  13941.   DropTimerTick(18,BackGroundClock);
  13942.  
  13943.  
  13944.  
  13945.  
  13946.  
  13947.  
  13948. ___________________________________________________________________________
  13949.  
  13950. NilUnitProc Event                                                  TEGLUNIT
  13951. ___________________________________________________________________________
  13952.  
  13953.  
  13954.  
  13955. Function
  13956.                    A place holder for events that have not been coded.
  13957. Declaration
  13958.                    NilUnitProc; 
  13959. Remarks
  13960.                    NilUnitProc can be used wherever an event handler
  13961.  
  13962.  Programmer's Reference Guide       - 229 -         TEGL Windows Toolkit
  13963.  
  13964.  
  13965.  
  13966.  
  13967.  
  13968.                            Miscellaneous Functions
  13969.  
  13970.                    is called for. This can be a place holder or it can be
  13971.                    where event is desired but a parameter is required.
  13972. Example
  13973.  
  13974.  
  13975.   { -- a line in a menu that is never selected or active }
  13976.   DefineOptions(filem,'--',false,nilunitproc);
  13977.  
  13978.  
  13979.  
  13980.  
  13981.  
  13982. ___________________________________________________________________________
  13983.  
  13984. OverLapArea Function                                               TEGLUNIT
  13985. ___________________________________________________________________________
  13986.  
  13987.  
  13988.  
  13989. Function
  13990.                    Returns the area that is occupied by two sets of
  13991.                    coordinates.
  13992. Declaration
  13993.                    OverlayArea(ax, ay, ax1, ay1, bx, by, bx1,b y1 : Word;
  13994.                      VAR cx, cy, cx1, cy1 : Word) : Boolean 
  13995. Remarks
  13996.                    a and b coodinates are the areas to test.
  13997.                    If they overlap then the area is return in the c
  13998.                    coordinates and the function returns true, otherwise
  13999.                    the function returns false and the c coordinates
  14000.                    are undetermined.
  14001.  
  14002.                    This is an advanced function that normally would not
  14003.                    be used.
  14004.  
  14005.  
  14006.  
  14007.  
  14008. ___________________________________________________________________________
  14009.  
  14010. SetTimerTick Procedure                                             TEGLUNIT
  14011. ___________________________________________________________________________
  14012.  
  14013.  
  14014.  
  14015. Function
  14016.                    Sets an event to be called periodically.
  14017. Declaration
  14018.                    SetTimerTick(Ticks : Word; p : CallProc;
  14019.                      ifs : ImageStkPtr; ms : MsClickPtr); 
  14020. Remarks
  14021.                    Ticks is how many timer ticks to wait before
  14022.  
  14023.  Programmer's Reference Guide       - 230 -         TEGL Windows Toolkit
  14024.  
  14025.  
  14026.  
  14027.  
  14028.  
  14029.                            Miscellaneous Functions
  14030.  
  14031.                    begin called. p is the event to call. ifs and
  14032.                    ms are passed to p.
  14033. See also
  14034.                    DropTimerTick.
  14035. Example
  14036.  
  14037.  
  14038.   SetTimerTick(18,BackGroundClock,NIL,NIL);
  14039.  
  14040.  
  14041.  
  14042.  
  14043.  
  14044.  
  14045.  
  14046.  
  14047.  
  14048.  
  14049.  
  14050.  
  14051.  
  14052.  
  14053.  
  14054.  
  14055.  
  14056.  
  14057.  
  14058.  
  14059.  
  14060.  
  14061.  
  14062.  
  14063.  
  14064.  
  14065.  
  14066.  
  14067.  
  14068.  
  14069.  
  14070.  
  14071.  
  14072.  
  14073.  
  14074.  
  14075.  
  14076.  
  14077.  
  14078.  
  14079.  
  14080.  
  14081.  
  14082.  
  14083.  
  14084.  Programmer's Reference Guide       - 231 -         TEGL Windows Toolkit
  14085.  
  14086.  
  14087.  
  14088.  
  14089.  
  14090.                                    TGraph
  14091.  
  14092. TGraph
  14093. ___________________________________________________________________________
  14094.  
  14095. The TGraph unit provides a subset of the functions in the Graph
  14096. unit provided with Turbo Pascal.
  14097.  
  14098. TGraph does not have to be used if you are using Turbo Pascal. If your
  14099. program requires elaborate graphics drawing and painting then the Graph
  14100. unit is needed. If, however, your graphics need are simpler then TGraph
  14101. may provide all that is needed. If this is the case your program can be as
  14102. much as 25K smaller by using TGraph exculsively. See the appendix
  14103. Condtional Compilation for directions on building the toolkit without
  14104. using the Graph unit.
  14105.  
  14106. If you are programming with Microsoft's Quick Pascal then TGraph is
  14107. necessary. Depending on the defines in the file switches.inc (see the
  14108. appendix Conditional Compilation) TGraph acts as stand-alone or maps
  14109. graphics calls to the equivalent MSGraph routine.
  14110.  
  14111.  
  14112. ___________________________________________________________________________
  14113.  
  14114. Bar Procedure                                                        TGRAPH
  14115. ___________________________________________________________________________
  14116.  
  14117.  
  14118.  
  14119. Function
  14120.                    Draws a bar using the current fill style and color.
  14121. Declaration
  14122.                    Bar(x1, y1, x2, y2: Integer);
  14123. Remarks
  14124.                    Draws a filled in bar using the pattern and color
  14125.                    defined by SetFillStyle or SetFillPattern.
  14126. See also
  14127.                    SetFillStyle, SetFillPattern
  14128.  
  14129.  
  14130.  
  14131. ___________________________________________________________________________
  14132.  
  14133. CloseGraph Procedure                                                 TGRAPH
  14134. ___________________________________________________________________________
  14135.  
  14136.  
  14137.  
  14138. Function
  14139.                    Shuts down the graphics system.
  14140. Declaration
  14141.                    CloseGraph
  14142. Remarks
  14143.                    The screen mode is restored to the original mode before
  14144.  
  14145.  Programmer's Reference Guide       - 232 -         TEGL Windows Toolkit
  14146.  
  14147.  
  14148.  
  14149.  
  14150.  
  14151.                                    TGraph
  14152.  
  14153.                    graphics were initialized.
  14154.  
  14155.  
  14156.  
  14157.  
  14158. ___________________________________________________________________________
  14159.  
  14160. DetectGraph Procedure                                                TGRAPH
  14161. ___________________________________________________________________________
  14162.  
  14163.  
  14164.  
  14165. Function
  14166.                    Detects graphics hardware.
  14167. Declaration
  14168.                    DetectGraph(VAR GraphDriver, GraphMode : Integer);
  14169. Remarks
  14170.                    Returns the detected driver and mode value that can be
  14171.                    passed to InitGraph which will change to graphics
  14172.                    mode. If no graphics hardware is found or the graphics
  14173.                    hardware is not supported  then a call to GraphResult
  14174.                    will return a value of -2 (grNotDetected).
  14175. See also
  14176.                    InitGraph, GraphResult
  14177.  
  14178.  
  14179.  
  14180. ___________________________________________________________________________
  14181.  
  14182. GetBkColor Function                                                  TGRAPH
  14183. ___________________________________________________________________________
  14184.  
  14185.  
  14186.  
  14187. Function
  14188.                    Returns the current background color.
  14189. Declaration
  14190.                    GetBkColor : word;
  14191. Remarks
  14192.                    Background colors can range from 0 to 15.
  14193. See also
  14194.                    GetColor, SetBkColor, SetColor
  14195.  
  14196.  
  14197.  
  14198.  
  14199. ___________________________________________________________________________
  14200.  
  14201. GetColor Function                                                    TGRAPH
  14202. ___________________________________________________________________________
  14203.  
  14204.  
  14205.  
  14206.  Programmer's Reference Guide       - 233 -         TEGL Windows Toolkit
  14207.  
  14208.  
  14209.  
  14210.  
  14211.  
  14212.                                    TGraph
  14213.  
  14214.  
  14215. Function
  14216.                    Returns the color value passed to the previous call to
  14217.                    SetColor.
  14218. Declaration
  14219.                    GetColor : Word;
  14220. Remarks
  14221.                    Drawing colors can range from 0 to 15.
  14222. See also
  14223.                    SetColor
  14224.  
  14225.  
  14226.  
  14227. ___________________________________________________________________________
  14228.  
  14229. GetFillPattern Procedure                                             TGRAPH
  14230. ___________________________________________________________________________
  14231.  
  14232.  
  14233. Function
  14234.                    Returns the last fill pattern set by the last call to
  14235.                    SetFillPattern.
  14236. Declaration
  14237.                    GetFillPattern(VAR FillPattern : FillPatternType);
  14238. Remarks
  14239.                    FillPatternType is
  14240.  
  14241.                      TYPE
  14242.                        FillPatternType = array[0..8] of byte;
  14243.  
  14244.  
  14245. See also
  14246.                    SetFillPattern, GetFillSettings
  14247.  
  14248.  
  14249.  
  14250.  
  14251. ___________________________________________________________________________
  14252.  
  14253. GetGraphMode Function                                                TGRAPH
  14254. ___________________________________________________________________________
  14255.  
  14256.  
  14257.  
  14258. Function
  14259.                    Returns the current graphics mode.
  14260. Declaration
  14261.                    GetGraphMode : Integer;
  14262. Remarks
  14263.                    Returns the current graphics mode set by InitGraph
  14264.                    or SetGraphMode.
  14265. See also
  14266.  
  14267.  Programmer's Reference Guide       - 234 -         TEGL Windows Toolkit
  14268.  
  14269.  
  14270.  
  14271.  
  14272.  
  14273.                                    TGraph
  14274.  
  14275.                    DetectGraph, InitGraph, RestoreCrtMode,
  14276.                      SetGraphMode
  14277.  
  14278.  
  14279.  
  14280. ___________________________________________________________________________
  14281.  
  14282. GetMaxX Function                                                     TGRAPH
  14283. ___________________________________________________________________________
  14284.  
  14285.  
  14286. Function
  14287.                    Returns the pixel width (minus 1) of the current graphics
  14288.                    driver and mode.
  14289. Declaration
  14290.                    GetMaxX : Integer;
  14291. Remarks
  14292.                    GetMaxX can be used to determine the boundaries of the
  14293.                    screen.
  14294. See also
  14295.                    GetMaxY, GetX, GetY
  14296.  
  14297.  
  14298.  
  14299. ___________________________________________________________________________
  14300.  
  14301. GetMaxY Function                                                     TGRAPH
  14302. ___________________________________________________________________________
  14303.  
  14304.  
  14305. Function
  14306.                    Returns the pixel height (minus 1) of the current graphics
  14307.                    driver and mode.
  14308. Declaration
  14309.                    GetMaxY : Integer;
  14310. Remarks
  14311.                    GetMaxY can be used to determine the boundaries of the
  14312.                    screen.
  14313. See also
  14314.                    GetMaxX, GetX, GetY
  14315.  
  14316.  
  14317.  
  14318. ___________________________________________________________________________
  14319.  
  14320. GetTextSettings Procedure                                            TGRAPH
  14321. ___________________________________________________________________________
  14322.  
  14323.  
  14324.  
  14325. Function
  14326.                    Returns the current text settings.
  14327.  
  14328.  Programmer's Reference Guide       - 235 -         TEGL Windows Toolkit
  14329.  
  14330.  
  14331.  
  14332.  
  14333.  
  14334.                                    TGraph
  14335.  
  14336. Declaration
  14337.                    GetTextSettings(VAR TextInfo : TextSettingsType);
  14338. Remarks
  14339.                    TextSettingsType contains fields for the font,
  14340.                    direction, size and justification that was set by
  14341.                    SetTextStyle and SetTextJustify.
  14342. See also
  14343.                    SetTextJustify, SetTextStyle
  14344.  
  14345.  
  14346.  
  14347. ___________________________________________________________________________
  14348.  
  14349. ImageSize Function \ TGraph                                                
  14350. ___________________________________________________________________________
  14351.  
  14352.  
  14353. Function
  14354.                    Returns the number of bytes required to store a
  14355.                    rectangular region of the screen.
  14356. Declaration
  14357.                    ImageSize(x1, y1, x2, y2: Integer): Word;
  14358. Remarks
  14359.                    x1,y1,x2,y1 defines the area on the screen.
  14360.  
  14361.  
  14362.  
  14363. ___________________________________________________________________________
  14364.  
  14365. GraphResult Function                                                 TGRAPH
  14366. ___________________________________________________________________________
  14367.  
  14368.  
  14369. Function
  14370.                    Returns the error code for the last graphics operation.
  14371. Declaration
  14372.                    GraphResult : Integer;
  14373. Remarks
  14374.                    GraphResult is reset to zero after it has been
  14375.                    called. The user may want to store it into a temporary
  14376.                    variable before testing it.
  14377.  
  14378.  
  14379.  
  14380. ___________________________________________________________________________
  14381.  
  14382. InitGraph Procedure                                                  TGRAPH
  14383. ___________________________________________________________________________
  14384.  
  14385.  
  14386. Function
  14387.                    Initializes the graphics system and sets the hardware to
  14388.  
  14389.  Programmer's Reference Guide       - 236 -         TEGL Windows Toolkit
  14390.  
  14391.  
  14392.  
  14393.  
  14394.  
  14395.                                    TGraph
  14396.  
  14397.                    graphics mode.
  14398. Declaration
  14399.                    InitGraph(VAR GraphDriver : Integer;
  14400.                      VAR GraphMode: Integer; DriverPath : String);
  14401. Remarks
  14402.                    If GraphDriver is equal to 0 (Detect) then a
  14403.                    call is made to DetectGraph. If supported hardware
  14404.                    is detected then the graphics system is initialized and
  14405.                    a graphics mode is selected.
  14406.  
  14407.                    The parameter DriverPath is provided for compatibility
  14408.                    with Graph, it is not used, all drivers are linked in.
  14409. See also
  14410.                    DetectGraph, CloseGraph
  14411.  
  14412.  
  14413.  
  14414. ___________________________________________________________________________
  14415.  
  14416. Line Procedure                                                       TGRAPH
  14417. ___________________________________________________________________________
  14418.  
  14419.  
  14420. Function
  14421.                    Draws a line from x1, y1 to x2, y2.
  14422. Declaration
  14423.                    Line(x1, y1, x2, y2 : Integer);
  14424. Remarks
  14425.                    Draws a line in the color set by SetColor
  14426.  
  14427.  
  14428.  
  14429. ___________________________________________________________________________
  14430.  
  14431. OutTextXY Procedure                                                  TGRAPH
  14432. ___________________________________________________________________________
  14433.  
  14434.  
  14435. Function
  14436.                    Sends a string to the screen.
  14437. Declaration
  14438.                    OutTextXY(x,y : Integer; TextString: String);
  14439. Remarks
  14440.                    TextString is output at the screen location
  14441.                    x,y.
  14442.  
  14443.                    OutTextXY uses the options set by SetTextJustify.
  14444. See also
  14445.                    SetTextJustify, GetTextSettings
  14446.  
  14447.  
  14448.  
  14449.  
  14450.  Programmer's Reference Guide       - 237 -         TEGL Windows Toolkit
  14451.  
  14452.  
  14453.  
  14454.  
  14455.  
  14456.                                    TGraph
  14457.  
  14458. ___________________________________________________________________________
  14459.  
  14460. Rectangle Procedure                                                  TGRAPH
  14461. ___________________________________________________________________________
  14462.  
  14463.  
  14464. Function
  14465.                    Draws a rectangle using the current color.
  14466. Declaration
  14467.                    Rectangle(x1, y1, x2, y2 : Integer);
  14468. Remarks         x1,y1 define the upper left corner of the rectangle,
  14469.                    and x2,y2 define the lower right corner.
  14470. See also
  14471.                    SetColor
  14472.  
  14473.  
  14474.  
  14475. ___________________________________________________________________________
  14476.  
  14477. RestoreCrtMode Procedure \ TGraph                                          
  14478. ___________________________________________________________________________
  14479.  
  14480.  
  14481. Function
  14482.                    Restore the screen mode.
  14483. Declaration
  14484.                    RestoreCrtMode;
  14485. Remarks
  14486.                    Restore the screen mode to its original state before
  14487.                    graphics was initialized.
  14488. See also
  14489.                    DetectGraph, InitGraph
  14490.  
  14491.  
  14492.  
  14493. ___________________________________________________________________________
  14494.  
  14495. SetBkColor Procedure                                                 TGRAPH
  14496. ___________________________________________________________________________
  14497.  
  14498.  
  14499. Function
  14500.                    Sets the backgound color.
  14501. Declaration
  14502. Remarks
  14503.                    Background colors may range from 0 to 15.
  14504. See also
  14505.                    GetBkColor,SetColor
  14506.  
  14507.  
  14508.  
  14509. ___________________________________________________________________________
  14510.  
  14511.  Programmer's Reference Guide       - 238 -         TEGL Windows Toolkit
  14512.  
  14513.  
  14514.  
  14515.  
  14516.  
  14517.                                    TGraph
  14518.  
  14519.  
  14520. SetColor Procedure                                                   TGRAPH
  14521. ___________________________________________________________________________
  14522.  
  14523.  
  14524. Function
  14525.                    Set the drawing color.
  14526. Declaration
  14527.                    SetColor(Color : Word);
  14528. Remarks
  14529.                    Drawing colors may range from 0 to 15.
  14530. See also
  14531.                    GetColor
  14532.  
  14533.  
  14534.  
  14535.  
  14536. ___________________________________________________________________________
  14537.  
  14538. SetFillPattern Procedure                                             TGRAPH
  14539. ___________________________________________________________________________
  14540.  
  14541.  
  14542. Function
  14543.                    Selects a user-defined fill pattern.
  14544. Declaration
  14545.                    SetFillPattern(Pattern : fillPatternType; Color: Word);
  14546. Remarks
  14547.                    Sets the pattern and color for all filling done by
  14548.                    Bar.
  14549. See also
  14550.                    GetFillPattern, SetFillStyle
  14551.  
  14552.  
  14553.  
  14554. ___________________________________________________________________________
  14555.  
  14556. SetFillStyle Procedure                                               TGRAPH
  14557. ___________________________________________________________________________
  14558.  
  14559.  
  14560. Function
  14561.                    Sets the fill pattern and color.
  14562. Declaration
  14563.                    SetFillStyle(Pattern : Word; Color: Word);
  14564. Remarks
  14565.                    Set the pattern and color for all filling done by
  14566.                    Bar. There are 12 fill patterns available.
  14567. See also
  14568.                    GetFillSettings
  14569.  
  14570.  
  14571.  
  14572.  Programmer's Reference Guide       - 239 -         TEGL Windows Toolkit
  14573.  
  14574.  
  14575.  
  14576.  
  14577.  
  14578.                                    TGraph
  14579.  
  14580.  
  14581. ___________________________________________________________________________
  14582.  
  14583. SetTextJustify Procedure                                             TGRAPH
  14584. ___________________________________________________________________________
  14585.  
  14586.  
  14587. Function
  14588.                    Sets text justification values used by OutTextXY.
  14589. Declaration
  14590.                    SetTextJustify(Horiz, Vert: Word);
  14591. Remarks
  14592.                    The default justification settings are SetTextJustify(
  14593.                    LeftText, TopText).
  14594. See also
  14595.                    GetTextSettings, OutTextXY
  14596.  
  14597.  
  14598.  
  14599.  
  14600.  
  14601.  
  14602.  
  14603.  
  14604.  
  14605.  
  14606.  
  14607.  
  14608.  
  14609.  
  14610.  
  14611.  
  14612.  
  14613.  
  14614.  
  14615.  
  14616.  
  14617.  
  14618.  
  14619.  
  14620.  
  14621.  
  14622.  
  14623.  
  14624.  
  14625.  
  14626.  
  14627.  
  14628.  
  14629.  
  14630.  
  14631.  
  14632.  
  14633.  Programmer's Reference Guide       - 240 -         TEGL Windows Toolkit
  14634.  
  14635.  
  14636.  
  14637.  
  14638.  
  14639.                               APPENDICES
  14640.  
  14641.  
  14642. Appendix A - Overlapping Graphics
  14643. ___________________________________________________________________________
  14644.  
  14645. There are many methods in creating and managing overlapping windows,
  14646. however the end result to the user must be in the context of windows that
  14647. form independent layers on a single display.
  14648.  
  14649. This section discusses the method that is used with the TEGL Windowing
  14650. Manager.
  14651.  
  14652.  
  14653. Video Buffers
  14654.  
  14655. The video buffer is a block of memory where displayable data is stored.  A
  14656. program may read and write to the video buffer in the same way it accesses
  14657. any other memory.
  14658.  
  14659. The video display circuitry updates the screen by continually reading the
  14660. data in the video buffer and translating the bit information to the
  14661. screen. Each group of bits in the video buffer specifies the color and
  14662. brightness of a particular location on the screen. A particular location
  14663. on the screen is known as a pixel. If a program changes the contents of
  14664. the video buffer, the screen reflects the change immediately.
  14665.  
  14666. Because you have control over each pixel in the displayed image, you can
  14667. construct complex geometric images, fill arbitrary areas of the screen
  14668. with blends of colors, or create animated images that moves across the
  14669. screen.
  14670.  
  14671. We may think of windows as multiple video buffers, the distinction is that,
  14672. with the TEGL Windows Toolkit, only 1 video buffer is used. To create a
  14673. window effect, we must physically copy and move display data to and from a
  14674. single video buffer, overlaying the images as we would layout images on
  14675. paper.
  14676.  
  14677.  
  14678. Windows
  14679.  
  14680. Windows are simply predefined rectangular areas of the screen. A window
  14681. manager is a coordinator that ensures that images related to a window are
  14682. saved (stored in memory) before other overlapping images writes to the
  14683. screen. When a window is closed, the underlying image is copied back to
  14684. screen video buffer.
  14685.  
  14686. The basis of a window manager is the copying and restoring of multiple
  14687. areas of the screen.
  14688.  
  14689.  
  14690. Frames
  14691.  
  14692. An EGA video has a maximum resolution of 640 pixels horizontal by 350
  14693.  
  14694.  Programmer's Reference Guide       - 241 -         TEGL Windows Toolkit
  14695.  
  14696.  
  14697.  
  14698.  
  14699.  
  14700.                               APPENDICES
  14701.  
  14702. pixels. The coordinates are specified as (x,y) and (x1,y1), where x and y
  14703. are the horizontal and vertical position respectively. The position is
  14704. relative to upper left coordinate which has a coordinate value of (0,0).
  14705.  
  14706.                               (x,y)
  14707.                                 +---------+
  14708.                                 |(y)      |
  14709.                                 ||        |
  14710.                                 ||        |
  14711.                                 |*        |
  14712.                                 |         |
  14713.                                 |(x)----->|
  14714.                                 +---------+
  14715.                                        (x1,y1)
  14716.  
  14717. A Frame Stack
  14718.  
  14719. A frame stack is a list with each entry representing a screen area. Each
  14720. entry contains information and data that is required by the window manager
  14721. to coordinate the overlaps between frames.
  14722.  
  14723. The order of the list is in the same order as the frames are stacked on
  14724. the screen.
  14725.  
  14726.  
  14727. A Simple Window Manager
  14728.  
  14729. This section talks about creating a simple window manager. We will use
  14730. the following example to see how we can update frame (A) independent of
  14731. the other 3 frames.
  14732.  
  14733. The following frames have called PUSHIMAGE to save the underlying
  14734. graphics.
  14735.  
  14736.                                  +----------------+
  14737.                        +---------+--+             |
  14738.                        |            |             |
  14739.                        |            |--+          |
  14740.                        |            |B |  A       |
  14741.                        | D          |--+          |
  14742.                        |            |             |
  14743.                        |            |--+          |
  14744.                        |            |C |          |
  14745.                        |            |--+          |
  14746.                        |            |             |
  14747.                        +---------+--+             |
  14748.                                  |                |
  14749.                                  +----------------+
  14750.  
  14751. In order for Frame (A) to be updated, the image for Frame (D) is saved, and
  14752. Frame (D) is erased from the screen
  14753. by restoring the the underlying image that was saved previously.
  14754.  
  14755.  Programmer's Reference Guide       - 242 -         TEGL Windows Toolkit
  14756.  
  14757.  
  14758.  
  14759.  
  14760.  
  14761.                               APPENDICES
  14762.  
  14763.  
  14764.                                  +----------------+
  14765.                                  |                |
  14766.                                  |                |
  14767.                            +-----|-----+          |
  14768.                            |  B  |     |  A       |
  14769.                            +-----|-----+          |
  14770.                                  |                |
  14771.                            +-----|-----+          |
  14772.                            |  C  |     |          |
  14773.                            +-----|-----+          |
  14774.                                  |                |
  14775.                                  |                |
  14776.                                  |                |
  14777.                                  +----------------+
  14778.  
  14779. The image for Frame (C) is saved, and Frame (C) is erased from the screen
  14780. by restoring the the underlying image that was saved previously.
  14781.  
  14782.                                  +----------------+
  14783.                                  |                |
  14784.                                  |                |
  14785.                            +-----|-----+          |
  14786.                            |  B  |     |  A       |
  14787.                            +-----|-----+          |
  14788.                                  |                |
  14789.                                  |                |
  14790.                                  |                |
  14791.                                  |                |
  14792.                                  |                |
  14793.                                  |                |
  14794.                                  |                |
  14795.                                  +----------------+
  14796.  
  14797. The image for Frame (B) is saved, and Frame (B) is erased from the screen
  14798. by restoring the the underlying image that was saved previously.
  14799.  
  14800.                                  +----------------+
  14801.                                  |                |
  14802.                                  |                |
  14803.                                  |                |
  14804.                                  |        A       |
  14805.                                  |                |
  14806.                                  |                |
  14807.                                  |                |
  14808.                                  |                |
  14809.                                  |                |
  14810.                                  |                |
  14811.                                  |                |
  14812.                                  |                |
  14813.                                  +----------------+
  14814.  
  14815.  
  14816.  Programmer's Reference Guide       - 243 -         TEGL Windows Toolkit
  14817.  
  14818.  
  14819.  
  14820.  
  14821.  
  14822.                               APPENDICES
  14823.  
  14824. The composite image of (A) is now complete and can be updated. The images
  14825. (B), (C) and (D) are restored by reversing the above steps.
  14826.  
  14827. In the earlier generations of TEGL, this formed the basis of the stacked
  14828. frame concept (the removal of images that overlaps the current).
  14829.  
  14830.  
  14831. Partial Image Update
  14832.  
  14833. As you can imagine, this process is slow and causes a lot a of unnecessary
  14834. updates to the screen. With the foundation of q a simple window manager,
  14835. we can now begin to refine this process.
  14836.  
  14837. Partial image update is removing only the intersection portion of the
  14838. frames from the screen by extracting a section of the saved image.
  14839.  
  14840. The following shows the intersection of D,C and B that is needed to
  14841. be replaced on the screen.
  14842.  
  14843.                                  +--+
  14844.                                  |D |
  14845.                                  |  |  +-----+
  14846.                                  |  |  |B    |
  14847.                                  |  |  +-----+
  14848.                                  |  |  +-----+
  14849.                                  |  |  |C    |
  14850.                                  |  |  +-----+
  14851.                                  +--+
  14852.  
  14853. Partial Image (D) is replaced first, followed by Partial (C) and (B).
  14854.  
  14855. Refined Partial Image Update
  14856.  
  14857. Since we are only interested in the composite image of (A), there is still
  14858. a lot of unnecessary update to the screen.
  14859.  
  14860. Imagine a notepad and you wish to write on the fifth page of the notepad.
  14861. The fastest way to lift up five pages in a
  14862. group, write, and close the notepad.
  14863.  
  14864. So let's split image (D) into 5 pieces.
  14865.  
  14866.       +--+
  14867.       |D1|
  14868.       +--+
  14869.       +--+--+
  14870.       |D2| B|
  14871.       +--+--+
  14872.       +--+
  14873.       |D3|
  14874.       +--+
  14875.       +--+--+
  14876.  
  14877.  Programmer's Reference Guide       - 244 -         TEGL Windows Toolkit
  14878.  
  14879.  
  14880.  
  14881.  
  14882.  
  14883.                               APPENDICES
  14884.  
  14885.       |D4| C|
  14886.       +--+--+
  14887.       +--+
  14888.       |D5|
  14889.       +--+
  14890.  
  14891. Notice the double pages of (D2)(B) and (D4)(C).  Now we only need to
  14892. replace (D1), (B), (D3), (C) and (D5). We don't need to replace (D2) and
  14893. (D4) because (B) and (C) has already restored the composite image of (A).
  14894.  
  14895. TEGL was further refined to (cut out) only the pieces that needs to
  14896. be replaced, thus removing all unnecessary updates to the screen.
  14897.  
  14898.  
  14899. A Refined Partial Image Update Algorithm
  14900.  
  14901.  
  14902. check for condition where by replacing the bottom image
  14903. will replace the top image. eg.
  14904.  
  14905.                              +----------------+
  14906.                              |1 +---------+   |
  14907.                              |  | 2 +-----+   |
  14908.                              |  |   |  3  |   |
  14909.                              |  +---+-----+   |
  14910.                              +----------------+
  14911.  
  14912. Replacing 3 will be redundant, since we want to update 1, replacing 2
  14913. will remove both 2 and 3.
  14914.  
  14915. check if we can begin trim the ends off one of the overlapped
  14916. images to reduce the size that we need to replace.
  14917.  
  14918. +---------+ +---------+ +---------+  +---------+ +---+---------+ +---------+---+
  14919. |   +-----+ | +-----+ | +-----+   |  |     :   | |   | :       | |       : |   |
  14920. +---|.....| +-|.....|-+ |.....|---+  +---------+ |   +---------+ +---------+   |
  14921.     |     |   |     |   |     |      |     |     |     |                 |     |
  14922.     |     |   |     |   |     |      +-----+     +-----+                 +-----+
  14923.     +-----+   +-----+   +-----+      +-----+     +-----+                 +-----+
  14924. +---+-----+ +-+-----+-+ +-----+---+  +---------+ |   +---------+ +---------+   |
  14925. |   |     | | |     | | |     |   |  |     :   | |   | :       | |       : |   |
  14926. +---|.....| +-|.....|-+ |.....|---+  +---------+ |   +---------+ +---------+   |
  14927.     |     |   |     |   |     |      +-----+     +-----+                 +-----+
  14928.     +-----+   +-----+   +-----+      +-----+              +-----+     +-----+
  14929.     +-----+   +-----+   +-----+      |     |              |     |     |     |
  14930.     |     |   |     |   |     |      +---------+  +---------+   | +---------+
  14931. +---|.....| +-|.....|-+ |.....|---+  |     :   |  |       : |   | |   :     |
  14932. |   |     | | |     | | |     |   |  +---------+  +---------+---+ +---------+
  14933. +---+-----+ +-+-----+-+ +-----+---+  +-----+            +-----+  +---------+
  14934.     +-----+   +-----+   +-----+      |     |        +---------+  |   :     |
  14935.     |     |   |     |   |     |      |   +---------+|   :     |  +---------+
  14936.     |     |   |     |   |     |      |   | :       |+---------+      |     |
  14937.  
  14938.  Programmer's Reference Guide       - 245 -         TEGL Windows Toolkit
  14939.  
  14940.  
  14941.  
  14942.  
  14943.  
  14944.                               APPENDICES
  14945.  
  14946. +---|.....| +-|.....|-+ |.....|---+  +---+---------+    +-----+      +-----+
  14947. |   +-----+ | +-----+ | +-----+   |
  14948. +---------+ +---------+ +---------+
  14949.  
  14950.  create an new insert that has one end trimmed and repeat steps 1
  14951. through 3 to cut the images into the necessary pieces.
  14952.  
  14953.     +-----+   +-----+   +-----+     +---------+   +-----+     +-----+
  14954. +---|     | +-|     |-+ |     |---+ |       : | +---------+   |     |
  14955. |   |     | | |     | | |     |   | +---------+ |       : | +---------+
  14956. +---|.....| +-|.....|-+ |.....|---+   |     |   +---------+ |       : |
  14957.     +-----+   +-----+   +-----+       +-----+     +-----+   +---------+
  14958.                                 +-----+-------+                 +-------+-----+
  14959.         +-----+ +-----+         |     |       | +-----+ +-----+ |       |     |
  14960. +-------|.....| |.....|-------+ |.....|-------+ |     | |     | +-------|.....|
  14961. |       |     | |     |       | |     | +-------|.....| |.....|-------+ |     |
  14962. +-------|     | |     |-------+ +-----+ |       |     | |     |       | +-----+
  14963.         +-----+ +-----+                 +-------+-----+ +-----+-------+
  14964. +---------++-----++---------+    +---------+    +---------++-----++---------+
  14965. |.........||     ||.........|---+|.........|+---|.........||     ||.........|
  14966. +---------+|     |+---------+   |+---------+|   +---------+|     |+---------+
  14967.     |     ||.....|-------+|     |  |     |  |     |+-------|.....||     |
  14968.     |     |+-----+       ||     |  |     |  |     ||       +-----+|     |
  14969.     +-----+    +---------++-----+  +-----+  +-----++---------+    +-----+
  14970. +-----+    +-----++---------+      +-----+      +---------++-----+    +-----+
  14971. |     |    |     ||       +-----+  |     |  +-----+       ||     |    |     |
  14972. |     |    |     |+-------|.....|  |     |  |.....|-------+|     |    |     |
  14973. +---------+|   +---------+|     |+---------+|     |+---------+   |+---------+
  14974. |.........|+---|.........||     ||.........||     ||.........|---+|.........|
  14975. +---------+    +---------++-----++---------++-----++---------+    +---------+
  14976.  
  14977. The only time that we are unable to split an overlapping image is when
  14978. the image overlaps by 1 pixel.
  14979.  
  14980.                                     +---------+
  14981.                                     |         |
  14982.                          +----------|         |-----------+
  14983.                          |          +----+---------+      |
  14984.                          +---------------|         |------+
  14985.                                          |         |
  14986.                                          +---------+
  14987.  
  14988.  
  14989.  
  14990. A Quick Run through the algorithm
  14991.  
  14992. The procedure to handle the splitting of images is called
  14993. StackOverlaps. StackOverlaps works in the following fashion:
  14994.  
  14995.                    Top (Stackptr)*                              Bottom
  14996.                +--+---------+-----+---+        Top      +----------------+
  14997.                |D |x,y,x1,y1|image|...|       +---------+--+             |
  14998.  
  14999.  Programmer's Reference Guide       - 246 -         TEGL Windows Toolkit
  15000.  
  15001.  
  15002.  
  15003.  
  15004.  
  15005.                               APPENDICES
  15006.  
  15007.                +--+---------+-----+---+       |            |             |
  15008.                +--+---------+-----+---+       |            |--+          |
  15009.                |C |x,y,x1,y1|image|...|       |            |B |  A       |
  15010.                +--+---------+-----+---+       | D          |--+          |
  15011.                +--+---------+-----+---+       |            |             |
  15012.                |A |x,y,x1,y1|image|...|       |            |--+          |
  15013.                +--+---------+-----+---+       |            |C |          |
  15014.                +--+---------+-----+---+       |            |--+          |
  15015.                |A |x,y,x1,y1|image|...|       |            |             |
  15016.                +--+---------+-----+---+       +---------+--+             |
  15017.                    Bottom                               |                |
  15018.                                                         +----------------+
  15019.  
  15020. PrepareForUpdate(A) creates temporary stack entries:
  15021.  
  15022.                    Top (Stackptr)*
  15023.                +--+---------+-----+---+
  15024.         +----> |B1|x,y,x1,y1|image|...|
  15025.         |      +--+---------+-----+---+
  15026.         |      +--+---------+-----+---+                  +----------------+
  15027.         | +--> |C1|x,y,x1,y1|image|...|        +---------+--+             |
  15028.         | |    +--+---------+-----+---+        |         |D1|             |
  15029.         | |    +--+---------+-----+---+        |         +-----+          |
  15030.         | | +> |D1|x,y,x1,y1|image|...|        |         |B1   |  A       |
  15031.         | | |  +--+---------+-----+---+        | D       +-----+          |
  15032.         | | |  +--+---------+-----+---+        |         +-----+          |
  15033.         | | +> |D |x,y,x1,y1|image|...|        |         |C1   |          |
  15034.         | |    +--+---------+-----+---+        |         +-----+          |
  15035.         | |    +--+---------+-----+---+        |         |  |             |
  15036.         | +--> |C |x,y,x1,y1|image|...|        +---------+--+             |
  15037.         |      +--+---------+-----+---+                  |                |
  15038.         |      +--+---------+-----+---+                  +----------------+
  15039.         +----> |B |x,y,x1,y1|image|...|
  15040.                +--+---------+-----+---+
  15041.                +--+---------+-----+---+
  15042.                |A |x,y,x1,y1|image|...|
  15043.                +--+---------+-----+---+
  15044.                    Bottom
  15045.  
  15046. Begin Cutting and Eliminating: Comparing only the overlapped images.
  15047.  
  15048.                +--+---------+-----+---+             +--+        +--+
  15049.         +----> |B1|x,y,x1,y1|image|...| Bottom      |D1|        |D1|
  15050.         |      +--+---------+-----+---+     Image   |  |--+     |  |
  15051.         |      +--+---------+-----+---+             |  |B1|     |  |
  15052.         | +--> |C1|x,y,x1,y1|image|...|             |  |--+     |  |
  15053.         | |    +--+---------+-----+---+             |  |        |  |
  15054.         | |    +--+---------+-----+---+             |  |        |  |--+
  15055.         | | +> |D1|x,y,x1,y1|image|...| Top Image   |  |        |  |C1|
  15056.         | | |  +--+---------+-----+---+             |  |        |  |--+
  15057.                                                     |  |        |  |
  15058.                                                     +--+        +--+
  15059.  
  15060.  Programmer's Reference Guide       - 247 -         TEGL Windows Toolkit
  15061.  
  15062.  
  15063.  
  15064.  
  15065.  
  15066.                               APPENDICES
  15067.  
  15068.  
  15069. StackOverlaps compares B1 with D1, B1 with C1 and
  15070. C1 with D1 for overlaps.
  15071.  
  15072.  
  15073.  
  15074.  
  15075. eliminate redundant overlaps
  15076.  
  15077.  
  15078.  
  15079.  
  15080. Appendix B - Heap Management
  15081. ___________________________________________________________________________
  15082.  
  15083. One of the major problems with window management is the amount of dynamic
  15084. memory that is allocated and de-allocated.  Memory is constantly
  15085. fragmented with records, dynamic variables, and window images, thus
  15086. reducing the largest block size over a period of time.
  15087.  
  15088.            Empty Heap Memory                     Fragmented Heap Memory
  15089.  
  15090.            Top of DOS Memory                       Top of DOS Memory
  15091. FreePtr-> +-----------------+                     +-----------------+
  15092.           |        *        |                     |-----------------|1--+
  15093.           |                 |           FreePtr-> |-----------------|2--|+
  15094.           |                 |                     |                 |   ||
  15095.           |                 |                     |    Free Space   |   ||
  15096.           |                 |                     |       60k       |   ||
  15097.           |                 |           HeapPtr-> |-----------------|   ||
  15098.           |        *        |                     |-----------------|   ||
  15099.           |     MaxAvail    |                     |                 |   ||
  15100.           |      341k       |                     |    Free Space   |   ||
  15101.           |        *        |                     |       70k       |   ||
  15102.           |                 |                     |                 |   ||
  15103.           |                 |                     |-----------------|2<-|+
  15104.           |                 |                     |-----------------|   |
  15105.           |                 |                     |    Free Space   |   |
  15106.           |                 |                     |        *        |   |
  15107.           |                 |                     |     MaxAvail    |   |
  15108.           |                 |                     |      102k       |   |
  15109.           |                 |                     |        *        |   |
  15110.           |        *        |                     |                 |   |
  15111. HeapPtr-> |-----------------| <-----HeapOrg-----> |-----------------|1<-+
  15112.           |   * Program *   |                     |   * Program *   |
  15113.  
  15114. This chapter will discuss how the normal Turbo Pascal heap manager and the
  15115. TEGL heap manager can coexist, and how ReserveHugeMinimum reduces the
  15116. fragmentation that occurs.
  15117.  
  15118.  
  15119. Turbo Pascal Heap Manager
  15120.  
  15121.  Programmer's Reference Guide       - 248 -         TEGL Windows Toolkit
  15122.  
  15123.  
  15124.  
  15125.  
  15126.  
  15127.                               APPENDICES
  15128.  
  15129.  
  15130. There are only two main pointers that manages the heap. The HeapPtr
  15131. points to the end of the last memory block. FreePtr points to a list
  15132. of free memory blocks that can be re-used.
  15133.  
  15134.            Top of DOS Memory
  15135.           +-----------------+
  15136.           |-----------------|1--+
  15137. FreePtr-> |-----------------|2--|+
  15138.           |                 |   ||
  15139.           |    Free Space   |   ||
  15140.           |       60k       |   ||
  15141. HeapPtr-> |-----------------|   ||
  15142.           |-----------------|   ||
  15143.           |                 |   ||
  15144.           |    Free Space   |   ||
  15145.           |       70k       |   ||
  15146.           |                 |   ||
  15147.           |-----------------|2<-|+
  15148.           |-----------------|   |
  15149.           |    Free Space   |   |
  15150.           |        *        |   |
  15151.           |     MaxAvail    |   |
  15152.           |      102k       |   |
  15153.           |        *        |   |
  15154.           |                 |   |
  15155.           |-----------------|1<-+
  15156.           |   * Program *   |
  15157.  
  15158. When memory is requested from the Turbo Pascal Heap Manager, a sequential
  15159. scan of the Freeptr chain is made to see if any of the free memory
  15160. space can be re-used. Any free space that satisfy the requested size will
  15161. be used.
  15162.  
  15163. The free space is then reduced by the allocation size and removed from the
  15164. FreePtr chain if the block is completely allocated.
  15165.  
  15166. GETMEM(102k)
  15167.  
  15168.            Top of DOS Memory                      Top of DOS Memory
  15169.           +-----------------+                    +-----------------+
  15170.           |-----------------|1--+      FreePtr-> |-----------------|2--+
  15171. FreePtr-> |-----------------|2--|+               |                 |   |
  15172.           |                 |   ||               |                 |   |
  15173.           |    Free Space   |   ||               |    Free Space   |   |
  15174.           |       60k       |   ||               |       60k       |   |
  15175. HeapPtr-> |-----------------|   ||     HeapPtr-> |-----------------|   |
  15176.           |-----------------|   ||               |-----------------|   |
  15177.           |                 |   ||               |                 |   |
  15178.           |    Free Space   |   ||               |    Free Space   |   |
  15179.           |       70k       |   ||               |       70k       |   |
  15180.           |                 |   ||               |                 |   |
  15181.  
  15182.  Programmer's Reference Guide       - 249 -         TEGL Windows Toolkit
  15183.  
  15184.  
  15185.  
  15186.  
  15187.  
  15188.                               APPENDICES
  15189.  
  15190.           |-----------------|2<-|+               |-----------------|2<-+
  15191.           |-----------------|   |                |/////////////////|
  15192.           |    Free Space   |   |                |/////////////////|
  15193.           |        *        |   |                |/////////////////|
  15194.           |     MaxAvail    |   |                |/////////////////|
  15195.           |      102k       |   |                |/////////////////|
  15196.           |        *        |   |                |/////////////////|
  15197.           |                 |   |                |/////////////////|
  15198.           |-----------------|1<-+                |-----------------|
  15199.           |   * Program *   |                    |   * Program *   |
  15200.  
  15201. GETMEM(20k)
  15202.  
  15203.            Top of DOS Memory                      Top of DOS Memory
  15204.           +-----------------+                    +-----------------+
  15205.           |-----------------|1--+                |-----------------|1--+
  15206. FreePtr-> |-----------------|2--|+     FreePtr-> |-----------------|2--|+
  15207.           |                 |   ||               |                 |   ||
  15208.           |    Free Space   |   ||               |    Free Space   |   ||
  15209.           |       60k       |   ||               |       60k       |   ||
  15210. HeapPtr-> |-----------------|   ||     HeapPtr-> |-----------------|   ||
  15211.           |-----------------|   ||               |-----------------|   ||
  15212.           |                 |   ||               |    Free Space   |   ||
  15213.           |    Free Space   |   ||               |       50k       |   ||
  15214.           |       70k       |   ||               |-----------------|2<-|+
  15215.           |                 |   ||               |/////////////////|   |
  15216.           |-----------------|2<-|+               |-----------------|   |
  15217.           |-----------------|   |                |-----------------|   |
  15218.           |    Free Space   |   |                |    Free Space   |   |
  15219.           |        *        |   |                |        *        |   |
  15220.           |     MaxAvail    |   |                |     MaxAvail    |   |
  15221.           |      102k       |   |                |      102k       |   |
  15222.           |        *        |   |                |        *        |   |
  15223.           |                 |   |                |                 |   |
  15224.           |-----------------|1<-+                |-----------------|1<-+
  15225.           |   * Program *   |                    |   * Program *   |
  15226.  
  15227. When memory is released (freed), the Turbo Pascal Heap Manager
  15228. sequentially scans the Freeptr chain to see if any of the free memory
  15229. space is adjacent to the memory block that is being freed.
  15230.  
  15231. FREEMEM(A)
  15232.  
  15233.            Top of DOS Memory                      Top of DOS Memory
  15234.           +-----------------+                    +-----------------+
  15235.           |-----------------|1--+                |-----------------|1--+
  15236.           |-----------------|2--|+               |--------x--------|2--|+
  15237.           |--------x--------|3--||+              |-----------------|5--||--+
  15238.           |-----------------|4--|||+   FreePtr-> |-----------------|4--||+ |
  15239. FreePtr-> |-----------------|5--||||+            |        *        |   ||| |
  15240.           |        *        |   |||||            |                 |   ||| |
  15241.           |                 |   |||||            |                 |   ||| |
  15242.  
  15243.  Programmer's Reference Guide       - 250 -         TEGL Windows Toolkit
  15244.  
  15245.  
  15246.  
  15247.  
  15248.  
  15249.                               APPENDICES
  15250.  
  15251.           |                 |   |||||            |                 |   ||| |
  15252.           |                 |   |||||            |                 |   ||| |
  15253.           |        *        |   |||||            |        *        |   ||| |
  15254. HeapPtr-> |-----------------|   |||||  HeapPtr-> |-----------------|   ||| |
  15255.           |+++++++++++++++++|   |||||            |+++++++++++++++++|   ||| |
  15256.           |+++++++++++++++++|2<-|+|||            |+++++++++++++++++|2<-|+| |
  15257.     (A)>>>|+++++++++++++++++|   | |||            |                 |   | | |
  15258.           |+++++++++++++++++|3<-|-+||      (A)>>>|-----------------|   | | |
  15259.           |+++++++++++++++++|   |  ||            |+++++++++++++++++|   | | |
  15260.           |+++++++++++++++++|5<-|--|+            |+++++++++++++++++|5<-|-|-+
  15261.           |+++++++++++++++++|   |  |             |+++++++++++++++++|   | |
  15262.           |+++++++++++++++++|1<-+  |             |+++++++++++++++++|1<-+ |
  15263.           |+++++++++++++++++|      |             |+++++++++++++++++|     |
  15264.           |+++++++++++++++++|4<----+             |+++++++++++++++++|4<---+
  15265.           |   * Program *   |                    |   * Program *   |
  15266.  
  15267. If adjacent memory is found, the free space pointer is removed from the
  15268. FreePtr chain and Turbo Pascal's heap manager takes the most recent
  15269. entry and moves it to fill the now empty position. The size and the
  15270. original pointer (A) is adjusted to reflect a new pointer position and
  15271. size.
  15272.  
  15273.            Top of DOS Memory                      Top of DOS Memory
  15274.           +-----------------+                    +-----------------+
  15275.           |-----------------|1--+                |-----------------|1--+
  15276.           |-----------------|4--|-+              |-----------------|4--|-+
  15277. FreePtr-> |-----------------|5--|-|+             |-----------------|5--|-|+
  15278.           |        *        |   | ||   FreePtr-> |-----------------|A--|+||
  15279.           |                 |   | ||             |                 |   ||||
  15280.           |                 |   | ||             |                 |   ||||
  15281.           |                 |   | ||             |                 |   ||||
  15282.           |                 |   | ||             |                 |   ||||
  15283.           |                 |   | ||             |                 |   ||||
  15284.           |        *        |   | ||             |        *        |   ||||
  15285. HeapPtr-> |-----------------|   | ||   HeapPtr-> |-----------------|   ||||
  15286.           |-----------------|   | ||             |+++++++++++++++++|   ||||
  15287.           |                 |   | ||             |||||||||||||||||||   ||||
  15288.           |                 |   | ||             |||||||||||||||||||   ||||
  15289.     (A)>>>|-----------------|   | ||             |+++++++++++++++++|A<-|+||
  15290.           |+++++++++++++++++|   | ||             |+++++++++++++++++|   | ||
  15291.           |+++++++++++++++++|5<-|-|+             |+++++++++++++++++|5<-|-|+
  15292.           |+++++++++++++++++|   | |              |+++++++++++++++++|   | |
  15293.           |+++++++++++++++++|1<-+ |              |+++++++++++++++++|1<-+ |
  15294.           |+++++++++++++++++|     |              |+++++++++++++++++|     |
  15295.           |+++++++++++++++++|4<---+              |+++++++++++++++++|4<---+
  15296.           |   * Program *   |                    |   * Program *   |
  15297.  
  15298. When all possible adjacent blocks have been removed, the Turbo Pascal heap
  15299. manager checks if the end of memory block is equal to the HeapPtr. If not,
  15300. a free space entry is added to the bottom of FreePtr.
  15301.  
  15302. FREEMEM(B)
  15303.  
  15304.  Programmer's Reference Guide       - 251 -         TEGL Windows Toolkit
  15305.  
  15306.  
  15307.  
  15308.  
  15309.  
  15310.                               APPENDICES
  15311.  
  15312.  
  15313.            Top of DOS Memory                      Top of DOS Memory
  15314.           +-----------------+                    +-----------------+
  15315.           |-----------------|1--+                |-----------------|1--+
  15316.           |-----------------|4--|-+              |-----------------|4--|-+
  15317.           |-----------------|5--|-|+   FreePtr-> |-----------------|5--|-|+
  15318. FreePtr-> |--------x--------|A--|+||             |        *        |   | ||
  15319.           |        *        |   ||||             |                 |   | ||
  15320.           |                 |   ||||             |                 |   | ||
  15321.           |                 |   ||||             |                 |   | ||
  15322.           |                 |   ||||             |                 |   | ||
  15323.           |                 |   ||||             |                 |   | ||
  15324.           |        *        |   ||||             |                 |   | ||
  15325. HeapPtr-> |-----------------|   ||||             |                 |   | ||
  15326.     (B)>>>|-----------------|   ||||             |                 |   | ||
  15327.           |                 |   ||||             |                 |   | ||
  15328.           |                 |   ||||             |        *        |   | ||
  15329.           |-----------------|A<-|+||   HeapPtr-> |-----------------|   | ||
  15330.           |+++++++++++++++++|   | ||             |+++++++++++++++++|   | ||
  15331.           |+++++++++++++++++|5<-|-|+             |+++++++++++++++++|5<-|-|+
  15332.           |+++++++++++++++++|   | |              |+++++++++++++++++|   | |
  15333.           |+++++++++++++++++|1<-+ |              |+++++++++++++++++|1<-+ |
  15334.           |+++++++++++++++++|     |              |+++++++++++++++++|     |
  15335.           |+++++++++++++++++|4<---+              |+++++++++++++++++|4<---+
  15336.           |   * Program *   |                    |   * Program *   |
  15337.  
  15338. As you may note that the free space pointer chain is almost on a first in
  15339. first out basis. The most recent freed block is used first. Thus heap
  15340. activities is dependant on localize freeing of memory. A more effecient
  15341. method is sorting the free space entries, so that attempts to allocate
  15342. space will always be towards the lower part of the heap memory. However
  15343. this is not the most effective method. If a single non-movable record is
  15344. allocated in the middle of the heap, this will fragment the heap into two
  15345. parts.
  15346.  
  15347.  
  15348. TEGL Heap Manager
  15349.  
  15350. The TEGL Heap Manager is slightly different in its management methods.
  15351. Allocation of memory is always attempted between HeapPtr and 
  15352. FreePtr before searching for free space within the FreePtr chain.
  15353.  
  15354. GETMEM(20k)
  15355.  
  15356.            Before                   Getmem                    TEGLGetMem
  15357.           +-------+                 +-------+                 +-------+
  15358.           |-------|1--+             |-------|1--+             |-------|1--+
  15359. FreePtr-> |-------|2--|+  FreePtr-> |-------|2--|+  FreePtr-> |-------|2--|+
  15360.           |   *   |   ||            |   *   |   ||            |  40k  |   ||
  15361.           |  60k  |   ||            |  60k  |   ||            |-------|   ||
  15362.           |   *   |   ||            |   *   |   ||            |///////|   ||
  15363. HeapPtr-> |-------|   ||  HeapPtr-> |-------|   ||  HeapPtr-> |-------|   ||
  15364.  
  15365.  Programmer's Reference Guide       - 252 -         TEGL Windows Toolkit
  15366.  
  15367.  
  15368.  
  15369.  
  15370.  
  15371.                               APPENDICES
  15372.  
  15373.           |-------|   ||            |-------|   ||            |-------|   ||
  15374.           |       |   ||            |   *   |   ||            |       |   ||
  15375.           |   *   |   ||            |  50k  |   ||            |   *   |   ||
  15376.           |  70k  |   ||            |-------|2<-|+            |  70k  |   ||
  15377.           |   *   |   ||            |///////|   |             |   *   |   ||
  15378.           |-------|2<-|+            |-------|   |             |-------|2<-|+
  15379.           |-------|   |             |-------|   |             |-------|   |
  15380.           |       |   |             |       |   |             |       |   |
  15381.           |       |   |             |       |   |             |       |   |
  15382.           |   *   |   |             |   *   |   |             |   *   |   |
  15383.           | 102k  |   |             | 102k  |   |             | 102k  |   |
  15384.           |   *   |   |             |   *   |   |             |   *   |   |
  15385.           |       |   |             |       |   |             |       |   |
  15386.           |-------|1<-+             |-------|1<-+             |-------|1<-+
  15387.           |Program|                 |Program|                 |Program|
  15388.  
  15389. When memory is released (freed), the TEGL Pascal Heap Manager is similar
  15390. to Turbo Pascal Heap Manager in that adjacent memory block are combined by
  15391. scanning through the Freeptr chain. However the difference that is
  15392. noticeble immediately, is the sorted order of the free space pointers in
  15393. comparison to the FIFO structure of TP's.
  15394.  
  15395. FREEMEM(A)
  15396.  
  15397.            Top of DOS Memory                      Top of DOS Memory
  15398.           +-----------------+                    +-----------------+
  15399.           |-----------------|1--+                |-----------------|1--+
  15400.           |--------x--------|2--|+               |-----------------|3--|-+
  15401.           |-----------------|3--||+              |-----------------|4--|-|+
  15402.           |-----------------|4--|||+   FreePtr-> |-----------------|5--|-||+
  15403. FreePtr-> |-----------------|5--||||+            |        *        |   | |||
  15404.           |        *        |   |||||            |                 |   | |||
  15405.           |                 |   |||||            |                 |   | |||
  15406.           |                 |   |||||            |                 |   | |||
  15407.           |                 |   |||||            |                 |   | |||
  15408.           |        *        |   |||||            |        *        |   | |||
  15409. HeapPtr-> |-----------------|   |||||  HeapPtr-> |-----------------|   | |||
  15410.           |+++++++++++++++++|   |||||            |+++++++++++++++++|   | |||
  15411.           |+++++++++++++++++|1<-+||||            |+++++++++++++++++|1<-+ |||
  15412.     (A)>>>|+++++++++++++++++|    ||||            |                 |     |||
  15413.           |+++++++++++++++++|2<--+|||      (A)>>>|-----------------|     |||
  15414.           |+++++++++++++++++|     |||            |+++++++++++++++++|     |||
  15415.           |+++++++++++++++++|3<---+||            |+++++++++++++++++|3<---+||
  15416.           |+++++++++++++++++|      ||            |+++++++++++++++++|      ||
  15417.           |+++++++++++++++++|4<----+|            |+++++++++++++++++|4<----+|
  15418.           |+++++++++++++++++|       |            |+++++++++++++++++|       |
  15419.           |+++++++++++++++++|5<-----+            |+++++++++++++++++|5<-----+
  15420.           |   * Program *   |                    |   * Program *   |
  15421.  
  15422. If adjacent memory is found, the free space pointer is removed from the
  15423. FreePtr chain and TEGL's heap manager moves the free chain structure
  15424. up by one entry to close the empty position. The size and the original
  15425.  
  15426.  Programmer's Reference Guide       - 253 -         TEGL Windows Toolkit
  15427.  
  15428.  
  15429.  
  15430.  
  15431.  
  15432.                               APPENDICES
  15433.  
  15434. pointer (A) is adjusted to reflect a new pointer position and size.
  15435.  
  15436.            Top of DOS Memory                      Top of DOS Memory
  15437.           +-----------------+                    +-----------------+
  15438.           |-----------------|3----+              |-----------------|A--+
  15439.           |-----------------|4----|+             |-----------------|3--|-+
  15440. FreePtr-> |-----------------|5----||+            |-----------------|4--|-|+
  15441.           |        *        |     |||  FreePtr-> |-----------------|5--|-||+
  15442.           |                 |     |||            |                 |   | |||
  15443.           |                 |     |||            |                 |   | |||
  15444.           |                 |     |||            |                 |   | |||
  15445.           |                 |     |||            |                 |   | |||
  15446.           |                 |     |||            |                 |   | |||
  15447.           |        *        |     |||            |        *        |   | |||
  15448. HeapPtr-> |-----------------|     |||  HeapPtr-> |-----------------|   | |||
  15449.           |-----------------|     |||            |+++++++++++++++++|   | |||
  15450.           |                 |     |||            |||||||||||||||||||   | |||
  15451.           |                 |     |||            |||||||||||||||||||   | |||
  15452.     (A)>>>|-----------------|     |||            |+++++++++++++++++|A<-+ |||
  15453.           |+++++++++++++++++|     |||            |+++++++++++++++++|     |||
  15454.           |+++++++++++++++++|3<---+||            |+++++++++++++++++|3<---+||
  15455.           |+++++++++++++++++|      ||            |+++++++++++++++++|      ||
  15456.           |+++++++++++++++++|4<----+|            |+++++++++++++++++|4<----+|
  15457.           |+++++++++++++++++|       |            |+++++++++++++++++|       |
  15458.           |+++++++++++++++++|5<-----+            |+++++++++++++++++|5<-----+
  15459.           |   * Program *   |                    |   * Program *   |
  15460.  
  15461. When all possible adjacent blocks have been removed, the TEGL heap manager
  15462. checks if the end of memory block is equal to the HeapPtr. If not, a free
  15463. space entry is added to the bottom of FreePtr.
  15464.  
  15465. FREEMEM(B)
  15466.  
  15467.            Top of DOS Memory                      Top of DOS Memory
  15468.           +-----------------+                    +-----------------+
  15469.           |-----------------|A--+                |-----------------|3----+
  15470.           |-----------------|3--|-+              |-----------------|4----|+
  15471.           |-----------------|4--|-|+   FreePtr-> |-----------------|5----||+
  15472. FreePtr-> |--------x--------|5--|-||+            |        *        |     |||
  15473.           |        *        |   | |||            |                 |     |||
  15474.           |                 |   | |||            |                 |     |||
  15475.           |                 |   | |||            |                 |     |||
  15476.           |                 |   | |||            |                 |     |||
  15477.           |                 |   | |||            |                 |     |||
  15478.           |        *        |   | |||            |                 |     |||
  15479. HeapPtr-> |-----------------|   | |||            |                 |     |||
  15480.     (B)>>>|-----------------|   | |||            |                 |     |||
  15481.           |                 |   | |||            |                 |     |||
  15482.           |                 |   | |||            |        *        |     |||
  15483.           |-----------------|A<-+ |||  HeapPtr-> |-----------------|     |||
  15484.           |+++++++++++++++++|     |||            |+++++++++++++++++|     |||
  15485.           |+++++++++++++++++|3<---+||            |+++++++++++++++++|3<---+||
  15486.  
  15487.  Programmer's Reference Guide       - 254 -         TEGL Windows Toolkit
  15488.  
  15489.  
  15490.  
  15491.  
  15492.  
  15493.                               APPENDICES
  15494.  
  15495.           |+++++++++++++++++|      ||            |+++++++++++++++++|      ||
  15496.           |+++++++++++++++++|4<----+|            |+++++++++++++++++|4<----+|
  15497.           |+++++++++++++++++|       |            |+++++++++++++++++|       |
  15498.           |+++++++++++++++++|5<-----+            |+++++++++++++++++|5<-----+
  15499.           |   * Program *   |                    |   * Program *   |
  15500.  
  15501. TEGL uses the more efficient method of maintaining the free space chain in
  15502. sorted out. This allows allocation of memory to favor the lower portion of
  15503. the heap. However, as mentioned before, this does not remove the
  15504. fragmentation problem where one non-movable records is allocated in the
  15505. middle of the heap.
  15506.  
  15507.  
  15508. Combining the best of both Heap Managers (Coexisting)
  15509.  
  15510. What we noted that we needed was the ability to have two heaps. One for
  15511. miscellaneous dyanamic variables and one for large allocations for images.
  15512. Combined with the virtual memory handler, this allows the paging out the
  15513. large allocations effectively releasing adjacent memory. At the same time
  15514. we did not want to limit either heap. The turbo heap must have the ability
  15515. to flow over to the second heap without problems.
  15516.  
  15517. ReserveHugeMinimum provides an elegant solution of partitioning the
  15518. standard heap into two parts. A single non-movable byte is allocated as a
  15519. partitioner.
  15520.  
  15521.                                     GetMem                  TEGLGetMem
  15522.           +-------+                +-------+                +-------+
  15523. FreePtr-> |-------|1--+  FreePtr-> |-------|1--+  FreePtr-> |-------|1--+
  15524.           |       |   |            |       |   |            |       |   |
  15525.           |       |   |            |       |   |            |       |   |
  15526.           |       |   |            |       |   |            |       |   |
  15527.           |       |   |            |       |   |            |       |   |
  15528.           |  329k |   |            |  329k |   |            |  200k |   |
  15529.           |       |   |            |       |   |            |       |   |
  15530.           |       |   |            |       |   |  HeapPtr-> |-------|   |
  15531.           |       |   |            |       |   |            |///////|   |
  15532.           |       |   |            |       |   |            |///////|   |
  15533.           |HugeMin|   |            |HugeMin|   |            |///////|   |
  15534. HeapPtr-> |-------|   |  HeapPtr-> |-------|   |            |-------|   |
  15535.           |       |   |            |       |   |            |       |   |
  15536.           |       |   |            |       |   |            |       |   |
  15537.           |  12k  |   |            |  11k  |   |            |  11k  |   |
  15538.           |       |   |            |       |   |            |       |   |
  15539.           |       |   |            |       |   |            |       |   |
  15540.           |       |   |            |-------|1<-+            |-------|1<-+
  15541.           |       |   |            |///////|                |///////|
  15542.           |-------|1<-+            |-------|                |-------|
  15543.           |Program|                |Program|                |Program|
  15544.  
  15545. Since Turbo Heap Manager will always search for free space through the 
  15546. FreePtr Chain, the lower partitioned area will always be used first (it
  15547.  
  15548.  Programmer's Reference Guide       - 255 -         TEGL Windows Toolkit
  15549.  
  15550.  
  15551.  
  15552.  
  15553.  
  15554.                               APPENDICES
  15555.  
  15556. is always the first few entries in the FreePtr chain). (Remember,
  15557. when Turbo Pascal frees a memory block, the free space pointer will be the
  15558. most recent entry.)
  15559.  
  15560. The TEGL heap manager will always attempt to allocate space between 
  15561. HeapPtr and FreePtr before searching through the free space pointer
  15562. chain. Even when searching through the free space chain, a comparison is
  15563. made on the minimum area for allocating. When TEGL frees a memory block,
  15564. the free space pointer is sorted upwards into the free space chain.
  15565.  
  15566.            Top of DOS Memory
  15567.           +-----------------+
  15568.       +--A|-----------------|
  15569.      +|--B|-----------------|
  15570.     +||--C|-----------------|
  15571.    +|||--D|-----------------|
  15572.   +||||--E|-----------------|
  15573.   |||||   |-----------------|4--+
  15574.   |||||   |-----------------|1--|+
  15575.   |||||   |-----------------|3--||+
  15576.   |||||   |-----------------|2--|||+
  15577.   |||||   |-----------------|5--||||+
  15578.   |||||   |                 |   |||||
  15579.   ||||+->A|+++++++++++++++++|   |||||
  15580.   |||+-->B|+++++++++++++++++|   |||||
  15581.   ||+--->C|+++++++++++++++++|   |||||
  15582.   |+---->D|+++++++++++++++++|   |||||
  15583.   +----->E|+++++++++++++++++|   |||||
  15584.           |    Hugemin      |   |||||
  15585.           |-----------------|   |||||
  15586.           |+++++++++++++++++|2<-|+|||
  15587.           |+++++++++++++++++|3<-|-+||
  15588.           |+++++++++++++++++|5<-|--|+
  15589.           |+++++++++++++++++|4<-+  |
  15590.           |+++++++++++++++++|2<----+
  15591.           |   * Program *   |
  15592.  
  15593.  
  15594.  
  15595.  
  15596.  
  15597.  
  15598.  
  15599.  
  15600.  
  15601.  
  15602.  
  15603.  
  15604.  
  15605.  
  15606.  
  15607.  
  15608.  
  15609.  Programmer's Reference Guide       - 256 -         TEGL Windows Toolkit
  15610.  
  15611.  
  15612.  
  15613.  
  15614.  
  15615.                          Variables, Types and Const
  15616.  
  15617.  
  15618. Appendix C - Vars, Types & Const
  15619. ___________________________________________________________________________
  15620.  
  15621.  
  15622. ___________________________________________________________________________
  15623.  
  15624. ActivePage Word Typed Const                                        FASTGRPH
  15625. ___________________________________________________________________________
  15626.  
  15627. Set to the memory address (segment) of the active video page.
  15628.  
  15629. See also FlipAPage, FlipVPage, SetAPage, SetVPage.
  15630.  
  15631.  
  15632. ___________________________________________________________________________
  15633.  
  15634. CallProc Procedure Type                                            TEGLUNIT
  15635. ___________________________________________________________________________
  15636.  
  15637. This is the standard declaration for and event. All procedures and
  15638. functions that set events specify this in their parameter list.
  15639.  
  15640. See also (it NilUnitProc.
  15641.  
  15642.  
  15643. ___________________________________________________________________________
  15644.  
  15645. FG* Const                                                          FASTGRPH
  15646. ___________________________________________________________________________
  15647.  
  15648. These constants are used as an arguments to PutBiti and can be assigned
  15649. to RmwBits. Determines what kind of binary operation to use. They are:
  15650. FGNorm - Normal or Copy put, FGAnd - AND put, FGOr - OR put,
  15651. FBXor - XOR put, FGNot - not put.
  15652.  
  15653.  
  15654. See also FastLine.
  15655.  
  15656.  
  15657.  
  15658. ___________________________________________________________________________
  15659.  
  15660. Jagged Word Typed Const                                            FASTGRPH
  15661. ___________________________________________________________________________
  15662.  
  15663. This const affects all output by OutTEGLTextXY and TEGLWrtChar. When
  15664. set to 0 no action is taken, when set to 1, text is output with alternate
  15665. rows of pixels shifted by one.
  15666.  
  15667.  
  15668.  
  15669.  
  15670.  Programmer's Reference Guide       - 257 -         TEGL Windows Toolkit
  15671.  
  15672.  
  15673.  
  15674.  
  15675.  
  15676.                          Variables, Types and Const
  15677.  
  15678. ___________________________________________________________________________
  15679.  
  15680. MSClick Boolean Const                                              TEGLUNIT
  15681. ___________________________________________________________________________
  15682.  
  15683. Set to False. Used as an argument to mouse related procedures where mouse
  15684. activation is desired by location over the mouse click area and pressing
  15685. the left button.
  15686.  
  15687. See also DefineMouseClickArea, ResetMSClickSense.
  15688.  
  15689.  
  15690. ___________________________________________________________________________
  15691.  
  15692. MSSense Boolean Const                                              TEGLUNIT
  15693. ___________________________________________________________________________
  15694.  
  15695. Set to True. Used as an argument to mouse related procedures where mouse
  15696. activation is desired by simply passing over a mouse click area.
  15697.  
  15698. See also DefineMouseClickArea, ResetMSClickSense.
  15699.  
  15700.  
  15701. ___________________________________________________________________________
  15702.  
  15703. RmwBits Word Typed Const                                           FASTGRPH
  15704. ___________________________________________________________________________
  15705.  
  15706. Set to the desired binary operation for subsequent PutPixs.
  15707.  
  15708. See also FG*.
  15709.  
  15710.  
  15711.  
  15712. The file switches.inc contains conditions compilation directives that
  15713. support different facilities with the Toolkit.
  15714.  
  15715. Note that if you change any defines you will have to make the entire
  15716. toolkit.
  15717.  
  15718. The following defines affect the Toolkit:
  15719.  
  15720. {$DEFINE AllFonts} - The toolkit is built referencing the unit {it TeglFont}
  15721. for getting the address of a font. If this symbol is not defined then the
  15722. fonts are referenced in seperate units. Having the fonts in individual units
  15723. has the advantage of saving some memory space during linking (assuming they
  15724. are not all used). If you are using the integrated environment then commonly
  15725. used fonts can be loaded directly into turbo.tpl for faster compiles.
  15726. Font units file names are of the form fon*.pas.
  15727.  
  15728. {$DEFINE NoGr} - The toolkit is built with no explicit references to the
  15729. Graph unit provided with Turbo Pascal. Instead a compatible unit 
  15730.  
  15731.  Programmer's Reference Guide       - 258 -         TEGL Windows Toolkit
  15732.  
  15733.  
  15734.  
  15735.  
  15736.  
  15737.                            Conditional Compilation
  15738.  
  15739. TGraph is uses which provides a subset of the functions provided in 
  15740. Graph. If your application does not need all the features of the Graph
  15741. unit then compiling with this directive enabled can save as much as 25K of
  15742. code size in a program (assuming the BGI drivers are linked in).
  15743.  
  15744. {$DEFINE NoVirt} - The code that implements virtual memory using either
  15745. EMS or a disk drive is not included. Applications save about 8K of code
  15746. space but can easily run out of memory if many windows are opened. This
  15747. is more critical for EGA or VGA displays since the windows require four
  15748. times as much memory than CGA or Hurcules displays.
  15749.  
  15750. {$DEFINE Quick} - The tookit will be built using the {it MSGraph} unit
  15751. provided with Quick Pascal. TGraph is used to map calls to the
  15752. appropriate routines in MSGraph.
  15753.  
  15754. These defines determine what graphics boards will be supported. The
  15755. assembly language code that implements the drivers for each board takes
  15756. about 3K of space in the final application. You cannot define all of these.
  15757.  
  15758. {$DEFINE NoCGA} - The code for the color graphics adaptor is not linked.
  15759.  
  15760. {$DEFINE NoEVGA} - The code for the enhanced graphics adaptor and the
  15761. video graphics array is not linked in.
  15762.  
  15763. {$DEFINE NoHerc} - The code for the hercules graphics adaptor is not
  15764. linked in.
  15765.  
  15766.  
  15767.  
  15768.  
  15769.  
  15770.  
  15771.  
  15772.  
  15773.  
  15774.  
  15775.  
  15776.  
  15777.  
  15778.  
  15779.  
  15780.  
  15781.  
  15782.  
  15783.  
  15784.  
  15785.  
  15786.  
  15787.  
  15788.  
  15789.  
  15790.  
  15791.  
  15792.  Programmer's Reference Guide       - 259 -         TEGL Windows Toolkit
  15793.  
  15794.  
  15795.  
  15796.  
  15797.  
  15798.  
  15799.  
  15800.  
  15801.  
  15802.  
  15803.  
  15804.  
  15805.  
  15806.  
  15807.  
  15808.  
  15809.  
  15810.  
  15811.  
  15812.  
  15813.  
  15814.  
  15815.  
  15816.  
  15817.  
  15818.  
  15819.  
  15820.  
  15821.  
  15822.  
  15823.  
  15824.  
  15825.  
  15826.  
  15827.  
  15828.  
  15829.  
  15830.  
  15831.  
  15832.  
  15833.  
  15834.  
  15835.  
  15836.  
  15837.  
  15838.  
  15839.  
  15840.  
  15841.  
  15842.  
  15843.  
  15844.  
  15845.  
  15846.  
  15847.  
  15848.  
  15849.  
  15850.  
  15851.  
  15852.  
  15853.  Programmer's Reference Guide       - 260 -         TEGL Windows Toolkit
  15854.  
  15855.  
  15856.  
  15857.  
  15858.  
  15859.                                 INDEX
  15860.  
  15861.  Abort Procedure............................................140
  15862.  ActiveButton Procedure..................................... 29
  15863.  ActivePage Word Typed Const................................257
  15864.  AddCaptureKey Procedure....................................122
  15865.  AddFrame Procedure Method..................................178
  15866.  AllocateExpandedMemoryPages function.......................200
  15867.  Animate Procedure Method...................................180
  15868.  AnimateInit Procedure Method...............................179
  15869.  AskSoundSense Event........................................192
  15870.  Bar Procedure..............................................232
  15871.  Bar menu................................................... 87
  15872.  Beep Procedure.............................................193
  15873.  BigImageSize Function......................................134
  15874.  CGA640x200x2 Procedure.....................................128
  15875.  CallProc Procedure Type....................................257
  15876.  CheckCtrlBreak Procedure...................................228
  15877.  CheckCtrlBreakFS Procedure.................................228
  15878.  CheckForMouseSelect Function...............................165
  15879.  CheckMouseClickPos Function................................164
  15880.  ClearButtonInfo Procedure..................................113
  15881.  ClearKeyBoardBuf Procedure................................. 83
  15882.  ClearTEGLKeyBoardBuf Procedure............................. 83
  15883.  ClearTEGLScreen Procedure..................................142
  15884.  Click and drag............................................. 23
  15885.  CloseGraph Procedure.......................................232
  15886.  CloseVirtual procedure.....................................219
  15887.  ColToX Function............................................ 30
  15888.  CollapseToIconShow Event...................................156
  15889.  CollapseToMsClick Event....................................156
  15890.  CommitUpdate Procedure..................................... 54
  15891.  Complete Procedure Method..................................180
  15892.  CountFrames Function....................................... 45
  15893.  CreateBarMenu Procedure.................................... 98
  15894.  CreateImageBuffer Procedure................................ 63
  15895.  CreateOptionMenu Function.................................. 89
  15896.  CreateShadowOM Function.................................... 91
  15897.  CurrentFrameNumber Function Method.........................179
  15898.  CursorShape Procedure......................................109
  15899.  DeallocateExpandedMemoryPages function.....................202
  15900.  DefineButtonClick Procedure................................154
  15901.  DefineGlobalKeyClickArea Procedure......................... 83
  15902.  DefineLocalKeyClickArea Procedure.......................... 84
  15903.  DefineLongButtonClick Procedure............................154
  15904.  DefineMouseClickArea Procedure............................. 73
  15905.  DefineMouseClickArea.......................................258
  15906.  DefineOptionClickArea Procedure............................102
  15907.  DefineOptions Procedure.................................... 90
  15908.  DefineResizeClickArea Procedure............................223
  15909.  DefineResizeMinMax Procedure...............................224
  15910.  DefineSliderArea Procedure.................................224
  15911.  DefineUserButtonClick Procedure............................155
  15912.  DeleteCaptureKey Procedure.................................123
  15913.  
  15914.  Programmer's Reference Guide       - 261 -         TEGL Windows Toolkit
  15915.  
  15916.  
  15917.  
  15918.  
  15919.  
  15920.                                 INDEX
  15921.  
  15922.  Destination Function Method................................175
  15923.  DetectGraph Procedure......................................233
  15924.  DrawLongButton Procedure...................................160
  15925.  DropImageBuffer Procedure.................................. 64
  15926.  DropKeyClick Procedure..................................... 85
  15927.  DropSliders Procedure......................................225
  15928.  DropStackImage Procedure................................... 49
  15929.  DropTimerCount Procedure...................................120
  15930.  DropTimerTick Procedure....................................229
  15931.  EGA........................................................135
  15932.  EGA640x350x16 Procedure....................................128
  15933.  EMSBlockRead procedure.....................................209
  15934.  EMSBlockWrite procedure....................................209
  15935.  EMSClose procedure.........................................210
  15936.  EMSOpen function...........................................207
  15937.  EMSPagesAvailable function.................................200
  15938.  EMSSeek procedure..........................................208
  15939.  EasyTEGL Procedure......................................... 33
  15940.  EditString Procedure.......................................191
  15941.  EmmInstalled function......................................199
  15942.  ErrMess Procedure.......................................... 30
  15943.  Event driven code.......................................... 22
  15944.  Exec.......................................................105
  15945.  Expand and shrink.......................................... 23
  15946.  ExplodeFromIconHide........................................157
  15947.  ExplodeFromMsClick Procedure...............................157
  15948.  ExtendTextXY Procedure.....................................153
  15949.  ExtractIMG Procedure.......................................137
  15950.  Extractpixs Function.......................................137
  15951.  FG* Const..................................................257
  15952.  FGAnd...................................................... 66
  15953.  FGAnd......................................................257
  15954.  FGNorm.....................................................257
  15955.  FGNorn..................................................... 66
  15956.  FGNot...................................................... 66
  15957.  FGNot......................................................257
  15958.  FGOr....................................................... 66
  15959.  FGOr.......................................................257
  15960.  FGXor...................................................... 66
  15961.  FGXor......................................................257
  15962.  FastLine Procedure.........................................131
  15963.  FindFrame Function.........................................162
  15964.  FindKeyClickPtr Function................................... 85
  15965.  FindMouseClickPtr Function................................. 75
  15966.  FindSliderFS Function......................................225
  15967.  FitFrame Procedure......................................... 31
  15968.  FlipAPage Procedure........................................135
  15969.  FlipVPage Procedure........................................136
  15970.  FontName Function..........................................187
  15971.  FontTable..................................................187
  15972.  FrameExist Function........................................ 45
  15973.  FrameFromIcon Procedure.................................... 31
  15974.  
  15975.  Programmer's Reference Guide       - 262 -         TEGL Windows Toolkit
  15976.  
  15977.  
  15978.  
  15979.  
  15980.  
  15981.                                 INDEX
  15982.  
  15983.  FrameSelectAndMove Function................................ 55
  15984.  FrameText Procedure........................................ 32
  15985.  FreeImageBuffer Procedure.................................. 67
  15986.  FreeVirtual procedure......................................218
  15987.  FreezeMouse function.......................................114
  15988.  FrozenMouse Procedure......................................114
  15989.  GetBkColor Function........................................233
  15990.  GetButtonPressInfo Procedure...............................112
  15991.  GetButtonReleaseInfo Procedure.............................112
  15992.  GetColor Function..........................................233
  15993.  GetFSImage Function........................................ 65
  15994.  GetFillPattern Procedure...................................234
  15995.  GetFrontImage Function..................................... 68
  15996.  GetGraphMode Function......................................234
  15997.  GetHandleCountUsed function................................203
  15998.  GetKBSteps Procedure.......................................118
  15999.  GetMaxX Function...........................................235
  16000.  GetMaxY Function...........................................235
  16001.  GetMouseSensitivity Procedure..............................116
  16002.  GetMousey Function......................................... 32
  16003.  GetOrigin Procedure Method.................................175
  16004.  GetPageFrameBaseAddress function...........................201
  16005.  GetPagesOwnedByHandle function.............................203
  16006.  GetPartialFrontImage Function.............................. 67
  16007.  GetTextSettings Procedure..................................235
  16008.  GetVersionNumber function..................................202
  16009.  GetYesNo Function.......................................... 33
  16010.  Getbiti Procedure..........................................133
  16011.  Getpixs Function...........................................132
  16012.  GraphResult Function.......................................236
  16013.  Herc720x200x2 Procedure....................................128
  16014.  HideImage Procedure........................................ 50
  16015.  HideMouse Procedure........................................108
  16016.  ImageSize Function \ TGraph................................236
  16017.  InitGraph Procedure........................................236
  16018.  Jagged Word Typed Const....................................257
  16019.  Jagged..................................................... 90
  16020.  KeyStackPtr................................................ 85
  16021.  Keyboard events............................................ 24
  16022.  LastCol Function........................................... 34
  16023.  LastRow Function........................................... 34
  16024.  Line Procedure.............................................237
  16025.  LinkFS Procedure........................................... 61
  16026.  LinkUnderFS Procedure...................................... 62
  16027.  LockImage Procedure........................................ 69
  16028.  MCursorOff Procedure.......................................106
  16029.  MCursorOn Procedure........................................107
  16030.  MSClick Boolean Const......................................258
  16031.  MSSense Boolean Const......................................258
  16032.  MSSense.................................................... 23
  16033.  MSetPos Procedure..........................................107
  16034.  MapExpandedMemoryPages function............................201
  16035.  
  16036.  Programmer's Reference Guide       - 263 -         TEGL Windows Toolkit
  16037.  
  16038.  
  16039.  
  16040.  
  16041.  
  16042.                                 INDEX
  16043.  
  16044.  Mickey.....................................................116
  16045.  MousePosition function.....................................111
  16046.  MoveBox Procedure..........................................158
  16047.  MoveFrame Procedure........................................ 60
  16048.  MoveFromVirtual procedure..................................217
  16049.  MoveStackImage Procedure................................... 59
  16050.  MoveToVirtual function.....................................218
  16051.  MsClick.................................................... 23
  16052.  MsSense.................................................... 73
  16053.  MxClick.................................................... 73
  16054.  NilKeyCallProc Function....................................124
  16055.  NilUnitProc Event..........................................229
  16056.  OE......................................................... 89
  16057.  OM......................................................... 88
  16058.  Option entry............................................... 89
  16059.  Option menu................................................ 88
  16060.  Origin Procedure Method....................................174
  16061.  OutBarOption Procedure..................................... 98
  16062.  OutFrameTextXY Procedure................................... 34
  16063.  OutTEGLTextXY Procedure....................................184
  16064.  OutTEGLTextXY..............................................187
  16065.  OutTEGLTextXY..............................................257
  16066.  OutTextXY Procedure........................................237
  16067.  OverLapArea Function.......................................230
  16068.  OverlayIMG Procedure.......................................138
  16069.  PageInFS Procedure......................................... 68
  16070.  PageOutFS Procedure........................................ 70
  16071.  PageOutImageStack Function................................. 71
  16072.  PictSize Procedure.........................................140
  16073.  PopImage Procedure......................................... 47
  16074.  PrepareForPartialUpdate Procedure.......................... 52
  16075.  PrepareForUpdate Function.................................. 53
  16076.  PressButton Procedure......................................167
  16077.  Proportional...............................................186
  16078.  PushImage Procedure........................................ 46
  16079.  PutFSImage Procedure....................................... 66
  16080.  PutUserButtonClick Procedure...............................155
  16081.  Putbiti Procedure..........................................133
  16082.  Putpict Procedure.......................................... 41
  16083.  Putpict Procedure..........................................139
  16084.  Putpixs Procedure..........................................132
  16085.  QuickFrame Procedure....................................... 35
  16086.  Quit Event................................................. 35
  16087.  ReadKey.................................................... 84
  16088.  Rectangle Procedure........................................238
  16089.  ReplaceOptionText Procedure................................ 94
  16090.  ReserveHugeMinimum procedure...............................221
  16091.  ResetFrame Procedure Method................................176
  16092.  ResetKeyClickCallProc Procedure............................ 85
  16093.  ResetMSClickActive Procedure............................... 77
  16094.  ResetMSClickCallProc Procedure............................. 79
  16095.  ResetMSClickSense Procedure................................ 81
  16096.  
  16097.  Programmer's Reference Guide       - 264 -         TEGL Windows Toolkit
  16098.  
  16099.  
  16100.  
  16101.  
  16102.  
  16103.                                 INDEX
  16104.  
  16105.  ResetMSClickSense..........................................258
  16106.  ResetMouseClicks Procedure................................. 80
  16107.  ResetOptionMenuEvents Procedure............................103
  16108.  ResetSequence Procedure Method.............................177
  16109.  ResetTimerFlag Procedure...................................120
  16110.  ResizeFrame Procedure......................................226
  16111.  ResizeOptionMenu Procedure................................. 92
  16112.  RestoreCrtMode Procedure \ TGraph..........................238
  16113.  RestoreFont Procedure...................................... 36
  16114.  RmwBits Word Typed Const...................................258
  16115.  RotateStackImage Procedure................................. 47
  16116.  RotateUnderStackImage Procedure............................ 48
  16117.  RowToY Function............................................ 36
  16118.  SVGA800x600x16.............................................129
  16119.  SelectAndMoveFrame Event...................................226
  16120.  SelectEasyFont Procedure................................... 37
  16121.  SelectaFile function.......................................189
  16122.  Sequence Procedure Method..................................177
  16123.  SetAPage Procedure.........................................134
  16124.  SetAutoRotate Procedure.................................... 56
  16125.  SetBarBorderColor Procedure................................100
  16126.  SetBarBorderOff Procedure..................................100
  16127.  SetBarFillStyle Procedure..................................101
  16128.  SetBarMenuColor Procedure.................................. 99
  16129.  SetBarMenuMargin Procedure.................................102
  16130.  SetBarShadowtext Procedure.................................101
  16131.  SetBarTextColor Procedure.................................. 99
  16132.  SetBkColor Procedure.......................................238
  16133.  SetColor Procedure.........................................239
  16134.  SetEasyFont Procedure...................................... 37
  16135.  SetFillPattern Procedure...................................239
  16136.  SetFillStyle Procedure.....................................239
  16137.  SetFrameMobility Procedure................................. 57
  16138.  SetHideSubMenu Procedure................................... 97
  16139.  SetImageCoordinates Procedure.............................. 70
  16140.  SetKBSteps Procedure.......................................117
  16141.  SetKeyBoardMouse Procedure.................................117
  16142.  SetMouseColor Procedure....................................111
  16143.  SetMouseHotSpot Procedure..................................110
  16144.  SetMouseMinMax Procedure...................................113
  16145.  SetMousePosition Procedure.................................108
  16146.  SetMouseSense Procedure....................................192
  16147.  SetMouseSensitivity Procedure..............................116
  16148.  SetMoveFrameCallProc Procedure............................. 58
  16149.  SetMoveRestrictions Procedure.............................. 57
  16150.  SetOptionMenuBorderColor Procedure......................... 96
  16151.  SetOptionMenuColors Procedure.............................. 96
  16152.  SetProportional Procedure..................................186
  16153.  SetShadowBorderColor Procedure.............................148
  16154.  SetShadowColor Procedure...................................147
  16155.  SetShadowFillPattern Procedure.............................148
  16156.  SetShadowFillStyle Procedure...............................149
  16157.  
  16158.  Programmer's Reference Guide       - 265 -         TEGL Windows Toolkit
  16159.  
  16160.  
  16161.  
  16162.  
  16163.  
  16164.                                 INDEX
  16165.  
  16166.  SetShadowTextHighlight Procedure...........................152
  16167.  SetShadowTextShadow Procedure..............................151
  16168.  SetShadowTextType Procedure................................150
  16169.  SetShiftKeys Procedure.....................................125
  16170.  SetSlidePosition Procedure.................................227
  16171.  SetTEGLBackColor Procedure.................................143
  16172.  SetTEGLBorderColor Procedure...............................144
  16173.  SetTEGLBorderShow Procedure................................143
  16174.  SetTEGLFillPattern Procedure...............................145
  16175.  SetTEGLFillStyle Procedure.................................145
  16176.  SetTEGLFont Procedure......................................186
  16177.  SetTextJustify Procedure...................................240
  16178.  SetTimerStart Procedure....................................119
  16179.  SetTimerTick Procedure.....................................230
  16180.  SetVPage Procedure.........................................135
  16181.  SetVideoChoices............................................129
  16182.  ShadowBox Procedure........................................146
  16183.  ShadowBoxText Procedure....................................147
  16184.  ShadowTextHighlightOFF Procedure...........................152
  16185.  Shadowtext Procedure.......................................150
  16186.  ShiftTextXY Procedure......................................153
  16187.  ShowButtonStatus Event.....................................125
  16188.  ShowCoordinates Event...................................... 52
  16189.  ShowFonts Event............................................188
  16190.  ShowImage Procedure........................................ 51
  16191.  ShowMouse Procedure........................................108
  16192.  ShowOneFont Event..........................................188
  16193.  SlideBeep Procedure........................................193
  16194.  SoundSwitch Procedure......................................194
  16195.  SwapBytes Procedure........................................138
  16196.  SwapTEGLIntrOff Procedure..................................105
  16197.  SwapTEGLIntrOn Procedure...................................106
  16198.  SwapTimerIn Procedure......................................119
  16199.  SwapTimerOut Procedure.....................................119
  16200.  TEGLCharHeight Function....................................185
  16201.  TEGLCharWidth Function.....................................185
  16202.  TEGLFreeMem Procedure......................................198
  16203.  TEGLGetMem Procedure.......................................197
  16204.  TEGLKeyPressed Function....................................124
  16205.  TEGLMaxAvail Function......................................219
  16206.  TEGLReadkey Function.......................................123
  16207.  TEGLSupervisor Procedure................................... 19
  16208.  TEGLSupervisor............................................. 23
  16209.  TEGLTextWidth Function.....................................184
  16210.  TEGLWrtChar Procedure......................................186
  16211.  TEGLWrtChar................................................187
  16212.  TEGLWrtChar................................................257
  16213.  Timer ticks................................................ 24
  16214.  TimerSwtich Procedure......................................121
  16215.  ToggleCheckMark Procedure.................................. 93
  16216.  ToggleEntryStatus Procedure................................ 93
  16217.  ToggleOptionBar Procedure.................................. 95
  16218.  
  16219.  Programmer's Reference Guide       - 266 -         TEGL Windows Toolkit
  16220.  
  16221.  
  16222.  
  16223.  
  16224.  
  16225.                                 INDEX
  16226.  
  16227.  UnFreezeMouse Procedure....................................115
  16228.  UnLinkFS Procedure......................................... 60
  16229.  UnLockImage Procedure...................................... 71
  16230.  UnUseImage Procedure....................................... 72
  16231.  UnderLineChar Function.....................................187
  16232.  UseHardDisk procedure......................................217
  16233.  UseImage Procedure......................................... 72
  16234.  VDSKFreeMem procedure......................................214
  16235.  VDSKGetMem function........................................213
  16236.  VDSKReadHeapData procedure.................................215
  16237.  VDSKWriteHeapData procedure................................214
  16238.  VDskCloseHeapFile procedure................................215
  16239.  VDskOpenHeapFile function..................................211
  16240.  VEMSOpenHeapFile function..................................212
  16241.  VGA........................................................130
  16242.  VGA640x480x16 Procedure....................................129
  16243.  VideoAutoDetect............................................130
  16244.  VideoID....................................................130
  16245.  VideoPage Function.........................................136
  16246.  VirtualMemUsed Function....................................219
  16247.  VisualButtonPress Function.................................169
  16248.  XORBox Procedure...........................................139
  16249.  XORCornerBox Procedure.....................................139
  16250.  ZipFromBox Procedure.......................................159
  16251.  ZipToBox Procedure.........................................159
  16252.  
  16253.  
  16254.  
  16255.  
  16256.  
  16257.  
  16258.  
  16259.  
  16260.  
  16261.  
  16262.  
  16263.  
  16264.  
  16265.  
  16266.  
  16267.  
  16268.  
  16269.  
  16270.  
  16271.  
  16272.  
  16273.  
  16274.  
  16275.  
  16276.  
  16277.  
  16278.  
  16279.  
  16280.