home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / c / cwl30 / cwl3docs / manual.doc < prev   
Text File  |  1994-10-16  |  738KB  |  20,653 lines

  1. @ME.FORMAT                                                              R        
  2.                         THE C WINDOW LIBRARY
  3.       (c) Copyright P. A. McKenzie 1990, 1991, 1992, 1993, 1994
  4.                          All Rights Reserved
  5.  
  6.                              Version 3.00a
  7.  
  8.  
  9.                   T A B L E   O F   C O N T E N T S
  10.  
  11.  
  12.          PRELIMINARIES ..........................................  i
  13.             Microsoft C .........................................  i
  14.             Turbo C/C++ / Borland C++ ...........................  ii
  15.             Global Variables ....................................  iv
  16.  
  17.          INTRODUCTION ........................................... 1
  18.             Defining Windows .................................... 1
  19.             Properties of Windows ............................... 1
  20.             Writing to Overlapping Windows ...................... 2
  21.             Top-Level, Child, and Desktop Windows ............... 2
  22.             Window Ranks ........................................ 2
  23.             Detection of Video Hardware ......................... 3
  24.             Window Coordinates .................................. 3
  25.             Client Area ......................................... 4
  26.             Video Attributes .................................... 4
  27.             Direct Screen Writes and BIOS Screen Updates ........ 5
  28.             Video Paging ........................................ 6
  29.             Error Codes ......................................... 7
  30.             Window Manager ...................................... 7
  31.  
  32.  
  33.          MANDATORY FUNCTIONS AND HEADER FILES ................... 8
  34.             WindowInitializeSystem() ............................ 8
  35.  
  36.  
  37.          CREATING WINDOWS ....................................... 9
  38.             The CWLWINDOW structure and WPOINTER structure ...... 9
  39.             WindowInitDesktop() ................................. 9
  40.             WindowInitialize() .................................. 10
  41.             CREATE_VIDEO_ATTRIBUTE() macro ...................... 11
  42.             Box types ........................................... 12
  43.  
  44.  
  45.          DISPLAYING WINDOWS ..................................... 14
  46.             The WindowDisplay() function and Explosion Effects .. 14
  47.             Displaying Multiple Windows ......................... 17
  48.  
  49.  
  50.          CLOSING WINDOWS ........................................ 19
  51.             WindowClose() ....................................... 19
  52.             WindowCloseAll() .................................... 20
  53.             WindowUninitSystem() ................................ 21
  54.  
  55.  
  56.          CENTERING WINDOWS ON THE SCREEN ........................ 22
  57.             WindowCenter() ...................................... 22
  58.  
  59.  
  60.  
  61.  
  62.                            The C Window Library
  63.  
  64.          CHANGING WINDOW CHARACTERISTICS ........................ 24
  65.             WindowChangeTextAttribute() ......................... 24
  66.             WindowChangeBorderAttribute() ....................... 25
  67.             WindowDrawBorder() .................................. 25
  68.             WindowRemoveBorder() ................................ 27
  69.             WindowResizeHeight() ................................ 27
  70.             WindowResizeWidth() ................................. 28
  71.  
  72.  
  73.          WRITING TEXT TO WINDOWS ................................ 30
  74.  
  75.             Null Terminated Write Functions ..................... 30
  76.                WindowWriteString() .............................. 30
  77.                WindowWriteStringAttr() .......................... 31
  78.                WindowWriteCenterString() ........................ 32
  79.                WindowWriteCenterStringAttr() .................... 33
  80.                WindowWriteStringCC() ............................ 33
  81.                WindowWriteStringCCAttr() ........................ 34
  82.                WindowWriteStringRJ() ............................ 35
  83.                WindowWriteStringRJAttr() ........................ 36
  84.  
  85.             Length Controlled Write Functions.................... 37
  86.                WindowWriteCharacters() .......................... 37
  87.                WindowWriteAttributes() .......................... 38
  88.                WindowWriteCharAndAttr() ......................... 39
  89.                WindowWriteCharactersAttr() ...................... 40
  90.                WindowWriteRepeatAttribute() ..................... 41
  91.                WindowWriteRepeatCharacter() ..................... 42
  92.  
  93.             Formatted Write Functions ........................... 43
  94.                Where output is placed in the window ............. 43
  95.                WindowSetWrap() .................................. 43
  96.                WindowPrintf() ................................... 44
  97.                WindowPrintfAttr() ............................... 45
  98.  
  99.  
  100.          WRITING TITLES TO WINDOWS .............................. 47
  101.             WindowTitleTop() .................................... 48
  102.             WindowTitleBottom() ................................. 49
  103.             WindowTitleTopAttr() ................................ 50
  104.             WindowTitleBottomAttr() ............................. 51
  105.  
  106.  
  107.          READING CHARACTERS AND ATTRIBUTES FROM WINDOWS ......... 53
  108.             WindowReadCharacters() .............................. 53
  109.             WindowReadAttributes() .............................. 54
  110.             WindowReadCharAndAttr() ............................. 55
  111.  
  112.  
  113.          HIDING WINDOWS ......................................... 57
  114.             WindowHide() ........................................ 57
  115.  
  116.  
  117.          CREATING COPIES OF A WINDOW ............................ 59
  118.             WindowCopy() ........................................ 59
  119.  
  120.  
  121.  
  122.                            The C Window Library
  123.  
  124.          SCROLLING TEXT IN WINDOWS .............................. 61
  125.             WindowScroll() ...................................... 61
  126.             WindowScrollRegion() ................................ 62
  127.             WindowScrollAttr() .................................. 63
  128.             WindowScrollRegionAttr() ............................ 64
  129.  
  130.  
  131.          CLEARING WINDOWS ....................................... 66
  132.             WindowClear() ....................................... 66
  133.             WindowClearAttr() ................................... 67
  134.             WindowClearRegion() ................................. 67
  135.             WindowClearRegionAttr() ............................. 68
  136.  
  137.  
  138.          WRITING WINDOW CONTENTS TO A FILE ...................... 70
  139.             WindowWriteTextToFile() ............................. 70
  140.  
  141.  
  142.          SHADOWING WINDOWS ...................................... 72
  143.             WindowDrawShadow() .................................. 72
  144.             WindowRemoveShadow() ................................ 74
  145.  
  146.  
  147.          SEE-THRU WINDOWS ....................................... 75
  148.             WindowMakeSeeThru() ................................. 75
  149.             WindowMakeNormal() .................................. 76
  150.  
  151.  
  152.          MOVING AND SLIDING WINDOWS ............................. 77
  153.             WindowMove() ........................................ 77
  154.             WindowSlide() ....................................... 78
  155.  
  156.  
  157.          CURSOR POSITIONING IN WINDOWS .......................... 79
  158.             Cursor Maintenance in The C Window Library .......... 79
  159.             Creating Cursor Shapes .............................. 79
  160.             WindowChangeCursor() ................................ 79
  161.             WindowMoveCursor() .................................. 80
  162.             WindowGetCursorShape() .............................. 81
  163.             WindowGetCursorPosition() ........................... 82
  164.  
  165.  
  166.          GETTING WHICH WINDOW OCCUPIES A LOCATION ............... 84
  167.             WindowWhich() ....................................... 84
  168.  
  169.  
  170.          GETTING INPUT FROM WINDOWS ............................. 85
  171.             Input Manager ....................................... 85
  172.             Regular Expressions ................................. 85
  173.             Editing Input ....................................... 90
  174.             Last Key Value ...................................... 92
  175.             Default Cursor Types and Editing Mode ............... 92
  176.             Editing using a character mask ...................... 93
  177.  
  178.  
  179.  
  180.  
  181.  
  182.                            The C Window Library
  183.  
  184.             Editing Functions ................................... 94
  185.                WindowGetString() ................................ 94
  186.                WindowGetStringAttr() ............................ 97
  187.                WindowGetMaskString() ............................ 98
  188.                WindowGetMaskStringAttr() ........................ 99
  189.                Getting Passwords ................................ 100
  190.                   WindowGetPassword() ........................... 101
  191.                   WindowGetPasswordAttr() ....................... 102
  192.                   WindowGetMaskPassword() ....................... 102
  193.                   WindowGetMaskPasswordAttr() ....................103
  194.                Undefined Keystroke Processing ................... 104
  195.                     The CWLundef_fkey_func and CWLundef_akey_func_
  196.                               function pointers ................. 104
  197.                     Specifying when to call an undefined key
  198.                           function in a Regular Expression ...... 106
  199.                     Return Values To The Input Manager .......... 106
  200.  
  201.  
  202.                Input Options .................................... 109
  203.                CHECKREGEXP and the reg_exp_error_func
  204.                      function pointer ........................... 110
  205.                THE CWLchars_entered_func function pointer ....... 113
  206.  
  207.  
  208.                Other Input releated functions ................... 114
  209.                TranslateStringToMaskString() .................... 114
  210.                TranslateMaskStringToString() .................... 116
  211.  
  212.  
  213.          CHILD WINDOWS .......................................... 118
  214.             Creating Child Windows with WindowSetParent() ....... 119
  215.             Translation of Child Coordinates .................... 120
  216.             Enumerating Child Windows ........................... 123
  217.             Testing Window Relationships ........................ 125
  218.             Testing Window Ranks ................................ 126
  219.  
  220.  
  221.          VIRTUAL WINDOWS ........................................ 127
  222.             Using Windows as Viewports .......................... 127
  223.             Attributed and Non-Attributed Virtual Windows ....... 127
  224.             Virtual Window's Logical Cursor ..................... 128
  225.  
  226.  
  227.             CREATING VIRTUAL WINDOWS ............................ 129
  228.                VirtualInitialize() .............................. 129
  229.  
  230.  
  231.             ASSIGNING VIEWPORTS AND CLOSING VIEWPORTS ........... 131
  232.                WindowAssignToVirtual() .......................... 131
  233.                Out of bounds Coordinates ........................ 132
  234.                WindowCloseViewport() ............................ 133
  235.  
  236.  
  237.             WRITING TEXT TO VIRTUAL WINDOWS ..................... 135
  238.  
  239.                Null Terminated String Functions ................. 135
  240.                   VirtualWriteString() .......................... 135
  241.                   VirtualWriteStringAttr() ...................... 136
  242.                   VirtualWriteCenterString() .................... 137
  243.                   VirtualWriteCenterStringAttr() ................ 138
  244.                   VirtualWriteStringCC() ........................ 139
  245.                   VirtualWriteStringCCAttr() .................... 140
  246.                   VirtualWriteStringRJ() ........................ 141
  247.                   VirtualWriteStringRJAttr() .................... 141
  248.  
  249.  
  250.                            The C Window Library
  251.  
  252.                Length Controlled Functions ...................... 142
  253.                   VirtualWriteCharacters() ...................... 142
  254.                   VirtualWriteAttributes() ...................... 143
  255.                   VirtualWriteCharAndAttr() ..................... 144
  256.                   VirtualWriteRepeatAttribute() ................. 145
  257.                   VirtualWriteRepeatCharacter() ................. 146
  258.  
  259.                Formatted Write Functions ........................ 147
  260.                   Format String ................................. 147
  261.                   Where Output is Placed ........................ 148
  262.                   VirtualSetWrap() .............................. 148
  263.                   VirtualPrintf() ............................... 149
  264.                   VirtualPrintfAttr() ........................... 149
  265.  
  266.  
  267.             READING CHARACTERS AND ATTRIBUTES FROM
  268.                                    VIRTUAL WINDOWS .............. 151
  269.                VirtualReadCharacters() .......................... 151
  270.                VirtualReadAttributes() .......................... 152
  271.                VirtualReadCharAndAttr() ......................... 153
  272.  
  273.  
  274.             REPOSITIONING THE VIEWPORT .......................... 155
  275.                WindowPositionViewport() ......................... 155
  276.  
  277.  
  278.             SCROLLING THE VIEWPORTS ............................. 159
  279.                WindowScrollVirtual() ............................ 159
  280.  
  281.  
  282.             WRITING VIRTUAL WINDOW CONTENTS TO A FILE ........... 162
  283.                VirtualWriteTextToFile() ......................... 162
  284.  
  285.  
  286.             MOVING THE LOGICAL CURSOR ........................... 164
  287.                VirtualMoveCursor() .............................. 164
  288.                VirtualGetCursorPosition() ....................... 165
  289.  
  290.  
  291.             CLEARING VIRTUAL WINDOWS ............................ 166
  292.                VirtualClear() ................................... 166
  293.                VirtualClearAttr() ............................... 167
  294.                VirtualClearRegion() ............................. 168
  295.                VirtualClearRegionAttr() ......................... 169
  296.  
  297.  
  298.             FREEZING VIEWPORTS .................................. 170
  299.                WindowFreeze() ................................... 170
  300.  
  301.  
  302.             DISPOSING OF VIRTUAL WINDOWS ........................ 172
  303.                VirtualClose() ................................... 172
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.                            The C Window Library
  311.  
  312.          INTRODUCTION TO MENU SYSTEM ............................ 174
  313.             Menu Manager ........................................ 174
  314.  
  315.  
  316.             POP-UP MENUS ........................................ 175
  317.                Description ...................................... 175
  318.  
  319.  
  320.             CREATING POP-UP MENUS ............................... 176
  321.                The PopupCreateMenu() function ................... 176
  322.                Creating Popup Menu Entries ...................... 179
  323.                Inserting Multiple Entries ....................... 183
  324.                Inserting a Popup Menu Within a Popup Menu ....... 185
  325.                Deleting Menu Entries ............................ 187
  326.                Initializing the size of the Virtual Window and
  327.                   and Viewport Window ........................... 188
  328.  
  329.  
  330.             SELECTING FROM POPUP MENUS .......................... 191
  331.                PopupSelectMenu() function ....................... 191
  332.                   Values passed to menu function ................ 193
  333.                   Values returned to menu manager ............... 193
  334.  
  335.  
  336.             SETTING OPTIONS IN POPUP MENUS ...................... 194
  337.                The PopupSetOptions() function ................... 194
  338.                   Setting Multiple Options ...................... 194
  339.                   Getting Menu Options .......................... 195
  340.  
  341.  
  342.             DISABLING POPUP MENU ENTRIES ........................ 196
  343.                Disabling and Enabling Entries ................... 196
  344.  
  345.  
  346.             CHANGING THE MENU ENTRY STRINGS ..................... 197
  347.                PopupSetEntryString() function ................... 197
  348.  
  349.  
  350.             CHECKING POPUP MENU ENTRIES ......................... 198
  351.                PopupCheckEntry() ................................ 198
  352.  
  353.  
  354.             REDEFINING MENU KEYS ................................ 199
  355.                Setting Global Key Definitions and
  356.                       the popup_key_definition Array ............ 199
  357.                Setting Local Key Definitions .................... 200
  358.                   PopupAssignKeys() function .................... 200
  359.  
  360.  
  361.             PROCESSING UNDEFINED KEYS ........................... 201
  362.                The CWLpopup_undef_key_func function pointer ..... 201
  363.                   Values returned to menu manager ............... 201
  364.  
  365.  
  366.             PRE-INPUT FUNCTION .................................. 205
  367.                Setting the CWLglobal_popup_prefunc
  368.                                   function pointer .............. 205
  369.  
  370.                            The C Window Library
  371.  
  372.             DISPOSING OF POPUP MENUS ............................ 207
  373.                PopupMenuClose() ................................. 207
  374.  
  375.  
  376.          BAR MENUS .............................................. 208
  377.             Description ......................................... 208
  378.  
  379.             CREATING BAR MENUS .................................. 209
  380.                 BarCreateMenu() ................................. 209
  381.                 Creating Bar Menu Entries ....................... 212
  382.                 Inserting Multiple Entries ...................... 215
  383.                 Deleting Menu Entries ........................... 216
  384.  
  385.  
  386.             SELECTING FROM BAR MENUS ............................ 218
  387.                BarSelectMenu() function ......................... 218
  388.                   Values passed to menu function ................ 220
  389.                   Values returned to menu manager ............... 220
  390.  
  391.  
  392.             SETTING OPTIONS IN BAR MENUS ........................ 221
  393.                The BarSetOptions() function ..................... 221
  394.                   Setting Multiple Options ...................... 221
  395.                   Getting Menu Options .......................... 222
  396.  
  397.  
  398.             ENABLING AND DISABLING BAR MENU ENTRIES ............. 223
  399.                Disabling and Enabling Entries ................... 223
  400.  
  401.  
  402.             CHANGING THE MENU ENTRY STRINGS ..................... 224
  403.                BarSetEntryString() function ..................... 224
  404.  
  405.  
  406.             REDEFINING MENU KEYS ................................ 225
  407.                Setting Global Key Definitions and
  408.                      the CWLbar_key_def Array ................... 225
  409.                Setting Local Key Definitions .................... 225
  410.                   BarAssignKeys() function ...................... 226
  411.  
  412.  
  413.             PROCESSING UNDEFINED KEYS ........................... 227
  414.                The CWLbar_undef_key_func function pointer ....... 227
  415.                Values returned to menu manager .................. 227
  416.  
  417.  
  418.             PRE-INPUT FUNCTION .................................. 230
  419.                Setting the CWLglobal_bar_prefunc function
  420.                                                  pointer ........ 230
  421.  
  422.  
  423.             DISPOSING OF BAR MENUS .............................. 232
  424.                BarMenuClose() function .......................... 232
  425.  
  426.  
  427.  
  428.  
  429.  
  430.                            The C Window Library
  431.  
  432.          PULLDOWN MENUS ......................................... 233
  433.             Description ......................................... 233
  434.             Bar Menu and Popup Menu levels ...................... 233
  435.  
  436.  
  437.             CREATING PULLDOWN MENUS ............................. 234
  438.                The PulldownCreateMenu() function ................ 234
  439.                Adding and Inserting menu entries ................ 235
  440.                Deleting Menu Entries ............................ 236
  441.  
  442.  
  443.             SELECTING MENU ENTRIES .............................. 237
  444.                The PulldownSelectMenu() function ................ 237
  445.  
  446.  
  447.             DISPOSING OF PULLDOWN MENUS ......................... 238
  448.  
  449.             USING BAR MENU FUNCTIONS ............................ 238
  450.  
  451.             USING POPUP MENU FUNCTIONS .......................... 239
  452.  
  453.             EXAMPLE OF PULLDOWN MENU SYSTEM ..................... 239
  454.                Key Definitions for Pulldown Menus ............... 245
  455.  
  456.  
  457.          MISCELLANEOUS FUNCTIONS ................................ 247
  458.  
  459.  
  460.             SETTING AND CHECKING VIDEO PAGES .................... 248
  461.                CheckVideoPage() ................................. 248
  462.                SetActiveVideoPage() function .................... 248
  463.                SetVisibleVideoPage() function ................... 249
  464.  
  465.  
  466.             GENERAL STRING WRITING FUNCTIONS .................... 251
  467.                VideoWriteString() ............................... 251
  468.                VideoWriteStringAttr() ........................... 252
  469.                VideoWriteAttributes() ........................... 252
  470.                VideoWriteCenterString() ......................... 253
  471.                VideoWriteCenterStringAttr() ..................... 254
  472.                VideoWriteCharAndAttr() .......................... 254
  473.                VideoWriteStringCC() ............................. 255
  474.                VideoWriteStringCCAttr() ......................... 256
  475.                VideoWriteStringRJ() ............................. 256
  476.                VideoWriteStringRJAttr() ......................... 257
  477.                VideoPrintf() .................................... 258
  478.                VideoPrintfAttr() ................................ 258
  479.  
  480.  
  481.             READING CHARACTERS AND ATTRIBUTES FROM THE SCREEN ... 260
  482.                VideoReadCharacters() ............................ 260
  483.                VideoReadAttributes() ............................ 260
  484.                VideoReadCharAndAttr() ........................... 261
  485.  
  486.  
  487.  
  488.  
  489.  
  490.                            The C Window Library
  491.  
  492.             DRAWING BOXES ....................................... 262
  493.                VideoDrawBox() ................................... 262
  494.                VideoDrawBoxAttr() ............................... 262
  495.  
  496.  
  497.             SAVING AND RESTORING SCREEN IMAGES .................. 264
  498.                VideoSave() ...................................... 264
  499.                VideoMove() ...................................... 265
  500.                VideoRestore() ................................... 265
  501.                VideoFree() ...................................... 266
  502.  
  503.  
  504.             CLEARING SCREENS .................................... 267
  505.                ClearScreen() .................................... 267
  506.                ClearRegion() .................................... 267
  507.  
  508.  
  509.             SCROLLING SCREENS ................................... 269
  510.                ScrollScreenUp() ................................. 269
  511.                ScrollScreenDown() ................................269
  512.  
  513.             CHANGING THE VIDEO MODE ............................. 271
  514.                SetVideoMode() ................................... 271
  515.  
  516.  
  517.             CHANGING THE NUMBER OF ROWS AND COLUMNS ON
  518.                                         THE SCREEN .............. 272
  519.                Changing rows .................................... 272
  520.                   AdjustScreenInfo() ............................ 272
  521.                   AdjustGlobalData() ............................ 273
  522.                   SetVideoRows() ................................ 273
  523.                Changing columns ................................. 276
  524.                   40 column and 80 column modes ................. 276
  525.                   Modes higher than 80 columns .................. 277
  526.  
  527.  
  528.             CURSOR MANIPULATION ................................. 279
  529.                MoveCursor() ..................................... 279
  530.                ChangeCursor() ................................... 279
  531.                GetCursorShape() ................................. 280
  532.                GetCursorPosition() .............................. 280
  533.                HideCursor() ..................................... 281
  534.                BlockCursor() .................................... 281
  535.                ThinCursor() ..................................... 281
  536.  
  537.  
  538.             GETTING VIDEO INFORMATION ........................... 283
  539.                VIDEO_CONFIG structure ........................... 283
  540.                GetVideoBiosInfo() ............................... 283
  541.  
  542.  
  543.             TIMED DELAYS ........................................ 285
  544.                delay() .......................................... 285
  545.  
  546.  
  547.  
  548.  
  549.  
  550.                            The C Window Library
  551.  
  552.             SOUND FUNCTIONS ..................................... 286
  553.                sound() and nosound() ............................ 286
  554.                MakeSound() ...................................... 286
  555.  
  556.  
  557.             ERROR HANDLING ...................................... 288
  558.                The CWLerror_func function pointer ............... 288
  559.  
  560.  
  561.             USING A MOUSE WITH THE C WINDOW LIBRARY ............. 291
  562.                Installing the Mouse Library ..................... 291
  563.                Include Files .................................... 291
  564.                Initializing the Mouse with
  565.                                 MouseInitializeSystem().......... 291
  566.                Turning off the mouse with MouseRestoreSystem() .. 292
  567.                Using a mouse with popup menus ................... 293
  568.                    Popup Menu's prefunction for mouse ........... 295
  569.                Using a mouse with bar menus ..................... 295
  570.                Using a mouse with pulldown menus ................ 295
  571.                Changing the mouse defaults ...................... 295
  572.  
  573.  
  574.             WINDOW AND VIRTUAL WINDOW MACROS .................... 297
  575.  
  576.  
  577.             MENU MACROS ......................................... 300
  578.                Popup Menu Macros ................................ 300
  579.                Bar Menu Macros .................................. 302
  580.                Pulldown Menu Macros ............................. 303
  581.  
  582.  
  583.             VIDEO MACROS ........................................ 304
  584.  
  585.             KEYBOARD MACROS ..................................... 308
  586.               Keyboard Idle Function ............................ 309
  587.               Keyboard Intercept Function ....................... 310
  588.               Checking for mouse presses ........................ 311
  589.  
  590.             ERROR CODES ......................................... 313
  591.  
  592.          IMPORTANT GLOBAL VARIABLES ............................. 314
  593.  
  594.          INDEX .................................................. 327
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.                            The C Window Library
  611.  
  612.                             PRELIMINARIES
  613.                             -------------
  614.  
  615.          Congratulations on using The C Window Library (CWL); an easy
  616.          to use, powerful, inexpensive C user interface library!
  617.          Before we start talking 'C', we will discuss briefly on how
  618.          to compile and link programs using The C Window Library.
  619.  
  620.          The following introduction is very brief.  For more in depth
  621.          information on make files, project files, link options, etc.
  622.          please consult the various documentation supplied with the
  623.          compiler that you are working with.
  624.  
  625.          The default word/byte alignment scheme was used when
  626.          compiling all the libraries.  In other words, all modules
  627.          used by The C Window Library were compiled without the use of
  628.          the word/byte alignment switch being used.
  629.  
  630.          Please read the README!!.1 and README!!.2 files for any
  631.          items changed/corrections that have been made to this manual.
  632.  
  633.  
  634.          Microsoft / Quick C
  635.          -------------------
  636.  
  637.          When compiling your programs, you must make sure that the
  638.          constant MSC is defined.  An example of how you would do this
  639.          as follows:
  640.  
  641.          cl -Ax -DMSC -Ihfiles prog1.c /link /SE:1000 mcwinx.lib
  642.  
  643.          the -Ax is the model used for compilation.  The x stands for
  644.          either S for small, M for medium, C for compact, or L for
  645.          large.  The -D option defines a constant, which in this case
  646.          is MSC.  You must use the -D switch with MSC as the constant.
  647.          If not, you will get either syntax errors, link errors, or
  648.          runtime errors.  The -I option tells the compiler that the .h
  649.          files are located in a directory on the default drive called
  650.          hfiles.  The /link option links the resulting object files
  651.          (prog1.obj) with The C Window Library file mswinx.lib, where
  652.          x stands for S, M, C, or L.  The /SE segment switch is a
  653.          mandatory switch when linking the CWL libraries.  The value
  654.          that is usually used is 1000, but you can experiment with
  655.          different values.
  656.  
  657.  
  658.          The other method is to create a make file.  If you are using
  659.          the integrated environment of Quick C or using the
  660.          Programmers Work Bench (PWB) for Microsoft C 6.0+ or Visual
  661.          C++, you can create your make files by selecting the files
  662.          you want to compile, and the libraries you want to link with
  663.          and letting these integrated environments create the make
  664.          file automatically.  If you are more advanced you can create
  665.          your make files by yourself without the aid of these
  666.          programs.  Consult the documentation for more information on
  667.          make files.
  668.  
  669.  
  670.                                   i
  671.  
  672.          Turbo C/TurboC++/Borland C++
  673.          ----------------------------
  674.  
  675.          The command to compile and link programs using the Turbo C
  676.          2.0, Turbo C++ 1.0 and higher, or Borland C++ 2.0 or higher,
  677.          the following command is to be used for the specified
  678.          compiler:
  679.  
  680.          Borland C++:
  681.                  bcc -mx -Ihfiles prog1.c bcwinx.lib
  682.  
  683.          Turbo C++, Turbo C:
  684.                  tcc -mx -Ihfiles prog1.c bcwinx.lib
  685.  
  686.  
  687.          the -mx is the model used for compilation.  The x stands for
  688.          either S for small, M for medium, C for compact, or L for
  689.          large.  The -I option tells the compiler that the .h files
  690.          are located in a directory on the default drive called
  691.          hfiles.  If you are using Turbo C or Turbo C++, replace bcc
  692.          with tc or tcc.
  693.  
  694.          If you will use the integrated environment, you must create a
  695.          project file.  This project file specifies the source code
  696.          modules, object code modules, and libraries that will be
  697.          linked in to produce an executable file.  If you use the
  698.          Turbo C Version 2.0 integrated environment, you must/ edit
  699.          this file yourself.  If you use the Turbo C++ or Borland C++
  700.          integrated environment, use the automatic Project File
  701.          creator.
  702.  
  703.          You can also use make files to link in your program.  Make
  704.          sure that the desired library from The C Window Library is
  705.          specified.
  706.  
  707.          You can also use the TCC.EXE (or BCC if you are using
  708.          Borland C++) command line compiler with the desired library
  709.          specified on the command line.  Consult the Turbo C/C++
  710.          documentation on using make files and using the integrated
  711.          environment.
  712.  
  713.          The default structure alignment was used to compile the
  714.          libraries, which is byte alignment.
  715.  
  716.          An example of using the TCC.EXE (BCC.EXE) command line is as
  717.          follows:
  718.  
  719.                 tcc -mm -G -r -ihfiles prog1.c bcwinm.lib
  720.  
  721.          The following command line uses -mm for the medium memory
  722.          model, -G to optimize for speed, -r for usage of register
  723.          variables, and -i to tell the compiler that the header files
  724.          are located in a directory on the default drive called
  725.          hfiles.
  726.  
  727.  
  728.  
  729.  
  730.                                  iii
  731.  
  732.                           GLOBAL VARIABLES
  733.                           ----------------
  734.  
  735.         The global variables used by The C Window Library follow a
  736.         consistent naming convention.  All global variables start with
  737.         the three letters 'CWL'.  For instance, CWLscreen_rows is a
  738.         global variable in The C Window Library to denote the number
  739.         of rows visible on the screen.  This naming convention is used
  740.         so that there is virtually no chance that you will invent a
  741.         variable name in your program that matches one used in the
  742.         library.  If you stay away from starting your user variable
  743.         names with 'CWL', duplication is impossible.
  744.  
  745.         All global variables are stored in the CWLGLOB.H header file.
  746.         If you are curious, you can peruse this file to see what the
  747.         global variables are.
  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.  
  787.  
  788.  
  789.  
  790.                                  iv
  791.  
  792.                             INTRODUCTION
  793.                             ------------
  794.  
  795.          Defining Windows
  796.          ----------------
  797.  
  798.          A window is an area of the screen that is separate and
  799.          independent from the other areas of the screen.  With
  800.          windows, you can scroll, write text, delete text, etc. in a
  801.          defined section of the screen.  An example of windows in
  802.          application programs are the resident memory utilities that
  803.          pop up on the screen when invoked, and restore the text to
  804.          its original state when the resident application is
  805.          terminated.  Sidekick is a good example of what you can do
  806.          with windows.  As a matter of fact, most professional
  807.          programs use windows in some manner.  Some applications use
  808.          windows to make pulldown menus i.e. the integrated
  809.          environment in the Borland compilers.  Other applications
  810.          such as text editors and word processors use windows to
  811.          display and edit a files contents.  With The C Window
  812.          Library, you can create professional looking application
  813.          program easily and without worrying about the tricky details
  814.          of window management.  At your disposal are tools that can
  815.          help you create pull-down menus, popup menus, bar menus, and
  816.          just fast output.
  817.  
  818.  
  819.          Properties of Windows
  820.          ---------------------
  821.  
  822.          Windows should have the following properties:
  823.            - more than one window can be displayed on the screen
  824.              simultaneously.
  825.  
  826.            - windows are allowed to overlap without disturbing the
  827.              contents of the windows underneath.
  828.  
  829.            - a window that is under a pile of windows can be brought
  830.              to the top.
  831.  
  832.            - a window that is under a pile of windows can be written
  833.              to without interfering with other windows.
  834.  
  835.            - windows can be disposed of when not needed, and erased
  836.              from the screen.  When erased, the contents of the
  837.              screen underneath the window is restored.
  838.  
  839.            - windows can be written to at any time.
  840.  
  841.            - the window application should automatically detect the
  842.              type of video hardware used.
  843.  
  844.            - the window functions should return an error if something
  845.              goes wrong.
  846.  
  847.  
  848.  
  849.  
  850.          Page 1          The C Window Library               Page 1
  851.  
  852.          Writing to Overlapping Windows
  853.          ------------------------------
  854.  
  855.          With The C Window Library, if a window does overlap another
  856.          window, this overlap will be displayed on the physical
  857.          screen.  The C Window Library allows you to direct output to
  858.          any window at any time.  When output is written to a window,
  859.          the window contents are updated in memory, but only the
  860.          visible portions of the window will be updated on the screen.
  861.  
  862.  
  863.          Top-Level, Child, and Desktop Windows
  864.          -------------------------------------
  865.  
  866.          CWL 3.0 now supports child windows.  Child windows are
  867.          windows that are embedded in other windows.  The window that
  868.          the child is embedded in is called the parent window.  The
  869.          child window is completely dependent on the parent when it
  870.          comes to position, hiding, and closing.  For example, if the
  871.          parent window is moved, the child is also moved.  A child
  872.          window can also have child windows.  You can have up to 255
  873.          child windows for each window.  The maximum number of windows
  874.          in total cannot exceed 32,767.
  875.  
  876.          If a window is not a window that you defined as a child
  877.          window, it is called a top-level window.  The main window
  878.          that all top-level windows are children of is called the
  879.          desktop window.  Top-level windows are children of the
  880.          desktop window.  A sibling window is a child window that has
  881.          the same parent as another child window.
  882.  
  883.  
  884.          Window Ranks
  885.          ------------
  886.  
  887.          The rank order of the windows on the screen will determine
  888.          which window has priority of the screen.
  889.  
  890.          Windows with lower rank numbers overlap windows with higher
  891.          rank numbers.  The lowest rank number is 1, and the highest
  892.          is 254 and 255 for top-level windows and child windows,
  893.          respectively.  If a new window is opened with the same rank
  894.          number as another previously opened window, the new window
  895.          takes over the rank position, and the previous window's rank
  896.          is increased by 1.  If there is a window with the same rank
  897.          as the previous window's new rank, its rank is increased by 1
  898.          etc.  When a window is closed, all windows with a higher rank
  899.          number are decreased by 1.
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.          Page 2          The C Window Library               Page 2
  911.  
  912.          For child windows, the rank determines the priority of the
  913.          window within the parent.  For example, a child window with a
  914.          rank of 1 will overlap another sibling window with a rank of
  915.          2 or higher.  Therefore knowing the rank number of the
  916.          window does NOT determine the priority, unless the windows
  917.          are top-level windows, or the windows are siblings within
  918.          the same parent window.  CWL has rank testing functions that
  919.          you should use instead of comparing ranks 'blindly'.
  920.  
  921.          Windows may be assigned different ranks if there is a
  922.          shadowed window.  If a window is shadowed, the shadow effect
  923.          is actually a secondary window that is always ranked 1 higher
  924.          than the actual window.  More will be stated on this in a
  925.          later section.
  926.  
  927.  
  928.  
  929.          Detection of Video Hardware
  930.          ---------------------------
  931.  
  932.          With The C Window Library, automatic detection of the type
  933.          of video hardware is necessary.  Since The C Window Library
  934.          can write directly to screen memory, the starting memory
  935.          address of screen memory must be known.  Depending on the
  936.          video adapter, the starting address of screen memory is
  937.          different.  For monochrome systems, the starting address is
  938.          different from a color system.  If the window routines think
  939.          that they are writing to a color system instead of a
  940.          monochrome system, crazy things will probably happen.  For
  941.          most adapters, The C Window Library will detect them and
  942.          assign the starting address of screen memory to a global
  943.          variable, so there is no need to specify the starting
  944.          address yourself.
  945.  
  946.  
  947.          Window Coordinates
  948.          ------------------
  949.  
  950.          A position on the screen can be specified as a pair of
  951.          numbers.  These numbers will denote the row and column of
  952.          the desired position.  Rows and columns are numbered from 0
  953.          to the maximum row or column number.  The upper left hand
  954.          corner of the screen would be at row 0, column 0.  For
  955.          simplicity, row y, column x will be abbreviated as (y,x).
  956.          The position (0,0) is called  the home position.
  957.  
  958.          However, when specifying a position in a window, this
  959.          position is numbered relative to the window itself.  No
  960.          matter where a window resides on the screen, the upper left
  961.          position of the window is (0,0), the second row of the
  962.          window is row 1, the fourth column is column 3, etc.  The
  963.          window coordinates are called window relative coordinates.
  964.          There are some window functions that require you to enter
  965.          physical screen (absolute) coordinates, but for most
  966.          functions, a window relative position would be needed.  For
  967.          example:
  968.  
  969.  
  970.          Page 3          The C Window Library               Page 3
  971.  
  972.          ┌─────────────────────────────────────────────────────────┐
  973.          │(0,0)                                              (0,79)│
  974.          │                                                         │
  975.          │                Valid Absolute Screen Coordinates        │
  976.          │                      For 80 x 25 Screen                 │
  977.          │                                                         │
  978.          │     This window opened at absolute (12,15)              │
  979.          │             │                                           │
  980.          │             │                                           │
  981.          │             V                                           │
  982.          │            ┌─────────────────────┐                      │
  983.          │            │(0,0)          (0,29)│                      │
  984.          │            │                     │                      │
  985.          │            │                     │                      │
  986.          │            │(14,0)        (14,29)│                      │
  987.          │            └─────────────────────┘                      │
  988.          │(24,0)                                            (24,79)│
  989.          └─────────────────────────────────────────────────────────┘
  990.  
  991.          CWL also supports positioning a window partially or
  992.          totally outside of the desktop by using negative coordinates
  993.          or positive coordinates that exceed the desktop height or
  994.          width.
  995.  
  996.          For child windows, the position is relative to the parent
  997.          window, and not to the screen itself.  The parent acts as a
  998.          'mini desktop window'.  The child window can also be
  999.          positioned partially outside of the parent window, however
  1000.          the only portion of the child window that will be visible
  1001.          will be the portion that is within the parent.
  1002.  
  1003.  
  1004.  
  1005.          Client Area
  1006.          -----------
  1007.  
  1008.          The client area of window is where all text is displayed in
  1009.          the window.  This does not include the borders.  The concept
  1010.          of the client area is important for some child window
  1011.          functions.
  1012.  
  1013.  
  1014.  
  1015.          Video Attributes
  1016.          ----------------
  1017.  
  1018.          With The C Window Library, a window can have an assortment
  1019.          of colors for text and background.  Each character that is
  1020.          displayed on the screen has its corresponding attribute
  1021.          byte.  The attribute byte is an 8-bit quantity that
  1022.          specifies a character's color, intensity, and blink status.
  1023.          The format of the attribute byte is as follows:
  1024.  
  1025.                              7  6  5  4  3  2  1  0
  1026.                            ┌──┬─────────┬─┬─────────┐
  1027.                            │B │ bground │I│fground  │
  1028.                            └──┴─────────┴─┴─────────┘
  1029.  
  1030.          Page 4          The C Window Library               Page 4
  1031.  
  1032.          The B is the blink bit and the I is the intensity bit.  Bits
  1033.          0 thru 2 is a color code for the foreground (text) color.
  1034.          Bits 4 thru 6 determine the color code for the background
  1035.          (screen) color.
  1036.  
  1037.  
  1038.          If the blink bit is 1, then the character will blink.  If
  1039.          the intensity bit is on, the character will appear brighter
  1040.          than usual.  Some monitors cannot display high intensity
  1041.          characters, so the intensity bit may not change the
  1042.          characters brightness at all.
  1043.  
  1044.               Here is a list of color values along with the color
  1045.               they represent:
  1046.  
  1047.               Value   Color     │    Value   Color
  1048.                                 │
  1049.                 0     Black     │     8     Gray
  1050.                 1     Blue      │     9     Light blue
  1051.                 2     Green     │    10     Light green
  1052.                 3     Cyan      │    11     Light cyan
  1053.                 4     Red       │    12     Light red
  1054.                 5     Magenta   │    13     Light magenta
  1055.                 6     Brown     │    14     Yellow
  1056.                 7     White     │    15     Intense white
  1057.  
  1058.          If the video system is a monochrome system, the color values
  1059.          specified above will give unpredictable results if not used
  1060.          carefully.  Monochrome systems also have an underline mode,
  1061.          that color systems (unless if you program the EGA or VGA
  1062.          adapters) cannot display.  Upcoming is a list of color
  1063.          values that should work on monochrome systems along with the
  1064.          type of display that will be produced:
  1065.  
  1066.  
  1067.             Display          Background      Foreground
  1068.  
  1069.             No display          0                 0
  1070.             Underline           0                 1
  1071.             Normal Video        0                 7
  1072.             Reverse Video       7                 0
  1073.  
  1074.          When programming a monochrome system, you can change the
  1075.          values of the colors not supported to black and white
  1076.          combinations supported on the monochrome system.  For
  1077.          example, you can change the light green color's value from
  1078.          10 to 7.  Now if light green is selected as a foreground
  1079.          color and the background color is black, you will have a
  1080.          normal video display on a monochrome system.
  1081.  
  1082.  
  1083.  
  1084.          Direct Screen Writes and BIOS Screen Updates
  1085.          --------------------------------------------
  1086.  
  1087.          By default, The C Window Library writes directly to screen
  1088.          memory.  This results in very fast screen output.  If you
  1089.  
  1090.          Page 5          The C Window Library               Page 5
  1091.  
  1092.          have ever wondered how commercial programs can display
  1093.          output so rapidly on the screen, direct screen writing is
  1094.          the major reason.  The disadvantage of writing directly to
  1095.          the screen is that it is ill-behaved with programs like
  1096.          Microsoft Windows or Quarterdeck's DesQView (although
  1097.          DesQView 386 running on a 386 or higher machine is well
  1098.          behaved with direct screen writes).  Also on some color
  1099.          systems, the screen output is so fast that the video display
  1100.          produces "snow" on the screen.  However, The C Window Library
  1101.          will automatically detect whether "snow" should be checked
  1102.          when writing directly to the screen.  The old IBM Color
  1103.          Graphics Adapters suffer from this problem, but most other
  1104.          adapters including monochrome, Hercules, EGA, VGA, and newer
  1105.          CGA's do not suffer from this problem.  When checking for
  1106.          snow, the screen writes are not as fast as when there is no
  1107.          snow checking, but it is fast enough.
  1108.  
  1109.          The other method of updating the screen is by making a call
  1110.          to the video functions contained in the ROM BIOS.  BIOS
  1111.          stands for Basic Input Output System.  The BIOS provides
  1112.          routines that are needed for the operation of the computer.
  1113.          Some of these routines are video functions needed to write
  1114.          characters and attributes, move the cursor, and scroll
  1115.          portions of the screen.  Using the BIOS instead of writing
  1116.          directly to screen memory results in much slower screen
  1117.          updates, but will be compatible with programs like Microsoft
  1118.          Windows and DesQView.
  1119.  
  1120.          With The C Window Library, you are allowed to use either
  1121.          method.
  1122.  
  1123.  
  1124.          Video Paging
  1125.          ------------
  1126.  
  1127.          Since most video display adapters have enough memory to
  1128.          store more than one screen of characters,  these video
  1129.          adapters will support multiple video pages.  With multiple
  1130.          video pages, you can write to a hidden video page and then
  1131.          display the entire video page instantaneously. The only
  1132.          adapter that does not support video paging is the Monochrome
  1133.          Display Adapter (MDA).  All CGA's, EGA's and VGA's support
  1134.          multiple video pages.   The maximum number of pages a card
  1135.          will support is determined by the amount of RAM included in
  1136.          the video board, and the maximum number of characters that
  1137.          can be displayed on each page.  A list of the maximum number
  1138.          of video pages in each mode for each card is as follows:
  1139.  
  1140.          BIOS        Mode                               Max. #
  1141.          Mode        Type           Adapter            of pages
  1142.          ----        ----           -------            --------
  1143.          0,1         Text        CGA, EGA, VGA             8
  1144.          2,3         Text        CGA,                      4
  1145.                                  EGA, VGA                  8
  1146.          7           Text        MDA, Hercules             1
  1147.                                  EGA, VGA                  8
  1148.  
  1149.  
  1150.          Page 6          The C Window Library               Page 6
  1151.  
  1152.          With The C Window Library, the video page displayed on the
  1153.          screen is called the visible page.  When creating a window,
  1154.          its page number is recorded.  When updating windows, the
  1155.          video page number where the window resides is used to direct
  1156.          the output to the appropriate video page.  There are also
  1157.          functions in The C Window Library that allow you to switch
  1158.          video pages.  With these routines, you can create very
  1159.          sophisticated user interfaces.  If you are using a clone
  1160.          Hercules Monochrome adapter, you may have access to more than
  1161.          one video page.  The original Hercules card has only one page
  1162.          of text memory.  The problem of accessing the other pages in
  1163.          the clone cards is that there is no universal way to
  1164.          determine how many pages that the card has.  If you are
  1165.          writing an application that targets a specific Hercules clone
  1166.          card, and you want to take advantage of the multiple pages,
  1167.          you can modify a global variable that contains the maximum
  1168.          number of available video pages, as well as the array that
  1169.          contains the segment:offset of each video page.  Make sure
  1170.          you have the full documentation for the card, or know
  1171.          off-hand the number of pages and their addresses.
  1172.  
  1173.  
  1174.  
  1175.          Error Codes
  1176.          -----------
  1177.  
  1178.          With most of The C Window Library functions,
  1179.          CWLerror_code, which is a global integer variable, is set
  1180.          to an error number when a function cannot be completed.
  1181.          Throughout this documentation, you are to assume that
  1182.          CWLerror_code is set to any error condition that is
  1183.          documented for each function.  The CWLerror_code
  1184.          variable IS NOT reset when a function has been completed
  1185.          successfully.
  1186.  
  1187.  
  1188.          Window Manager
  1189.          --------------
  1190.  
  1191.          The window manager is the code in The C Window Library that
  1192.          handles window initialization, movement, coloring, and other
  1193.          functions that control window management.
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.          Page 7          The C Window Library               Page 7
  1211.  
  1212.                 MANDATORY FUNCTIONS AND HEADER FILES
  1213.                 ------------------------------------
  1214.  
  1215.          The only mandatory function is WindowInitializeSystem(),
  1216.          explained below.  The cwlwin.h header file must be included
  1217.          in any module that will call functions included in The C
  1218.          Window Library.  This means that on the first line of any C
  1219.          file that will call any window functions, you must have the
  1220.          line:
  1221.  
  1222.               #include "cwlwin.h"
  1223.  
  1224.  
  1225.  
  1226.          WindowInitializeSystem()
  1227.          ------------------------
  1228.  
  1229.          This function MUST be called before any other function
  1230.          defined in The C Window Library.  This function also sets
  1231.          global variables, so it is also mandatory to call
  1232.          WindowInitializeSystem() before accessing any global
  1233.          variables defined by The C Window Library.
  1234.  
  1235.          WindowInitializeSystem() detects the type of video display
  1236.          used, the number of rows and columns that the screen
  1237.          currently displays, and initializes data structures and
  1238.          global variables.
  1239.  
  1240.          Example:
  1241.  
  1242.          #include "cwlwin.h"
  1243.  
  1244.          main()
  1245.          {
  1246.            WindowInitializeSystem();   /* Initialization function */
  1247.            /* Now it is safe to use C Window Library functions and
  1248.               global variables */
  1249.          }
  1250.  
  1251.          There is no return value for WindowInitializeSystem().
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.          Page 8          The C Window Library               Page 8
  1271.  
  1272.                           CREATING WINDOWS
  1273.                           ----------------
  1274.  
  1275.          We will now look how a window is created by defining a
  1276.          CWLWINDOW, WPOINTER, and using the WindowInitDesktop() and
  1277.          WindowInitialize() function.
  1278.  
  1279.  
  1280.  
  1281.          The CWLWINDOW structure and WPOINTER structure pointer
  1282.          ---------------------------------------------------
  1283.  
  1284.          When a window is created, the upper left hand column and
  1285.          row, the width, height, etc. must be recorded.  It would be
  1286.          very tedious if for every function call that acts on these
  1287.          windows we have to specify width, height, upper left hand
  1288.          row, etc. as function parameters.  The C Window Library
  1289.          conveniently has a structure called CWLWINDOW, and its
  1290.          corresponding pointer called a WPOINTER to alleviate these
  1291.          problems.
  1292.  
  1293.          When a window is created, its characteristics are stored in
  1294.          a CWLWINDOW structure, and most functions require that a pointer
  1295.          to this structure be passed.  This pointer is called a
  1296.          WPOINTER.  By only referring to the WPOINTER, argument lists
  1297.          to functions become much shorter.
  1298.  
  1299.  
  1300.  
  1301.  
  1302.          WindowInitDesktop()
  1303.          -------------------
  1304.  
  1305.          The WindowInitDesktop() function saves the base screen as a
  1306.          desktop window.  This MUST be called prior to creating any
  1307.          windows.  Here is a prototype:
  1308.  
  1309.               int WindowInitDesktop(int page)
  1310.  
  1311.          The page argument is the video page of the base screen to
  1312.          save.  If you are creating windows that will be manipulated
  1313.          on video page 0, you must call WindowInitDesktop() with 0 as
  1314.          the argument:
  1315.  
  1316.          #include "cwlwin.h"
  1317.  
  1318.          main()
  1319.          {
  1320.            WindowInitializeSystem(); /* Initialize global variables */
  1321.            WindowInitDesktop(0); /* Save video page 0's base screen */
  1322.          }
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.          Page 9           The C Window Library               Page 9
  1331.  
  1332.          In most applications, the initial screen page is page 0.
  1333.          However, it is safer to use the global variable
  1334.          CWLactive_page (explained in the IMPORTANT GLOBAL
  1335.          VARIABLES section) to determine the page.  If you are
  1336.          changing video pages in an application, the new page has
  1337.          to be initialized with WindowInitDesktop() so that the
  1338.          window manager updates the screen properly when moving
  1339.          windows, hiding windows, etc.  This function must be called
  1340.          only once in an application for each screen page desired.
  1341.  
  1342.          Return Values for WindowInitDesktop() are as follows:
  1343.  
  1344.              Return Value            Definition
  1345.          ┌────────────────┬───────────────────────────────┐
  1346.          │NO_ERROR        │ No error occurred.            │
  1347.          ├────────────────┼───────────────────────────────┤
  1348.          │NO_HEAP_MEM     │ Not enough memory to allocate.│
  1349.          ├────────────────┼───────────────────────────────┤
  1350.          │MAX_WINDOW      │ Too many windows defined.     │
  1351.          ├────────────────┼───────────────────────────────┤
  1352.          │BAD_DISPLAY_PAGE│ Video page does not exist.    │
  1353.          └────────────────┴───────────────────────────────┘
  1354.  
  1355.  
  1356.          WindowInitialize()
  1357.          ------------------
  1358.  
  1359.          The next function is WindowInitialize().  This function sets
  1360.          up a window with the position on the screen or another
  1361.          window to place the window, width, height, colors, and box
  1362.          type.  If successful, this function returns a new WPOINTER.
  1363.          Here is an example:
  1364.  
  1365.          #include "cwlwin.h"
  1366.          #define  NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1367.  
  1368.          WPOINTER w;
  1369.          main()
  1370.          {
  1371.            WindowInitializeSystem();
  1372.            WindowInitDesktop(0);
  1373.            w =
  1374.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,15,NORM,
  1375.                             NORM,SINGLEBOX);
  1376.                             ...
  1377.          }
  1378.  
  1379.          In the above example, we have defined a variable w as having
  1380.          a WPOINTER type.  This variable will ultimately point to a
  1381.          valid CWLWINDOW structure.  The first argument is the new
  1382.          window's parent window.  If the window is a top-level
  1383.          window, the first argument is DESKTOP_WINDOW.  If the window
  1384.          is a child, the first argument is the WPOINTER of the
  1385.          parent window.  The second argument to WindowInitialize() is
  1386.          a constant called BORDER.  This tells the window manager that
  1387.  
  1388.  
  1389.  
  1390.          Page 10          The C Window Library               Page 10
  1391.  
  1392.          the window desired is going to have a border.  If no border
  1393.          was desired, the constant would be NOBORDER. The third and
  1394.          fourth arguments tells the window manager the row and column
  1395.          of the screen where the upper left corner of the window will
  1396.          be located.  Since the upper left corner of the screen is row
  1397.          0, column 0, the upper left hand corner of the window will be
  1398.          placed at the upper left corner of the video screen.  The
  1399.          fifth and sixth arguments denote the width and the height of
  1400.          the window.  DO NOT INCLUDE THE BORDERS (if any) TO DETERMINE
  1401.          THE WIDTH AND HEIGHT OF THE WINDOW.  Our window will have a
  1402.          width of 30 characters and a height of 15 characters.  The
  1403.          seventh and eighth arguments are the video attributes of the
  1404.          inside of the window and the border respectively.
  1405.  
  1406.          The last argument tells us what type of border the window
  1407.          will have.  We use the constant SINGLEBOX to tell the window
  1408.          manager that we want a window with a border made up of
  1409.          single lines.
  1410.  
  1411.          If there is no error, WindowInitialize() returns a valid
  1412.          WPOINTER.
  1413.  
  1414.          If there is an error, WindowInitialize() returns a
  1415.          WIN_NULL_PTR (a null window pointer) and sets CWLerror_code
  1416.          to one of the following values:
  1417.  
  1418.              Return Value             Definition
  1419.          ┌────────────────┬───────────────────────────────┐
  1420.          │NO_HEAP_MEM     │ Not enough memory to allocate.│
  1421.          ├────────────────┼───────────────────────────────┤
  1422.          │MAX_WINDOW      │ Too many windows defined.     │
  1423.          ├────────────────┼───────────────────────────────┤
  1424.          │BAD_WINDOW      │ Parent Window does not exist. │
  1425.          └────────────────┴───────────────────────────────┘
  1426.  
  1427.          Even though there is a structure type called CWLWINDOW, you
  1428.          should always use the pointer to the structure (WPOINTER)
  1429.          rather than the CWLWINDOW structure itself.
  1430.  
  1431.  
  1432.  
  1433.          CREATE_VIDEO_ATTRIBUTE() macro
  1434.          ------------------------------
  1435.  
  1436.          Please note the use of the macro CREATE_VIDEO_ATTRIBUTE() in
  1437.          the previous example to create an integer representing the
  1438.          foreground and background colors.  This macro uses the first
  1439.          argument as the background color, and the second argument as
  1440.          the foreground color.  In the above example we have a
  1441.          constant called NORM which uses CREATE_VIDEO_ATTRIBUTE() to
  1442.          create a black background and a white foreground color
  1443.          combination.  Note that the colors are denoted by capitalized
  1444.          letters appended with an underscore character (_).
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.          Page 11          The C Window Library               Page 11
  1451.  
  1452.          Box types
  1453.          ---------
  1454.          For ease of use, There are predefined constants found that
  1455.          contains definitions of common border types.  These constants
  1456.          are as follows:
  1457.  
  1458.            Box Type        Visual    Box Type        Visual
  1459.          ┌─────────────────────────╥─────────────────────────┐
  1460.          │                 ╔════╗  ║                 ▒▒▒▒▒▒  │
  1461.          │ DOUBLEBOX       ║    ║  ║ HATCHBOX2       ▒    ▒  │
  1462.          │                 ║    ║  ║                 ▒    ▒  │
  1463.          │                 ╚════╝  ║                 ▒▒▒▒▒▒  │
  1464.          ├─────────────────────────╫─────────────────────────┤
  1465.          │                 ┌────┐  ║                 ▓▓▓▓▓▓  │
  1466.          │ SINGLEBOX       │    │  ║ HATCHBOX3       ▓    ▓  │
  1467.          │                 │    │  ║                 ▓    ▓  │
  1468.          │                 └────┘  ║                 ▓▓▓▓▓▓  │
  1469.          ├─────────────────────────╫─────────────────────────┤
  1470.          │                 ╒════╕  ║                 █▀▀▀▀█  │
  1471.          │ MIXEDBOX1       │    │  ║ SOLIDBOX1       █    █  │
  1472.          │                 │    │  ║                 █    █  │
  1473.          │                 ╘════╛  ║                 █▄▄▄▄█  │
  1474.          ├─────────────────────────╫─────────────────────────┤
  1475.          │                 ╓────╖  ║                 ██████  │
  1476.          │ MIXEDBOX2       ║    ║  ║ SOLIDBOX2       █    █  │
  1477.          │                 ║    ║  ║                 █    █  │
  1478.          │                 ╙────╜  ║                 ██████  │
  1479.          ├─────────────────────────╫─────────────────────────┤
  1480.          │                 ░░░░░░  ║                         │
  1481.          │ HATCHBOX1       ░    ░  ║ BLANKBOX                │
  1482.          │                 ░    ░  ║                         │
  1483.          │                 ░░░░░░  ║                         │
  1484.          ├─────────────────────────╫─────────────────────────┘
  1485.          │                -------- ║
  1486.          │ DOTTEDLINE     |      | ║
  1487.          │                |      | ║
  1488.          │                |      | ║
  1489.          │                -------- ║
  1490.          └─────────────────────────╜
  1491.  
  1492.          Although there are predefined border types in The C Window
  1493.          Library, you can define your own types.  The window border
  1494.          characters are represented by an 8 byte character string.
  1495.          Each character in this string refers to a border character
  1496.          to be used in drawing the window border.  A list of what
  1497.          each position in the string stands for is as follows:
  1498.  
  1499.          position                Representation
  1500.          --------           ---------------------------
  1501.             0               Upper left corner character.
  1502.             1               Top line character.
  1503.             2               Upper right corner character.
  1504.             3               Left side character.
  1505.             4               Right side character.
  1506.             5               Bottom left corner character.
  1507.             6               Bottom line character.
  1508.             7               Bottom right corner character.
  1509.  
  1510.          Page 12          The C Window Library               Page 12
  1511.  
  1512.          This character string is sent to the window functions that
  1513.          call for a string of box drawing characters.  For example,
  1514.          you can create your own customized set of characters with
  1515.          something like this:
  1516.  
  1517.          #define MYBOXCHARS  "+-+||+-+"
  1518.  
  1519.  
  1520.          MYBOXCHARS is a literal string of box drawing characters.
  1521.          Using the rules of box drawing characters defined above, the
  1522.          upper left hand corner of the box is the plus sign, the top
  1523.          line is the hyphen, the upper right and corner is the plus
  1524.          sign, the left side is a pipe character, as is the right
  1525.          side, and the bottom part of the box is defined the same as
  1526.          the upper part.  Then you would use it in a call to any
  1527.          function that asks for a box drawing string like this:
  1528.  
  1529.  
  1530.          w = WindowInitialize(DESKTOP_WINDOW,BORDER, ... ,MYBOXCHARS);
  1531.  
  1532.  
  1533.          The '...' are the other arguments that you would normally
  1534.          put for the WindowInitialize() function.
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.          Page 13          The C Window Library               Page 13
  1571.  
  1572.                          DISPLAYING WINDOWS
  1573.                          ------------------
  1574.  
  1575.          Now we will display the window we created in the previous
  1576.          example.
  1577.  
  1578.  
  1579.          The WindowDisplay() function and Explosion Effects
  1580.          --------------------------------------------------
  1581.  
  1582.          The WindowDisplay() function displays a window.  Here is the
  1583.          previous example with WindowDisplay() added to it:
  1584.  
  1585.          #include "cwlwin.h"
  1586.          #define  NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1587.  
  1588.          WPOINTER w;
  1589.          main()
  1590.          {
  1591.            WindowInitializeSystem();
  1592.            WindowInitDesktop(0);
  1593.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,15,NORM,
  1594.                                 NORM,SINGLEBOX);
  1595.            WindowDisplay(w,1,NOEFFECT);
  1596.            ...
  1597.          }
  1598.  
  1599.          The first argument to WindowDisplay() is the window to
  1600.          display, in our case, w is the window.  The second argument
  1601.          is the rank order of the window.  Since the rank order we
  1602.          desire is 1, this window will lie on top of all windows,
  1603.          unless another window is opened with a rank of 1.  Remember,
  1604.          any window with a rank number n will have sibling windows
  1605.          with rank n-1, n-2,...,1 to be displayed on top of it.
  1606.          Remember that top-level windows are siblings of each
  1607.          other.  You can change the rank order of a window at any time
  1608.          by calling WindowDisplay() with a different rank number.
  1609.  
  1610.          The third argument to WindowDisplay() is the explosion
  1611.          effect of the window when it is displayed.  There are
  1612.          currently 16 ways to explode a window on the screen,
  1613.          numbered from 0 thru 15.  Here is an overview of each
  1614.          effect:
  1615.  
  1616.          Defined Constant   Value      Effect
  1617.          ┌───────────────┬───────┬───────────────┐
  1618.          │   NOEFFECT    │   0   │ ┌───────────┐ │
  1619.          │               │       │ │           │ │
  1620.          │               │       │ │           │ │
  1621.          │               │       │ │           │ │
  1622.          │               │       │ │           │ │
  1623.          │               │       │ │           │ │
  1624.          │               │       │ │           │ │
  1625.          │               │       │ │           │ │
  1626.          │               │       │ └───────────┘ │
  1627.          └───────────────┴───────┴───────────────┘
  1628.  
  1629.  
  1630.          Page 14          The C Window Library               Page 14
  1631.  
  1632.          Defined Constant   Value      Effect
  1633.          ┌───────────────┬───────┬───────────────┐
  1634.          │EXPLODE        │   1   │ ┌───────────┐ │
  1635.          │               │       │ │     ^     │ │
  1636.          │               │       │ │     |     │ │
  1637.          │               │       │ │<--     -->│ │
  1638.          │               │       │ │           │ │
  1639.          │               │       │ │     |     │ │
  1640.          │               │       │ │     v     │ │
  1641.          │               │       │ └───────────┘ │
  1642.          ├───────────────┼───────┼───────────────┤
  1643.          │CONTRACT       │   2   │ ┌───────────┐ │
  1644.          │               │       │ │     |     │ │
  1645.          │               │       │ │     |     │ │
  1646.          │               │       │ │     v     │ │
  1647.          │               │       │ │-->     <--│ │
  1648.          │               │       │ │     ^     │ │
  1649.          │               │       │ │     |     │ │
  1650.          │               │       │ │     |     │ │
  1651.          │               │       │ └───────────┘ │
  1652.          ├───────────────┼───────┼───────────────┤
  1653.          │BRICKS         │   3   │ ┌───────────┐ │
  1654.          │               │       │ │█     █    │ │
  1655.          │               │       │ │ █         │ │
  1656.          │               │       │ │     █     │ │
  1657.          │               │       │ │        █  │ │
  1658.          │               │       │ │  █  █     │ │
  1659.          │               │       │ │█        █ │ │
  1660.          │               │       │ └───────────┘ │
  1661.          ├───────────────┼───────┼───────────────┤
  1662.          │               │       │       ^       │
  1663.          │MIDDLEROWOUT   │   4   │       │       │
  1664.          │               │       │  ┌──────────┐ │
  1665.          │               │       │  └──────────┘ │
  1666.          │               │       │       │       │
  1667.          │               │       │       v       │
  1668.          ├───────────────┼───────┼───────────────┤
  1669.          │TOPBOTTOMIN    │   5   │  ┌──────────┐ │
  1670.          │               │       │  └──────────┘ │
  1671.          │               │       │       │       │
  1672.          │               │       │       v       │
  1673.          │               │       │       ^       │
  1674.          │               │       │       │       │
  1675.          │               │       │  ┌──────────┐ │
  1676.          │               │       │  └──────────┘ │
  1677.          ├───────────────┼───────┼───────────────┤
  1678.          │TOPDOWN        │   6   │  ┌──────────┐ │
  1679.          │               │       │  └──────────┘ │
  1680.          │               │       │       |       │
  1681.          │               │       │       v       │
  1682.          ├───────────────┼───────┼───────────────┤
  1683.          │               │       │       ^       │
  1684.          │BOTTOMUP       │   7   │       |       │
  1685.          │               │       │  ┌──────────┐ │
  1686.          │               │       │  └──────────┘ │
  1687.          └───────────────┴───────┴───────────────┘
  1688.  
  1689.  
  1690.          Page 15          The C Window Library               Page 15
  1691.  
  1692.          Defined Constant   Value      Effect
  1693.          ┌───────────────┬───────┬───────────────┐
  1694.          │MIDDLECOLOUT   │   8   │      ┌┐       │
  1695.          │               │       │      ││       │
  1696.          │               │       │      ││       │
  1697.          │               │       │    <-││->     │
  1698.          │               │       │      ││       │
  1699.          │               │       │      ││       │
  1700.          │               │       │      └┘       │
  1701.          ├───────────────┼───────┼───────────────┤
  1702.          │LEFTRIGHTIN    │   9   │  ┌┐      ┌┐   │
  1703.          │               │       │  ││      ││   │
  1704.          │               │       │  ││      ││   │
  1705.          │               │       │  ││->  <-││   │
  1706.          │               │       │  ││      ││   │
  1707.          │               │       │  ││      ││   │
  1708.          │               │       │  └┘      └┘   │
  1709.          ├───────────────┼───────┼───────────────┤
  1710.          │LEFTTORIGHT    │  10   │      ┌┐       │
  1711.          │               │       │      ││       │
  1712.          │               │       │      ││       │
  1713.          │               │       │      ││->     │
  1714.          │               │       │      ││       │
  1715.          │               │       │      ││       │
  1716.          │               │       │      └┘       │
  1717.          ├───────────────┼───────┼───────────────┤
  1718.          │RIGHTTOLEFT    │  11   │      ┌┐       │
  1719.          │               │       │      ││       │
  1720.          │               │       │      ││       │
  1721.          │               │       │    <-││       │
  1722.          │               │       │      ││       │
  1723.          │               │       │      ││       │
  1724.          │               │       │      └┘       │
  1725.          ├───────────────┼───────┼───────────────┤
  1726.          │SLIDELEFT      │  12   │  ╔═════════╗  │
  1727.          │               │       │  ║         ║  │
  1728.          │               │       │  ║    ┌────╢  │
  1729.          │               │       │  ║    │    ║  │
  1730.          │               │       │  ║    │<───╢  │
  1731.          │               │       │  ║    │    ║  │
  1732.          │               │       │  ║    └────╢  │
  1733.          │               │       │  ║         ║  │
  1734.          │               │       │  ╚═════════╝  │
  1735.          ├───────────────┼───────┼───────────────┤
  1736.          │SLIDERIGHT     │  13   │  ╔═════════╗  │
  1737.          │               │       │  ║         ║  │
  1738.          │               │       │  ╟────┐    ║  │
  1739.          │               │       │  ║    │    ║  │
  1740.          │               │       │  ╟──> │    ║  │
  1741.          │               │       │  ║    │    ║  │
  1742.          │               │       │  ╟────┘    ║  │
  1743.          │               │       │  ║         ║  │
  1744.          │               │       │  ╚═════════╝  │
  1745.          └───────────────┴───────┴───────────────┘
  1746.  
  1747.  
  1748.  
  1749.  
  1750.          Page 16          The C Window Library               Page 16
  1751.  
  1752.          ┌───────────────┬───────┬───────────────┐
  1753.          │SLIDEDOWN      │  14   │  ╔══╤═╤═╤══╗  │
  1754.          │               │       │  ║  │ │ │  ║  │
  1755.          │               │       │  ║  │ V │  ║  │
  1756.          │               │       │  ║  └───┘  ║  │
  1757.          │               │       │  ║         ║  │
  1758.          │               │       │  ║         ║  │
  1759.          │               │       │  ╚═════════╝  │
  1760.          ├───────────────┼───────┼───────────────┤
  1761.          │SLIDEUP        │  15   │  ╔═════════╗  │
  1762.          │               │       │  ║         ║  │
  1763.          │               │       │  ║  ┌───┐  ║  │
  1764.          │               │       │  ║  │   │  ║  │
  1765.          │               │       │  ║  │ ^ │  ║  │
  1766.          │               │       │  ║  │ │ │  ║  │
  1767.          │               │       │  ╚══╧═╧═╧══╝  │
  1768.          └───────────────┴───────┴───────────────┘
  1769.  
  1770.  
  1771.          The last four effects, SLIDELEFT, SLIDERIGHT, SLIDEUP, and
  1772.          SLIDEDOWN slide a window that is initially out of view of the
  1773.          desktop window or the parent window into view.  Note that the
  1774.          illustrations above use boxes with single lines to denote the
  1775.          actual window, and the double box lines represent the desktop
  1776.          or parent window for the SLIDE... effects.
  1777.  
  1778.  
  1779.          Return Values for WindowDisplay():
  1780.  
  1781.              Return Value         Definition
  1782.          ┌────────────────┬────────────────────────┐
  1783.          │NO_ERROR        │ No error occured.      │
  1784.          ├────────────────┼────────────────────────┤
  1785.          │BAD_WINDOW      │ Window does not exist. │
  1786.          └────────────────┴────────────────────────┘
  1787.  
  1788.  
  1789.  
  1790.          Displaying Multiple Windows
  1791.          ---------------------------
  1792.  
  1793.          If you are creating multiple windows you can change the rank
  1794.          of the window by calling WindowDisplay() with a different
  1795.          rank number.  Here is an example:
  1796.  
  1797.  
  1798.  
  1799.          #include "cwlwin.h"
  1800.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1801.          #define BLUEONBLACK  CREATE_VIDEO_ATTRIBUTE(BLACK_,BLUE_)
  1802.          #define REDONBLACK   CREATE_VIDEO_ATTRIBUTE(BLACK_,RED_)
  1803.          #define GREENONBLACK CREATE_VIDEO_ATTRIBUTE(BLACK_,GREEN_)
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.          Page 17          The C Window Library               Page 17
  1811.  
  1812.          main()
  1813.          {
  1814.            int i;
  1815.            WPOINTER w1,w2,w3; /* pointers to a window structures */
  1816.            WindowInitializeSystem();
  1817.            WindowInitDesktop(0);
  1818.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,15,
  1819.                                  BLUEONBLACK,NORM,SINGLEBOX);
  1820.  
  1821.            /* define second window */
  1822.            w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,3,3,30,15,
  1823.                                  REDONBLACK,NORM,DOUBLEBOX);
  1824.  
  1825.            /* define third window */
  1826.            w3 = WindowInitialize(DESKTOP_WINDOW,BORDER,6,6,30,15,
  1827.                                  GREENONBLACK,NORM,SINGLEBOX);
  1828.  
  1829.            WindowDisplay(w1,1,NOEFFECT);
  1830.            WindowDisplay(w2,2,NOEFFECT);
  1831.            WindowDisplay(w3,3,NOEFFECT);
  1832.  
  1833.            GET_KEY();
  1834.            WindowDisplay(w2,1,NOEFFECT);
  1835.            GET_KEY();
  1836.            WindowDisplay(w3,1,NOEFFECT);
  1837.            GET_KEY();
  1838.            WindowDisplay(w1,1,NOEFFECT);
  1839.            GET_KEY();
  1840.          }
  1841.  
  1842.  
  1843.          In the above program, w1, w2, and w3 are displayed with rank
  1844.          numbers of 1, 2, and 3, respectively.  The ordering means
  1845.          that w1 will overlay w2, and w2 will overlay w3.
  1846.  
  1847.          Note that after the windows w1, w2, and w3 are initially
  1848.          displayed, they are redisplayed by making another call to
  1849.          WindowDisplay().  You can redisplay a window and change its
  1850.          rank by calling the WindowDisplay() function again.  For
  1851.          example, w2 is redisplayed with a rank of 1.  This promotes
  1852.          w2 to the top of the stack of displayed windows within the
  1853.          parent window, and demotes w1 with a rank of 2.  Each and
  1854.          every window has a unique rank number.  The window manager
  1855.          keeps track of conflicts in rank numbers, and adjusts the
  1856.          data structures involved in maintaining the windows in
  1857.          working order.  Therefore, there is really no need for you to
  1858.          remember whether a rank number is used or not.
  1859.  
  1860.          The macro GET_KEY() pauses the program until you press a key.
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.          Page 18          The C Window Library               Page 18
  1871.  
  1872.                            CLOSING WINDOWS
  1873.                            ---------------
  1874.  
  1875.          In this section, we will discuss closing windows.
  1876.  
  1877.  
  1878.  
  1879.          WindowClose()
  1880.          -------------
  1881.  
  1882.          The WindowClose() function removes the window from the
  1883.          display (if it is displayed) and deallocates all memory
  1884.          used by the window.  This effectively renders the WPOINTER
  1885.          useless unless it is assigned to another window, or a
  1886.          window is created again.
  1887.  
  1888.  
  1889.                    int WindowClose(WPOINTER w, int effect)
  1890.  
  1891.          The first argument is the window.  The second argument is
  1892.          the special effect to use when closing the window.  This
  1893.          argument is only meaningful if the window is visible.  For a
  1894.          list of effects refer back to the DISPLAYING WINDOWS
  1895.          section.
  1896.  
  1897.          Example:
  1898.  
  1899.           #include "cwlwin.h"
  1900.           #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1901.           #define BLUEONBLACK  CREATE_VIDEO_ATTRIBUTE(BLACK_,BLUE_)
  1902.           #define REDONBLACK   CREATE_VIDEO_ATTRIBUTE(BLACK_,RED_)
  1903.           #define GREENONBLACK CREATE_VIDEO_ATTRIBUTE(BLACK_,GREEN_)
  1904.  
  1905.           main()
  1906.           {
  1907.             int i;
  1908.             WPOINTER w1,w2,w3;
  1909.             WindowInitializeSystem();
  1910.             WindowInitDesktop(0);
  1911.             w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,15,
  1912.                                   BLUEONBLACK,NORM,SINGLEBOX);
  1913.  
  1914.             /* define second window */
  1915.             w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,3,3,30,15,
  1916.                                   REDONBLACK,NORM,DOUBLEBOX);
  1917.  
  1918.             /* define third window */
  1919.             w3 = WindowInitialize(DESKTOP_WINDOW,BORDER,6,6,30,15,
  1920.                                   GREENONBLACK,NORM,SINGLEBOX);
  1921.  
  1922.             WindowDisplay(w1,1,NOEFFECT);
  1923.             WindowDisplay(w2,2,NOEFFECT);
  1924.             WindowDisplay(w3,3,NOEFFECT);
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.          Page 19          The C Window Library               Page 19
  1931.  
  1932.             GET_KEY();
  1933.             WindowDisplay(w2,1,NOEFFECT);
  1934.             GET_KEY();
  1935.             WindowDisplay(w3,1,NOEFFECT);
  1936.             GET_KEY();
  1937.             WindowDisplay(w1,1,NOEFFECT);
  1938.             GET_KEY();
  1939.             WindowClose(w2,NOEFFECT);
  1940.             GET_KEY();
  1941.             WindowClose(w3,NOEFFECT);
  1942.             GET_KEY();
  1943.             WindowClose(w1,NOEFFECT);
  1944.           }
  1945.  
  1946.  
  1947.          The example above calls WindowClose() on all three windows.
  1948.  
  1949.          Return Values for WindowClose():
  1950.  
  1951.              Return Value         Definition
  1952.          ┌────────────────┬────────────────────────┐
  1953.          │NO_ERROR        │ No error occured.      │
  1954.          ├────────────────┼────────────────────────┤
  1955.          │BAD_WINDOW      │ Window does not exist. │
  1956.          └────────────────┴────────────────────────┘
  1957.  
  1958.  
  1959.  
  1960.          WindowCloseAll()
  1961.          ----------------
  1962.  
  1963.          The WindowCloseAll() function acts just like WindowClose()
  1964.          function except that all windows are destroyed on a desired
  1965.          video page.  Here is the prototype:
  1966.  
  1967.                       int WindowCloseAll(int page, int effect)
  1968.  
  1969.          The page argument is the video page of where the windows are
  1970.          located.  Remember that The C Window Library allows
  1971.          displaying windows on video pages other than page 0 (default
  1972.          page).  The effect argument is the special effect to use
  1973.          when closing the window.  Refer to DISPLAYING WINDOWS for
  1974.          the list of special effects.
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.          Page 20          The C Window Library               Page 20
  1991.  
  1992.          Example:
  1993.  
  1994.          #include "cwlwin.h"
  1995.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1996.          #define BLUEONBLACK  CREATE_VIDEO_ATTRIBUTE(BLACK_,BLUE_)
  1997.          #define REDONBLACK   CREATE_VIDEO_ATTRIBUTE(BLACK_,RED_)
  1998.          #define GREENONBLACK CREATE_VIDEO_ATTRIBUTE(BLACK_,GREEN_)
  1999.  
  2000.          main()
  2001.          {
  2002.            int i;
  2003.            WPOINTER w1,w2,w3;
  2004.            WindowInitializeSystem();
  2005.            WindowInitDesktop(0);
  2006.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,15,
  2007.                                  BLUEONBLACK,NORM,SINGLEBOX);
  2008.            /* define second window */
  2009.            w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,3,3,30,15,
  2010.                                  REDONBLACK,NORM,DOUBLEBOX);
  2011.            /* define third window */
  2012.            w3 = WindowInitialize(DESKTOP_WINDOW,BORDER,5,5,30,15,
  2013.                                  GREENONBLACK,NORM,SINGLEBOX);
  2014.  
  2015.            WindowDisplay(w1,1,NOEFFECT);
  2016.            WindowDisplay(w2,2,NOEFFECT);
  2017.            WindowDisplay(w3,3,NOEFFECT);
  2018.            WindowCloseAll(0,NOEFFECT);  /* close all the windows */
  2019.          }
  2020.  
  2021.  
  2022.          The example above calls WindowCloseAll() to close all three
  2023.          windows.
  2024.  
  2025.          Refer to WindowClose() for return values.
  2026.  
  2027.  
  2028.  
  2029.          WindowUninitSystem()
  2030.          --------------------
  2031.  
  2032.          The WindowUninitSystem() frees any memory that was
  2033.          allocated by The C Window Library functions.  This includes
  2034.          memory used for windows, virtual windows, menus, and other
  2035.          memory areas used for temporary storage.  This function
  2036.          should be called right before termination of a program.  Even
  2037.          though the MSDOS operating system frees any allocated memory
  2038.          when a program terminates, it is still a good idea to call
  2039.          WindowUninitSystem().  A prototype of this function is
  2040.          as follows:
  2041.  
  2042.                   void WindowUninitSystem(void)
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.          Page 21          The C Window Library               Page 21
  2051.  
  2052.                           CENTERING WINDOWS
  2053.                           -----------------
  2054.  
  2055.          The C Window Library allows easy centering of windows on
  2056.          the parent or desktop window.
  2057.  
  2058.  
  2059.          WindowCenter()
  2060.          --------------
  2061.  
  2062.          The WindowCenter() function centers a window on the parent or
  2063.          desktop window vertically, horizontally, or both.  Here is
  2064.          the prototype:
  2065.  
  2066.               int WindowCenter(WPOINTER w, int option)
  2067.  
  2068.          The first argument is the window to center, and the second
  2069.          argument tells whether to center the window horizontally,
  2070.          vertically, or both.  The options argument must be one of
  2071.          the following:
  2072.  
  2073.                 Options                  Type of centering
  2074.             ┌─────────────────────────┬────────────────────┐
  2075.             │VERTCENTER               │ vertical           │
  2076.             ├─────────────────────────┼────────────────────┤
  2077.             │HORIZCENTER              │ horizontal         │
  2078.             ├─────────────────────────┼────────────────────┤
  2079.             │VERTCENTER | HORIZCENTER │ both horizontal and│
  2080.             │                         │ vertical           │
  2081.             └─────────────────────────┴────────────────────┘
  2082.  
  2083.          Note the bitwise OR (|) between the constants VERTCENTER and
  2084.          HORIZCENTER for both horizontal and vertical centering.
  2085.          This function can be used on hidden windows.
  2086.  
  2087.  
  2088.  
  2089.          Example:
  2090.  
  2091.          #include "cwlwin.h"
  2092.  
  2093.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2094.  
  2095.          WPOINTER w;
  2096.  
  2097.          main()
  2098.          {
  2099.            WindowInitializeSystem();
  2100.            WindowInitDesktop(0);
  2101.            w =
  2102.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,NORM,
  2103.                             NORM,SINGLEBOX);
  2104.            WindowDisplay(w,1,NOEFFECT);
  2105.            GET_KEY();
  2106.  
  2107.  
  2108.  
  2109.  
  2110.          Page 22          The C Window Library               Page 22
  2111.  
  2112.            WindowCenter(w,VERTCENTER);  /* center vertically */
  2113.            GET_KEY();
  2114.            WindowMove(w,0,0);
  2115.            GET_KEY();
  2116.            WindowCenter(w,HORIZCENTER); /* center horizontally */
  2117.            GET_KEY();
  2118.            WindowMove(w,0,0);
  2119.            GET_KEY();
  2120.            WindowCenter(w,VERTCENTER | HORIZCENTER); /* center both
  2121.                                           horizontal and vertical */
  2122.            GET_KEY();
  2123.            WindowClose(w,NOEFFECT);
  2124.          }
  2125.  
  2126.                   Return Values for WindowCenter():
  2127.  
  2128.              Return Value        Definition
  2129.          ┌────────────────┬────────────────────────┐
  2130.          │NO_ERROR        │ No error occured.      │
  2131.          ├────────────────┼────────────────────────┤
  2132.          │BAD_WINDOW      │ Window does not exist. │
  2133.          └────────────────┴────────────────────────┘
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.          Page 23          The C Window Library               Page 23
  2171.  
  2172.                    CHANGING WINDOW CHARACTERISTICS
  2173.                    -------------------------------
  2174.  
  2175.          In this section, we will discuss changing the window
  2176.          attributes, border style, and the window's height and width.
  2177.  
  2178.  
  2179.          WindowChangeTextAttribute()
  2180.          ---------------------------
  2181.  
  2182.  
  2183.          This function changes the attribute of the text portion of
  2184.          the window.  The text portion is the inside of the window.
  2185.          Here is a prototype:
  2186.  
  2187.             int WindowChangeTextAttribute(WPOINTER w, int color)
  2188.  
  2189.          where w is the WPOINTER to change the text attribute, and
  2190.          color is the new color.  You can use the
  2191.          CREATE_VIDEO_ATTRIBUTE() macro to define the color.
  2192.  
  2193.          Example:
  2194.  
  2195.          #include "cwlwin.h"
  2196.  
  2197.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2198.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2199.  
  2200.          WPOINTER w;
  2201.  
  2202.          main()
  2203.          {
  2204.            WindowInitializeSystem();
  2205.            WindowInitDesktop(0);
  2206.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,
  2207.                                 NORM,NORM,SINGLEBOX);
  2208.            WindowDisplay(w,1,NOEFFECT);
  2209.            GET_KEY();
  2210.            WindowChangeTextAttribute(w,REVERSE);
  2211.          }
  2212.  
  2213.            Return Values for WindowChangeTextAttribute():
  2214.  
  2215.              Return Value         Definition
  2216.          ┌────────────────┬────────────────────────┐
  2217.          │NO_ERROR        │ No error occured.      │
  2218.          ├────────────────┼────────────────────────┤
  2219.          │BAD_WINDOW      │ Window does not exist. │
  2220.          └────────────────┴────────────────────────┘
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.          Page 24          The C Window Library               Page 24
  2231.  
  2232.          WindowChangeBorderAttribute()
  2233.          -----------------------------
  2234.  
  2235.          This function changes the video attribute of the border of
  2236.          the window.  If the window does not have a border, nothing is
  2237.          changed.  Here is a prototype:
  2238.  
  2239.            int WindowChangeBorderAttribute(WPOINTER w, int color)
  2240.  
  2241.          where w is the WPOINTER to change the border attribute, and
  2242.          color is the new color.  You can use the
  2243.          CREATE_VIDEO_ATTRIBUTE() macro to define the color.
  2244.  
  2245.  
  2246.  
  2247.          Example:
  2248.  
  2249.  
  2250.          #include "cwlwin.h"
  2251.  
  2252.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2253.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2254.  
  2255.          WPOINTER w;
  2256.  
  2257.          main()
  2258.          {
  2259.            WindowInitializeSystem();
  2260.            WindowInitDesktop(0);
  2261.            w =
  2262.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,
  2263.                             NORM,NORM,SINGLEBOX);
  2264.            WindowDisplay(w,1,NOEFFECT);
  2265.            GET_KEY();
  2266.            WindowChangeBorderAttribute(w,REVERSE);
  2267.          }
  2268.  
  2269.            Return values for WindowChangeBorderAttribute():
  2270.  
  2271.              Return Value       Definition
  2272.          ┌────────────────┬────────────────────────┐
  2273.          │NO_ERROR        │ No error occured.      │
  2274.          ├────────────────┼────────────────────────┤
  2275.          │BAD_WINDOW      │ Window does not exist. │
  2276.          └────────────────┴────────────────────────┘
  2277.  
  2278.  
  2279.  
  2280.  
  2281.          WindowDrawBorder()
  2282.          ------------------
  2283.  
  2284.          You can also change the border type, or draw a border on an
  2285.          unbordered window by calling the WindowDrawBorder()
  2286.          function.
  2287.  
  2288.  
  2289.  
  2290.          Page 25          The C Window Library               Page 25
  2291.  
  2292.          Here is a prototype:
  2293.  
  2294.              int WindowDrawBorder(WPOINTER w, char *box)
  2295.  
  2296.          The first argument is the window we want to change the
  2297.          border of.  The second argument is a string of border
  2298.          characters.  This string denotes the type of border that the
  2299.          window should now have.  In the example given below, w is
  2300.          initialized with a SINGLEBOX border, but WindowDrawBorder()
  2301.          changes this to a DOUBLEBOX.
  2302.  
  2303.          The WindowDrawBorder() function is also used to draw borders
  2304.          on borderless windows.  When drawing borders on a NOBORDER
  2305.          window, the window must not have any of its sides touching
  2306.          the edges of the physical screen.  In other words, the
  2307.          window must "have room" for a border to be drawn.  If there
  2308.          is no room to draw the border, there is no change to the
  2309.          window.
  2310.  
  2311.          Example:
  2312.  
  2313.  
  2314.          #include "cwlwin.h"
  2315.  
  2316.          #define REVERSE   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2317.  
  2318.          WPOINTER w;
  2319.  
  2320.          main()
  2321.          {
  2322.            WindowInitializeSystem();
  2323.            WindowInitDesktop(0);
  2324.            w =
  2325.            WindowInitialize(DESKTOP_WINDOW,NOBORDER,2,2,10,10,
  2326.                             REVERSE,REVERSE,SINGLEBOX);
  2327.            WindowDisplay(w,1,NOEFFECT);
  2328.            GET_KEY();
  2329.            WindowDrawBorder(w,DOUBLEBOX);  /* Draws a double box
  2330.                                            around NOBORDER window */
  2331.          }
  2332.  
  2333.                 Return values for WindowDrawBorder():
  2334.  
  2335.              Return Value       Definition
  2336.          ┌────────────────┬───────────────────────────────┐
  2337.          │NO_ERROR        │ No error occured.             │
  2338.          ├────────────────┼───────────────────────────────┤
  2339.          │BAD_WINDOW      │ Window does not exist.        │
  2340.          ├────────────────┼───────────────────────────────┤
  2341.          │NO_HEAP_MEM     │ Mot enough memory to allocate.│
  2342.          └────────────────┴───────────────────────────────┘
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.          Page 26          The C Window Library               Page 26
  2351.  
  2352.          WindowRemoveBorder()
  2353.          --------------------
  2354.  
  2355.          This function removes a border from a bordered window.  Here
  2356.          is the prototype:
  2357.  
  2358.               int WindowRemoveBorder(WPOINTER w)
  2359.  
  2360.          If the window does not have a border, nothing is changed.
  2361.  
  2362.          Example:
  2363.  
  2364.          #include "cwlwin.h"
  2365.          #define REVERSE   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2366.  
  2367.          WPOINTER w;
  2368.  
  2369.          main()
  2370.          {
  2371.            WindowInitializeSystem();
  2372.            WindowInitDesktop(0);
  2373.            w =
  2374.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,
  2375.                             REVERSE,REVERSE,SINGLEBOX);
  2376.            WindowDisplay(w,1,NOEFFECT);
  2377.            GET_KEY();
  2378.            WindowRemoveBorder(w);  /* Removes the double box around
  2379.                                       BORDERed window */
  2380.          }
  2381.  
  2382.                Return values for WindowRemoveBorder():
  2383.  
  2384.              Return Value       Definition
  2385.          ┌────────────────┬───────────────────────────────┐
  2386.          │NO_ERROR        │ No error occured.             │
  2387.          ├────────────────┼───────────────────────────────┤
  2388.          │BAD_WINDOW      │ Window does not exist.        │
  2389.          ├────────────────┼───────────────────────────────┤
  2390.          │NO_HEAP_MEM     │ Mot enough memory to allocate.│
  2391.          └────────────────┴───────────────────────────────┘
  2392.  
  2393.  
  2394.          WindowResizeHeight()
  2395.          --------------------
  2396.  
  2397.          This function changes the inside (text portion) height of
  2398.          the window.  Here is a prototype:
  2399.  
  2400.          int WindowResizeHeight(WPOINTER w, int newheight, int anchor)
  2401.  
  2402.          The newheight argument is the new height of the window.  The
  2403.          anchor argument determines which side to "hold down" while
  2404.          the window is being resized.
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.          Page 27          The C Window Library               Page 27
  2411.  
  2412.          If the anchor is ANCHORTOP, the top line of the window is
  2413.          held in its current position and the window is resized
  2414.          accordingly.  If anchor is ANCHORBOTTOM, the bottom of the
  2415.          window is held and the window is resized accordingly.
  2416.  
  2417.          If there is text in the window, the text will be truncated
  2418.          if the window is made shorter (unless the window is a
  2419.          viewport to a virtual window.  Virtual windows are discussed
  2420.          in the VIRTUAL WINDOWS section).
  2421.  
  2422.          Example:
  2423.  
  2424.          #include "cwlwin.h"
  2425.  
  2426.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2427.  
  2428.          WPOINTER w;
  2429.  
  2430.          main()
  2431.          {
  2432.            WindowInitializeSystem();
  2433.            WindowInitDesktop(0);
  2434.            w =
  2435.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,
  2436.                             NORM,NORM,SINGLEBOX);
  2437.            WindowDisplay(w,1,NOEFFECT);
  2438.            GET_KEY();
  2439.            WindowResizeHeight(w,15,ANCHORTOP); /* height now is 15 */
  2440.            GET_KEY();
  2441.            WindowResizeHeight(w,5,ANCHORBOTTOM);/* height is now 5 */
  2442.          }
  2443.  
  2444.  
  2445.                Return values for WindowResizeHeight():
  2446.  
  2447.              Return Value       Definition
  2448.          ┌────────────────┬───────────────────────────────┐
  2449.          │NO_ERROR        │ No error occured.             │
  2450.          ├────────────────┼───────────────────────────────┤
  2451.          │BAD_WINDOW      │ Window does not exist.        │
  2452.          ├────────────────┼───────────────────────────────┤
  2453.          │NO_HEAP_MEM     │ Mot enough memory to allocate.│
  2454.          └────────────────┴───────────────────────────────┘
  2455.  
  2456.  
  2457.          WindowResizeWidth()
  2458.          -------------------
  2459.  
  2460.          This function changes the inside (text portion) width of the
  2461.          window.  Here is a prototype:
  2462.  
  2463.          int WindowResizeWidth(WPOINTER w, int newwidth, int anchor)
  2464.  
  2465.          The newwidth argument is the new width of the window.  The
  2466.          anchor argument determines which side to "hold down" while
  2467.          the window is being resized.
  2468.  
  2469.  
  2470.          Page 28          The C Window Library               Page 28
  2471.  
  2472.          If the anchor is ANCHORLEFT, the left side of the window is
  2473.          held in its current position and the window is resized
  2474.          accordingly.  If anchor is ANCHORRIGHT, the right side of
  2475.          the window is held and the window is resized accordingly.
  2476.  
  2477.          If there is text in the window, the text will be truncated
  2478.          if the window is made shorter (unless the window is a
  2479.          viewport to a virtual window.  Virtual windows are discussed
  2480.          in the VIRTUAL WINDOWS section).
  2481.  
  2482.  
  2483.          main()
  2484.          {
  2485.            WindowInitializeSystem();
  2486.            WindowInitDesktop(0);
  2487.            w =
  2488.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,
  2489.                             NORM,NORM,SINGLEBOX);
  2490.            WindowDisplay(w,1,NOEFFECT);
  2491.            GET_KEY();
  2492.            WindowResizeWidth(w,15,ANCHORLEFT);/* width is now 15 */
  2493.            GET_KEY();
  2494.            WindowResizeWidth(w,5,ANCHORRIGHT);/* width is now 5 */
  2495.          }
  2496.  
  2497.  
  2498.  
  2499.                Return values for WindowResizeWidth():
  2500.  
  2501.              Return Value       Definition
  2502.          ┌────────────────┬───────────────────────────────┐
  2503.          │NO_ERROR        │ No error occured.             │
  2504.          ├────────────────┼───────────────────────────────┤
  2505.          │BAD_WINDOW      │ Window does not exist.        │
  2506.          ├────────────────┼───────────────────────────────┤
  2507.          │NO_HEAP_MEM     │ Mot enough memory to allocate.│
  2508.          └────────────────┴───────────────────────────────┘
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.          Page 29          The C Window Library               Page 29
  2531.  
  2532.                        WRITING TEXT TO WINDOWS
  2533.                        -----------------------
  2534.  
  2535.          There are various functions that will write text to a window.
  2536.          These functions are divided into two groups:  Functions that
  2537.          specify a null terminated string, and functions that require
  2538.          the length of the string of characters to write to be an
  2539.          explicit argument.
  2540.  
  2541.  
  2542.          Null Terminated Write Functions
  2543.          -------------------------------
  2544.  
  2545.          WindowWriteString()
  2546.          -------------------
  2547.  
  2548.          The WindowWriteString() function writes a null terminated
  2549.          string of characters to a window at a specified row and
  2550.          column of the window.  If the string is too long to fit in
  2551.          the boundaries of the window, the string is clipped
  2552.          (truncated) to fit in the boundaries of the window.
  2553.  
  2554.          Here is the prototype:
  2555.  
  2556.          int WindowWriteString(WPOINTER w, char *string, int row,
  2557.                                int col)
  2558.  
  2559.          The first argument is the window to write the string to.  The
  2560.          second argument is the null terminated string to write.  The
  2561.          third and fourth arguments are the row and column of the
  2562.          window to place the string.  The video attribute used when
  2563.          writing the string is the video attribute of the inside of
  2564.          the window.
  2565.  
  2566.  
  2567.          Example:
  2568.  
  2569.  
  2570.          #include "cwlwin.h"
  2571.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2572.  
  2573.          WPOINTER w;
  2574.          int i;
  2575.  
  2576.          main()
  2577.          {
  2578.            WindowInitializeSystem();
  2579.            WindowInitDesktop(0);
  2580.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2581.                                 NORM,NORM,SINGLEBOX);
  2582.            WindowDisplay(w,1,NOEFFECT);
  2583.            GET_KEY();
  2584.            for (i=0;i<=9;i++)
  2585.              WindowWriteString(w,"Hello World",i,0);
  2586.          }
  2587.  
  2588.  
  2589.  
  2590.          Page 30          The C Window Library               Page 30
  2591.  
  2592.          The above example writes the string "Hello World" to each
  2593.          line of the window w.
  2594.  
  2595.                Return values for WindowWriteString():
  2596.  
  2597.              Return Value       Definition
  2598.          ┌────────────────┬─────────────────────────────────┐
  2599.          │NO_ERROR        │ No error occured.               │
  2600.          ├────────────────┼─────────────────────────────────┤
  2601.          │BAD_WINDOW      │ Window does not exist.          │
  2602.          ├────────────────┼─────────────────────────────────┤
  2603.          │WINDOW_BOUND    │ Row or column are out of bounds.│
  2604.          └────────────────┴─────────────────────────────────┘
  2605.  
  2606.  
  2607.  
  2608.          WindowWriteStringAttr()
  2609.          -----------------------
  2610.  
  2611.          The WindowWriteStringAttr() function works the same as the
  2612.          WindowWriteString() function except that an extra argument
  2613.          determines the color used to write the string.  Here is the
  2614.          prototype:
  2615.  
  2616.          int WindowWriteStringAttr(WPOINTER w, char *string, int row,
  2617.                                    int col, int attr)
  2618.  
  2619.          The first argument is the window to write the string to.  The
  2620.          second argument is the null terminated string to write.  The
  2621.          third and fourth arguments are the row and column of the
  2622.          window to place the string. The last argument is the video
  2623.          attribute to use.
  2624.  
  2625.  
  2626.          Example:
  2627.  
  2628.          #include "cwlwin.h"
  2629.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2630.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2631.  
  2632.          WPOINTER w;
  2633.          int i;
  2634.  
  2635.          main()
  2636.          {
  2637.            WindowInitializeSystem();
  2638.            WindowInitDesktop(0);
  2639.            w =
  2640.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2641.                             NORM,NORM,SINGLEBOX);
  2642.            WindowDisplay(w,1,NOEFFECT);
  2643.            GET_KEY();
  2644.            for (i=0;i<=9;i++)
  2645.              WindowWriteStringAttr(w,"Hello World",i,0,REVERSE);
  2646.          }
  2647.  
  2648.  
  2649.  
  2650.          Page 31          The C Window Library               Page 31
  2651.  
  2652.          The above example writes the string "Hello World" to each
  2653.          line of the window w using the video attribute defined by the
  2654.          constant REVERSE.
  2655.  
  2656.          The return values to WindowWriteStringAttr() are the same as
  2657.          WindowWriteString().
  2658.  
  2659.  
  2660.  
  2661.          WindowWriteCenterString()
  2662.          -------------------------
  2663.  
  2664.          The WindowWriteCenterString() function centers a null
  2665.          terminated string in a window.  Here is a prototype:
  2666.  
  2667.          int WindowWriteCenterString(WPOINTER w, char *string,
  2668.                                      int row)
  2669.  
  2670.          The first argument is the window.  The second argument is the
  2671.          string to write.  The third argument is the row that the
  2672.          string will be centered.
  2673.  
  2674.          The attribute used to write the string is the attribute of
  2675.          the inside of the window.
  2676.  
  2677.          Example:
  2678.  
  2679.          #include "cwlwin.h"
  2680.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2681.  
  2682.          WPOINTER w;
  2683.          int i;
  2684.  
  2685.          main()
  2686.          {
  2687.            WindowInitializeSystem();
  2688.            WindowInitDesktop(0);
  2689.            w =
  2690.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2691.                             NORM,NORM,SINGLEBOX);
  2692.            WindowDisplay(w,1,NOEFFECT);
  2693.            GET_KEY();
  2694.            for (i=0;i<=9;i++)
  2695.              WindowWriteCenterString(w,"Hello World",i);
  2696.          }
  2697.  
  2698.  
  2699.  
  2700.          The above example writes and centers the string "Hello World"
  2701.          to each line of the window w.
  2702.  
  2703.          The return values for WindowWriteCenterString() are the same
  2704.          as WindowWriteString().
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.          Page 32          The C Window Library               Page 32
  2711.  
  2712.          WindowWriteCenterStringAttr()
  2713.          -----------------------------
  2714.  
  2715.          The WindowWriteCenterStringAttr() function works the same as
  2716.          the WindowWriteCenterString() function except that an extra
  2717.          argument determines the color used to write the string.  Here
  2718.          is the prototype:
  2719.  
  2720.          int WindowWriteCenterStringAttr(WPOINTER w, char *string,
  2721.                                          int row, int attr)
  2722.  
  2723.          The first argument is the window.  The second argument is the
  2724.          string to write.  The third argument is the row that the
  2725.          string will be centered.  The last argument is the video
  2726.          attribute to use to write the string.
  2727.  
  2728.          Example:
  2729.  
  2730.          #include "cwlwin.h"
  2731.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2732.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2733.  
  2734.          WPOINTER w;
  2735.          int i;
  2736.  
  2737.          main()
  2738.          {
  2739.            WindowInitializeSystem();
  2740.            WindowInitDesktop(0);
  2741.            w =
  2742.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2743.                             NORM,NORM,SINGLEBOX);
  2744.            WindowDisplay(w,1,NOEFFECT);
  2745.            GET_KEY();
  2746.            for (i=0;i<=9;i++)
  2747.              WindowWriteCenterStringAttr(w,"Hello World",i,REVERSE);
  2748.          }
  2749.  
  2750.  
  2751.          The above example writes and centers the string "Hello World"
  2752.          to each line of the window w using REVERSE as the video
  2753.          attribute.
  2754.  
  2755.          The return values for WindowWriteCenterStringAttr() are the
  2756.          same as WindowWriteString().
  2757.  
  2758.  
  2759.          WindowWriteStringCC()
  2760.          ---------------------
  2761.  
  2762.          Centers and writes a string around a column of the window
  2763.          (the CC stands for Centered Column).  If the string is longer
  2764.          than the width of the window, the string is placed on column
  2765.          1 of the window and is clipped at the right edge of the
  2766.          window.  Here is the prototype:
  2767.  
  2768.  
  2769.  
  2770.          Page 33          The C Window Library               Page 33
  2771.  
  2772.          The attribute used to write the string is the attribute of
  2773.          the inside of the window.
  2774.  
  2775.          int WindowWriteStringCC(WPOINTER w, char *string, int row)
  2776.  
  2777.          The first argument is the window.  The second argument is the
  2778.          string. The third argument is the row to write the string,
  2779.          and the last argument is the column to center the string on.
  2780.  
  2781.  
  2782.          Example:
  2783.  
  2784.  
  2785.          #include "cwlwin.h"
  2786.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2787.  
  2788.          WPOINTER w;
  2789.  
  2790.          main()
  2791.          {
  2792.            WindowInitializeSystem();
  2793.            WindowInitDesktop(0);
  2794.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2795.                                 NORM,NORM,SINGLEBOX);
  2796.            WindowDisplay(w,1,NOEFFECT);
  2797.            GET_KEY();
  2798.            WindowWriteStringCC(w,"This",0,10);
  2799.            WindowWriteStringCC(w,"is",1,10);
  2800.            WindowWriteStringCC(w,"centered",2,10);
  2801.            WindowWriteStringCC(w,"around",3,10);
  2802.            WindowWriteStringCC(w,"column",4,10);
  2803.            WindowWriteStringCC(w,"10",5,10);
  2804.          }
  2805.  
  2806.          The example above writes the text centered around column 10
  2807.          of the window w.
  2808.  
  2809.          The return values for WindowWriteStringCC() are the same as
  2810.          WindowWriteString().
  2811.  
  2812.  
  2813.  
  2814.  
  2815.          WindowWriteStringCCAttr()
  2816.          -------------------------
  2817.  
  2818.          The WindowWriteStringCCAttr() function works the same as the
  2819.          WindowWriteStringCC() function except that an extra argument
  2820.          determines the color used to write the string.  Here is the
  2821.          prototype:
  2822.  
  2823.          int WindowWriteStringCCAttr(WPOINTER w, char *string,
  2824.                                      int row, int col, int attr)
  2825.  
  2826.          The first argument is the window.  The second argument is the
  2827.  
  2828.  
  2829.  
  2830.          Page 34          The C Window Library               Page 34
  2831.  
  2832.          string to write.  The third argument is the row that the
  2833.          string will be centered.  The column argument is the column
  2834.          to center the string on. The last argument is the video
  2835.          attribute to use to write the string.
  2836.  
  2837.          Example:
  2838.  
  2839.  
  2840.          #include "cwlwin.h"
  2841.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2842.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2843.  
  2844.          WPOINTER w;
  2845.  
  2846.          main()
  2847.          {
  2848.            WindowInitializeSystem();
  2849.            WindowInitDesktop(0);
  2850.            w =
  2851.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2852.                             NORM,NORM,SINGLEBOX);
  2853.            WindowDisplay(w,1,NOEFFECT);
  2854.            GET_KEY();
  2855.            WindowWriteStringCCAttr(w,"This",0,10,REVERSE);
  2856.            WindowWriteStringCCAttr(w,"is",1,10,REVERSE);
  2857.            WindowWriteStringCCAttr(w,"centered",2,10,REVERSE);
  2858.            WindowWriteStringCCAttr(w,"around",3,10,REVERSE);
  2859.            WindowWriteStringCCAttr(w,"column",4,10,REVERSE);
  2860.            WindowWriteStringCCAttr(w,"10",5,10,REVERSE);
  2861.          }
  2862.  
  2863.  
  2864.  
  2865.          The example above writes the text centered around column 10
  2866.          of the window w using the video attribute REVERSE.
  2867.  
  2868.          The return values for WindowWriteStringCCAttr() are the same
  2869.          as WindowWriteString().
  2870.  
  2871.  
  2872.  
  2873.          WindowWriteStringRJ()
  2874.          ---------------------
  2875.  
  2876.          The WindowWriteStringRJ() function writes a right justified
  2877.          string.  Here is the prototype:
  2878.  
  2879.          int WindowWriteStringRJ(WPOINTER w, char *string, int row,
  2880.                                  int col)
  2881.  
  2882.          The first argument is the window.  The second argument is the
  2883.          string. The third argument is the row to write the string,
  2884.          and the last argument is the column to place the right edge
  2885.          of the string.
  2886.  
  2887.  
  2888.  
  2889.  
  2890.          Page 35          The C Window Library               Page 35
  2891.  
  2892.          Example:
  2893.  
  2894.          #include "cwlwin.h"
  2895.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2896.  
  2897.          WPOINTER w;
  2898.  
  2899.          main()
  2900.          {
  2901.            WindowInitializeSystem();
  2902.            WindowInitDesktop(0);
  2903.            w =
  2904.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2905.                             NORM,NORM,SINGLEBOX);
  2906.            WindowDisplay(w,1,NOEFFECT);
  2907.            GET_KEY();
  2908.            WindowWriteStringRJ(w,"This",0,10);
  2909.            WindowWriteStringRJ(w,"is",1,10);
  2910.            WindowWriteStringRJ(w,"right",2,10);
  2911.            WindowWriteStringRJ(w,"justified",3,10);
  2912.            WindowWriteStringRJ(w,"on ",4,10);
  2913.            WindowWriteStringRJ(w,"column",5,10);
  2914.            WindowWriteStringRJ(w,"10",6,10);
  2915.          }
  2916.  
  2917.  
  2918.          The example above writes the text right justified on column
  2919.          10 of the window w.
  2920.  
  2921.          The attribute used to write the string is the attribute of
  2922.          the inside of the window.
  2923.  
  2924.          The return values for WindowWriteStringRJ() are the same as
  2925.          WindowWriteString().
  2926.  
  2927.  
  2928.  
  2929.          WindowWriteStringRJAttr()
  2930.          -------------------------
  2931.  
  2932.          The WindowWriteStringRJAttr() function works the same as the
  2933.          WindowWriteStringRJ() function except that an extra argument
  2934.          determines the color used to write the string.  Here is the
  2935.          prototype:
  2936.  
  2937.          int WindowWriteStringRJAttr(WPOINTER w, char *string,
  2938.                                      int row, int col, int attr)
  2939.  
  2940.          The first argument is the window.  The second argument is the
  2941.          string to write.  The third argument is the row to write the
  2942.          string.  The col is the column to right justify the string.
  2943.          The last argument is the video attribute to use to write the
  2944.          string.
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.          Page 36          The C Window Library               Page 36
  2951.  
  2952.  
  2953.          Example:
  2954.  
  2955.          #include "cwlwin.h"
  2956.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2957.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  2958.  
  2959.          WPOINTER w;
  2960.  
  2961.          main()
  2962.          {
  2963.            WindowInitializeSystem();
  2964.            WindowInitDesktop(0);
  2965.            w =
  2966.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  2967.                             NORM,NORM,SINGLEBOX);
  2968.            WindowDisplay(w,1,NOEFFECT);
  2969.            GET_KEY();
  2970.            WindowWriteStringRJAttr(w,"This",0,10,REVERSE);
  2971.            WindowWriteStringRJAttr(w,"is",1,10,REVERSE);
  2972.            WindowWriteStringRJAttr(w,"right",2,10,REVERSE);
  2973.            WindowWriteStringRJAttr(w,"justified",3,10,REVERSE);
  2974.            WindowWriteStringRJAttr(w,"on ",4,10,REVERSE);
  2975.            WindowWriteStringRJAttr(w,"column",5,10,REVERSE);
  2976.            WindowWriteStringRJAttr(w,"10",7,6,REVERSE);
  2977.          }
  2978.  
  2979.  
  2980.          The example above writes the text right justified at  column
  2981.          10 of the window w using the video attribute REVERSE.
  2982.  
  2983.          The return values for WindowWriteStringRJAttr() are the same
  2984.          as WindowWriteString().
  2985.  
  2986.  
  2987.  
  2988.  
  2989.          Length Controlled Write Functions
  2990.          ---------------------------------
  2991.  
  2992.          The upcoming functions must have the length explicitly stated
  2993.          as one of the arguments.  These functions do not stop writing
  2994.          characters if the null character in the string to write is
  2995.          reached.
  2996.  
  2997.  
  2998.  
  2999.          WindowWriteCharacters()
  3000.          -----------------------
  3001.  
  3002.          This function writes characters from a buffer to the window.
  3003.          Here is the prototype:
  3004.  
  3005.          int WindowWriteCharacters(WPOINTER w, char *buffer, int row,
  3006.                                    int col, int length)
  3007.  
  3008.          The first argument is the window.  The second argument is a
  3009.  
  3010.          Page 37          The C Window Library               Page 37
  3011.  
  3012.          pointer to the buffer where the characters are stored.  The
  3013.          third and fourth arguments are the (row,col) position in the
  3014.          window to write the string, and the last argument is the
  3015.          number of characters from buffer to write.  The attribute
  3016.          used is the attribute of the inside of the window.
  3017.  
  3018.  
  3019.          Example:
  3020.  
  3021.          #include "cwlwin.h"
  3022.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3023.  
  3024.          WPOINTER w;
  3025.          char buf[] = "Hello World!!";
  3026.  
  3027.          main()
  3028.          {
  3029.            WindowInitializeSystem();
  3030.            WindowInitDesktop(0);
  3031.            w =
  3032.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3033.                             NORM,NORM,SINGLEBOX);
  3034.            WindowDisplay(w,1,NOEFFECT);
  3035.            GET_KEY();
  3036.            WindowWriteCharacters(w,buf,0,0,11);
  3037.            WindowWriteCharacters(w,buf,1,0,13);
  3038.          }
  3039.  
  3040.  
  3041.          The return values for WindowWriteCharacters() are the same as
  3042.          WindowWriteString().
  3043.  
  3044.  
  3045.  
  3046.  
  3047.          WindowWriteAttributes()
  3048.          -----------------------
  3049.  
  3050.          This function writes attributes from a buffer to the window.
  3051.          Here is the prototype:
  3052.  
  3053.          int WindowWriteAttributes(WPOINTER w, char *buffer, int row,
  3054.                                    int col, int length)
  3055.  
  3056.          The first argument is the window.  The second argument is a
  3057.          pointer to the buffer where the attributes are stored.  The
  3058.          third and fourth arguments are the (row,col) position in the
  3059.          window to write the string, and the last argument is the
  3060.          number of attributes from buffer to write.
  3061.  
  3062.  
  3063.          Example:
  3064.  
  3065.          #include "cwlwin.h"
  3066.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3067.  
  3068.  
  3069.  
  3070.          Page 38          The C Window Library               Page 38
  3071.  
  3072.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3073.  
  3074.  
  3075.          WPOINTER w;
  3076.          char buf[13];
  3077.  
  3078.          main()
  3079.          {
  3080.            int i;
  3081.            WindowInitializeSystem();
  3082.            WindowInitDesktop(0);
  3083.            w =
  3084.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3085.                             NORM,NORM,SINGLEBOX);
  3086.            WindowDisplay(w,1,NOEFFECT);
  3087.            for (i=0;i<13;i++)
  3088.              if (i % 2)
  3089.                buf[i] = NORM;
  3090.              else
  3091.                buf[i] = REVERSE;
  3092.  
  3093.            WindowWriteString(w,"Hello World!!",0,0);
  3094.            GET_KEY();
  3095.            WindowWriteAttributes(w,buf,0,0,13);  /* Writes alternating
  3096.                                                     NORM and REVERSE
  3097.                                                     attributes */
  3098.          }
  3099.  
  3100.  
  3101.          The return values for WindowWriteAttributes() are the same as
  3102.          WindowWriteString().
  3103.  
  3104.  
  3105.  
  3106.  
  3107.          WindowWriteCharAndAttr()
  3108.          ------------------------
  3109.  
  3110.          The WindowWriteCharAndAttr() function writes a string of
  3111.          character/attribute pairs to a window.  Use this function if
  3112.          you have created a string of character/attribute pairs, and
  3113.          want to output them easily.  The string consists of character
  3114.          and attributes in the following manner:
  3115.  
  3116.                   char-attr-char-attr...
  3117.  
  3118.          Each character is followed by its corresponding video
  3119.          attribute.
  3120.  
  3121.  
  3122.          Here is the prototype:
  3123.  
  3124.          int WindowWriteCharAndAttr(WPOINTER w, char *buffer, int row,
  3125.                                     int col, int length)
  3126.  
  3127.  
  3128.          The first argument is the window. The second is the buffer
  3129.  
  3130.          Page 39          The C Window Library               Page 39
  3131.  
  3132.          where the character and attributes are stored.  The third and
  3133.          fourth is the (row,col) position in the window to write, and
  3134.          the length argument is the number of character/attribute
  3135.          pairs from the buffer to write.  Please note the difference
  3136.          in the meaning of the length argument in this function as
  3137.          opposed to its use in the preceding functions.
  3138.  
  3139.  
  3140.          Example:
  3141.  
  3142.  
  3143.          #include "cwlwin.h"
  3144.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3145.  
  3146.          WPOINTER w;
  3147.          char buf[26];
  3148.          char *str = "Hello World!!";
  3149.          main()
  3150.          {
  3151.            int i;
  3152.            WindowInitializeSystem();
  3153.            WindowInitDesktop(0);
  3154.            w =
  3155.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3156.                             NORM,NORM,SINGLEBOX);
  3157.            WindowDisplay(w,1,NOEFFECT);
  3158.  
  3159.            for (i=0;i<26;i+=2,str++)
  3160.            {
  3161.              buf[i] = *str;
  3162.              buf[i+1] = NORM;
  3163.            }
  3164.  
  3165.            WindowWriteCharAndAttr(w,buf,0,0,13);
  3166.          }
  3167.  
  3168.  
  3169.          The return values for WindowWriteCharAndAttr() are the same as
  3170.          WindowWriteString().
  3171.  
  3172.  
  3173.  
  3174.          WindowWriteCharactersAttr()
  3175.          ---------------------------
  3176.  
  3177.          The WindowWriteCharactersAttr() function writes characters
  3178.          from a buffer to a window.  The difference between this
  3179.          function and WindowWriteCharacters() is that a video
  3180.          attribute is specified.  Here is the prototype:
  3181.  
  3182.          int WindowWriteCharactersAttr(WPOINTER w, char *buffer,
  3183.                                        int row, int col, int attr,
  3184.                                        int length)
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.          Page 40          The C Window Library               Page 40
  3191.  
  3192.          The attr argument is the video attribute to use when writing
  3193.          the characters.
  3194.  
  3195.          Example:
  3196.  
  3197.          #include "cwlwin.h"
  3198.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3199.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3200.  
  3201.          WPOINTER w;
  3202.          char buf[] = "Hello World!!";
  3203.  
  3204.          main()
  3205.          {
  3206.            WindowInitializeSystem();
  3207.            WindowInitDesktop(0);
  3208.            w =
  3209.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3210.                             NORM,NORM,SINGLEBOX);
  3211.            WindowDisplay(w,1,NOEFFECT);
  3212.            GET_KEY();
  3213.            WindowWriteCharactersAttr(w,buf,1,0,REVERSE,13);
  3214.          }
  3215.  
  3216.  
  3217.          The return values for WindowWriteCharactersAttr() are the
  3218.          same as WindowWriteString().
  3219.  
  3220.  
  3221.  
  3222.          WindowWriteRepeatAttribute()
  3223.          ----------------------------
  3224.  
  3225.          The WindowWriteRepeatAttribute() function writes an attribute
  3226.          a specified number of times to a window.  Here is a
  3227.          prototype:
  3228.  
  3229.          int WindowWriteRepeatAttribute(WPOINTER w, int attr, int row,
  3230.                                         int col, int count)
  3231.  
  3232.  
  3233.          The attr argument is the attribute to use.  The count
  3234.          argument specifies the number of times to write the attribute
  3235.          attr to the window starting at (row,col).
  3236.  
  3237.          Example:
  3238.  
  3239.          #include "cwlwin.h"
  3240.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3241.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3242.  
  3243.          WPOINTER w;
  3244.  
  3245.  
  3246.  
  3247.  
  3248.  
  3249.  
  3250.          Page 41          The C Window Library               Page 41
  3251.  
  3252.          main()
  3253.          {
  3254.            WindowInitializeSystem();
  3255.            WindowInitDesktop(0);
  3256.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3257.                                 NORM,NORM,SINGLEBOX);
  3258.            WindowDisplay(w,1,NOEFFECT);
  3259.            WindowWriteString(w,"Hello World!!",0,0);
  3260.            GET_KEY();
  3261.            WindowWriteRepeatAttribute(w,REVERSE,0,0,13);
  3262.          }
  3263.  
  3264.  
  3265.          The example above illustrates that the
  3266.          WindowWriteRepeatAttribute() writes the REVERSE attribute 13
  3267.          times starting at row 0, column 0 of the window w.
  3268.  
  3269.          The return values for WindowWriteRepeatAttribute() are the
  3270.          same as WindowWriteString().
  3271.  
  3272.  
  3273.  
  3274.  
  3275.          WindowWriteRepeatCharacter()
  3276.          ----------------------------
  3277.  
  3278.          The WindowWriteRepeatCharacter() function writes a character
  3279.          a specified number of times to a window.  Here is a
  3280.          prototype:
  3281.  
  3282.          int WindowWriteRepeatCharacter(WPOINTER w, int ch, int row,
  3283.                                         int col, int count)
  3284.  
  3285.          The count argument is the character to use.  The count
  3286.          argument specifies the number of times to write the character
  3287.          ch to the window starting at (row,col).
  3288.  
  3289.          #include "cwlwin.h"
  3290.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3291.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3292.  
  3293.          WPOINTER w;
  3294.  
  3295.          main()
  3296.          {
  3297.            WindowInitializeSystem();
  3298.            WindowInitDesktop(0);
  3299.            w =
  3300.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3301.                             NORM,NORM,SINGLEBOX);
  3302.            WindowDisplay(w,1,NOEFFECT);
  3303.            WindowWriteRepeatCharacter(w,'a',0,0,5);
  3304.            WindowWriteRepeatCharacter(w,'b',1,0,5);
  3305.            WindowWriteRepeatCharacter(w,'c',2,0,5);
  3306.          }
  3307.  
  3308.  
  3309.  
  3310.          Page 42          The C Window Library               Page 42
  3311.  
  3312.          The example above illustrates that the
  3313.          WindowWriteRepeatCharacter() writes the letter 'a', 'b', and
  3314.          'c' 5 times on rows 0, 1, and 2 respectively.
  3315.  
  3316.  
  3317.          The return values for WindowWriteRepeatCharacter() are the
  3318.          same as WindowWriteString().
  3319.  
  3320.  
  3321.  
  3322.          Formatted Write Functions
  3323.          -------------------------
  3324.  
  3325.          These functions write formatted output to windows just like
  3326.          the printf() function.  There are two functions that do this,
  3327.          namely WindowPrintf() and WindowPrintfAttr().  These
  3328.          functions use a format string that is similar to the format
  3329.          string found in printf().  For example, %d, %s, %lf, etc. and
  3330.          most of the escape sequences are supported.  The list of
  3331.          escape sequences supported are as follows:
  3332.  
  3333.                                \n - newline
  3334.                                \b - backspace
  3335.                                \t - tab
  3336.                                \a - bell
  3337.                                \r - carriage return
  3338.                                \x - hexadecimal
  3339.  
  3340.  
  3341.          Where output is placed in the window
  3342.          ------------------------------------
  3343.  
  3344.          The row and column of where the string will be written is
  3345.          determined by the window's logical cursor.  The logical
  3346.          cursor is advanced by both of these functions to one column
  3347.          position after the last character is printed.  If you want to
  3348.          start at a particular row and column of the window, you must
  3349.          move the cursor yourself by calling the WindowMoveCursor()
  3350.          function.  This function is explained later in the CURSOR
  3351.          POSITIONING IN WINDOWS section.  If the window is displayed,
  3352.          the logical cursor of the window is equivalent to the screen
  3353.          cursor.  If the output to the window will be obscured by
  3354.          other windows, the screen cursor will also be hidden.
  3355.  
  3356.          When the window is first created, the logical cursor is
  3357.          automatically moved to (0,0) of the window.
  3358.  
  3359.  
  3360.          WindowSetWrap()
  3361.          ---------------
  3362.  
  3363.          With these functions, any text that will exceed the
  3364.          boundaries of the window will be wrapped to the next line.
  3365.          If the output will exceed the last row of the window, the
  3366.          window is automatically scrolled up by one line.  This is the
  3367.  
  3368.  
  3369.  
  3370.          Page 43          The C Window Library               Page 43
  3371.  
  3372.          default action that is taken when characters exceed the right
  3373.          edge of the window.  If you want the output clipped instead
  3374.          of wrapped, you must set the window's wrap flag using the
  3375.          WindowSetWrap() function.
  3376.  
  3377.          The WindowSetWrap() function sets the window's wrap flag to
  3378.          either on or off.  Here is the prototype:
  3379.  
  3380.                 int WindowSetWrap(WPOINTER w, int option)
  3381.  
  3382.          The second argument will be 0 if you want to turn the wrap
  3383.          flag off, or 1 if you want to turn it on.  If the wrap flag
  3384.          is off, the output generated by WindowPrintf() and
  3385.          WindowPrintfAttr() will be terminated when the right edge
  3386.          of the window is reached.  If the wrap flag is on, the output
  3387.          is wrapped to the next line when the right edge is reached,
  3388.          and the window will be scrolled up by one line if the output
  3389.          will exceed the last row.
  3390.  
  3391.          You can set the wrap flag to a window at any time.
  3392.  
  3393.  
  3394.  
  3395.          WindowPrintf()
  3396.          --------------
  3397.  
  3398.          The WindowPrintf() function writes formatted output to the
  3399.          window.  Here is the prototype:
  3400.  
  3401.             int WindowPrintf(WPOINTER w, char *format [,arg1,...])
  3402.  
  3403.          The first argument is the window.  The second argument is a
  3404.          format string.  The rest of the arguments are optional
  3405.          arguments that are written to the window.
  3406.  
  3407.          Example:
  3408.  
  3409.          #include "cwlwin.h"
  3410.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3411.          WPOINTER w;
  3412.          char *s1 = "This string will wrap around to the next line\n";
  3413.          char *s2 = "This escape code will ring the bell \a";
  3414.          int i = 3;
  3415.          double j = 5.6;
  3416.  
  3417.          main()
  3418.          {
  3419.            WindowInitializeSystem();
  3420.            WindowInitDesktop(0);
  3421.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  3422.                                 NORM,NORM,SINGLEBOX);
  3423.            WindowDisplay(w,1,NOEFFECT);
  3424.            WindowPrintf(w,"3+2 is equal to %d\n",3+2);
  3425.            GET_KEY();
  3426.            WindowPrintf(w,"i is equal to %d\nj is equal to %lf\n",
  3427.                         i,j);
  3428.  
  3429.  
  3430.          Page 44          The C Window Library               Page 44
  3431.  
  3432.            GET_KEY();
  3433.            WindowPrintf(w,s1);
  3434.            GET_KEY();
  3435.            WindowPrintf(w,s2);
  3436.          }
  3437.  
  3438.          The above example illustrates how WindowPrintf() is used to
  3439.          print formatted strings.
  3440.  
  3441.          The return values for WindowPrintf() are the same as
  3442.          WindowWriteString().
  3443.  
  3444.  
  3445.  
  3446.          WindowPrintfAttr()
  3447.          ------------------
  3448.  
  3449.          The WindowPrintfAttr() function writes formatted output to
  3450.          the window.  The difference between WindowPrintf() and
  3451.          WindowPrintfAttr() is that WindowPrintfAttr() uses a video
  3452.          attribute specified as an argument.  Here is the prototype:
  3453.  
  3454.          int WindowPrintfAttr(WPOINTER w, int attr,
  3455.                               char *format [,arg1,...])
  3456.  
  3457.          The first argument is the window.  The second argument is the
  3458.          video attribute to use.  The third argument is the format
  3459.          string.  The rest of the arguments are optional arguments
  3460.          that are written to the window.
  3461.  
  3462.          Example:
  3463.  
  3464.          #include "cwlwin.h"
  3465.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3466.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3467.  
  3468.          WPOINTER w;
  3469.          char *s1 = "This string will wrap around to the next line\n";
  3470.          char *s2 = "This escape code will ring the bell \a";
  3471.          int i = 3;
  3472.          double j = 5.6;
  3473.  
  3474.          main()
  3475.          {
  3476.            WindowInitializeSystem();
  3477.            WindowInitDesktop(0);
  3478.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  3479.                                 NORM,NORM,SINGLEBOX);
  3480.            WindowDisplay(w,1,NOEFFECT);
  3481.            WindowPrintfAttr(w,REVERSE,"3+2 is equal to %d\n",3+2);
  3482.            GET_KEY();
  3483.            WindowPrintfAttr(w,REVERSE,
  3484.                      "i is equal to %d\nj is equal to %lf\n",i,j);
  3485.            GET_KEY();
  3486.            WindowPrintfAttr(w,REVERSE,s1);
  3487.            WindowPrintfAttr(w,REVERSE,s2);
  3488.          }
  3489.  
  3490.          Page 45          The C Window Library               Page 45
  3491.  
  3492.          The above example illustrates how WindowPrintfAttr() is used
  3493.          to print formatted strings.
  3494.  
  3495.          The return values for WindowPrintfAttr() are the same as
  3496.          WindowWriteString().
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.  
  3504.  
  3505.  
  3506.  
  3507.  
  3508.  
  3509.  
  3510.  
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.          Page 46          The C Window Library               Page 46
  3551.  
  3552.                       WRITING TITLES TO WINDOWS
  3553.                       -------------------------
  3554.  
  3555.          This section only applies to bordered windows.  There are two
  3556.          methods of writing text to the top or bottom border of a
  3557.          window.  Each method has its advantages and disadvantages.
  3558.  
  3559.          The first method is to explicitly write to the border of the
  3560.          window.  Except for the WindowPrintf...() functions, if you
  3561.          specify the row number to be -1, the text is written on the
  3562.          upper border of the window. If the row number is equal to the
  3563.          window height, the text is written on the lower border of the
  3564.          window.  To access the window's height use the macro
  3565.          WINDOW_HEIGHT() described later in the WINDOW MACROS section.
  3566.  
  3567.          If you want to write a formatted string on the border of the
  3568.          window, use the standard library function sprintf() to create
  3569.          a string of formatted output, and then write this string with
  3570.          one of the WindowWrite...() functions.
  3571.  
  3572.          Any text that is written on the borders of a window are not
  3573.          retained if the window is resized using one of the
  3574.          WindowResize...() functions, or if the border is changed
  3575.          using WindowDrawBorder().  Therefore it is a good idea to
  3576.          maintain what is on the borders of the window in your own
  3577.          string variables.
  3578.  
  3579.  
  3580.          Example:
  3581.  
  3582.  
  3583.          #include "cwlwin.h"
  3584.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3585.  
  3586.          WPOINTER w;
  3587.          int i;
  3588.  
  3589.          main()
  3590.          {
  3591.            WindowInitializeSystem();
  3592.            WindowInitDesktop(0);
  3593.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3594.                                 NORM,NORM,SINGLEBOX);
  3595.            WindowDisplay(w,1,NOEFFECT);
  3596.            GET_KEY();
  3597.  
  3598.            /* Specify row 0 to write on */
  3599.            WindowWriteCenterString(w,"This is a title",-1);
  3600.  
  3601.            WindowWriteCenterString(w,"This is a title",
  3602.                                    WINDOW_HEIGHT(w));
  3603.          }
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.          Page 47          The C Window Library               Page 47
  3611.  
  3612.          The second method is writing a string of text to either the
  3613.          top or bottom border by using the WindowTitle...() functions.
  3614.          The advantage of using these functions is that the strings
  3615.          are retained automatically if the window is resized or the
  3616.          border type is changed.  Another advantage is that if the
  3617.          title does not fit in the boundaries of the window, the title
  3618.          is truncated, but the full title is retained in a buffer.  If
  3619.          the window is later resized so that the title can fit, the
  3620.          full title will appear on the border.
  3621.  
  3622.          The disadvantage is that only one string of text is allowed
  3623.          for the top and bottom borders, and there are only three
  3624.          positions on each border to place the title.
  3625.  
  3626.  
  3627.          WindowTitleTop()
  3628.          ----------------
  3629.  
  3630.          The WindowTitleTop() function writes a title to the top
  3631.          border of a window.  Here is the prototype:
  3632.  
  3633.          int WindowTitleTop(WPOINTER w, char *title, int pos)
  3634.  
  3635.          The first argument is the window to write the title.  The
  3636.          second argument is the title to write.  The third argument is
  3637.          the position to place the title.  Here is a list of valid
  3638.          constants to use for the position:
  3639.  
  3640.             Title
  3641.            Constant               Description
  3642.          ┌───────────┬────────────────────────────────────────────┐
  3643.          │TITLELEFT  │Places the title starting at column 1 of the│
  3644.          │           │window.                                     │
  3645.          ├───────────┼────────────────────────────────────────────┤
  3646.          │TITLECENTER│Centers the title in the window.            │
  3647.          ├───────────┼────────────────────────────────────────────┤
  3648.          │TITLERIGHT │Right justifies the title to the last column│
  3649.          │           │of the window.                              │
  3650.          └───────────┴────────────────────────────────────────────┘
  3651.  
  3652.          Example:
  3653.  
  3654.          #include "cwlwin.h"
  3655.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3656.  
  3657.          WPOINTER w;
  3658.          int i;
  3659.          main()
  3660.          {
  3661.            WindowInitializeSystem();
  3662.            WindowInitDesktop(0);
  3663.            w =
  3664.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3665.                             NORM,NORM,SINGLEBOX);
  3666.            WindowDisplay(w,1,NOEFFECT);
  3667.            GET_KEY();
  3668.  
  3669.  
  3670.          Page 48          The C Window Library               Page 48
  3671.  
  3672.            /* left justify title */
  3673.            WindowTitleTop(w,"This is a title",TITLELEFT);
  3674.            GET_KEY();
  3675.  
  3676.            /* center title */
  3677.            WindowTitleTop(w,"This is a title",TITLECENTER);
  3678.            GET_KEY();
  3679.            /* right justify title */
  3680.            WindowTitleTop(w,"This is a title",TITLERIGHT);
  3681.          }
  3682.  
  3683.  
  3684.          Return Values for WindowTitleTop():
  3685.  
  3686.              Return Value         Definition
  3687.          ┌────────────────┬────────────────────────┐
  3688.          │NO_ERROR        │ No error occured.      │
  3689.          ├────────────────┼────────────────────────┤
  3690.          │BAD_WINDOW      │ Window does not exist. │
  3691.          └────────────────┴────────────────────────┘
  3692.  
  3693.  
  3694.  
  3695.          WindowTitleBottom()
  3696.          -------------------
  3697.  
  3698.          The WindowTitleBottom() function writes a title to the bottom
  3699.          border of a window.  Here is the prototype:
  3700.  
  3701.          int WindowTitleBottom(WPOINTER w, char *title, int pos)
  3702.  
  3703.          The first argument is the window to write the title.  The
  3704.          second argument is the title to write.  The third argument is
  3705.          a constant that denotes the position to place the title.  A
  3706.          list of valid constants can be found in the description of
  3707.          WindowTitleBottom() described above.
  3708.  
  3709.  
  3710.          #include "cwlwin.h"
  3711.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3712.  
  3713.          WPOINTER w;
  3714.          int i;
  3715.          main()
  3716.          {
  3717.            WindowInitializeSystem();
  3718.            WindowInitDesktop(0);
  3719.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3720.                                 NORM,NORM,SINGLEBOX);
  3721.            WindowDisplay(w,1,NOEFFECT);
  3722.            GET_KEY();
  3723.  
  3724.            /* left justify title */
  3725.            WindowTitleBottom(w,"This is a title",TITLELEFT);
  3726.            GET_KEY();
  3727.  
  3728.  
  3729.  
  3730.          Page 49          The C Window Library               Page 49
  3731.  
  3732.            /* center title */
  3733.            WindowTitleBottom(w,"This is a title",TITLECENTER);
  3734.            GET_KEY();
  3735.  
  3736.            /* right justify title */
  3737.            WindowTitleBottom(w,"This is a title",TITLERIGHT);
  3738.          }
  3739.  
  3740.  
  3741.          Return Values for WindowTitleBottom():
  3742.  
  3743.              Return Value         Definition
  3744.          ┌────────────────┬────────────────────────┐
  3745.          │NO_ERROR        │ No error occured.      │
  3746.          ├────────────────┼────────────────────────┤
  3747.          │BAD_WINDOW      │ Window does not exist. │
  3748.          └────────────────┴────────────────────────┘
  3749.  
  3750.  
  3751.          WindowTitleTopAttr()
  3752.          --------------------
  3753.  
  3754.          The WindowTitleTopAttr() function writes a title to the top
  3755.          border of a window with a specified color attribute.  Here is
  3756.          the prototype:
  3757.  
  3758.          int WindowTitleTopAttr(WPOINTER w, char *title, int pos,
  3759.                                 int attr)
  3760.  
  3761.          The first argument is the window to write the title.  The
  3762.          second argument is the title to write.  The third argument is
  3763.          a constant that denotes the position to place the title.  A
  3764.          list of valid constants can be found in the description of
  3765.          WindowTitleTopAttr() described above.  The fourth argument is
  3766.          the color attribute to use.
  3767.  
  3768.  
  3769.          #include "cwlwin.h"
  3770.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3771.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3772.  
  3773.          WPOINTER w;
  3774.          int i;
  3775.          main()
  3776.          {
  3777.            WindowInitializeSystem();
  3778.            WindowInitDesktop(0);
  3779.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3780.                                 NORM,NORM,SINGLEBOX);
  3781.            WindowDisplay(w,1,NOEFFECT);
  3782.            GET_KEY();
  3783.            /* left justify title */
  3784.            WindowTitleTopAttr(w,"This is a title",TITLELEFT,
  3785.                               REVERSE);
  3786.  
  3787.  
  3788.  
  3789.  
  3790.          Page 50          The C Window Library               Page 50
  3791.  
  3792.            GET_KEY();
  3793.  
  3794.            /* center title */
  3795.            WindowTitleTopAttr(w,"This is a title",TITLECENTER,
  3796.                               REVERSE);
  3797.            GET_KEY();
  3798.  
  3799.            /* right justify title */
  3800.            WindowTitleTopAttr(w,"This is a title",TITLERIGHT,
  3801.                               REVERSE);
  3802.          }
  3803.  
  3804.  
  3805.                Return Values for WindowTitleTopAttr():
  3806.  
  3807.              Return Value         Definition
  3808.          ┌────────────────┬────────────────────────┐
  3809.          │NO_ERROR        │ No error occured.      │
  3810.          ├────────────────┼────────────────────────┤
  3811.          │BAD_WINDOW      │ Window does not exist. │
  3812.          └────────────────┴────────────────────────┘
  3813.  
  3814.  
  3815.  
  3816.          WindowTitleBottomAttr()
  3817.          -----------------------
  3818.  
  3819.          The WindowTitleBottomAttr() function writes a title to the
  3820.          bottom border of a window with a specified color attribute.
  3821.          Here is the prototype:
  3822.  
  3823.          int WindowTitleBottomAttr(WPOINTER w, char *title, int pos,
  3824.                                    int attr)
  3825.  
  3826.          The first argument is the window to write the title.  The
  3827.          second argument is the title to write.  The third argument is
  3828.          a constant that denotes the position to place the title.  A
  3829.          list of valid constants can be found in the description of
  3830.          WindowTitleBottomAttr() described above.  The fourth argument
  3831.          is the color attribute to use.
  3832.  
  3833.          #include "cwlwin.h"
  3834.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3835.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3836.  
  3837.          WPOINTER w;
  3838.          int i;
  3839.          main()
  3840.          {
  3841.            WindowInitializeSystem();
  3842.            WindowInitDesktop(0);
  3843.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3844.                                 NORM,NORM,SINGLEBOX);
  3845.            WindowDisplay(w,1,NOEFFECT);
  3846.            GET_KEY();
  3847.  
  3848.  
  3849.  
  3850.          Page 51          The C Window Library               Page 51
  3851.  
  3852.            /* left justify title */
  3853.            WindowTitleBottomAttr(w,"This is a title",TITLELEFT,
  3854.                                  REVERSE);
  3855.            GET_KEY();
  3856.  
  3857.            /* center title */
  3858.            WindowTitleBottomAttr(w,"This is a title",TITLECENTER,
  3859.                                  REVERSE);
  3860.            GET_KEY();
  3861.  
  3862.            /* right justify title */
  3863.            WindowTitleBottomAttr(w,"This is a title",TITLERIGHT,
  3864.                                  REVERSE);
  3865.          }
  3866.  
  3867.  
  3868.              Return Values for WindowTitleBottomAttr():
  3869.  
  3870.              Return Value         Definition
  3871.          ┌────────────────┬────────────────────────┐
  3872.          │NO_ERROR        │ No error occured.      │
  3873.          ├────────────────┼────────────────────────┤
  3874.          │BAD_WINDOW      │ Window does not exist. │
  3875.          └────────────────┴────────────────────────┘
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  
  3906.  
  3907.  
  3908.  
  3909.  
  3910.          Page 52          The C Window Library               Page 52
  3911.  
  3912.            READING CHARACTERS AND ATTRIBUTES FROM WINDOWS
  3913.            ----------------------------------------------
  3914.  
  3915.          With The C Window Library, you can read the contents of a
  3916.          window into a character buffer.  These functions provide the
  3917.          programmer with the contents of the window at any time.  The
  3918.          functions to perform this are WindowReadAttributes(),
  3919.          WindowReadCharacters(), and WindowReadCharAndAttr().
  3920.  
  3921.  
  3922.  
  3923.          WindowReadCharacters()
  3924.          ----------------------
  3925.  
  3926.          The WindowReadCharacters() function reads the characters from
  3927.          a window into a buffer.  Here is the prototype.
  3928.  
  3929.          int WindowReadCharacters(WPOINTER w, char *buffer, int row,
  3930.                                   int col, int length)
  3931.  
  3932.          The first argument is the window.  The second argument is the
  3933.          buffer to store the characters in.  The third and fourth
  3934.          arguments are the (row,col) position in the window to start
  3935.          reading from.  The last argument is the number of characters
  3936.          to read.
  3937.  
  3938.          You must make sure that buffer has enough room to hold all of
  3939.          the characters read in.
  3940.  
  3941.  
  3942.          Example:
  3943.  
  3944.          #include "cwlwin.h"
  3945.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3946.  
  3947.          WPOINTER w;
  3948.          char buf[14] = {0};      /* Null all elements of buf */
  3949.  
  3950.          main()
  3951.          {
  3952.            int i;
  3953.            WindowInitializeSystem();
  3954.            WindowInitDesktop(0);
  3955.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  3956.                                 NORM,NORM,SINGLEBOX);
  3957.            WindowDisplay(w,1,NOEFFECT);
  3958.            WindowWriteString(w,"Hello World!!",0,0);/* Write String */
  3959.            WindowReadCharacters(w,buf,0,0,13);  /* Read characters */
  3960.            GET_KEY();
  3961.            WindowWriteString(w,buf,1,0); /* Write what we have read */
  3962.          }
  3963.  
  3964.  
  3965.          The example above illustrates the use of
  3966.          WindowReadCharacters(), which reads the window's contents
  3967.  
  3968.  
  3969.  
  3970.          Page 53          The C Window Library               Page 53
  3971.  
  3972.          starting at (0,0) of the window.  This happens to be the
  3973.          string "Hello World!!".  After GET_KEY() is called, the
  3974.          results of the buffer are written on line 1 of the window.
  3975.  
  3976.          If the length exceeds the right edge of the window,
  3977.          WindowReadCharacters() will read up to the right edge of the
  3978.          window.
  3979.  
  3980.               Return Values for WindowReadCharacters():
  3981.  
  3982.              Return Value         Definition
  3983.          ┌────────────────┬────────────────────────┐
  3984.          │NO_ERROR        │ No error occured.      │
  3985.          ├────────────────┼────────────────────────┤
  3986.          │BAD_WINDOW      │ Window does not exist. │
  3987.          ├────────────────┼────────────────────────┤
  3988.          │WINDOW_BOUND    │ Row or column specified│
  3989.          │                │ is out of bounds.      │
  3990.          └────────────────┴────────────────────────┘
  3991.  
  3992.  
  3993.  
  3994.  
  3995.          WindowReadAttributes()
  3996.          ----------------------
  3997.  
  3998.          The WindowReadAttributes() function reads the attributes from
  3999.          a window into a buffer.  Here is the prototype.
  4000.  
  4001.          int WindowReadAttributes(WPOINTER w, char *buffer, int row,
  4002.                                   int col, int length)
  4003.  
  4004.          The first argument is the window.  The second argument is the
  4005.          buffer to store the attributes in.  The third and fourth
  4006.          arguments are the (row,col) position in the window to start
  4007.          reading from.  The last argument is the number of attributes
  4008.          to read.
  4009.  
  4010.          You must make sure that buffer has enough room to hold all of
  4011.          the attributes read in.
  4012.  
  4013.          Example:
  4014.  
  4015.          #include "cwlwin.h"
  4016.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4017.  
  4018.          WPOINTER w;
  4019.          char buf[14] = {0};      /* Null all elements of buf */
  4020.  
  4021.          main()
  4022.  
  4023.          {
  4024.            int i;
  4025.            WindowInitializeSystem();
  4026.            WindowInitDesktop(0);
  4027.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4028.                                 NORM,NORM,SINGLEBOX);
  4029.  
  4030.          Page 54          The C Window Library               Page 54
  4031.  
  4032.            WindowDisplay(w,1,NOEFFECT);
  4033.            WindowWriteString(w,"Hello World!!",0,0);/* Write String */
  4034.            WindowReadAttributes(w,buf,0,0,13);  /* Read attributes */
  4035.            GET_KEY();
  4036.            WindowWriteString(w,buf,1,0); /* Write what we have read */
  4037.          }
  4038.  
  4039.  
  4040.          The example above illustrates the use of
  4041.          WindowReadAttributes(), which reads the window's attribute
  4042.          contents starting at (0,0) of the window.  This happens to be
  4043.          the attributes of the string "Hello World!!", which is the
  4044.          NORM attribute.  After GET_KEY() is called, the results of
  4045.          the buffer are written on line 1 of the window.
  4046.  
  4047.          If the length exceeds the right edge of the window,
  4048.          WindowReadAttributes() will read up to the right edge of the
  4049.          window.
  4050.  
  4051.  
  4052.              Return Values for WindowReadAttributes():
  4053.  
  4054.              Return Value         Definition
  4055.          ┌────────────────┬───────────────────────────────┐
  4056.          │NO_ERROR        │ No error occured.             │
  4057.          ├────────────────┼───────────────────────────────┤
  4058.          │BAD_WINDOW      │ Window does not exist.        │
  4059.          ├────────────────┼───────────────────────────────┤
  4060.          │WINDOW_BOUND    │Row or Column is out of bounds.│
  4061.          └────────────────┴───────────────────────────────┘
  4062.  
  4063.  
  4064.  
  4065.  
  4066.          WindowReadCharAndAttr()
  4067.          ----------------------
  4068.  
  4069.          The WindowReadCharAndAttr() function reads
  4070.          character/attribute pairs from a window into a buffer.  Here
  4071.          is the prototype.
  4072.  
  4073.          int WindowReadCharAndAttr(WPOINTER w, char *buffer, int row,
  4074.                                    int col, int length)
  4075.  
  4076.          The first argument is the window.  The second argument is the
  4077.          buffer to store the character/attribute pairs in.  The third
  4078.  
  4079.          and fourth arguments are the (row,col) position in the window
  4080.          to start reading from.  The last argument is the number of
  4081.          character/attribute pairs to read.
  4082.  
  4083.          You must make sure that buffer has enough room to hold all of
  4084.          the character/attribute pairs read in.
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.          Page 55          The C Window Library               Page 55
  4091.  
  4092.          Example:
  4093.  
  4094.          #include "cwlwin.h"
  4095.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4096.  
  4097.          WPOINTER w;
  4098.          char buf[27] = {0};      /* Null all elements of buf */
  4099.  
  4100.          main()
  4101.          {
  4102.            int i;
  4103.            WindowInitializeSystem();
  4104.            WindowInitDesktop(0);
  4105.            w =
  4106.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4107.                             NORM,NORM,SINGLEBOX);
  4108.            WindowDisplay(w,1,NOEFFECT);
  4109.            WindowWriteString(w,"Hello World!!",0,0);/* Write String */
  4110.            WindowReadCharAndAttr(w,buf,0,0,13);
  4111.            GET_KEY();
  4112.            WindowWriteCharAndAttr(w,buf,1,0,13); /* Write what we have
  4113.                                                     read */
  4114.          }
  4115.  
  4116.  
  4117.          The example above illustrates the use of
  4118.          WindowReadCharAndAttr(), which reads the window's
  4119.          character/attribute contents starting at (0,0) of the window.
  4120.          This happens to be the characters/attributes of the string
  4121.          "Hello World!!".  After GET_KEY() is called, the results of
  4122.          the buffer are written on line 1 of the window.
  4123.  
  4124.          If the length exceeds the right edge of the window,
  4125.          WindowReadCharAndAttr() will read up to the right edge of the
  4126.          window.
  4127.  
  4128.  
  4129.              Return Values for WindowReadCharAndAttr():
  4130.  
  4131.              Return Value         Definition
  4132.          ┌────────────────┬───────────────────────────────┐
  4133.          │NO_ERROR        │ No error occured.             │
  4134.          ├────────────────┼───────────────────────────────┤
  4135.          │BAD_WINDOW      │ Window does not exist.        │
  4136.          ├────────────────┼───────────────────────────────┤
  4137.          │WINDOW_BOUND    │Row or Column is out of bounds.│
  4138.          └────────────────┴───────────────────────────────┘
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.          Page 56          The C Window Library               Page 56
  4151.  
  4152.                            HIDING WINDOWS
  4153.                            --------------
  4154.  
  4155.          With The C Window Library, you can hide windows at any time
  4156.          without disturbing the contents of other windows.
  4157.  
  4158.  
  4159.          WindowHide()
  4160.          ------------
  4161.  
  4162.          The WindowHide() function hides a window on the screen from
  4163.          view.  The window retains all text and shadows that may be
  4164.          present.  Here is a prototype:
  4165.  
  4166.                    int WindowHide(WPOINTER w, int effect)
  4167.  
  4168.          The first argument is the window, and the last argument is
  4169.          the special effect to use when hiding the window.  For a list
  4170.          of special effects, refer to the DISPLAYING WINDOWS section.
  4171.  
  4172.          Example :
  4173.  
  4174.          #include "cwlwin.h"
  4175.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4176.          #define REDONWHITE  CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  4177.          #define BLACKONWHITE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  4178.  
  4179.          WPOINTER w1,w2,w3;
  4180.          main()
  4181.          {
  4182.            WindowInitializeSystem();
  4183.            WindowInitDesktop(0);
  4184.  
  4185.            /* Initialize all windows */
  4186.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4187.                                  NORM,NORM,SINGLEBOX);
  4188.            w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,1,1,20,10,
  4189.                                  REDONWHITE,NORM,DOUBLEBOX);
  4190.            w3 = WindowInitialize(DESKTOP_WINDOW,BORDER,2,2,20,10,
  4191.                                  BLACKONWHITE,NORM,SINGLEBOX);
  4192.  
  4193.            /* Display All windows */
  4194.            WindowDisplay(w1,1,NOEFFECT);
  4195.            WindowDisplay(w2,2,NOEFFECT);
  4196.            WindowDisplay(w3,3,NOEFFECT);
  4197.  
  4198.            WindowWriteString(w1,"This is window 1",0,0);
  4199.            WindowWriteString(w2,"This is window 2",1,0);
  4200.            WindowWriteString(w3,"This is window 3",2,0);
  4201.  
  4202.            GET_KEY();
  4203.            WindowHide(w3,NOEFFECT);
  4204.            GET_KEY();
  4205.            WindowHide(w2,BRICKS);
  4206.            GET_KEY();
  4207.            WindowHide(w1,CONTRACT);
  4208.          }
  4209.  
  4210.          Page 57          The C Window Library               Page 57
  4211.  
  4212.  
  4213.          The example initializes, opens, and displays three windows.
  4214.          Note that you can hide windows regardless of the order in
  4215.          which they were displayed.  This makes for very flexible
  4216.          window management.
  4217.  
  4218.                    Return Values for WindowHide():
  4219.  
  4220.              Return Value         Definition
  4221.          ┌────────────────┬──────────────────────────────┐
  4222.          │NO_ERROR        │No error occured.             │
  4223.          ├────────────────┼──────────────────────────────┤
  4224.          │BAD_WINDOW      │Window does not exist.        │
  4225.          └────────────────┴──────────────────────────────┘
  4226.  
  4227.  
  4228.  
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.  
  4235.  
  4236.  
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242.  
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.          Page 58          The C Window Library               Page 58
  4271.  
  4272.                      CREATING COPIES OF A WINDOW
  4273.                      ---------------------------
  4274.  
  4275.          You can create copies of a window without going using the
  4276.          WindowInitialize() function.
  4277.  
  4278.  
  4279.          WindowCopy()
  4280.          ------------
  4281.  
  4282.          The WindowCopy() function makes a copy of a previous window.
  4283.          The copy will have the same colors, border type, shadow,
  4284.          parent window, and may have the same text as a previous
  4285.          window.  If the original window is a viewport on a virtual
  4286.          window (virtual windows are discussed later in the VIRTUAL
  4287.          WINDOWS section), the copy can also be made a viewport on the
  4288.          same virtual window.  The only thing that will not be copied
  4289.          is the (row,col) of the original window.  You supply the
  4290.          position of the new window.  Here is the prototype:
  4291.  
  4292.          WPOINTER WindowCopy(WPOINTER w, int row, int col, int options)
  4293.  
  4294.          Please note that WindowCopy() returns a new WPOINTER.  You
  4295.          must assign the return value to a WPOINTER or you will not
  4296.          get easy access to the newly created window.
  4297.  
  4298.          The first argument is the original window to copy.  This
  4299.          window must already exist.  The second and third arguments
  4300.          are the coordinates of where to place the new window.  The
  4301.          last argument are additional options that control whether the
  4302.          window will contain the same text as the previous window, and
  4303.          if the new window will be made a viewport if the original
  4304.          window is a viewport.  The constants used for options is as
  4305.          follows:
  4306.  
  4307.          Options             Action
  4308.          ┌────────────┬─────────────────────────────────────────┐
  4309.          │MAKECHILD   │ Makes new window a child of w's parent. │
  4310.          ├────────────┼─────────────────────────────────────────┤
  4311.          │COPYTEXT    │ Makes a copy of the text area of the    │
  4312.          │            │ original window.                        │
  4313.          ├────────────┼─────────────────────────────────────────┤
  4314.          │MAKEVIEWPORT│ Turns the copy into a viewport if the   │
  4315.          │            │ original is a viewport.                 │
  4316.          ├────────────┼─────────────────────────────────────────┤
  4317.          │NO_OPTIONS  │ No options desired.                     │
  4318.          └────────────┴─────────────────────────────────────────┘
  4319.  
  4320.          As was stated before, viewports are discussed in the VIRTUAL
  4321.          WINDOW section of the manual.  If options is NO_OPTIONS, the
  4322.          windows size, border type, shadow (if there is a shadow) and
  4323.          colors are copied.
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.          Page 59          The C Window Library               Page 59
  4331.  
  4332.          Example:
  4333.  
  4334.          #include "cwlwin.h"
  4335.  
  4336.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4337.  
  4338.          WPOINTER w,w2;
  4339.  
  4340.          main()
  4341.          {
  4342.            WindowInitializeSystem();
  4343.            WindowInitDesktop(0);
  4344.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,45,10,
  4345.                                 NORM,NORM,SINGLEBOX);
  4346.            WindowDisplay(w,1,NOEFFECT);
  4347.            WindowWriteString(w,
  4348.                        "This will be copied to the new window",0,0);
  4349.            GET_KEY();
  4350.            w2 = WindowCopy(w,3,3,COPYTEXT);  /* Make a copy of w */
  4351.            WindowDisplay(w2,1,NOEFFECT);     /* Display this copy */
  4352.            GET_KEY();
  4353.            WindowCloseAll(0,NOEFFECT);
  4354.          }
  4355.  
  4356.  
  4357.  
  4358.                    Return Values for WindowCopy():
  4359.  
  4360.              Return Value         Definition
  4361.          ┌────────────────┬───────────────────────────────────┐
  4362.          │NO_ERROR        │No error occured.                  │
  4363.          ├────────────────┼───────────────────────────────────┤
  4364.          │BAD_WINDOW      │Window to copy from does not exist.│
  4365.          ├────────────────┼───────────────────────────────────┤
  4366.          │NO_HEAP_MEM     │Not enough memory to allocate for  │
  4367.          │                │new window.                        │
  4368.          ├────────────────┼───────────────────────────────────┤
  4369.          │MAX_WINDOW      │Maximimum number of windows defined│
  4370.          └────────────────┴───────────────────────────────────┘
  4371.  
  4372.  
  4373.  
  4374.  
  4375.  
  4376.  
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.          Page 60          The C Window Library               Page 60
  4391.  
  4392.                       SCROLLING TEXT IN WINDOWS
  4393.                       -------------------------
  4394.  
  4395.          With The C Window Library, you can scroll text in a window
  4396.          up, or down, or scroll just particular regions of a window.
  4397.          The functions used to scroll windows are WindowScroll(),
  4398.          WindowScrollAttr(), WindowScrollRegion(), and
  4399.          WindowScrollRegionAttr().
  4400.  
  4401.          When specifying a direction, use the constant UP to scroll up
  4402.          or DOWN to scroll down.  These constants are defined in
  4403.          cwlwin.h.
  4404.  
  4405.  
  4406.  
  4407.          WindowScroll()
  4408.          --------------
  4409.  
  4410.          If you want to scroll the entire window either up or down,
  4411.          you can use the WindowScroll() function.  Here is a
  4412.          prototype:
  4413.  
  4414.            int WindowScroll(WPOINTER w, int numlines, int direction)
  4415.  
  4416.  
  4417.          The first argument is the window to scroll.   The second
  4418.          argument is the number of lines to scroll. The last argument
  4419.          is the direction to scroll the window (either UP or DOWN).
  4420.  
  4421.  
  4422.          Example:
  4423.  
  4424.          #include "cwlwin.h"
  4425.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4426.  
  4427.          WPOINTER w;
  4428.  
  4429.          main()
  4430.          {
  4431.            int i;
  4432.            WindowInitializeSystem();
  4433.            WindowInitDesktop(0);
  4434.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4435.                                 NORM,NORM,SINGLEBOX);
  4436.            WindowDisplay(w,1,NOEFFECT);
  4437.            for (i=0;i<10;i++)
  4438.              WindowWriteRepeatCharacter(w,'A'+i,i,0,20);
  4439.            GET_KEY();
  4440.            WindowScroll(w,1,UP);
  4441.            GET_KEY();
  4442.            WindowScroll(w,3,DOWN);
  4443.          }
  4444.  
  4445.          The above example creates text using
  4446.          WindowWriteRepeatCharacter() function.  The WindowScroll()
  4447.  
  4448.  
  4449.  
  4450.          Page 61          The C Window Library               Page 61
  4451.  
  4452.          calls will scroll the window up by one line, and then scroll
  4453.          the window down by 3 lines.
  4454.  
  4455.                   Return Values for WindowScroll():
  4456.  
  4457.              Return Value         Definition
  4458.          ┌────────────────┬───────────────────────┐
  4459.          │NO_ERROR        │No error occured.      │
  4460.          ├────────────────┼───────────────────────┤
  4461.          │BAD_WINDOW      │Window does not exist. │
  4462.          └────────────────┴───────────────────────┘
  4463.  
  4464.  
  4465.  
  4466.          WindowScrollRegion()
  4467.          --------------------
  4468.  
  4469.          The WindowScrollRegion() functions scrolls a specified region
  4470.          of a window.  To use the WindowScrollRegion() function, you
  4471.          must describe the rectangular region to scroll.  Here is the
  4472.          prototype:
  4473.  
  4474.          int WindowScrollRegion(WPOINTER w, int numlines, int urow,
  4475.                                 int ucol, int lrow,
  4476.                                 int lcol, int direction)
  4477.  
  4478.          Arguments 3 thru 6 describe the rectangular region.  They are
  4479.          in the order of upper left row, upper left column, lower
  4480.          right row, lower right column.  All of these coordinates are
  4481.          window relative.  The second argument is the number of lines
  4482.          to scroll.  The last argument is the direction.
  4483.  
  4484.          Example:
  4485.  
  4486.          #include "cwlwin.h"
  4487.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4488.  
  4489.          WPOINTER w;
  4490.  
  4491.          main()
  4492.          {
  4493.            int i;
  4494.            WindowInitializeSystem();
  4495.            WindowInitDesktop(0);
  4496.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4497.                                 NORM,NORM,SINGLEBOX);
  4498.            WindowDisplay(w,1,NOEFFECT);
  4499.            for (i=0;i<10;i++)
  4500.  
  4501.            WindowWriteRepeatCharacter(w,'A'+i,i,0,20);
  4502.            GET_KEY();
  4503.            WindowScrollRegion(w,1,2,2,4,10,UP);
  4504.            GET_KEY();
  4505.            WindowScrollRegion(w,3,7,2,9,8,DOWN);
  4506.          }
  4507.  
  4508.  
  4509.  
  4510.          Page 62          The C Window Library               Page 62
  4511.  
  4512.          The above example creates text using
  4513.          WindowWriteRepeatCharacter() function.  The first
  4514.          WindowScrollRegion() call will scroll the region described by
  4515.          the rectangular coordinates (2,2) and (4,10).  This region is
  4516.          scrolled up one line.  The second call to
  4517.          WindowScrollRegion() scrolls the region defined by the
  4518.          rectangular region (7,2) and (9,8).  This region is scrolled
  4519.          down by three lines.
  4520.  
  4521.                Return Values for WindowScrollRegion():
  4522.  
  4523.              Return Value         Definition
  4524.          ┌────────────────┬───────────────────────────────────┐
  4525.          │NO_ERROR        │No error occured.                  │
  4526.          ├────────────────┼───────────────────────────────────┤
  4527.          │BAD_WINDOW      │Window does not exist.             │
  4528.          ├────────────────┼───────────────────────────────────┤
  4529.          │WINDOW_BOUND    │The rectangular region defined     │
  4530.          │                │is out of bounds of the window.    │
  4531.          └────────────────┴───────────────────────────────────┘
  4532.  
  4533.  
  4534.  
  4535.  
  4536.          WindowScrollAttr()
  4537.          ------------------
  4538.  
  4539.          This function works the same way as the WindowScroll()
  4540.          function except that an attribute is defined for the blank
  4541.          lines that are created when the window is scrolled.  Here is
  4542.          a prototype:
  4543.  
  4544.          int WindowScrollAttr(WPOINTER w, int numlines, int direction,
  4545.                               int attr)
  4546.  
  4547.          The last argument is the attribute to use for the blank lines
  4548.          created.
  4549.  
  4550.          Example:
  4551.  
  4552.          #include "cwlwin.h"
  4553.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4554.          #define REDONWHITE  CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  4555.  
  4556.          WPOINTER w;
  4557.  
  4558.          main()
  4559.          {
  4560.            int i;
  4561.  
  4562.            WindowInitializeSystem();
  4563.            WindowInitDesktop(0);
  4564.            w =
  4565.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4566.                             NORM,NORM,SINGLEBOX);
  4567.            WindowDisplay(w,1,NOEFFECT);
  4568.  
  4569.  
  4570.          Page 63          The C Window Library               Page 63
  4571.  
  4572.            for (i=0;i<10;i++)
  4573.              WindowWriteRepeatCharacter(w,'A'+i,i,0,20);
  4574.            GET_KEY();
  4575.            WindowScrollAttr(w,1,UP,REDONWHITE);
  4576.            GET_KEY();
  4577.            WindowScrollAttr(w,3,DOWN,REDONWHITE);
  4578.          }
  4579.  
  4580.          The above example creates text using
  4581.          WindowWriteRepeatCharacter() function.  The
  4582.          WindowScrollAttr() calls will scroll the window up by one
  4583.          line, and then scroll the window down by 3 lines with both
  4584.          scrolls using REDONWHITE as the video attribute.
  4585.  
  4586.          WindowScrollAttr() returns the same values as WindowScroll().
  4587.  
  4588.  
  4589.  
  4590.  
  4591.          WindowScrollRegionAttr()
  4592.          ------------------------
  4593.  
  4594.          This function works the same way as the WindowScrollRegion()
  4595.          function except that an attribute is defined for the blank
  4596.          lines that are created when the window is scrolled.  Here is
  4597.          a prototype:
  4598.  
  4599.          int WindowScrollRegionAttr(WPOINTER w, int numlines, int
  4600.                                    int urow, int ucol, int lrow,
  4601.                                    int lcol, int direction, int attr)
  4602.  
  4603.          The last argument is the attribute to use for the blank lines
  4604.          created.
  4605.  
  4606.          Example:
  4607.  
  4608.          #include "cwlwin.h"
  4609.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4610.          #define REDONWHITE  CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  4611.  
  4612.          WPOINTER w;
  4613.  
  4614.          main()
  4615.          {
  4616.            int i;
  4617.            WindowInitializeSystem();
  4618.            WindowInitDesktop(0);
  4619.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4620.                                 NORM,NORM,SINGLEBOX);
  4621.            WindowDisplay(w,1,NOEFFECT);
  4622.            for (i=0;i<10;i++)
  4623.              WindowWriteRepeatCharacter(w,'A'+i,i,0,20);
  4624.            GET_KEY();
  4625.            WindowScrollRegionAttr(w,1,3,5,6,15,UP,REDONWHITE);
  4626.  
  4627.  
  4628.  
  4629.  
  4630.          Page 64          The C Window Library               Page 64
  4631.  
  4632.            GET_KEY();
  4633.            WindowScrollRegionAttr(w,3,8,4,10,12,DOWN,REDONWHITE);
  4634.          }
  4635.  
  4636.  
  4637.          The above example creates text using
  4638.          WindowWriteRepeatCharacter() function.  The first
  4639.          WindowScrollRegionAttr() call will scroll the region
  4640.          described by the rectangular coordinates (3,5) and (6,15).
  4641.          This region is scrolled one line.  The second call to
  4642.          WindowScrollRegionAttr() scrolls the region defined by the
  4643.          rectangular region (8,4) and (10,12).  This region is
  4644.          scrolled down by three lines.  All blank lines use the video
  4645.          attribute REDONWHITE.
  4646.  
  4647.          WindowScrollRegionAttr() returns the same values as
  4648.          WindowScrollRegion().
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.          Page 65          The C Window Library               Page 65
  4691.  
  4692.                           CLEARING WINDOWS
  4693.                           ----------------
  4694.  
  4695.          The C Window Library contains functions that clears the
  4696.          entire window, or clears defined rectangular regions of the
  4697.          window.
  4698.  
  4699.  
  4700.          WindowClear()
  4701.          -------------
  4702.  
  4703.          The WindowClear() function clears an entire window to spaces.
  4704.          The attribute used is the current attribute of the text area
  4705.          of the window.  Here is the prototype:
  4706.  
  4707.                        int WindowClear(WPOINTER w)
  4708.  
  4709.          The only argument is the window to clear.
  4710.  
  4711.          Example:
  4712.  
  4713.          #include "cwlwin.h"
  4714.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4715.  
  4716.          WPOINTER w;
  4717.  
  4718.          main()
  4719.          {
  4720.            int i;
  4721.            WindowInitializeSystem();
  4722.            WindowInitDesktop(0);
  4723.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4724.                                 NORM,NORM,SINGLEBOX);
  4725.            WindowDisplay(w,1,NOEFFECT);
  4726.            for (i=0;i<10;i++)
  4727.              WindowWriteString(w,"Hello World!!",i,1);
  4728.            GET_KEY();
  4729.            WindowClear(w);
  4730.          }
  4731.  
  4732.  
  4733.                   Return Values for WindowClear():
  4734.  
  4735.              Return Value         Definition
  4736.          ┌────────────────┬───────────────────────┐
  4737.          │NO_ERROR        │No error occured.      │
  4738.          ├────────────────┼───────────────────────┤
  4739.          │BAD_WINDOW      │Window does not exist. │
  4740.          └────────────────┴───────────────────────┘
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.          Page 66          The C Window Library               Page 66
  4751.  
  4752.          WindowClearAttr()
  4753.          -----------------
  4754.  
  4755.          The WindowClearAttr() function works the same way as the
  4756.          WindowClear() function except that an attribute is specified.
  4757.          Here is the prototype:
  4758.  
  4759.             int WindowClearAttr(WPOINTER w, int attr)
  4760.  
  4761.          The second argument is the video attribute to use.
  4762.  
  4763.  
  4764.          Example:
  4765.  
  4766.          #include "cwlwin.h"
  4767.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4768.          #define REDONWHITE  CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  4769.  
  4770.          WPOINTER w;
  4771.  
  4772.          main()
  4773.          {
  4774.            int i;
  4775.            WindowInitializeSystem();
  4776.            WindowInitDesktop(0);
  4777.            w =
  4778.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4779.                             NORM,NORM,SINGLEBOX);
  4780.            WindowDisplay(w,1,NOEFFECT);
  4781.            for (i=0;i<10;i++)
  4782.              WindowWriteString(w,"Hello World!!",i,1);
  4783.            GET_KEY();
  4784.            WindowClearAttr(w,REDONWHITE);
  4785.          }
  4786.  
  4787.  
  4788.          The return values for WindowClearAttr() are the same as
  4789.          WindowClear().
  4790.  
  4791.  
  4792.  
  4793.          WindowClearRegion()
  4794.          -------------------
  4795.  
  4796.          The WindowClearRegion() function clears a region of a window.
  4797.          To use the WindowClearRegion() function, you must describe
  4798.          the rectangular region to clear.  Here is the prototype:
  4799.  
  4800.          int WindowClearRegion(WPOINTER w, int urow, int ucol,
  4801.                                int lrow, int lcol)
  4802.  
  4803.          where (urow,ucol) describes the upper left of the rectangle
  4804.          and (lrow,lcol) is the lower right of the window.  These
  4805.          coordinates are window relative.
  4806.  
  4807.  
  4808.  
  4809.  
  4810.          Page 67          The C Window Library               Page 67
  4811.  
  4812.          Example:
  4813.  
  4814.          #include "cwlwin.h"
  4815.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4816.  
  4817.          WPOINTER w;
  4818.  
  4819.          main()
  4820.          {
  4821.            int i;
  4822.            WindowInitializeSystem();
  4823.            WindowInitDesktop(0);
  4824.            w =
  4825.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4826.                             NORM,NORM,SINGLEBOX);
  4827.            WindowDisplay(w,1,NOEFFECT);
  4828.            for (i=0;i<10;i++)
  4829.              WindowWriteString(w,"Hello World!!",i,1);
  4830.            GET_KEY();
  4831.            WindowClearRegion(w,4,4,8,15);
  4832.          }
  4833.  
  4834.  
  4835.  
  4836.          The WindowClearRegion() call will clear the region described
  4837.          by the rectangular coordinates (4,4) and (8,15).
  4838.  
  4839.                Return Values for WindowClearRegion():
  4840.  
  4841.              Return Value         Definition
  4842.          ┌────────────────┬───────────────────────────────────┐
  4843.          │NO_ERROR        │No error occured.                  │
  4844.          ├────────────────┼───────────────────────────────────┤
  4845.          │BAD_WINDOW      │Window does not exist.             │
  4846.          ├────────────────┼───────────────────────────────────┤
  4847.          │WINDOW_BOUND    │The rectangular region defined     │
  4848.          │                │is out of bounds of the window.    │
  4849.          └────────────────┴───────────────────────────────────┘
  4850.  
  4851.  
  4852.  
  4853.  
  4854.          WindowClearRegionAttr()
  4855.          -----------------------
  4856.  
  4857.          The WindowClearRegionAttr() function works the same as the
  4858.          WindowClearRegion() function, except that a video attribute
  4859.          is specified.  Here is the prototype:
  4860.  
  4861.          int WindowClearRegionAttr(WPOINTER w, int urow, int ucol,
  4862.                                    int lrow, int lcol, int attr)
  4863.  
  4864.          The attr argument is a video attribute to use to clear the
  4865.          region.
  4866.  
  4867.  
  4868.  
  4869.  
  4870.          Page 68          The C Window Library               Page 68
  4871.  
  4872.          Example:
  4873.  
  4874.          #include "cwlwin.h"
  4875.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4876.          #define REDONWHITE  CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  4877.  
  4878.          WPOINTER w;
  4879.  
  4880.          main()
  4881.          {
  4882.            int i;
  4883.            WindowInitializeSystem();
  4884.            WindowInitDesktop(0);
  4885.            w =
  4886.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4887.                             NORM,NORM,SINGLEBOX);
  4888.            WindowDisplay(w,1,NOEFFECT);
  4889.            for (i=0;i<10;i++)
  4890.              WindowWriteString(w,"Hello World!!",i,1);
  4891.            GET_KEY();
  4892.            WindowClearRegionAttr(w,4,4,8,15,REDONWHITE);
  4893.          }
  4894.  
  4895.  
  4896.  
  4897.          The WindowClearRegionAttr() call will clear the region
  4898.          described by the rectangular coordinates (4,4) and (8,15)
  4899.          using the video attribute defined by the constant REDONWHITE.
  4900.  
  4901.          The WindowClearRegionAttr() returns the same values as
  4902.          WindowClearRegion().
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.          Page 69          The C Window Library               Page 69
  4931.  
  4932.                   WRITING WINDOW CONTENTS TO A FILE
  4933.                   ---------------------------------
  4934.  
  4935.          The C Window Library allows you to print the contents of a
  4936.          window using the WindowWriteTextToFile() function.
  4937.  
  4938.  
  4939.          WindowWriteTextToFile()
  4940.          -----------------------
  4941.  
  4942.          The WindowWriteTextToFile() function allows you to print the
  4943.          contents of a window to a file.  Here is the prototype:
  4944.  
  4945.          int WindowWriteTextToFile(WPOINTER w, char *filename,
  4946.                                    int mode)
  4947.  
  4948.          The first argument is the window.  The second argument is the
  4949.          file name.  This file can be any of the DOS filenames ("con",
  4950.          "prn", "aux", etc.).  The file specified by filename must be
  4951.          closed before calling WindowWriteTextToFile(), and the file
  4952.          handle is automatically closed before exiting
  4953.          WindowWriteTextToFile().
  4954.  
  4955.          The last argument is the mode switch.  If mode is 1, a
  4956.          newline ('\n') is written to the file after each line of the
  4957.          window is written to the file.  If mode is 0, no newline
  4958.          character is written.
  4959.  
  4960.  
  4961.  
  4962.          Example:
  4963.  
  4964.          #include "cwlwin.h"
  4965.          #include <stdio.h>
  4966.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4967.  
  4968.          WPOINTER w;
  4969.          FILE *outfile;
  4970.          char *filename = "wintext";
  4971.          char *filename2 = "wintext2";
  4972.  
  4973.          main()
  4974.          {
  4975.            int i;
  4976.            WindowInitializeSystem();
  4977.            WindowInitDesktop(0);
  4978.            w =
  4979.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  4980.                             NORM,NORM,SINGLEBOX);
  4981.            WindowDisplay(w,1,NOEFFECT);
  4982.            for (i=0;i<10;i++)
  4983.              WindowWriteString(w,"Hello World!!",i,1);
  4984.            GET_KEY();
  4985.            WindowWriteTextToFile(w,filename,1);  /* use newlines */
  4986.            WindowWriteTextToFile(w,filename2,0); /* no newlines */
  4987.          }
  4988.  
  4989.  
  4990.          Page 70          The C Window Library               Page 70
  4991.  
  4992.          The example above illustrates two calls to
  4993.          WindowWriteTextToFile().  The first call writes the contents
  4994.          of the window w to a file called "wintext".  Note that the
  4995.          mode parameter for the first call is 1.  This will cause '\n'
  4996.          to be written to the file for each line of the window.  The
  4997.          second call writes the window text to a file call "wintest2",
  4998.          with the mode parameter being 0 (no '\n').
  4999.  
  5000.          Please note that WindowWriteTextToFile() does not check if
  5001.          the file already exists, so be careful that you do not
  5002.          replace files that are important to you.
  5003.  
  5004.  
  5005.  
  5006.                Return Values for WindowWriteTextToFile():
  5007.  
  5008.              Return Value         Definition
  5009.          ┌────────────────┬────────────────────────────────────┐
  5010.          │NO_ERROR        │No error occured.                   │
  5011.          ├────────────────┼────────────────────────────────────┤
  5012.          │BAD_WINDOW      │Window to copy from does not exist. │
  5013.          ├────────────────┼────────────────────────────────────┤
  5014.          │WINDOW_BOUND    │The rectangular region defined      │
  5015.          │                │is out of bounds of the window.     │
  5016.          ├────────────────┼────────────────────────────────────┤
  5017.          │FILE_CANT_OPEN  │The file specified cannot be opened.│
  5018.          ├────────────────┼────────────────────────────────────┤
  5019.          │FILE_CANT_CLOSE │The file specified cannot be closed.│
  5020.          └────────────────┴────────────────────────────────────┘
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.          Page 71          The C Window Library               Page 71
  5051.  
  5052.                           SHADOWING WINDOWS
  5053.                           -----------------
  5054.  
  5055.          With The C Window Library, you can place shadows on the
  5056.          windows created.  Shadows create a nice effect when displayed
  5057.          with the proper background color.  There are four positions
  5058.          where you can place a shadow on a window: the upper left
  5059.          corner of the window, the upper right corner, the lower left
  5060.          corner or the lower right corner.
  5061.  
  5062.          The shadow consists of two components.  One of these
  5063.          components is the part of the shadow that is drawn either on
  5064.          the left or right side of the window.  You can control the
  5065.          width of this portion of the shadow.  The other component
  5066.          that makes up the shadow is the portion that is drawn either
  5067.          on top of or underneath a window.  You can control the height
  5068.          of this portion of the shadow.
  5069.  
  5070.          You can also control the shadows video attribute, as well as
  5071.          the character that makes up the shadow itself.  My suggestion
  5072.          is to use ASCII character 219 for the shadow character.
  5073.          Other ones that work well are ASCII 176, 178, and 178.
  5074.  
  5075.          Transparent shadows are also supported.
  5076.  
  5077.          You can place a shadow on a window at any time or take it off
  5078.          at any time.  The only restriction with the shadow is that
  5079.          the window's current position must have room to draw the
  5080.          shadow.
  5081.  
  5082.          When shadows are drawn, CWL uses a window to draw the shadow.
  5083.          The rank of a window's shadow is one higher than the window
  5084.          itself.  Therefore, you should note that a window is being
  5085.          used by CWL and that the number of windows available is
  5086.          reduced for each shadowed window.
  5087.  
  5088.  
  5089.  
  5090.          WindowDrawShadow()
  5091.          ------------------
  5092.  
  5093.          The WindowDrawShadow() function places a shadow on a window.
  5094.          Here is the prototype:
  5095.  
  5096.          int WindowDrawShadow(WPOINTER w, int shadowpos, int width,
  5097.                               int height, int shadowchar,
  5098.                               int shadowattr, int transflag)
  5099.  
  5100.          The first argument is the window that the shadow will be
  5101.          drawn.  The second argument is the position of the shadow.
  5102.          There are four possible positions:
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.          Page 72          The C Window Library               Page 72
  5111.  
  5112.          Shadow Constant        Function
  5113.         ┌──────────────┬────────────────────────────────────────────┐
  5114.         │SHADOWUPRIGHT │Draws shadow on upper right corner of the   │
  5115.         │              │window.                                     │
  5116.         ├──────────────┼────────────────────────────────────────────┤
  5117.         │SHADOWUPLEFT  │Draws shadow on upper left corner of the    │
  5118.         │              │window.                                     │
  5119.         ├──────────────┼────────────────────────────────────────────┤
  5120.         │SHADOWLOWRIGHT│Draws shadow on lower right corner of       │
  5121.         │              │window.                                     │
  5122.         ├──────────────┼────────────────────────────────────────────┤
  5123.         │SHADOWLOWLEFT │Draws shadow on lower left corner of window.│
  5124.         └──────────────┴────────────────────────────────────────────┘
  5125.  
  5126.          The third argument is the width of the strip of the shadow
  5127.          that is drawn on the right or left side of the window.  The
  5128.          fourth argument is the height of the strip of the shadow that
  5129.          is drawn on top or underneath the window.  The fifth argument
  5130.          is the character to use for the shadow.  The sixth argument
  5131.          is the attribute to use for the shadow.  The last argument is
  5132.          a flag denoting whether the shadow should be a transparent
  5133.          shadow.  If the flag is 0, the shadow is solid, otherwise the
  5134.          shadow is transparent.
  5135.  
  5136.          Example:
  5137.  
  5138.          #include "cwlwin.h"
  5139.          #define NORM         CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5140.          #define BLUEONBLACK  CREATE_VIDEO_ATTRIBUTE(BLACK_,BLUE_)
  5141.          #define REDONBLACK   CREATE_VIDEO_ATTRIBUTE(BLACK_,RED_)
  5142.          #define GREENONBLACK CREATE_VIDEO_ATTRIBUTE(BLACK_,GREEN_)
  5143.          #define REVERSE      CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  5144.  
  5145.          main()
  5146.          {
  5147.            WPOINTER w0,w1;
  5148.            WindowInitializeSystem();
  5149.            WindowInitDesktop(0);
  5150.            w0 =
  5151.            WindowInitialize(DESKTOP_WINDOW,NOBORDER,0,0,80,25,
  5152.                             REVERSE,REVERSE,0);
  5153.            WindowDisplay(w0,1,NOEFFECT);
  5154.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,5,5,40,15,
  5155.                                  BLUEONBLACK,REDONBLACK,SINGLEBOX);
  5156.            WindowDrawShadow(w1,SHADOWUPLEFT,2,1,219,REVERSE,0);
  5157.            WindowDisplay(w1,1,NOEFFECT);
  5158.            WindowWriteString(w1,"Press a key to move shadow",0,0);
  5159.            GET_KEY();
  5160.            WindowDrawShadow(w1,SHADOWUPRIGHT,2,1,219,REVERSE,0);
  5161.            WindowWriteString(w1,"Press a key again",2,1);
  5162.            GET_KEY();
  5163.            WindowDrawShadow(w1,SHADOWLOWLEFT,2,1,219,REVERSE,0);
  5164.            WindowWriteString(w1,"Press a key once more",3,1);
  5165.            GET_KEY();
  5166.  
  5167.  
  5168.  
  5169.  
  5170.          Page 73          The C Window Library               Page 73
  5171.  
  5172.            WindowDrawShadow(w1,SHADOWLOWRIGHT,2,1,219,REVERSE,0);
  5173.            GET_KEY();
  5174.            WindowClose(w1,NOEFFECT);
  5175.            WindowClose(w0,NOEFFECT);
  5176.          }
  5177.  
  5178.  
  5179.          The above example illustrates the use of WindowDrawShadow().
  5180.  
  5181.                Return Values for WindowDrawShadow():
  5182.  
  5183.              Return Value         Definition
  5184.          ┌────────────────┬─────────────────────────────────────┐
  5185.          │NO_ERROR        │No error occured.                    │
  5186.          ├────────────────┼─────────────────────────────────────┤
  5187.          │BAD_WINDOW      │Window to copy from does not exist.  │
  5188.          ├────────────────┼─────────────────────────────────────┤
  5189.          │WINDOW_BOUND    │The rectangular region defined       │
  5190.          │                │is out of bounds of the window.      │
  5191.          ├────────────────┼─────────────────────────────────────┤
  5192.          │MAX_WINDOW      │Maximum number of windows defined.   │
  5193.          └────────────────┴─────────────────────────────────────┘
  5194.  
  5195.  
  5196.          WindowRemoveShadow()
  5197.          --------------------
  5198.  
  5199.          The WindowRemoveShadow() function removes a shadow from a
  5200.          window, and takes a single argument, namely the window
  5201.          pointer.  Here is the prototype:
  5202.  
  5203.                    int WindowRemoveShadow(WPOINTER w)
  5204.  
  5205.                Return Values for WindowRemoveShadow():
  5206.  
  5207.              Return Value         Definition
  5208.          ┌────────────────┬───────────────────────┐
  5209.          │NO_ERROR        │No error occured.      │
  5210.          ├────────────────┼───────────────────────┤
  5211.          │BAD_WINDOW      │Window does not exist. │
  5212.          └────────────────┴───────────────────────┘
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.          Page 74          The C Window Library               Page 74
  5231.  
  5232.                           SEE-THRU WINDOWS
  5233.                           ----------------
  5234.  
  5235.          You can create windows that have borders, but do not
  5236.          overwrite the screen underneath.  These windows are called
  5237.          see-thru windows.
  5238.  
  5239.          When creating see-thru windows the WindowMakeSeeThru()
  5240.          function is used to make a defined window a see-thru window.
  5241.  
  5242.          You can turn a non-seethru window into a seethru window and
  5243.          vice-versa by calling the WindowMakeNormal() function.
  5244.  
  5245.  
  5246.  
  5247.          WindowMakeSeeThru()
  5248.          -------------------
  5249.  
  5250.          The WindowMakeSeeThru() function turns a normal window into a
  5251.          see-thru window.  Here is a prototype:
  5252.  
  5253.                        int WindowMakeSeeThru(WPOINTER w)
  5254.  
  5255.          The only argument is the window pointer.  You can make a
  5256.          window a see-thru window at any time, including if it is
  5257.          hidden.  If there is text in the normal window before making
  5258.          it a see-thru window, the text is retained.  If text is
  5259.          written to a see-thru window, the text is written to the
  5260.          window's internal write buffer, but is not displayed on the
  5261.          screen.
  5262.  
  5263.  
  5264.          Example:
  5265.  
  5266.            #include "cwlwin.h"
  5267.  
  5268.            #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5269.  
  5270.            WPOINTER w;
  5271.  
  5272.            main()
  5273.            {
  5274.              WindowInitializeSystem();
  5275.              WindowInitDesktop(0);
  5276.              w =
  5277.              WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,5,
  5278.                               NORM,NORM,SINGLEBOX);
  5279.              WindowDisplay(w,1,NOEFFECT);
  5280.              GET_KEY();
  5281.  
  5282.              WindowMakeSeeThru(w);
  5283.              GET_KEY();
  5284.              WindowClose(w,NOEFFECT);
  5285.            }
  5286.  
  5287.  
  5288.  
  5289.  
  5290.          Page 75          The C Window Library               Page 75
  5291.  
  5292.          The example above displays a normal window, and then turns
  5293.          the normal window into a see-thru window when a key is
  5294.          pressed.
  5295.  
  5296.                Return Values for WindowMakeSeeThru():
  5297.  
  5298.              Return Value         Definition
  5299.          ┌────────────────┬───────────────────────┐
  5300.          │NO_ERROR        │No error occured.      │
  5301.          ├────────────────┼───────────────────────┤
  5302.          │BAD_WINDOW      │Window does not exist. │
  5303.          └────────────────┴───────────────────────┘
  5304.  
  5305.  
  5306.  
  5307.          WindowMakeNormal()
  5308.          ------------------
  5309.  
  5310.          The WindowMakeNormal() function turns a see-thru window into
  5311.          a normal text window.  Any text that may have been written to
  5312.          the window will be displayed.  Here is the prototype:
  5313.  
  5314.                      int WindowMakeNormal(WPOINTER w)
  5315.  
  5316.          Example:
  5317.  
  5318.            #include "cwlwin.h"
  5319.  
  5320.            #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5321.  
  5322.            WPOINTER w;
  5323.  
  5324.            main()
  5325.            {
  5326.              WindowInitializeSystem();
  5327.              WindowInitDesktop(0);
  5328.              w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,5,
  5329.                                   NORM,NORM,SINGLEBOX);
  5330.              WindowDisplay(w,1,NOEFFECT);
  5331.              GET_KEY();
  5332.              WindowMakeSeeThru(w);
  5333.              GET_KEY();
  5334.              WindowMakeNormal(w);
  5335.            }
  5336.  
  5337.          The example above demonstrates the WindowMakeNormal()
  5338.          function.
  5339.  
  5340.  
  5341.          Return Values for WindowMakeNormal():
  5342.  
  5343.              Return Value         Definition
  5344.          ┌────────────────┬───────────────────────┐
  5345.          │NO_ERROR        │No error occured.      │
  5346.          ├────────────────┼───────────────────────┤
  5347.          │BAD_WINDOW      │Window does not exist. │
  5348.          └────────────────┴───────────────────────┘
  5349.  
  5350.          Page 76          The C Window Library               Page 76
  5351.  
  5352.                      MOVING AND SLIDING WINDOWS
  5353.                      --------------------------
  5354.  
  5355.          With The C Window Library, you can move and slide windows on
  5356.          the parent window, or desktop window if the window is
  5357.          a top-level window.  The functions that perform this
  5358.          are the WindowMove() and WindowSlide().
  5359.  
  5360.  
  5361.          WindowMove()
  5362.          ------------
  5363.  
  5364.          The WindowMove() function moves a window to a new location in
  5365.          the parent window.  Here is the prototype:
  5366.  
  5367.                 int WindowMove(WPOINTER w, int row, int col)
  5368.  
  5369.          The first argument is the window.  The second and third
  5370.          arguments are the row and column on the parent to place the
  5371.          upper left hand corner of the window.  Note that row and
  5372.          column are parent-relative coordinates, not window relative.
  5373.          This is one of the few functions where row and column denote
  5374.          a position in the window's parent (the DESKTOP_WINDOW is the
  5375.          parent of a top-level window).
  5376.  
  5377.          Example:
  5378.  
  5379.          #include "cwlwin.h"
  5380.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5381.          #define BLUEONBLACK  CREATE_VIDEO_ATTRIBUTE(BLACK_,BLUE_)
  5382.  
  5383.          main()
  5384.          {
  5385.            WPOINTER w;
  5386.            WindowInitializeSystem();
  5387.            WindowInitDesktop(0);
  5388.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,15,
  5389.                                 BLUEONBLACK,NORM,SINGLEBOX);
  5390.            WindowWriteString(w,"Press a key to move me",0,0);
  5391.            WindowDisplay(w,1,NOEFFECT);
  5392.            GET_KEY();
  5393.            WindowMove(w,12,14);
  5394.          }
  5395.  
  5396.          The example above moves the window from its original position
  5397.          (0,0) to (12,14).
  5398.  
  5399.                    Return Values for WindowMove():
  5400.  
  5401.              Return Value         Definition
  5402.          ┌────────────────┬───────────────────────┐
  5403.          │NO_ERROR        │No error occured.      │
  5404.          ├────────────────┼───────────────────────┤
  5405.          │BAD_WINDOW      │Window does not exist. │
  5406.          └────────────────┴───────────────────────┘
  5407.  
  5408.  
  5409.  
  5410.          Page 77          The C Window Library               Page 77
  5411.  
  5412.          WindowSlide()
  5413.          -------------
  5414.  
  5415.          The WindowSlide() function "slides" a window from one
  5416.          position on the parent window to another.  Here is the
  5417.          prototype:
  5418.  
  5419.              int WindowSlide(WPOINTER w, int direction, int units)
  5420.  
  5421.          The first argument is the window.  The second argument tells
  5422.          in which direction to move the window, either up, down, left,
  5423.          or right.  The constants to use for up, down, left, and right
  5424.          are UP, DOWN, LEFT, and RIGHT, respectively.  The third
  5425.          argument tells how many rows or columns to move the window.
  5426.  
  5427.          Example:
  5428.  
  5429.          #include "cwlwin.h"
  5430.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5431.  
  5432.          #define BLUEONBLACK  CREATE_VIDEO_ATTRIBUTE(BLACK_,BLUE_)
  5433.  
  5434.  
  5435.          main()
  5436.          {
  5437.            WPOINTER w;
  5438.            WindowInitializeSystem();
  5439.            WindowInitDesktop(0);
  5440.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  5441.                                 BLUEONBLACK,NORM,SINGLEBOX);
  5442.            WindowWriteString(w,"Press a key to slide right",0,0);
  5443.            WindowDisplay(w,1,NOEFFECT);
  5444.            GET_KEY();
  5445.            WindowSlide(w,RIGHT,20);
  5446.            WindowWriteString(w,"Press a key to slide down",1,0);
  5447.            GET_KEY();
  5448.            WindowSlide(w,DOWN,10);
  5449.            WindowWriteString(w,"Press a key to slide left",2,0);
  5450.            GET_KEY();
  5451.            WindowSlide(w,LEFT,20);
  5452.            WindowWriteString(w,"Press a key to slide up",3,0);
  5453.            GET_KEY();
  5454.            WindowSlide(w,UP,20);
  5455.          }
  5456.  
  5457.  
  5458.  
  5459.          The example above illustrates how to use the WindowSlide()
  5460.          function.
  5461.  
  5462.          The return values for WindowSlide() are the same as
  5463.          WindowMove().
  5464.  
  5465.  
  5466.  
  5467.  
  5468.  
  5469.  
  5470.          Page 78          The C Window Library               Page 78
  5471.  
  5472.                     CURSOR POSITIONING IN WINDOWS
  5473.                     -----------------------------
  5474.  
  5475.          You can change the position of the cursor and its shape in
  5476.          the windows you create with The C Window Library.
  5477.  
  5478.  
  5479.  
  5480.          Cursor Maintenance in The C Window Library
  5481.          ------------------------------------------
  5482.  
  5483.          As was stated before, The C Window Library can write to any
  5484.          window at any time.  This makes the question "which window
  5485.          owns the cursor?" a hard question to answer.  One method is
  5486.          that the window being updated either by writing text,
  5487.          clearing, etc. should have immediate control of the cursor.
  5488.          The approach The C Window Library has taken is that the
  5489.          topmost window always has control of the cursor.  The topmost
  5490.          window is the top-level window with the lowest rank number.
  5491.          Windows with low rank numbers overlay windows with higher
  5492.          rank numbers.
  5493.  
  5494.  
  5495.  
  5496.          Creating Cursor Shapes
  5497.          ----------------------
  5498.  
  5499.          The C Window Library has four pre-defined cursor shapes;
  5500.          INVISIBLE, THIN, BLOCK, and HALFBLOCK.  An INVISIBLE cursor
  5501.          hides the cursor, a BLOCK shape creates a "fat" cursor, and
  5502.          THIN creates a thin cursor.  The HALFBLOCK cursor is
  5503.          between a BLOCK and a THIN cursor.
  5504.  
  5505.          If you want to define your own cursor shapes, use the
  5506.          CREATE_CURSOR_SHAPE() macro.  This macro takes two arguments
  5507.          the first argument is the beginning scan line, and the second
  5508.          argument is the ending scan line.  Scan lines determine the
  5509.          height of the cursor.  For monochrome systems, the scan lines
  5510.          range from 0 to 13.  In a color system, the scan lines range
  5511.          from 0 to 7.  A THIN cursor has its starting scan line at 6
  5512.          and its ending scan line at 7 for color systems, and for
  5513.          monochrome systems, the starting scan line is 11 and its
  5514.          ending scan line is at 12.  If the starting scan line number
  5515.          is greater than the ending scan line number, the cursor takes
  5516.          on a 'double' cursor shape.  Experiment with different
  5517.          starting and ending scan lines for the desired effect.
  5518.  
  5519.  
  5520.  
  5521.          WindowChangeCursor()
  5522.          --------------------
  5523.  
  5524.          The WindowChangeCursor() function changes the shape of the
  5525.          cursor in a window.  Here is the prototype:
  5526.  
  5527.                 int WindowChangeCursor(WPOINTER w, int shape)
  5528.  
  5529.  
  5530.          Page 79          The C Window Library               Page 79
  5531.  
  5532.          The first argument is the window.  The second argument is the
  5533.          desired cursor shape.
  5534.  
  5535.  
  5536.          Example:
  5537.  
  5538.          #include "cwlwin.h"
  5539.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5540.  
  5541.          WPOINTER w;
  5542.  
  5543.          main()
  5544.          {
  5545.            WindowInitializeSystem();
  5546.            WindowInitDesktop(0);
  5547.            w =
  5548.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  5549.                             NORM,NORM,SINGLEBOX);
  5550.            WindowDisplay(w,1,NOEFFECT);
  5551.            WindowWriteString(w,"Press a key to change cursor",0,0);
  5552.            GET_KEY();
  5553.            WindowChangeCursor(w,BLOCK);
  5554.            WindowWriteString(w,"Press a key to change cursor again",
  5555.                              1,0);
  5556.            GET_KEY();
  5557.            WindowChangeCursor(w,INVISIBLE);
  5558.            WindowWriteString(w,"Press a key to change cursor again",
  5559.                              2,0);
  5560.            GET_KEY();
  5561.            WindowChangeCursor(w,THIN);
  5562.          }
  5563.  
  5564.  
  5565.  
  5566.                Return Values for WindowChangeCursor():
  5567.  
  5568.              Return Value         Definition
  5569.          ┌────────────────┬───────────────────────┐
  5570.          │NO_ERROR        │No error occured.      │
  5571.          ├────────────────┼───────────────────────┤
  5572.          │BAD_WINDOW      │Window does not exist. │
  5573.          └────────────────┴───────────────────────┘
  5574.  
  5575.  
  5576.  
  5577.          WindowMoveCursor()
  5578.          ------------------
  5579.  
  5580.          The WindowMoveCursor() functions moves the cursor in a window
  5581.          to a new location in the window.  Here is the prototype:
  5582.  
  5583.             int WindowMoveCursor(WPOINTER w, int row, int col)
  5584.  
  5585.  
  5586.  
  5587.  
  5588.  
  5589.  
  5590.          Page 80          The C Window Library               Page 80
  5591.  
  5592.          The first argument is the window, and the second and third
  5593.          arguments are the new (row,col) position in the window to
  5594.          place the cursor.
  5595.  
  5596.  
  5597.          Example:
  5598.  
  5599.          #include "cwlwin.h"
  5600.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5601.  
  5602.          WPOINTER w;
  5603.  
  5604.          main()
  5605.          {
  5606.            WindowInitializeSystem();
  5607.            WindowInitDesktop(0);
  5608.            w =
  5609.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  5610.                             NORM,NORM,SINGLEBOX);
  5611.            WindowDisplay(w,1,NOEFFECT);
  5612.            WindowWriteString(w,"Press a key to move cursor",0,0);
  5613.            GET_KEY();
  5614.            WindowMoveCursor(w,7,5);
  5615.          }
  5616.  
  5617.  
  5618.  
  5619.                 Return Values for WindowMoveCursor():
  5620.  
  5621.              Return Value         Definition
  5622.          ┌────────────────┬────────────────────────────────────┐
  5623.          │NO_ERROR        │No error occured.                   │
  5624.          ├────────────────┼────────────────────────────────────┤
  5625.          │BAD_WINDOW      │Window does not exist.              │
  5626.          ├────────────────┼────────────────────────────────────┤
  5627.          │WINDOW_BOUND    │Row or column number is             │
  5628.          │                │out of the boundaries of the window │
  5629.          └────────────────┴────────────────────────────────────┘
  5630.  
  5631.  
  5632.  
  5633.          WindowGetCursorShape()
  5634.          ----------------------
  5635.  
  5636.          The WindowGetCursorShape() function returns the starting and
  5637.          ending scan lines of the cursor defined in a window.  Here is
  5638.          the prototype:
  5639.  
  5640.  
  5641.          int WindowGetCursorShape(WPOINTER w, int *startline,
  5642.                                   int *endline)
  5643.  
  5644.          The startline and endline arguments are pointers to integers
  5645.          that will contain the starting and ending scan lines of the
  5646.          cursor when WindowGetCursorShape() returns.
  5647.  
  5648.  
  5649.  
  5650.          Page 81          The C Window Library               Page 81
  5651.  
  5652.          Example:
  5653.  
  5654.          #include "cwlwin.h"
  5655.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5656.  
  5657.          WPOINTER w;
  5658.  
  5659.          main()
  5660.          {
  5661.            int startline,endline;
  5662.            WindowInitializeSystem();
  5663.            WindowInitDesktop(0);
  5664.            w =
  5665.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  5666.                             NORM,NORM,SINGLEBOX);
  5667.            WindowDisplay(w,1,NOEFFECT);
  5668.            WindowGetCursorShape(w,&startline,&endline);
  5669.            WindowPrintf(w,
  5670.            "The starting scan line is %d\nThe ending scan line is %d",
  5671.                         startline,endline);
  5672.          }
  5673.  
  5674.  
  5675.          The example above calls WindowGetCursorShape() and uses
  5676.          WindowPrintf() to print what the starting and ending scan
  5677.          lines are.
  5678.  
  5679.               Return Values for WindowGetCursorShape():
  5680.  
  5681.              Return Value         Definition
  5682.          ┌────────────────┬───────────────────────┐
  5683.          │NO_ERROR        │No error occured.      │
  5684.          ├────────────────┼───────────────────────┤
  5685.          │BAD_WINDOW      │Window does not exist. │
  5686.          └────────────────┴───────────────────────┘
  5687.  
  5688.  
  5689.          WindowGetCursorPosition()
  5690.          -------------------------
  5691.  
  5692.          The WindowGetCursorPosition() function gives the current row
  5693.          and column of the cursor in a window.  Here is the prototype:
  5694.  
  5695.          int WindowGetCursorPosition(WPOINTER w, int *row, int *col)
  5696.  
  5697.          The row and col arguments are pointers to integers that will
  5698.          contain the row and column of the cursor after
  5699.          WindowGetCursorPosition() is called.
  5700.  
  5701.  
  5702.  
  5703.  
  5704.  
  5705.  
  5706.  
  5707.  
  5708.  
  5709.  
  5710.          Page 82          The C Window Library               Page 82
  5711.  
  5712.          Example:
  5713.  
  5714.          #include "cwlwin.h"
  5715.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5716.  
  5717.  
  5718.          WPOINTER w;
  5719.  
  5720.          main()
  5721.          {
  5722.            int row,col;
  5723.            WindowInitializeSystem();
  5724.            WindowInitDesktop(0);
  5725.            w =
  5726.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  5727.                             NORM,NORM,SINGLEBOX);
  5728.            WindowDisplay(w,1,NOEFFECT);
  5729.            WindowMoveCursor(w,7,4);
  5730.            WindowGetCursorPosition(w,&row,&col);
  5731.            WindowPrintf(w,
  5732.                         "The row of the cursor is %d\n"
  5733.                         "The column of the cursor is %d", row,col);
  5734.          }
  5735.  
  5736.  
  5737.             Return Values for WindowGetCursorPosition():
  5738.  
  5739.              Return Value         Definition
  5740.          ┌────────────────┬───────────────────────┐
  5741.          │NO_ERROR        │No error occured.      │
  5742.          ├────────────────┼───────────────────────┤
  5743.          │BAD_WINDOW      │Window does not exist. │
  5744.          └────────────────┴───────────────────────┘
  5745.  
  5746.  
  5747.  
  5748.  
  5749.  
  5750.  
  5751.  
  5752.  
  5753.  
  5754.  
  5755.  
  5756.  
  5757.  
  5758.  
  5759.  
  5760.  
  5761.  
  5762.  
  5763.  
  5764.  
  5765.  
  5766.  
  5767.  
  5768.  
  5769.  
  5770.          Page 83          The C Window Library               Page 83
  5771.  
  5772.               GETTING WHICH WINDOW OCCUPIES A LOCATION
  5773.               ----------------------------------------
  5774.  
  5775.          You can determine the WPOINTER which occupies a location on
  5776.          the screen.  If you have multiple windows displayed, this can
  5777.          be very useful if you have overlaps and want to know which
  5778.          window is visible in a given screen location.
  5779.  
  5780.  
  5781.          WindowWhich()
  5782.          -------------
  5783.  
  5784.          The WindowWhich() function determines which window is visible
  5785.          on a given desktop window location.  Here is the prototype:
  5786.  
  5787.               WPOINTER WindowWhich(int row, int col, int page)
  5788.  
  5789.          Note that WindowWhich() returns a WPOINTER.  The arguments
  5790.          row and col are desktop (screen) coordinates.  The last
  5791.          argument, page, is the video page to use when determining
  5792.          which window lies in position (row,col).  The WPOINTER that
  5793.          is returned is the WPOINTER that occupies the specified
  5794.          screen location.
  5795.  
  5796.  
  5797.          #include "cwlwin.h"
  5798.  
  5799.          WPOINTER w1, w2, w3, w4, w5;
  5800.          main()
  5801.          {
  5802.             /* ... Assume everything including windows have been
  5803.                    initialized and opened           */
  5804.  
  5805.            if (WindowWhich(4,7,0) == w1)
  5806.            {
  5807.              /* some part of w1 is visible on row 4 column 7 of the
  5808.                 screen (video page 0) */
  5809.            }
  5810.          }
  5811.  
  5812.  
  5813.           The above example calls WindowWhich to determine if w1
  5814.           is visible on position (4,7) of video page 0.
  5815.           Refer to the INTRODUCTION on video pages.
  5816.  
  5817.           If there is no window visible for a given screen location,
  5818.           WIN_NULL_PTR is returned.  The base screen will always
  5819.           return a WIN_NULL_PTR.
  5820.  
  5821.           To convert from local window coordinates to desktop
  5822.           coordinates and vice-versa, refer to the CHILD WINDOWS
  5823.           section in this manual.
  5824.  
  5825.  
  5826.  
  5827.  
  5828.  
  5829.  
  5830.          Page 84          The C Window Library               Page 84
  5831.  
  5832.                      GETTING INPUT FROM WINDOWS
  5833.                      --------------------------
  5834.  
  5835.          With The C Window Library, you can read input from windows.
  5836.          The input can be simple string input, or inputting strings
  5837.          with a character mask.  There is also support for scrolling
  5838.          input fields.
  5839.  
  5840.  
  5841.  
  5842.  
  5843.          Input Manager
  5844.          -------------
  5845.  
  5846.          The input manager are functions internal in The C Window
  5847.          Library that control editing, checking for invalid
  5848.          characters, cursor movement, etc.
  5849.  
  5850.  
  5851.          Regular Expressions
  5852.          -------------------
  5853.  
  5854.          With The C Window Library, you specify exactly what
  5855.          characters are to be expected for every input position by
  5856.          using a special string of characters called a regular
  5857.          expression (a pattern matching string).
  5858.  
  5859.          Note:
  5860.          For those who are familiar with regular expressions, there is
  5861.          a difference between the regular expressions you will see
  5862.          here, and the regular expressions you will find in certain
  5863.          text editors, or in computer language syntax definitions.
  5864.          One major difference is that there are no wild cards denoting
  5865.          an arbitrary number of repeated characters (which is usually
  5866.          denoted by a '*' or a '+'), and there are no 'match begin of
  5867.          string' and 'match end of string' functions.
  5868.  
  5869.  
  5870.  
  5871.          An example of a regular expression would be the string
  5872.          "[A-Z]" which means only those characters that are between  A
  5873.          and Z, inclusive, are to be accepted as valid input
  5874.          characters.  Of course, the ASCII collating sequence is used.
  5875.  
  5876.          The following characters have special meanings in regular
  5877.          expressions:
  5878.  
  5879.           Character              Purpose
  5880.         ┌─────────────────────┬────────────────────────────────────┐
  5881.         │ Forward Slash (/)   │  Removes the special meaning of the│
  5882.         │                     │  next character in the regular     │
  5883.         │                     │  expression.                       │
  5884.         └─────────────────────┴────────────────────────────────────┘
  5885.  
  5886.  
  5887.  
  5888.  
  5889.  
  5890.          Page 85          The C Window Library               Page 85
  5891.  
  5892.           Character              Purpose
  5893.         ┌─────────────────────┬───────────────────────────────────────┐
  5894.         │ Brackets ([])       │  Encloses a set of characters to be   │
  5895.         │                     │  matched with the current character   │
  5896.         │                     │  entered at the keyboard.  There are  │
  5897.         │                     │  other special symbols that can appear│
  5898.         │                     │  in brackets:                         │
  5899.         └─────────────────────┼─────────────┬─────────────────────────┤
  5900.                               │  Carat (^)  │ This symbol states that │
  5901.                               │             │ the character entered at│
  5902.                               │             │ the keyboard must not   │
  5903.                               │             │ match any character in  │
  5904.                               │             │ the brackets.  The carat│
  5905.                               │             │ must be the first       │
  5906.                               │             │ character after the left│
  5907.                               │             │ bracket ([), otherwise  │
  5908.                               │             │ the carat is taken      │
  5909.                               │             │ literally as just       │
  5910.                               │             │ another character.      │
  5911.                               ├─────────────┼─────────────────────────┤
  5912.                               │  Dash  (-)  │ Matches character       │
  5913.                               │             │ entered at keyboard with│
  5914.                               │             │ characters in ASCII     │
  5915.                               │             │ order between           │
  5916.                               │             │ (inclusive) the         │
  5917.                               │             │ characters on either    │
  5918.                               │             │ side of the dash.       │
  5919.                               ├─────────────┼─────────────────────────┤
  5920.                               │  Dot   (.)  │ Matches any displayable │
  5921.                               │             │ ASCII character.        │
  5922.                               └─────────────┴─────────────────────────┘
  5923.  
  5924.          There are two categories of regular expressions; namely
  5925.          simple and complex.  Simple regular expressions only specify
  5926.          a single character to be entered from the keyboard, while
  5927.          complex regular expressions specify that more than a single
  5928.          character must be entered from the keyboard.
  5929.  
  5930.          Here are examples of simple regular expressions:
  5931.  
  5932.               Simple
  5933.               Regular
  5934.               Expression   What will be accepted
  5935.               ┌────────┬───────────────────────────────┐
  5936.               │[0-9]   │  Accept any single digit      │
  5937.               │        │  character.                   │
  5938.               ├────────┼───────────────────────────────┤
  5939.               │[3-7]   │  Accept single digit character│
  5940.               │        │  between '3' and '7'          │
  5941.               │        │  inclusive.                   │
  5942.               ├────────┼───────────────────────────────┤
  5943.               │[A-Z]   │  Accept a letter between 'A'  │
  5944.               │        │  and 'Z' inclusive.           │
  5945.               └────────┴───────────────────────────────┘
  5946.  
  5947.  
  5948.  
  5949.  
  5950.          Page 86          The C Window Library               Page 86
  5951.  
  5952.              ┌───────────┬────────────────────────────────┐
  5953.              │[A-Za-z]   │  Accept a letter between 'A'   │
  5954.              │           │  and 'Z' or a letter between   │
  5955.              │           │  'a' and 'z'.                  │
  5956.              ├───────────┼────────────────────────────────┤
  5957.              │[ABCD]     │  Accept either 'A', 'B', 'C',  │
  5958.              │           │  or 'D'.                       │
  5959.              ├───────────┼────────────────────────────────┤
  5960.              │[A-Za-z0-9]│  Accept anything between 'A'   │
  5961.              │           │  and 'Z', or 'a' and 'z', or   │
  5962.              │           │  '0' and '9'                   │
  5963.              ├───────────┼────────────────────────────────┤
  5964.              │[0-9ABCD]  │  Accept '0' thru '9', 'A',     │
  5965.              │           │  'B', 'C', or 'D'.             │
  5966.              ├───────────┼────────────────────────────────┤
  5967.              │[^A]       │  Accept any character except   │
  5968.              │           │  'A'.                          │
  5969.              ├───────────┼────────────────────────────────┤
  5970.              │[^A-Z]     │  Accept any character except   │
  5971.              │           │  the characters between 'A'    │
  5972.              │           │  and 'Z' (inclusive).          │
  5973.              ├───────────┼────────────────────────────────┤
  5974.              │[A-/[]     │  Accept any character between  │
  5975.              │           │  'A' and '[', inclusive.       │
  5976.              │           │  Please note the use of the    │
  5977.              │           │  forward slash to denote that  │
  5978.              │           │  the left bracket has no       │
  5979.              │           │  special meaning.              │
  5980.              ├───────────┼────────────────────────────────┤
  5981.              │[A Z]      │  Accept 'A', the space         │
  5982.              │           │  character, or 'Z'.            │
  5983.              ├───────────┼────────────────────────────────┤
  5984.              │[A/-Z]     │  Accept 'A', the minus (-), or │
  5985.              │           │  'Z'.                          │
  5986.              ├───────────┼────────────────────────────────┤
  5987.              │[/-///]]   │  Accept the minus (-), the     │
  5988.              │           │  forward slash (/), or the     │
  5989.              │           │  right bracket (]).            │
  5990.              ├───────────┼────────────────────────────────┤
  5991.              │[!-&]      │  Accept the ASCII characters   │
  5992.              │           │  between '!' and '&',          │
  5993.              │           │  inclusive.                    │
  5994.              ├───────────┼────────────────────────────────┤
  5995.              │A          │  Accept the letter 'A'.  Note  │
  5996.              │           │  that this is equivalent to    │
  5997.              │           │  [A].                          │
  5998.              ├───────────┼────────────────────────────────┤
  5999.              │[9]        │  Accept the digit '9'.         │
  6000.              ├───────────┼────────────────────────────────┤
  6001.              │.          │  Accept any character.         │
  6002.              ├───────────┼────────────────────────────────┤
  6003.              │[]         │  Accept no key and call user   │
  6004.              │           │  defined function (explained   │
  6005.              │           │  later in the UNDEFINED        │
  6006.              │           │  KEYSTROKE PROCESSING          │
  6007.              │           │  section).                     │
  6008.              └───────────┴────────────────────────────────┘
  6009.  
  6010.          Page 87          The C Window Library               Page 87
  6011.  
  6012.              ┌───────────┬───────────────────────────────┐
  6013.              │#          │  Accept a numeric digit.  This│
  6014.              │           │  is shorthand for [0-9].      │
  6015.              ├───────────┼───────────────────────────────┤
  6016.              │@          │  Accept an alphabetic         │
  6017.              │           │  character.  This is shorthand│
  6018.              │           │  for [A-Za-z].                │
  6019.              └───────────┴───────────────────────────────┘
  6020.  
  6021.          Remember, all of the above expressions process only one
  6022.          character entered at the keyboard, even though some of the
  6023.          expressions can accept a variety of characters.
  6024.  
  6025.          As you can see there are many possibilities you can make up.
  6026.          However the above forms of a regular expressions only work
  6027.          for one character entered at the keyboard.  What if you want
  6028.          to enter a persons name, address, social security number
  6029.          etc.?  You can concatenate (glue together) the regular
  6030.          expressions above to form a chain of regular expressions.
  6031.          This resulting chain is called a complex regular expression.
  6032.          Here are a few examples of complex regular expressions:
  6033.  
  6034.               Regular Expression        What will be accepted
  6035.          ┌──────────────────────────┬──────────────────────────────┐
  6036.          │[A-Z][0-9]                │ The first character entered  │
  6037.          │                          │ must be between 'A' and 'Z'. │
  6038.          │                          │ The second character entered │
  6039.          │                          │ must be between '0' and '9'. │
  6040.          ├──────────────────────────┼──────────────────────────────┤
  6041.          │[A-Z][^A-Z][0-9]          │ Enter three characters.  The │
  6042.          │                          │ first must be between 'A' and│
  6043.          │                          │ 'Z'.  The second can be any  │
  6044.          │                          │ character except anything    │
  6045.          │                          │ between 'A' and 'Z', and the │
  6046.          │                          │ third character must be      │
  6047.          │                          │ between '0' and '9'.         │
  6048.          ├──────────────────────────┼──────────────────────────────┤
  6049.          │[1-9][0-9][0-9][0-9][0-9] │ Enter five characters.  The  │
  6050.          │                          │ first must be between '1' and│
  6051.          │                          │ '9'.  The other four         │
  6052.          │                          │ characters must be between   │
  6053.          │                          │ '0' and '9'.                 │
  6054.          ├──────────────────────────┼──────────────────────────────┤
  6055.          │[A-Z][][0-9]              │ The first character must be  │
  6056.          │                          │ between 'A' and 'Z', the     │
  6057.          │                          │ second input position calls a│
  6058.          │                          │ user defined function        │
  6059.          │                          │ (explained in UNDEFINED      │
  6060.          │                          │ KEYSTROKE PROCESSING), and   │
  6061.          │                          │ the third character must be  │
  6062.          │                          │ between '0' and '9'.         │
  6063.          └──────────────────────────┴──────────────────────────────┘
  6064.  
  6065.          As you can see again, the strings can get pretty long if you
  6066.          wanted to setup a thirty character input specification, for
  6067.          instance, a persons name.  To save time typing, you can use a
  6068.          multiplying factor in the regular expression.  A multiplying
  6069.  
  6070.          Page 88          The C Window Library               Page 88
  6071.  
  6072.          factor is a number that is placed before a simple regular
  6073.          expression to denote that the simple regular expression is
  6074.          repeated.
  6075.  
  6076.          Here are a few examples:
  6077.  
  6078.          Regular Expression    What will be accepted
  6079.          ┌───────────────────┬───────────────────────────────────────┐
  6080.          │25[A-Z]            │Enter twenty-five characters.  All the │
  6081.          │                   │characters must be between 'A' and 'Z'.│
  6082.          ├───────────────────┼───────────────────────────────────────┤
  6083.          │10[0-9]            │Enter ten characters.  All must be     │
  6084.          │                   │between '0' and '9'.                   │
  6085.          ├───────────────────┼───────────────────────────────────────┤
  6086.          │5[A-C] 3[1-3]      │Enter nine characters. The first five  │
  6087.          │                   │must be between 'A' and 'C' the sixth  │
  6088.          │                   │must be the space character, and the   │
  6089.          │                   │last three must be between '1' and '3'.│
  6090.          │                   │Please note the space embedded in the  │
  6091.          │                   │string just before the multiplying     │
  6092.          │                   │factor 3.                              │
  6093.          ├───────────────────┼───────────────────────────────────────┤
  6094.          │[1-9]2X/[5[^A-Z]/1 │Enter nine characters.  The first must │
  6095.          │                   │be between '1' and '9'.  The second and│
  6096.          │                   │third must be 'X'. The fourth is the   │
  6097.          │                   │left bracket ([).  The next five       │
  6098.          │                   │characters entered can be any character│
  6099.          │                   │except anything between 'A' and 'Z',   │
  6100.          │                   │and the last character to accept is a  │
  6101.          │                   │'1'.  Please note the use of the       │
  6102.          │                   │forward slash just before the second   │
  6103.          │                   │left bracket and just before the last  │
  6104.          │                   │character ('1').  The forward slash    │
  6105.          │                   │before the '1' makes sure the '1' is   │
  6106.          │                   │not to be confused with a multiplying  │
  6107.          │                   │factor of 1.                           │
  6108.          ├───────────────────┼───────────────────────────────────────┤
  6109.          │[A-Z]/..           │Enter three characters.  The first must│
  6110.          │                   │be between 'A' and 'Z'.  The second is │
  6111.          │                   │the '.', and the third is any          │
  6112.          │                   │character.                             │
  6113.          ├───────────────────┼───────────────────────────────────────┤
  6114.          │10[A-Z]3[]         │Enter thirteen characters.  The first  │
  6115.          │                   │ten must be between 'A' and 'Z', and   │
  6116.          │                   │the last three input positions will    │
  6117.          │                   │call a user defined undefined key      │
  6118.          │                   │function (explained later in the       │
  6119.          │                   │UNDEFINED KEYSTROKE PROCESSING         │
  6120.          │                   │section).                              │
  6121.          └───────────────────┴───────────────────────────────────────┘
  6122.  
  6123.          The only limitation to what you can do with regular
  6124.  
  6125.          expressions is that you cannot nest regular expressions.  For
  6126.          example:
  6127.  
  6128.                         [A-[A-Z]]     or     20[20[a-z]]
  6129.  
  6130.          Page 89          The C Window Library               Page 89
  6131.  
  6132.          It is ok to say [9-0] instead of [0-9].  They are both
  6133.          equivalent and both accepted by The C Window Library, so
  6134.          there is no need to know your ASCII table by heart, although
  6135.          it is advantageous to learn it if you want to create
  6136.          sophisticated regular expression strings.  You can even use
  6137.          the IBM extended character set (ASCII values above 127) in
  6138.          the regular expression string.
  6139.  
  6140.  
  6141.          Editing Input
  6142.          -------------
  6143.  
  6144.          The C library function gets(x), gets a string from the
  6145.          keyboard and points the character pointer x to the string.
  6146.          This function has limited editing capabilities.  The only
  6147.          keys recognized are the backspace, which serves as a
  6148.          destructive backspace (erases character immediately to the
  6149.          left) and the enter key when the user has typed in the
  6150.          desired string.  With The C Window Library, you have much
  6151.          more editing capabilities.
  6152.  
  6153.  
  6154.          The editing functions have the following default key values:
  6155.  
  6156.                                                               Mapped
  6157.            Function                               Key        Position
  6158.         ┌───────────────────────────────────┬──────────────────┬───┐
  6159.         │Move cursor left                   │Left Arrow        │ 0 │
  6160.         ├───────────────────────────────────┼──────────────────┼───┤
  6161.         │Move cursor right                  │Right Arrow       │ 1 │
  6162.         ├───────────────────────────────────┼──────────────────┼───┤
  6163.         │Delete character at cursor         │Del (on keypad)   │ 2 │
  6164.         ├───────────────────────────────────┼──────────────────┼───┤
  6165.         │Toggle Insert/Overwrite mode       │Insert (on keypad)│ 3 │
  6166.         ├───────────────────────────────────┼──────────────────┼───┤
  6167.         │Erase Input and go to first column │^E                │ 4 │
  6168.         ├───────────────────────────────────┼──────────────────┼───┤
  6169.         │Destructive backspace              │Backspace         │ 5 │
  6170.         ├───────────────────────────────────┼──────────────────┼───┤
  6171.         │Accept Input and return            │Enter             │ 6 │
  6172.         ├───────────────────────────────────┼──────────────────┼───┤
  6173.         │Accept default and return          │Escape            │ 7 │
  6174.         ├───────────────────────────────────┼──────────────────┼───┤
  6175.         │Go to first column                 │Home              │ 8 │
  6176.         ├───────────────────────────────────┼──────────────────┼───┤
  6177.         │Move cursor to last char. entered  │End               │ 9 │
  6178.         └───────────────────────────────────┴──────────────────┴───┘
  6179.  
  6180.  
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.          Page 90          The C Window Library               Page 90
  6191.  
  6192.          Here is a list of what the key functions perform:
  6193.  
  6194.         ┌───────────────────┬──────────────────────────────────────┐
  6195.         │Move cursor left   │Moves the cursor left one character.  │
  6196.         │                   │If the beginning of the input field is│
  6197.         │                   │encountered the cursor is not moved.  │
  6198.         ├───────────────────┼──────────────────────────────────────┤
  6199.         │Move cursor right  │Moves the cursor right one character. │
  6200.         │                   │If the end of the input field is      │
  6201.         │                   │encountered, the cursor is not moved. │
  6202.         ├───────────────────┼──────────────────────────────────────┤
  6203.         │Delete character   │Deletes the character at the position │
  6204.         │at cursor          │of the cursor.  If in insert mode,    │
  6205.         │                   │any input to the right of the cursor  │
  6206.         │                   │is moved one character to the left.   │
  6207.         │                   │If in overwrite mode, no characters   │
  6208.         │                   │are moved.                            │
  6209.         ├───────────────────┼──────────────────────────────────────┤
  6210.         │Toggle             │Toggles the input between insert and  │
  6211.         │Insert/Overwrite   │overwrite mode. In insert mode, the   │
  6212.         │                   │default cursor is an underline cursor.│
  6213.         │                   │If in overwrite mode, the default     │
  6214.         │                   │cursor is a full block.               │
  6215.         ├───────────────────┼──────────────────────────────────────┤
  6216.         │Erase Input        │Deletes all characters inputted and   │
  6217.         │                   │moves the cursor to the first input   │
  6218.         │                   │position.                             │
  6219.         ├───────────────────┼──────────────────────────────────────┤
  6220.         │Destructive        │Deletes the character immediately to  │
  6221.         │Backspace          │the left of the cursor and moves the  │
  6222.         │                   │cursor to the left one character. If  │
  6223.         │                   │insert mode is on, the characters from│
  6224.         │                   │the current cursor position to the end│
  6225.         │                   │of the input field are also moved.    │
  6226.         ├───────────────────┼──────────────────────────────────────┤
  6227.         │Accept string      │Accepts the string that is inputted   │
  6228.         │                   │and returns the string.               │
  6229.         ├───────────────────┼──────────────────────────────────────┤
  6230.         │Accept default     │Returns the default string given to   │
  6231.         │and return         │the input routine.                    │
  6232.         ├───────────────────┼──────────────────────────────────────┤
  6233.         │Go to first column │Moves cursor to the first input       │
  6234.         │                   │position.                             │
  6235.         ├───────────────────┼──────────────────────────────────────┤
  6236.         │Go to last         │Moves cursor to the last character in │
  6237.         │character          │the current input string.             │
  6238.         └───────────────────┴──────────────────────────────────────┘
  6239.  
  6240.          The keys used to perform these functions can be changed.  The
  6241.          mapped position is the offset in a table of key functions.
  6242.          By changing the value there, you can change the key used to
  6243.          perform these functions.  If you do want to change these
  6244.          keys, I recommend using the key definitions found in the
  6245.          cwlwin.h file.  For example, if you wanted Control-B to be
  6246.          the destructive backspace you would do as follows:
  6247.  
  6248.  
  6249.  
  6250.          Page 91          The C Window Library               Page 91
  6251.  
  6252.                CWLedit_key[5] = CTRLB;
  6253.  
  6254.          The table of key functions is stored in the array
  6255.          CWLedit_key.  The CTRLB stands for Control-B and its
  6256.          definition is found in the cwlwin.h file.  To totally
  6257.          undefine a key definition, assign a 0 to the desired array
  6258.          position in CWLedit_key.  For example:
  6259.  
  6260.                CWLedit_key[2] = 0;
  6261.  
  6262.          undefines the delete character at cursor definition.
  6263.  
  6264.          When changing keys, make sure that the definitions all have
  6265.          unique key combinations.  If you desire more keystrokes for a
  6266.          particular key function, see Undefined Keystroke Processing
  6267.          below.
  6268.  
  6269.  
  6270.          Last Key Value
  6271.          --------------
  6272.  
  6273.          On exit of any of the input functions, the global integer
  6274.          CWLlast_key contains the ascii code (scan code) of the key
  6275.          that was used to exit the input function.
  6276.  
  6277.  
  6278.  
  6279.          Default Cursor Types and Editing Mode
  6280.          -------------------------------------
  6281.  
  6282.          By default, The C Window Library starts editing input in
  6283.          overstrike mode.  This means that characters are overwritten
  6284.          when the cursor is placed on a character.  The opposite of
  6285.          overstrike mode is insert mode, which pushes the characters
  6286.          to the right of the cursor over by one input position when a
  6287.          character is entered.  Also, the default cursor type for
  6288.          overstrike mode is a block cursor, and the default cursor for
  6289.          insert mode is a thin cursor.  You can change the startup
  6290.          mode, as well as the cursor types.
  6291.  
  6292.          The global variables CWLcursor_type and CWLcursor_mode store
  6293.          the values of the cursor shapes and the startup mode.
  6294.  
  6295.          The CWLcursor_type is an array of two integers.  The
  6296.          OVERSTRIKEMODE constant is the position in the CWLcursor_type
  6297.          array of where the overstrike shape of the cursor is stored.
  6298.          The INSERTMODE constant is the position in CWLcursor_type of
  6299.          where the insert shape of the cursor is stored.  Here is an
  6300.          example of how you would change the cursor types.
  6301.  
  6302.  
  6303.  
  6304.  
  6305.  
  6306.  
  6307.  
  6308.  
  6309.  
  6310.          Page 92          The C Window Library               Page 92
  6311.  
  6312.          #include "cwlwin.h"
  6313.  
  6314.          main()
  6315.          {
  6316.            WindowInitializeSystem();
  6317.            /*...*/                  /* Some code */
  6318.  
  6319.            CWLcursor_type[OVERSTRIKEMODE] =
  6320.                                        CREATE_CURSOR_SHAPE(6,7);
  6321.            CWLcursor_type[INSERTMODE] = THIN;
  6322.          }
  6323.  
  6324.          The CREATE_CURSOR_SHAPE() macro creates a cursor shape by
  6325.          using the first argument as the starting scan line of the
  6326.          cursor, and the second argument as the ending scan line.
  6327.          Refer to VIDEO MACROS section for more information on
  6328.          CREATE_CURSOR_SHAPE().  The THIN constant is a predefined
  6329.          constant that stands for a thin cursor.  The other predefined
  6330.          constants for cursor shapes are BLOCK and INVISIBLE.
  6331.  
  6332.          To change the startup mode when an input function is called,
  6333.          you must change the CWLcursor_mode global variable.  Here is
  6334.          how you would change the default mode:
  6335.  
  6336.          #include "cwlwin.h"
  6337.  
  6338.          main()
  6339.          {
  6340.            WindowInitializeSystem();
  6341.            /*...*/                  /* Some code */
  6342.            CWLcursor_mode = OVERSTRIKEMODE;
  6343.          }
  6344.  
  6345.          Use the constants OVERSTRIKEMODE and INSERTMODE for the
  6346.          desired mode.
  6347.  
  6348.  
  6349.  
  6350.          Editing using a character mask
  6351.          ------------------------------
  6352.  
  6353.          The C Window Library also provides input functions that use
  6354.          character masks.  For example to enter a date, you might want
  6355.          the user to enter a date in MM-DD-YY format.  Instead of the
  6356.          user having to enter the hyphens, it would be advantageous if
  6357.          the input field already had hyphens, and the cursor will
  6358.          advance or back up to the next input position, jumping over
  6359.          any hyphens encountered.  You can accomplish this by using a
  6360.          character mask.
  6361.  
  6362.          The mask is a character string which is made up of
  6363.          displayable characters, and a special character used to
  6364.          denote an input position.  For example, a date mask would
  6365.          look like this:
  6366.  
  6367.  
  6368.  
  6369.  
  6370.          Page 93          The C Window Library               Page 93
  6371.  
  6372.                                 __-__-__
  6373.  
  6374.          The hyphens are displayed in the window, but the underscores
  6375.          are not displayed.  The underscores are used as a place
  6376.          holder, i.e. a place where input is expected.  By default,
  6377.          the input position character is an underscore, but you can
  6378.          change this.  Another example would be a social security
  6379.          mask:
  6380.  
  6381.                                ___-__-____
  6382.  
  6383.           a telephone mask:
  6384.                                   (___) ___-____ ext: ____
  6385.  
  6386.           another date mask:
  6387.                                   __/__/__
  6388.  
  6389.  
  6390.          If a character is deleted or inserted, the input manager is
  6391.          smart enough to move characters so that they do not clobber
  6392.          the characters that are not part of the input field.
  6393.  
  6394.  
  6395.  
  6396.          Editing Functions
  6397.          -----------------
  6398.  
  6399.          The following are functions that can be used to edit input
  6400.          with The C Window Library.
  6401.  
  6402.  
  6403.  
  6404.          WindowGetString()
  6405.          -----------------
  6406.  
  6407.          The WindowGetString() function gets a string from a window
  6408.          starting at a certain row and column of the window.  Here is
  6409.          the prototype:
  6410.  
  6411.          int WindowGetString(WPOINTER w, int row, int col,
  6412.                              char *buffer, int fillchar, int minchars,
  6413.                              int maxwidth, int options, int startpos,
  6414.                              char *regexp)
  6415.  
  6416.          The first argument is the window pointer.  The second and
  6417.          third arguments are the row and column of where the input
  6418.          begins.  The fourth argument is a pointer to a character
  6419.          buffer where the input characters will be stored.  Whatever
  6420.          null terminated string is stored in the character buffer
  6421.          prior to calling WindowGetString() will be used as a default
  6422.          string.   For example:
  6423.  
  6424.                            strcpy(str,"ABC");
  6425.  
  6426.          WindowGetString(w,2,1,str,' ',3,3,0,0,"3[A-Z]");
  6427.  
  6428.  
  6429.  
  6430.          Page 94          The C Window Library               Page 94
  6431.  
  6432.          The default value of "ABC" will be displayed in the window
  6433.          when WindowGetString() is called.  Therefore, make sure that
  6434.          your string buffer has a 0 in the 0th position if you want to
  6435.          make sure your input is empty when WindowGetString() is
  6436.          called.  When inputting information, hitting the Escape key
  6437.          (or whatever the current key definition is for
  6438.          CWLedit_key[7]) will abort input and will return the original
  6439.          default string.
  6440.  
  6441.          The fifth argument is the fill character.  This character is
  6442.          used to fill any unfilled input positions on the window.
  6443.          Instead of having spaces for unfilled positions, you can have
  6444.          any character.  Try ASCII 177 or the underline character.
  6445.          You may like the effect.
  6446.  
  6447.          The sixth argument is the minimum number of characters to
  6448.          accept.  If the number of characters entered is less than
  6449.          minchars, the input manager will not accept the input.
  6450.          However, you can change this by allowing the input manager to
  6451.          call a user defined routine when it detects that the minimum
  6452.          number of characters was not satisfied.  More information on
  6453.          this later in this section.
  6454.  
  6455.          The seventh argument is the maximum width of the displayable
  6456.          input field.  This argument allows for scrollable input
  6457.          fields.  If the maximum width of the displayable field is
  6458.          less than the total number of characters in the input field,
  6459.          the field will scroll right and left depending on the input
  6460.          position.  If the input cursor exceeds the right edge of the
  6461.          displayable field, the input is scrolled right until the next
  6462.          input position is visible.  If the cursor is moved beyond the
  6463.          left edge of the displayable field, the input is scrolled
  6464.          left until the previous input position comes into view.
  6465.          Scrolling input fields allow for large input fields in small
  6466.          windows.
  6467.  
  6468.          The eighth argument is an integer representing the various
  6469.          options available for the input field.  The various options
  6470.          available will be discussed later on.
  6471.  
  6472.          The ninth argument is the starting position in the input
  6473.          string of where the cursor will be placed.  Position numbers
  6474.          start from 0 to the maximum number of input positions less
  6475.          one.  For most applications, the starting position is usually
  6476.          0.  If the starting position is not within bounds of the
  6477.          input string, the starting position is assumed to be 0.
  6478.  
  6479.          The last argument is the regular expression to use for the
  6480.          input.  Make sure that the input buffer you provide is large
  6481.          enough to hold the maximum number of characters plus one more
  6482.          character for the terminating null character.
  6483.  
  6484.  
  6485.  
  6486.  
  6487.  
  6488.  
  6489.  
  6490.          Page 95          The C Window Library               Page 95
  6491.  
  6492.          More Examples:
  6493.  
  6494.          WindowGetString(w,2,1,str,' ',1,1,NO_OPTIONS,0,"[YyNn]");
  6495.  
  6496.          This will accept one character but only if the character is
  6497.  
  6498.  
  6499.          'Y','y','N', or 'n'.  Another example is this:
  6500.  
  6501.          WindowGetString(w,2,1,str,' ',5,5,NO_OPTIONS,0,"5[0-9]");
  6502.  
  6503.          This will allow the user to enter five digit characters.
  6504.  
  6505.          To accept all characters, use this:
  6506.          WindowGetString(w,2,1,str,' ',3,3,NO_OPTIONS,0,".");
  6507.  
  6508.          Example Program:
  6509.  
  6510.          #include "cwlwin.h"
  6511.          #include <string.h>
  6512.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6513.  
  6514.          WPOINTER w;
  6515.  
  6516.          char buffer[80];
  6517.          main()
  6518.          {
  6519.            int i,row,col;
  6520.            buffer[0] = 0;   /* Make sure first character is null */
  6521.            WindowInitializeSystem();
  6522.            WindowInitDesktop(0);
  6523.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6524.                                 NORM,NORM,SINGLEBOX);
  6525.            WindowDisplay(w,1,NOEFFECT);
  6526.            buffer[0] = 0;   /* Make sure first character is NULL */
  6527.            WindowWriteString(w,"Enter Your first name :",0,0);
  6528.            WindowGetString(w,2,0,buffer,' ',0,40,NO_OPTIONS,0,"40.");
  6529.            WindowWriteString(w,"You entered the following:",3,0);
  6530.            WindowWriteString(w,buffer,4,1);
  6531.            GET_KEY();
  6532.            WindowWriteString(w,"Now Enter your last name:",6,1);
  6533.  
  6534.            /* Note that the last string is now used as a default */
  6535.            WindowGetString(w,7,0,buffer,' ',0,40,NO_OPTIONS,0,"40.");
  6536.            WindowWriteString(w,"You entered the following:",8,0);
  6537.            WindowWriteString(w,buffer,9,0);
  6538.          }
  6539.  
  6540.  
  6541.  
  6542.  
  6543.  
  6544.  
  6545.  
  6546.  
  6547.  
  6548.  
  6549.  
  6550.          Page 96          The C Window Library               Page 96
  6551.  
  6552.                Return Values for WindowGetString():
  6553.  
  6554.              Return Value        Definition
  6555.          ┌────────────────┬─────────────────────────────┐
  6556.          │NO_ERROR        │No error occured.            │
  6557.          ├────────────────┼─────────────────────────────┤
  6558.          │BAD_WINDOW      │Window does not exist.       │
  6559.          ├────────────────┼─────────────────────────────┤
  6560.          │NO_HEAP_MEM     │Not enough memory to allocate│
  6561.          │                │for internal buffers.        │
  6562.          ├────────────────┼─────────────────────────────┤
  6563.          │NO_INPUT_CHARS  │Regular Expression indicates │
  6564.          │                │no characters to accept.     │
  6565.          └────────────────┴─────────────────────────────┘
  6566.  
  6567.  
  6568.  
  6569.          WindowGetStringAttr()
  6570.          ---------------------
  6571.  
  6572.          The WindowGetStringAttr() function is the same as the
  6573.          WindowGetString() function described above except that a
  6574.          video attribute is used for the input entered.  Here is the
  6575.          prototype:
  6576.  
  6577.          int WindowGetStringAttr(WPOINTER w, int row, int col,
  6578.                                  char *buffer, int fillchar,
  6579.                                  int minchars, int maxwidth,
  6580.                                  int options, int startpos, int attr,
  6581.                                  char *regexp)
  6582.  
  6583.          Note that attr is the tenth argument.  This is the video
  6584.          attribute to use when receiving input.
  6585.  
  6586.          Example Program:
  6587.  
  6588.          #include "cwlwin.h"
  6589.          #define NORM    CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6590.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  6591.  
  6592.          WPOINTER w;
  6593.          char buffer[80];
  6594.          main()
  6595.          {
  6596.            int i,row,col;
  6597.            buffer[0] = 0;   /* Make sure first character is NULL */
  6598.            WindowInitializeSystem();
  6599.            WindowInitDesktop(0);
  6600.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6601.                                 NORM,NORM,SINGLEBOX);
  6602.            WindowDisplay(w,1,NOEFFECT);
  6603.            buffer[0] = 0;   /* Make sure first character is null */
  6604.            WindowWriteString(w,"Enter Your first name :",1,0);
  6605.            WindowGetStringAttr(w,2,0,buffer,' ',0,40,NO_OPTIONS,0,
  6606.                                REVERSE,"40.");
  6607.            WindowWriteString(w,"You entered the following:",3,0);
  6608.            WindowWriteString(w,buffer,4,0);
  6609.  
  6610.          Page 97          The C Window Library               Page 97
  6611.  
  6612.            GET_KEY();
  6613.            WindowWriteString(w,"Now Enter your last name:",6,0);
  6614.  
  6615.            /* Note that the last string is now used as a default */
  6616.            WindowGetStringAttr(w,7,0,buffer,' ',0,40,NO_OPTIONS,0,
  6617.                                REVERSE,"40.");
  6618.            WindowWriteString(w,"You entered the following:",8,0);
  6619.            WindowWriteString(w,buffer,9,0);
  6620.          }
  6621.  
  6622.  
  6623.          The return values for WindowGetStringAttr() are the same as
  6624.          WindowGetString().
  6625.  
  6626.  
  6627.  
  6628.          WindowGetMaskString()
  6629.          ---------------------
  6630.  
  6631.          The WindowGetMaskString() function is the same as the
  6632.          WindowGetString() except that a character mask is used when
  6633.          editing the input.  Here is the prototype:
  6634.  
  6635.          int WindowGetMaskString(WPOINTER w, int row, int col,
  6636.                                  char *buffer, char *mask,
  6637.                                  int fillchar, int minchars,
  6638.                                  int maxwidth, int options,
  6639.                                  int startpos, char *regexp)
  6640.  
  6641.          The mask argument is an extra argument.  This is the
  6642.          character mask to use when editing the input.  The string
  6643.          returned in the buffer does not contain any characters that
  6644.          are used for the mask.  For instance, if the mask is
  6645.          "__/__/__", and the string entered is "121589",
  6646.          WindowGetMaskString() will place "121589" into the buffer.
  6647.          If you want to create a string with the components separated
  6648.          according to a mask pattern, use the
  6649.          TranslateStringToMaskString() function described later in the
  6650.          manual.  Default strings must be set up 'unmasked'.  For
  6651.          instance, if you wanted the default date to be "12/15/89",
  6652.          and the character mask is "__/__/__", your string buffer
  6653.          should contain "121589" before calling WindowGetMaskString().
  6654.          This same rule applies to any input functions that use a
  6655.          character mask.
  6656.  
  6657.          Example:
  6658.  
  6659.          #include "cwlwin.h"
  6660.          #include <string.h>
  6661.          #define NORM    CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6662.          #define TELMASK "(___)___-____ ext:____"
  6663.          #define SSMASK  "___-__-____"
  6664.  
  6665.          WPOINTER w;
  6666.          char buffer[80];
  6667.          main()
  6668.          {
  6669.  
  6670.          Page 98          The C Window Library               Page 98
  6671.  
  6672.            int i,row,col;
  6673.            buffer[0] = 0;   /* Make sure first character is null */
  6674.            WindowInitializeSystem();
  6675.            WindowInitDesktop(0);
  6676.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6677.                                 NORM,NORM,SINGLEBOX);
  6678.            WindowDisplay(w,1,NOEFFECT);
  6679.            buffer[0] = 0;   /* Make sure first character is null */
  6680.            WindowWriteString(w,"Enter Your Telephone No.",0,0);
  6681.            WindowGetMaskString(w,2,1,buffer,TELMASK,' ',0,40,
  6682.                                NO_OPTIONS,0,"40.");
  6683.            WindowWriteString(w,"You entered the following phone no:",
  6684.                              3,0);
  6685.            WindowWriteString(w,buffer,4,0);
  6686.            GET_KEY();
  6687.            memset(buffer,0,sizeof(buffer));
  6688.            WindowWriteString(w,"Now Enter your Soc. Sec. Number:",
  6689.                              6,0);
  6690.            WindowGetMaskString(w,7,0,buffer,SSMASK,' ',0,40,
  6691.                                NO_OPTIONS,0,"40.");
  6692.            WindowWriteString(w,"You entered the following:",8,0);
  6693.            WindowWriteString(w,buffer,9,0);
  6694.          }
  6695.  
  6696.                Return Values for WindowGetMaskString():
  6697.  
  6698.              Return Value        Definition
  6699.          ┌────────────────┬─────────────────────────────┐
  6700.          │NO_ERROR        │No error occured.            │
  6701.          ├────────────────┼─────────────────────────────┤
  6702.          │BAD_WINDOW      │Window does not exist.       │
  6703.          ├────────────────┼─────────────────────────────┤
  6704.          │NO_HEAP_MEM     │Not enough memory to allocate│
  6705.          │                │for internal buffers.        │
  6706.          ├────────────────┼─────────────────────────────┤
  6707.          │NO_INPUT_CHARS  │Regular Expression indicates │
  6708.          │                │no characters to accept.     │
  6709.          └────────────────┴─────────────────────────────┘
  6710.  
  6711.          WindowGetMaskStringAttr()
  6712.          -------------------------
  6713.  
  6714.          The WindowGetMaskStringAttr() functions works the same way as
  6715.          WindowGetMaskString() except that WindowGetMaskStringAttr()
  6716.          allows you to specify a video attribute to use for the
  6717.          characters that are entered.  Here is the prototype:
  6718.  
  6719.  
  6720.  
  6721.          int WindowGetMaskStringAttr(WPOINTER w, int row, int col,
  6722.                                      char *buffer, char *mask,
  6723.                                      int fillchar, int minchars,
  6724.                                      int maxwidth, int options,
  6725.                                      startpos, int attr, char *regexp)
  6726.  
  6727.  
  6728.  
  6729.  
  6730.          Page 99          The C Window Library               Page 99
  6731.  
  6732.          Example:
  6733.  
  6734.          #include "cwlwin.h"
  6735.          #include <string.h>
  6736.          #define NORM    CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6737.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  6738.          #define TELMASK "(___)___-____ ext:____"
  6739.          #define SSMASK  "___-__-____"
  6740.          WPOINTER w;
  6741.          char buffer[80];
  6742.          main()
  6743.          {
  6744.            int i,row,col;
  6745.            buffer[0] = 0;   /* Make sure first character is null */
  6746.            WindowInitializeSystem();
  6747.            WindowInitDesktop(0);
  6748.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6749.                                 NORM,NORM,SINGLEBOX);
  6750.            WindowDisplay(w,1,NOEFFECT);
  6751.            buffer[0] = 0;   /* Make sure first character is null */
  6752.            WindowWriteString(w,"Enter Your Telephone No.",0,0);
  6753.            WindowGetMaskStringAttr(w,2,0,buffer,TELMASK,' ',0,40,
  6754.                                    NO_OPTIONS,0,REVERSE,"40.");
  6755.            WindowWriteString(w,"You entered the following phone no:",
  6756.                              3,0);
  6757.            WindowWriteString(w,buffer,4,0);
  6758.            GET_KEY();
  6759.            memset(buffer,0,sizeof(buffer));
  6760.            WindowWriteString(w,"Now Enter your Soc. Sec. Number:",6,0);
  6761.            WindowGetMaskStringAttr(w,7,1,buffer,SSMASK,' ',0,40,
  6762.                                    NO_OPTIONS,0,REVERSE,"40.");
  6763.            WindowWriteString(w,"You entered the following:",8,0);
  6764.            WindowWriteString(w,buffer,9,0);
  6765.          }
  6766.  
  6767.          The return values for WindowGetMaskStringAttr() are the same
  6768.          as WindowGetMaskString().
  6769.  
  6770.  
  6771.          Getting Passwords
  6772.          -----------------
  6773.  
  6774.          The C Window Library also allows you to receive hidden input.
  6775.          The functions to perform this are WindowGetPassword(),
  6776.          WindowGetMaskPassword(), WindowGetPasswordAttr() and
  6777.          WindowGetMaskPasswordAttr().  These functions are similar to
  6778.          the other WindowGetxx() functions. except that a character
  6779.          specified by you is displayed instead of the actual key
  6780.          pressed.
  6781.  
  6782.  
  6783.  
  6784.  
  6785.  
  6786.  
  6787.  
  6788.  
  6789.  
  6790.          Page 100          The C Window Library               Page 100
  6791.  
  6792.          WindowGetPassword()
  6793.          -------------------
  6794.  
  6795.          The WindowGetPassword() function gets hidden input from a
  6796.          window.  Here is the prototype:
  6797.  
  6798.          int WindowGetPassword(WPOINTER w, int row, int col,
  6799.                                char *buffer, int fillchar,
  6800.                                int passchar, int minchars,
  6801.                                int maxwidth, int options,
  6802.                                int startpos, char *regexp)
  6803.  
  6804.          The first argument is the window pointer.  The second and
  6805.          third arguments are the (row,col) to start receiving input.
  6806.          The fourth argument is the buffer to store the inputted
  6807.          characters.  The fifth argument is the character to use to
  6808.          fill empty input positions on the screen.  The sixth argument
  6809.          is the character to display to the screen when a key is
  6810.          pressed.  The last four arguments are the same as the
  6811.          WindowGetString()'s last four arguments.
  6812.  
  6813.          For example, if the user typed "ABCDEF", and the passchar is
  6814.          '*', the screen will display "******".  Notice the asterisk
  6815.          is displayed instead of the actual characters inputted.
  6816.  
  6817.          Example Program:
  6818.  
  6819.          #include "cwlwin.h"
  6820.          #include <string.h>
  6821.  
  6822.          #define NORM    CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6823.  
  6824.          WPOINTER w;
  6825.          char buffer[80];
  6826.          main()
  6827.          {
  6828.            int i,row,col;
  6829.            buffer[0] = 0;   /* Make sure first character is null */
  6830.            WindowInitializeSystem();
  6831.            WindowInitDesktop(0);
  6832.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6833.                                 NORM,NORM,SINGLEBOX);
  6834.            WindowDisplay(w,1,NOEFFECT);
  6835.            buffer[0] = 0;   /* Make sure first character is null */
  6836.            WindowWriteString(w,"Enter A Password",0,0);
  6837.            WindowGetPassword(w,1,0,buffer,' ','*',0,40,NO_OPTIONS,
  6838.                              0,"40.");
  6839.            WindowWriteString(w,"You entered the following:",3,0);
  6840.            WindowWriteString(w,buffer,4,0);
  6841.          }
  6842.  
  6843.          The return values for WindowGetPassword() are the same as
  6844.          WindowGetMaskString().
  6845.  
  6846.  
  6847.  
  6848.  
  6849.  
  6850.          Page 101          The C Window Library               Page 101
  6851.  
  6852.          WindowGetPasswordAttr()
  6853.          -----------------------
  6854.  
  6855.          The WindowGetPasswordAttr() function is the same as
  6856.          WindowGetPassword() except that a video attribute is
  6857.          specified for the input characters.  Here is the prototype:
  6858.  
  6859.          int WindowGetPasswordAttr(WPOINTER w, int row, int col,
  6860.                                    char *buffer, int fillchar,
  6861.                                    int passchar, int minchars,
  6862.                                    int maxwidth, int options,
  6863.                                    int startpos, int attr,
  6864.                                    char *regexp)
  6865.  
  6866.          Please note that the attribute argument is the next to last
  6867.          argument in the function.
  6868.  
  6869.          Example Program:
  6870.  
  6871.          #include "cwlwin.h"
  6872.          #include <string.h>
  6873.          #define NORM    CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6874.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  6875.  
  6876.          WPOINTER w;
  6877.          char buffer[80];
  6878.  
  6879.          main()
  6880.          {
  6881.            int i,row,col;
  6882.            buffer[0] = 0;   /* Make sure first character is null */
  6883.            WindowInitializeSystem();
  6884.            WindowInitDesktop(0);
  6885.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6886.                                 NORM,NORM,SINGLEBOX);
  6887.            WindowDisplay(w,1,NOEFFECT);
  6888.            buffer[0] = 0;   /* Make sure first character is null */
  6889.            WindowWriteString(w,"Enter A Password",0,0);
  6890.            WindowGetPasswordAttr(w,2,0,buffer,' ','*',0,40,
  6891.                                  NO_OPTIONS,1,REVERSE,"40.");
  6892.            WindowWriteString(w,"You entered the following:",3,0);
  6893.            WindowWriteString(w,buffer,4,0);
  6894.          }
  6895.  
  6896.          The return values for WindowGetPasswordAttr() are the same as
  6897.          WindowGetMaskString().
  6898.  
  6899.  
  6900.  
  6901.          WindowGetMaskPassword()
  6902.          -----------------------
  6903.  
  6904.          The WindowGetMaskPassword() function works just like
  6905.          WindowGetPassword() except that a character mask is supplied.
  6906.          Here is the prototype:
  6907.  
  6908.  
  6909.  
  6910.          Page 102          The C Window Library               Page 102
  6911.  
  6912.          int WindowGetMaskPassword(WPOINTER w, int row, int col,
  6913.                                    char *buffer, char *mask,
  6914.                                    int fillchar, int passchar,
  6915.                                    int minchars, int maxwidth,
  6916.                                    int options, int startpos,
  6917.                                    char *regexp)
  6918.  
  6919.          Example:
  6920.  
  6921.  
  6922.          #include "cwlwin.h"
  6923.          #include <string.h>
  6924.          #define NORM    CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6925.          #define CREDITCARDMASK "____-____-____-____"
  6926.  
  6927.          WPOINTER w;
  6928.          char buffer[80];
  6929.          main()
  6930.          {
  6931.            int i,row,col;
  6932.            buffer[0] = 0;   /* Make sure first character is null */
  6933.            WindowInitializeSystem();
  6934.            WindowInitDesktop(0);
  6935.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6936.                                 NORM,NORM,SINGLEBOX);
  6937.            WindowDisplay(w,1,NOEFFECT);
  6938.            buffer[0] = 0;   /* Make sure first character is null */
  6939.            WindowWriteString(w,"Enter A Credit Card #",0,0);
  6940.            WindowGetMaskPassword(w,2,0,buffer,CREDITCARDMASK,' ','*',
  6941.                                  0,40,NO_OPTIONS,0,"40.");
  6942.            WindowWriteString(w,"You entered the following:",3,0);
  6943.            WindowWriteString(w,buffer,4,0);
  6944.          }
  6945.  
  6946.  
  6947.          The return values for WindowGetMaskPassword() are the same as
  6948.          WindowGetMaskString().
  6949.  
  6950.  
  6951.          WindowGetMaskPasswordAttr()
  6952.          ---------------------------
  6953.  
  6954.          The WindowGetMaskPasswordAttr() function works just like
  6955.          WindowGetMaskPassword() except that a video attribute is
  6956.          supplied. Here is the prototype:
  6957.  
  6958.  
  6959.          int WindowGetMaskPasswordAttr(WPOINTER w, int row, int col,
  6960.                                        char *buffer, char *mask,
  6961.                                        int fillchar, int passchar,
  6962.                                        int minchars, int maxwidth,
  6963.                                        int options, int startpos,
  6964.                                        int attr, char *regexp)
  6965.  
  6966.  
  6967.  
  6968.  
  6969.  
  6970.          Page 103          The C Window Library               Page 103
  6971.  
  6972.          Example:
  6973.  
  6974.          #include "cwlwin.h"
  6975.          #include <string.h>
  6976.          #define NORM    CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  6977.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  6978.          #define CREDITCARDMASK "____-____-____-____"
  6979.  
  6980.          WPOINTER w;
  6981.          char buffer[80];
  6982.          main()
  6983.          {
  6984.            int i,row,col;
  6985.            buffer[0] = 0;   /* Make sure first character is null */
  6986.            WindowInitializeSystem();
  6987.            WindowInitDesktop(0);
  6988.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  6989.                                 NORM,NORM,SINGLEBOX);
  6990.            WindowDisplay(w,1,NOEFFECT);
  6991.            buffer[0] = 0;   /* Make sure first character is null */
  6992.            WindowWriteString(w,"Enter A Credit Card #",0,0);
  6993.            WindowGetMaskPasswordAttr(w,1,0,buffer,CREDITCARDMASK,' ',
  6994.                                      '*',0,40, NO_OPTIONS,0,REVERSE,
  6995.                                      "40.");
  6996.  
  6997.            WindowWriteString(w,"You entered the following:",3,0);
  6998.            WindowWriteString(w,buffer,4,0);
  6999.          }
  7000.  
  7001.  
  7002.          The return values for WindowGetMaskPasswordAttr() are the
  7003.          same as WindowGetMaskString().
  7004.  
  7005.  
  7006.  
  7007.          Undefined Keystroke Processing
  7008.          ------------------------------
  7009.  
  7010.          Another powerful feature of the input functions is that you
  7011.          can call a function for keys that are not in the current key
  7012.          definitions.  For instance, say you want the Enter key AND
  7013.          Control-R to mean accept the input.  Since there is only room
  7014.          for one definition for accept input, you can write a function
  7015.          that checks for the Control-R key, and return a number to the
  7016.          input manager as to what action to take.
  7017.  
  7018.          The CWLundef_fkey_func and CWLundef_akey_func function pointers
  7019.          ---------------------------------------------------------------
  7020.  
  7021.          There are two global variables, CWLundef_fkey_func and
  7022.          CWLundef_akey_func.  Both of these function pointers are
  7023.          defined in the file key.h.  These two variables are pointers
  7024.          to functions that return an integer.  By setting these
  7025.          functions to point to your own functions, you can process
  7026.          undefined keystrokes yourself and return to the input manager
  7027.          what action to take.
  7028.  
  7029.  
  7030.          Page 104          The C Window Library               Page 104
  7031.  
  7032.          The CWLundef_fkey_func is used to define keys that are not
  7033.          normal ASCII keys.  For instance, Control key and Alt key
  7034.          combinations, the F-keys, PgDn and PgUp, etc.  The
  7035.          CWLundef_akey_func is used to define normal ASCII keys (keys
  7036.          with ASCII values between 32 and 255, inclusive).
  7037.  
  7038.          Whenever an undefined key is encountered, the input manager
  7039.          will pass the string that has been currently entered, the
  7040.          current key pressed, the current position number of the
  7041.          character being processed, and a pointer to a new position to
  7042.          place the input cursor.  The prototype for this function is
  7043.          as follows:
  7044.  
  7045.           int (*CWLundef_fkey_func)(char *str,int key,
  7046.                                     int pos,int *newposptr)
  7047.  
  7048.          The prototype to the CWLundef_akey_func is similar to the one
  7049.          above.
  7050.  
  7051.          The str is a pointer to a null-terminated string of
  7052.          characters that has been currently entered.  For instance, if
  7053.  
  7054.  
  7055.  
  7056.          the string currently entered is
  7057.  
  7058.                      ABC123
  7059.  
  7060.          str will point to "ABC123".
  7061.  
  7062.  
  7063.          The second argument is the last key that was pressed.  You
  7064.          should use the values defined in the header file "cwlwin.h"
  7065.          if you want to check for non-ascii keys.  This will ensure
  7066.          that you are properly checking the keystroke desired.  For
  7067.          instance, if you want to check if the key pressed was the
  7068.          Page Up key, use the constant PGUP defined in cwlwin.h.
  7069.  
  7070.          The third argument is an integer representing the position
  7071.          number of the current character that the cursor is on.  The
  7072.          first character is at position number 0, the second character
  7073.          in the input field is 1, etc.  If there is an input mask (as
  7074.          in WindowGetMaskString() and WindowGetMaskStringAttr()) the
  7075.          position number does not include any characters that are used
  7076.          to create the non-input positions.  For instance:
  7077.  
  7078.                              "__/__/__ "
  7079.                               01 23 45
  7080.  
  7081.          The numbers under the mask are the position numbers for each
  7082.          character.
  7083.  
  7084.          The fourth argument is a pointer to an integer representing a
  7085.          new position to move the cursor.  Use of this pointer will be
  7086.          explained later.
  7087.  
  7088.  
  7089.  
  7090.          Page 105          The C Window Library               Page 105
  7091.  
  7092.          Specifying when to call an undefined key function in a
  7093.          Regular Expression
  7094.          -------------------------------
  7095.  
  7096.          An empty bracketed simple regular expression tells the input
  7097.          manager to call the undefined keystroke function.  An example
  7098.          of this type of regular expression is as follows:
  7099.  
  7100.                  Regular
  7101.                Expression          Definition
  7102.            ┌────────────────┬─────────────────────────────┐
  7103.            │[A-Z][]         │The first input position must│
  7104.            │                │be between 'A' and 'Z', and  │
  7105.            │                │the second position will     │
  7106.            │                │automatically call the user  │
  7107.            │                │defined undefined keystroke  │
  7108.            │                │function.                    │
  7109.            ├────────────────┼─────────────────────────────┤
  7110.            │20[]            │All twenty input positions   │
  7111.            │                │will call the undefined      │
  7112.            │                │keystroke function.          │
  7113.            ├────────────────┼─────────────────────────────┤
  7114.            │3[0-9]2[]2[A-Z] │The first three input        │
  7115.            │                │positions must be between '0'│
  7116.            │                │and '9', the next two input  │
  7117.            │                │positions automatically call │
  7118.            │                │the undefined keystroke      │
  7119.            │                │function, and the last two   │
  7120.            │                │positions must be between    │
  7121.            │                │'A' and 'Z'.                 │
  7122.            └────────────────┴─────────────────────────────┘
  7123.  
  7124.  
  7125.          If you use this form of a regular expression, you MUST have
  7126.          defined an undefined keystroke function.  If you did not
  7127.          define one, you will more than likely get into an infinite
  7128.          loop.  Using this form of regular expression combined with
  7129.          the return values (defined below) that can be returned to the
  7130.          input manager, you will virtually have total control of the
  7131.          way the input is handled.
  7132.  
  7133.  
  7134.          Return Values To The Input Manager
  7135.          ----------------------------------
  7136.  
  7137.          When writing your function you must return an integer to the
  7138.          input manager.  This integer will inform the input manager as
  7139.          to what action to take.  Here are a list of the return values
  7140.          and what they inform the input manager:
  7141.  
  7142.  
  7143.  
  7144.  
  7145.  
  7146.  
  7147.  
  7148.  
  7149.  
  7150.          Page 106          The C Window Library               Page 106
  7151.  
  7152.            Return                         Action to
  7153.            Value                            Take
  7154.           ┌──────────────────┬─────────────────────────────────────┐
  7155.           │DONT_PROCESS      │ Do not Process keystroke and        │
  7156.           │                  │ continue getting input.             │
  7157.           ├──────────────────┼─────────────────────────────────────┤
  7158.           │MOVE_CURSOR_LEFT  │ Move cursor left.                   │
  7159.           ├──────────────────┼─────────────────────────────────────┤
  7160.           │MOVE_CURSOR_RIGHT │ Move cursor right.                  │
  7161.           ├──────────────────┼─────────────────────────────────────┤
  7162.           │DELETE_AT_CURSOR  │ Delete character at cursor.         │
  7163.           ├──────────────────┼─────────────────────────────────────┤
  7164.           │TOGGLE_INSERT     │ Toggle Insert/Overwrite mode.       │
  7165.           ├──────────────────┼─────────────────────────────────────┤
  7166.           │DESTRUCT_BACKSPACE│ Destructive Backspace.              │
  7167.           ├──────────────────┼─────────────────────────────────────┤
  7168.           │ACCEPT_INPUT      │ Accept Input and return string.     │
  7169.           ├──────────────────┼─────────────────────────────────────┤
  7170.           │ACCEPT_DEFAULT    │ Accept default string and return.   │
  7171.           ├──────────────────┼─────────────────────────────────────┤
  7172.           │ERASE_INPUT       │ Erase Input and go to first         │
  7173.           │                  │ character in input field.           │
  7174.           ├──────────────────┼─────────────────────────────────────┤
  7175.           │GOTO_FIRST        │ Go to first input character in      │
  7176.           │                  │ field.                              │
  7177.           ├──────────────────┼─────────────────────────────────────┤
  7178.           │GOTO_LAST         │ Move cursor to last input character │
  7179.           │                  │ in field.                           │
  7180.           ├──────────────────┼─────────────────────────────────────┤
  7181.           │MOVE_TO_CHARACTER │ Move cursor to input position       │
  7182.           │                  │ specified in the *pos argument.     │
  7183.           ├──────────────────┼─────────────────────────────────────┤
  7184.           │INSERT_CHARACTER  │ Accept character as valid and insert│
  7185.           │                  │ it at the current cursor position.  │
  7186.           │                  │                                     │
  7187.           └──────────────────┴─────────────────────────────────────┘
  7188.  
  7189.          The MOVE_TO_CHARACTER return value moves the input cursor to
  7190.          the position in the input string specified in the fourth
  7191.          argument of CWLundef_akey_func or CWLundef_fkey_func.  If you
  7192.          recall, the fourth argument was a pointer to an integer.
  7193.  
  7194.          The INSERT_CHARACTER return value only applies to the
  7195.          function pointed to by CWLundef_akey_func.
  7196.  
  7197.          These user-defined functions can do anything, not just
  7198.          process keystrokes.  For instance, if you want F1 to be a
  7199.          help key, where the help function is in a function called
  7200.          do_help() you must make sure that:
  7201.  
  7202.          a) the F1 key is undefined (not defined in the
  7203.          CWLedit_key array) b) the CWLundef_fkey_func function
  7204.          pointer points to your function c) return an integer to the
  7205.          input manager from your function.
  7206.  
  7207.  
  7208.  
  7209.  
  7210.          Page 107          The C Window Library               Page 107
  7211.  
  7212.          Here is a typical way that this would be set up:
  7213.  
  7214.          #include "cwlwin.h"
  7215.  
  7216.          /*  ... Other #includes and #defines */
  7217.  
  7218.          int do_help();           /* define help function */
  7219.  
  7220.          main()
  7221.          {
  7222.            WindowInitializeSystem();
  7223.  
  7224.            /* ...Some code */
  7225.            CWLundef_fkey_func = do_help;
  7226.            WindowGetString(/*  ... Parameters */);
  7227.  
  7228.            /* ... Other code */
  7229.          }
  7230.  
  7231.  
  7232.  
  7233.          int do_help(char *str, int ch, int pos, int *newpos)
  7234.          {
  7235.            if (ch == F1)                     /* check for F1 */
  7236.            {
  7237.               /* help function goes here */
  7238.              return DONT_PROCESS;  /* make sure input manager does not
  7239.                                       process this or any other
  7240.                                       undefined keystroke */
  7241.  
  7242.            }
  7243.            else
  7244.            {
  7245.              *newpos = 3;       /* move input cursor to the fourth
  7246.                                    input position */
  7247.  
  7248.              return MOVE_TO_CHARACTER   /* let input manager know we
  7249.                                            want to move the input
  7250.                                            cursor */
  7251.            }
  7252.          }
  7253.  
  7254.  
  7255.          With this flexibility in the input functions, you can totally
  7256.          control how input is handled.
  7257.  
  7258.  
  7259.  
  7260.  
  7261.  
  7262.  
  7263.  
  7264.  
  7265.  
  7266.  
  7267.  
  7268.  
  7269.  
  7270.          Page 108          The C Window Library               Page 108
  7271.  
  7272.          Input Options
  7273.          -------------
  7274.  
  7275.          In the previous examples, the available options were
  7276.          discussed briefly.  These options provide further control of
  7277.          the input functions.  Here is a list of the options that are
  7278.          available:
  7279.  
  7280.                 Option               Definition
  7281.             ┌────────────┬────────────────────────────────┐
  7282.             │UPPERCASE   │Translates and displays lower   │
  7283.             │            │case to upper case.             │
  7284.             ├────────────┼────────────────────────────────┤
  7285.             │LOWERCASE   │Translates and displays upper   │
  7286.             │            │case to lower case.             │
  7287.             ├────────────┼────────────────────────────────┤
  7288.             │CHECKSPACES │Spaces are counted when         │
  7289.             │            │determining whether the minimum │
  7290.             │            │number of characters are        │
  7291.             │            │entered.                        │
  7292.             ├────────────┼────────────────────────────────┤
  7293.             │ENHANCEDKEY │Use the enhanced keyboard keys  │
  7294.             │            │and distinguish between keypad  │
  7295.             │            │keys and separate cursor pad    │
  7296.             │            │keys.  Also detect F11 and F12  │
  7297.             │            │keys.                           │
  7298.             ├────────────┼────────────────────────────────┤
  7299.             │CHECKREGEXP │Check to see if all characters  │
  7300.             │            │entered agree with the regular  │
  7301.             │            │expression provided.            │
  7302.             ├────────────┼────────────────────────────────┤
  7303.             │AUTORETURN  │Automatically accept the input  │
  7304.             │            │when a character in the last    │
  7305.             │            │input position is entered.      │
  7306.             ├────────────┼────────────────────────────────┤
  7307.             │HOMECURSOR  │Move scrolled input back to the │
  7308.             │            │first character in the input    │
  7309.             │            │string when input is accepted.  │
  7310.             ├────────────┼────────────────────────────────┤
  7311.             │CLEARFIELD  │Clears the input field if the   │
  7312.             │            │first key pressed is recognized │
  7313.             │            │by the regular expression as a  │
  7314.             │            │valid input key.  If a cursor   │
  7315.             │            │movement key is pressed first,  │
  7316.             │            │the field is not cleared if any │
  7317.             │            │subsequent input keys are       │
  7318.             │            │pressed.                        │
  7319.             ├────────────┼────────────────────────────────┤
  7320.             │USEMOUSE    │Utilize the mouse to move the   │
  7321.             │            │cursor in the input field.      │
  7322.             ├────────────┼────────────────────────────────┤
  7323.             │NO_OPTIONS  │No options desired.             │
  7324.             └────────────┴────────────────────────────────┘
  7325.  
  7326.  
  7327.  
  7328.  
  7329.  
  7330.          Page 109          The C Window Library               Page 109
  7331.  
  7332.          UPPERCASE
  7333.          ---------
  7334.          The UPPERCASE option converts and displays all lower case
  7335.          letters to upper case while the user is inputting characters.
  7336.  
  7337.  
  7338.          LOWERCASE
  7339.          ---------
  7340.          The LOWERCASE option converts and displays all upper case
  7341.          letters to lower case while the user is inputting characters.
  7342.  
  7343.  
  7344.          CHECKSPACES
  7345.          -----------
  7346.          The CHECKSPACES option will cause the input manager to count
  7347.          any embedded spaces when determining whether the minimum
  7348.          number of characters are reached.  Trailing spaces are
  7349.          counted only if the user explicitly put them there.
  7350.  
  7351.  
  7352.  
  7353.          ENHANCEDKEY
  7354.          -----------
  7355.          The ENHANCEDKEY option will distinguish between the cursor
  7356.          keys on the keypad from the dedicated cursor keys on the
  7357.          enhanced keyboards as well as the Ins, Home, Del, PgUp and
  7358.          PgDn keys.  Also the F11 and F12 keys will be detected.
  7359.  
  7360.  
  7361.  
  7362.          CHECKREGEXP and the CWLreg_exp_error_func function pointer
  7363.          -------------------------------------------------------
  7364.  
  7365.          The CHECKREGEXP option will check to make sure that every
  7366.          character inputted is a valid character according to the
  7367.          regular expression.  When inserting or deleting characters
  7368.          during input, characters may be moved left or right depending
  7369.          on whether the input is in insert or overwrite mode.  When
  7370.          the characters are moved, the resulting pattern of characters
  7371.          may not match the regular expression desired.  For instance,
  7372.          if the regular expression is "3[A-Z]2[0-9]", meaning 3
  7373.          characters between A and Z followed by 2 characters between 0
  7374.          and 9, and the current input entered is as follows :
  7375.  
  7376.                         ABC34
  7377.  
  7378.          If the cursor is currently under the 'C', the delete key is
  7379.          pressed, and the input is currently in insert mode, the '34'
  7380.          will be moved one character to the left.  The resulting input
  7381.          would then look like this:
  7382.  
  7383.                         AB34
  7384.  
  7385.          As you can see, the input does not match the regular
  7386.          expression "3[A-Z]2[0-9]" because the '3' is in a position
  7387.          that should be occupied by a letter.  When the CHECKREGEXP
  7388.  
  7389.  
  7390.          Page 110          The C Window Library               Page 110
  7391.  
  7392.          option is chosen, each position is checked when the user
  7393.          wants to accept the string, not while the user is entering
  7394.          characters.  If the input is not OK, the input manager will
  7395.          not accept the string. You can override this by setting the
  7396.          CWLreg_exp_error_func function pointer.
  7397.  
  7398.          The global function pointer CWLreg_exp_error_func is prototyped
  7399.          as follows:
  7400.  
  7401.             int (*CWLreg_exp_error_func)(char *buf, int nomatch);
  7402.  
  7403.          where buf is the current string entered, and nomatch is the
  7404.          position of the first non-matching character that did not
  7405.          match the regular expression.  The first character of the
  7406.          string is at position 0.
  7407.  
  7408.          Your function must return an integer back as to what to do.
  7409.          There are two valid return values, namely ACCEPT_INPUT and
  7410.          DONT_PROCESS.  A return value of ACCEPT_INPUT will accept the
  7411.          input, even though all of the characters do not match the
  7412.          regular expression.  DONT_PROCESS tells the input manager to
  7413.          keep getting input.  Here is an example:
  7414.  
  7415.  
  7416.            int my_check_func();
  7417.            main()
  7418.            {
  7419.                ...
  7420.               CWLreg_exp_error_func = my_check_func;
  7421.  
  7422.               WindowGetString(other parameters, CHECKREGEXP,
  7423.                               "[A-Z][0-9]");
  7424.  
  7425.                ...
  7426.            }
  7427.  
  7428.            int my_check_func(char *buf, int mistake_pos)
  7429.            {
  7430.              /* Assume w is initialized and open for writing */
  7431.  
  7432.              WindowPrintf(w,
  7433.          "Illegal input for %s.  Illegal character at position %d",buf,
  7434.                           mistake_pos);
  7435.              GET_KEY();
  7436.              WindowHide(w,NOEFFECT);
  7437.              return DONT_PROCESS;
  7438.            }
  7439.  
  7440.  
  7441.          The above example shows a function called my_check_func()
  7442.          which will be called when the input manager detects that all
  7443.          of the characters in the buffer buf do not match the regular
  7444.          expression.  The function displays a message in a window and
  7445.          waits for a key to be pressed.  Then the function returns
  7446.          DONT_PROCESS back to the input manager.
  7447.  
  7448.  
  7449.  
  7450.          Page 111          The C Window Library               Page 111
  7451.  
  7452.          AUTORETURN
  7453.          ----------
  7454.  
  7455.          The AUTORETURN will automatically accept the input and return
  7456.          to the calling function if the cursor is on the last input
  7457.          position and the user types a valid character.  Of course, if
  7458.          CHECKREGEXP is on, the input is checked for validity.
  7459.  
  7460.  
  7461.          HOMECURSOR
  7462.          ----------
  7463.  
  7464.          The HOMECURSOR options will scroll an input field back to the
  7465.          first position when the input is accepted.
  7466.  
  7467.  
  7468.          CLEARFIELD
  7469.          ----------
  7470.  
  7471.          The CLEARFIELD option will automatically clear the input
  7472.          field of any characters if the first key struck is a key
  7473.          recognized as a valid input key, and the character is
  7474.          displayed in the input position.  If the first key struck is
  7475.          a cursor movement key or a delete character key (destructive
  7476.          backspace or delete character), any valid input key that is
  7477.          subsequently struck does not clear the field,  but is
  7478.          recorded in the input field.
  7479.  
  7480.  
  7481.          USEMOUSE
  7482.          --------
  7483.  
  7484.          This option can only be used if you have access to The C
  7485.          Window Library MouseLib functions, the system has a mouse
  7486.          installed, and the mouse has been activated.  By positioning
  7487.          the mouse cursor to any valid input position in the input
  7488.          field and pressing the mouse button defined in the global
  7489.          integer variable field_button_press, the cursor is
  7490.          automatically moved to that input position.  If the
  7491.          CLEARFIELD option is used in conjunction to USEMOUSE, any
  7492.          subsequent input will not clear the field if the mouse was
  7493.          used to move the cursor.
  7494.  
  7495.  
  7496.          NO_OPTIONS
  7497.          ----------
  7498.  
  7499.          No field options desired.  In other words, all of the options
  7500.          defined above are turned off.
  7501.  
  7502.  
  7503.  
  7504.  
  7505.  
  7506.  
  7507.  
  7508.  
  7509.  
  7510.          Page 112          The C Window Library               Page 112
  7511.  
  7512.          Examples of Input Options
  7513.          -------------------------
  7514.  
  7515.          Examples:
  7516.  
  7517.            a) WindowGetString(w,0,0,str,' ',1,1,UPPERCASE,0,"[YyNn]");
  7518.  
  7519.            b) WindowGetString(w,0,0,str,' ',1,1,LOWERCASE,0,"[YyNn]");
  7520.  
  7521.            c) WindowGetStringAttr(w,1,0,str,' ',
  7522.                               CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_),1,
  7523.                               1,UPPERCASE | AUTORETURN,0,"[YyNn]");
  7524.  
  7525.            d) WindowGetString(w,0,0,str,' ',10,10,
  7526.                               UPPERCASE | ENHANCEDKEY,1,"10.");
  7527.  
  7528.            e) WindowGetString(w,0,0,str,' ',20,10,CHECKREGEXP |
  7529.                               HOMECURSOR,1,"10[A-Z]10[0-9]");
  7530.  
  7531.          Example a) gets one character and will automatically set this
  7532.                     character to upper case.
  7533.  
  7534.                  b) same as a) except character is converted to lower
  7535.                     case.
  7536.  
  7537.                  c) converts one character to uppercase and
  7538.                     automatically accepts the input because the input
  7539.                     cursor was on the last input position.  Note the
  7540.                     use of the bitwise OR (|) to set multiple options.
  7541.  
  7542.                  d) Converts the input to uppercase and treats extra
  7543.                     keys on an enhanced keyboard as different than
  7544.                     their "normal" keys.
  7545.  
  7546.                  e) On accepting of the input field, the input is
  7547.                     checked to see if every position on the input
  7548.                     field is checked to see if it matches the regular
  7549.                     expression.  Once the input is accepted, the input
  7550.                     is scrolled back to the first input position.
  7551.  
  7552.  
  7553.          The CWLchars_entered_func function pointer
  7554.          ------------------------------------------
  7555.  
  7556.          If the number of characters entered is not enough to satisfy
  7557.          the minimum number of characters allowed, by default the
  7558.          input manager will not return until the required number of
  7559.          characters is entered.  However, a global function pointer
  7560.          can be assigned to a user-written function that will be
  7561.          called when the input manager detects that the minimum number
  7562.          of characters was not reached.  The function pointer
  7563.          CWLchars_entered_func is prototyped as follows:
  7564.  
  7565.  
  7566.          int (*CWLchars_entered_func)(char *buf, int minchars);
  7567.  
  7568.  
  7569.  
  7570.          Page 113          The C Window Library               Page 113
  7571.  
  7572.          where buf is the current string that is entered, and minchars
  7573.          is the minimum number of characters to expect.
  7574.  
  7575.          Your function must return an integer back as to what to do.
  7576.          There are two valid return values, namely ACCEPT_INPUT and
  7577.          DONT_PROCESS.  A return value of ACCEPT_INPUT will accept the
  7578.          input, even though the minimum number of characters was not
  7579.          reached.  DONT_PROCESS tells the input manager to keep
  7580.          getting input.  Here is an example:
  7581.  
  7582.  
  7583.            int my_min_func();
  7584.            main()
  7585.            {
  7586.                ...
  7587.               CWLchars_entered_func = my_min_func;
  7588.                ...
  7589.            }
  7590.  
  7591.            int my_min_func(char *buf, int m)
  7592.            {
  7593.  
  7594.              /* Assume w is initialized and open for writing */
  7595.  
  7596.              WindowWriteString(w,"Not enough characters!",0,0);
  7597.              GET_KEY();
  7598.              WindowHide(w,NOEFFECT);
  7599.              return DONT_PROCESS;
  7600.            }
  7601.  
  7602.          The above example shows a function called my_min_func() which
  7603.          will be called when the input manager detects that the number
  7604.          of characters in the buffer buf, does not meet the minimum
  7605.          requirements.  The function displays a message in a window
  7606.          and waits for a key to be pressed.  Then the function returns
  7607.          DONT_PROCESS back to the input manager.
  7608.  
  7609.  
  7610.  
  7611.  
  7612.          Other Input Related Functions
  7613.          -----------------------------
  7614.  
  7615.          There are other input related functions that you can use to
  7616.          translate strings into their character mask equivalents and
  7617.          vice-versa.
  7618.  
  7619.  
  7620.          TranslateStringToMaskString()
  7621.          -----------------------------
  7622.  
  7623.          This TranslateStringToMaskString() function takes a string
  7624.          and either places spaces, or the actual mask character
  7625.          between the characters in the string.  A pointer to the
  7626.          translated string is returned.  Here is the prototype:
  7627.  
  7628.  
  7629.  
  7630.          Page 114          The C Window Library               Page 114
  7631.  
  7632.          char *TranslateStringToMaskString(char *buffer, char *mask,
  7633.                                            char *buf2, int maskchar,
  7634.                                            int flag)
  7635.  
  7636.          The first argument is a pointer to the string to translate.
  7637.          The second argument is the mask string to use. The third
  7638.          argument is a pointer to the buffer that will store the
  7639.          translated string.  The fourth argument is the mask character
  7640.          that is to be used.  This character determines where the
  7641.          input positions are.  The flag argument tells whether to
  7642.          include spaces between each component, or to use the
  7643.          character in the mask.
  7644.  
  7645.          You must make sure that buf2 is big enough to hold the
  7646.          translated string.
  7647.  
  7648.          The string length of the mask determines how far to translate
  7649.          the string.  If the mask string is shorter than the string to
  7650.          translate, the string is truncated up to the last character
  7651.          in the mask.  If the string to translate runs out of
  7652.          characters before the mask has been totally scanned, the
  7653.          extra characters in buf2 will either be spaces, or the
  7654.          characters in the mask (not the mask character specified in
  7655.          argument 4) will be copied over.
  7656.  
  7657.          Example:
  7658.  
  7659.              #include "cwlwin.h"
  7660.  
  7661.              #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  7662.              #define DATEMASK "__/__/__"
  7663.              char buf1[] = "123456";
  7664.              char buf2[9];
  7665.              WPOINTER w;
  7666.  
  7667.              main()
  7668.              {
  7669.                WindowInitializeSystem();
  7670.                WindowInitDesktop(0);
  7671.                w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  7672.                                     NORM,NORM,SINGLEBOX);
  7673.                WindowDisplay(w,1,NOEFFECT);
  7674.                TranslateStringToMaskString(buf1,DATEMASK,buf2,'_',0);
  7675.                WindowPrintf(w,
  7676.            "The original string is %s\nThe translated string is %s\n",
  7677.                             buf1,buf2);
  7678.                TranslateStringToMaskString(buf1,DATEMASK,buf2,'_',1);
  7679.                WindowPrintf(w,
  7680.            "The original string is %s\nThe translated string is %s\n",
  7681.                             buf1,buf2);
  7682.          }
  7683.  
  7684.          The example above takes the string "123456" with the mask of
  7685.          "__/__/__".  The results of a translate with a flag of 0, and
  7686.          with a flag value of 1, is displayed in window w.
  7687.  
  7688.  
  7689.  
  7690.          Page 115          The C Window Library               Page 115
  7691.  
  7692.          The return value for TranslateStringToMaskString() is the
  7693.          pointer to the buffer that holds the translated string.  This
  7694.          string is automatically null terminated.
  7695.  
  7696.  
  7697.          TranslateMaskStringToString()
  7698.          -----------------------------
  7699.  
  7700.          This TranslateMaskStringToString() function does the opposite
  7701.          of TranslateStringToMaskString().  This function takes a
  7702.          string that has been translated with the
  7703.          TranslateStringToMaskString() or contains mask characters and
  7704.          returns the string without the extra characters.  Here is the
  7705.          prototype:
  7706.  
  7707.          char *TranslateMaskStringToString(char *buffer, char *mask,
  7708.                                            char *buf2, int maskchar)
  7709.  
  7710.          The first argument is a pointer to the translated string.
  7711.          The second argument is the mask string to use. The third
  7712.          argument is a pointer to the buffer that will store the
  7713.          resulting string.  The fourth argument is the mask character
  7714.          that is to be used.  This character determines where the
  7715.          input positions are.
  7716.  
  7717.  
  7718.          You must make sure that buf2 is big enough to hold the new
  7719.          string.
  7720.  
  7721.          The translation stops when either the end of the buffer is
  7722.          reached, or the end of the mask string is reached.
  7723.  
  7724.  
  7725.          Example:
  7726.  
  7727.          #include "cwlwin.h"
  7728.          #include <string.h>
  7729.  
  7730.          #define NORM CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  7731.          #define DATEMASK "__/__/__"
  7732.          char buf1[] = "12/34/56";
  7733.  
  7734.          char buf2[9];
  7735.          WPOINTER w;
  7736.  
  7737.          main()
  7738.          {
  7739.            memset(buf2,0,sizeof(buf2));
  7740.            WindowInitializeSystem();
  7741.            WindowInitDesktop(0);
  7742.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  7743.                                 NORM,NORM,SINGLEBOX);
  7744.            WindowDisplay(w,1,NOEFFECT);
  7745.            TranslateMaskStringToString(buf1,DATEMASK,buf2,'_');
  7746.            WindowPrintf(w,"The original string is %s\n"
  7747.                          "The untranslated string is %s\n", buf1,buf2);
  7748.          }
  7749.  
  7750.          Page 116          The C Window Library               Page 116
  7751.  
  7752.          The example above takes the string "12/34/56" with the mask
  7753.          of "__/__/__".  The results of the translation is displayed
  7754.          in window w.
  7755.  
  7756.          The return value for TranslateMaskStringToString() is the
  7757.          pointer to the buffer that holds the translated string.  This
  7758.          string is automatically null terminated.
  7759.  
  7760.  
  7761.  
  7762.  
  7763.  
  7764.  
  7765.  
  7766.  
  7767.  
  7768.  
  7769.  
  7770.  
  7771.  
  7772.  
  7773.  
  7774.  
  7775.  
  7776.  
  7777.  
  7778.  
  7779.  
  7780.  
  7781.  
  7782.  
  7783.  
  7784.  
  7785.  
  7786.  
  7787.  
  7788.  
  7789.  
  7790.  
  7791.  
  7792.  
  7793.  
  7794.  
  7795.  
  7796.  
  7797.  
  7798.  
  7799.  
  7800.  
  7801.  
  7802.  
  7803.  
  7804.  
  7805.  
  7806.  
  7807.  
  7808.  
  7809.  
  7810.          Page 117          The C Window Library               Page 117
  7811.  
  7812.                             CHILD WINDOWS
  7813.                             -------------
  7814.  
  7815.          Child Windows are windows that are embedded in other windows.
  7816.          The window which the child is embedded is called the parent
  7817.          window.  The child window is always visible within the parent
  7818.          window, and is positioned with coordinates relative to the
  7819.          parent.  Child windows can also have child windows.  A child
  7820.          window can only have one parent, but a parent window can have
  7821.          up to 255 children.
  7822.  
  7823.          What purpose would a child window serve?  Let's say that you
  7824.          want to create a window that will hold a directory listing.
  7825.          You would like the layout of the window to be separated into
  7826.          two parts:  a list of the names of the files, and a list of
  7827.          names of the directories and other available drives.  It would
  7828.          be advantageous to embed two windows into the main window, one
  7829.          window for the file names, and the other for the directory and
  7830.          drive names.  Here is an illustration of what the layout may
  7831.          look like:
  7832.  
  7833.  
  7834.                     ╔════════════File Window═════════════╗
  7835.                     ║                                    ║
  7836.                     ║                                    ║
  7837.                     ║  File Names         Directories    ║
  7838.                     ║  ┌────────────┐     ┌───────────┐  ║
  7839.                     ║  │File 1      │     │<Dir 1>    │  ║
  7840.                     ║  │File 2      │     │<Dir 2>    │  ║
  7841.                     ║  │File 3      │     │..         │  ║
  7842.                     ║  │File 4      │     │.          │  ║
  7843.                     ║  │File 5      │     │[a]        │  ║
  7844.                     ║  │            │     │[b]        │  ║
  7845.                     ║  │            │     │[c]        │  ║
  7846.                     ║  └────────────┘     └───────────┘  ║
  7847.                     ║                                    ║
  7848.                     ║                                    ║
  7849.                     ╚════════════════════════════════════╝
  7850.  
  7851.          There are three approaches to solving this problem.  The first
  7852.          approach is to not use CWL and try to code this yourself.
  7853.          Let's throw out this 'solution'!
  7854.  
  7855.          The second approach is to create three top-level windows, the
  7856.          File Window, File Names window, and Directories window.  The
  7857.          drawbacks in creating all three as top-level is that a) you
  7858.          have to position the File Names and Directories window inside
  7859.          of the File Window using desktop coordinates, and b) If you
  7860.          move or hide the File Window, the File Names and Directories
  7861.          window do not move or hide unless you explicitly call these
  7862.          functions yourself.
  7863.  
  7864.          The third and preferred method is to make File Names and
  7865.          Directories windows as child windows of the File Window.
  7866.          Whenever the File Window is hidden or moved, the File Names
  7867.          and Directories windows will automatically follow along and
  7868.  
  7869.  
  7870.          Page 118          The C Window Library               Page 118
  7871.  
  7872.          hide themselves or move.  Also, the positioning of a child
  7873.          window is relative to the parent window, not the screen.  This
  7874.          allows easier positioning of the child within the parent.
  7875.  
  7876.  
  7877.  
  7878.          Creating Child Windows with WindowSetParent()
  7879.          ---------------------------------------------
  7880.  
  7881.          There are two ways of creating a child window.  The first
  7882.          method has already been discussed, namely using the
  7883.          WindowInitialize() function.  You specify the new window's
  7884.          parent window as the first argument to WindowInitialize().
  7885.          When a child window is created this way, the rank of the
  7886.          child window is always 1.
  7887.  
  7888.          The second method is to take a window that is not a child
  7889.          window or is a child window of another window, and to make it
  7890.          a child of the window desired.  To do this, you would use the
  7891.          WindowSetParent() function.  Here is the prototype:
  7892.  
  7893.          int WindowSetParent(WPOINTER parent, WPOINTER child, int rank,
  7894.                              int row, int col)
  7895.  
  7896.          The parent argument is the WPOINTER of the parent window.
  7897.          The second argument is the WPOINTER of the window that you
  7898.          want to make a child of the parent.  The rank argument is the
  7899.          window rank of the child.  The row and col arguments denote
  7900.          the position of the child window within the parent window.
  7901.  
  7902.          If parent is DESKTOP_WINDOW, child is made into a top-level
  7903.          window.  As was suggested above, you can take a window that
  7904.          is already a child of another window and reassign it to
  7905.          another parent.
  7906.  
  7907.  
  7908.          Example:
  7909.  
  7910.          #include "cwlwin.h"
  7911.  
  7912.          WPOINTER w, childw, childw2;
  7913.  
  7914.          main()
  7915.          {
  7916.            WindowInitializeSystem();
  7917.            WindowInitDesktop(0);
  7918.  
  7919.            /* Create top-level window */
  7920.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  7921.                                 NORM,NORM,DOUBLEBOX);
  7922.  
  7923.            /* Create a child window with parent window as w */
  7924.            childw =
  7925.            WindowInitialize(w,BORDER,4,4,8,8,NORM,NORM,SINGLEBOX);
  7926.  
  7927.  
  7928.  
  7929.  
  7930.          Page 119          The C Window Library               Page 119
  7931.  
  7932.            /* Create another top-level window */
  7933.            childw2 = WindowInitialize(DESKTOP_WINDOW,BORDER,
  7934.                                       4,4,8,8,NORM,NORM,SINGLEBOX);
  7935.  
  7936.            /* Make childw2 a child of w by calling WindowSetParent() */
  7937.            WindowSetParent(w,childw2,1,4,20);
  7938.            WindowDisplay(w,1,NOEFFECT);
  7939.          }
  7940.  
  7941.                 Return Values for WindowSetParent():
  7942.  
  7943.              Return Value        Definition
  7944.          ┌────────────────┬────────────────────────┐
  7945.          │NO_ERROR        │ No error occured.      │
  7946.          ├────────────────┼────────────────────────┤
  7947.          │BAD_WINDOW      │ Parent window does     │
  7948.          │                │ not exist.             │
  7949.          ├────────────────┼────────────────────────┤
  7950.          │MAX_WINDOW      │ Maximum number of      │
  7951.          │                │ windows defined.       │
  7952.          ├────────────────┼────────────────────────┤
  7953.          │NO_HEAP_MEM     │ Not enough memory to   │
  7954.          │                │ allocate for window.   │
  7955.          └────────────────┴────────────────────────┘
  7956.  
  7957.  
  7958.          Translation of Child Coordinates and the CWLPOINT structure
  7959.          -----------------------------------------------------------
  7960.  
  7961.          As was stated above, the child windows are positioned
  7962.          relative to the parent window.  CWL provides functions that
  7963.          allow you to translate from child window coordinates to any
  7964.          other window's coordinate system.  For example, you may want
  7965.          to know what the desktop position of (1,1) of a child
  7966.          window is.  This is very useful for positioning windows given
  7967.          that you only know the desktop, parent, or child window
  7968.          position.
  7969.  
  7970.          There are three functions that provide these translation
  7971.          functions:  CWLClientToDesktop(), CWLDesktopToClient(), and
  7972.          CWLMapWindowPoints(). Before proceeding with definitions of
  7973.          these functions, the CWLPOINT structure must be explained.
  7974.  
  7975.          The CWLPOINT structure is a C structure that has the following
  7976.          definition:
  7977.  
  7978.          typedef struct tagCWLPOINT
  7979.          {
  7980.           int x;      /* x - coordinate */
  7981.           int y;      /* y - coordinate */
  7982.          } CWLPOINT;
  7983.  
  7984.          The CWLPOINT structure defines a point in a window.  This
  7985.          structure is used extensively in the translation functions.
  7986.  
  7987.          The prototypes to the the translation functions are as
  7988.          follows:
  7989.  
  7990.          Page 120          The C Window Library               Page 120
  7991.  
  7992.          int CWLClientToDesktop(WPOINTER w, CWLPOINT *point)
  7993.  
  7994.          int CWLDesktopToClient(WPOINTER w, CWLPOINT *point)
  7995.  
  7996.          int CWLMapWindowPoints(WPOINTER w1, WPOINTER w2,
  7997.                                 CWLPOINT *point, int numpoints)
  7998.  
  7999.          The CWLClientToDesktop() function translates window
  8000.          coordinates to desktop (screen) coordinates.  The first
  8001.          argument is the window from where the points are to be
  8002.          referenced, and the second argument is a pointer to a
  8003.          CWLPOINT structure variable.  This structure must be filled
  8004.          in with the points to translate.  When CWLClientToDesktop()
  8005.          returns, the CWLPOINT structure variable will be overwritten
  8006.          with the translated coordinates.
  8007.  
  8008.          The CWLDesktopToClient() function does the opposite of
  8009.          CWLClientToDesktop().  The CWLPOINT structure variable is
  8010.          translated from desktop coordinates to window coordinates on
  8011.          return.
  8012.  
  8013.          The CWLMapWindowPoints() function translates from one
  8014.          window's coordinate system to another window's coordinate
  8015.          system.  It is actually a combination of CWLDesktopToClient()
  8016.          and CWLClientToDesktop() functions.  The w1 arguement is the
  8017.          window where the coordinates are to be translated from.  The
  8018.          w2 argument is the coordinate system that the points will be
  8019.          translated to.  The point argument is an array of CWLPOINT
  8020.          structures, and the last argument is the number of CWLPOINT
  8021.          structures to translate.
  8022.  
  8023.          All of these functions do not skimp on the translation.  If a
  8024.          point lies outside of the window's client area, the functions
  8025.          give a true indication of where the point lies.  In some
  8026.          cases this may mean that the points translate to negative
  8027.          coordinates.  Also, for CWLMapWindowPoints(), the two windows
  8028.          can be totally unrelated (no parent-child relationship) and
  8029.          will still return valid, translated points.
  8030.  
  8031.          Example:
  8032.  
  8033.          #include "cwlwin.h"
  8034.  
  8035.          WPOINTER w, childw;
  8036.          CWLPOINT point;
  8037.          main()
  8038.          {
  8039.            WindowInitializeSystem();
  8040.            WindowInitDesktop(0);
  8041.  
  8042.            /* Create top-level window */
  8043.  
  8044.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,20,
  8045.                                 NORM,NORM,DOUBLEBOX);
  8046.  
  8047.  
  8048.  
  8049.  
  8050.          Page 121          The C Window Library               Page 121
  8051.  
  8052.            /* Create a child window with parent window as w */
  8053.            childw =
  8054.            WindowInitialize(w,BORDER,4,4,8,8,NORM,NORM,SINGLEBOX);
  8055.            WindowDisplay(w,1,NOEFFECT);
  8056.  
  8057.            /* Translate (0,0) of childw to desktop coordinates */
  8058.            point.x = 0;
  8059.            point.y = 0;
  8060.            CWLClientToDesktop(childw,&point);
  8061.  
  8062.            /* Write the results */
  8063.            WindowMoveCursor(w,16,0);
  8064.            WindowPrintf(w,
  8065.                        "(0,0) of childw is (%d,%d) of the desktop\n",
  8066.                        point.y, point.x);
  8067.  
  8068.            /* Translate (7,12) of desktop to w's coordinates */
  8069.            point.x = 12;
  8070.            point.y = 7;
  8071.            CWLDesktopToClient(w,&point);
  8072.  
  8073.            /* Write the results */
  8074.            WindowPrintf(w,
  8075.                        "(7,12) of desktop is (%d,%d) of w\n",
  8076.                        point.y, point.x);
  8077.  
  8078.            /* Translate (0,0) of w to childw */
  8079.            point.x = 0;
  8080.            poiny.y = 0;
  8081.            CWLMapWindowPoints(w,childw,&point,1);
  8082.  
  8083.            /* Write the results */
  8084.            WindowPrintf(w,
  8085.                        "(0,0) of w is (%d,%d) of childw\n",
  8086.                        point.y, point.x);
  8087.          }
  8088.  
  8089.  
  8090.             Return Values for all translation functions:
  8091.  
  8092.              Return Value        Definition
  8093.          ┌────────────────┬────────────────────────┐
  8094.          │NO_ERROR        │ No error occured.      │
  8095.          ├────────────────┼────────────────────────┤
  8096.          │BAD_WINDOW      │ Window does not exist. │
  8097.          └────────────────┴────────────────────────┘
  8098.  
  8099.          Another method of translating coordinates is to use macros
  8100.          instead of the functions defined above.  The macros are
  8101.          called DESKTOP_TO_CLIENT() and CLIENT_TO_DESKTOP().  The
  8102.          macros encapsulate creating a CWLPOINT variable, filling
  8103.          in the structure with numbers, calling the desired
  8104.          translation function, and getting the new values from
  8105.          the CWLPOINT variable and assigning them to other
  8106.          variables.  These macros have the following prototype:
  8107.  
  8108.  
  8109.  
  8110.          Page 122          The C Window Library               Page 122
  8111.  
  8112.          DESKTOP_TO_CLIENT(WPOINTER w, int orow, int ocol, int nrow,
  8113.                            int ncol)
  8114.  
  8115.          CLIENT_TO_DESKTOP(WPOINTER w, int orow, int ocol, int nrow,
  8116.                            int ncol)
  8117.  
  8118.          The orow and ocol arguments are analogous to the y and x
  8119.          members of a CWLPOINT structure variable before you would
  8120.          call CWLDesktopToClient() or CWLClientToDesktop().  The nrow
  8121.          and ncol arguments will be filled in with the y and x members
  8122.          of the CWLPOINT structure variable on return of the
  8123.          translation function.
  8124.  
  8125.          These macros are useful in that a CWLPOINT structure variable
  8126.          is created inside of the macro, so you don't have to create
  8127.          one yourself.  However you must remember that these are
  8128.          macros.  The orow and ocol arguments can be any valid C
  8129.          expression, but the nrow and ncol arguments must be variable
  8130.          names or l-values.  L-values are expressions that can be
  8131.          legally placed on the left side of an assignment statement
  8132.          (which is simply the equal sign).
  8133.  
  8134.  
  8135.          Enumerating Child Windows
  8136.          -------------------------
  8137.  
  8138.          In some cases you may want to call a function that will act
  8139.          on all child windows and windows that are children of the
  8140.          child window.  For example, you may want to move all of a
  8141.          parents descendant windows up by one row (A descendant window
  8142.          can be the child of a window, a child window's child, a child
  8143.          of a child of a child window, etc.).   Another example, is
  8144.          that you just may want to count the number of child windows.
  8145.          Whatever you desire, CWL supports a function that enumerates
  8146.          and calls a user-defined function for all descendant windows
  8147.          of a parent.  The WindowEnumChildren() function does this
  8148.          job.
  8149.  
  8150.          int WindowEnumChildren(WPOINTER root, CWLENUMPROC enumproc,
  8151.                                 long lParam)
  8152.  
  8153.          The first argument is the window where all descendants will
  8154.          be processed.  The second argument is a pointer to a
  8155.          user-defined function defined as a CWLENUMPROC that will be
  8156.          called for all children.  The last argument is a long
  8157.          parameter that can be used for any purpose that you desire.
  8158.  
  8159.          The user-defined function must have the following prototype:
  8160.  
  8161.                     int enumproc(WPOINTER w, int lParam)
  8162.  
  8163.          The first argument is the child window being processed.  The
  8164.          second argument is the lParam defined in the
  8165.          WindowEnumChildren().  If enumproc() returns 0, the
  8166.          enumeration stops.  If enumproc() returns 1, the enumeration
  8167.          continues to the next window.  This allows you to stop the
  8168.          enumeration whenever you want.
  8169.  
  8170.          Page 123          The C Window Library               Page 123
  8171.  
  8172.          The windows are processed in a depth-first search manner.  In
  8173.          other words, if the first child window has children of its
  8174.          own, the child window, and then its children will be
  8175.          processed before going onto the next sibling.  If child
  8176.          windows are created during the enumeration, these windows
  8177.          will not be processed.  Also, if child windows are deleted
  8178.          during processing, they are not enumerated.
  8179.  
  8180.          If the first argument to WindowEnumChildren() is
  8181.          DESKTOP_WINDOW, all windows, including top-level windows will
  8182.          be enumerated.
  8183.  
  8184.          Example:
  8185.  
  8186.          #include "cwlwin.h"
  8187.  
  8188.          WPOINTER w, childw;
  8189.  
  8190.          int MyEnumProc(WPOINTER, long);
  8191.  
  8192.          main()
  8193.          {
  8194.            WindowInitializeSystem();
  8195.            WindowInitDesktop(0);
  8196.  
  8197.            /* Create top-level window */
  8198.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,20,
  8199.                                 NORM,NORM,DOUBLEBOX);
  8200.  
  8201.            /* Create a child window with parent window as w */
  8202.            childw =
  8203.            WindowInitialize(w,BORDER,4,4,8,8,NORM,NORM,SINGLEBOX);
  8204.            WindowDisplay(w,1,NOEFFECT);
  8205.  
  8206.            /* Call enumeration function */
  8207.            WindowEnumChildren(w,MyEnumProc,0L);
  8208.          }
  8209.  
  8210.  
  8211.          /* Write a string to all descendant windows */
  8212.          int MyEnumProc(WPOINTER w, long lParam)
  8213.          {
  8214.            WindowWriteString(w,"Window enumerated",0,0);
  8215.            return 1;    /* Continue enumeration */
  8216.          }
  8217.  
  8218.                Return Values for WindowEnumChildren():
  8219.  
  8220.              Return Value        Definition
  8221.          ┌────────────────┬────────────────────────┐
  8222.          │NO_ERROR        │ No error occured.      │
  8223.          ├────────────────┼────────────────────────┤
  8224.          │BAD_WINDOW      │ Window does not exist. │
  8225.          └────────────────┴────────────────────────┘
  8226.  
  8227.  
  8228.  
  8229.  
  8230.          Page 124          The C Window Library               Page 124
  8231.  
  8232.          Testing Window Relationships
  8233.          ----------------------------
  8234.  
  8235.          CWL allows testing for window relationships.  These include
  8236.          parent to child, child to parent, testing if a window is a
  8237.          child window, and testing if two windows are related in any
  8238.          fashion.
  8239.  
  8240.          The functions that are to be used are WindowIsChild(),
  8241.          WindowIsDescendant(), WindowIsRelated(), WindowIsSibling(),
  8242.          WindowGetParent(), and WindowTestRelation().  Here is the
  8243.          prototype for these functions:
  8244.  
  8245.          int WindowIsChild(WPOINTER parent, WPOINTER child)
  8246.  
  8247.          int WindowIsDescendant(WPOINTER parent, WPOINTER desc)
  8248.  
  8249.          int WindowIsRelated(WPOINTER w1, WPOINTER w2)
  8250.  
  8251.          int WindowIsSibling(WPOINTER w1, WPOINTER w2)
  8252.  
  8253.          WPOINTER WindowGetParent(WPOINTER child)
  8254.  
  8255.          int WindowTestRelation(WPOINTER w1, WPOINTER w2)
  8256.  
  8257.  
  8258.          The WindowIsChild() function tests if the second argument
  8259.          (child)is a child of the first argument (parent).  TRUE is
  8260.          returned if the relationship exists, FALSE otherwise.  This
  8261.          function only will return TRUE if child is a direct child of
  8262.          the parent, not a descendant of the parent.  For example if
  8263.          child has child windows, those 'grandchildren' are not
  8264.          children of parent.  This function also returns FALSE if the
  8265.          window is a top-level window.
  8266.  
  8267.          The WindowIsDescendant() returns TRUE if desc is a descendant
  8268.          of parent.  This includes child windows of parent and any
  8269.          children that any child may have.  FALSE is returned if no
  8270.          relationship holds.
  8271.  
  8272.          WindowIsRelated() returns TRUE if w1 is related to w2 in any
  8273.          fashion, except if w1 and w2 are top-level windows or are
  8274.          descendants of two different top-level windows.  TRUE is
  8275.          returned if both windows are related, FALSE otherwise.
  8276.  
  8277.          WindowIsSibling() returns TRUE if w2 and w1 are sibling
  8278.          windows, i.e. they have the same parent.  FALSE is returned
  8279.          if this relationship does not exist.
  8280.  
  8281.          WindowGetParent() returns the WPOINTER of the parent window
  8282.          of child.  If parent is a top-level window, the window
  8283.          pointer w is returned.  If child does not exist, WIN_NULL_PTR
  8284.          is returned.
  8285.  
  8286.          WindowTestRelation() returns an integer denoting the type of
  8287.          relationship that two windows hold.  Here are a list of the
  8288.          return values and their definitions:
  8289.  
  8290.          Page 125          The C Window Library               Page 125
  8291.  
  8292.           Constant           Value       Definition
  8293.          ┌──────────────────┬───┬───────────────────────────────────┐
  8294.          │BAD_WINDOW        │   │  One or both windows do not exist.│
  8295.          ├──────────────────┼───┼───────────────────────────────────┤
  8296.          │NO_RELATION       │ 0 │  There is no relationship         │
  8297.          │                  │   │  between the two windows.         │
  8298.          ├──────────────────┼───┼───────────────────────────────────┤
  8299.          │PARENT_CHILD      │ 1 │  w1 is a parent of w2.            │
  8300.          ├──────────────────┼───┼───────────────────────────────────┤
  8301.          │CHILD_PARENT      │ 2 │  w2 is a parent of w1.            │
  8302.          ├──────────────────┼───┼───────────────────────────────────┤
  8303.          │PARENT_DESCENDANT │ 3 │  w2 is a descendant window of     │
  8304.          │                  │   │  w1.                              │
  8305.          ├──────────────────┼───┼───────────────────────────────────┤
  8306.          │DESCENDANT_PARENT │ 4 │  w1 is a descendant window of     │
  8307.          │                  │   │  w2.                              │
  8308.          ├──────────────────┼───┼───────────────────────────────────┤
  8309.          │SIBLING_WINDOWS   │ 5 │  w1 and w2 are siblings.          │
  8310.          └──────────────────┴───┴───────────────────────────────────┘
  8311.  
  8312.  
  8313.          Testing Window Ranks
  8314.          --------------------
  8315.  
  8316.          One of the things that you may want to test is to see if when
  8317.          two windows share the same space, which window will have
  8318.          priority.  In versions of CWL prior to this one (3.0), the
  8319.          test was as simple as comparing the ranks of both windows,
  8320.          and the window with the smaller rank number would get
  8321.          priority.  However, with the introduction of child windows,
  8322.          this test is no longer safe to do.  The reason is that
  8323.          windows have their own system of ranking windows that is
  8324.          independent of another window.  For example, a child window
  8325.          with a rank of 1 does not necessarily have to lie on top of
  8326.          another child window with a rank of 100 if both child windows
  8327.          have different parents.
  8328.  
  8329.          The function to use to compare window ranks is the
  8330.          WindowCompareRank() function.  This function compares
  8331.          two windows and returns an integer denoting which window
  8332.          really does have the priority if both windows shared the same
  8333.          screen space.  Here is the prototype:
  8334.  
  8335.            int WindowCompareRank(WPOINTER w1, WPOINTER w2)
  8336.  
  8337.          w1 and w2 are the windows that you want to compare.  If
  8338.          WindowCompareRank() returns -1, w1 will overlap w2.  If the
  8339.          return value is 1, w2 will overlap w1.
  8340.  
  8341.  
  8342.          This function returns BAD_WINDOW if either w1 or w2 do not
  8343.          exist.
  8344.  
  8345.  
  8346.  
  8347.  
  8348.  
  8349.  
  8350.          Page 126          The C Window Library               Page 126
  8351.  
  8352.                            VIRTUAL WINDOWS
  8353.                            ---------------
  8354.  
  8355.          A virtual window can be thought of as a rectangular area
  8356.          filled with text.  This rectangular region can be broken up
  8357.          into rows and columns, just as a normal window can be divided
  8358.          into rows and columns.  The differences between a virtual
  8359.          window and a regular window is that a virtual window's
  8360.          dimensions can be larger than the physical screen, and a
  8361.          virtual window is not displayed on the screen.  Then what
  8362.          good is it if you cannot display it?  You use regular windows
  8363.          to display portions of the virtual window.  If a regular
  8364.          window is used to view a virtual window, the regular window
  8365.          is called a viewport.  With this method, you can use a
  8366.          viewport to display a virtual window, and then 'pan' around,
  8367.          viewing different sections of the virtual window.  Text
  8368.          editors use this method to display files.  Scrolling popup
  8369.          menus also use virtual windows.
  8370.  
  8371.          With The C Window Library, you can create virtual windows of
  8372.          any size, up to available user memory.
  8373.  
  8374.  
  8375.  
  8376.  
  8377.          Using Windows as Viewports
  8378.          --------------------------
  8379.  
  8380.          If text is written to a virtual window, and there is a
  8381.          viewport that is displaying the portion of the virtual window
  8382.          that has changed, the viewport will show the change
  8383.          immediately.  You do not have to "repaint" or "refresh" the
  8384.          viewport to show an updated change.  That is handled
  8385.          internally in The C Window Library.  However, there is an
  8386.          option that will "freeze" a viewport, i.e. will not update
  8387.          automatically, if there is a change in the virtual window.
  8388.          When the viewport is unfrozen, the changes to the virtual
  8389.          window are than displayed.
  8390.  
  8391.  
  8392.  
  8393.  
  8394.          Attributed and Non-Attributed Virtual Windows
  8395.          ---------------------------------------------
  8396.  
  8397.          There are two types of virtual windows.  You can have either
  8398.          a virtual window with its own video attributes or a virtual
  8399.          window which gets its video attributes from the viewport that
  8400.          is displaying the virtual window.  Virtual windows without
  8401.          attributes use half as much memory as a virtual window with
  8402.          attributes, but attributed virtual window's are more
  8403.          flexible.  For instance, lets say you have highlighted some
  8404.          text in the virtual window.  If the virtual window is not
  8405.          attributed, you must write the highlight attribute to the
  8406.          viewport window using one of the window functions
  8407.  
  8408.  
  8409.  
  8410.          Page 127          The C Window Library               Page 127
  8411.  
  8412.          (WindowWriteStringAttr() for example), since the virtual
  8413.          window does not have the capacity to store the video
  8414.          attribute.  If you were to scroll the highlighted portion out
  8415.          of the viewport, you lose the highlight attribute, and must
  8416.          call the window function again to highlight the text, if the
  8417.          text is displayed again in the viewport.  With an attributed
  8418.          virtual window, you write the attributes to the virtual
  8419.          window.  Since the attributes are stored in the virtual
  8420.          window structure itself, the attributes are retained until
  8421.          you change them.
  8422.  
  8423.          From this point on, virtual windows without attributes are
  8424.          called NOATTRIBUTE virtual windows.  Virtual windows with
  8425.          attributes will be called ATTRIBUTE virtual windows.
  8426.  
  8427.  
  8428.          Virtual Window's Logical Cursor
  8429.          -------------------------------
  8430.  
  8431.          Each virtual window has its own logical cursor.  This cursor
  8432.          is updated automatically when calling VirtualPrintf(), and
  8433.          VirtualWriteCharacter() functions, or can be updated manually
  8434.          by calling the VirtualMoveCursor() function.  This cursor is
  8435.          independent of the screen cursor.
  8436.  
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.  
  8443.  
  8444.  
  8445.  
  8446.  
  8447.  
  8448.  
  8449.  
  8450.  
  8451.  
  8452.  
  8453.  
  8454.  
  8455.  
  8456.  
  8457.  
  8458.  
  8459.  
  8460.  
  8461.  
  8462.  
  8463.  
  8464.  
  8465.  
  8466.  
  8467.  
  8468.  
  8469.  
  8470.          Page 128          The C Window Library               Page 128
  8471.  
  8472.                       CREATING VIRTUAL WINDOWS
  8473.                       ------------------------
  8474.  
  8475.          The section will discuss creating virtual windows using the
  8476.          VirtualInitialize() function.
  8477.  
  8478.  
  8479.          VirtualInitialize()
  8480.          -------------------
  8481.  
  8482.          Virtual windows are created by calling the
  8483.          VirtualInitialize() function.  Here is the prototype:
  8484.  
  8485.          VWPOINTER VirtualInitialize(int vwtype, unsigned nrows,
  8486.                                      unsigned ncols, int attr)
  8487.  
  8488.          The VirtualInitialize() function returns a pointer to a
  8489.          virtual window structure (a VWPOINTER).  The first argument
  8490.          to VirtualInitialize() tells whether the virtual window will
  8491.          or will not have its own video attributes.  If this argument
  8492.          is NOATTRIBUTE, the virtual window will not have attributes,
  8493.          otherwise if it is ATTRIBUTE, the virtual window will have
  8494.          its own attributes.  The second argument is the number of
  8495.          rows of the virtual window.  The third argument is the number
  8496.          of columns.  The fourth argument is the attribute to use for
  8497.          the virtual window.  This argument is ignored if the virtual
  8498.          window is NOATTRIBUTE.
  8499.  
  8500.          Example:
  8501.  
  8502.          #include "cwlwin.h"
  8503.          #include <stdio.h>
  8504.  
  8505.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  8506.          VWPOINTER vw1, vw2;
  8507.          main()
  8508.          {
  8509.            WindowInitializeSystem();
  8510.            /* set up a NOATTRIBUTE virtual window */
  8511.            vw1 = VirtualInitialize(NOATTRIBUTE,/* virt. window type */
  8512.                                    30,  /* Number of rows */
  8513.                                    80,  /* Number of cols */
  8514.                                    0);  /* Attribute      */
  8515.  
  8516.            /* set up an ATTRIBUTE virtual window */
  8517.            vw2 = VirtualInitialize(ATTRIBUTE,/* virtual window type */
  8518.                                    30,        /* Number of rows */
  8519.                                    100,       /* Number of cols */
  8520.                                    NORM);     /* Attribute      */
  8521.  
  8522.            if (vw1 == (VWPOINTER)0 ||
  8523.                vw2 == (VWPOINTER)0 ) /* Check if allocation worked */
  8524.              printf(
  8525.              "Error in allocating virtual window."
  8526.              "The error number is %d"", CWLerror_code);
  8527.  
  8528.          }
  8529.  
  8530.          Page 129          The C Window Library               Page 129
  8531.  
  8532.          In the above program, the VirtualInitialize() function is
  8533.          called.  This function allocates memory for the virtual
  8534.          window, and does other initializations.  Once this function
  8535.          is called, you can write to and read characters from the
  8536.          virtual window.
  8537.  
  8538.          Notice that the first argument to VirtualInitialize() is
  8539.          either the constant NOATTRIBUTE or ATTRIBUTE.
  8540.  
  8541.          Also note that there is a check to see whether the virtual
  8542.          windows could be allocated.   If there are no errors,
  8543.          VirtualInitialize() returns a valid VWPOINTER.  If there are
  8544.          errors, VirtualInitialize() returns a null VWPOINTER and sets
  8545.          the global variable CWLerror_code to one of the
  8546.          following:
  8547.  
  8548.          NO_HEAP_MEM if there is not enough memory to allocate for the
  8549.          virtual window.
  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.          Page 130          The C Window Library               Page 130
  8591.  
  8592.               ASSIGNING VIEWPORTS AND CLOSING VIEWPORTS
  8593.               -----------------------------------------
  8594.  
  8595.          For a virtual window to have any useful purpose, it should be
  8596.          displayed on the screen.  However the virtual window may be
  8597.          larger than the physical screen.  The problem is solved by
  8598.          using normal windows to display parts of the virtual window.
  8599.  
  8600.  
  8601.  
  8602.          WindowAssignToVirtual()
  8603.          -----------------------
  8604.  
  8605.          To turn a window into a viewport onto a virtual window, you
  8606.          use the WindowAssignToVirtual() function.
  8607.  
  8608.          Here is the prototype:
  8609.  
  8610.          int WindowAssignToVirtual(WPOINTER w, VWPOINTER vw,
  8611.                                    unsigned row, unsigned col)
  8612.  
  8613.          The first argument is the window that will be turned into a
  8614.          viewport.  The second argument is the virtual window that w
  8615.          will be assigned to.  The third and fourth arguments are the
  8616.          (row,col) of the virtual window.  This position is where the
  8617.          upper left hand corner of the viewport's text area will be
  8618.          placed.
  8619.  
  8620.          To illustrate this, here is a sample call to
  8621.          WindowAssignToVirtual():
  8622.  
  8623.                 WindowAssignToVirtual(w,vw,5,10)
  8624.  
  8625.          The following description shows how this is to be
  8626.          interpreted:
  8627.  
  8628.                                   VIRTUAL WINDOW
  8629.          ┌───────────────────────────────────────────────────────────┐
  8630.          │(0,0)                                               (0,100)│
  8631.          │                                                           │
  8632.          │       (5,10) of virtual window is equivalent to (0,0) of  │
  8633.          │         |    the viewport.                                │
  8634.          │         v                                                 │
  8635.          │         ┌─────────────────────┐                           │
  8636.          │         │(0,0) of the viewport│                           │
  8637.          │         │                     │                           │
  8638.          │         │   VIEWPORT WINDOW   │                           │
  8639.          │         │(14,0)        (14,30)│                           │
  8640.          │         └─────────────────────┘                           │
  8641.          │                                                           │
  8642.          │(100,0)                                           (100,100)│
  8643.          └───────────────────────────────────────────────────────────┘
  8644.  
  8645.          The viewport relative position of (0,0) is located at (5,10)
  8646.          of the virtual window.
  8647.  
  8648.  
  8649.  
  8650.          Page 131          The C Window Library               Page 131
  8651.  
  8652.          Example:
  8653.  
  8654.          #include "cwlwin.h"
  8655.  
  8656.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  8657.          VWPOINTER vw;          /* virtual window pointers */
  8658.          WPOINTER w;
  8659.          main()
  8660.          {
  8661.            WindowInitializeSystem();
  8662.            WindowInitDesktop(0);
  8663.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  8664.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0, 0,20,12,
  8665.                                 NORM,NORM,SINGLEBOX);
  8666.            WindowDisplay(w,1,NOEFFECT);
  8667.            VirtualWriteString(vw,"This is a string",0,0);
  8668.  
  8669.            WindowAssignToVirtual(w,vw,0,0);  /* Assign viewport
  8670.                                                 to virtual window
  8671.                                               */
  8672.          }
  8673.  
  8674.  
  8675.          The above program opens a virtual window, vw, and opens a
  8676.          normal window, w.  In the above example, the
  8677.          VirtualWriteString() function is used to write strings to the
  8678.          virtual window.  See the WRITING TEXT TO VIRTUAL WINDOWS
  8679.          section for more information on VirtualWriteString().
  8680.  
  8681.          Once a window is turned into a viewport, nothing is stopping
  8682.          you from using the other window functions.  You can still use
  8683.          WindowWriteString(), WindowMove(), WindowPrintf(), etc.
  8684.          Writing text to a viewport window via the normal window
  8685.          functions does not effect the virtual window in any way.
  8686.  
  8687.                Return Values for WindowAssignToVirtual():
  8688.  
  8689.              Return Value        Definition
  8690.          ┌────────────────┬────────────────────────┐
  8691.          │NO_ERROR        │ No error occured.      │
  8692.          ├────────────────┼────────────────────────┤
  8693.          │BAD_WINDOW      │ Window does not exist. │
  8694.          ├────────────────┼────────────────────────┤
  8695.          │BAD_V_WINDOW    │ Virtual window does    │
  8696.          │                │ not exist.             │
  8697.          └────────────────┴────────────────────────┘
  8698.  
  8699.  
  8700.          Out of bounds Coordinates
  8701.          -------------------------
  8702.  
  8703.  
  8704.          The next question is "What do you do if the coordinates given
  8705.          in WindowAssignToVirtual() are out of bounds of the range of
  8706.          the virtual window?".  For instance, if the virtual window
  8707.  
  8708.  
  8709.  
  8710.          Page 132          The C Window Library               Page 132
  8711.  
  8712.          has 100 rows, but the call to WindowAssignToVirtual()
  8713.          specifies row 97, and the viewport itself has a height of 10
  8714.          rows.  The window manager will fill the viewport with as much
  8715.          of the virtual window as possible, and will clear the
  8716.          contents of the viewport that are not inside the virtual
  8717.          window.
  8718.  
  8719.          Here is another view of what happens in this case:
  8720.  
  8721.  
  8722.                                 VIRTUAL WINDOW
  8723.          ┌─────────────────────────────────────────────────────────┐
  8724.          │(0,0)                                             (100,0)│
  8725.          │                                                         │
  8726.          │       (97,10) of virtual window is same as (0,0) of     │
  8727.          │         |     the viewport window.                      │
  8728.          │         v                                               │
  8729.          │         ┌─────────────────────┐                         │
  8730.          │         │(0,0) of the viewport│                         │
  8731.          │         │                     │                         │
  8732.          │(100,0)  │   VIEWPORT WINDOW   │               (100,100) │
  8733.          └─────────┼─────────────────────┼─────────────────────────┘
  8734.                    │This portion of the  │
  8735.                    │  window is cleared  │
  8736.                    └─────────────────────┘
  8737.  
  8738.          The above picture shows a viewport that is partially
  8739.          contained in the virtual window.  The contents of the window
  8740.          above the last row of the virtual window is updated, while
  8741.          the portion of the viewport below the line is cleared.
  8742.  
  8743.  
  8744.  
  8745.  
  8746.          WindowCloseViewport()
  8747.          ---------------------
  8748.  
  8749.          To turn a viewport back to a normal window,
  8750.          WindowCloseViewport() is called.  Here is the prototype:
  8751.  
  8752.          int WindowCloseViewport(WPOINTER w, int hide, int effect)
  8753.  
  8754.          where w is the viewport to be turned back into a regular
  8755.          window.  When this function is called, the window w is
  8756.          cleared with its own video attribute.  The second argument
  8757.          tells if the window is to be hidden. If hide is 1, the window
  8758.          is hidden.  If it is 0, the window remains on the screen.
  8759.          The effect argument is a special effect to use when hiding
  8760.          the window.  A list of special effects are defined in the
  8761.          DISPLAYING WINDOWS section.  This function DOES NOT close the
  8762.          virtual window or does a WindowClose() to the viewport
  8763.          window.
  8764.  
  8765.  
  8766.  
  8767.  
  8768.  
  8769.  
  8770.          Page 133          The C Window Library               Page 133
  8771.  
  8772.          Example:
  8773.  
  8774.  
  8775.          #include "cwlwin.h"
  8776.  
  8777.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  8778.          VWPOINTER vw;          /* virtual window pointers */
  8779.          WPOINTER w;
  8780.          main()
  8781.          {
  8782.            WindowInitializeSystem();
  8783.            WindowInitDesktop(0);
  8784.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  8785.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0, 0,20,12,NORM,
  8786.                                 NORM,SINGLEBOX);
  8787.            WindowDisplay(w,1,NOEFFECT);
  8788.            VirtualWriteString(vw,"This is a string",0,0);
  8789.            WindowAssignToVirtual(w,vw,0,0);
  8790.            GET_KEY();
  8791.            WindowCloseViewport(w,1,NOEFFECT);
  8792.            GET_KEY();
  8793.          }
  8794.  
  8795.  
  8796.          The example above opens a virtual windows and a normal.  It
  8797.          then assigns the windows to the virtual window by calling
  8798.          WindowAssignToVirtual().  The program then unassigns the
  8799.          viewport by calling WindowCloseViewport().
  8800.  
  8801.               Return Values for WindowCloseViewport():
  8802.  
  8803.              Return Value        Definition
  8804.          ┌────────────────┬────────────────────────┐
  8805.          │NO_ERROR        │ No error occured.      │
  8806.          ├────────────────┼────────────────────────┤
  8807.          │BAD_WINDOW      │ Window does not exist. │
  8808.          ├────────────────┼────────────────────────┤
  8809.          │BAD_V_WINDOW    │ Virtual window does    │
  8810.          │                │ not exist.             │
  8811.          └────────────────┴────────────────────────┘
  8812.  
  8813.  
  8814.  
  8815.  
  8816.  
  8817.  
  8818.  
  8819.  
  8820.  
  8821.  
  8822.  
  8823.  
  8824.  
  8825.  
  8826.  
  8827.  
  8828.  
  8829.  
  8830.          Page 134          The C Window Library               Page 134
  8831.  
  8832.                    WRITING TEXT TO VIRTUAL WINDOWS
  8833.                    -------------------------------
  8834.  
  8835.          There are several functions that write strings to virtual
  8836.          windows.  They are divided into two groups: functions that
  8837.          take null terminated strings as arguments, and functions that
  8838.          use character buffers and a length argument.
  8839.  
  8840.          When any of the text functions are called, any viewport that
  8841.          is displaying any portion of the virtual window that has been
  8842.          changed will display the update.
  8843.  
  8844.  
  8845.          Null Terminated String Functions
  8846.          --------------------------------
  8847.  
  8848.          VirtualWriteString()
  8849.          --------------------
  8850.  
  8851.          The VirtualWriteString() function writes a null terminated to
  8852.          a virtual window at a specific row and column of the virtual
  8853.          window.  Here is the prototype:
  8854.  
  8855.          int VirtualWriteString(VWPOINTER vw, char *string,
  8856.                                 unsigned row, unsigned col)
  8857.  
  8858.          The first argument is the virtual window pointer.  The second
  8859.          argument is the string to write.  The third and fourth
  8860.          arguments are the row and column of the virtual window that
  8861.          the string is to be written to.  If the string will exceed
  8862.          the boundaries of the virtual window, the string is
  8863.          truncated.
  8864.  
  8865.          Example:
  8866.  
  8867.          #include "cwlwin.h"
  8868.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  8869.          VWPOINTER vw;          /* virtual window pointers */
  8870.          WPOINTER w1, w2;
  8871.          main()
  8872.          {
  8873.            WindowInitializeSystem();
  8874.            WindowInitDesktop(0);
  8875.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  8876.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0, 0,20,12,
  8877.                                  NORM,NORM,SINGLEBOX);
  8878.            w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,13,0,20,10,
  8879.                                  NORM,NORM,DOUBLEBOX);
  8880.            WindowDisplay(w1,1,NOEFFECT);
  8881.            WindowDisplay(w2,2,NOEFFECT);
  8882.  
  8883.            VirtualWriteString(vw,"This is a string",0,0);
  8884.            WindowAssignToVirtual(w1,vw,0,0);
  8885.            WindowAssignToVirtual(w2,vw,0,10);
  8886.          }
  8887.  
  8888.  
  8889.  
  8890.          Page 135          The C Window Library               Page 135
  8891.  
  8892.          The example above writes the string "This is a string" to the
  8893.          virtual window at row 0, column 0.  The windows w1 and w2 are
  8894.          viewports on the virtual window vw.  The window w1 is located
  8895.          at (0,0) of the virtual window, while w2 is located at (0,10)
  8896.          of the virtual window.  The window w1 will display "This is a
  8897.          string", but w2 will only display "string" since it is
  8898.          situated at column 10 of the virtual window.
  8899.  
  8900.  
  8901.                Return Values for VirtualWriteString():
  8902.  
  8903.              Return Value        Definition
  8904.          ┌────────────────┬────────────────────────┐
  8905.          │NO_ERROR        │ No error occured.      │
  8906.          ├────────────────┼────────────────────────┤
  8907.          │BAD_V_WINDOW    │ Virtual window does    │
  8908.          │                │ not exist.             │
  8909.          ├────────────────┼────────────────────────┤
  8910.          │V_WINDOW_BOUND  │ Row or Column is out   │
  8911.          │                │ of bounds.             │
  8912.          └────────────────┴────────────────────────┘
  8913.  
  8914.  
  8915.  
  8916.          VirtualWriteStringAttr()
  8917.          ------------------------
  8918.  
  8919.          The VirtualWriteStringAttr() works the same way as the
  8920.          VirtualWriteString() except that a video attribute is used.
  8921.          Here is the prototype:
  8922.  
  8923.          int VirtualWriteStringAttr(VWPOINTER vw, char *string,
  8924.                                     unsigned row, unsigned col,
  8925.                                     int attr)
  8926.  
  8927.          The last argument is the video attribute to use.  If the
  8928.          virtual window is NOATTRIBUTE, the attribute is ignored, and
  8929.          only the string is written.  Any viewports that are assigned
  8930.          to NOATTRIBUTE virtual windows will not reflect the change in
  8931.          the attribute.
  8932.  
  8933.          Example:
  8934.  
  8935.          #include "cwlwin.h"
  8936.          #define NORM     CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  8937.          #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  8938.          VWPOINTER vw;          /* virtual window pointers */
  8939.          WPOINTER w;
  8940.          main()
  8941.          {
  8942.            WindowInitializeSystem();
  8943.            WindowInitDesktop(0);
  8944.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  8945.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0, 0,20,12,
  8946.                                 NORM,NORM,SINGLEBOX);
  8947.            WindowDisplay(w,1,NOEFFECT);
  8948.            VirtualWriteStringAttr(vw,"This is a string",0,0,REVERSE);
  8949.  
  8950.          Page 136          The C Window Library               Page 136
  8951.  
  8952.            WindowAssignToVirtual(w,vw,0,0);
  8953.          }
  8954.  
  8955.  
  8956.          The example above writes the string "This is a string" in the
  8957.          virtual window with a video attribute defined by the constant
  8958.          REVERSE.
  8959.  
  8960.              Return Value        Definition
  8961.          ┌────────────────┬────────────────────────┐
  8962.          │NO_ERROR        │ No error occured.      │
  8963.          ├────────────────┼────────────────────────┤
  8964.          │BAD_V_WINDOW    │ Virtual window does    │
  8965.          │                │ not exist.             │
  8966.          ├────────────────┼────────────────────────┤
  8967.          │V_WINDOW_BOUND  │ Row or Column is out   │
  8968.          │                │ of bounds.             │
  8969.          ├────────────────┼────────────────────────┤
  8970.          │NO_ATTRIB       │ Virtual Window is      │
  8971.          │                │ NOATTRIBUTE.  If this  │
  8972.          │                │ error occurs, only the │
  8973.          │                │ string is written.     │
  8974.          └────────────────┴────────────────────────┘
  8975.  
  8976.  
  8977.  
  8978.          VirtualWriteCenterString()
  8979.          --------------------------
  8980.  
  8981.          The VirtualWriteCenterString() writes a centered string in a
  8982.          virtual window.  Here is the prototype:
  8983.  
  8984.          int VirtualWriteCenterString(VWPOINTER vw, char *string,
  8985.                                       unsigned row)
  8986.  
  8987.          The row argument is the row to center the string on.
  8988.  
  8989.          Example:
  8990.  
  8991.          #include "cwlwin.h"
  8992.          #define NORM     CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  8993.          VWPOINTER vw;          /* virtual window pointers */
  8994.          WPOINTER w;
  8995.  
  8996.          main()
  8997.          {
  8998.            WindowInitializeSystem();
  8999.            WindowInitDesktop(0);
  9000.            vw = VirtualInitialize(NOATTRIBUTE,30,80,NORM);
  9001.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,
  9002.                                 0,50,12,NORM,NORM,SINGLEBOX);
  9003.            WindowDisplay(w,1,NOEFFECT);
  9004.            VirtualWriteCenterString(vw,"This is a string",0);
  9005.            WindowAssignToVirtual(w,vw,0,0);
  9006.          }
  9007.  
  9008.  
  9009.  
  9010.          Page 137          The C Window Library               Page 137
  9011.  
  9012.          The above example illustrates the use of
  9013.          VirtualWriteCenterString().  The viewport window w is just
  9014.          used as a guide to display what has happened.
  9015.  
  9016.                Return Values for VirtualWriteCenterString():
  9017.  
  9018.              Return Value        Definition
  9019.          ┌────────────────┬────────────────────────┐
  9020.          │NO_ERROR        │ No error occured.      │
  9021.          ├────────────────┼────────────────────────┤
  9022.          │BAD_V_WINDOW    │ Virtual window does    │
  9023.          │                │ not exist.             │
  9024.          ├────────────────┼────────────────────────┤
  9025.          │V_WINDOW_BOUND  │ Row is out of bounds.  │
  9026.          └────────────────┴────────────────────────┘
  9027.  
  9028.  
  9029.  
  9030.          VirtualWriteCenterStringAttr()
  9031.          ------------------------------
  9032.  
  9033.  
  9034.          The VirtualWriteCenterStringAttr() function works the same
  9035.          way as VirtualWriteCenterString() except that a video
  9036.          attribute is specified.  Here is the prototype:
  9037.  
  9038.          int VirtualWriteCenterStringAttr(VWPOINTER vw, char *string,
  9039.                                           unsigned row, int attr)
  9040.  
  9041.          The attr argument is the video attribute to use.  If the
  9042.          virtual window is NOATTRIBUTE, the attribute is ignored and
  9043.          only the string is written to the virtual window.
  9044.  
  9045.  
  9046.          #include "cwlwin.h"
  9047.  
  9048.          #define NORM     CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9049.          #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  9050.          VWPOINTER vw;          /* virtual window pointers */
  9051.          WPOINTER w;
  9052.          main()
  9053.          {
  9054.            WindowInitializeSystem();
  9055.            WindowInitDesktop(0);
  9056.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  9057.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,
  9058.                                 0,50,12,NORM,NORM,SINGLEBOX);
  9059.            WindowDisplay(w,1,NOEFFECT);
  9060.            VirtualWriteCenterStringAttr(vw,"This is a string",0,
  9061.                                         REVERSE);
  9062.            WindowAssignToVirtual(w,vw,0,0);
  9063.          }
  9064.  
  9065.  
  9066.  
  9067.  
  9068.  
  9069.  
  9070.          Page 138          The C Window Library               Page 138
  9071.  
  9072.                Return Values for VirtualWriteString():
  9073.  
  9074.              Return Value        Definition
  9075.          ┌────────────────┬────────────────────────┐
  9076.          │NO_ERROR        │ No error occured.      │
  9077.          ├────────────────┼────────────────────────┤
  9078.          │BAD_V_WINDOW    │ Virtual window does    │
  9079.          │                │ not exist.             │
  9080.          ├────────────────┼────────────────────────┤
  9081.          │V_WINDOW_BOUND  │ Row or Column is out   │
  9082.          │                │ of bounds.             │
  9083.          ├────────────────┼────────────────────────┤
  9084.          │NO_ATTRIB       │The virtual window is   │
  9085.          │                │NOATTRIBUTE.  If this   │
  9086.          │                │error occurs, only the  │
  9087.          │                │string is written.      │
  9088.          └────────────────┴────────────────────────┘
  9089.  
  9090.  
  9091.          VirtualWriteStringCC()
  9092.          ----------------------
  9093.          The VirtualWriteStringCC() function centers and writes a
  9094.          string around a column of the virtual window (the CC stands
  9095.          for Centered Column).  If the string is longer than the width
  9096.          of the virtual window, the string is placed on column 1 is
  9097.          clipped at the right edge of the virtual window.  Here is the
  9098.          prototype:
  9099.  
  9100.          int VirtualWriteStringCC(VWPOINTER vw, char *string,
  9101.                                   unsigned row, unsigned col)
  9102.  
  9103.          The first argument is the window.  The second argument is the
  9104.          string. The third argument is the row to write the string,
  9105.          and the last argument is the column to center the string on.
  9106.  
  9107.          Example:
  9108.  
  9109.          #include "cwlwin.h"
  9110.          #define NORM     CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9111.          VWPOINTER vw;          /* virtual window pointers */
  9112.          WPOINTER w;
  9113.          main()
  9114.          {
  9115.            WindowInitializeSystem();
  9116.            WindowInitDesktop(0);
  9117.            vw = VirtualInitialize(NOATTRIBUTE,30,80,NORM);
  9118.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,
  9119.                                 0,50,12,NORM,NORM,SINGLEBOX);
  9120.            WindowDisplay(w,1,NOEFFECT);
  9121.            VirtualWriteStringCC(vw,"This",0,10);
  9122.            VirtualWriteStringCC(vw,"is",1,10);
  9123.            VirtualWriteStringCC(vw,"centered",2,10);
  9124.            VirtualWriteStringCC(vw,"around",3,10);
  9125.            VirtualWriteStringCC(vw,"column",4,10);
  9126.            VirtualWriteStringCC(vw,"10",5,10);
  9127.            WindowAssignToVirtual(w,vw,0,0);
  9128.          }
  9129.  
  9130.          Page 139          The C Window Library               Page 139
  9131.  
  9132.          The example above writes the text centered around column 10
  9133.          of the virtual window w.
  9134.  
  9135.          The return values for VirtualWriteStringCC() are the same as
  9136.          VirtualWriteString().
  9137.  
  9138.  
  9139.  
  9140.  
  9141.  
  9142.          VirtualWriteStringCCAttr()
  9143.          --------------------------
  9144.  
  9145.          The VirtualWriteStringCCAttr() works the same way as the
  9146.          VirtualWriteStringCC() function except that a video attribute
  9147.          is specified.  Here is the prototype:
  9148.  
  9149.          int VirtualWriteStringCCAttr(VWPOINTER vw, char *string,
  9150.                                       unsigned row, unsigned col,
  9151.                                       int attr)
  9152.  
  9153.          The attribute to use is the last argument.  If the virtual
  9154.          window is NOATTRIBUTE, the attr argument is ignored, and only
  9155.          the string is written to the virtual window.
  9156.  
  9157.          Example:
  9158.  
  9159.          #include "cwlwin.h"
  9160.  
  9161.          #define NORM     CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9162.          #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  9163.  
  9164.          VWPOINTER vw;          /* virtual window pointers */
  9165.          WPOINTER w;
  9166.          main()
  9167.          {
  9168.            WindowInitializeSystem();
  9169.            WindowInitDesktop(0);
  9170.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  9171.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,
  9172.                                 0,50,12,NORM,NORM,SINGLEBOX);
  9173.            WindowDisplay(w,1,NOEFFECT);
  9174.            VirtualWriteStringCCAttr(vw,"This",0,10,REVERSE);
  9175.            VirtualWriteStringCCAttr(vw,"is",1,10,REVERSE);
  9176.            VirtualWriteStringCCAttr(vw,"centered",2,10,REVERSE);
  9177.            VirtualWriteStringCCAttr(vw,"around",3,10,REVERSE);
  9178.            VirtualWriteStringCCAttr(vw,"column",4,10,REVERSE);
  9179.            VirtualWriteStringCCAttr(vw,"10",5,10,REVERSE);
  9180.            WindowAssignToVirtual(w,vw,0,0);
  9181.          }
  9182.  
  9183.          The return values for VirtualWriteStringCCAttr() are the same
  9184.          as VirtualWriteStringAttr().
  9185.  
  9186.  
  9187.  
  9188.  
  9189.  
  9190.          Page 140          The C Window Library               Page 140
  9191.  
  9192.          VirtualWriteStringRJ()
  9193.          ----------------------
  9194.  
  9195.          The VirtualWriteStringRJ() function writes a right justified
  9196.          string in a virtual window.  Here is the prototype:
  9197.  
  9198.          int VirtualWriteStringRJ(WPOINTER w, char *string,
  9199.                                   unsigned row, unsigned col)
  9200.  
  9201.          The first argument is the virtual window.  The second
  9202.          argument is the string.  The third argument is the row to
  9203.          write the string, and the last argument is the column to
  9204.          place the right edge of the string.
  9205.  
  9206.  
  9207.          Example:
  9208.  
  9209.          #include "cwlwin.h"
  9210.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9211.  
  9212.           VWPOINTER vw;          /* virtual window pointers */
  9213.           WPOINTER w;
  9214.           main()
  9215.           {
  9216.             WindowInitializeSystem();
  9217.             WindowInitDesktop(0);
  9218.             vw = VirtualInitialize(NOATTRIBUTE,30,80,NORM);
  9219.             w = WindowInitialize(DESKTOP_WINDOW,BORDER,0, 0,50,12,
  9220.                                  NORM,NORM,SINGLEBOX);
  9221.             WindowDisplay(w,1,NOEFFECT);
  9222.             VirtualWriteStringRJ(vw,"This",0,10);
  9223.             VirtualWriteStringRJ(vw,"is",1,10);
  9224.             VirtualWriteStringRJ(vw,"right",2,10);
  9225.             VirtualWriteStringRJ(vw,"justified",3,10);
  9226.             VirtualWriteStringRJ(vw,"on ",4,10);
  9227.             VirtualWriteStringRJ(vw,"column",5,10);
  9228.             VirtualWriteStringRJ(vw,"10",6,10);
  9229.             WindowAssignToVirtual(w,vw,0,0);
  9230.           }
  9231.  
  9232.  
  9233.          The example above writes the text right justified on column
  9234.          10 of the virtual window.
  9235.  
  9236.          The return values for VirtualWriteStringRJ() are the same as
  9237.          VirtualWriteString().
  9238.  
  9239.  
  9240.  
  9241.  
  9242.          VirtualWriteStringRJAttr()
  9243.          --------------------------
  9244.  
  9245.          The VirtualWriteStringRJAttr() writes a right justified
  9246.          string in a virtual window, and allows you to specify a video
  9247.          attribute. Here is the prototype:
  9248.  
  9249.  
  9250.          Page 141          The C Window Library               Page 141
  9251.  
  9252.          int VirtualWriteStringRJAttr(WPOINTER w, char *string,
  9253.                                       unsigned row, unsigned col,
  9254.                                       int attr)
  9255.  
  9256.          The last argument is the attribute to use.
  9257.  
  9258.  
  9259.          Example:
  9260.  
  9261.  
  9262.          #include "cwlwin.h"
  9263.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9264.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  9265.  
  9266.          VWPOINTER vw;          /* virtual window pointers */
  9267.          WPOINTER w;
  9268.          main()
  9269.          {
  9270.            WindowInitializeSystem();
  9271.            WindowInitDesktop(0);
  9272.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  9273.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,
  9274.                                 0,50,12,NORM,NORM,SINGLEBOX);
  9275.            WindowDisplay(w,1,NOEFFECT);
  9276.            VirtualWriteStringRJAttr(vw,"This",0,10,REVERSE);
  9277.            VirtualWriteStringRJAttr(vw,"is",1,10,REVERSE);
  9278.            VirtualWriteStringRJAttr(vw,"right",2,10,REVERSE);
  9279.            VirtualWriteStringRJAttr(vw,"justified",3,10,REVERSE);
  9280.            VirtualWriteStringRJAttr(vw,"on ",4,10,REVERSE);
  9281.            VirtualWriteStringRJAttr(vw,"column",5,10,REVERSE);
  9282.            VirtualWriteStringRJAttr(vw,"10",6,10,REVERSE);
  9283.            WindowAssignToVirtual(w,vw,0,0);
  9284.          }
  9285.  
  9286.  
  9287.          The example above writes the text right justified on column
  9288.          10 of the virtual window.  If the virtual window is
  9289.          NOATTRIBUTE, only the string is written.
  9290.  
  9291.          The return values for VirtualWriteStringRJAttr() are the same
  9292.          as VirtualWriteStringAttr().
  9293.  
  9294.  
  9295.          Length Controlled Functions
  9296.          ---------------------------
  9297.  
  9298.          VirtualWriteCharacters()
  9299.          ------------------------
  9300.  
  9301.          The VirtualWriteCharacters() writes a specified number of
  9302.          characters from a buffer to the virtual window.  Here is the
  9303.          prototype:
  9304.  
  9305.          int VirtualWriteCharacters(VWPOINTER vw, char *buffer,
  9306.                                     unsigned row, unsigned col,
  9307.                                     unsigned length)
  9308.  
  9309.  
  9310.          Page 142          The C Window Library               Page 142
  9311.  
  9312.          The first argument is the virtual window.  The second
  9313.          argument is the buffer where the characters are stored.  The
  9314.          third and fourth arguments are the (row,col) of where the
  9315.          characters will be placed in the virtual window.  The last
  9316.          argument is the number of characters from buffer that will be
  9317.          written.
  9318.  
  9319.  
  9320.          Example:
  9321.  
  9322.          #include "cwlwin.h"
  9323.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9324.  
  9325.          WPOINTER w;
  9326.          VWPOINTER vw;
  9327.          char buf[] = "Hello World!!";
  9328.  
  9329.          main()
  9330.          {
  9331.            WindowInitializeSystem();
  9332.            WindowInitDesktop(0);
  9333.            w =
  9334.            WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  9335.                             NORM,NORM,SINGLEBOX);
  9336.            vw = VirtualInitialize(NOATTRIBUTE,30,80,NORM);
  9337.            WindowDisplay(w,1,NOEFFECT);
  9338.            VirtualWriteCharacters(vw,buf,0,0,11);
  9339.            VirtualWriteCharacters(vw,buf,1,0,13);
  9340.            WindowAssignToVirtual(w,vw,0,0);
  9341.          }
  9342.  
  9343.  
  9344.          The return values for VirtualWriteCharacters() are the same
  9345.          as VirtualWriteString().
  9346.  
  9347.  
  9348.          VirtualWriteAttributes()
  9349.          ------------------------
  9350.  
  9351.          The VirtualWriteAttributes() writes a specified number of
  9352.          attributes from a buffer to the virtual window.  Here is the
  9353.          prototype:
  9354.  
  9355.  
  9356.          int VirtualWriteAttributes(VWPOINTER vw, char *buffer,
  9357.                                     unsigned row, unsigned col,
  9358.                                     unsigned length)
  9359.  
  9360.  
  9361.          The first argument is the virtual window.  The second
  9362.          argument is the buffer where the attributes are stored.  The
  9363.          third and fourth arguments are the (row,col) of where the
  9364.          attributes will be placed in the virtual window.  The last
  9365.          argument is the number of attributes from buffer that will be
  9366.          written.  If the window is NOATTRIBUTE, this function does
  9367.          nothing.
  9368.  
  9369.  
  9370.          Page 143          The C Window Library               Page 143
  9371.  
  9372.          Example:
  9373.  
  9374.  
  9375.          #include "cwlwin.h"
  9376.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9377.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  9378.          WPOINTER w;
  9379.          VWPOINTER vw;
  9380.          char buf[13];
  9381.  
  9382.          main()
  9383.          {
  9384.            int i;
  9385.            WindowInitializeSystem();
  9386.            WindowInitDesktop(0);
  9387.            for (i=0;i<13;i++)
  9388.              if (i % 2)
  9389.                buf[i] = NORM;
  9390.              else
  9391.                buf[i] = REVERSE;
  9392.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  9393.                                 NORM,NORM,SINGLEBOX);
  9394.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  9395.            WindowDisplay(w,1,NOEFFECT);
  9396.            VirtualWriteString(vw,"Hello World!!",0,0);
  9397.            VirtualWriteAttributes(vw,buf,0,0,13);
  9398.            WindowAssignToVirtual(w,vw,0,0);
  9399.          }
  9400.  
  9401.  
  9402.          The return values for VirtualWriteAttributes() are the same
  9403.          as VirtualWriteStringAttr().
  9404.  
  9405.  
  9406.  
  9407.  
  9408.  
  9409.          VirtualWriteCharAndAttr()
  9410.          -------------------------
  9411.  
  9412.          The VirtualWriteCharAndAttr() function writes a string of
  9413.          character/attribute pairs to a virtual window.  Use this
  9414.          function if you have created a string of character/attribute
  9415.          pairs, and want to output them easily.  The string consists
  9416.          of character and attributes in the following manner:
  9417.  
  9418.                   char-attr-char-attr...
  9419.  
  9420.          Each character is followed by its corresponding video
  9421.          attribute.  Here is the prototype:
  9422.  
  9423.  
  9424.          int VirtualWriteCharAndAttr(VWPOINTER vw, char *buffer,
  9425.                                      unsigned row, unsigned col,
  9426.                                      unsigned length)
  9427.  
  9428.  
  9429.  
  9430.          Page 144          The C Window Library               Page 144
  9431.  
  9432.          The first argument is the virtual window. The second is the
  9433.          buffer where the character and attributes are stored.  The
  9434.          third and fourth is the (row,col) position in the virtual
  9435.          window to write, and the length argument is the number of
  9436.          character/attribute pairs from the buffer to write.  Please
  9437.          note the difference in the meaning of the length argument in
  9438.          this function as opposed to its use in the preceding
  9439.          functions.
  9440.  
  9441.          If the virtual window is NOATTRIBUTE, nothing is written to
  9442.          the virtual window.
  9443.  
  9444.          Example:
  9445.  
  9446.          #include "cwlwin.h"
  9447.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9448.  
  9449.          WPOINTER w;
  9450.          VWPOINTER vw;
  9451.          char buf[26];
  9452.          char *str = "Hello World!!";
  9453.          main()
  9454.          {
  9455.            int i;
  9456.            WindowInitializeSystem();
  9457.            WindowInitDesktop(0);
  9458.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  9459.                                 NORM,NORM,SINGLEBOX);
  9460.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  9461.            WindowDisplay(w,1,NOEFFECT);
  9462.  
  9463.            for (i=0;i<26;i+=2,str++)
  9464.            {
  9465.              buf[i] = *str;
  9466.              buf[i+1] = NORM;
  9467.            }
  9468.            VirtualWriteCharAndAttr(vw,buf,0,0,13);
  9469.            WindowAssignToVirtual(w,vw,0,0);
  9470.          }
  9471.  
  9472.  
  9473.          The return values for VirtualWriteCharAndAttr() are the same
  9474.          as VirtualWriteStringAttr().
  9475.  
  9476.  
  9477.  
  9478.          VirtualWriteRepeatAttribute()
  9479.          -----------------------------
  9480.  
  9481.          The VirtualWriteRepeatAttribute() function writes an
  9482.          attribute a specified number of times to a virtual window.
  9483.  
  9484.          Here is a prototype:
  9485.  
  9486.          int VirtualWriteRepeatAttribute(VWPOINTER vw, int attr,
  9487.                                          unsigned row, unsigned col,
  9488.                                          int count)
  9489.  
  9490.          Page 145          The C Window Library               Page 145
  9491.  
  9492.          The attr argument is the attribute to use.  The count
  9493.          argument specifies the number of times to write the attribute
  9494.          attr to the virtual window starting at (row,col).  If the
  9495.          virtual window is NOATTRIBUTE, this function returns an
  9496.          error.
  9497.  
  9498.  
  9499.          Example:
  9500.  
  9501.          #include "cwlwin.h"
  9502.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9503.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  9504.  
  9505.          WPOINTER w;
  9506.          VWPOINTER vw;
  9507.          main()
  9508.          {
  9509.            WindowInitializeSystem();
  9510.            WindowInitDesktop(0);
  9511.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  9512.                                 NORM,NORM,SINGLEBOX);
  9513.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  9514.            WindowDisplay(w,1,NOEFFECT);
  9515.            VirtualWriteString(vw,"Hello World!!",0,0);
  9516.            VirtualWriteRepeatAttribute(vw,REVERSE,0,0,13);
  9517.            WindowAssignToVirtual(w,vw,0,0);
  9518.          }
  9519.  
  9520.          The example above illustrates that the
  9521.          VirtualWriteRepeatAttribute() writes the REVERSE attribute 13
  9522.          times starting at row 0, column 0 of the virtual window w.
  9523.  
  9524.          The return values for VirtualWriteRepeatAttribute() are the
  9525.          same as VirtualWriteStringAttr().
  9526.  
  9527.  
  9528.  
  9529.          VirtualWriteRepeatCharacter()
  9530.          -----------------------------
  9531.  
  9532.          The VirtualWriteRepeatCharacter() function writes a character
  9533.          a specified number of times to a virtual window.  Here is a
  9534.          prototype:
  9535.  
  9536.  
  9537.  
  9538.          int VirtualWriteRepeatCharacter(WPOINTER w, int ch, int row,
  9539.                                          int col, int count)
  9540.  
  9541.          The count argument is the character to use.  The count
  9542.          argument specifies the number of times to write the character
  9543.          ch to the virtual window starting at (row,col).
  9544.  
  9545.  
  9546.  
  9547.  
  9548.  
  9549.  
  9550.          Page 146          The C Window Library               Page 146
  9551.  
  9552.          Example:
  9553.  
  9554.          #include "cwlwin.h"
  9555.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9556.  
  9557.          VWPOINTER vw;
  9558.          WPOINTER w;
  9559.  
  9560.          main()
  9561.          {
  9562.            WindowInitializeSystem();
  9563.            WindowInitDesktop(0);
  9564.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,20,10,
  9565.                                 NORM,NORM,SINGLEBOX);
  9566.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  9567.            WindowDisplay(w,1,NOEFFECT);
  9568.            VirtualWriteRepeatCharacter(vw,'a',0,0,5);
  9569.            VirtualWriteRepeatCharacter(vw,'b',1,0,5);
  9570.            VirtualWriteRepeatCharacter(vw,'c',2,0,5);
  9571.            WindowAssignToVirtual(w,vw,0,0);
  9572.          }
  9573.  
  9574.  
  9575.  
  9576.          The example above illustrates that the
  9577.          VirtualWriteRepeatCharacter() writes the letter 'a', 'b', and
  9578.          'c' 5 times on rows 0, 1, and 2 respectively.
  9579.  
  9580.          The return values for VirtualWriteRepeatCharacter() are the
  9581.          same as VirtualWriteString().
  9582.  
  9583.  
  9584.  
  9585.  
  9586.          Formatted Write Functions
  9587.          -------------------------
  9588.  
  9589.  
  9590.          Format String
  9591.          -------------
  9592.  
  9593.          These functions write formatted output to virtual windows
  9594.          just like the printf() function.  There are two functions
  9595.          that do this, namely VirtualPrintf() and VirtualPrintfAttr().
  9596.          These functions use a format string that is similar to the
  9597.          format string found in printf().  For example, %d, %s, %lf,
  9598.          etc. and most of the escape sequences are supported.  The
  9599.          list of escape sequences supported are as follows:
  9600.  
  9601.  
  9602.                                \n - newline
  9603.                                \t - tab
  9604.                                \r - carriage return
  9605.                                \x - hexadecimal
  9606.  
  9607.  
  9608.  
  9609.  
  9610.          Page 147          The C Window Library               Page 147
  9611.  
  9612.          Where Output is Placed
  9613.          ----------------------
  9614.  
  9615.          The row and column of where the string will be written is
  9616.          determined by the virtual window's logical cursor.  The
  9617.          logical cursor is advanced by both of these functions to one
  9618.          column position after the last character is printed.  If you
  9619.          want to start at a particular row and column of the window,
  9620.          you must move the cursor yourself by calling the
  9621.          VirtualMoveCursor() function.  This function is explained in
  9622.          the MOVING THE LOGICAL CURSOR section.
  9623.  
  9624.          When the virtual window is first initialized using
  9625.          VirtualInitialize(), the logical cursor is automatically
  9626.          moved to (0,0) of the virtual window.
  9627.  
  9628.  
  9629.  
  9630.          VirtualSetWrap()
  9631.          ----------------
  9632.  
  9633.          With these functions, any text that will exceed the
  9634.          boundaries of the window will be wrapped to the next line.
  9635.          If the output will exceed the last row of the window, the
  9636.          window is automatically scrolled up by one line.  This is the
  9637.          default action to take when characters exceed the right edge
  9638.          of the virtual window.  If you want the output clipped
  9639.          instead of wrapped, you must set the virtual window's wrap
  9640.          flag using the VirtualSetWrap() function.
  9641.  
  9642.          The VirtualSetWrap() function sets the virtual window's wrap
  9643.          flag to either on or off.  Here is the prototype:
  9644.  
  9645.                int VirtualSetWrap(VWPOINTER vw, int option)
  9646.  
  9647.  
  9648.  
  9649.  
  9650.          The second argument will be 0 if you want to turn the wrap
  9651.          flag off, or 1 if you want to turn it on.  If the wrap flag
  9652.          is off, the output generated by
  9653.  
  9654.  
  9655.          VirtualPrintf() and VirtualPrintfAttr() will be terminated
  9656.          when the right edge of the window is reached.  If the wrap
  9657.          flag is on, the output is wrapped to the next line when the
  9658.          right edge is reached.  Unlike regular windows, the output is
  9659.          not scrolled if the last line of the virtual window is
  9660.          reached.
  9661.  
  9662.          You can set the wrap flag to a virtual window at any time.
  9663.  
  9664.  
  9665.  
  9666.  
  9667.  
  9668.  
  9669.  
  9670.          Page 148          The C Window Library               Page 148
  9671.  
  9672.          VirtualPrintf()
  9673.          ---------------
  9674.  
  9675.          The VirtualPrintf() function writes formatted output to the
  9676.          virtual window.  Here is the prototype:
  9677.  
  9678.            int VirtualPrintf(VWPOINTER vw, char *format [,arg1,...])
  9679.  
  9680.          The first argument is the virtual window.  The second
  9681.          argument is a format string.  The rest of the arguments are
  9682.          optional arguments that are written to the virtual window.
  9683.  
  9684.          Example:
  9685.  
  9686.          #include "cwlwin.h"
  9687.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9688.  
  9689.          WPOINTER w;
  9690.          VWPOINTER vw;
  9691.          int i = 3;
  9692.          double j = 5.6;
  9693.  
  9694.          main()
  9695.          {
  9696.            WindowInitializeSystem();
  9697.            WindowInitDesktop(0);
  9698.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  9699.                                 NORM,NORM,SINGLEBOX);
  9700.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  9701.            WindowDisplay(w,1,NOEFFECT);
  9702.            WindowAssignToVirtual(w,vw,0,0);
  9703.            VirtualPrintf(vw,"3+2 is equal to %d\n",3+2);
  9704.            GET_KEY();
  9705.            VirtualPrintf(vw,"i is equal to %d\nj is equal to %lf\n",
  9706.                          i,j);
  9707.          }
  9708.  
  9709.  
  9710.          The above example illustrates how VirtualPrintf() is used to
  9711.          print formatted strings to a virtual window.
  9712.  
  9713.          The return values for VirtualPrintf() are the same as
  9714.          VirtualWriteString().
  9715.  
  9716.  
  9717.          VirtualPrintfAttr()
  9718.          -------------------
  9719.  
  9720.          The VirtualPrintfAttr() function writes formatted output to
  9721.          the virtual window.  The difference between VirtualPrintf()
  9722.          and VirtualPrintfAttr() is that VirtualPrintfAttr() uses a
  9723.          video attribute specified as an argument.  Here is the
  9724.          prototype:
  9725.  
  9726.          int VirtualPrintfAttr(VWPOINTER vw, int attr,
  9727.                                char *format [,arg1,...])
  9728.  
  9729.  
  9730.          Page 149          The C Window Library               Page 149
  9731.  
  9732.          The first argument is the virtual window.  The second
  9733.          argument is the video attribute to use.  The third argument
  9734.          is the format string.  The rest of the arguments are optional
  9735.          arguments that are written to the virtual window.  If the
  9736.          virtual window is NOATTRIBUTE, only the string is written to
  9737.          the window.
  9738.  
  9739.          Example:
  9740.  
  9741.          #include "cwlwin.h"
  9742.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9743.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  9744.  
  9745.          WPOINTER w;
  9746.          VWPOINTER vw;
  9747.          int i = 3;
  9748.          double j = 5.6;
  9749.  
  9750.          main()
  9751.          {
  9752.            WindowInitializeSystem();
  9753.            WindowInitDesktop(0);
  9754.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  9755.                                 NORM,NORM,SINGLEBOX);
  9756.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  9757.            WindowDisplay(w,1,NOEFFECT);
  9758.            WindowAssignToVirtual(w,vw,0,0);
  9759.            VirtualPrintfAttr(vw,REVERSE,"3+2 is equal to %d\n",3+2);
  9760.            GET_KEY();
  9761.            VirtualPrintfAttr(vw,REVERSE,
  9762.                        "i is equal to %d\nj is equal to %lf\n",i,j);
  9763.          }
  9764.  
  9765.  
  9766.          The above example illustrates how VirtualPrintfAttr() is used
  9767.          to print formatted strings.
  9768.  
  9769.          The return values for VirtualPrintfAttr() are the same as
  9770.          VirtualWriteStringAttr().
  9771.  
  9772.  
  9773.  
  9774.  
  9775.  
  9776.  
  9777.  
  9778.  
  9779.  
  9780.  
  9781.  
  9782.  
  9783.  
  9784.  
  9785.  
  9786.  
  9787.  
  9788.  
  9789.  
  9790.          Page 150          The C Window Library               Page 150
  9791.  
  9792.            READING CHARACTERS AND ATTRIBUTES FROM VIRTUAL WINDOWS
  9793.            ------------------------------------------------------
  9794.  
  9795.  
  9796.          With The C Window Library, you can read the contents of a
  9797.          virtual window into a character buffer.  These functions
  9798.          provide the programmer with the contents of the virtual
  9799.          window at any time.  The functions to perform this are
  9800.          VirtualReadAttributes(), VirtualReadCharacters() and
  9801.          VirtualReadCharAndAttr().
  9802.  
  9803.  
  9804.  
  9805.          VirtualReadCharacters()
  9806.          -----------------------
  9807.  
  9808.          The VirtualReadCharacters() function reads the characters
  9809.          from a virtual window into a buffer.  Here is the prototype.
  9810.  
  9811.          int VirtualReadCharacters(VWPOINTER vw, char *buffer,
  9812.                                    unsigned row, unsigned col,
  9813.                                    unsigned length)
  9814.  
  9815.          The first argument is the virtual window.  The second
  9816.          argument is the buffer to store the characters in.  The third
  9817.          and fourth arguments are the (row,col) position in the
  9818.          virtual window to start reading from.  The last argument is
  9819.          the number of characters to read.
  9820.  
  9821.          You must make sure that buffer has enough room to hold all of
  9822.          the characters read in.
  9823.  
  9824.  
  9825.          Example:
  9826.  
  9827.          #include "cwlwin.h"
  9828.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9829.  
  9830.          VWPOINTER vw;
  9831.          char buf[14] = {0};      /* Null all elements of buf */
  9832.  
  9833.          main()
  9834.          {
  9835.            int i;
  9836.            WindowInitializeSystem();
  9837.            WindowInitDesktop(0);
  9838.            vw = VirtualInitialize(NOATTRIBUTE,10,80,NORM);
  9839.            VirtualWriteString(vw,"Hello World!!",0,0);
  9840.            VirtualReadCharacters(vw,buf,0,0,13);
  9841.          }
  9842.  
  9843.          The example above illustrates the use of
  9844.  
  9845.          VirtualReadCharacters(), which reads the virtual window's
  9846.          contents starting at (0,0).  This happens to be the string
  9847.          "Hello World!!".
  9848.  
  9849.  
  9850.          Page 151          The C Window Library               Page 151
  9851.  
  9852.          If the length exceeds the right edge of the virtual window,
  9853.          VirtualReadCharacters() will read up to the right edge of the
  9854.          virtual window.
  9855.  
  9856.              Return Values for VirtualReadCharacters():
  9857.  
  9858.              Return Value        Definition
  9859.          ┌────────────────┬────────────────────────┐
  9860.          │NO_ERROR        │ No error occured.      │
  9861.          ├────────────────┼────────────────────────┤
  9862.          │BAD_V_WINDOW    │ Virtual window does    │
  9863.          │                │ not exist.             │
  9864.          ├────────────────┼────────────────────────┤
  9865.          │V_WINDOW_BOUND  │ Row or Column is out   │
  9866.          │                │ of bounds.             │
  9867.          └────────────────┴────────────────────────┘
  9868.  
  9869.  
  9870.  
  9871.          VirtualReadAttributes()
  9872.          ----------------------
  9873.  
  9874.          The VirtualReadAttributes() function reads the attributes
  9875.          from a virtual window into a buffer.  Here is the prototype.
  9876.  
  9877.          int VirtualReadAttributes(VWPOINTER w, char *buffer,
  9878.                                    unsigned row, unsigned col,
  9879.                                    unsigned length)
  9880.  
  9881.          The first argument is the virtual window.  The second
  9882.          argument is the buffer to store the attributes in.  The third
  9883.          and fourth arguments are the (row,col) position in the
  9884.          virtual window to start reading from.  The last argument is
  9885.          the number of attributes to read.  If the virtual window is
  9886.          NOATTRIBUTE, nothing is read.
  9887.  
  9888.          You must make sure that buffer has enough room to hold all of
  9889.          the attributes read in.
  9890.  
  9891.  
  9892.          Example:
  9893.  
  9894.          #include "cwlwin.h"
  9895.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9896.  
  9897.          VWPOINTER vw;
  9898.          char buf[14] = {0};      /* Null all elements of buf */
  9899.  
  9900.          main()
  9901.          {
  9902.            int i;
  9903.            WindowInitializeSystem();
  9904.            WindowInitDesktop(0);
  9905.            vw = VirtualInitialize(ATTRIBUTE,10,80,NORM);
  9906.            VirtualReadAttributes(vw,buf,0,0,13); /* Read attributes */
  9907.          }
  9908.  
  9909.  
  9910.          Page 152          The C Window Library               Page 152
  9911.  
  9912.          The example above illustrates the use of
  9913.          VirtualReadAttributes(), which reads the virtual window's
  9914.          attribute contents starting at (0,0) of the virtual window.
  9915.  
  9916.  
  9917.          If the length exceeds the right edge of the virtual window,
  9918.          VirtualReadAttributes() will read up to the right edge of the
  9919.          virtual window.
  9920.  
  9921.  
  9922.  
  9923.                Return Values for VirtualReadAttributes():
  9924.  
  9925.              Return Value        Definition
  9926.          ┌────────────────┬────────────────────────┐
  9927.          │NO_ERROR        │ No error occured.      │
  9928.          ├────────────────┼────────────────────────┤
  9929.          │BAD_V_WINDOW    │ Virtual window does    │
  9930.          │                │ not exist.             │
  9931.          ├────────────────┼────────────────────────┤
  9932.          │V_WINDOW_BOUND  │ Row or Column is out   │
  9933.          │                │ of bounds.             │
  9934.          ├────────────────┼────────────────────────┤
  9935.          │NO_ATTRIB       │ The virtual window is  │
  9936.          │                │ NOATTRIBUTE.           │
  9937.          └────────────────┴────────────────────────┘
  9938.  
  9939.  
  9940.  
  9941.          VirtualReadCharAndAttr()
  9942.          ------------------------
  9943.  
  9944.          The VirtualReadCharAndAttr() function reads
  9945.          character/attribute pairs from a virtual window into a
  9946.          buffer.  Here is the prototype.
  9947.  
  9948.          int VirtualReadCharAndAttr(VWPOINTER w, char *buffer,
  9949.                                     unsigned row, unsigned col,
  9950.                                     unsigned length)
  9951.  
  9952.          The first argument is the virtual window.  The second
  9953.          argument is the buffer to store the character/attribute pairs
  9954.          in.  The third and fourth arguments are the (row,col)
  9955.          position in the virtual window to start reading from.  The
  9956.          last argument is the number of character/attribute pairs to
  9957.          read.  If the window is NOATTRIBUTE, nothing is read.
  9958.  
  9959.          You must make sure that buffer has enough room to hold all of
  9960.          the character/attribute pairs read in.
  9961.  
  9962.          Example:
  9963.  
  9964.          #include "cwlwin.h"
  9965.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  9966.  
  9967.          VWPOINTER vw;
  9968.          char buf[27] = {0};      /* Null all elements of buf */
  9969.  
  9970.          Page 153          The C Window Library               Page 153
  9971.  
  9972.          main()
  9973.          {
  9974.            int i;
  9975.            WindowInitializeSystem();
  9976.            WindowInitDesktop(0);
  9977.            vw = VirtualInitialize(ATTRIBUTE,10,80,NORM);
  9978.            VirtualWriteString(vw,"Hello World!!",0,0);
  9979.  
  9980.           VirtualReadCharAndAttr(vw,buf,0,0,13);
  9981.          }
  9982.  
  9983.  
  9984.          The example above illustrates the use of
  9985.          VirtualReadCharAndAttr(), which reads the virtual window's
  9986.          character/attribute contents starting at (0,0) of the virtual
  9987.          window.  This happens to be the characters/attributes of the
  9988.          string "Hello World!!".
  9989.  
  9990.          If the length exceeds the right edge of the virtual window,
  9991.          VirtualReadCharAndAttr() will read up to the right edge of
  9992.          the virtual window.
  9993.  
  9994.  
  9995.              Return Values for VirtualReadCharAndAttr():
  9996.  
  9997.              Return Value        Definition
  9998.          ┌────────────────┬────────────────────────┐
  9999.          │NO_ERROR        │ No error occured.      │
  10000.          ├────────────────┼────────────────────────┤
  10001.          │BAD_V_WINDOW    │ Virtual window does    │
  10002.          │                │ not exist.             │
  10003.          ├────────────────┼────────────────────────┤
  10004.          │V_WINDOW_BOUND  │ Row or Column is out   │
  10005.          │                │ of bounds.             │
  10006.          ├────────────────┼────────────────────────┤
  10007.          │NO_ATTRIB       │ The virtual window is  │
  10008.          │                │ NOATTRIBUTE.           │
  10009.          └────────────────┴────────────────────────┘
  10010.  
  10011.  
  10012.  
  10013.  
  10014.  
  10015.  
  10016.  
  10017.  
  10018.  
  10019.  
  10020.  
  10021.  
  10022.  
  10023.  
  10024.  
  10025.  
  10026.  
  10027.  
  10028.  
  10029.  
  10030.          Page 154          The C Window Library               Page 154
  10031.  
  10032.                      REPOSITIONING THE VIEWPORT
  10033.                      --------------------------
  10034.  
  10035.          A viewport can be repositioned anywhere on the virtual
  10036.          window.  This allows to view different parts of the virtual
  10037.          window.
  10038.  
  10039.  
  10040.  
  10041.          WindowPositionViewport()
  10042.          ------------------------
  10043.  
  10044.          The WindowPositionViewport() function positions the viewport
  10045.          to a new location on the virtual window it is associated
  10046.          with.  Here is the prototype:
  10047.  
  10048.  
  10049.          int WindowPositionViewport(WPOINTER w, unsigned row,
  10050.                                     unsigned col)
  10051.  
  10052.          The first argument is the viewport window.  The second
  10053.          argument and third arguments are is the (row,col) position of
  10054.          the virtual window associated with w.  This position will be
  10055.          where the upper left hand corner of the viewport's text area
  10056.          will be placed.
  10057.  
  10058.  
  10059.          Example:
  10060.  
  10061.          #include <stdio.h>
  10062.          #include <string.h>
  10063.          #include "cwlwin.h"
  10064.  
  10065.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  10066.  
  10067.          #define FILENAMECHARS  \
  10068.                         "25[A-Za-z0-9!@#$%/^&()+=_/-{}/[/]`~/.\\:]"
  10069.  
  10070.          VWPOINTER vw;          /* virtual window pointer */
  10071.          WPOINTER w;            /* Window pointer */
  10072.          char filename[26];
  10073.          FILE *infile;          /* input file handle */
  10074.  
  10075.          main()
  10076.          {
  10077.            unsigned int i,j,row,col;
  10078.            WindowInitializeSystem();
  10079.            WindowInitDesktop(0);
  10080.  
  10081.            /* set up a Type 0 virtual window */
  10082.            vw = VirtualInitialize(NOATTRIBUTE,200,80,0);
  10083.  
  10084.            /* set up viewport window */
  10085.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,
  10086.                                 12,NORM,NORM,SINGLEBOX);
  10087.            WindowDisplay(w,1,NOEFFECT);
  10088.  
  10089.  
  10090.          Page 155          The C Window Library               Page 155
  10091.  
  10092.            /* read a file name */
  10093.            read_file();
  10094.  
  10095.            /* display file in viewport */
  10096.            WindowAssignToVirtual(w,vw,0,0);
  10097.  
  10098.  
  10099.            row = col = 1;
  10100.            CWLflush_kbd = TRUE; /* Set keyboard flush to TRUE */
  10101.            while (1)
  10102.            {
  10103.              switch (GET_KEY())    /* Keep getting keys until
  10104.                                       ESCAPE key is hit */
  10105.  
  10106.              {
  10107.                 case UARROW:      /* Move viewport up 1 line */
  10108.  
  10109.                   if (row > 0)
  10110.                     WindowPositionViewport(w,--row,col);
  10111.                 break;
  10112.                 case DARROW:      /* Move viewport down 1 line */
  10113.                   if (row < 188)
  10114.                     WindowPositionViewport(w,++row,col);
  10115.                 break;
  10116.                 case LARROW:      /* Move viewport left 1 line */
  10117.                   if (col > 0)
  10118.                     WindowPositionViewport(w,row,--col);
  10119.                 break;
  10120.                 case RARROW:      /* Move viewport right 1 line */
  10121.                   if (col < 68)
  10122.                     WindowPositionViewport(w,row,++col);
  10123.                 break;
  10124.                 case ESC:         /* End program */
  10125.                   close_all();
  10126.                 break;
  10127.              }
  10128.            }
  10129.          }
  10130.  
  10131.          read_file()         /* Gets a filename and displays
  10132.                                 it in the window */
  10133.          {
  10134.             int ch;
  10135.             unsigned r = 0, c = 0;
  10136.             filename[0] = 0;
  10137.             WindowWriteString(w,"Please enter a file name: ",0,0);
  10138.             WindowGetString(w,0,26,filename,'_',0,40,0,0,FILENAMECHARS);
  10139.             if ((infile = fopen(filename,"r")) == NULL)
  10140.             {
  10141.               WindowMoveCursor(w,2,0);
  10142.               WindowPrintf(w,"File name %s does not exist\n"
  10143.                              "Press a key to continue", filename);
  10144.               GET_KEY();
  10145.               close_all();
  10146.             }
  10147.             else
  10148.  
  10149.  
  10150.          Page 156          The C Window Library               Page 156
  10151.  
  10152.             while(1)         /* Read characters into virtual window */
  10153.             {
  10154.               ch = fgetc(infile);
  10155.               if (feof(infile))
  10156.  
  10157.                break;
  10158.               if (ch != '\n')
  10159.                 VirtualWriteRepeatCharacter(vw,ch,r,c++,1);
  10160.               else
  10161.               {
  10162.  
  10163.                 r++;
  10164.                 c=0;
  10165.  
  10166.               }
  10167.             }
  10168.             fclose(infile);
  10169.          }
  10170.  
  10171.  
  10172.  
  10173.          close_all()
  10174.          {
  10175.            WindowClose(w,NOEFFECT);
  10176.            exit(0);
  10177.          }
  10178.  
  10179.  
  10180.          The above example reads in a text file and uses
  10181.          WindowPositionViewport() to move left, right, up, or down.
  10182.          There is no checking to see if you have scrolled past the end
  10183.          of the file.
  10184.  
  10185.          The read_file() function reads a file and copies each
  10186.          character in the file to the virtual window called vw.
  10187.  
  10188.          In the main program, the global variable CWLflush_kbd,
  10189.          defined in the IMPORTANT GLOBAL VARIABLES section, is set to
  10190.          TRUE.  When flush_keyboard is TRUE, the keyboard buffer is
  10191.          flushed before any incoming keystrokes are accepted.
  10192.          Otherwise the keyboard buffer is not flushed.
  10193.  
  10194.          In the while(1) loop of the main program, the constants
  10195.          UARROW, DARROW, LARROW, and RARROW, stands for the up, down,
  10196.          left, and the right arrow keys on the keypad, respectively.
  10197.          The constants UARROW, DARROW, LARROW, and RARROW are defined
  10198.          in cwlwin.h.  Depending on the key that is hit, the
  10199.          viewport is repositioned to point to a new row or column.
  10200.          The call to WindowPositionViewport() has three arguments.
  10201.          The first is the pointer to the viewport window, the second
  10202.          and the third are the row and the column of the virtual
  10203.          window to place the upper left hand corner of the viewport.
  10204.  
  10205.          There is minimal bounds checking in the above example,
  10206.          however you can enhance it by putting in more bounds checking
  10207.          and by implementing a page down, or page up function.
  10208.  
  10209.  
  10210.          Page 157          The C Window Library               Page 157
  10211.  
  10212.              Return Values for WindowPositionViewport():
  10213.  
  10214.              Return Value        Definition
  10215.          ┌────────────────┬────────────────────────┐
  10216.          │NO_ERROR        │ No error occured.      │
  10217.          ├────────────────┼────────────────────────┤
  10218.          │BAD_WINDOW      │ Window does not exist. │
  10219.          ├────────────────┼────────────────────────┤
  10220.          │BAD_V_WINDOW    │ Virtual window does    │
  10221.          │                │ not exist.             │
  10222.          ├────────────────┼────────────────────────┤
  10223.          │V_WINDOW_BOUND  │ Row or Column is out   │
  10224.          │                │ of bounds.             │
  10225.          └────────────────┴────────────────────────┘
  10226.  
  10227.  
  10228.  
  10229.  
  10230.  
  10231.  
  10232.  
  10233.  
  10234.  
  10235.  
  10236.  
  10237.  
  10238.  
  10239.  
  10240.  
  10241.  
  10242.  
  10243.  
  10244.  
  10245.  
  10246.  
  10247.  
  10248.  
  10249.  
  10250.  
  10251.  
  10252.  
  10253.  
  10254.  
  10255.  
  10256.  
  10257.  
  10258.  
  10259.  
  10260.  
  10261.  
  10262.  
  10263.  
  10264.  
  10265.  
  10266.  
  10267.  
  10268.  
  10269.  
  10270.          Page 158          The C Window Library               Page 158
  10271.  
  10272.                        SCROLLING THE VIEWPORTS
  10273.                        -----------------------
  10274.  
  10275.  
  10276.          Viewports can have its display scrolled left, right, up, or
  10277.          down using the WindowScrollViewport() function described
  10278.          below.
  10279.  
  10280.  
  10281.          WindowScrollViewport()
  10282.          ---------------------
  10283.  
  10284.          This functions scrolls the viewport specific number of
  10285.          characters.  Here is the prototype:
  10286.  
  10287.          int WindowScrollViewport(WPOINTER w, unsigned num,
  10288.                                   int direction)
  10289.  
  10290.          The first argument is the viewport and the second argument is
  10291.          the number of characters to scroll.  The last argument is the
  10292.          direction to scroll.  This direction can be UP, DOWN, LEFT,
  10293.          or RIGHT.
  10294.  
  10295.  
  10296.          Example:
  10297.  
  10298.  
  10299.          #include <stdio.h>
  10300.          #include <string.h>
  10301.          #include "cwlwin.h"
  10302.  
  10303.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  10304.  
  10305.          #define FILENAMECHARS  \
  10306.                     "25[A-Za-z0-9!@#$%/^&()+=_/-{}/[/]`~/.\\:]"
  10307.  
  10308.          VWPOINTER vw;          /* virtual window pointer */
  10309.          WPOINTER w;            /* Window pointer */
  10310.          char filename[26];
  10311.          FILE *infile;          /* input file handle */
  10312.  
  10313.          main()
  10314.          {
  10315.            unsigned int i,j,row,col;
  10316.            WindowInitializeSystem();
  10317.            WindowInitDesktop(0);
  10318.            /* set up a Type 0 virtual window */
  10319.            vw = VirtualInitialize(NOATTRIBUTE,200,80,0);
  10320.  
  10321.            /* set up viewport window */
  10322.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,12,
  10323.                                 NORM,NORM,SINGLEBOX);
  10324.            WindowDisplay(w,1,NOEFFECT);
  10325.            /* read a file name */
  10326.            read_file();
  10327.  
  10328.  
  10329.  
  10330.          Page 159          The C Window Library               Page 159
  10331.  
  10332.            /* display file in viewport */
  10333.  
  10334.            WindowAssignToVirtual(w,vw,0,0);
  10335.            CWLflush_kbd = TRUE;
  10336.            while (1)
  10337.            {
  10338.              switch (GET_KEY())  {  /* Keep getting keys until
  10339.                                       ESCAPE key is hit */
  10340.                 case UARROW:      /* Move viewport up 1 line */
  10341.                   WindowScrollViewport(w,1,UP);
  10342.                 break;
  10343.                 case DARROW:      /* Move viewport down 1 line */
  10344.                   WindowScrollViewport(w,1,DOWN);
  10345.                 break;
  10346.                 case LARROW:      /* Move viewport left 1 line */
  10347.                   WindowScrollViewport(w,1,LEFT);
  10348.                 break;
  10349.                 case RARROW:      /* Move viewport right 1 line */
  10350.                   WindowScrollViewport(w,1,RIGHT);
  10351.                 break;
  10352.                 case ESC:         /* End program */
  10353.                   close_all();
  10354.                 break;
  10355.              }
  10356.            }
  10357.          }
  10358.  
  10359.          read_file()  {       /* Gets a filename and
  10360.                                 displays it in the window */
  10361.             int ch;
  10362.             unsigned r = 0, c = 0;
  10363.             filename[0]=0;
  10364.             WindowWriteString(w,"Please enter a file name: ",0,0);
  10365.             WindowGetString(w,0,26,filename,'_',0,40,0,0,FILENAMECHARS);
  10366.             if ((infile = fopen(filename,"r")) == NULL)
  10367.             {
  10368.               WindowMoveCursor(w,2,0);
  10369.               WindowPrintf(w,"File name %s does not exist\n"
  10370.                              "Press a key to continue", filename);
  10371.               GET_KEY();
  10372.               close_all();
  10373.             }
  10374.             else
  10375.             while(1)   {      /* Read characters into virtual window */
  10376.               ch = fgetc(infile);
  10377.               if (feof(infile))
  10378.                 break;
  10379.               if (ch != '\n')
  10380.                 VirtualWriteRepeatCharacter(vw,ch,r,c++,1);
  10381.               else
  10382.  
  10383.                 r++;
  10384.                 c = 0;
  10385.              }
  10386.            }
  10387.             fclose(infile);
  10388.          }
  10389.  
  10390.          Page 160          The C Window Library               Page 160
  10391.  
  10392.          close_all()
  10393.          {
  10394.            WindowClose(w,NOEFFECT);
  10395.            WindowUninitializeSystem();
  10396.            exit(0);
  10397.          }
  10398.  
  10399.  
  10400.          The example above is the same as the example for the
  10401.          WindowPositionViewport() function, except that the call to
  10402.          WindowPositionViewport() is replaced with the appropriate
  10403.          WindowScrollViewport() call.
  10404.  
  10405.  
  10406.          For WindowScrollViewport(), the window is never scrolled if
  10407.          the scroll will result in the upper left hand corner of the
  10408.          viewport being out of bounds of the virtual window.  For
  10409.          example, you cannot scroll left 1 character if the viewport
  10410.          is located at (0,0) of the virtual window, similarly you
  10411.          cannot scroll right if the virtual window has a maximum of 80
  10412.          characters and the upper left hand corner of the viewport is
  10413.          situated at (0,79).  The same restrictions apply for
  10414.          scrolling up and down.
  10415.  
  10416.               Return Values for WindowScrollViewport():
  10417.  
  10418.              Return Value        Definition
  10419.          ┌────────────────┬────────────────────────┐
  10420.          │NO_ERROR        │ No error occured.      │
  10421.          ├────────────────┼────────────────────────┤
  10422.          │BAD_WINDOW      │ Window does not exist. │
  10423.          ├────────────────┼────────────────────────┤
  10424.          │BAD_V_WINDOW    │ Virtual window does    │
  10425.          │                │ not exist.             │
  10426.          └────────────────┴────────────────────────┘
  10427.  
  10428.  
  10429.  
  10430.  
  10431.  
  10432.  
  10433.  
  10434.  
  10435.  
  10436.  
  10437.  
  10438.  
  10439.  
  10440.  
  10441.  
  10442.  
  10443.  
  10444.  
  10445.  
  10446.  
  10447.  
  10448.  
  10449.  
  10450.          Page 161          The C Window Library               Page 161
  10451.  
  10452.               WRITING VIRTUAL WINDOW CONTENTS TO A FILE
  10453.               -----------------------------------------
  10454.  
  10455.          The C Window Library allows you to print the contents of a
  10456.          virtual window using the VirtualWriteTextToFile() function.
  10457.  
  10458.  
  10459.          VirtualWriteTextToFile()
  10460.          ------------------------
  10461.  
  10462.          The VirtualWriteTextToFile() function allows you to print the
  10463.          contents of a virtual window to a file.  Here is the
  10464.          prototype:
  10465.  
  10466.          int VirtualWriteTextToFile(VWPOINTER vw, char *filename,
  10467.                                     int mode)
  10468.  
  10469.  
  10470.          The first argument is the virtual window.  The second
  10471.          argument is the file name.  This file can be any of the DOS
  10472.          filenames ("con", "prn", "aux", etc.).  The file specified by
  10473.          filename must be closed before calling
  10474.          VirtualWriteTextToFile(), and the file handle is
  10475.          automatically closed before exiting VirtualWriteTextToFile().
  10476.  
  10477.          The last argument is the mode switch.  If mode is 1, a
  10478.          newline ('\n') is written to the file after each line of the
  10479.          virtual window written to the file.  If mode is 0, no newline
  10480.          character is written.  When mode 0 is chosen, the file is
  10481.          open in binary mode, else it is open in text mode.
  10482.  
  10483.          Example:
  10484.  
  10485.          #include "cwlwin.h"
  10486.  
  10487.          VWPOINTER vw;
  10488.          char *filename = "wintext";
  10489.          char *filename2 = "wintext2";
  10490.  
  10491.          main()
  10492.          {
  10493.            int i;
  10494.            WindowInitializeSystem();
  10495.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  10496.            for (i=0;i<10;i++)
  10497.              VirtualWriteString(vw,"Hello World!!",i,0);
  10498.            VirtualWriteTextToFile(vw,filename,1);  /* use newlines */
  10499.            VirtualWriteTextToFile(vw,filename2,0); /* no newlines */
  10500.          }
  10501.  
  10502.          The example above illustrates two calls to
  10503.          VirtualWriteTextToFile().  The first call writes the contents
  10504.          of the virtual window vw to a file called "wintext".  Note
  10505.          that the mode parameter for the first call is 1.  This will
  10506.          cause '\n' to be written to the file for each line of the
  10507.  
  10508.  
  10509.  
  10510.          Page 162          The C Window Library               Page 162
  10511.  
  10512.          virtual window.  The second call writes the virtual window
  10513.          text to a file call "wintest2", with the mode parameter being
  10514.          0 (no '\n').
  10515.  
  10516.          Please note that VirtualWriteTextToFile() does not check if
  10517.          the file already exists, so be careful that you do not
  10518.          replace files that are important to you.
  10519.  
  10520.          If there are no errors, VirtualWriteTextToFile() returns
  10521.          NO_ERROR.
  10522.  
  10523.          If there are errors, VirtualWriteTextToFile() will return one
  10524.          of the following:
  10525.  
  10526.  
  10527.              Return Values for VirtualWriteTextToFile():
  10528.  
  10529.              Return Value        Definition
  10530.          ┌────────────────┬────────────────────────┐
  10531.          │NO_ERROR        │ No error occured.      │
  10532.          ├────────────────┼────────────────────────┤
  10533.          │BAD_V_WINDOW    │ Virtual window does    │
  10534.          │                │ not exist.             │
  10535.          ├────────────────┼────────────────────────┤
  10536.          │FILE_CANT_OPEN  │ File cannot be opened. │
  10537.          ├────────────────┼────────────────────────┤
  10538.          │FILE_CANT_CLOSE │ File cannot be closed. │
  10539.          └────────────────┴────────────────────────┘
  10540.  
  10541.  
  10542.  
  10543.  
  10544.  
  10545.  
  10546.  
  10547.  
  10548.  
  10549.  
  10550.  
  10551.  
  10552.  
  10553.  
  10554.  
  10555.  
  10556.  
  10557.  
  10558.  
  10559.  
  10560.  
  10561.  
  10562.  
  10563.  
  10564.  
  10565.  
  10566.  
  10567.  
  10568.  
  10569.  
  10570.          Page 163          The C Window Library               Page 163
  10571.  
  10572.                       MOVING THE LOGICAL CURSOR
  10573.                       -------------------------
  10574.  
  10575.          You can move and get the position of the logical cursor in a
  10576.          virtual window.
  10577.  
  10578.  
  10579.  
  10580.          VirtualMoveCursor()
  10581.          -------------------
  10582.  
  10583.          The VirtualMoveCursor() function moves a virtual window's
  10584.          logical cursor to a new location.  Here is the prototype:
  10585.  
  10586.          int VirtualMoveCursor(VWPOINTER vw, unsigned row,
  10587.                                unsigned col)
  10588.  
  10589.          The first argument is the virtual window, and the second and
  10590.          third arguments denote the new (row,col) position of the
  10591.          logical cursor.
  10592.  
  10593.          Example:
  10594.  
  10595.          #include "cwlwin.h"
  10596.  
  10597.  
  10598.          VWPOINTER vw;
  10599.  
  10600.          main()
  10601.          {
  10602.            int i;
  10603.            WindowInitializeSystem();
  10604.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  10605.            VirtualMoveCursor(vw,10,10)   /* Moves the logical cursor
  10606.                                             to row 10, column 10 of
  10607.                                             the virtual window */
  10608.          }
  10609.  
  10610.  
  10611.                Return Values for VirtualMoveCursor():
  10612.  
  10613.              Return Value        Definition
  10614.          ┌────────────────┬────────────────────────┐
  10615.          │NO_ERROR        │ No error occured.      │
  10616.          ├────────────────┼────────────────────────┤
  10617.          │BAD_V_WINDOW    │ Virtual window does    │
  10618.          │                │ not exist.             │
  10619.          ├────────────────┼────────────────────────┤
  10620.          │V_WINDOW_BOUND  │ Row or Column is out   │
  10621.          │                │ of bounds.             │
  10622.          └────────────────┴────────────────────────┘
  10623.  
  10624.  
  10625.  
  10626.  
  10627.  
  10628.  
  10629.  
  10630.          Page 164          The C Window Library               Page 164
  10631.  
  10632.          VirtualGetCursorPosition()
  10633.          --------------------------
  10634.  
  10635.  
  10636.          The VirtualGetCursorPosition() function gives the current row
  10637.          and column of the cursor in a virtual window.  Here is the
  10638.          prototype:
  10639.  
  10640.          int VirtualGetCursorPosition(VWPOINTER vw, unsigned *row,
  10641.                                       unsigned *col)
  10642.  
  10643.          The row and col arguments are pointers to unsigned integers
  10644.          that will contain the row and column of the cursor after
  10645.          VirtualGetCursorPosition() is called.
  10646.  
  10647.          Example:
  10648.  
  10649.          #include "cwlwin.h"
  10650.  
  10651.          VWPOINTER vw;
  10652.  
  10653.          main()
  10654.          {
  10655.            unsigned row,col;
  10656.            WindowInitializeSystem();
  10657.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  10658.            VirtualMoveCursor(vw,7,4);
  10659.            VirtualGetCursorPosition(vw,&row,&col);
  10660.          }
  10661.  
  10662.             Return Values for VirtualGetCursorPosition():
  10663.  
  10664.              Return Value        Definition
  10665.          ┌────────────────┬────────────────────────┐
  10666.          │NO_ERROR        │ No error occured.      │
  10667.          ├────────────────┼────────────────────────┤
  10668.          │BAD_V_WINDOW    │ Virtual window does    │
  10669.          │                │ not exist.             │
  10670.          └────────────────┴────────────────────────┘
  10671.  
  10672.  
  10673.  
  10674.  
  10675.  
  10676.  
  10677.  
  10678.  
  10679.  
  10680.  
  10681.  
  10682.  
  10683.  
  10684.  
  10685.  
  10686.  
  10687.  
  10688.  
  10689.  
  10690.          Page 165          The C Window Library               Page 165
  10691.  
  10692.                       CLEARING VIRTUAL WINDOWS
  10693.                       ------------------------
  10694.  
  10695.  
  10696.          The C Window Library contains functions that clears the
  10697.          entire virtual window, or clears defined rectangular regions
  10698.          of the virtual window.
  10699.  
  10700.  
  10701.          VirtualClear()
  10702.          --------------
  10703.  
  10704.          The VirtualClear() function clears an entire virtual window
  10705.          to spaces.  Here is the prototype:
  10706.  
  10707.                    int VirtualClear(VWPOINTER vw)
  10708.  
  10709.          The only argument is the virtual window to clear.
  10710.  
  10711.          Example:
  10712.  
  10713.          #include "cwlwin.h"
  10714.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  10715.  
  10716.          VWPOINTER vw;
  10717.          WPOINTER w;
  10718.  
  10719.          main()
  10720.          {
  10721.            int i;
  10722.            WindowInitializeSystem();
  10723.            WindowInitDesktop(0);
  10724.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,
  10725.                                 20,10,NORM,NORM,SINGLEBOX);
  10726.            vw = VirtualInitialize(NOATTRIBUTE,30,80,NORM);
  10727.            WindowDisplay(w,1,NOEFFECT);
  10728.            WindowAssignToVirtual(w,vw,0,0);
  10729.            for (i=0;i<10;i++)
  10730.              VirtualWriteString(vw,"Hello World!!",i,0);
  10731.            GET_KEY();
  10732.            VirtualClear(vw);
  10733.          }
  10734.  
  10735.                   Return Values for VirtualClear():
  10736.  
  10737.              Return Value        Definition
  10738.  
  10739.          ┌────────────────┬────────────────────────┐
  10740.          │NO_ERROR        │ No error occured.      │
  10741.          ├────────────────┼────────────────────────┤
  10742.          │BAD_V_WINDOW    │ Virtual window does    │
  10743.          │                │ not exist.             │
  10744.          └────────────────┴────────────────────────┘
  10745.  
  10746.  
  10747.  
  10748.  
  10749.  
  10750.          Page 166          The C Window Library               Page 166
  10751.  
  10752.          VirtualClearAttr()
  10753.          ------------------
  10754.  
  10755.          The VirtualClearAttr() function works the same way as the
  10756.          VirtualClear() function except that an attribute is
  10757.          specified.  Here is the prototype:
  10758.  
  10759.                 int VirtualClearAttr(VWPOINTER vw, int attr)
  10760.  
  10761.          The second argument is the video attribute to use.  If the
  10762.          virtual window is NOATTRIBUTE, this function only clears the
  10763.          text.
  10764.  
  10765.          Example:
  10766.  
  10767.          #include "cwlwin.h"
  10768.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  10769.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  10770.          WPOINTER w;
  10771.          VWPOINTER vw;
  10772.  
  10773.          main()
  10774.          {
  10775.            int i;
  10776.            WindowInitializeSystem();
  10777.            WindowInitDesktop(0);
  10778.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  10779.                                 NORM,NORM,SINGLEBOX);
  10780.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  10781.            WindowDisplay(w,1,NOEFFECT);
  10782.            WindowAssignToVirtual(w,vw,0,0);
  10783.            for (i=0;i<10;i++)
  10784.              VirtualWriteString(vw,"Hello World!!",i,0);
  10785.            GET_KEY();
  10786.            VirtualClearAttr(vw,REVERSE);
  10787.          }
  10788.  
  10789.                 Return Values for VirtualClearAttr():
  10790.  
  10791.              Return Value        Definition
  10792.          ┌────────────────┬────────────────────────┐
  10793.          │NO_ERROR        │ No error occured.      │
  10794.          ├────────────────┼────────────────────────┤
  10795.          │BAD_V_WINDOW    │ Virtual window does    │
  10796.          │                │ not exist.             │
  10797.          ├────────────────┼────────────────────────┤
  10798.          │NO_ATTRIB       │ The virtual window is  │
  10799.          │                │ NOATTRIBUTE.           │
  10800.          └────────────────┴────────────────────────┘
  10801.  
  10802.  
  10803.  
  10804.  
  10805.  
  10806.  
  10807.  
  10808.  
  10809.  
  10810.          Page 167          The C Window Library               Page 167
  10811.  
  10812.          VirtualClearRegion()
  10813.          -------------------
  10814.  
  10815.          The VirtualClearRegion() function clears a region of a
  10816.          virtual window.  To use the VirtualClearRegion() function,
  10817.          you must describe the rectangular region to clear.  Here is
  10818.          the prototype:
  10819.  
  10820.          int VirtualClearRegion(VWPOINTER vw, unsigned urow,
  10821.                                 unsigned ucol, unsigned lrow,
  10822.                                 unsigned lcol)
  10823.  
  10824.          where (urow,ucol) describes the upper left of the rectangle
  10825.          and (lrow,lcol) is the lower right of the virtual window.
  10826.  
  10827.          Example:
  10828.  
  10829.          #include "cwlwin.h"
  10830.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  10831.          WPOINTER w;
  10832.          VWPOINTER vw;
  10833.  
  10834.          main()
  10835.          {
  10836.            int i;
  10837.            WindowInitializeSystem();
  10838.            WindowInitDesktop(0);
  10839.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  10840.                                 NORM,NORM,SINGLEBOX);
  10841.            vw = VirtualInitialize(NOATTRIBUTE,30,80,NORM);
  10842.            WindowDisplay(w,1,NOEFFECT);
  10843.            WindowAssignToVirtual(w,vw,0,0);
  10844.            for (i=0;i<10;i++)
  10845.              VirtualWriteString(vw,"Hello World!!",i,0);
  10846.            GET_KEY();
  10847.            VirtualClearRegion(vw,4,4,8,15);
  10848.          }
  10849.  
  10850.          The VirtualClearRegion() call will clear the region described
  10851.          by the rectangular coordinates (4,4) and (8,15).
  10852.  
  10853.                Return Values for VirtualClearRegion():
  10854.  
  10855.              Return Value        Definition
  10856.          ┌────────────────┬─────────────────────────┐
  10857.          │NO_ERROR        │ No error occured.       │
  10858.          ├────────────────┼─────────────────────────┤
  10859.          │BAD_V_WINDOW    │ Virtual window does     │
  10860.          │                │ not exist.              │
  10861.          ├────────────────┼─────────────────────────┤
  10862.          │V_WINDOW_BOUND  │ Invalid region specified│
  10863.          └────────────────┴─────────────────────────┘
  10864.  
  10865.  
  10866.  
  10867.  
  10868.  
  10869.  
  10870.          Page 168          The C Window Library               Page 168
  10871.  
  10872.          VirtualClearRegionAttr()
  10873.          ------------------------
  10874.  
  10875.          The VirtualClearRegionAttr() function works the same as the
  10876.          VirtualClearRegion() function, except that a video attribute
  10877.          is specified.  Here is the prototype:
  10878.  
  10879.          int VirtualClearRegionAttr(VWPOINTER vw, unsigned urow,
  10880.                                     unsigned ucol, unsigned lrow,
  10881.                                     unsigned lcol, int attr)
  10882.  
  10883.          The attr argument is a video attribute to use to clear the
  10884.          region.  If the virtual window is NOATTRIBUTE, the attribute
  10885.          argument is ignored.
  10886.  
  10887.          Example:
  10888.  
  10889.          #include "cwlwin.h"
  10890.          #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  10891.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  10892.          WPOINTER w;
  10893.          VWPOINTER vw;
  10894.  
  10895.          main()
  10896.          {
  10897.            int i;
  10898.            WindowInitializeSystem();
  10899.            WindowInitDesktop(0);
  10900.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  10901.                                 NORM,NORM,SINGLEBOX);
  10902.            vw = VirtualInitialize(ATTRIBUTE,30,80,NORM);
  10903.            WindowDisplay(w,1,NOEFFECT);
  10904.            WindowAssignToVirtual(w,vw,0,0);
  10905.            for (i=0;i<10;i++)
  10906.              VirtualWriteString(vw,"Hello World!!",i,0);
  10907.            GET_KEY();
  10908.            VirtualClearRegionAttr(vw,4,4,8,15,REVERSE);
  10909.          }
  10910.  
  10911.          The VirtualClearRegionAttr() call will clear the region
  10912.          described by the rectangular coordinates (4,4) and (8,15)
  10913.          using the video attribute defined by the constant REVERSE.
  10914.  
  10915.              Return Values for VirtualClearRegionAttr():
  10916.  
  10917.              Return Value        Definition
  10918.          ┌────────────────┬─────────────────────────┐
  10919.          │NO_ERROR        │ No error occured.       │
  10920.          ├────────────────┼─────────────────────────┤
  10921.          │BAD_V_WINDOW    │ Virtual window does     │
  10922.          │                │ not exist.              │
  10923.          ├────────────────┼─────────────────────────┤
  10924.          │NO_ATTRIB       │ The virtual window is   │
  10925.          │                │ NOATTRIBUTE.            │
  10926.          ├────────────────┼─────────────────────────┤
  10927.          │V_WINDOW_BOUND  │ Invalid region specified│
  10928.          └────────────────┴─────────────────────────┘
  10929.  
  10930.          Page 169          The C Window Library               Page 169
  10931.  
  10932.                          FREEZING VIEWPORTS
  10933.                          ------------------
  10934.  
  10935.  
  10936.          You can temporarily suspend or 'freeze' a viewport window
  10937.          from displaying updates to the virtual window.  This is good
  10938.          if there is data being written to the virtual window which
  10939.          takes a long time to generate.  The viewport can be frozen
  10940.          when the information is being written, and unfrozen when the
  10941.          writing of the data is terminated.
  10942.  
  10943.  
  10944.          WindowFreeze()
  10945.          --------------
  10946.  
  10947.          The WindowFreeze() function suspends or resumes displaying of
  10948.          virtual window updates on a viewport window.  Here is the
  10949.          prototype:
  10950.  
  10951.               int WindowFreeze(WPOINTER w, int option)
  10952.  
  10953.          The first argument is the viewport window, and the second
  10954.          argument is the option flag.  If this flag is 0, the window
  10955.          is unfrozen, i.e. the window will display virtual window
  10956.          updates.  If it is 1, the window will suspend virtual window
  10957.          updates from being displayed.
  10958.  
  10959.          Example:
  10960.  
  10961.          #include "cwlwin.h"
  10962.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  10963.  
  10964.          VWPOINTER vw;
  10965.          WPOINTER w;
  10966.  
  10967.          main()
  10968.          {
  10969.            int i;
  10970.            WindowInitializeSystem();
  10971.  
  10972.            WindowInitDesktop(0);
  10973.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  10974.                                 NORM,NORM,SINGLEBOX);
  10975.            vw = VirtualInitialize(NOATTRIBUTE,10,80,NORM);
  10976.            WindowAssignToVirtual(w,vw,0,0);
  10977.            WindowDisplay(w,1,NOEFFECT);
  10978.            /* Freeze Viewport */
  10979.            WindowFreeze(w,1);
  10980.  
  10981.            for (i=0;i<10;i++)
  10982.            {
  10983.              delay(1000);
  10984.              VirtualPrintf(vw,"Line %d\n",i);
  10985.            }
  10986.  
  10987.            /* Unfreeze window */
  10988.            WindowFreeze(w,0);
  10989.  
  10990.          Page 170          The C Window Library               Page 170
  10991.  
  10992.            GET_KEY();
  10993.  
  10994.            /* Now try with window always displaying data */
  10995.            VirtualClear(vw);
  10996.            for (i=0;i<10;i++)
  10997.            {
  10998.              delay(1000);
  10999.              VirtualPrintf(vw,"Line %d\n",i);
  11000.            }
  11001.          }
  11002.  
  11003.  
  11004.          The above program first freezes the viewport w with the first
  11005.          call to WindowFreeze().  Then text is written slowly to the
  11006.          virtual window vw.  This text is not displayed until the
  11007.          window is unfrozen again with the second call to
  11008.          WindowFreeze().  Everything is reset and the writing of the
  11009.          text to the virtual window is done again, but this time the
  11010.          viewport is always displaying virtual window updates, even
  11011.          when the text is being written to the virtual window.
  11012.  
  11013.          The delay() function is discussed in the TIMED DELAYS
  11014.          section.
  11015.  
  11016.  
  11017.                 Return Values for WindowFreeze():
  11018.  
  11019.              Return Value        Definition
  11020.          ┌────────────────┬─────────────────────────┐
  11021.          │NO_ERROR        │ No error occured.       │
  11022.          ├────────────────┼─────────────────────────┤
  11023.          │BAD_WINDOW      │ The viewport window does│
  11024.          │                │ not exist.              │
  11025.          ├────────────────┼─────────────────────────┤
  11026.          │BAD_V_WINDOW    │ Virtual window does     │
  11027.          │                │ not exist.              │
  11028.          ├────────────────┼─────────────────────────┤
  11029.          │NO_ATTRIB       │ The virtual window is   │
  11030.          │                │ NOATTRIBUTE.            │
  11031.          └────────────────┴─────────────────────────┘
  11032.  
  11033.  
  11034.  
  11035.  
  11036.  
  11037.  
  11038.  
  11039.  
  11040.  
  11041.  
  11042.  
  11043.  
  11044.  
  11045.  
  11046.  
  11047.  
  11048.  
  11049.  
  11050.          Page 171          The C Window Library               Page 171
  11051.  
  11052.                     DISPOSING OF VIRTUAL WINDOWS
  11053.                     ----------------------------
  11054.  
  11055.  
  11056.          The last step is to dispose of the virtual window.  The
  11057.          function to do this is the VirtualClose() function.
  11058.  
  11059.  
  11060.          VirtualClose()
  11061.          -------------
  11062.  
  11063.          The VirtualClose() function frees all the memory allocated to
  11064.          the virtual window and destroys the virtual window pointer.
  11065.          Here is the prototype:
  11066.  
  11067.          int VirtualClose(VWPOINTER vw, int hideflag, int effect)
  11068.  
  11069.          The first argument is the virtual window.  The second
  11070.          argument is a flag that determines whether any viewports
  11071.          displaying the virtual window should be hidden.  If this
  11072.          argument is 1, all viewports displaying the virtual window is
  11073.          hidden.  If the argument is 0, all viewports are cleared, but
  11074.          not hidden.  The third argument is the special effect to use
  11075.          when hiding the viewports.  This argument is ignored if
  11076.          hideflag is 0.  For a list of special effects, refer to the
  11077.          DISPLAYING WINDOWS section.
  11078.  
  11079.          Once VirtualClose() is called you must not use the VWPOINTER
  11080.          again unless you assign it to another virtual window, or
  11081.          create a new virtual window.
  11082.  
  11083.          Example:
  11084.  
  11085.          #include "cwlwin.h"
  11086.  
  11087.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  11088.  
  11089.          VWPOINTER vw;          /* virtual window pointer */
  11090.          WPOINTER w1, w2;
  11091.          main()
  11092.          {
  11093.            WindowInitializeSystem();
  11094.            WindowInitDesktop(0);
  11095.            vw = VirtualInitialize(NOATTRIBUTE,30,80,0);
  11096.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,
  11097.                                  0,20,12,NORM,NORM,SINGLEBOX);
  11098.  
  11099.            w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,
  11100.                                  13,0,20,10,NORM,NORM,DOUBLEBOX);
  11101.            WindowDisplay(w1,1,NOEFFECT);
  11102.            WindowDisplay(w2,2,NOEFFECT);
  11103.            VirtualWriteString(vw,"This is a string",0,0);
  11104.            WindowAssignToVirtual(w1,vw,0,0);
  11105.            WindowAssignToVirtual(w2,vw,0,0);
  11106.            GET_KEY();
  11107.            VirtualClose(vw,1,NOEFFECT);
  11108.          }
  11109.  
  11110.          Page 172          The C Window Library               Page 172
  11111.  
  11112.                   Return Values for VirtualClose():
  11113.  
  11114.              Return Value        Definition
  11115.          ┌────────────────┬─────────────────────────┐
  11116.          │NO_ERROR        │ No error occured.       │
  11117.          ├────────────────┼─────────────────────────┤
  11118.          │BAD_V_WINDOW    │ Virtual window does     │
  11119.          │                │ not exist.              │
  11120.          └────────────────┴─────────────────────────┘
  11121.  
  11122.  
  11123.  
  11124.  
  11125.  
  11126.  
  11127.  
  11128.  
  11129.  
  11130.  
  11131.  
  11132.  
  11133.  
  11134.  
  11135.  
  11136.  
  11137.  
  11138.  
  11139.  
  11140.  
  11141.  
  11142.  
  11143.  
  11144.  
  11145.  
  11146.  
  11147.  
  11148.  
  11149.  
  11150.  
  11151.  
  11152.  
  11153.  
  11154.  
  11155.  
  11156.  
  11157.  
  11158.  
  11159.  
  11160.  
  11161.  
  11162.  
  11163.  
  11164.  
  11165.  
  11166.  
  11167.  
  11168.  
  11169.  
  11170.          Page 173          The C Window Library               Page 173
  11171.  
  11172.                      INTRODUCTION TO MENU SYSTEM
  11173.                      ---------------------------
  11174.  
  11175.          Menu systems are important entities in any program.  The C
  11176.          Window Library has functions that create popup, pull-down,
  11177.          and bar menus.  The popup menus are scrollable menus with a
  11178.          limit of 32,767 selections.  The bar menus can have any
  11179.          number of entries.  As of this version, the bar menus are not
  11180.          scrollable, although there will be an implementation of
  11181.          scrolling bar menus in a future version.  The pull-down menus
  11182.          are a combination of popup and bar menus.  You can change
  11183.          entries, hide entries, use hotkeys to invoke a menu entry,
  11184.          and many more things.
  11185.  
  11186.  
  11187.          Menu Manager
  11188.          ------------
  11189.  
  11190.          The menu manager is the code in The C Window Library that
  11191.          handles moving the highlight bar in the menu, calling the
  11192.          menu functions when they are selected, keeps tracks of
  11193.          available entries, and other functions that keep track of the
  11194.          menu when selections are made.
  11195.  
  11196.  
  11197.  
  11198.  
  11199.  
  11200.  
  11201.  
  11202.  
  11203.  
  11204.  
  11205.  
  11206.  
  11207.  
  11208.  
  11209.  
  11210.  
  11211.  
  11212.  
  11213.  
  11214.  
  11215.  
  11216.  
  11217.  
  11218.  
  11219.  
  11220.  
  11221.  
  11222.  
  11223.  
  11224.  
  11225.  
  11226.  
  11227.  
  11228.  
  11229.  
  11230.          Page 174          The C Window Library               Page 174
  11231.  
  11232.                             POP-UP MENUS
  11233.                             ------------
  11234.  
  11235.  
  11236.          Description
  11237.          -----------
  11238.  
  11239.          A popup menu is a vertical menu with a list of entries that
  11240.          are selected by placing a highlight bar on the entry and
  11241.          pressing return, releasing the left mouse button, or pressing
  11242.          a key that will automatically move the highlight bar to the
  11243.          desired entry and invoking the entry.  Popup menus are
  11244.          scrollable, in other words, if there are more entries than
  11245.          can be displayed in the window, the menu will scroll through
  11246.          the rest of the selections.  You can have up to 32,767
  11247.          entries in a popup menu.  A popup menu consists of a window
  11248.          and a virtual window.  The virtual window allows you to
  11249.          scroll through the entries, and the window is used as a
  11250.          viewport on the virtual window.
  11251.  
  11252.          Here is a partial list of the various options you can have
  11253.          with popup menus:
  11254.  
  11255.             * Highlight bar wrapping - wrap highlight bar to first or
  11256.                                        last option when there are no
  11257.                                        more selections.
  11258.  
  11259.             * Static Menus - menu remains on the screen when entry is
  11260.                              selected.
  11261.  
  11262.             * Perpetual Menus - menu remain on the screen regardless
  11263.               of whether the PopupSelectMenu() function (explained
  11264.               later) is called or not.
  11265.  
  11266.             * Hidden (Unavailable) entries - You can make an entry in
  11267.                                              the popup menu
  11268.                                              unavailable or available
  11269.                                              at any time.
  11270.  
  11271.             * Color scheme of the menu - You can customize the color
  11272.                                          of the highlight bar, the
  11273.                                          hotkey letters, hidden
  11274.                                          entries, etc.
  11275.  
  11276.             * Change entry names   - You can safely change the names
  11277.                                      displayed in the menu at any
  11278.                                      time.
  11279.  
  11280.             * Delete or Add Entries at any time.
  11281.  
  11282.  
  11283.             * Use a mouse to select menu entries.
  11284.  
  11285.  
  11286.  
  11287.  
  11288.  
  11289.  
  11290.          Page 175          The C Window Library               Page 175
  11291.  
  11292.                         CREATING POP-UP MENUS
  11293.                         ---------------------
  11294.  
  11295.  
  11296.  
  11297.          The PopupCreateMenu() function
  11298.          ------------------------------
  11299.  
  11300.          To initialize a popup menu, the PopupCreateMenu() function is
  11301.          used.  This function creates an empty popup menu.  Adding
  11302.          entries to the menu will be discussed in the next section.
  11303.          Here is the prototype:
  11304.  
  11305.          POPUP_MENU_PTR PopupCreateMenu(WPOINTER parent,
  11306.                            unsigned options, unsigned pcolor, int row,
  11307.                            int col)
  11308.  
  11309.          The parent argument is a pointer to the window that
  11310.          will be the parent of the popup menu window.  If the menu is
  11311.          to have no parent, this argument should be DESKTOP_WINDOW.
  11312.  
  11313.          The options argument denotes options that are used to turn on
  11314.          various aspect of a popup menu.
  11315.  
  11316.          The options are as follows:
  11317.  
  11318.            Option               Definition
  11319.         ┌──────────────────┬───────────────────────────────────────────┐
  11320.         │POPUPCREATWIN     │Allows PopupCreateMenu() to create a       │
  11321.         │                  │window.  Once this window is created, it   │
  11322.         │                  │is attached to the menu and will be used   │
  11323.         │                  │for displaying the menu entries.  The menu │
  11324.         │                  │window is defaulted to have a border       │
  11325.         │                  │consisting of single lines.  This option   │
  11326.         │                  │should always be used unless you have a    │
  11327.         │                  │window that you have created that you      │
  11328.         │                  │would like to use.  Any user-defined       │
  11329.         │                  │windows must be attached to the menu by    │
  11330.         │                  │calling PopupAttachWindow() before any     │
  11331.         │                  │entries can be added.  However, you can    │
  11332.         │                  │change the characteristics of the default  │
  11333.         │                  │window by getting the window pointer and   │
  11334.         │                  │applying any of the Window...() functions  │
  11335.         │                  │to it.                                     │
  11336.         ├──────────────────┼───────────────────────────────────────────┤
  11337.         │POPUPRESIZEWIDTH  │Automatically adjusts the width of the     │
  11338.         │                  │menu window to fit the longest menu entry. │
  11339.         ├──────────────────┼───────────────────────────────────────────┤
  11340.         │POPUPRESIZEHEIGHT │Automatically adjusts the height of the    │
  11341.         │                  │menu whenever menu entries are added or    │
  11342.         │                  │deleted.                                   │
  11343.         ├──────────────────┼───────────────────────────────────────────┤
  11344.         │POPUPRESIZEALL    │Combination of POPUPRESIZEWIDTH and        │
  11345.         │                  │POPUPRESIZEHEIGHT options.                 │
  11346.         └──────────────────┴───────────────────────────────────────────┘
  11347.  
  11348.  
  11349.  
  11350.          Page 176          The C Window Library               Page 176
  11351.  
  11352.            Option               Definition
  11353.         ┌──────────────────┬───────────────────────────────────────────┐
  11354.         │POPUPWRAP         │Allows the menu highlight bar to wrap to   │
  11355.         │                  │the first entry if the user moves the menu │
  11356.         │                  │highlight bar past the last entry, and     │
  11357.         │                  │will wrap to the last entry if the         │
  11358.         │                  │highlight bar is moved before the first    │
  11359.         │                  │entry.                                     │
  11360.         ├──────────────────┼───────────────────────────────────────────┤
  11361.         │POPUPSTATIC       │Allows the menu to be displayed while the  │
  11362.         │                  │user-defined menu function is invoked.     │
  11363.         ├──────────────────┼───────────────────────────────────────────┤
  11364.         │POPUPSCROLLBAR    │Draws a vertical scroll bar on the right   │
  11365.         │                  │side of a popup menu window if the number  │
  11366.         │                  │of menu entries exceed the height of the   │
  11367.         │                  │window.  This scroll bar will consist of   │
  11368.         │                  │up and down arows, and a moveable scroll   │
  11369.         │                  │box.  The scroll box is a highlighted      │
  11370.         │                  │character inside of the scroll bar that    │
  11371.         │                  │indicates approximately where the menu     │
  11372.         │                  │highlight bar is positioned in relation to │
  11373.         │                  │all of the entries.  For example, if there │
  11374.         │                  │are 500 entries in the popup menu, and the │
  11375.         │                  │highlight bar is on entry 250, the scroll  │
  11376.         │                  │box will appear in the center of the       │
  11377.         │                  │scroll bar.  This scroll bar can also be   │
  11378.         │                  │controlled with a mouse.  This is          │
  11379.         │                  │discussed in the section Using A Mouse in  │
  11380.         │                  │CWL.                                       │
  11381.         ├──────────────────┼───────────────────────────────────────────┤
  11382.         │POPUPDISPLAY      │Allows the menu to be displayed after      │
  11383.         │                  │processing the entries for a menu.         │
  11384.         │                  │Normally, when the PopupSelectMenu()       │
  11385.         │                  │function is called to start the selection  │
  11386.         │                  │process of the menu, (this will be         │
  11387.         │                  │discussed later), the menu is invoked, and │
  11388.         │                  │selections can be made from the menu.      │
  11389.         │                  │When the PopupSelectMenu() function exits, │
  11390.         │                  │the menu is hidden from the screen. If the │
  11391.         │                  │POPUPDISPLAY option is on, the menu will   │
  11392.         │                  │still be displayed on exit, but no         │
  11393.         │                  │selections can be made from it.            │
  11394.         ├──────────────────┼───────────────────────────────────────────┤
  11395.         │POPUPENHANCEDKEY  │Allows the processing of enhanced keys in  │
  11396.         │                  │a menu.  The enhanced keys are the F11 and │
  11397.         │                  │F12 keys, as well as grey keys used on     │
  11398.         │                  │enhanced keyboards.                        │
  11399.         └──────────────────┴───────────────────────────────────────────┘
  11400.  
  11401.          The options described above can be combined with a bitwise OR
  11402.          operator.  For example, if scroll bars, an automatic
  11403.          adjustable window, and the menu creates the window, the
  11404.          options would be:
  11405.  
  11406.             POPUPSCROLLBAR | POPUPRESIZEALL | POPUPCREATWIN
  11407.  
  11408.  
  11409.  
  11410.          Page 177          The C Window Library               Page 177
  11411.  
  11412.          The pcolor argument is an array of menu colors used to color
  11413.          different parts of the menu.  An array of type unsigned int
  11414.          is used to define the colors used in a popup menu.  Each
  11415.          element in the array denote a certain area of the popup menu.
  11416.          A list of the constants used to define these areas as well as
  11417.          their definitions is as follows:
  11418.  
  11419.          Menu Color    Constant     Definition
  11420.          ┌───────────────┬───┬───────────────────────────────────┐
  11421.          │ENTRYCOLOR     │ 0 │ Color of the text area of the     │
  11422.          │               │   │ popup menu's window.              │
  11423.          ├───────────────┼───┼───────────────────────────────────┤
  11424.          │BORDERCOLOR    │ 1 │ Color of the border of the popup  │
  11425.          │               │   │ menu's window.                    │
  11426.          ├───────────────┼───┼───────────────────────────────────┤
  11427.          │HOTKEYCOLOR    │ 2 │ Color of each menu entry's hotkey │
  11428.          │               │   │ character.                        │
  11429.          ├───────────────┼───┼───────────────────────────────────┤
  11430.          │HIGHLIGHTCOLOR │ 3 │ Color of a highlighted entry.     │
  11431.          │               │   │ This is effectively the color of  │
  11432.          │               │   │ an entry when the highlight bar is│
  11433.          │               │   │ over the entry.                   │
  11434.          ├───────────────┼───┼───────────────────────────────────┤
  11435.          │UNAVAILCOLOR   │ 4 │ Color of the unavailable entries. │
  11436.          │               │   │ In CWL, you can make entries      │
  11437.          │               │   │ unavailable (the highlight bar    │
  11438.          │               │   │ skips over these entries).        │
  11439.          └───────────────┴───┴───────────────────────────────────┘
  11440.  
  11441.          Colors can be created using the CREATE_VIDEO_ATTRIBUTE()
  11442.          macro.
  11443.  
  11444.          The row and col arguments denote where the popup menu window
  11445.          will be placed within the parent.
  11446.  
  11447.          The return value is a pointer to a structure called a
  11448.          POPUP_MENU_PTR.  This pointer is used to identify the popup
  11449.          menu and is used in any subsequent functions that manipulate
  11450.          the popup menu.  If the POPUP_MENU_PTR is POPUP_NULL_PTR the
  11451.          menu could not be created and CWLerror_code is set to
  11452.          NO_HEAP_MEM.
  11453.  
  11454.  
  11455.  
  11456.  
  11457.  
  11458.  
  11459.  
  11460.  
  11461.  
  11462.  
  11463.  
  11464.  
  11465.  
  11466.  
  11467.  
  11468.  
  11469.  
  11470.          Page 178          The C Window Library               Page 178
  11471.  
  11472.          Example:
  11473.  
  11474.          #include "cwlwin.h"
  11475.          unsigned int menu_colors[NUMPOPUPCOLORS];
  11476.          POPUP_MENU_PTR p;
  11477.  
  11478.          main() {
  11479.            /* ... */
  11480.            ...
  11481.            menu_color[ENTRYCOLOR]  =
  11482.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  11483.            menu_color[BORDERCOLOR]=
  11484.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  11485.            menu_color[HOTKEYCOLOR]  =
  11486.                 CREATE_VIDEO_ATTTRIBUTE(BLUE_WHITE_);
  11487.            menu_color[HIGHLIGHTCOLOR]  =
  11488.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  11489.            menu_color[UNAVAILCOLOR]=
  11490.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  11491.  
  11492.            p = PopupCreateMenu(DESKTOP_WINDOW,
  11493.                                POPUPCREATEWIN | POPUPRESIZEALL,
  11494.                                menu_color,0,0);
  11495.            if (p == POPUP_NULL_PTR)
  11496.            {
  11497.              /* popup window could not be created */
  11498.            } ...
  11499.          }
  11500.  
  11501.          The example above shows an array of menu colors called
  11502.          menu_colors initialized with the color scheme that the menu
  11503.          will use.  The constant NUMPOPUPCOLORS is defined in cwlwin.h
  11504.          and should be used to determine the size of the color array.
  11505.          Next, the POPUP_MENU_PTR p is initialized in the
  11506.          PopupCreateMenu() function.  If the menu could not be
  11507.          created, p will be a NULL pointer, which is denoted by
  11508.          POPUP_NULL_PTR.
  11509.  
  11510.  
  11511.  
  11512.          Creating Popup Menu Entries
  11513.          ---------------------------
  11514.  
  11515.          Now that the menu has been created with PopupCreateMenu(), it
  11516.          is now necessary to fill in our menu entries in the menu.
  11517.  
  11518.          Here are a list of the functions that allow the creation and
  11519.          deletion of menu entries.  Here is the prototype:
  11520.  
  11521.           int PopupInsertEntry(POPUP_MENU_PTR p, int type, int where,
  11522.                                char *entry_string, int menuid,
  11523.                                POPUPSELECTPROC popproc)
  11524.  
  11525.           int PopupAppendEntry(POPUP_MENU_PTR p, int type,
  11526.                                char *entry_string, int menuid,
  11527.                                POPUPSELECTPROC popproc)
  11528.  
  11529.  
  11530.          Page 179          The C Window Library               Page 179
  11531.  
  11532.          The p argument is the POPUP_MENU_PTR to the popup menu.
  11533.  
  11534.          The type argument denotes the menu entry type.  The different
  11535.          types are as follows:
  11536.  
  11537.  
  11538.          Menu Type           Definition
  11539.         ┌───────────────┬──────────────────────────────────────────┐
  11540.         │CWL_MSTRING    │ Denotes that the entry is a character    │
  11541.         │               │ string.                                  │
  11542.         ├───────────────┼──────────────────────────────────────────┤
  11543.         │CWL_MSEPARATOR │ Entry is a menu separator.  The          │
  11544.         │               │ separator is a horizontal line that is   │
  11545.         │               │ drawn in the menu.  This entry is always │
  11546.         │               │ skipped over by the highlight bar and    │
  11547.         │               │ cannot be chosen.  If this type is used, │
  11548.         │               │ entry_string must be the constant        │
  11549.         │               │ SEPARATOR, which is defined in cwlwin.h. │
  11550.         ├───────────────┼──────────────────────────────────────────┤
  11551.         │CWL_MDISABLED  │ The entry is initially disabled.  This   │
  11552.         │               │ option only works with CWL_MSTRING types.│
  11553.         ├───────────────┼──────────────────────────────────────────┤
  11554.         │CWL_MENABLED   │ The entry is initially enabled.  This    │
  11555.         │               │ option can be omitted when creating      │
  11556.         │               │ entries since this is the default if     │
  11557.         │               │ CWL_MDISABLED is not set.                │
  11558.         ├───────────────┼──────────────────────────────────────────┤
  11559.         │CWL_MCHECKED   │ The menu item has a check mark that is   │
  11560.         │               │ displayed as the first character of the  │
  11561.         │               │ menu string.                             │
  11562.         ├───────────────┼──────────────────────────────────────────┤
  11563.         │CWL_MUNCHECKED │ The menu item is initially unchecked.    │
  11564.         │               │ This option may be omitted when creating │
  11565.         │               │ menu entries since CWL_MUNCHECKED is the │
  11566.         │               │ default.                                 │
  11567.         ├───────────────┼──────────────────────────────────────────┤
  11568.         │CWL_MGRAYED    │ The menu item is initially grayed and    │
  11569.         │               │ disabled.  This differs from             │
  11570.         │               │ CWL_MDISABLED in that the entry is also  │
  11571.         │               │ 'grayed' using this option.  It is       │
  11572.         │               │ advantageous to use this option rather   │
  11573.         │               │ than CWL_MDISABLED since it is more than │
  11574.         │               │ likely that disabled entries are also    │
  11575.         │               │ grayed.  The actual disabling color may  │
  11576.         │               │ not really be gray, but whatever the     │
  11577.         │               │ UNAVAILCOLOR color was when the popup    │
  11578.         │               │ menu was created with PopupCreateMenu(). │
  11579.         └───────────────┴──────────────────────────────────────────┘
  11580.  
  11581.          The where argument for the PopupInsertEntry() function
  11582.          denotes the place in the menu where the entry will be
  11583.          inserted.  The entry is inserted before the entry denoted by
  11584.          the where argument.  Entries are numbered starting from 0.
  11585.  
  11586.  
  11587.  
  11588.  
  11589.  
  11590.          Page 180          The C Window Library               Page 180
  11591.  
  11592.          The entry_string argument is the menu string that is
  11593.          displayed in the menu.  The ampersand character (&) in the
  11594.          menu string denotes that the next character is to be used as
  11595.          a hotkey.  A hotkey will invoke a menu entry just be typing a
  11596.          key instead of moving the highlight to the entry and pressing
  11597.          enter.  For example, if the entry string is " &Load ", the
  11598.          'L' is considered as the hotkey.  If you desire an ampersand
  11599.          character in the entry string, use two consecutive ampersand
  11600.          characters.  If there are duplicate hotkeys in a menu, the
  11601.          menu entry that is closest to the first entry in the list is
  11602.          invoked.  If the entry string is to be checked, the first
  11603.          character should be a blank or space character, since this
  11604.          position is where the check mark will be placed.
  11605.  
  11606.          The menuid argument is an optional integer that the
  11607.          programmer can use for any purpose.  This value will be used
  11608.          in a future version of CWL when full event-driven menus will
  11609.          be implemented.
  11610.  
  11611.          The popproc argument is a user-defined function that is
  11612.          invoked when a menu entry is selected.  The popproc function
  11613.          must have the following prototype:
  11614.  
  11615.                 int popproc(POPUP_MENU_PTR pCurrent, int selection)
  11616.  
  11617.          The pCurrent argument is a pointer to the menu that invoked
  11618.          the function.  The selection argument is the entry that was
  11619.          selected.  For instance, if the first menu entry was
  11620.          selected, selection is 0.
  11621.  
  11622.          PopupAppendEntry() always places menu entries at the end of
  11623.          the list of defined  menu entries.
  11624.  
  11625.  
  11626.                   Return Values for PopupAppendEntry() and
  11627.                   PopupInsertEntry():
  11628.  
  11629.  
  11630.              Return Value        Definition
  11631.          ┌────────────────────┬───────────────────────────┐
  11632.          │NO_ERROR            │ No error occured.         │
  11633.          ├────────────────────┼───────────────────────────┤
  11634.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  11635.          ├────────────────────┼───────────────────────────┤
  11636.          │NO_HEAP_MEM         │ Not enough memory to      │
  11637.          │                    │ allocate for new entry.   │
  11638.          ├────────────────────┼───────────────────────────┤
  11639.          │WINDOW_NOT_ATTACHED │ No attached window.       │
  11640.          └────────────────────┴───────────────────────────┘
  11641.  
  11642.          Example:
  11643.  
  11644.          #include "cwlwin.h"
  11645.          unsigned int menu_colors[NUMPOPUPCOLORS];
  11646.          POPUP_MENU_PTR p;
  11647.          int myproc(POPUP_MENU_PTR, int);  /* Call back function */
  11648.  
  11649.  
  11650.          Page 181          The C Window Library               Page 181
  11651.  
  11652.          main()
  11653.          { /* ... */
  11654.               ...
  11655.            menu_color[ENTRYCOLOR]  =
  11656.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  11657.            menu_color[BORDERCOLOR]=
  11658.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  11659.            menu_color[HOTKEYCOLOR]  =
  11660.                 CREATE_VIDEO_ATTRIBUTE(BLUE_WHITE_);
  11661.            menu_color[HIGHLIGHTCOLOR]  =
  11662.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  11663.            menu_color[UNAVAILCOLOR]=
  11664.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  11665.  
  11666.            p =  PopupCreateMenu(DESKTOP_WINDOW, POPUPCREATEWIN |
  11667.                                 POPUPRESIZEALL, menu_color,0,0);
  11668.  
  11669.            if (p == POPUP_NULL_PTR)
  11670.            {
  11671.              /* popup window could not be created */
  11672.              exit(0);
  11673.            }
  11674.  
  11675.            /* Append a entry item to the menu */
  11676.            PopupAppendEntry(p, CWL_MSTRING,"Menu Item 2",0,myproc);
  11677.  
  11678.            /* Insert an entry before the first entry.  This entry is
  11679.               also grayed and disabled */
  11680.            PopupInsertEntry(p,CWL_MSTRING | CWL_MGRAYED,0,
  11681.                             "Menu Item 1",0,myproc);
  11682.  
  11683.            /* Append a separator */
  11684.            PopupAppendEntry(p,CWL_MSEPARATOR, SEPARATOR,0,
  11685.                             (POPUPSELECTPROC)0);
  11686.  
  11687.            /* Append a entry item to the menu */
  11688.            PopupAppendEntry(p, CWL_MSTRING,"Menu Item 3",0,myproc);
  11689.  
  11690.            /* Insert an entry before the separator. */
  11691.            PopupInsertEntry(p,CWL_MSTRING | CWL_MGRAYED,0,
  11692.                             "Menu Item 1",2,myproc);
  11693.  
  11694.            ...
  11695.          }
  11696.  
  11697.  
  11698.          The example above creates a popup menu called p. Five entries
  11699.          are placed on the menu.   The first entry is placed inside
  11700.          the menu with the PopupAppendEntry() function.  The second
  11701.          entry is placed using the PopupInsertEntry(), and is inserted
  11702.          before the first entry.  The third entry is a SEPARATOR
  11703.          entry.  The fourth entry is appended using
  11704.          PopupAppendEntry().  The last entry is inserted before the
  11705.          separator by inserting it at position 2 of the menu.
  11706.  
  11707.  
  11708.  
  11709.  
  11710.          Page 182          The C Window Library               Page 182
  11711.  
  11712.          Inserting Multiple Entries
  11713.          --------------------------
  11714.  
  11715.          You can insert multiple entries by calling the
  11716.          PopupInsertMultEntries() and PopupAppendMultEntries()
  11717.          functions.  These function require that an array of
  11718.          structures called POPUP_MENU_ENTRY's are filled in with the
  11719.          desired values.  The layout of this structure is defined as
  11720.          follows:
  11721.  
  11722.          typedef struct tagPOPUPENTRY  {
  11723.                  char *entry_name;
  11724.                  unsigned int menuid;
  11725.                  unsigned int type;
  11726.                  POPUPSELECTPROC popproc;
  11727.          } POPUP_MENU_ENTRY;
  11728.  
  11729.          The entry_name, menuid, type and popproc members are the same
  11730.          as the corresponding names used in the PopupInsertEntry() and
  11731.          PopupAppendEntry().
  11732.  
  11733.          The prototypes for PopupInsertMultEntries() and
  11734.          PopupAppendMultEntries() are as follows:
  11735.  
  11736.          int PopupInsertMultEntries(POPUP_MENU_PTR p, int where,
  11737.                                     POPUP_MENU_ENTRY *pentry,
  11738.                                     int numentries)
  11739.  
  11740.          int PopupAppendMultEntries(POPUP_MENU_PTR p,
  11741.                                     POPUP_MENU_ENTRY *pentry,
  11742.                                     int numentries)
  11743.  
  11744.          The p argument is the pointer to the popup menu.
  11745.  
  11746.          The where argument is analogous to the where argument for the
  11747.          PopupInsertEntry() function defined in the previous section.
  11748.          The where argument denotes the position in the menu where the
  11749.          entries will be inserted.  This argument is pertinent only to
  11750.          the PopupInsertMultEntries() function.
  11751.  
  11752.          The pentry argument is the array of POPUP_MENU_ENTRY's to be
  11753.          inserted.
  11754.  
  11755.          The numentries argument is the number of POPUP_MENU_ENTRY's
  11756.          to insert.
  11757.  
  11758.          The PopupAppendMultEntries() always places the menu entries
  11759.          at the end of the popup menu.
  11760.  
  11761.  
  11762.  
  11763.  
  11764.  
  11765.  
  11766.  
  11767.  
  11768.  
  11769.  
  11770.          Page 183          The C Window Library               Page 183
  11771.  
  11772.                   Return Values for PopupAppendMultEntries() and
  11773.                   PopupInsertMultEntries():
  11774.  
  11775.              Return Value        Definition
  11776.          ┌────────────────────┬───────────────────────────┐
  11777.          │NO_ERROR            │ No error occured.         │
  11778.          ├────────────────────┼───────────────────────────┤
  11779.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  11780.          ├────────────────────┼───────────────────────────┤
  11781.          │NO_HEAP_MEM         │ Not enough memory to      │
  11782.          │                    │ allocate for new entries. │
  11783.          ├────────────────────┼───────────────────────────┤
  11784.          │WINDOW_NOT_ATTACHED │ No attached window.       │
  11785.          └────────────────────┴───────────────────────────┘
  11786.  
  11787.          Example:
  11788.  
  11789.          #include "cwlwin.h"
  11790.  
  11791.            /* Define menu function */
  11792.          int menu_func(POPUP_MENU_PTR, int);
  11793.  
  11794.          /* Set up array of POPUP_MENU_ENTRY's */
  11795.          POPUP_MENU_ENTRY menu_items[] = {
  11796.                 {" &Load  "    ,0,CWL_MSTRING,menu_func},
  11797.                 {" &Pick  "    ,0,CWL_MSTRING,menu_func},
  11798.                 {" &New   "    ,0,CWL_MSTRING,menu_func},
  11799.                 {SEPARATOR     ,0,CWL_MSEPARATOR ,(POPUPPROC)0},
  11800.                 {" &Save  "    ,0,CWL_MSTRING,menu_func},
  11801.                 {" &Write to  ",0,CWL_MSTRING,menu_func},
  11802.                 {" &Directory ",0,CWL_MSTRING,menu_func},
  11803.                 {" &Change Dir",0,CWL_MSTRING,menu_func},
  11804.                 {" &OS Shell  ",0,CWL_MSTRING,menu_func},
  11805.                 {" E&xit  "    ,0,CWL_MSTRING,menu_func}
  11806.             };
  11807.  
  11808.          main()
  11809.          {
  11810.           ...
  11811.            /* Assume initialization has been done */
  11812.            p = PopupCreateMenu( /* Arguments */);
  11813.  
  11814.            /* Insert the entries (there are 10 of them) */
  11815.            PopupInsertMultEntries(p,0,menu_items,10);
  11816.  
  11817.            /* ... */
  11818.          }
  11819.  
  11820.          The example above sets up an array of POPUP_MENU_ENTRY called
  11821.          menu_items, with each element filled in with the information
  11822.          desired.  The PopupInsertMultEntries() function inserts all
  11823.          ten entries into the popup menu.
  11824.  
  11825.  
  11826.  
  11827.  
  11828.  
  11829.  
  11830.          Page 184          The C Window Library               Page 184
  11831.  
  11832.          Inserting a Popup Menu Within a Popup Menu
  11833.          ------------------------------------------
  11834.  
  11835.          There may be situations where a popup menu scheme would make
  11836.          sense if one of the entries opened another popup menu when
  11837.          selected.  These type of popup menus are called cascading
  11838.          menus.  With CWL, you can insert a popup menu within a popup
  11839.          menu by using the PopupInsertPopup() function.  Here is the
  11840.          prototype:
  11841.  
  11842.          int PopupInsertPopup(POPUP_MENU_PTR pOwner,
  11843.                               POPUP_MENU_PTR pInsert, int type,
  11844.                               int where, char *entry_string,
  11845.                               int menuid)
  11846.  
  11847.          int PopupAppendPopup(POPUP_MENU_PTR pOwner,
  11848.                               POPUP_MENU_PTR pInsert, int type,
  11849.                               char *entry_string, int menuid)
  11850.  
  11851.  
  11852.          The pOwner argument is a pointer to the popup menu that will
  11853.          hold the inserted popup.
  11854.  
  11855.          The pInsert argument is the popup menu to insert.
  11856.  
  11857.          The type argument are the menu entry types that were defined
  11858.          for PopupInsertEntry().  This means that the entry can be
  11859.          initially grayed, checked, etc.
  11860.  
  11861.          The where argument denotes the position in pOwner to place
  11862.          the embedded popup entry.
  11863.  
  11864.          The entry_string argument is the actual name that will appear
  11865.          in pOwner for this menu entry.
  11866.  
  11867.          The menuid is an optional integer that the programmer can use
  11868.          for any purpose.
  11869.  
  11870.          For the PopupAppendPopup() function, the entries are attached
  11871.          to the end of the menu.  When a menu is attached to another
  11872.          menu, the entry_name has a character appended to the name to
  11873.          denote that there is another menu associated with the entry.
  11874.          By default, this character is the ASCII 16, which is a
  11875.          triangular character that points right.  The global character
  11876.          variable CWLpopup_char holds the current character that is
  11877.          used for the popup menu indicator.  You can change this
  11878.          variable to any character desired by doing something like the
  11879.          following:
  11880.  
  11881.                 CWLpopup_char = '*'
  11882.  
  11883.          The above uses the asterisk (*) as the embedded popup
  11884.          indicator.  If no character is desired, this character can be
  11885.          a space. Popup menus can be cascaded to any level i.e. menus
  11886.          that are inserted can also have cascading menus.
  11887.  
  11888.  
  11889.  
  11890.          Page 185          The C Window Library               Page 185
  11891.  
  11892.                   Return Values for PopupInsertPopup() and
  11893.                   PopupAppendPopup():
  11894.  
  11895.              Return Value        Definition
  11896.          ┌────────────────────┬───────────────────────────┐
  11897.          │NO_ERROR            │ No error occured.         │
  11898.          ├────────────────────┼───────────────────────────┤
  11899.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  11900.          │                    │ (either the parent or the │
  11901.          │                    │ menu that is to be        │
  11902.          │                    │ embedded)                 │
  11903.          ├────────────────────┼───────────────────────────┤
  11904.          │NO_HEAP_MEM         │ Not enough memory to      │
  11905.          │                    │ allocate for new entry.   │
  11906.          ├────────────────────┼───────────────────────────┤
  11907.          │WINDOW_NOT_ATTACHED │ No attached window.       │
  11908.          └────────────────────┴───────────────────────────┘
  11909.  
  11910.          Example:
  11911.  
  11912.          #include "cwlwin.h"
  11913.          /* Define menu function */
  11914.          int menu_func(POPUP_MENU_PTR, int);
  11915.  
  11916.          /* Set up array of POPUP_MENU_ENTRY's */
  11917.               POPUP_MENU_ENTRY menu_items[] = {
  11918.               {" &Load   ",0,CWL_MSTRING,menu_func},
  11919.               {" &Pick  ",0,CWL_MSTRING,menu_func},
  11920.               {SEPARATOR ,0,CWL_MSEPARATOR ,(POPUPPROC)0},
  11921.               {" &Save  ",0,CWL_MSTRING,menu_func},
  11922.               {" &Write to       ",0,CWL_MSTRING,menu_func},
  11923.               {" &Directory    ",0,CWL_MSTRING,menu_func},
  11924.               {" &Change Dir "  ,0,CWL_MSTRING,menu_func},
  11925.               {" &OS Shell      ",0,CWL_MSTRING,menu_func},
  11926.               {" E&xit  ",0,CWL_MSTRING,menu_func}
  11927.             };
  11928.             /* Set up array of POPUP_MENU_ENTRY's for second menu*/
  11929.               POPUP_MENU_ENTRY menu_items2[] = {
  11930.               {" New Sub-Item1",0,CWL_MSTRING,menu_func},
  11931.               {" New Sub-Item2",1,CWL_MSTRING,menu_func},
  11932.             };
  11933.  
  11934.             main() {
  11935.               POPUP_MENU_PTR p, p2; ...
  11936.  
  11937.               /* Assume initialization has been done */
  11938.               p = PopupCreateMenu( /* Arguments */);
  11939.               p2 = PopupCreateMenu(/* Arguments */);
  11940.  
  11941.               /* Insert the entries */
  11942.               PopupInsertMultEntries(p,0,menu_items,9);
  11943.               PopupInsertMultEntries(p2,0,menu_items2,2);
  11944.  
  11945.               /* Insert the popup menu as item 2 */
  11946.               PopupInsertPopup(p,p2,"&Name",CWL_MSTRING,2,0)
  11947.               /* ... */
  11948.             }
  11949.  
  11950.          Page 186          The C Window Library               Page 186
  11951.  
  11952.          The p2 menu is embedded into the p menu at menu entry 1.
  11953.          Here is an example of what these menus will look like on the
  11954.          screen:
  11955.  
  11956.                ┌────────────┐
  11957.                │ Load       ├──────────────┐
  11958.                │ Pick      │New Sub-Item 1│
  11959.                │────────────│New Sub-Item 2│
  11960.                │ Save       ├──────────────┘
  11961.                │ Write to   │
  11962.                │ Directory  │
  11963.                │ Change Dir │
  11964.                │ OS Shell   │
  11965.                │ Exit       │
  11966.                └────────────┘
  11967.  
  11968.          Note that the embedded menu appears if 'Pick' is selected.
  11969.  
  11970.  
  11971.          Deleting Menu Entries
  11972.          ---------------------
  11973.  
  11974.          Deleting many entries is easily accomplished by calling the
  11975.          PopupDeleteEntry() and PopupDeleteMultEntries() functions.
  11976.          The entries can be separator entries, string entries,
  11977.          or embedded popup menus.  Here are the prototypes to these
  11978.          functions:
  11979.  
  11980.          int PopupDeleteEntry(POPUP_MENU_PTR p, int where)
  11981.  
  11982.          int PopupDeleteMultEntries(POPUP_MENU_PTR p, int where, int num)
  11983.  
  11984.          The argument p is the pointer to the popup menu.
  11985.  
  11986.          The where argument denotes the position of the menu entry to
  11987.          delete.  For the PopupDeleteMultEntries() function, this
  11988.          position denotes the first menu item to delete.  If where is
  11989.          -1, the last entry is deleted.
  11990.  
  11991.          The num argument in the PopupDeleteMultEntries() function is
  11992.          the number of entries to delete starting from position where.
  11993.  
  11994.          If an embedded popup menu is deleted, the embedded menu is
  11995.          still available for use as either a stand-alone popup menu,
  11996.          or can be embedded in another window.
  11997.  
  11998.                   Return Values for PopupDeleteEntry() and
  11999.                   PopupDeleteMultEntries():
  12000.  
  12001.              Return Value        Definition
  12002.          ┌────────────────────┬───────────────────────────┐
  12003.          │NO_ERROR            │ No error occured.         │
  12004.          ├────────────────────┼───────────────────────────┤
  12005.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  12006.          ├────────────────────┼───────────────────────────┤
  12007.          │WINDOW_NOT_ATTACHED │ No attached window.       │
  12008.          └────────────────────┴───────────────────────────┘
  12009.  
  12010.          Page 187          The C Window Library               Page 187
  12011.  
  12012.          Example:
  12013.  
  12014.          #include "cwlwin.h"
  12015.  
  12016.          POPUP_MENU_ENTRIES menu_items[] = {  /* Fill in entries */ };
  12017.  
  12018.          main()
  12019.          {
  12020.            POPUP_MENU_PTR p;
  12021.            ... /* Assume initialization has been done and entries were
  12022.                 created*/
  12023.  
  12024.            p = PopupCreateMenu( /* Arguments */);
  12025.  
  12026.            /* Insert the entries */
  12027.            PopupInsertMultEntries(p,0,menu_items,3);
  12028.  
  12029.            /* Delete the first entry */
  12030.            PopupDeleteEntry(p,0)
  12031.  
  12032.            /* ... */
  12033.          }
  12034.  
  12035.  
  12036.          Initializing the size of the Virtual Window and Window
  12037.          ------------------------------------------------------
  12038.  
  12039.          Normally when entries are added or deleted, the popup menu's
  12040.          virtual window and viewport window will grow or shrink
  12041.          accordingly.  Sometimes this may be time consuming for a
  12042.          large number of entries.
  12043.  
  12044.          The PopupSetDimensions() function sets up the dimensions of
  12045.          the popup menu's virtual window to a specific size so that
  12046.          the virtual window does not have to be resized every time an
  12047.          entry is added.  It also makes the virtual window
  12048.          unshrinkable, so this function should be used judiciously
  12049.          when determining the maximum size of the virtual window.
  12050.  
  12051.          The PopupSetWinDimensions() function sizes the viewport
  12052.          window to a fixed size.  This is useful if you want the popup
  12053.          menu's window to not grow larger or smaller than a certain
  12054.          height or width when entries are added or deleted.
  12055.  
  12056.          Here are the prototypes for these two functions:
  12057.  
  12058.          int PopupSetDimensions(POPUP_MENU_PTR p, int width, int height,
  12059.                                 int options)
  12060.  
  12061.          int PopupSetWinDimensions(POPUP_MENU_PTR p, int width,
  12062.                                    int height, int options)
  12063.  
  12064.          The p argument is the pointer to the popup menu.
  12065.  
  12066.          The width and height arguments are the width and height
  12067.          desired.
  12068.  
  12069.  
  12070.          Page 188          The C Window Library               Page 188
  12071.  
  12072.          The options argument denote whether the width, height or both
  12073.          arguments are to be used when resizing the window.  The
  12074.          various options are as follows:
  12075.  
  12076.          POPUP_SETWIDTH sets the width of the virtual window using the
  12077.          width argument.  The height argument is ignored.
  12078.  
  12079.          POPUP_SETHEIGHT sets the heigth of the virtual window using
  12080.          the height argument.  The width argument is ignored.
  12081.  
  12082.          POPUP_SETALL sets both the width and the height using the
  12083.          width and height arguments, respectively.
  12084.  
  12085.  
  12086.  
  12087.          If the width or height argument is less than the current
  12088.          virtual window's width or height, the argument is ignored.
  12089.          This function can only be used to enlarge a virtual window,
  12090.          not to shrink it.  The viewport window is also sized to the
  12091.          dimensions specified, but can be made no smaller than width
  12092.          or height.
  12093.  
  12094.          You can manually resize the width and height by using
  12095.          WindowResize...() or VirtualResize() functions on the popup
  12096.          window or popup virtual window, respectively.  When
  12097.          PopupSetWinDimensions() is called, the popup menu's viewport
  12098.          window is automatically resized, and will not grow beyond the
  12099.          sizes given in width and height.  This differs from the
  12100.          PopupSetDimensions() function in that the virtual window is
  12101.          always resized if the number of entries exceeds the height of
  12102.          the window or the length of a new entry is wider than the
  12103.          virtual window.
  12104.  
  12105.          It is recommended that this function is used on the viewport
  12106.          window if a lot of entries are to be added.  The viewport
  12107.          window can be retrieved using the POPUP_WINDOW() macro.  The
  12108.          virtual window of the popup menu can be retrieved using the
  12109.          POPUP_VIRTUAL_WINDOW() macro.  Both of these macros are
  12110.          described in Macros section of this manual.
  12111.  
  12112.                   Return Values for PopupSetDimensions and
  12113.                   PopupSetWinDimensions():
  12114.  
  12115.              Return Value        Definition
  12116.          ┌────────────────────┬───────────────────────────┐
  12117.          │NO_ERROR            │ No error occured.         │
  12118.          ├────────────────────┼───────────────────────────┤
  12119.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  12120.          ├────────────────────┼───────────────────────────┤
  12121.          │NO_HEAP_MEM         │ Not enough memory to      │
  12122.          │                    │ allocate for new entries. │
  12123.          ├────────────────────┼───────────────────────────┤
  12124.          │WINDOW_NOT_ATTACHED │ No attached window.       │
  12125.          └────────────────────┴───────────────────────────┘
  12126.  
  12127.  
  12128.  
  12129.  
  12130.          Page 189          The C Window Library               Page 189
  12131.  
  12132.          Example:
  12133.  
  12134.          #include "cwlwin.h"
  12135.          main()
  12136.          {
  12137.            POPUP_MENU_PTR p;
  12138.            ...
  12139.  
  12140.            /* Assume initialization has been done and entries
  12141.               were created*/
  12142.            p = PopupCreateMenu( /* Arguments */);
  12143.  
  12144.            /* Reset the dimensions of the virtual window */
  12145.            PopupSetDimensions(p,30,100,POPUP_SETALL);
  12146.            PopupSetWinDimensions(p,12,6,POPUP_SETALL);
  12147.            /* ... */
  12148.          }
  12149.  
  12150.  
  12151.  
  12152.  
  12153.  
  12154.  
  12155.  
  12156.  
  12157.  
  12158.  
  12159.  
  12160.  
  12161.  
  12162.  
  12163.  
  12164.  
  12165.  
  12166.  
  12167.  
  12168.  
  12169.  
  12170.  
  12171.  
  12172.  
  12173.  
  12174.  
  12175.  
  12176.  
  12177.  
  12178.  
  12179.  
  12180.  
  12181.  
  12182.  
  12183.  
  12184.  
  12185.  
  12186.  
  12187.  
  12188.  
  12189.  
  12190.          Page 190          The C Window Library               Page 190
  12191.  
  12192.                      SELECTING FROM POPUP MENUS
  12193.                      --------------------------
  12194.  
  12195.          We have now created the popup menu.  Now how do we get the
  12196.          menu manager to act on our popup window?  The answer is the
  12197.          PopupSelectMenu() function.
  12198.  
  12199.          PopupSelectMenu() function
  12200.          --------------------------
  12201.  
  12202.          The PopupSelectMenu() function displays the popup window, and
  12203.          allows the user to move the highlight bar until he/she has
  12204.          placed the bar on the desired option, or the user presses a
  12205.          hotkey to invoke one of the entries.
  12206.  
  12207.          Before the call to the PopupSelectMenu(), nothing has been
  12208.          displayed (unless you called WindowDisplay() on the popup
  12209.          menu's window).  This means that you can resize the popup
  12210.          window, change borders, write strings to the popup menus
  12211.          virtual window, insert and delete entries etc.  while
  12212.          everything is hidden away from view.  The only time when the
  12213.          popup menu is displayed is when the call to PopupSelectMenu()
  12214.          is made (or unless you have displayed the popup window
  12215.          yourself using WindowDisplay()).  The prototype of the call
  12216.          to PopupSelectMenu() is as follows:
  12217.  
  12218.          int PopupSelectMenu(POPUP_MENU_PTR p, int rank, int start)
  12219.  
  12220.          The first argument is the POPUP_MENU_PTR.  The second
  12221.          argument is the rank of the popup window.  As with other
  12222.          windows, the rank determines how the window will be situated
  12223.          on the screen with respect to the other windows.  The last
  12224.          argument is the number of the menu entry of where the
  12225.          highlight bar should be situated.  Usually this is 0, but
  12226.          this will give you the option to start on any one of the menu
  12227.          entries.  If the start value is out of bounds (say you have
  12228.          specified start to be 5 while there are only 5 menu entries)
  12229.          the menu manager will default to the first menu option.
  12230.  
  12231.          Now let's put everything together:
  12232.  
  12233.            /* Define menu function */
  12234.          int menu_func(POPUP_MENU_PTR, int);
  12235.  
  12236.          /* Set up array of POPUP_MENU_ENTRY's */
  12237.          POPUP_MENU_ENTRY menu_items[] = {
  12238.                 {" &Load  ",0,CWL_MSTRING,menu_func},
  12239.                 {" &Pick  ",0,CWL_MSTRING,menu_func},
  12240.                 {" &New            " ,0,CWL_MSTRING,menu_func},
  12241.                 {SEPARATOR ,0,CWL_MSEPARATOR ,(POPUPPROC)0},
  12242.                 {" &Save  ",0,CWL_MSTRING,menu_func},
  12243.                 {" &Write to       ",0,CWL_MSTRING,menu_func},
  12244.                 {" &Directory    ",0,CWL_MSTRING,menu_func},
  12245.                 {" &Change Dir "  ,0,CWL_MSTRING,menu_func},
  12246.                 {" &OS Shell      ",0,CWL_MSTRING,menu_func},
  12247.                 {" E&xit    "  ,0,CWL_MSTRING,menu_func}
  12248.             };
  12249.  
  12250.          Page 191          The C Window Library               Page 191
  12251.  
  12252.          unsigned int menu_colors[5];
  12253.          POPUP_MENU_PTR p;
  12254.  
  12255.          main()
  12256.          {
  12257.            WindowInitializeSystem();
  12258.            WindowInitDesktop(0);
  12259.           /* define colors */
  12260.            menu_colors[ENTRYCOLOR] =
  12261.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_);
  12262.            menu_colors[BORDERCOLOR] =
  12263.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_);
  12264.            menu_colors[HOTKEYCOLOR] =
  12265.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLUE_);
  12266.            menu_colors[HIGHLIGHTCOLOR] =
  12267.                   CREATE_VIDEO_ATTRIBUTE(CYAN_,BLACK_);
  12268.            menu_colors[UNAVAILCOLOR] =
  12269.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_);
  12270.  
  12271.           /* create a POPUP_MENU_PTR */
  12272.            p =  PopupCreateMenu(DESKTOP_WINDOW, POPUPCREATEWIN |
  12273.                                 POPUPRESIZEALL, menu_color,0,0);
  12274.  
  12275.           /* insert the entries */
  12276.            PopupInsertMultEntries(p,0,menu_items,10);
  12277.  
  12278.           /* get menu selections */
  12279.            PopupSelectMenu(p,  /* POPUP_MENU_PTR */
  12280.                             1,  /* rank of popup window */
  12281.                             0   /* menu entry to start on */
  12282.                            );
  12283.          }
  12284.  
  12285.          int menu_func(POPUP_MENU_PTR p, int which)
  12286.          {
  12287.            WPOINTER w;
  12288.            w = WindowInitialize(DESKTOP_WINDOW, BORDER,15,15,40,4,
  12289.                                 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_),
  12290.                                 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_),
  12291.                                 SINGLEBOX);
  12292.            WindowClear(w);
  12293.            WindowPrintf(w,"You have selected %s",
  12294.                         POPUP_ENTRY_STRING(p,which));
  12295.            WindowWriteCenterString(w,"Press a key to continue",3);
  12296.            WindowDisplay(w,1,NOEFFECT);
  12297.            GET_KEY();
  12298.            WindowClose(w,NOEFFECT);
  12299.            if (which == 9)
  12300.              return POPUP_EXIT;
  12301.            else
  12302.              return POPUP_CONTINUE;
  12303.  
  12304.          }
  12305.  
  12306.  
  12307.  
  12308.  
  12309.  
  12310.          Page 192          The C Window Library               Page 192
  12311.  
  12312.          The above example has a call to PopupSelectMenu().  The
  12313.          arguments passed are p as the POPUP_MENU_PTR, a window rank
  12314.          of 1, and a starting position of 0.  The POPUP_ENTRY_STRING()
  12315.          macro in the menu_func() function returns the entry string
  12316.          for the particualr menu entry.  The first argument is the
  12317.          POPUP_MENU_PTR and the second argument is the entry number.
  12318.  
  12319.  
  12320.          Values passed to menu function
  12321.          ------------------------------
  12322.  
  12323.          When a selection is made, the menu manager will call the
  12324.          function defined for the selection, and pass two arguments to
  12325.          this function.  The first argument passed is the
  12326.          POPUP_MENU_PTR of the current popup menu and the second
  12327.          argument is the number of the entry selected.  Entry numbers
  12328.          are numbered from 0 to the highest entry in the menu, less
  12329.          one.  For example, if the " Load " entry is selected, the
  12330.          menu manager will pass the POPUP_MENU_PTR p, and a 0 to
  12331.          func().  If " Pick " is chosen, the menu manager passes
  12332.          a 1 as the second argument to func() etc.
  12333.  
  12334.  
  12335.          Values returned to menu manager
  12336.          -------------------------------
  12337.  
  12338.          The user function must return an integer back to the menu
  12339.          manager.  If the value returned to the menu manager is
  12340.          POPUP_EXIT, the menu manager will exit from the current menu
  12341.          and will return control back to the function that called it.
  12342.          If the return value is POPUP_CONTINUE, the menu continues to
  12343.          process selections.
  12344.  
  12345.          The menu_func() function defined above creates a window,
  12346.          displays the entry you have chosen, and returns a value back
  12347.          to the menu manager.  If the value is POPUP_EXIT, the menu
  12348.          manager returns control back to the function that called it.
  12349.          In this case, main() called PopupSelectMenu().  A return
  12350.          value of POPUP_CONTINUE will cause the menu manager to let
  12351.          the user make another selection.
  12352.  
  12353.          The menu_func() function is a simple implementation.  However
  12354.          your function can do much more sophisticated things,
  12355.          including opening other popup menus.  If another popup menu
  12356.          is called while in another popup menu, the new popup menu
  12357.          gets its own menu manager and will not interfere with the
  12358.          original menu manager.  This is good if a menu function will
  12359.          call another menu function.
  12360.  
  12361.                 Return Values for PopupSelectMenu():
  12362.  
  12363.              Return Value        Definition
  12364.          ┌────────────────────┬───────────────────────────┐
  12365.          │NO_ERROR            │ No error occured.         │
  12366.          ├────────────────────┼───────────────────────────┤
  12367.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  12368.          └────────────────────┴───────────────────────────┘
  12369.  
  12370.          Page 193          The C Window Library               Page 193
  12371.  
  12372.                    SETTING OPTIONS IN POPUP MENUS
  12373.                    ------------------------------
  12374.  
  12375.          In addition to setting options using the PopupCreateMenu()
  12376.          function, you can turn on and off options at any time using
  12377.          the PopupSetOptions() function.
  12378.  
  12379.  
  12380.          The PopupSetOptions() function
  12381.          ------------------------------
  12382.  
  12383.          The PopupSetOptions() function turns either one or more of
  12384.          the above options on or off.  The prototype to the call is as
  12385.          follows:
  12386.  
  12387.          int PopupSetOptions(POPUP_MENU_PTR p, int option, int switch)
  12388.  
  12389.          The first argument is the POPUP_MENU_PTR.  The second
  12390.          argument are the options that you wish to change.  The
  12391.          constants that describe the options are exactly the same as
  12392.          the ones described in PopupCreateMenu().  The third argument
  12393.          is whether you want to switch the options on or off.
  12394.  
  12395.            Here are some sample calls to PopupSetOptions():
  12396.  
  12397.              a) PopupSetOptions(p,POPUPWRAP,1)
  12398.              b) PopupSetOptions(p,POPUPSTATIC,1)
  12399.              c) PopupSetOptions(p,POPUPSTATIC,0)
  12400.              d) PopupSetOptions(p,POPUPDISPLAY,1)
  12401.              e) PopupSetOptions(p,POPUPENHANCEDKEY,1)
  12402.  
  12403.          The third argument is 1 for "turn option on", 0 for "turn
  12404.          option off".
  12405.  
  12406.  
  12407.          Setting Multiple Options
  12408.          ------------------------
  12409.          You can also set multiple options with a single call by using
  12410.          a bitwise OR (|).  For example:
  12411.  
  12412.                  PopupSetOptions(p,POPUPWRAP | POPUPSTATIC 1)
  12413.  
  12414.          will set options POPUPWRAP and POPUPSTATIC.
  12415.  
  12416.  
  12417.                 Return Values for PopupSetOptions():
  12418.  
  12419.              Return Value        Definition
  12420.          ┌────────────────────┬───────────────────────────┐
  12421.          │NO_ERROR            │ No error occured.         │
  12422.          ├────────────────────┼───────────────────────────┤
  12423.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  12424.          └────────────────────┴───────────────────────────┘
  12425.  
  12426.  
  12427.  
  12428.  
  12429.  
  12430.          Page 194          The C Window Library               Page 194
  12431.  
  12432.          Getting Menu Options
  12433.          --------------------
  12434.  
  12435.          You can retrieve the options in a popup menu by calling the
  12436.          PopupGetOptions() function.  The prototype is as follows:
  12437.  
  12438.             int PopupGetOptions(POPUP_MENU_PTR p, int *options)
  12439.  
  12440.          The first argument is the popup menu that you want to retieve
  12441.          the options from.
  12442.  
  12443.          The second argument is a pointer to an integer that will hold
  12444.          the options when PopupGetOptions() returns.
  12445.  
  12446.          You can see if an option is set by using the bitwise AND.
  12447.  
  12448.          Example:
  12449.                         int options;
  12450.                         POPUP_MENU_PTR p;
  12451.                         ...
  12452.  
  12453.                         PopupGetOptions(p,&options);
  12454.                         if (options & POPUPWRAP)  {
  12455.                           /* wrap option is on */
  12456.                         }
  12457.  
  12458.                         ...
  12459.  
  12460.  
  12461.  
  12462.                   Return Values for PopupGetOptions():
  12463.  
  12464.              Return Value        Definition
  12465.          ┌────────────────────┬───────────────────────────┐
  12466.          │NO_ERROR            │ No error occured.         │
  12467.          ├────────────────────┼───────────────────────────┤
  12468.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  12469.          └────────────────────┴───────────────────────────┘
  12470.  
  12471.  
  12472.  
  12473.  
  12474.  
  12475.  
  12476.  
  12477.  
  12478.  
  12479.  
  12480.  
  12481.  
  12482.  
  12483.  
  12484.  
  12485.  
  12486.  
  12487.  
  12488.  
  12489.  
  12490.          Page 195          The C Window Library               Page 195
  12491.  
  12492.                     DISABLING POPUP MENU ENTRIES
  12493.                     ----------------------------
  12494.  
  12495.          There may be cases when a menu entry should be disabled.  The
  12496.          entry shows up in the menu, but it is a different color than
  12497.          the other entries and cannot be selected.
  12498.  
  12499.  
  12500.          Disabling and Enabling Entries
  12501.          ------------------------------
  12502.  
  12503.          With The C Window Library, you can disable and enable menu
  12504.          entries at any time.  The PopupEnableEntry() function
  12505.          performs this task.  Here is the prototype to this function.
  12506.  
  12507.          int PopupEnableEntry(POPUP_MENU_PTR p, int where, int option)
  12508.  
  12509.          The first argument is the POPUP_MENU_PTR.  The second
  12510.          argument is the number of the entry that you wish to change.
  12511.          Entry numbers range from 0 to the highest entry in the menu
  12512.          less one.
  12513.  
  12514.          The option argument is either CWL_MDISABLED to disable a
  12515.          menu, or CWL_MENABLED to enable an entry.  You can combine
  12516.          CWL_MGRAYED with CWL_MDISABLED by using the bitwise OR
  12517.          operator (|) to gray the entry.
  12518.  
  12519.  
  12520.  
  12521.                 Return Values for PopupEnableEntry():
  12522.  
  12523.              Return Value        Definition
  12524.          ┌────────────────────┬───────────────────────────┐
  12525.          │NO_ERROR            │ No error occured.         │
  12526.          ├────────────────────┼───────────────────────────┤
  12527.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  12528.          ├────────────────────┼───────────────────────────┤
  12529.          │MENU_ENTRY_INVALID  │ Entry number is invalid.  │
  12530.          └────────────────────┴───────────────────────────┘
  12531.  
  12532.  
  12533.  
  12534.  
  12535.  
  12536.  
  12537.  
  12538.  
  12539.  
  12540.  
  12541.  
  12542.  
  12543.  
  12544.  
  12545.  
  12546.  
  12547.  
  12548.  
  12549.  
  12550.          Page 196          The C Window Library               Page 196
  12551.  
  12552.                    CHANGING THE MENU ENTRY STRINGS
  12553.                    -------------------------------
  12554.  
  12555.          There may be times when you want to change a POPUP_MENU_ENTRY
  12556.          entry_name string.  For instance, you may have a menu entry
  12557.          with the following entry_name:
  12558.  
  12559.                  "Default File Name     ABC.DAT"
  12560.  
  12561.  
  12562.          If the user selects this choice, the file name should change
  12563.          to another file name the user wants.  From there the menu
  12564.          should reflect the new choice the user has made.  Let's say
  12565.          the user has changed the default file name to DEF.DAT.  The
  12566.          menu then should say:
  12567.  
  12568.  
  12569.                 "Default File Name     DEF.DAT"
  12570.  
  12571.  
  12572.  
  12573.          PopupSetEntryString() function
  12574.          ------------------------------
  12575.  
  12576.          How do you change the entry string?  One way is to fool
  12577.          around with the POPUP_MENU_PTR's structure members, and
  12578.          change the string yourself.  This is not recommended for the
  12579.          novice to average C programmer, since it is not a good idea
  12580.          to change the structure members directly without a full
  12581.          understanding of the structure.
  12582.  
  12583.          A safer way is to call the PopupSetEntryString() function.
  12584.          A prototype of this function is as follows:
  12585.  
  12586.          PopupSetEntryString(POPUP_MENU_PTR p, int entry,
  12587.                                 char *newstring)
  12588.  
  12589.          The first argument is the POPUP_MENU_PTR.  The second
  12590.          argument is the number of the entry that you wish to change.
  12591.          Entry numbers range from 0 to the highest entry in the menu
  12592.          less one.  The third argument is a pointer to the new
  12593.          character string.  The newstring cannot be longer than the
  12594.          current POPUP_MENU_ENTRY entry_name string.
  12595.  
  12596.          The return values are the same as the PopupEnableEntry()
  12597.          function defined above.
  12598.  
  12599.  
  12600.  
  12601.  
  12602.  
  12603.  
  12604.  
  12605.  
  12606.  
  12607.  
  12608.  
  12609.  
  12610.          Page 197          The C Window Library               Page 197
  12611.  
  12612.                         CHECKING MENU ENTRIES
  12613.                         ---------------------
  12614.  
  12615.          Menu entries can be checked or unchecked at any time.
  12616.          You usually check menu entries if one of the entries
  12617.          serves as an indicator to whether an option in your
  12618.          program is turned on or off.
  12619.  
  12620.  
  12621.  
  12622.          PopupCheckEntry()
  12623.          -----------------
  12624.  
  12625.          PopupCheckEntry() places or erases a check mark in the
  12626.          first character position of the menu.  You should define
  12627.          your menu strings so that the check mark can be placed
  12628.          properly without erasing any characters.  Here is the
  12629.          prototype:
  12630.  
  12631.          PopupCheckEntry(POPUP_MENU_PTR p, int entry, int flag)
  12632.  
  12633.          The first argument is the POPUP_MENU_PTR.
  12634.  
  12635.          The second argument is the number of the entry that you wish
  12636.          to check or uncheck.  Entry numbers range from 0 to the
  12637.          highest entry in the menu less one.
  12638.  
  12639.          The flag argument is TRUE if the entry is to be checked,
  12640.          or FALSE if the entry is to be unchecked.
  12641.  
  12642.  
  12643.          The return values are the same as the PopupEnableEntry()
  12644.          function defined above.
  12645.  
  12646.  
  12647.  
  12648.  
  12649.  
  12650.  
  12651.  
  12652.  
  12653.  
  12654.  
  12655.  
  12656.  
  12657.  
  12658.  
  12659.  
  12660.  
  12661.  
  12662.  
  12663.  
  12664.  
  12665.  
  12666.  
  12667.  
  12668.  
  12669.  
  12670.          Page 198          The C Window Library               Page 198
  12671.  
  12672.                         REDEFINING MENU KEYS
  12673.                         --------------------
  12674.  
  12675.  
  12676.          Setting Global Key Definitions and
  12677.          the popup_key_definition Array
  12678.          ----------------------------------
  12679.  
  12680.          You can redefine the keys used to control moving the
  12681.          highlight bar, accepting the menu choice, and exiting from
  12682.          the menu.  Here is a list of the default key mapping:
  12683.  
  12684.             Function                      Key      Constant
  12685.         ┌────────────────────────────┬──────────┬──────────────────────┐
  12686.         │ Move highlight bar up      │Up Arrow  │POPUP_UPKEY           │
  12687.         ├────────────────────────────┼──────────┼──────────────────────┤
  12688.         │ Move highlight bar down    │Down Arrow│POPUP_DOWNKEY         │
  12689.         ├────────────────────────────┼──────────┼──────────────────────┤
  12690.         │ Accept Menu Choice         │Enter     │POPUP_ACCEPTKEY       │
  12691.         ├────────────────────────────┼──────────┼──────────────────────┤
  12692.         │ Escape Pop-up menu         │Escape    │POPUP_QUITKEY         │
  12693.         ├────────────────────────────┼──────────┼──────────────────────┤
  12694.         │ Move To First Menu Item    │Home      │POPUP_HOMEKEY         │
  12695.         ├────────────────────────────┼──────────┼──────────────────────┤
  12696.         │ Move to Last Menu Item     │End       │POPUP_ENDKEY          │
  12697.         ├────────────────────────────┼──────────┼──────────────────────┤
  12698.         │ Scroll entries up by one   │          │                      │
  12699.         │ page                       │PgUp      │POPUP_PAGEUPKEY       │
  12700.         ├────────────────────────────┼──────────┼──────────────────────┤
  12701.         │ Scroll entries down by one │          │                      │
  12702.         │ page                       │PgDn      │POPUP_PAGEDOWNKEY     │
  12703.         ├────────────────────────────┼──────────┼──────────────────────┤
  12704.         │*Move To Next Popup Menu    │Unassigned│POPUP_RIGHTKEY        │
  12705.         ├────────────────────────────┼──────────┼──────────────────────┤
  12706.         │*Move to Previous Popup Menu│Unassigned│POPUP_LEFTKEY         │
  12707.         ├────────────────────────────┼──────────┼──────────────────────┤
  12708.         │*Escape Pulldown Menu       │Unassigned│POPUP_PULLDOWN_QUITKEY│
  12709.         └────────────────────────────┴──────────┴──────────────────────┘
  12710.  
  12711.          The global array popup_key_definition contains the values of
  12712.          the default popup menu key definitions.  The names under the
  12713.          Constant heading are the offsets in the popup_key_definition
  12714.          array of where the key value for the function is defined.
  12715.          For instance, the value for the "Move highlight bar up"
  12716.          function is located at popup_key_definition[POPUP_UPKEY].
  12717.          You can change the values in popup_key_definition at any
  12718.          time, but make sure that a definition for "Escape Pop-up
  12719.          menu" always exists, and that there are no duplicate
  12720.          definitions (i.e.  the "Move highlight bar up" key definition
  12721.          is the same as the "Move highlight bar down" key definition).
  12722.          When defining new key values, you should use the values
  12723.          defined in the cwlwin.h header file for non-ascii keys.
  12724.  
  12725.          * The POPUP_RIGHTKEY, POPUP_LEFTKEY, and the
  12726.            POPUP_PULLDOWN_QUITKEY definitions only apply to popup
  12727.            menus that are incorporated in a pulldown menu.  See the
  12728.            section on pulldown menus for more information.
  12729.  
  12730.          Page 199          The C Window Library               Page 199
  12731.  
  12732.          Setting Local Key Definitions
  12733.          -----------------------------
  12734.  
  12735.          Another way of redefining menu keys is to load your own array
  12736.          of key definitions with your desired values, and then calling
  12737.          the PopupAssignKeys() function.  With this method, each menu
  12738.          can have different key definitions.
  12739.  
  12740.  
  12741.  
  12742.          PopupAssignKeys() function
  12743.          --------------------------
  12744.  
  12745.          Here is a prototype of the PopupAssignKeys() function:
  12746.  
  12747.          int PopupAssignKeys(POPUP_MENU_PTR p, unsigned *keys)
  12748.  
  12749.          where p is the POPUP_MENU_PTR, and keys is an array of key
  12750.          definitions.  Here is a small code example:
  12751.  
  12752.  
  12753.          #include "cwlwin.h"
  12754.  
  12755.          unsigned mykeys[NUMPOPUPKEYS] = {CTRLU,CTRLD,RETURN,
  12756.  
  12757.                                        ESC,HOME,END,0,0,0,0};
  12758.          POPUP_MENU_PTR p;
  12759.  
  12760.          /* Other stuff...*/
  12761.  
  12762.          main()
  12763.          {
  12764.            /* Assume p is initialized */
  12765.  
  12766.            /* Assigns my key definitions to popup menu p */
  12767.            PopupAssignKeys(p,mykeys);
  12768.          }
  12769.  
  12770.          The constant NUMPOPUPKEYS should be used to make sure that
  12771.          your array of key definitions is large enough to hold all the
  12772.          definitions.   The above example uses the constants defined
  12773.          in cwlwin.h to assign to the array mykeys.  Each position
  12774.          in the mykeys array uses the default key mapping explained
  12775.          above.  In other words, mykeys[POPUP_UPKEY] is CTRLU, etc.
  12776.  
  12777.                 Return Values for PopupAssignKeys():
  12778.  
  12779.              Return Value        Definition
  12780.          ┌────────────────────┬───────────────────────────┐
  12781.          │NO_ERROR            │ No error occured.         │
  12782.          ├────────────────────┼───────────────────────────┤
  12783.          │POPUP_MENU_INVALID  │ Popup Menu does not exist.│
  12784.          └────────────────────┴───────────────────────────┘
  12785.  
  12786.  
  12787.  
  12788.  
  12789.  
  12790.          Page 200          The C Window Library               Page 200
  12791.  
  12792.                       PROCESSING UNDEFINED KEYS
  12793.                       -------------------------
  12794.  
  12795.          If you are an advanced programmer and/or have experience in
  12796.          using other window/menu libraries, you may be wondering "how
  12797.          do I define a function that supplies context-sensitive help
  12798.          for each POPUP_MENU_ENTRY?  There is no structure member in
  12799.          POPUP_MENU_ENTRY that supplies this".  With The C Window
  12800.          Library, any key that is not recognized by the menu manager
  12801.          (i.e. the key struck does not invoke a menu option, move the
  12802.          highlight bar up or down, or ends processing of the menu) can
  12803.          be processed by calling a user written function.   The
  12804.          WindowGet...() family of functions allowed us to define a
  12805.          function that will be called if a key that has no current
  12806.          definition is pressed.  For popup menus, we can do the same
  12807.          thing.
  12808.  
  12809.  
  12810.          The CWLpopup_undef_key_func function pointer
  12811.          --------------------------------------------
  12812.  
  12813.          The global function pointer, CWLpopup_undef_key_func, can
  12814.          point to a user written function that will be called when the
  12815.          menu manager encounters a key that is not defined.  The
  12816.          declaration for CWLpopup_undef_key_func is as follows:
  12817.  
  12818.          unsigned int (*CWLpopup_undef_key_func)(POPUP_MENU_PTR p,
  12819.                                                  int sel,
  12820.                                                  int *choice)
  12821.  
  12822.          The user written function takes three arguments.  The first
  12823.          argument is a pointer to the popup menu that the menu manager
  12824.          is currently processing. The second argument is an integer
  12825.          that contains the value of the key that was pressed.  The
  12826.          third argument is a pointer to an integer that will contain
  12827.          the number of the menu choice to execute.  Initially, choice
  12828.          points to an integer that contains the current menu choice
  12829.          that the menu highlight bar is situated.  For instance, if
  12830.          the highlight bar is on the first menu choice when an
  12831.          undefined key is pressed, *choice will be equal to 0.  If
  12832.          CWLpopup_undef_key_func is equal to a Null Function pointer
  12833.          (NULLFN), no user defined function is called.  By default,
  12834.          CWLpopup_undef_key_func is assigned to NULLFN.
  12835.  
  12836.  
  12837.          Values returned to menu manager
  12838.          -------------------------------
  12839.  
  12840.          If CWLpopup_undef_key_func is assigned to a function, the
  12841.          function must return an integer back to the menu manager.
  12842.          This integer value will tell the menu manager how to proceed.
  12843.          Here is a list of the valid return values that the user
  12844.          written function can return:
  12845.  
  12846.  
  12847.  
  12848.  
  12849.  
  12850.          Page 201          The C Window Library               Page 201
  12851.  
  12852.            Return                         Action to
  12853.            Value                            Take
  12854.          ┌─────────────────────┬────────────────────────────────────┐
  12855.          │ POPUP_CONTINUE      │No Action. Continue processing the  │
  12856.          │                     │popup menu.                         │
  12857.          ├─────────────────────┼────────────────────────────────────┤
  12858.          │ POPUP_MOVE_UP       │Move the highlight bar up.          │
  12859.          ├─────────────────────┼────────────────────────────────────┤
  12860.          │ POPUP_MOVE_DOWN     │Move the highlight bar down.        │
  12861.          ├─────────────────────┼────────────────────────────────────┤
  12862.          │ POPUP_DO_CHOICE     │Accept and invoke menu entry        │
  12863.          │                     │assigned to *choice.                │
  12864.          ├─────────────────────┼────────────────────────────────────┤
  12865.          │ POPUP_MOVE_CONTINUE │Move the highlight bar to menu entry│
  12866.          │                     │assigned to *choice and continue    │
  12867.          │                     │processing menu.                    │
  12868.          ├─────────────────────┼────────────────────────────────────┤
  12869.          │ POPUP_ESCAPE        │Escape the popup menu.              │
  12870.          ├─────────────────────┼────────────────────────────────────┤
  12871.          │ POPUP_MOVE_HOME     │Move highlight to first available   │
  12872.          │                     │menu entry.                         │
  12873.          ├─────────────────────┼────────────────────────────────────┤
  12874.          │ POPUP_MOVE_END      │Move highlight to last available    │
  12875.          │                     │menu entry.                         │
  12876.          ├─────────────────────┼────────────────────────────────────┤
  12877.          │ POPUP_MOVE_PAGEUP   │Scroll the entries in the popup     │
  12878.          │                     │window up by one "page" (a page is  │
  12879.          │                     │the current height of the popup     │
  12880.          │                     │window).                            │
  12881.          ├─────────────────────┼────────────────────────────────────┤
  12882.          │ POPUP_MOVE_PAGEDOWN │Scroll the entries in the popup     │
  12883.          │                     │window down by one "page" (a page is│
  12884.          │                     │the current height of the popup     │
  12885.          │                     │window).                            │
  12886.          ├─────────────────────┼────────────────────────────────────┤
  12887.          │*POPUP_MOVE_LEFT     │Move to next popup menu.            │
  12888.          ├─────────────────────┼────────────────────────────────────┤
  12889.          │*POPUP_MOVE_RIGHT    │Move to previous popup menu.        │
  12890.          ├─────────────────────┼────────────────────────────────────┤
  12891.          │*POPUP_PULLDOWN_QUIT │Escape pulldown menu                │
  12892.          └─────────────────────┴────────────────────────────────────┘
  12893.  
  12894.          A return value of POPUP_CONTINUE is a "do nothing" command to
  12895.          the menu manager.
  12896.  
  12897.          If POPUP_DO_CHOICE is returned to the menu manager, the
  12898.          integer assigned to the parameter *choice is used as the menu
  12899.          entry to invoke.  The highlight bar will automatically be
  12900.          moved to the menu choice specified, and the menu function
  12901.          will be called.  If POPUP_MOVE_CONTINUE is returned to the
  12902.          menu manager, the highlight bar will be moved to the entry
  12903.          specified by the value of *choice, but no function is called.
  12904.  
  12905.          Return values of POPUP_DO_CHOICE and POPUP_MOVE_CONTINUE only
  12906.          work when the menu entry specified by *choice is an available
  12907.  
  12908.  
  12909.  
  12910.          Page 202          The C Window Library               Page 202
  12911.  
  12912.          entry or the POPUPVERRIDE option is on , otherwise the menu
  12913.          manager just continues processing the popup menu.
  12914.  
  12915.  
  12916.          * The POPUP_MOVE_RIGHT, POPUP_MOVE_LEFT, and
  12917.            POPUP_PULLDOWN_QUIT only apply to popup menus that are
  12918.            incorporated in a pulldown menu system.  See the section on
  12919.            pulldown menus for more information.
  12920.  
  12921.          Here is an example of using a user defined function for the
  12922.          undefined keys:
  12923.  
  12924.  
  12925.          #include "cwlwin.h"
  12926.  
  12927.          /*  Other includes */
  12928.  
  12929.          int user_func();
  12930.  
  12931.          main()
  12932.  
  12933.          {
  12934.            CWLpopup_undef_key_func = user_func;
  12935.  
  12936.            /* Other code */
  12937.  
  12938.          }
  12939.  
  12940.          unsigned int user_func(POPUP_MENU_PTR p, int sel,
  12941.                                 int *choice)
  12942.          {
  12943.            switch(sel)
  12944.            {
  12945.              case F1:
  12946.                help(*choice);         /* call help function */
  12947.                return POPUP_CONTINUE; /* return "do nothing" */
  12948.              case F2:
  12949.                *choice = 6;  /* let menu manager know to do
  12950.                                 choice 7 on the menu */
  12951.                return POPUP_DO_CHOICE;  /* Also let menu manager
  12952.                                            know we are returning the
  12953.                                            "do the function assigned to
  12954.                                             *choice" command */
  12955.              default:
  12956.                return POPUP_CONTINUE;
  12957.                /* let menu manager know not to do anything */
  12958.            }
  12959.          }
  12960.  
  12961.          int help(int choice)
  12962.          {  /* help function */
  12963.            switch (choice)
  12964.            {
  12965.              case 0:
  12966.                /* do context-sensitive help for entry 0 */
  12967.              break;
  12968.  
  12969.  
  12970.          Page 203          The C Window Library               Page 203
  12971.  
  12972.              case 1:
  12973.                /* do context-sensitive help for entry 1 */
  12974.              break;
  12975.               /* do more entries */
  12976.               /* ... */
  12977.            }
  12978.          }
  12979.  
  12980.          In the above example, if the user hits F1, a help function is
  12981.          called.  If you wanted to know how to incorporate a help
  12982.  
  12983.          function in the popup menus, here is the way to do it.
  12984.  
  12985.          If the user hits F2, the integer pointed to by choice is
  12986.          assigned a 6, and user_func() returns POPUP_DO_CHOICE to the
  12987.          menu manager.  This tells the menu manager to invoke the
  12988.          function assigned to menu entry 7.
  12989.  
  12990.  
  12991.  
  12992.  
  12993.  
  12994.  
  12995.  
  12996.  
  12997.  
  12998.  
  12999.  
  13000.  
  13001.  
  13002.  
  13003.  
  13004.  
  13005.  
  13006.  
  13007.  
  13008.  
  13009.  
  13010.  
  13011.  
  13012.  
  13013.  
  13014.  
  13015.  
  13016.  
  13017.  
  13018.  
  13019.  
  13020.  
  13021.  
  13022.  
  13023.  
  13024.  
  13025.  
  13026.  
  13027.  
  13028.  
  13029.  
  13030.          Page 204          The C Window Library               Page 204
  13031.  
  13032.                          PRE-INPUT FUNCTION
  13033.                          ------------------
  13034.  
  13035.          With The C Window Library, you can define a function that
  13036.          will be performed just before the menu manager waits for the
  13037.          user to enter a keystroke.  This function can perform just
  13038.          about anything.
  13039.  
  13040.  
  13041.          Setting the CWLglobal_popup_prefunc function pointer
  13042.          -------------------------------------------------
  13043.  
  13044.          The CWLglobal_popup_prefunc function pointer points to this user
  13045.          written function.  Here is the prototype:
  13046.  
  13047.          int (*CWLglobal_popup_prefunc)(POPUP_MENU_PTR p, int *sel)
  13048.  
  13049.          The arguments that will be passed to your function are the
  13050.          following:
  13051.  
  13052.          a)  The POPUP_MENU_PTR of the popup menu that called your
  13053.              function, and
  13054.  
  13055.          b)  A pointer to the number of the selection that the
  13056.              highlight bar is currently on.
  13057.  
  13058.          The selection number ranges from 1 to the highest entry
  13059.          number of the menu.
  13060.  
  13061.          The pre-input function MUST return a value back to the menu
  13062.          manager.  The return values that can be returned are the same
  13063.          as the CWLpopup_undef_key_func function described above.  If
  13064.          you are using a version of The C Window Library prior to
  13065.          version 1.5, you must declare your pre-input function as
  13066.          returning an int, and you must return a value back to the
  13067.          menu manager.  Versions prior to 1.5 declared the pre-input
  13068.          function as void.
  13069.  
  13070.          The POPUP_DO_CHOICE and POPUP_MOVE_CONTINUE return values
  13071.          will move the highlight bar to the entry number that is
  13072.          assigned to the *sel argument when the pre-input function has
  13073.          returned.
  13074.  
  13075.          By default, CWLglobal_popup_prefunc points to a NULLFN, and
  13076.          therefore will not be performed.  However, you can implement
  13077.          pre-input functions depending on the current selection.  For
  13078.          instance, you can write a function that displays extra
  13079.          information for each entry like so:
  13080.  
  13081.          #include "cwlwin.h"
  13082.  
  13083.          char *mess[] = {
  13084.                 " This option saves and loads files",
  13085.                 " This brings you in edit mode",
  13086.                 " This compiles and/or links the current program",
  13087.                /* ... More stuff */
  13088.                         };
  13089.  
  13090.          Page 205          The C Window Library               Page 205
  13091.  
  13092.          WPOINTER message_window;
  13093.  
  13094.          int disp_info();
  13095.  
  13096.          main()
  13097.  
  13098.         {
  13099.            /* ... */
  13100.  
  13101.            CWLglobal_popup_prefunc = disp_info;
  13102.  
  13103.            /* ... */
  13104.          }
  13105.  
  13106.          int disp_info(POPUP_MENU_PTR p, int *sel)
  13107.          {
  13108.           /* Assume message_window already created and opened */
  13109.            WindowClear(message_window,
  13110.                        CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  13111.            WindowWriteString(message_window,mess[*sel],0,0);
  13112.            return POPUP_CONTINUE;
  13113.          }
  13114.  
  13115.  
  13116.          For simplicity, the menu definitions are left out of the
  13117.          preceding code sample.  The disp_info displays the
  13118.          appropriate description in the window message_window.
  13119.          POPUP_CONTINUE is returned to the menu manager.  This informs
  13120.          the menu manager to continue looking for a keystroke.
  13121.  
  13122.  
  13123.  
  13124.  
  13125.  
  13126.  
  13127.  
  13128.  
  13129.  
  13130.  
  13131.  
  13132.  
  13133.  
  13134.  
  13135.  
  13136.  
  13137.  
  13138.  
  13139.  
  13140.  
  13141.  
  13142.  
  13143.  
  13144.  
  13145.  
  13146.  
  13147.  
  13148.  
  13149.  
  13150.          Page 206          The C Window Library               Page 206
  13151.  
  13152.                       DISPOSING OF POPUP MENUS
  13153.                       ------------------------
  13154.  
  13155.  
  13156.          PopupMenuClose()
  13157.          ----------------
  13158.  
  13159.          If the popup menu is no longer needed, the PopupMenuClose()
  13160.          function will dispose of the popup menu and return any memory
  13161.          allocated to the popup menu, window, and virtual window
  13162.          memory back to the heap.  The call to the function is very
  13163.          simple:
  13164.  
  13165.                 PopupMenuClose(POPUP_MENU_PTR p)
  13166.  
  13167.          where p is the POPUP_MENU_PTR to dispose of.  Since this
  13168.          function destroys the POPUP_MENU_PTR p, p must not be used
  13169.          for any popup menu functions, unless p is pointing to a valid
  13170.          POPUP_MENU_PTR.  For any menus that may be embedded in p,
  13171.          they are destroyed as well.
  13172.  
  13173.  
  13174.          The return values and the reasons for failure are the same as
  13175.          PopupSelectMenu().
  13176.  
  13177.  
  13178.  
  13179.  
  13180.  
  13181.  
  13182.  
  13183.  
  13184.  
  13185.  
  13186.  
  13187.  
  13188.  
  13189.  
  13190.  
  13191.  
  13192.  
  13193.  
  13194.  
  13195.  
  13196.  
  13197.  
  13198.  
  13199.  
  13200.  
  13201.  
  13202.  
  13203.  
  13204.  
  13205.  
  13206.  
  13207.  
  13208.  
  13209.  
  13210.          Page 207          The C Window Library               Page 207
  13211.  
  13212.                               BAR MENUS
  13213.                               ---------
  13214.  
  13215.  
  13216.          Description
  13217.          -----------
  13218.  
  13219.          A bar menu is a horizontal menu with a list of entries that
  13220.          are selected by placing a highlight bar on the entry and
  13221.          pressing return, releasing the left mouse button, or pressing
  13222.          a key that will automatically move the highlight bar to the
  13223.          desired entry and invoking the entry.  You can have up to
  13224.          32,767 entries in a bar menu.  A bar menu consists of only a
  13225.          window, unlike popup menus which use virtual windows.
  13226.  
  13227.  
  13228.  
  13229.  
  13230.  
  13231.  
  13232.  
  13233.  
  13234.  
  13235.  
  13236.  
  13237.  
  13238.  
  13239.  
  13240.  
  13241.  
  13242.  
  13243.  
  13244.  
  13245.  
  13246.  
  13247.  
  13248.  
  13249.  
  13250.  
  13251.  
  13252.  
  13253.  
  13254.  
  13255.  
  13256.  
  13257.  
  13258.  
  13259.  
  13260.  
  13261.  
  13262.  
  13263.  
  13264.  
  13265.  
  13266.  
  13267.  
  13268.  
  13269.  
  13270.          Page 208          The C Window Library               Page 208
  13271.  
  13272.                          CREATING BAR MENUS
  13273.                          ------------------
  13274.  
  13275.  
  13276.  
  13277.          The BarCreateMenu() function
  13278.          ----------------------------
  13279.  
  13280.          To initialize a bar menu, the BarCreateMenu() function is
  13281.          used.  This function creates an empty bar menu.  Adding
  13282.          entries to the menu will be discussed in the next section.
  13283.          Here is the prototype:
  13284.  
  13285.          BAR_MENU_PTR BarCreateMenu(WPOINTER parent,
  13286.                                     unsigned options, unsigned bcolor,
  13287.                                     int row, int col, int width)
  13288.  
  13289.          The parent argument is a pointer to the window that
  13290.          will be the parent of the bar menu window.  If the menu is
  13291.          to have no parent, this argument should be DESKTOP_WINDOW.
  13292.  
  13293.          The options argument denotes options that are used to turn on
  13294.          various aspect of a bar menu.
  13295.  
  13296.          The options are as follows:
  13297.  
  13298.              Option          Definition
  13299.          ┌────────────┬────────────────────────────────────────────┐
  13300.          │BARCREATWIN │Allows BarCreateMenu() to create a window.  │
  13301.          │            │Once this window is created, it is attached │
  13302.          │            │to the menu and will be used for displaying │
  13303.          │            │the menu entries.  The menu window is       │
  13304.          │            │defaulted to have a border consisting of    │
  13305.          │            │single lines.  This option should always be │
  13306.          │            │used unless you have a window that you have │
  13307.          │            │created that you would like to use.  Any    │
  13308.          │            │user-defined windows must be attached to    │
  13309.          │            │the menu by calling BarAttachWindow()       │
  13310.          │            │before any entries can be added.  However,  │
  13311.          │            │you can change the characteristics of the   │
  13312.          │            │default window by getting the window        │
  13313.          │            │pointer and applying any of the Window...() │
  13314.          │            │functions to it.                            │
  13315.          ├────────────┼────────────────────────────────────────────┤
  13316.          │BARWRAP     │Allows the menu highlight bar to wrap to    │
  13317.          │            │the first entry if the user moves the menu  │
  13318.          │            │highlight bar past the last entry, and will │
  13319.          │            │wrap to the last entry if the highlight bar │
  13320.          │            │is moved before the first entry.            │
  13321.          ├────────────┼────────────────────────────────────────────┤
  13322.          │BARSTATIC   │Allows the menu to be displayed while the   │
  13323.          │            │user-defined menu function is invoked.      │
  13324.          └────────────┴────────────────────────────────────────────┘
  13325.  
  13326.  
  13327.  
  13328.  
  13329.  
  13330.          Page 209          The C Window Library               Page 209
  13331.  
  13332.              Option          Definition
  13333.          ┌──────────────┬────────────────────────────────────────────┐
  13334.          │BARDISPLAY    │Allows the menu to be displayed after       │
  13335.          │              │processing the entries for a menu.          │
  13336.          │              │Normally, when the BarSelectMenu() function │
  13337.          │              │is called to start the selection process of │
  13338.          │              │the menu, (this will be discussed later),   │
  13339.          │              │the menu is invoked, and selections can be  │
  13340.          │              │made from the menu.  When the               │
  13341.          │              │BarSelectMenu() function exits, the menu is │
  13342.          │              │hidden from the screen. If the BARDISPLAY   │
  13343.          │              │option is on, the menu will still be        │
  13344.          │              │displayed on exit, but no selections can be │
  13345.          │              │made from it.                               │
  13346.          ├──────────────┼────────────────────────────────────────────┤
  13347.          │BARENHANCEDKEY│Allows the processing of enhanced keys in a │
  13348.          │              │menu.  The enhanced keys are the F11 and    │
  13349.          │              │F12 keys, as well as grey keys used on      │
  13350.          │              │enhanced keyboards.                         │
  13351.          └──────────────┴────────────────────────────────────────────┘
  13352.  
  13353.          The options described above can be combined with a bitwise
  13354.          OR operator.
  13355.  
  13356.          The bcolor argument is an array of menu colors used to color
  13357.          different parts of the menu.  An array of type unsigned int
  13358.          is used to define the colors used in a bar menu.  Each
  13359.          element in the array denote a certain area of the bar menu.
  13360.          A list of the constants used to define these areas as well as
  13361.          their definitions is as follows:
  13362.  
  13363.  
  13364.          Menu Color    Constant     Definition
  13365.          ┌──────────────┬───┬───────────────────────────────────┐
  13366.          │ENTRYCOLOR    │ 0 │Color of the text area of the      │
  13367.          │              │   │bar menu's window.                 │
  13368.          ├──────────────┼───┼───────────────────────────────────┤
  13369.          │BORDERCOLOR   │ 1 │Color of the border of the bar     │
  13370.          │              │   │menu's window.                     │
  13371.          ├──────────────┼───┼───────────────────────────────────┤
  13372.          │HOTKEYCOLOR   │ 2 │Color of each menu entry's hotkey  │
  13373.          │              │   │character.                         │
  13374.          ├──────────────┼───┼───────────────────────────────────┤
  13375.          │HIGHLIGHTCOLOR│ 3 │Color of a highlighted entry.      │
  13376.          │              │   │This is effectively the color of   │
  13377.          │              │   │an entry when the highlight bar is │
  13378.          │              │   │over the entry.                    │
  13379.          ├──────────────┼───┼───────────────────────────────────┤
  13380.          │UNAVAILCOLOR  │ 4 │Color of the unavailable entries.  │
  13381.          │              │   │In CWL, you can make entries       │
  13382.          │              │   │unavailable (the highlight bar     │
  13383.          │              │   │skips over these entries).         │
  13384.          └──────────────┴───┴───────────────────────────────────┘
  13385.  
  13386.          Colors can be created using the CREATE_VIDEO_ATTRIBUTE()
  13387.          macro.
  13388.  
  13389.  
  13390.          Page 210          The C Window Library               Page 210
  13391.  
  13392.          The row and col arguments denote where the bar menu window
  13393.          will be placed within the parent.
  13394.  
  13395.          The width argument is the width of the bar menu window if
  13396.          BARCREATEWIN option is used.
  13397.  
  13398.          The return value is a pointer to a structure called a
  13399.          BAR_MENU_PTR.  This pointer is used to identify the bar
  13400.          menu and is used in any subsequent functions that manipulate
  13401.          the bar menu.  If the BAR_MENU_PTR is NULL the menu could
  13402.          not be created and CWLerror_code is set to NO_HEAP_MEM.
  13403.  
  13404.  
  13405.          Example:
  13406.  
  13407.          #include "cwlwin.h"
  13408.          unsigned int menu_colors[NUMBARCOLORS];
  13409.          BAR_MENU_PTR b;
  13410.  
  13411.          main() {
  13412.            /* ... */
  13413.            ...
  13414.            menu_color[ENTRYCOLOR]  =
  13415.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  13416.            menu_color[BORDERCOLOR]=
  13417.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  13418.            menu_color[HOTKEYCOLOR]  =
  13419.                 CREATE_VIDEO_ATTTRIBUTE(BLUE_WHITE_);
  13420.            menu_color[HIGHLIGHTCOLOR]  =
  13421.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  13422.            menu_color[UNAVAILCOLOR]=
  13423.                 CREATE_VIDEO_ATTTRIBUTE(BLACK_WHITE_);
  13424.  
  13425.            b = BarCreateMenu(DESKTOP_WINDOW,BARCREATEWIN,
  13426.                              menu_color,0,0,50);
  13427.            if (b == BAR_NULL_PTR)
  13428.            {
  13429.              /* bar window could not be created */
  13430.            } ...
  13431.          }
  13432.  
  13433.  
  13434.          The example above shows an array of menu colors called
  13435.          menu_colors initialized with the color scheme that the menu
  13436.          will use.  The constant NUMBARCOLORS is defined in cwlwin.h
  13437.          and should be used to determine the size of the color array.
  13438.          Next, the BAR_MENU_PTR b is initialized in the
  13439.          BarCreateMenu() function.  If the menu could not be
  13440.          created, b will be a NULL pointer, which is denoted by
  13441.          BAR_NULL_PTR.
  13442.  
  13443.  
  13444.  
  13445.  
  13446.  
  13447.  
  13448.  
  13449.  
  13450.          Page 211          The C Window Library               Page 211
  13451.  
  13452.          Creating Bar Menu Entries
  13453.          -------------------------
  13454.  
  13455.          Now that the menu has been created with BarCreateMenu(), it
  13456.          is now necessary to fill in our menu entries in the menu.
  13457.  
  13458.          Here are a list of the functions that allow the creation and
  13459.          deletion of menu entries.  Here is the prototype:
  13460.  
  13461.           int BarInsertEntry(BAR_MENU_PTR b, int type, int where,
  13462.                                char *entry_string, int menuid,
  13463.                                BARSELECTPROC barproc)
  13464.  
  13465.           int BarAppendEntry(BAR_MENU_PTR b, int type,
  13466.                                char *entry_string, int menuid,
  13467.                                BARSELECTPROC barproc)
  13468.  
  13469.  
  13470.  
  13471.          The b argument is the BAR_MENU_PTR to the bar menu.
  13472.  
  13473.          The where argument for the BarInsertEntry() function
  13474.          denotes the place in the menu where the entry will be
  13475.          inserted.  The entry is inserted before the entry denoted by
  13476.          the where argument the entry where.  Entries are numbered
  13477.          starting from 0.
  13478.  
  13479.          The type argument denotes the menu entry type.  The different
  13480.          types are as follows:
  13481.  
  13482.           Menu Type           Definition
  13483.          ┌─────────────┬─────────────────────────────────────────┐
  13484.          │CWL_MSTRING  │Denotes that the entry is a character    │
  13485.          │             │string.                                  │
  13486.          ├─────────────┼─────────────────────────────────────────┤
  13487.          │CWL_MDISABLED│The entry is initially disabled.  This   │
  13488.          │             │option only works with CWL_MSTRING types.│
  13489.          ├─────────────┼─────────────────────────────────────────┤
  13490.          │CWL_MENABLED │The entry is initially enabled.  This    │
  13491.          │             │option can be omitted when creating      │
  13492.          │             │entries since this is the default if     │
  13493.          │             │CWL_MDISABLED is not set.                │
  13494.          ├─────────────┼─────────────────────────────────────────┤
  13495.          │CWL_MGRAYED  │ The menu item is initially grayed and   │
  13496.          │             │disabled.  This differs from             │
  13497.          │             │CWL_MDISABLED in that the entry is only  │
  13498.          │             │disabled in this option.  It is          │
  13499.          │             │advantageous to use this option rather   │
  13500.          │             │than CWL_MDISABLED since it is more than │
  13501.          │             │likely that disabled entries are also    │
  13502.          │             │grayed.  The actual disabling color may  │
  13503.          │             │not really be gray, but whatever the     │
  13504.          │             │UNAVAILCOLOR color was when the bar      │
  13505.          │             │menu was created with BarCreateMenu().   │
  13506.          └─────────────┴─────────────────────────────────────────┘
  13507.  
  13508.  
  13509.  
  13510.          Page 212          The C Window Library               Page 212
  13511.  
  13512.          The entry_string argument is the menu string that is
  13513.          displayed in the menu.  The ampersand character (&) in the
  13514.          menu string denotes that the next character is to be used as
  13515.          a hotkey.  A hotkey will invoke a menu entry just be typing a
  13516.          key instead of moving the highlight to the entry and pressing
  13517.          enter.  For example, if the entry string is " &Load ", the
  13518.          'L' is considered as the hotkey.  If you desire an ampersand
  13519.          character in the entry string, use two consecutive ampersand
  13520.          characters.  If there are duplicate hotkeys in a menu, the
  13521.          menu entry that is closest to the first entry in the list is
  13522.          invoked.  If the entry string is to be checked, the first
  13523.          character should be a blank or space character, since this
  13524.          position is where the check mark will be placed.
  13525.  
  13526.          The menuid argument is an optional integer that the
  13527.          programmer can use for any purpose.  This value will be used
  13528.          in a future version of CWL when full event-driven menus will
  13529.          be implemented.
  13530.  
  13531.          The barproc argument is a user-defined function that is
  13532.          invoked when a menu entry is selected.  The barproc function
  13533.          must have the following prototype:
  13534.  
  13535.                 int barproc(BAR_MENU_PTR bCurrent, int selection)
  13536.  
  13537.          The bCurrent argument is a pointer to the menu that invoked
  13538.          the function.  The selection argument is the entry that was
  13539.          selected.  For instance, if the first menu entry was
  13540.          selected, selection is 0.
  13541.  
  13542.          BarAppendEntry() always places menu entries at the end of
  13543.          the list of defined  menu entries.
  13544.  
  13545.  
  13546.                 Return Values for BarAppendEntry() and
  13547.                 BarInsertEntry():
  13548.  
  13549.              Return Value        Definition
  13550.          ┌───────────────────┬───────────────────────────┐
  13551.          │NO_ERROR           │ No error occured.         │
  13552.          ├───────────────────┼───────────────────────────┤
  13553.          │BAR_MENU_INVALID   │ Bar Menu does not exist.  │
  13554.          ├───────────────────┼───────────────────────────┤
  13555.          │NO_HEAP_MEM        │ Not enough memory to      │
  13556.          │                   │ allocate for the entry.   │
  13557.          ├───────────────────┼───────────────────────────┤
  13558.          │WINDOW_NOT_ATTACHED│ returned if the menu does │
  13559.          │                   │ not have an attached      │
  13560.          │                   │ window.                   │
  13561.          └───────────────────┴───────────────────────────┘
  13562.  
  13563.          Example:
  13564.  
  13565.          #include "cwlwin.h"
  13566.          unsigned int menu_colors[NUMBARCOLORS];
  13567.          BAR_MENU_PTR b;
  13568.          int myproc(BAR_MENU_PTR, int);  /* Call back function */
  13569.  
  13570.          Page 213          The C Window Library               Page 213
  13571.  
  13572.  
  13573.          main()
  13574.          { /* ... */
  13575.               ...
  13576.            menu_color[ENTRYCOLOR]  =
  13577.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  13578.            menu_color[BORDERCOLOR]=
  13579.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  13580.            menu_color[HOTKEYCOLOR]  =
  13581.                 CREATE_VIDEO_ATTRIBUTE(BLUE_WHITE_);
  13582.            menu_color[HIGHLIGHTCOLOR]  =
  13583.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  13584.            menu_color[UNAVAILCOLOR]=
  13585.                 CREATE_VIDEO_ATTRIBUTE(BLACK_WHITE_);
  13586.  
  13587.            b =  BarCreateMenu(DESKTOP_WINDOW, BARCREATEWIN,
  13588.                               menu_color,0,0, 50);
  13589.  
  13590.            if (b == BAR_NULL_PTR)
  13591.            {
  13592.              /* bar window could not be created */
  13593.              exit(0);
  13594.            }
  13595.  
  13596.            /* Append a entry item to the menu */
  13597.            BarAppendEntry(b, CWL_MSTRING,"Menu Item 2",0,myproc);
  13598.  
  13599.            /* Insert an entry before the first entry.  This entry is
  13600.               also grayed and disabled */
  13601.            BarInsertEntry(b,CWL_MSTRING | CWL_MGRAYED,0,
  13602.                             "Menu Item 1",0,myproc);
  13603.  
  13604.            /* Append a entry item to the menu */
  13605.            BarAppendEntry(b, CWL_MSTRING,"Menu Item 3",0,myproc);
  13606.  
  13607.            /* Insert an entry before the separator. */
  13608.            BarInsertEntry(b,CWL_MSTRING | CWL_MGRAYED,0,
  13609.                             "Menu Item 1",2,myproc);
  13610.  
  13611.            ...
  13612.          }
  13613.  
  13614.  
  13615.          The example above creates a bar menu called b. Five entries
  13616.          are placed on the menu.   The first entry is placed inside
  13617.          the menu with the BarAppendEntry() function.  The second
  13618.          entry is placed using the BarInsertEntry(), and is inserted
  13619.          before the first entry.
  13620.  
  13621.  
  13622.  
  13623.  
  13624.  
  13625.  
  13626.  
  13627.  
  13628.  
  13629.  
  13630.          Page 214          The C Window Library               Page 214
  13631.  
  13632.          Inserting Multiple Entries
  13633.          --------------------------
  13634.  
  13635.          You can insert multiple entries by calling the
  13636.          BarInsertMultEntries() and BarAppendMultEntries()
  13637.          functions.  These function require that an array of
  13638.          structures called BAR_MENU_ENTRY's are filled in with the
  13639.          desired values.  The layout of this structure is defined as
  13640.          follows:
  13641.  
  13642.          typedef struct tagBARENTRY  {
  13643.                  char *entry_name;
  13644.                  unsigned int menuid;
  13645.                  unsigned int type;
  13646.                  BARSELECTPROC barproc;
  13647.          } BAR_MENU_ENTRY;
  13648.  
  13649.          The entry_name, menuid, type and barproc members are the same
  13650.          as the corresponding names used in the BarInsertEntry() and
  13651.          BarAppendEntry().
  13652.  
  13653.          The prototypes for BarInsertMultEntries() and
  13654.          BarAppendMultEntries() are as follows:
  13655.  
  13656.          int BarInsertMultEntries(BAR_MENU_PTR b, int where,
  13657.                                     BAR_MENU_ENTRY *bentry,
  13658.                                     int numentries)
  13659.  
  13660.          int BarAppendMultEntries(BAR_MENU_PTR b,
  13661.                                     BAR_MENU_ENTRY *bentry,
  13662.                                     int numentries)
  13663.  
  13664.          The b argument is the pointer to the bar menu.
  13665.  
  13666.          The where argument is analogous to the where argument for the
  13667.          BarInsertEntry() function defined in the previous section.
  13668.          The where argument denotes the position in the menu where the
  13669.          entries will be inserted.  This argument is pertinent only to
  13670.          the BarInsertMultEntries() function.
  13671.  
  13672.          The bentry argument is the array of BAR_MENU_ENTRY's to be
  13673.          inserted.
  13674.  
  13675.          The numentries argument is the number of BAR_MENU_ENTRY's
  13676.          to insert.
  13677.  
  13678.          The BarAppendMultEntries() always places the menu entries
  13679.          at the end of the bar menu.
  13680.  
  13681.  
  13682.          The return values for BarAppendMultEntries() and
  13683.          BarInsertMultEntries() is the same as BarInsertEntry()
  13684.          defined above.
  13685.  
  13686.  
  13687.  
  13688.  
  13689.  
  13690.          Page 215          The C Window Library               Page 215
  13691.  
  13692.  
  13693.          Example:
  13694.  
  13695.          #include "cwlwin.h"
  13696.  
  13697.            /* Define menu function */
  13698.          int menu_func(BAR_MENU_PTR, int);
  13699.  
  13700.          /* Set up array of BAR_MENU_ENTRY's */
  13701.  
  13702.          main()
  13703.          {
  13704.           ...
  13705.            /* Assume initialization has been done */
  13706.            b = BarCreateMenu( /* Arguments */);
  13707.  
  13708.            /* Insert the entries (there are 8 of them) */
  13709.            BarInsertMultEntries(b,0,menu_items,8);
  13710.  
  13711.            /* ... */
  13712.          }
  13713.  
  13714.          The example above sets up an array of BAR_MENU_ENTRY called
  13715.          menu_items, with each element filled in with the information
  13716.          desired.  The BarInsertMultEntries() function inserts all
  13717.          ten entries into the bar menu.
  13718.  
  13719.  
  13720.  
  13721.          Deleting Menu Entries
  13722.          ---------------------
  13723.  
  13724.          Deleting many entries is easily accomplished by calling the
  13725.          BarDeleteEntry() and BarDeleteMultEntries() functions.
  13726.          The entries can be separator entries, string entries,
  13727.          or embedded bar menus.  Here are the prototypes to these
  13728.          functions:
  13729.  
  13730.          int BarDeleteEntry(BAR_MENU_PTR b, int where)
  13731.  
  13732.          int BarDeleteMultEntries(BAR_MENU_PTR b, int where, int num)
  13733.  
  13734.          The argument b is the pointer to the bar menu.
  13735.  
  13736.          The where argument denotes the position of the menu entry to
  13737.          delete.  For the BarDeleteMultEntries() function, this
  13738.          position denotes the first menu item to delete.  If where is
  13739.          -1, the last entry is deleted.
  13740.  
  13741.          The num argument in the BarDeleteMultEntries() function is
  13742.          the number of entries to delete starting from position where.
  13743.  
  13744.          If an embedded bar menu is deleted, the embedded menu is
  13745.          still available for use as either a stand-alone bar menu,
  13746.          or can be embedded in another window.
  13747.  
  13748.  
  13749.  
  13750.          Page 216          The C Window Library               Page 216
  13751.  
  13752.                 Return Values for BarDeleteEntry() and
  13753.                 BarDeleteMultEntries():
  13754.  
  13755.              Return Value        Definition
  13756.          ┌───────────────────┬───────────────────────────┐
  13757.          │NO_ERROR           │ No error occured.         │
  13758.          ├───────────────────┼───────────────────────────┤
  13759.          │BAR_MENU_INVALID   │ Bar Menu does not exist.  │
  13760.          ├───────────────────┼───────────────────────────┤
  13761.          │MENU_ENTRY_INVALID │ Entry number is invalid.  │
  13762.          └───────────────────┴───────────────────────────┘
  13763.  
  13764.          Example:
  13765.  
  13766.          #include "cwlwin.h"
  13767.  
  13768.          BAR_MENU_ENTRIES menu_items[] = {  /* Fill in entries */ };
  13769.  
  13770.          main()
  13771.          {
  13772.            BAR_MENU_PTR b;
  13773.            ... /* Assume initialization has been done and entries were
  13774.                 created*/
  13775.  
  13776.            b = BarCreateMenu( /* Arguments */);
  13777.  
  13778.            /* Insert the entries */
  13779.            BarInsertMultEntries(b,0,menu_items,3);
  13780.  
  13781.            /* Delete the first entry */
  13782.            BarDeleteEntry(b,0)
  13783.  
  13784.            /* ... */
  13785.          }
  13786.  
  13787.  
  13788.  
  13789.  
  13790.  
  13791.  
  13792.  
  13793.  
  13794.  
  13795.  
  13796.  
  13797.  
  13798.  
  13799.  
  13800.  
  13801.  
  13802.  
  13803.  
  13804.  
  13805.  
  13806.  
  13807.  
  13808.  
  13809.  
  13810.          Page 217          The C Window Library               Page 217
  13811.  
  13812.                      SELECTING FROM BAR MENUS
  13813.                      ------------------------
  13814.  
  13815.          We have now created the bar menu.  Now how do we get the
  13816.          menu manager to act on our bar window?  The answer is the
  13817.          BarSelectMenu() function.
  13818.  
  13819.  
  13820.          BarSelectMenu() function
  13821.          ------------------------
  13822.  
  13823.          The BarSelectMenu() function displays the bar window, and
  13824.          allows the user to move the highlight bar until he/she has
  13825.          placed the bar on the desired option, or the user presses a
  13826.          hotkey to invoke one of the entries.
  13827.  
  13828.          Before the call to the BarSelectMenu(), nothing has been
  13829.          displayed.  This means that you can resize the bar window,
  13830.          change borders, write strings to the bar menus virtual
  13831.          window, insert and delete entries etc. while everything is
  13832.          hidden away from view.  The only time when the bar menu is
  13833.          displayed is when the call to BarSelectMenu() is made (or
  13834.          unless you have displayed the bar window yourself using
  13835.          WindowDisplay()). The prototype of the call to
  13836.          BarSelectMenu() is as follows:
  13837.  
  13838.          int BarSelectMenu(BAR_MENU_PTR b, int rank, int start)
  13839.  
  13840.          The first argument is the BAR_MENU_PTR.  The second argument
  13841.          is the rank of the bar window.  As with other windows, the
  13842.          rank determines how the window will be situated on the screen
  13843.          with respect to the other windows.  The last argument is the
  13844.          number of the menu entry of where the highlight bar should be
  13845.          situated.  Usually this is 0, but this will give you the
  13846.          option to start on any one of the menu entries.  If the start
  13847.          value is out of bounds (say you have specified start to be 5
  13848.          while there are only 5 menu entries) the menu manager will
  13849.          default to the first menu option.
  13850.  
  13851.          Now let's put everything together:
  13852.  
  13853.            /* Define menu function */
  13854.          int menu_func(BAR_MENU_PTR, int);
  13855.  
  13856.          /* Set up array of BAR_MENU_ENTRY's */
  13857.          BAR_MENU_ENTRY bar_items[] = {
  13858.                            {"&File",0,CWL_MSTRING,menu_func},
  13859.                            {"&Edit",0,CWL_MSTRING,menu_func},
  13860.                            {"&Run", 0,CWL_MSTRING,menu_func},
  13861.                            {"&Compile",0,CWL_MSTRING,menu_func},
  13862.                            {"&Project",0,CWL_MSTRING,menu_func},
  13863.                            {"&Options", 0,CWL_MSTRING,menu_func},
  13864.                            {"&Debug",0,CWL_MSTRING,menu_func},
  13865.                            {"&Break/watch",0,CWL_MSTRING,menu_func}
  13866.                          };
  13867.  
  13868.  
  13869.  
  13870.          Page 218          The C Window Library               Page 218
  13871.  
  13872.          unsigned int menu_colors[5];
  13873.          BAR_MENU_PTR b;
  13874.  
  13875.          main()
  13876.          {
  13877.            WindowInitializeSystem();
  13878.            WindowInitDesktop(0);
  13879.           /* define colors */
  13880.            menu_colors[ENTRYCOLOR] =
  13881.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_);
  13882.            menu_colors[BORDERCOLOR] =
  13883.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_);
  13884.            menu_colors[HOTKEYCOLOR] =
  13885.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLUE_);
  13886.            menu_colors[HIGHLIGHTCOLOR] =
  13887.                   CREATE_VIDEO_ATTRIBUTE(CYAN_,BLACK_);
  13888.            menu_colors[UNAVAILCOLOR] =
  13889.                   CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_);
  13890.  
  13891.           /* create a BAR_MENU_PTR */
  13892.            b =  BarCreateMenu(DESKTOP_WINDOW, BARCREATEWIN,
  13893.                               BARRESIZEALL, menu_color,0,0);
  13894.  
  13895.           /* insert the entries */
  13896.            BarInsertMultEntries(b,0,menu_items,8);
  13897.  
  13898.           /* get menu selections */
  13899.            BarSelectMenu(b,  /* BAR_MENU_PTR */
  13900.                             1,  /* rank of bar window */
  13901.                             0   /* menu entry to start on */
  13902.                            );
  13903.          }
  13904.  
  13905.          int menu_func(BAR_MENU_PTR b, int which)
  13906.          {
  13907.            WPOINTER w;
  13908.            w = WindowInitialize(DESKTOP_WINDOW, BORDER,15,15,40,4,
  13909.                                 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_),
  13910.                                 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_),
  13911.                                 SINGLEBOX);
  13912.            WindowClear(w);
  13913.            WindowPrintf(w,"You have selected %s",
  13914.                         BAR_ENTRY_STRING(b,which));
  13915.            WindowWriteCenterString(w,"Press a key to continue",3);
  13916.            WindowDisplay(w,1,NOEFFECT);
  13917.            GET_KEY();
  13918.            return BAR_CONTINUE;
  13919.  
  13920.          }
  13921.  
  13922.          The above example has a call to BarSelectMenu().  The
  13923.          arguments passed are b as the BAR_MENU_PTR, a window rank
  13924.          of 1, and a starting position of 0.  The BAR_ENTRY_STRING()
  13925.          macro in the menu_func() function returns the entry string
  13926.          for the particualr menu entry.  The first argument is the
  13927.          BAR_MENU_PTR and the second argument is the entry number.
  13928.  
  13929.  
  13930.          Page 219          The C Window Library               Page 219
  13931.  
  13932.          Values passed to menu function
  13933.          ------------------------------
  13934.  
  13935.          When a selection is made, the menu manager will call the
  13936.          function defined for the selection, and pass two arguments to
  13937.          this function.  The first argument passed is the
  13938.          BAR_MENU_PTR of the current bar menu and the second
  13939.          argument is the number of the entry selected.  Entry numbers
  13940.          are numbered from 0 to the highest entry in the menu, less
  13941.          one.  For example, if the " Load " entry is selected, the
  13942.          menu manager will pass the BAR_MENU_PTR b, and a 1 to
  13943.          func().  If " Pick " is chosen, the menu manager passes
  13944.          a 2 as the second argument to func() etc.
  13945.  
  13946.  
  13947.          Values returned to menu manager
  13948.          -------------------------------
  13949.  
  13950.          The user function must return an integer back to the menu
  13951.          manager.  If the value returned to the menu manager is
  13952.          BAR_EXIT, the menu manager will exit from the current menu
  13953.          and will return control back to the function that called it.
  13954.          If the return value is BAR_CONTINUE, the menu continues to
  13955.          process selections.
  13956.  
  13957.          The menu_func() function defined above creates a window,
  13958.          displays the entry you have chosen, and returns a value back
  13959.          to the menu manager.  If the value is BAR_EXIT, the menu
  13960.          manager returns control back to the function that called it.
  13961.          In this case, main() called BarSelectMenu().  A return
  13962.          value of BAR_CONTINUE will cause the menu manager to let
  13963.          the user make another selection.
  13964.  
  13965.          The menu_func() function is a simple implementation.  However
  13966.          your function can do much more sophisticated things,
  13967.          including opening other bar menus.  If another bar menu
  13968.          is called while in another bar menu, the new bar menu
  13969.          gets its own menu manager and will not interfere with the
  13970.          original menu manager.  This is good if a menu function will
  13971.          call another menu function.
  13972.  
  13973.  
  13974.  
  13975.                 Return Values for BarSelectMenu();
  13976.  
  13977.              Return Value        Definition
  13978.          ┌───────────────────┬───────────────────────────┐
  13979.          │NO_ERROR           │ No error occured.         │
  13980.          ├───────────────────┼───────────────────────────┤
  13981.          │BAR_MENU_INVALID   │ Bar Menu does not exist.  │
  13982.          └───────────────────┴───────────────────────────┘
  13983.  
  13984.  
  13985.  
  13986.  
  13987.  
  13988.  
  13989.  
  13990.          Page 220          The C Window Library               Page 220
  13991.  
  13992.                    SETTING OPTIONS IN BAR MENUS
  13993.                    ----------------------------
  13994.  
  13995.          In addition to setting options using the BarCreateMenu()
  13996.          function, you can turn on and off options at any time using
  13997.          the BarSetOptions() function.
  13998.  
  13999.  
  14000.          The BarSetOptions() function
  14001.          ----------------------------
  14002.  
  14003.          The BarSetOptions() function turns either one or more of
  14004.          the above options on or off.  The prototype to the call is as
  14005.          follows:
  14006.  
  14007.          int BarSetOptions(BAR_MENU_PTR b, int option, int switch)
  14008.  
  14009.          The first argument is the BAR_MENU_PTR.  The second
  14010.          argument are the options that you wish to change.  The
  14011.          constants that describe the options are exactly the same as
  14012.          the ones described in BarCreateMenu().  The third argument
  14013.          is whether you want to switch the options on or off.
  14014.  
  14015.            Here are some sample calls to BarSetOptions():
  14016.  
  14017.              a) BarSetOptions(b,BARWRAP,1)
  14018.              b) BarSetOptions(b,BARSTATIC,1)
  14019.              c) BarSetOptions(b,BARSTATIC,0)
  14020.              d) BarSetOptions(b,BARDISPLAY,1)
  14021.              e) BarSetOptions(b,BARENHANCEDKEY,1)
  14022.  
  14023.          The third argument is 1 for "turn option on", 0 for "turn
  14024.          option off".
  14025.  
  14026.  
  14027.          Setting Multiple Options
  14028.          ------------------------
  14029.          You can also set multiple options with a single call by using
  14030.          a bitwise OR (|).  For example:
  14031.  
  14032.          BarSetOptions(b,BARWRAP | BARSTATIC,1)
  14033.  
  14034.          will set options BARWRAP and BARSTATIC defined above.
  14035.  
  14036.                  Return Values for BarSetOptions():
  14037.  
  14038.              Return Value        Definition
  14039.          ┌───────────────────┬───────────────────────────┐
  14040.          │NO_ERROR           │ No error occured.         │
  14041.          ├───────────────────┼───────────────────────────┤
  14042.          │BAR_MENU_INVALID   │ Bar Menu does not exist.  │
  14043.          └───────────────────┴───────────────────────────┘
  14044.  
  14045.  
  14046.  
  14047.  
  14048.  
  14049.  
  14050.          Page 221          The C Window Library               Page 221
  14051.  
  14052.          Getting Menu Options
  14053.          --------------------
  14054.  
  14055.          You can retrieve the options in a popup menu by calling the
  14056.          BarGetOptions() function.  The prototype is as follows:
  14057.  
  14058.             int BarGetOptions(BAR_MENU_PTR b, int *options)
  14059.  
  14060.          The first argument is the bar menu that you want to retieve
  14061.          the options from.
  14062.  
  14063.          The second argument is a pointer to an integer that will hold
  14064.          the options when BarGetOptions() returns.
  14065.  
  14066.          You can see if an option is set by using the bitwise AND.
  14067.  
  14068.          Example:
  14069.                         int options;
  14070.                         BAR_MENU_PTR b;
  14071.                         ...
  14072.  
  14073.                         BarGetOptions(b,&options);
  14074.                         if (options & BARWRAP)  {
  14075.                           /* wrap option is on */
  14076.                         }
  14077.  
  14078.                         ...
  14079.  
  14080.  
  14081.                   Return Values for BarGetOptions():
  14082.  
  14083.              Return Value        Definition
  14084.          ┌───────────────────┬───────────────────────────┐
  14085.          │NO_ERROR           │ No error occured.         │
  14086.          ├───────────────────┼───────────────────────────┤
  14087.          │BAR_MENU_INVALID   │ Bar Menu does not exist.  │
  14088.          └───────────────────┴───────────────────────────┘
  14089.  
  14090.  
  14091.  
  14092.  
  14093.  
  14094.  
  14095.  
  14096.  
  14097.  
  14098.  
  14099.  
  14100.  
  14101.  
  14102.  
  14103.  
  14104.  
  14105.  
  14106.  
  14107.  
  14108.  
  14109.  
  14110.          Page 222          The C Window Library               Page 222
  14111.  
  14112.                        ENABLING AND DISABLING MENU ENTRIES
  14113.                        -----------------------------------
  14114.  
  14115.          There may be cases when a menu entry should be made
  14116.          unavailable.  The entry shows up in the menu, but it is a
  14117.          different color than the other entries, and the highlight bar
  14118.          will just skip over this unavailable entry.
  14119.  
  14120.  
  14121.  
  14122.          Disabling and Enabling Entries
  14123.          ------------------------------
  14124.  
  14125.          With The C Window Library, you can disable and enable menu
  14126.          entries at any time.  The BarEnableEntry() function
  14127.          performs this task.  Here is the prototype to this function.
  14128.  
  14129.          int BarEnableEntry(BAR_MENU_PTR b, int where, int option)
  14130.  
  14131.          The first argument is the BAR_MENU_PTR.  The second
  14132.          argument is the number of the entry that you wish to change.
  14133.          Entry numbers range from 0 to the highest entry in the menu
  14134.          less one.  The option argument is either CWL_MDISABLED to
  14135.          disable a menu, or CWL_MENABLED to enable an entry.  You can
  14136.          combine CWL_MGRAYED with CWL_MDISABLED by using the bitwise
  14137.          OR operator (|) to gray the entry.
  14138.  
  14139.  
  14140.  
  14141.  
  14142.  
  14143.  
  14144.  
  14145.  
  14146.  
  14147.  
  14148.  
  14149.  
  14150.  
  14151.  
  14152.  
  14153.  
  14154.  
  14155.  
  14156.  
  14157.  
  14158.  
  14159.  
  14160.  
  14161.  
  14162.  
  14163.  
  14164.  
  14165.  
  14166.  
  14167.  
  14168.  
  14169.  
  14170.          Page 223          The C Window Library               Page 223
  14171.  
  14172.                    SETTING THE MENU ENTRY STRINGS
  14173.                    ------------------------------
  14174.  
  14175.          There may be times when you want to change a BAR_MENU_ENTRY
  14176.          entry_name string.  For instance, you may have a menu entry
  14177.          with the following entry_name:
  14178.  
  14179.                  "Default File Name     ABC.DAT"
  14180.  
  14181.  
  14182.          If the user selects this choice, the file name should change
  14183.          to another file name the user wants.  From there the menu
  14184.          should reflect the new choice the user has made.  Let's say
  14185.          the user has changed the default file name to DEF.DAT.  The
  14186.          menu then should say:
  14187.  
  14188.  
  14189.                 "Default File Name     DEF.DAT"
  14190.  
  14191.  
  14192.  
  14193.          BarSetEntryString() function
  14194.          ----------------------------
  14195.  
  14196.          How do you change the entry string?  One way is to fool
  14197.          around with the BAR_MENU_PTR's structure members, and
  14198.          change the string yourself.  This is not recommended for the
  14199.          novice to average C programmer, since it is not a good idea
  14200.          to change the structure members directly without a full
  14201.          understanding of the structure.
  14202.  
  14203.          A safer way is to call the BarSetEntryString() function.
  14204.          A prototype of this function is as follows:
  14205.  
  14206.          BarSetEntryString(BAR_MENU_PTR b, int entry,
  14207.                                 char *newstring)
  14208.  
  14209.          The first argument is the BAR_MENU_PTR.  The second
  14210.          argument is the number of the entry that you wish to change.
  14211.          Entry numbers range from 0 to the highest entry in the menu
  14212.          less one.  The third argument is a pointer to the new
  14213.          character string.  The newstring cannot be longer than the
  14214.          current BAR_MENU_ENTRY entry_name string.
  14215.  
  14216.               Return Values for BarSetEntryString():
  14217.  
  14218.              Return Value        Definition
  14219.          ┌───────────────────┬───────────────────────────┐
  14220.          │NO_ERROR           │ No error occured.         │
  14221.          ├───────────────────┼───────────────────────────┤
  14222.          │BAR_MENU_INVALID   │ Bar Menu does not exist.  │
  14223.          ├───────────────────┼───────────────────────────┤
  14224.          │MENU_ENTRY_INVALID │ Entry number is invalid.  │
  14225.          └───────────────────┴───────────────────────────┘
  14226.  
  14227.  
  14228.  
  14229.  
  14230.          Page 224          The C Window Library               Page 224
  14231.  
  14232.                         REDEFINING MENU KEYS
  14233.                         --------------------
  14234.  
  14235.  
  14236.          Setting Global Key Definitions and
  14237.          the CWLbar_key_def Array
  14238.          ------------------------
  14239.  
  14240.          You can redefine the keys used to control moving the
  14241.          highlight bar, accepting the menu choice, and exiting from
  14242.          the menu.  Here is a list of the default key mapping:
  14243.  
  14244.           Function                    Key        Constant
  14245.          ┌────────────────────────┬───────────┬─────────────┐
  14246.          │Move highlight bar right│Right Arrow│BAR_RIGHTKEY │
  14247.          ├────────────────────────┼───────────┼─────────────┤
  14248.          │Move highlight bar left │Down Arrow │BAR_LEFTKEY  │
  14249.          ├────────────────────────┼───────────┼─────────────┤
  14250.          │Accept Menu Choice      │Enter      │BAR_ACCEPTKEY│
  14251.          ├────────────────────────┼───────────┼─────────────┤
  14252.          │Escape Bar menu         │Escape     │BAR_QUITKEY  │
  14253.          ├────────────────────────┼───────────┼─────────────┤
  14254.          │Move To First Menu Item │Home       │BAR_HOMEKEY  │
  14255.          ├────────────────────────┼───────────┼─────────────┤
  14256.          │Move to Last Menu Item  │End        │BAR_ENDKEY   │
  14257.          └────────────────────────┴───────────┴─────────────┘
  14258.  
  14259.          The global array CWLbar_key_def contains the values of the
  14260.          default bar menu key definitions.  The names under the
  14261.          Constant heading are the offsets in the CWLbar_key_def
  14262.          array of where the key value for the function is defined.
  14263.          For instance, the value for the "Move highlight bar up"
  14264.          function is located at CWLbar_key_def[BAR_UPKEY].  You
  14265.          can change the values in CWLbar_key_def at any time, but
  14266.          make sure that a definition for "Escape Pop-up menu" always
  14267.          exists, and that there are no duplicate definitions (i.e.
  14268.          the "Move highlight bar up" key definition is the same as the
  14269.          "Move highlight bar down" key definition).  When defining new
  14270.          key values, you should use the values defined in the cwlwin.h
  14271.          header file for non-ascii keys.
  14272.  
  14273.  
  14274.  
  14275.          Setting Local Key Definitions
  14276.          -----------------------------
  14277.  
  14278.          Another way of redefining menu keys is to load your own array
  14279.          of key definitions with your desired values, and then calling
  14280.          the BarAssignKeys() function.  With this method, each menu
  14281.          can have different key definitions.
  14282.  
  14283.  
  14284.  
  14285.  
  14286.  
  14287.  
  14288.  
  14289.  
  14290.          Page 225          The C Window Library               Page 225
  14291.  
  14292.          BarAssignKeys() function
  14293.          ------------------------
  14294.  
  14295.          Here is a prototype of the BarAssignKeys() function:
  14296.  
  14297.          int BarAssignKeys(BAR_MENU_PTR b, unsigned *keys)
  14298.  
  14299.          where b is the BAR_MENU_PTR, and keys is an array of key
  14300.          definitions.  Here is a small code example:
  14301.  
  14302.  
  14303.          #include "cwlwin.h"
  14304.  
  14305.          unsigned mykeys[NUMBARKEYS] = {CTRLU,CTRLD,RETURN,
  14306.  
  14307.                                        ESC,HOME,END,0,0,0,0};
  14308.          BAR_MENU_PTR b;
  14309.  
  14310.          /* Other stuff...*/
  14311.  
  14312.          main()
  14313.          {
  14314.            /* Assume b is initialized */
  14315.  
  14316.            /* Assigns my key definitions to bar menu b */
  14317.            BarAssignKeys(b,mykeys);
  14318.          }
  14319.  
  14320.          The constant NUMBARKEYS should be used to make sure that
  14321.          your array of key definitions is large enough to hold all the
  14322.          definitions.   The above example uses the constants defined
  14323.  
  14324.          in cwlwin.h to assign to the array mykeys.  Each position
  14325.          in the mykeys array uses the default key mapping explained
  14326.          above.  In other words, mykeys[BAR_UPKEY] is CTRLU, etc.
  14327.  
  14328.          If there is no error, then NO_ERROR is returned.
  14329.  
  14330.          If there is an error, the error conditions and reasons are
  14331.          the same as the BarSelectMenu() function defined above.
  14332.  
  14333.  
  14334.  
  14335.  
  14336.  
  14337.  
  14338.  
  14339.  
  14340.  
  14341.  
  14342.  
  14343.  
  14344.  
  14345.  
  14346.  
  14347.  
  14348.  
  14349.  
  14350.          Page 226          The C Window Library               Page 226
  14351.  
  14352.                       PROCESSING UNDEFINED KEYS
  14353.                       -------------------------
  14354.  
  14355.          If you are an advanced programmer and/or have experience in
  14356.          using other window/menu libraries, you may be wondering "how
  14357.          do I define a function that supplies context-sensitive help
  14358.          for each BAR_MENU_ENTRY?  There is no structure member in
  14359.          BAR_MENU_ENTRY that supplies this".  With The C Window
  14360.          Library, any key that is not recognized by the menu manager
  14361.          (i.e. the key struck does not invoke a menu option, move the
  14362.          highlight bar up or down, or ends processing of the menu) can
  14363.          be processed by calling a user written function.   The
  14364.          WindowGet...() family of functions allowed us to define a
  14365.          function that will be called if a key that has no current
  14366.          definition is pressed.  For bar menus, we can do the same
  14367.          thing.
  14368.  
  14369.  
  14370.          The CWLbar_undef_key_func function pointer
  14371.          ------------------------------------------
  14372.  
  14373.          The global function pointer, CWLbar_undef_key_func, can point
  14374.          to a user written function that will be called when the menu
  14375.          manager encounters a key that is not defined.  The
  14376.          declaration for CWLbar_undef_key_func is as follows:
  14377.  
  14378.          unsigned int (*CWLbar_undef_key_func)(BAR_MENU_PTR b,
  14379.                                                int sel,
  14380.                                                int *choice)
  14381.  
  14382.          The user written function takes three arguments.  The first
  14383.          argument is a pointer to the bar menu that the menu manager
  14384.          is currently processing. The second argument is an integer
  14385.          that contains the value of the key that was pressed.  The
  14386.          third argument is a pointer to an integer that will contain
  14387.          the number of the menu choice to execute.  Initially, choice
  14388.          points to an integer that contains the current menu choice
  14389.          that the menu highlight bar is situated.  For instance, if
  14390.          the highlight bar is on the first menu choice when an
  14391.          undefined key is pressed, *choice will be equal to 0.  If
  14392.          CWLbar_undef_key_func is equal to a Null Function pointer
  14393.          (NULLFN), no user defined function is called.  By default,
  14394.          CWLbar_undef_key_func is assigned to NULLFN.
  14395.  
  14396.  
  14397.          Values returned to menu manager
  14398.          -------------------------------
  14399.  
  14400.          If CWLbar_undef_key_func is assigned to a function, the
  14401.          function must return an integer back to the menu manager.
  14402.          This integer value will tell the menu manager how to proceed.
  14403.          Here is a list of the valid return values that the user
  14404.          written function can return:
  14405.  
  14406.  
  14407.  
  14408.  
  14409.  
  14410.          Page 227          The C Window Library               Page 227
  14411.  
  14412.            Return                         Action to
  14413.            Value                            Take
  14414.          ┌─────────────────┬───────────────────────────────────────┐
  14415.          │BAR_CONTINUE     │ No Action. Continue processing the bar│
  14416.          │                 │ menu.                                 │
  14417.          ├─────────────────┼───────────────────────────────────────┤
  14418.          │BAR_DO_CHOICE    │ Accept and invoke menu entry assigned │
  14419.          │                 │ to *choice.                           │
  14420.          ├─────────────────┼───────────────────────────────────────┤
  14421.          │BAR_MOVE_CONTINUE│ Move the highlight bar to menu entry  │
  14422.          │                 │ assigned to *choice and continue      │
  14423.          │                 │ processing menu.                      │
  14424.          ├─────────────────┼───────────────────────────────────────┤
  14425.          │BAR_ESCAPE       │ Escape the bar menu.                  │
  14426.          ├─────────────────┼───────────────────────────────────────┤
  14427.          │BAR_MOVE_LEFT    │ Move to next bar menu.                │
  14428.          ├─────────────────┼───────────────────────────────────────┤
  14429.          │BAR_MOVE_RIGHT   │ Move to previous bar menu.            │
  14430.          ├─────────────────┼───────────────────────────────────────┤
  14431.          │BAR_MOVE_HOME    │ Move highlight to first entry.        │
  14432.          ├─────────────────┼───────────────────────────────────────┤
  14433.          │BAR_MOVE_END     │ Move highlight to last entry.         │
  14434.          └─────────────────┴───────────────────────────────────────┘
  14435.  
  14436.          A return value of BAR_CONTINUE is a "do nothing" command to
  14437.          the menu manager.
  14438.  
  14439.          If BAR_DO_CHOICE is returned to the menu manager, the integer
  14440.          assigned to the parameter *choice is used as the menu entry
  14441.          to invoke.  The highlight bar will automatically be moved to
  14442.          the menu choice specified, and the menu function will be
  14443.          called.  If BAR_MOVE_CONTINUE is returned to the menu
  14444.          manager, the highlight bar will be moved to the entry
  14445.          specified by the value of *choice, but no function is called.
  14446.  
  14447.          Here is an example of using a user defined function for the
  14448.          undefined keys:
  14449.  
  14450.  
  14451.          #include "cwlwin.h"
  14452.  
  14453.          /*  Other includes */
  14454.  
  14455.          int user_func();
  14456.  
  14457.          main()
  14458.  
  14459.          {
  14460.            CWLbar_undef_key_func = user_func;
  14461.  
  14462.            /* Other code */
  14463.  
  14464.          }
  14465.  
  14466.  
  14467.  
  14468.  
  14469.  
  14470.          Page 228          The C Window Library               Page 228
  14471.  
  14472.          unsigned int user_func(BAR_MENU_PTR b, int sel,
  14473.                                 int *choice)
  14474.          {
  14475.            switch(sel)
  14476.            {
  14477.              case F1:
  14478.                help(*choice);         /* call help function */
  14479.                return BAR_CONTINUE; /* return "do nothing" */
  14480.              case F2:
  14481.                *choice = 6;  /* let menu manager know to do
  14482.                                 choice 7 on the menu */
  14483.                return BAR_DO_CHOICE;  /* Also let menu manager
  14484.                                            know we are returning the
  14485.                                            "do the function assigned to
  14486.                                             *choice" command */
  14487.              default:
  14488.                return BAR_CONTINUE;
  14489.                /* let menu manager know not to do anything */
  14490.            }
  14491.          }
  14492.  
  14493.          int help(int choice)
  14494.          {  /* help function */
  14495.            switch (choice)
  14496.            {
  14497.              case 0:
  14498.                /* do context-sensitive help for entry 0 */
  14499.              break;
  14500.  
  14501.  
  14502.  
  14503.              case 1:
  14504.                /* do context-sensitive help for entry 1 */
  14505.              break;
  14506.               /* do more entries */
  14507.               /* ... */
  14508.            }
  14509.          }
  14510.  
  14511.          In the above example, if the user hits F1, a help function is
  14512.          called.  If you wanted to know how to incorporate a help
  14513.  
  14514.          function in the bar menus, here is the way to do it.
  14515.  
  14516.          If the user hits F2, the integer pointed to by choice is
  14517.          assigned a 6, and user_func() returns BAR_DO_CHOICE to the
  14518.          menu manager.  This tells the menu manager to invoke the
  14519.          function assigned to menu entry 7.
  14520.  
  14521.  
  14522.  
  14523.  
  14524.  
  14525.  
  14526.  
  14527.  
  14528.  
  14529.  
  14530.          Page 229          The C Window Library               Page 229
  14531.  
  14532.                          PRE-INPUT FUNCTION
  14533.                          ------------------
  14534.  
  14535.          With The C Window Library, you can define a function that
  14536.          will be performed just before the menu manager waits for the
  14537.          user to enter a keystroke.  This function can perform just
  14538.          about anything.
  14539.  
  14540.  
  14541.          Setting the CWLglobal_bar_prefunc function pointer
  14542.          -------------------------------------------------
  14543.  
  14544.          The CWLglobal_bar_prefunc function pointer points to this user
  14545.          written function.  Here is the prototype:
  14546.  
  14547.          int (*CWLglobal_bar_prefunc)(BAR_MENU_PTR b, int *sel)
  14548.  
  14549.          The arguments that will be passed to your function are the
  14550.          following:
  14551.  
  14552.          a)  The BAR_MENU_PTR of the bar menu that called your
  14553.              function, and
  14554.  
  14555.          b)  A pointer to the number of the selection that the
  14556.              highlight bar is currently on.
  14557.  
  14558.          The selection number ranges from 1 to the highest entry
  14559.          number of the menu.
  14560.  
  14561.          The pre-input function MUST return a value back to the menu
  14562.          manager.  The return values that can be returned are the same
  14563.          as the CWLbar_undef_key_func function described above.  If
  14564.          you are using a version of The C Window Library prior to
  14565.          version 1.5, you must declare your pre-input function as
  14566.          returning an int, and you must return a value back to the
  14567.          menu manager.  Versions prior to 1.5 declared the pre-input
  14568.          function as void.
  14569.  
  14570.          The BAR_DO_CHOICE and BAR_MOVE_CONTINUE return values will
  14571.          move the highlight bar to the entry number that is assigned
  14572.          to the *sel argument when the pre-input function has
  14573.          returned.
  14574.  
  14575.          By default, CWLglobal_bar_prefunc points to a NULLFN, and
  14576.          therefore will not be performed.  However, you can implement
  14577.          pre-input functions depending on the current selection.  For
  14578.          instance, you can write a function that displays extra
  14579.          information for each entry like so:
  14580.  
  14581.          #include "cwlwin.h"
  14582.  
  14583.          char *mess[] = {
  14584.                 " This option saves and loads files",
  14585.                 " This brings you in edit mode",
  14586.                 " This compiles and/or links the current program",
  14587.                /* ... More stuff */
  14588.                         };
  14589.  
  14590.          Page 230          The C Window Library               Page 230
  14591.  
  14592.          WPOINTER message_window;
  14593.  
  14594.          int disp_info();
  14595.  
  14596.          main()
  14597.  
  14598.          {
  14599.            /* ... */
  14600.  
  14601.            CWLglobal_bar_prefunc = disp_info;
  14602.  
  14603.            /* ... */
  14604.          }
  14605.  
  14606.          int disp_info(BAR_MENU_PTR b, int *sel)
  14607.          {
  14608.           /* Assume message_window already created and opened */
  14609.            WindowClear(message_window,
  14610.                        CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  14611.            WindowWriteString(message_window,mess[*sel],0,0);
  14612.            return BAR_CONTINUE;
  14613.          }
  14614.  
  14615.  
  14616.          For simplicity, the menu definitions are left out of the
  14617.          preceding code sample.  The disp_info displays the
  14618.          appropriate description in the window message_window.
  14619.          BAR_CONTINUE is returned to the menu manager.  This informs
  14620.          the menu manager to continue looking for a keystroke.
  14621.  
  14622.  
  14623.  
  14624.  
  14625.  
  14626.  
  14627.  
  14628.  
  14629.  
  14630.  
  14631.  
  14632.  
  14633.  
  14634.  
  14635.  
  14636.  
  14637.  
  14638.  
  14639.  
  14640.  
  14641.  
  14642.  
  14643.  
  14644.  
  14645.  
  14646.  
  14647.  
  14648.  
  14649.  
  14650.          Page 231          The C Window Library               Page 231
  14651.  
  14652.                        DISPOSING OF BAR MENUS
  14653.                        ----------------------
  14654.  
  14655.  
  14656.          BarMenuClose()
  14657.          -------------
  14658.  
  14659.  
  14660.          If the bar menu is no longer needed, the BarMenuClose()
  14661.          function will dispose of the bar menu and return any memory
  14662.          allocated to the bar menu, window, and virtual window
  14663.          memory back to the heap.  The call to the function is very
  14664.          simple:
  14665.  
  14666.                 BarMenuClose(BAR_MENU_PTR b)
  14667.  
  14668.          where b is the BAR_MENU_PTR to dispose of.  Since this
  14669.          function destroys the BAR_MENU_PTR b, b must not be used
  14670.          for any bar menu functions, unless b is pointing to a valid
  14671.          BAR_MENU_PTR.
  14672.  
  14673.  
  14674.          The return values and the reasons for failure are the same as
  14675.          BarSelectMenu().
  14676.  
  14677.  
  14678.  
  14679.  
  14680.  
  14681.  
  14682.  
  14683.  
  14684.  
  14685.  
  14686.  
  14687.  
  14688.  
  14689.  
  14690.  
  14691.  
  14692.  
  14693.  
  14694.  
  14695.  
  14696.  
  14697.  
  14698.  
  14699.  
  14700.  
  14701.  
  14702.  
  14703.  
  14704.  
  14705.  
  14706.  
  14707.  
  14708.  
  14709.  
  14710.          Page 232          The C Window Library               Page 232
  14711.  
  14712.                            PULLDOWN MENUS
  14713.                            --------------
  14714.  
  14715.          Description
  14716.          -----------
  14717.  
  14718.          A pulldown menu is a combination of popup menus and a bar
  14719.          menu.  The bar menu portion of the pulldown menu acts the
  14720.          same way as a normal bar menu.  However when a choice is made
  14721.          from the bar menu, a popup menu appears with more options to
  14722.          choose.  An example of a pulldown menu is the integrated
  14723.          environments of most PC based C compilers.
  14724.  
  14725.          Most of what was discussed previously will apply to pulldown
  14726.          menus.  Make sure that you have read the sections on popup
  14727.          menus and bar menus before preceding.
  14728.  
  14729.  
  14730.  
  14731.          Bar Menu and Bar Menu levels
  14732.          ----------------------------
  14733.  
  14734.          With pulldown menus there are two levels; the bar menu level
  14735.          and the popup menu level.  When in the bar menu level, no
  14736.          popup menu's are displayed, and the move right and move left
  14737.          keys move the highlight bar to the next or previous selection
  14738.          in the bar menu.  When in the popup menu level, the move
  14739.          right and move left keys not only move the highlight in the
  14740.          bar menu, but will also display the popup menu associated
  14741.          with the bar menu option.
  14742.  
  14743.  
  14744.  
  14745.  
  14746.  
  14747.  
  14748.  
  14749.  
  14750.  
  14751.  
  14752.  
  14753.  
  14754.  
  14755.  
  14756.  
  14757.  
  14758.  
  14759.  
  14760.  
  14761.  
  14762.  
  14763.  
  14764.  
  14765.  
  14766.  
  14767.  
  14768.  
  14769.  
  14770.          Page 233          The C Window Library               Page 233
  14771.  
  14772.                        CREATING PULLDOWN MENUS
  14773.                        -----------------------
  14774.  
  14775.          There are 4 steps that must be done when creating pulldown
  14776.          menus.  They are as follows:
  14777.  
  14778.             Step 1)  Call PulldownCreateMenu() to create an empty
  14779.                      pulldown menu.
  14780.  
  14781.             Step 2)  Create each popup menu to be displayed underneath
  14782.                      the bar.
  14783.  
  14784.  
  14785.             Step 3)  Call PulldownInsertEntry() or
  14786.                      PulldownAppendEntry() to insert or add the
  14787.                      entries on the pulldown menu.
  14788.  
  14789.  
  14790.          For Step 1) the bar menu is created automatically.  There
  14791.          is no need for the programmer to create a bar menu.
  14792.  
  14793.          Step 2) is as described in the Popup windows section.
  14794.  
  14795.          Step 3) is a function that inserts the popup menus defined
  14796.          in step 2 into the pulldown menus.
  14797.  
  14798.  
  14799.          The PulldownCreateMenu() function
  14800.          ---------------------------------
  14801.  
  14802.          To create an empty pulldown menu template, the
  14803.          PulldownCreateMenu() function is used.  Here is the
  14804.          prototype:
  14805.  
  14806.  
  14807.          PULLDOWN_MENU_PTR PulldownCreateMenu(WPOINTER wParent,
  14808.                            int options, unsigned *bcolor, int row,
  14809.                            int col, int width)
  14810.  
  14811.  
  14812.          The wParent argument is the pointer to the window that will
  14813.          be the parent to the pulldown menu.  If no parent window is
  14814.          desired, use the DESKTOP_WINDOW constant.
  14815.  
  14816.          The options argument follow the same options as for bar
  14817.          menus, such as BARSTATIC or BARWRAP.  See the BAR MENU
  14818.          section for these bar menu options.
  14819.  
  14820.          The bcolor is an array of menu colors which is exactly the
  14821.          same argument for the BarCreateMenu() function.
  14822.  
  14823.          The row and col arguments is the position to place the
  14824.          pulldown menu.  The width is the width of the bar portion of
  14825.          the menu window.
  14826.  
  14827.  
  14828.  
  14829.  
  14830.  
  14831.          Page 234          The C Window Library               Page 234
  14832.  
  14833.          Note that the return value is a pointer to a pulldown menu,
  14834.          namely, a PULLDOWN_MENU_PTR.  This is the handle that has to
  14835.          be used when referencing the pulldown menu.  If there are
  14836.          errors, PulldownCreateMenu() returns NULL, and CWLerror_code
  14837.          is set to the error that occurred.
  14838.  
  14839.  
  14840.  
  14841.          Adding and Inserting menu entries
  14842.          ---------------------------------
  14843.  
  14844.          Each entry on the bar portion of the pulldown menu has to be
  14845.          added to the menu.  The way to do this is to use either the
  14846.          PulldownInsertEntry() or PulldownAppendEntry() functions.
  14847.          Here are the prototypes to these functions:
  14848.  
  14849.          int PulldownInsertEntry(PULLDOWN_MENU_PTR pd, int type,
  14850.                                  int where, char *entry_string,
  14851.                                  int menuid, BARSELECTPROC func,
  14852.                                  POPUP_MENU_PTR p)
  14853.  
  14854.          int PulldownAppendEntry(PULLDOWN_MENU_PTR pd, int type,
  14855.                                  char *entry_string, int menuid,
  14856.                                  BARSELECTPROC func,
  14857.                                  POPUP_MENU_PTR pop)
  14858.  
  14859.          The pd argument is the PULLDOWN_MENU_PTR.  This is the value
  14860.          that was returned when PulldownCreateMenu() was called.
  14861.  
  14862.          The type argument is the menu type.  The available types are
  14863.          the same as the types available to bar and popup menus.
  14864.          These include CWL_MSTRING, CWL_MDISABLED, CWL_MGRAYED, etc.
  14865.          The only type that is not allowed is CWL_MSEPERATOR, since
  14866.          pulldowns do not have separators.
  14867.  
  14868.          The where argument denotes the position to place the menu
  14869.          item.  (PulldownInsertEntry() only).
  14870.  
  14871.          The entry_string argument is a pointer to the string that
  14872.          will be displayed in the menu.
  14873.  
  14874.          The menuid argument is an optional integer argument that can
  14875.          be used for any purpose.
  14876.  
  14877.          The last two arguments, func and pop, should be explained in
  14878.          tandem, since one depends on the other.
  14879.  
  14880.          The func argument can take on one of two types of values:  If
  14881.          func is BAR_NULL_FUNC (a NULL function), the popup menu
  14882.          defined in the pop argument (the last argument) is displayed.
  14883.  
  14884.          If the func argument is not BAR_NULL_FUNC, the user-defined
  14885.          function func is called when a selection is made.  This
  14886.          allows entries in the pulldown menu to have no popup menu
  14887.          associated with them, and still have functions invoked if
  14888.          they are selected.
  14889.  
  14890.  
  14891.          Page 235          The C Window Library               Page 235
  14892.  
  14893.          If func is BAR_NULL_FUNC, pop MUST point to a valid
  14894.          POPUP_MENU_PTR.
  14895.  
  14896.          The popup menus are placed underneath the bar menu in a
  14897.          'pleasing' manner, so you do not have to do the hard work and
  14898.          place them yourself.  This means that using a POPUP_MENU_PTR
  14899.          as part of a pulldown menu will render the popup menu's
  14900.          previous location moot, but most programmers usually find
  14901.          the position of the popup menus acceptable.  However, you can
  14902.          move a popup menu anywhere on the screen after
  14903.          PulldownAppendEntry() or PulldownInsertEntry() is called.
  14904.  
  14905.  
  14906.                  Return Values for PulldownInsertEntry() and
  14907.                  PulldownAppendEntry():
  14908.  
  14909.              Return Value        Definition
  14910.          ┌──────────────────────┬────────────────────────────────┐
  14911.          │NO_ERROR              │ No error occured.              │
  14912.          ├──────────────────────┼────────────────────────────────┤
  14913.          │PULLDOWN_MENU_INVALID │ Pulldown Menu does not exist.  │
  14914.          └──────────────────────┴────────────────────────────────┘
  14915.  
  14916.  
  14917.  
  14918.          Deleting menu entries
  14919.          ---------------------
  14920.  
  14921.          You can delete entries from the pulldown menu.  The
  14922.          PulldownDeleteEntry() function deletes an entry,
  14923.          including the entries popup if it exists.  Here is the
  14924.          prototype:
  14925.  
  14926.          int PulldownDeleteEntry(PULLDOWN_MENU_PTR pd, int where)
  14927.  
  14928.          The where argument is the entry to delete.  Entries are
  14929.          numbered starting from 0.  If a popup menu is associated with
  14930.          the entry, the POPUP_MENU_PTR of the entry is not destroyed,
  14931.          only its reference in the pulldown menu is removed.
  14932.  
  14933.                  Return Values for PulldownInsertEntry() and
  14934.                  PulldownAppendEntry():
  14935.  
  14936.              Return Value            Definition
  14937.          ┌──────────────────────┬────────────────────────────────┐
  14938.          │NO_ERROR              │ No error occured.              │
  14939.          ├──────────────────────┼────────────────────────────────┤
  14940.          │PULLDOWN_MENU_INVALID │ Pulldown Menu does not exist.  │
  14941.          ├──────────────────────┼────────────────────────────────┤
  14942.          │MENU_ENTRY_INVALID    │ Entry number invalid.          │
  14943.          └──────────────────────┴────────────────────────────────┘
  14944.  
  14945.  
  14946.  
  14947.  
  14948.  
  14949.  
  14950.  
  14951.          Page 236          The C Window Library               Page 236
  14952.  
  14953.                        SELECTING MENU ENTRIES
  14954.                        ----------------------
  14955.  
  14956.          To start the selection process in a pulldown menu, the
  14957.          PulldownSelectMenu() function is called.  Here is the
  14958.          prototype:
  14959.  
  14960.          int PulldownSelectMenu(PULLDOWN_MENU_PTR pd, int rank,
  14961.                                 int start, int immediate)
  14962.  
  14963.          The rank argument is the rank of the bar menu of the pulldown
  14964.          menu.  The start argument determines the starting entry to
  14965.          place the highlight bar.
  14966.  
  14967.          The immediate argument is a flag that denotes whether the
  14968.          popup menu of the desired bar entry is to be displayed when
  14969.          the PulldownSelectMenu() function is called.  If immediate is
  14970.          TRUE, the popup menu is displayed.  If FALSE, the popup menu
  14971.          is not displayed, and only the bar menu portion of the
  14972.          pulldown menu is displayed.
  14973.  
  14974.          When a selection is made in a pulldown menu, the user-defined
  14975.          function that is associated with the popup menu is called if
  14976.          a popup menu exists for the entry, or the user-defined
  14977.          function defined for the bar menu is called if the entry does
  14978.          not have a popup menu associated with it.
  14979.  
  14980.          The user-defined function must return a value back to the
  14981.          menu manager.  There are two possible return values,
  14982.          PULLDOWN_EXIT and PULLDOWN_CONTINUE.
  14983.  
  14984.          The PULLDOWN_EXIT return value will cause the menu manager to
  14985.          close both the popup menu window (if one was displayed), and
  14986.          the bar menu.  Then control is returned back to the function
  14987.          that called PulldownSelectMenu().
  14988.  
  14989.          The PULLDOWN_CONTINUE return value will cause the menu
  14990.          manager to continue processing the pulldown menu without
  14991.          closing the popup window (if one was displayed).
  14992.  
  14993.          If the return value is not one of the ones mentioned above,
  14994.          PULLDOWN_CONTINUE is assumed.
  14995.  
  14996.          Selections made on a bar menu item that has a popup menu
  14997.          associated with it will display the popup menu.
  14998.  
  14999.                Return Values for PulldownSelectMenu():
  15000.  
  15001.              Return Value            Definition
  15002.          ┌──────────────────────┬────────────────────────────────┐
  15003.          │NO_ERROR              │ No error occured.              │
  15004.          ├──────────────────────┼────────────────────────────────┤
  15005.          │PULLDOWN_MENU_INVALID │ Pulldown Menu does not exist.  │
  15006.          ├──────────────────────┼────────────────────────────────┤
  15007.          │MENU_ENTRY_INVALID    │ Entry number invalid.          │
  15008.          └──────────────────────┴────────────────────────────────┘
  15009.  
  15010.  
  15011.          Page 237          The C Window Library               Page 237
  15012.  
  15013.                      DISPOSING OF PULLDOWN MENUS
  15014.                      ---------------------------
  15015.  
  15016.          To dispose of a pulldown menu, use the PulldownMenuClose() or
  15017.          PulldownMenuCloseAll() functions.  Here are the prototyes for
  15018.          these functions:
  15019.  
  15020.          int PulldownMenuCloseAll(PULLDOWN_MENU_PTR pd)
  15021.  
  15022.          int PulldownMenuClose(PULLDOWN_MENU_PTR pd)
  15023.  
  15024.          The difference between these functions is that
  15025.          PulldownMenuCloseAll() destroys all popup menus associated
  15026.          with the pulldown menu, while PulldownMenuClose() only deletes
  15027.          the bar portion but leaves the popup menus alone.
  15028.  
  15029.                Return Values for PulldownMenuClose() and
  15030.                PulldownMenuCloseAll():
  15031.  
  15032.              Return Value            Definition
  15033.          ┌──────────────────────┬────────────────────────────────┐
  15034.          │NO_ERROR              │ No error occured.              │
  15035.          ├──────────────────────┼────────────────────────────────┤
  15036.          │PULLDOWN_MENU_INVALID │ Pulldown Menu does not exist.  │
  15037.          └──────────────────────┴────────────────────────────────┘
  15038.  
  15039.  
  15040.                       USING BAR MENU FUNCTIONS
  15041.                       ------------------------
  15042.  
  15043.          Any thing that was mentioned in the BAR MENUS chapter
  15044.          can be applied to the bar menu portion of the pulldown menu.
  15045.          To get a BAR_MENU_PTR from a pulldown menu, use the
  15046.          PulldownGetBar() function.  The prototype is as follows:
  15047.  
  15048.          BAR_MENU_PTR PulldownGetBar(PULLDOWN_MENU_PTR pd)
  15049.  
  15050.          Note that a BAR_MENU_PTR is returned.  You can then apply of
  15051.          the techniques and functions mentioned previously to the bar
  15052.          menu.  This includes enabling and disabling entries, setting
  15053.          options, etc.  The menu manager can determine whether the bar
  15054.          menu is really part of a pulldown menu system and will act
  15055.          accordingly.  For example, disabling a bar menu entry will
  15056.          disable the popup menu window from being displayed.
  15057.  
  15058.          The only thing that is not recommended is to call
  15059.          BarMenuClose() on the bar menu, since PulldownMenuFree() or
  15060.          PulldownMenuFreeAll() destroys the bar menu.
  15061.  
  15062.          All global user-defined functions for bar menus
  15063.          (CWLglobal_bar_prefunc and CWLbar_undef_key_func) are active
  15064.          for the pulldown menu pointers bar menu.
  15065.  
  15066.  
  15067.  
  15068.  
  15069.  
  15070.  
  15071.          Page 238          The C Window Library               Page 238
  15072.  
  15073.                      USING POPUP MENU FUNCTIONS
  15074.                      --------------------------
  15075.  
  15076.          Just as with the bar menu, the individual popup menus can
  15077.          also be manipulated using the methods described in POPUP
  15078.          MENUS.  To get the POPUP_MENU_PTR for a particular entry in
  15079.          the pulldown menu, use the PulldownGetPopup() function.  Here
  15080.          is the prototype:
  15081.  
  15082.          POPUP_MENU_PTR PulldownGetPopup(PULLDOWN_MENU_PTR pd,
  15083.                                          int entry)
  15084.  
  15085.          The entry argument is the entry in the pulldown menu of the
  15086.          desired popup menu.  If the entry does not have a popup
  15087.          associated with it, POPUP_NULL_PTR is returned.  Just as the
  15088.          menu manager can determine whether a bar menu is part of a
  15089.          pulldown menu, it also determines that a popup menu is part
  15090.          of a pulldown menu system.
  15091.  
  15092.  
  15093.          Do not call PopupMenuFree() on the popup menu, since the
  15094.          pulldown menu always assumes that the popup menu is
  15095.          available.
  15096.  
  15097.          All global user-defined functions for popup menus
  15098.          (CWLglobal_popup_prefunc and CWLpopup_undef_key_func) are
  15099.          active for the pulldown menu's popup menus.
  15100.  
  15101.  
  15102.          Example of a Pulldown Menu
  15103.          --------------------------
  15104.  
  15105.          Here is an example of a CWL program that sets up a pulldown
  15106.          menu and makes selections from it:
  15107.  
  15108.  
  15109.          #include "cwlwin.h"
  15110.          #include <string.h>
  15111.  
  15112.          /* define colors */
  15113.          #define YELLOWONRED  CREATE_VIDEO_ATTRIBUTE(RED_, YELLOW_)
  15114.  
  15115.          #define WHITEONBLUE  CREATE_VIDEO_ATTRIBUTE(BLUE_, WHITE_)
  15116.          #define BLUEONWHITE  CREATE_VIDEO_ATTRIBUTE(WHITE_, BLUE_)
  15117.          #define BLACKONCYAN  CREATE_VIDEO_ATTRIBUTE(CYAN_, BLACK_)
  15118.          #define NORM         CREATE_VIDEO_ATTRIBUTE(BLACK_, WHITE_)
  15119.  
  15120.          #define BLACKONWHITE \
  15121.                               CREATE_VIDEO_ATTRIBUTE(WHITE_, BLACK_)
  15122.  
  15123.          #define WHITEONRED \
  15124.                               CREATE_VIDEO_ATTRIBUTE(RED_,LIGHTWHITE_)
  15125.          #define GRAYONWHITE \
  15126.                               CREATE_VIDEO_ATTRIBUTE(WHITE_,GRAY_)
  15127.  
  15128.  
  15129.  
  15130.  
  15131.          Page 239          The C Window Library               Page 239
  15132.  
  15133.          unsigned menu_colors[NUMMENUCOLORS];    /* Menu colors */
  15134.  
  15135.          void pulldown_demo ();
  15136.  
  15137.          int rt1 _PROTO_((POPUP_MENU_PTR, int));
  15138.          int rt2 _PROTO_((BAR_MENU_PTR, int));
  15139.          WPOINTER pw;
  15140.  
  15141.          void main()
  15142.          {
  15143.            int b;
  15144.            WindowInitializeSystem();
  15145.            ClearScreen(NORM);
  15146.  
  15147.            /* Save Base Screen as a window */
  15148.            WindowInitDesktop(CWLactive_page);
  15149.  
  15150.            /* define colors */
  15151.            menu_colors[ENTRYCOLOR] =
  15152.            menu_colors[BORDERCOLOR] = BLACKONWHITE;
  15153.            menu_colors[UNAVAILCOLOR] = GRAYONWHITE;
  15154.            menu_colors[HOTKEYCOLOR] =
  15155.            menu_colors[HIGHLIGHTCOLOR] = WHITEONBLACK
  15156.  
  15157.            /* create status window */
  15158.            pw = WindowInitialize(DESKTOP_WINDOW,BORDER,
  15159.                                  15,0,40,5,NORM,NORM,SINGLEBOX);
  15160.            WindowCenter(pw,HORIZCENTER);
  15161.  
  15162.            /* Call Pulldown demo function */
  15163.            pulldown_demo();
  15164.  
  15165.            /* uninitialize CWL */
  15166.            WindowUninitSystem();
  15167.          }
  15168.  
  15169.  
  15170.          /* create pulldown menu here */
  15171.          void pulldown_demo()
  15172.          {
  15173.            int i;
  15174.            PULLDOWN_MENU_PTR pull;
  15175.            POPUP_MENU_PTR pmenu[8];
  15176.  
  15177.            /* Create a PULLDOWN_MENU_PTR */
  15178.            pull = PulldownCreateMenu(DESKTOP_WINDOW, /* Parent */
  15179.                                      BARWRAP,   /* options for bar */
  15180.                                      menu_colors, /* color scheme */
  15181.                                      0,           /* row */
  15182.                                      0,           /* column */
  15183.                                      75);         /* width */
  15184.  
  15185.  
  15186.  
  15187.  
  15188.  
  15189.  
  15190.  
  15191.          Page 240          The C Window Library               Page 240
  15192.  
  15193.            /*********************************
  15194.             * Create all of the popup menus *
  15195.             *********************************/
  15196.  
  15197.            /* Create first popup */
  15198.  
  15199.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15200.                             " &Load   ",0,rt1);
  15201.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15202.                             " &Pick  ",0,rt1);
  15203.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15204.                             " &New         ",0,rt1);
  15205.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15206.                             " &Save  ",0,rt1);
  15207.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15208.                             " &Write to    ",0,rt1);
  15209.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15210.                             " &Directory   ",0,rt1);
  15211.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15212.                             " &Change Dir  ",0,rt1);
  15213.            PopupAppendEntry(pmenu[0],CWL_MSTRING ,
  15214.                             " &Quit  ",0,rt1);
  15215.  
  15216.            /* create second popup */
  15217.            pmenu[1] = PopupCreateMenu(DESKTOP_WINDOW,
  15218.                                       POPUPSTATIC | POPUPMOUSE |
  15219.                                       POPUPRESIZEALL |
  15220.                                       POPUPWRAP | POPUPMOUSE   |
  15221.                                       POPUPCREATEWIN,
  15222.                                       menu_colors,0,0);
  15223.  
  15224.            PopupAppendEntry(pmenu[1],CWL_MSTRING ,
  15225.                             " &Run         ",0,rt1);
  15226.            PopupAppendEntry(pmenu[1],CWL_MSTRING ,
  15227.                             " &Program Reset",0,rt1);
  15228.            PopupAppendEntry(pmenu[1],CWL_MSTRING ,
  15229.                             " &Go to Cursor",0,rt1);
  15230.            PopupAppendEntry(pmenu[1],CWL_MSTRING ,
  15231.                             " &Trace Into  ",0,rt1);
  15232.            PopupAppendEntry(pmenu[1],CWL_MSTRING ,
  15233.                             " &Step Over   ",0,rt1);
  15234.            PopupAppendEntry(pmenu[1],CWL_MSTRING ,
  15235.                             " &User Screen ",0,rt1);
  15236.  
  15237.            /* create third popup */
  15238.            pmenu[2] = PopupCreateMenu(DESKTOP_WINDOW,
  15239.                                       POPUPSTATIC | POPUPMOUSE |
  15240.                                       POPUPRESIZEALL |
  15241.                                       POPUPWRAP | POPUPMOUSE   |
  15242.                                       POPUPCREATEWIN,
  15243.                                       menu_colors,0,0);
  15244.  
  15245.            PopupAppendEntry(pmenu[2],CWL_MSTRING ,
  15246.                             " &Compile to OBJ",0,rt1);
  15247.            PopupAppendEntry(pmenu[2],CWL_MSTRING ,
  15248.                             " &Make EXE file",0,rt1);
  15249.  
  15250.  
  15251.          Page 241          The C Window Library               Page 241
  15252.  
  15253.            PopupAppendEntry(pmenu[2],CWL_MSTRING ,
  15254.                             " &Link EXE file",0,rt1);
  15255.            PopupAppendEntry(pmenu[2],CWL_MSTRING ,
  15256.                             " &Build all  ",0,rt1);
  15257.            PopupAppendEntry(pmenu[2],CWL_MSTRING ,
  15258.                             " &Primary C File",0,rt1);
  15259.            PopupAppendEntry(pmenu[2],CWL_MSTRING ,
  15260.                             " &Get Info ",0,rt1);
  15261.  
  15262.            /* create fourth popup */
  15263.            pmenu[3] = PopupCreateMenu(DESKTOP_WINDOW,
  15264.                                       POPUPSTATIC | POPUPMOUSE |
  15265.                                       POPUPRESIZEALL |
  15266.                                       POPUPWRAP | POPUPMOUSE   |
  15267.                                       POPUPCREATEWIN,
  15268.                                       menu_colors,0,0);
  15269.  
  15270.            PopupAppendEntry(pmenu[3],CWL_MSTRING ,
  15271.                             " &Compiler    ",0,rt1);
  15272.            PopupAppendEntry(pmenu[3],CWL_MSTRING ,
  15273.                             " &Linker       ",0,rt1);
  15274.            PopupAppendEntry(pmenu[3],CWL_MSTRING ,
  15275.                             " &Environment ",0,rt1);
  15276.            PopupAppendEntry(pmenu[3],CWL_MSTRING ,
  15277.                             " &Directories ",0,rt1);
  15278.            PopupAppendEntry(pmenu[3],CWL_MSTRING ,
  15279.                             " &Save Options ",0,rt1);
  15280.            PopupAppendEntry(pmenu[3],CWL_MSTRING ,
  15281.                             " &Retrieve options ",0,rt1);
  15282.  
  15283.  
  15284.            /* create fifth popup */
  15285.            pmenu[4] = PopupCreateMenu(DESKTOP_WINDOW,
  15286.                                       POPUPSTATIC | POPUPMOUSE |
  15287.                                       POPUPRESIZEALL |
  15288.                                       POPUPWRAP | POPUPMOUSE   |
  15289.                                       POPUPCREATEWIN,
  15290.                                       menu_colors,0,0);
  15291.  
  15292.            PopupAppendEntry(pmenu[4],CWL_MSTRING ,
  15293.                             " &Evaluate ",0,rt1);
  15294.            PopupAppendEntry(pmenu[4],CWL_MSTRING ,
  15295.                             " &Call Stack ",0,rt1);
  15296.            PopupAppendEntry(pmenu[4],CWL_MSTRING ,
  15297.                             " &Find Function",0,rt1);
  15298.            PopupAppendEntry(pmenu[4],CWL_MSTRING ,
  15299.                             " &Refresh display ",0,rt1);
  15300.            PopupAppendEntry(pmenu[4],CWL_MSTRING ,
  15301.                             " &Display Swapping     Smart",0,rt1);
  15302.            PopupAppendEntry(pmenu[4],CWL_MSTRING ,
  15303.                             " &Source Debugging ",0,rt1);
  15304.  
  15305.  
  15306.  
  15307.  
  15308.  
  15309.  
  15310.  
  15311.          Page 242          The C Window Library               Page 242
  15312.  
  15313.            /* create sixth popup */
  15314.            pmenu[5] = PopupCreateMenu(DESKTOP_WINDOW,
  15315.                                       POPUPSTATIC | POPUPMOUSE |
  15316.                                       POPUPRESIZEALL |
  15317.                                       POPUPWRAP | POPUPMOUSE   |
  15318.                                       POPUPCREATEWIN,
  15319.                                       menu_colors,0,0);
  15320.            PopupAppendEntry(pmenu[5],CWL_MSTRING ,
  15321.                             " &Add watch          Ctrl-F7",0,rt1);
  15322.            PopupAppendEntry(pmenu[5],CWL_MSTRING ,
  15323.                             " &Delete watch       Ctrl-F3",0,rt1);
  15324.            PopupAppendEntry(pmenu[5],CWL_MSTRING ,
  15325.                             " &Edit Watch   ",0,rt1);
  15326.            PopupAppendEntry(pmenu[5],CWL_MSTRING ,
  15327.                             " &Remove All Watches",0,rt1);
  15328.            PopupAppendEntry(pmenu[5],CWL_MSEPARATOR,"",0,rt1);
  15329.            PopupAppendEntry(pmenu[5],CWL_MSTRING ,
  15330.                             " &Toggle breakpoint  ",0,rt1);
  15331.            PopupAppendEntry(pmenu[5],CWL_MSTRING ,
  15332.                             " &Clear all breakpoints",0,rt1);
  15333.            PopupAppendEntry(pmenu[5],CWL_MSTRING ,
  15334.                             " &View Next breakpoint",0,rt1);
  15335.  
  15336.            /*************************************
  15337.             * insert entries into pulldown menu *
  15338.             *************************************/
  15339.  
  15340.            PulldownInsertEntry(pull, CWL_MSTRING ,
  15341.                                0,"&File",
  15342.                                0,BAR_NULL_PTR,
  15343.                                pmenu[0]);
  15344.  
  15345.            /* Note that this entry does not have a pulldown
  15346.               associated with it */
  15347.            PulldownInsertEntry(pull, CWL_MSTRING ,
  15348.                                1,"&Edit",
  15349.                                0,rt2,
  15350.                                POPUP_NULL_PTR);
  15351.  
  15352.            PulldownInsertEntry(pull, CWL_MSTRING ,
  15353.                                2,"&Run",
  15354.                                0,BAR_NULL_PTR,
  15355.                                pmenu[1]);
  15356.  
  15357.  
  15358.            PulldownInsertEntry(pull, CWL_MSTRING ,
  15359.                                3,"&Compile",
  15360.                                0,BAR_NULL_PTR,
  15361.                                pmenu[2]);
  15362.  
  15363.  
  15364.  
  15365.            PulldownInsertEntry(pull, CWL_MSTRING ,
  15366.                                4,"&Project",
  15367.                                0,BAR_NULL_PTR,
  15368.                                pmenu[3]);
  15369.  
  15370.  
  15371.          Page 243          The C Window Library               Page 243
  15372.  
  15373.            PulldownInsertEntry(pull, CWL_MSTRING ,
  15374.                                5,"&Options",
  15375.                                0,BAR_NULL_PTR,
  15376.                                pmenu[4]);
  15377.  
  15378.  
  15379.            PulldownInsertEntry(pull, CWL_MSTRING ,
  15380.                                6,"&Miscellaneous",
  15381.                                0,BAR_NULL_PTR,
  15382.                                pmenu[5]);
  15383.  
  15384.            /* Test disabling by turning off the last entry */
  15385.            BarEnableEntry(PulldownGetBar(pull),6,CWL_MGRAYED);
  15386.  
  15387.            /* Go! */
  15388.            PulldownSelectMenu(pull,1,0,0);
  15389.  
  15390.            /* Dispose of pulldown menu and all other menus
  15391.               used to build it */
  15392.            PulldownMenuFreeAll(pull);
  15393.          }
  15394.  
  15395.  
  15396.          /* Routine that is called when popup function is invoked */
  15397.  
  15398.          int rt1(POPUP_MENU_PTR p, int which)
  15399.          {
  15400.            int dummy;
  15401.            WindowClear(pw);
  15402.  
  15403.            /* Display the entry name that was chosen */
  15404.            WindowPrintf(pw, "You have selected %s",
  15405.                         PopupGetEntryString(p,which));
  15406.  
  15407.            WindowWriteCenterString(pw, "Press a key to continue", 4);
  15408.  
  15409.            /* Display the window with all the info */
  15410.            WindowDisplay(pw, 1, NOEFFECT);
  15411.  
  15412.            GET_MPRESS_KEY(&dummy);
  15413.  
  15414.            /* Hide the info window */
  15415.            WindowHide(pw, NOEFFECT);
  15416.  
  15417.            /* Keep getting popup selections */
  15418.            return POPUP_CONTINUE;
  15419.          }
  15420.  
  15421.  
  15422.          /* routine called when bar menu function is selected */
  15423.          int rt2(BAR_MENU_PTR b, int which)
  15424.          {
  15425.            WindowClear(pw);
  15426.            /* Display the entry name that was chosen */
  15427.            WindowPrintf(pw, "You have selected %s",
  15428.                         BarGetEntryString(b, which));
  15429.  
  15430.  
  15431.          Page 244          The C Window Library               Page 244
  15432.  
  15433.            WindowWriteCenterString(pw, "Press a key to continue", 4);
  15434.            WindowDisplay(pw, 1, NOEFFECT);
  15435.            GET_MPRESS_KEY(&which);
  15436.  
  15437.            /* Hide window */
  15438.            WindowHide(pw, NOEFFECT);
  15439.  
  15440.            /* Keep getting selections */
  15441.            return BAR_CONTINUE;
  15442.          }
  15443.  
  15444.  
  15445.          The GET_MPRESS_KEY() macro waits for a key to be struck, or a
  15446.          mouse button on the mouse to be pressed.
  15447.  
  15448.          It may be advantageous to always create a pulldown menu
  15449.          instead of just a bar menu since pulldowns are more flexible
  15450.          in that popups can be added underneath, and the pulldown menu
  15451.          inherits all of the properties of a bar menu, i.e. you can
  15452.          call bar menu functions on the pulldown menu by specifying
  15453.          the bar menu portion of the pulldown menu.
  15454.  
  15455.  
  15456.          Key definitions for pulldown menus
  15457.          ----------------------------------
  15458.  
  15459.          In the POPUP MENU section, there were three key definitions
  15460.          that pertain to pulldown menus:
  15461.  
  15462.                 Action                  Key         Constant
  15463.         ┌───────────────────────────┬──────────┬──────────────────────┐
  15464.         │Move To Next Popup Menu    │Rt. Arrow │POPUP_RIGHTKEY        │
  15465.         ├───────────────────────────┼──────────┼──────────────────────┤
  15466.         │Move to Previous Popup Menu│Left Arrow│POPUP_LEFTKEY         │
  15467.         ├───────────────────────────┼──────────┼──────────────────────┤
  15468.         │Escape Pulldown Menu       │Unassigned│POPUP_PULLDOWN_QUITKEY│
  15469.         └───────────────────────────┴──────────┴──────────────────────┘
  15470.  
  15471.          By default, the right arrow key moves to the next popup menu
  15472.          defined on the bar menu.  If the next bar entry does not have
  15473.          a popup menu defined, the bar entry is highlighted instead.
  15474.  
  15475.          The left arrow key moves to the previous popup menu defined
  15476.          on the bar menu.
  15477.  
  15478.          POPUP_PULLDOWN_QUITKEY constant closes the pulldown menu.
  15479.  
  15480.          These definitions can be assigned to each popup menu in the
  15481.          pulldown menu system by using the PulldownGetPopup() function
  15482.          combined with PopupSetKeys() function i.e.
  15483.  
  15484.            PopupSetKeys(PulldownGetPopup(pull,0),keys)
  15485.  
  15486.          where pull is the PULLDOWN_MENU_PTR, 0 is the desired popup,
  15487.          and keys is an array of popup menu keys.  You can also
  15488.          change the key definitions by setting values in the
  15489.          CWLglobal_popup array.
  15490.  
  15491.          Page 245          The C Window Library               Page 245
  15492.  
  15493.  
  15494.  
  15495.  
  15496.  
  15497.  
  15498.  
  15499.  
  15500.  
  15501.  
  15502.  
  15503.  
  15504.  
  15505.  
  15506.  
  15507.  
  15508.  
  15509.  
  15510.  
  15511.  
  15512.  
  15513.  
  15514.  
  15515.  
  15516.  
  15517.  
  15518.  
  15519.  
  15520.  
  15521.  
  15522.  
  15523.  
  15524.  
  15525.  
  15526.  
  15527.  
  15528.  
  15529.  
  15530.  
  15531.  
  15532.  
  15533.  
  15534.  
  15535.  
  15536.  
  15537.  
  15538.  
  15539.  
  15540.  
  15541.  
  15542.  
  15543.  
  15544.  
  15545.  
  15546.  
  15547.  
  15548.  
  15549.  
  15550.  
  15551.          Page 246          The C Window Library               Page 246
  15552.  
  15553.                        MISCELLANEOUS FUNCTIONS
  15554.                        -----------------------
  15555.  
  15556.          There are other functions in The C Window Library that you
  15557.          can use without defining windows.  These functions include
  15558.          writing strings directly to the display, dynamically changing
  15559.          the number of displayable rows and columns on the screen,
  15560.          timed delays, sound functions, and other video related
  15561.          functions.
  15562.  
  15563.  
  15564.  
  15565.  
  15566.  
  15567.  
  15568.  
  15569.  
  15570.  
  15571.  
  15572.  
  15573.  
  15574.  
  15575.  
  15576.  
  15577.  
  15578.  
  15579.  
  15580.  
  15581.  
  15582.  
  15583.  
  15584.  
  15585.  
  15586.  
  15587.  
  15588.  
  15589.  
  15590.  
  15591.  
  15592.  
  15593.  
  15594.  
  15595.  
  15596.  
  15597.  
  15598.  
  15599.  
  15600.  
  15601.  
  15602.  
  15603.  
  15604.  
  15605.  
  15606.  
  15607.  
  15608.  
  15609.  
  15610.  
  15611.          Page 247          The C Window Library               Page 247
  15612.  
  15613.                  SETTING AND CHECKING VIDEO PAGES
  15614.                  --------------------------------
  15615.  
  15616.          The following functions sets and checks video pages.  Your
  15617.          video setup must support multiple video pages for the
  15618.          examples given in this section to work.  Please refer to page
  15619.          5 for a discussion of video adapters and the number of pages
  15620.          each will support.
  15621.  
  15622.  
  15623.          CheckVideoPage()
  15624.          ----------------
  15625.  
  15626.          This function checks to see if the video page is valid.  Here
  15627.          is the prototype:
  15628.  
  15629.                         int CheckVideoPage(int page)
  15630.  
  15631.          If page is valid, CheckVideoPage() returns NO_ERROR.  If it
  15632.          is not, the return value is INVALID_PAGE.
  15633.  
  15634.  
  15635.          Example:
  15636.  
  15637.          #include "cwlwin.h"
  15638.  
  15639.          main()
  15640.          {
  15641.            int i;
  15642.            WindowInitializeSystem();
  15643.            for (i=0;i<8;i++)
  15644.            {
  15645.              if (CheckVideoPage(i) == NO_ERROR)
  15646.                printf("\nValid video page #%d",i);
  15647.              else
  15648.                printf("\nInvalid video page #%d",i);
  15649.            }
  15650.          }
  15651.  
  15652.  
  15653.  
  15654.          SetActiveVideoPage() function
  15655.          -----------------------------
  15656.  
  15657.          The SetActiveVideoPage() function sets the active video page.
  15658.          Here is a prototype:
  15659.  
  15660.                   int SetActiveVideoPage(int page)
  15661.  
  15662.          Any windows initialized with WindowInitialize() will have its
  15663.          output directed to the current active video page on
  15664.          initialization.  This function DOES NOT change the visible
  15665.          display page.
  15666.  
  15667.  
  15668.  
  15669.  
  15670.  
  15671.          Page 248          The C Window Library               Page 248
  15672.  
  15673.          Example:
  15674.  
  15675.          #include "cwlwin.h"
  15676.          #define NORM CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  15677.  
  15678.          WPOINTER w1, w2;
  15679.          main()
  15680.          {
  15681.            WindowInitializeSystem();
  15682.  
  15683.            /* Save Base Screen for video pages 0 and 1 */
  15684.            WindowInitDesktop(0);
  15685.            WindowInitDesktop(1);
  15686.  
  15687.            /* Set the active video page */
  15688.            SetActiveVideoPage(0);
  15689.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,
  15690.                                  NORM,NORM,SINGLEBOX);
  15691.            SetActiveVideoPage(1);
  15692.            w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,10,10,
  15693.                                  NORM,NORM,SINGLEBOX);
  15694.          }
  15695.  
  15696.          The above example shows two windows, w1 and w2, being open on
  15697.          different video pages.  Please note the two calls to
  15698.          WindowInitDesktop().  The first saves the base screen on
  15699.          video page 0, and the second call saves the initial screen on
  15700.          page 1.  The first call to SetActiveVideoPage() sets the
  15701.          active video page to page 0.  This is usually the active
  15702.          video page on startup.  Since the active page is 0, w1 is
  15703.          opened with page 0 as its video page.  The second call to
  15704.          SetActiveVideoPage() makes page 1 the active page, therefore
  15705.          w2 is initialized to send its output to video page 1.
  15706.  
  15707.                Return Values for SetActiveVideoPage():
  15708.  
  15709.              Return Value            Definition
  15710.          ┌──────────────┬───────────────────────┐
  15711.          │NO_ERROR      │ No error occured.     │
  15712.          ├──────────────┼───────────────────────┤
  15713.          │INVALID_PAGE  │ Video Page is invalid.│
  15714.          └──────────────┴───────────────────────┘
  15715.  
  15716.  
  15717.          SetVisibleVideoPage() function
  15718.          ------------------------------
  15719.  
  15720.          The SetVisibleVideoPage() function sets the visible video
  15721.          page.  Here is a prototype:
  15722.  
  15723.  
  15724.                  int SetVisibleVideoPage(int page)
  15725.  
  15726.  
  15727.          The visible video page is the page displayed on the screen.
  15728.  
  15729.  
  15730.  
  15731.          Page 249          The C Window Library               Page 249
  15732.  
  15733.          Example:
  15734.  
  15735.          #include "cwlwin.h"
  15736.          #define NORM CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  15737.  
  15738.          WPOINTER w1,w2;
  15739.  
  15740.          main()
  15741.          {
  15742.            WindowInitializeSystem();
  15743.            /* Make sure video page is 0 */
  15744.            SetVisibleVideoPage(0);
  15745.            SetActiveVideoPage(0);
  15746.  
  15747.            /*Save Base screen for video pages 0 and 1 */
  15748.            WindowInitDesktop(0);
  15749.            WindowInitDesktop(1);
  15750.  
  15751.            /* Initialize Windows */
  15752.            w1 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  15753.                                  NORM,NORM,SINGLEBOX);
  15754.            SetActiveVideoPage(1);
  15755.            w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  15756.                                  NORM,NORM,SINGLEBOX);
  15757.            WindowWriteString(w1,"This is window 1 on page 0",0,0);
  15758.            WindowWriteString(w2,"This is window 2 on page 1",0,0);
  15759.  
  15760.            /* Display video page 0 */
  15761.            WindowDisplay(w1,1,NOEFFECT);
  15762.            GET_KEY();
  15763.  
  15764.            /* Change to video page 1 and display */
  15765.            SetVisibleVideoPage(1);
  15766.            WindowDisplay(w2,1,NOEFFECT);
  15767.            GET_KEY();
  15768.  
  15769.            /* Reset to page 0 */
  15770.            SetVisibleVideoPage(0);
  15771.          }
  15772.  
  15773.          The example above initializes two windows.  w1 is initialized
  15774.          on page 0 and w2 is initialized on page 1.  Also note that
  15775.          there are two calls to WindowInitDesktop(), one for page 0
  15776.          and another for page 1.  The first window displayed is w1.
  15777.          Once a key is pressed the visible page is switched to page 1
  15778.          by calling SetVisibleVideoPage().  The last line of the
  15779.          program sets the visible page back to page 0.  You should do
  15780.          this on exit of any program that changes video pages.
  15781.  
  15782.                Return Values for SetVisibleVideoPage():
  15783.  
  15784.              Return Value            Definition
  15785.          ┌──────────────┬───────────────────────┐
  15786.          │NO_ERROR      │ No error occured.     │
  15787.          ├──────────────┼───────────────────────┤
  15788.          │INVALID_PAGE  │ Video Page is invalid.│
  15789.          └──────────────┴───────────────────────┘
  15790.  
  15791.          Page 250          The C Window Library               Page 250
  15792.  
  15793.                   GENERAL STRING WRITING FUNCTIONS
  15794.                   --------------------------------
  15795.  
  15796.          The following functions write strings to the active video
  15797.          page.  These functions are not window functions, therefore
  15798.          you should use these functions when you are not using windows
  15799.          created with The C Window Library unless you are careful in
  15800.          using them.  The advantage of using these functions instead
  15801.          of the normal string writing functions found in most C
  15802.          compiler libraries (i.e.  printf(), puts(), etc.) is that the
  15803.          output is written directly to screen memory, which results in
  15804.          fast output.  If the BIOS option is selected, BIOS functions
  15805.          are used to write the strings.  Refer to page 4 for a
  15806.          discussion of direct screen writing and BIOS functions.
  15807.  
  15808.  
  15809.  
  15810.  
  15811.          VideoWriteString()
  15812.          ------------------
  15813.  
  15814.          This function writes a null terminated string to the active
  15815.          video page.  Here is the prototype:
  15816.  
  15817.             void VideoWriteString(char *string, int row, int col)
  15818.  
  15819.          The first argument is the string, and the second and third
  15820.          arguments are the (row,col) position of the active video page
  15821.          to place the string.  There is no check to see if (row,col)
  15822.          is out of bounds.  The attribute that is used is determined
  15823.          by the current video attribute at each character position on
  15824.          the screen.
  15825.  
  15826.  
  15827.          Example:
  15828.  
  15829.  
  15830.          #include "cwlwin.h"
  15831.  
  15832.          main()
  15833.          {
  15834.            int i;
  15835.            WindowInitializeSystem();
  15836.            for (i=0;i<10;i++)
  15837.              VideoWriteString("Hello, World",i,0);
  15838.          }
  15839.  
  15840.  
  15841.          There is no return value for VideoWriteString().
  15842.  
  15843.  
  15844.  
  15845.  
  15846.  
  15847.  
  15848.  
  15849.  
  15850.  
  15851.          Page 251          The C Window Library               Page 251
  15852.  
  15853.          VideoWriteStringAttr()
  15854.          ----------------------
  15855.  
  15856.          This function writes a null terminated string to the active
  15857.          video page using a video attribute.  Here is the prototype:
  15858.  
  15859.          void VideoWriteStringAttr(char *string, int row, int col,
  15860.                                    int attr)
  15861.  
  15862.          The first argument is the string, the second and third
  15863.          arguments are the (row,col) position of the active video page
  15864.          to place the string, and the last argument is the video
  15865.          attribute to use.  There is no check to see if (row,col) is
  15866.          out of bounds.  The last argument is the video attribute to
  15867.          use.
  15868.  
  15869.          Example:
  15870.  
  15871.          #include "cwlwin.h"
  15872.          #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  15873.  
  15874.          main()
  15875.          {
  15876.            int i;
  15877.            WindowInitializeSystem();
  15878.            for (i=0;i<10;i++)
  15879.              VideoWriteStringAttr("Hello, World",i,0,REVERSE);
  15880.          }
  15881.  
  15882.  
  15883.          There is no return value for VideoWriteStringAttr().
  15884.  
  15885.  
  15886.  
  15887.  
  15888.  
  15889.          VideoWriteAttributes()
  15890.          ----------------------
  15891.  
  15892.          This function writes a string of attributes to the active
  15893.          video page.  Here is the prototype:
  15894.  
  15895.           void VideoWriteAttributes(char *buffer, int row, int col,
  15896.                                     int num)
  15897.  
  15898.          The first argument is the buffer that contains the video
  15899.          attributes.  The second and third arguments are the (row,col)
  15900.          position of the active video page to place the attributes,
  15901.          and the last arguments is the number of attributes to write
  15902.          from the buffer.  There is no check to see if (row,col) is
  15903.  
  15904.          out of bounds, or if num attributes will exceed the right
  15905.          edge of the screen.
  15906.  
  15907.  
  15908.  
  15909.  
  15910.  
  15911.          Page 252          The C Window Library               Page 252
  15912.  
  15913.          Example:
  15914.  
  15915.          #include "cwlwin.h"
  15916.          #include <string.h>
  15917.  
  15918.          #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  15919.          char buf[12];
  15920.  
  15921.          main()
  15922.          {
  15923.            WindowInitializeSystem();
  15924.            VideoWriteString("Hello, World",0,0);
  15925.            GET_KEY();
  15926.            memset(buf,REVERSE,sizeof(buf));
  15927.            VideoWriteAttributes(buf,0,0,sizeof(buf));
  15928.          }
  15929.  
  15930.          The example above writes a string using the
  15931.          VideoWriteString() function and then changes the attribute of
  15932.          the string by setting a buffer to the REVERSE attribute and
  15933.          using the VideoWriteAttributes() function with this buffer.
  15934.  
  15935.          There is no return value for VideoWriteAttributes().
  15936.  
  15937.  
  15938.  
  15939.          VideoWriteCenterString()
  15940.          ------------------------
  15941.  
  15942.          The VideoWriteCenterString() function centers a string at a
  15943.          certain row of the active video page.  Here is the prototype:
  15944.  
  15945.               void VideoWriteCenterString(char *string, int row)
  15946.  
  15947.          The first argument is the string and the second argument is
  15948.          the row to write on the active video page to write the
  15949.          string.   There is no check to see if row is out of bounds.
  15950.  
  15951.  
  15952.          Example:
  15953.  
  15954.  
  15955.          #include "cwlwin.h"
  15956.  
  15957.          main()
  15958.          {
  15959.            int i;
  15960.            WindowInitializeSystem();
  15961.            for (i=0;i<10;i++)
  15962.              VideoWriteCenterString("Hello, World",i);
  15963.          }
  15964.  
  15965.  
  15966.          There is no return value for VideoWriteCenterString().
  15967.  
  15968.  
  15969.  
  15970.  
  15971.          Page 253          The C Window Library               Page 253
  15972.  
  15973.          VideoWriteCenterStringAttr()
  15974.          ----------------------------
  15975.  
  15976.          The VideoWriteCenterStringAttr() function centers a string at
  15977.          a certain row of the active video page with a specified video
  15978.          attribute.  Here is the prototype:
  15979.  
  15980.          void VideoWriteCenterStringAttr(char *string, int row,
  15981.                                          int attr)
  15982.  
  15983.          The first argument is the string and the second argument is
  15984.          the row to write on the active video page to write the
  15985.          string.  The third argument is the video attribute to use.
  15986.          There is no check to see if row is out of bounds.
  15987.  
  15988.  
  15989.          Example:
  15990.  
  15991.  
  15992.          #include "cwlwin.h"
  15993.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  15994.  
  15995.          main()
  15996.          {
  15997.            int i;
  15998.            WindowInitializeSystem();
  15999.            for (i=0;i<10;i++)
  16000.              VideoWriteCenterStringAttr("Hello, World",i,REVERSE);
  16001.          }
  16002.  
  16003.          There is no return value for VideoWriteCenterStringAttr().
  16004.  
  16005.  
  16006.  
  16007.  
  16008.          VideoWriteCharAndAttr()
  16009.          -----------------------
  16010.  
  16011.          The VideoWriteCharAndAttr() function writes a string of
  16012.          character-attribute pairs to the active video page.  Here is
  16013.          the prototype:
  16014.  
  16015.          void VideoWriteCharAndAttr(char *buffer, int row, int col,
  16016.                                     int num)
  16017.  
  16018.          The first argument is the buffer that holds the character
  16019.          attribute pairs.  This buffer should be in the following
  16020.          form:
  16021.  
  16022.               ┌──────┬───────┬───────┬───────┬───────┬──────┐
  16023.               │char1 │ attr1 │ char2 │ attr2 │ char3 │ attr3│ ...
  16024.               └──────┴───────┴───────┴───────┴───────┴──────┘
  16025.  
  16026.          The second and third arguments are the (row,col) position of
  16027.          the active video page to write the string.  The last argument
  16028.          is the number of character-attribute pairs to write.
  16029.  
  16030.  
  16031.          Page 254          The C Window Library               Page 254
  16032.  
  16033.          Example:
  16034.  
  16035.          #include "cwlwin.h"
  16036.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  16037.          char buf[24];
  16038.  
  16039.          main()
  16040.          {
  16041.            int i,j;
  16042.            WindowInitializeSystem();
  16043.            for (i=0,j='A'; i<24; i+=2,j++)
  16044.            {
  16045.              buf[i] = j;
  16046.              buf[i+1] = REVERSE;
  16047.            }
  16048.            for (i=0;i<10;i++)
  16049.              VideoWriteCharAndAttr(buf,i,012);
  16050.          }
  16051.  
  16052.          The example above creates a string of character attribute
  16053.          pairs and then writes this string using the
  16054.          VideoWriteCharAndAttr() function.
  16055.  
  16056.          There is no return value for VideoWriteCharAndAttr().
  16057.  
  16058.  
  16059.          VideoWriteStringCC()
  16060.          --------------------
  16061.  
  16062.          This function writes a string centered around a column on the
  16063.          active video page.  Here is the prototype:
  16064.  
  16065.               void VideoWriteStringCC(char *string, int row, int col)
  16066.  
  16067.          The first argument is the string.  The second argument is the
  16068.          row, and the third argument is the column to center the
  16069.          string around.
  16070.  
  16071.          Example:
  16072.  
  16073.          #include "cwlwin.h"
  16074.  
  16075.          main()
  16076.          {
  16077.            int i;
  16078.            WindowInitializeSystem();
  16079.            VideoWriteStringCC("This",0,10);
  16080.            VideoWriteStringCC("is",1,10);
  16081.            VideoWriteStringCC("centered",2,10);
  16082.            VideoWriteStringCC("around",3,10);
  16083.            VideoWriteStringCC("column",4,10);
  16084.            VideoWriteStringCC("10",5,10);
  16085.          }
  16086.  
  16087.          There is no return value for VideoWriteStringCC().
  16088.  
  16089.  
  16090.  
  16091.          Page 255          The C Window Library               Page 255
  16092.  
  16093.          VideoWriteStringCCAttr()
  16094.          ------------------------
  16095.  
  16096.          This function writes a string centered around a column on the
  16097.          active video page with a specified video attribute.  Here is
  16098.          the prototype:
  16099.  
  16100.          void VideoWriteStringCCAttr(char *string, int row, int col,
  16101.                                      int attr)
  16102.  
  16103.          The first argument is the string.  The second argument is the
  16104.          row.  The third argument is the column to center the string
  16105.          around, and the fourth argument is the attribute to use.
  16106.  
  16107.  
  16108.          Example:
  16109.  
  16110.          #include "cwlwin.h"
  16111.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  16112.          main()
  16113.          {
  16114.            int i;
  16115.            WindowInitializeSystem();
  16116.            VideoWriteStringCCAttr("This",0,10,REVERSE);
  16117.            VideoWriteStringCCAttr("is",1,10,REVERSE);
  16118.            VideoWriteStringCCAttr("centered",2,10,REVERSE);
  16119.            VideoWriteStringCCAttr("around",3,10,REVERSE);
  16120.            VideoWriteStringCCAttr("column",4,10,REVERSE);
  16121.            VideoWriteStringCCAttr("10",5,10,REVERSE);
  16122.          }
  16123.  
  16124.          There is no return value for VideoWriteStringCCAttr().
  16125.  
  16126.  
  16127.  
  16128.  
  16129.          VideoWriteStringRJ()
  16130.          --------------------
  16131.  
  16132.          The VideoWriteStringRJ() function writes a string to the
  16133.          screen that is right justified at column col.  If the string
  16134.          will not fit within column 0, the string is still right
  16135.          justified, but excess characters to the left of column 1 are
  16136.          clipped.  This function writes a string  column on the active
  16137.          video page.  Here is the prototype:
  16138.  
  16139.          void VideoWriteStringRJ(char *string, int row, int col)
  16140.  
  16141.          The first argument is the string.  The second argument is the
  16142.          row, and the third argument is the column to right justify
  16143.          the string on.
  16144.  
  16145.  
  16146.  
  16147.  
  16148.  
  16149.  
  16150.  
  16151.          Page 256          The C Window Library               Page 256
  16152.  
  16153.          Example:
  16154.  
  16155.          #include "cwlwin.h"
  16156.          main()
  16157.          {
  16158.            int i;
  16159.            WindowInitializeSystem();
  16160.            VideoWriteStringRJ("This",0,10);
  16161.            VideoWriteStringRJ("is",1,10);
  16162.            VideoWriteStringRJ("right",2,10);
  16163.            VideoWriteStringRJ("justified",3,10);
  16164.            VideoWriteStringRJ("on ",4,10);
  16165.            VideoWriteStringRJ("column",5,10);
  16166.            VideoWriteStringRJ("10",6,10);
  16167.          }
  16168.  
  16169.          There is no return value for VideoWriteStringRJ().
  16170.  
  16171.  
  16172.  
  16173.          VideoWriteStringRJAttr()
  16174.          ------------------------
  16175.  
  16176.          The VideoWriteStringRJAttr() function writes a string to the
  16177.          screen that is right justified at column col with a specified
  16178.          video attribute.  If the string will not fit within column 1,
  16179.          the string is still right justified, but excess characters to
  16180.          the left of column 0 are clipped.  This function writes a
  16181.          string  column on the active video page.  Here is the
  16182.          prototype:
  16183.  
  16184.          void VideoWriteStringRJAttr(char *string, int row, int col,
  16185.                                      int attr)
  16186.  
  16187.          The first argument is the string.  The second argument is the
  16188.          row.  The third argument is the column to right justify the
  16189.          string on, and the last argument is the video attribute to
  16190.          use.
  16191.  
  16192.          Example:
  16193.  
  16194.          #include "cwlwin.h"
  16195.          #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  16196.          main()
  16197.          {
  16198.            int i;
  16199.            WindowInitializeSystem();
  16200.            VideoWriteStringRJAttr("This",0,10,REVERSE);
  16201.            VideoWriteStringRJAttr("is",1,10,REVERSE);
  16202.            VideoWriteStringRJAttr("right",2,10,REVERSE);
  16203.            VideoWriteStringRJAttr("justified",3,10,REVERSE);
  16204.            VideoWriteStringRJAttr("on ",4,10,REVERSE);
  16205.            VideoWriteStringRJAttr("column",5,10,REVERSE);
  16206.            VideoWriteStringRJAttr("10",6,10,REVERSE);
  16207.          }
  16208.  
  16209.          There is no return value for VideoWriteStringRJAttr().
  16210.  
  16211.          Page 257          The C Window Library               Page 257
  16212.  
  16213.          VideoPrintf()
  16214.          -------------
  16215.  
  16216.          The VideoPrintf() function writes formatted strings to the
  16217.          active video page.  This function works exactly the same as
  16218.          printf() except that output is written directly to the
  16219.          screen.  Here is the prototype:
  16220.  
  16221.                 void VideoPrintf(char *format [,arg1,arg2...])
  16222.  
  16223.          The location of the output is placed at the current cursor
  16224.          position.  The cursor is advanced to one character beyond the
  16225.          last character of output.
  16226.  
  16227.          Example:
  16228.  
  16229.          #include "cwlwin.h"
  16230.          int i = 3;
  16231.          double j = 5.6;
  16232.          main()
  16233.          {
  16234.            WindowInitializeSystem();
  16235.            VideoPrintf("3+2 is equal to %d\n",3+2);
  16236.            VideoPrintf("i is equal to %d\nj is equal to %lf\n",i,j);
  16237.          }
  16238.  
  16239.          Unlike printf(), there is no return value with VideoPrintf().
  16240.  
  16241.  
  16242.  
  16243.          VideoPrintfAttr()
  16244.          -----------------
  16245.  
  16246.          The VideoPrintfAttr() function works the same as
  16247.          VideoPrintf() except that a video attribute is specified.
  16248.          Here is the prototype:
  16249.  
  16250.           void VideoPrintfAttr(int attr, char *format [,arg1,arg2...])
  16251.  
  16252.          The first argument is the attribute to use.  The second
  16253.          argument is the format string, and the other arguments are
  16254.          optional arguments.
  16255.  
  16256.          Example:
  16257.  
  16258.          #include "cwlwin.h"
  16259.          #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  16260.          int i = 3;
  16261.          double j = 5.6;
  16262.          main()
  16263.          {
  16264.            WindowInitializeSystem();
  16265.            VideoPrintfAttr(REVERSE,"3+2 is equal to %d\n",3+2);
  16266.            VideoPrintfAttr(REVERSE,
  16267.                   "i is equal to %d\nj is equal to %lf\n",i,j);
  16268.          }
  16269.  
  16270.  
  16271.          Page 258          The C Window Library               Page 258
  16272.  
  16273.          Unlike printf(), there is no return value with
  16274.          VideoPrintfAttr().
  16275.  
  16276.  
  16277.  
  16278.  
  16279.  
  16280.  
  16281.  
  16282.  
  16283.  
  16284.  
  16285.  
  16286.  
  16287.  
  16288.  
  16289.  
  16290.  
  16291.  
  16292.  
  16293.  
  16294.  
  16295.  
  16296.  
  16297.  
  16298.  
  16299.  
  16300.  
  16301.  
  16302.  
  16303.  
  16304.  
  16305.  
  16306.  
  16307.  
  16308.  
  16309.  
  16310.  
  16311.  
  16312.  
  16313.  
  16314.  
  16315.  
  16316.  
  16317.  
  16318.  
  16319.  
  16320.  
  16321.  
  16322.  
  16323.  
  16324.  
  16325.  
  16326.  
  16327.  
  16328.  
  16329.  
  16330.  
  16331.          Page 259          The C Window Library               Page 259
  16332.  
  16333.           READING CHARACTERS AND ATTRIBUTES FROM THE SCREEN
  16334.           -------------------------------------------------
  16335.  
  16336.          These functions read characters and/or attributes from the
  16337.          active video page.
  16338.  
  16339.  
  16340.          VideoReadCharacters()
  16341.          ---------------------
  16342.  
  16343.          This function reads characters from the active video page
  16344.          into a buffer.  Here is the prototype:
  16345.  
  16346.  
  16347.          void VideoReadCharacters(char *buffer, int row, int col,
  16348.                                   int num)
  16349.  
  16350.          The first argument is the buffer to store the characters.
  16351.          The second and third arguments are the (row,col) position on
  16352.          the active video page.  The last argument is the number of
  16353.          characters to read in.  There is no check to see if the row,
  16354.          col, or the num arguments are in bounds of the screen.
  16355.  
  16356.  
  16357.          Example:
  16358.  
  16359.          #include "cwlwin.h"
  16360.  
  16361.          char buf[25];
  16362.  
  16363.          main()
  16364.          {
  16365.            WindowInitializeSystem();
  16366.            VideoReadCharacters(buf,0,0,25);
  16367.          }
  16368.  
  16369.  
  16370.          The example above reads the characters on the screen starting
  16371.          at position (0,0).
  16372.  
  16373.          There is no return value for VideoReadCharacters().
  16374.  
  16375.  
  16376.  
  16377.          VideoReadAttributes()
  16378.          ---------------------
  16379.  
  16380.          This function reads attributes from the active video page
  16381.          into a buffer.  Here is the prototype:
  16382.  
  16383.  
  16384.          void VideoReadAttributes(char *buffer, int row, int col,
  16385.                                   int num)
  16386.  
  16387.  
  16388.  
  16389.  
  16390.  
  16391.          Page 260          The C Window Library               Page 260
  16392.  
  16393.          The first argument is the buffer to store the attributes.
  16394.          The second and third arguments are the (row,col) position on
  16395.          the active video page.  The last argument is the number of
  16396.          attributes to read in.  There is no check to see if the row,
  16397.          col, or the num arguments are in bounds of the screen.
  16398.  
  16399.          Example:
  16400.  
  16401.          #include "cwlwin.h"
  16402.  
  16403.          char buf[25];
  16404.  
  16405.          main()
  16406.          {
  16407.            WindowInitializeSystem();
  16408.            VideoReadAttributes(buf,0,0,25);
  16409.          }
  16410.  
  16411.          The example above reads the attributes on the screen
  16412.          starting at position (0,0).
  16413.  
  16414.          There is no return value for VideoReadAttributes().
  16415.  
  16416.  
  16417.  
  16418.          VideoReadCharAndAttr()
  16419.          ----------------------
  16420.  
  16421.          This function reads character-attribute pairs from the active
  16422.          video page into a buffer.  Here is the prototype:
  16423.  
  16424.          void VideoReadCharAndAttr(char *buffer, int row, int col,
  16425.                                    int num)
  16426.  
  16427.          The first argument is the buffer to store the
  16428.          character-attribute pairs.  The second and third arguments
  16429.          are the (row,col) position on the active video page.  The
  16430.          last argument is the number of character-attribute pairs to
  16431.          read in.  There is no check to see if the row, col, or the
  16432.          num arguments are in bounds of the screen.
  16433.  
  16434.          Example:
  16435.  
  16436.          #include "cwlwin.h"
  16437.          char buf[26];
  16438.  
  16439.          main()
  16440.  
  16441.          {
  16442.            WindowInitializeSystem();
  16443.            VideoReadCharAndAttr(buf,0,0,13);
  16444.          }
  16445.  
  16446.          The example above reads the character-attribute pairs on the
  16447.          screen starting at position (0,0).
  16448.  
  16449.          There is no return value for VideoReadCharAndAttr().
  16450.  
  16451.          Page 261          The C Window Library               Page 261
  16452.  
  16453.                             DRAWING BOXES
  16454.                             -------------
  16455.  
  16456.          The following functions draw boxes on the screen.
  16457.  
  16458.  
  16459.          VideoDrawBox()
  16460.          --------------
  16461.  
  16462.          The VideoDrawBox() function draws a box on the screen.  Here
  16463.          is the prototype:
  16464.  
  16465.          void VideoDrawBox(int urow, int ucol, int lrow, int lcol,
  16466.                            char *boxchars)
  16467.  
  16468.          The box is defined by a rectangular region.  The urow and
  16469.          ucol arguments are the coordinates of the upper left hand
  16470.          corner of the box.  The lrow and lcol arguments are the
  16471.          coordinates of the lower right hand corner of the box.  The
  16472.          last argument is a string of box drawing characters to use.
  16473.          You can use the predefined box types in the header file
  16474.          cwlwin.h, or you can make your own.  Refer to page 11 for
  16475.          more information on box types.
  16476.  
  16477.          There is no check to see if the coordinates are in bounds.
  16478.  
  16479.          Example:
  16480.  
  16481.          #include "cwlwin.h"
  16482.  
  16483.          main()
  16484.          {
  16485.            WindowInitializeSystem();
  16486.            ClearScreen(CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  16487.  
  16488.            /* Draw two boxes */
  16489.            VideoDrawBox(1,1,10,10,SINGLEBOX);
  16490.            VideoDrawBox(1,11,10,21,DOUBLEBOX);
  16491.          }
  16492.  
  16493.          There is no return value for VideoDrawBox().
  16494.  
  16495.  
  16496.          VideoDrawBoxAttr()
  16497.          ------------------
  16498.  
  16499.          The VideoDrawBoxAttr() function draws a box on the screen
  16500.          with a specified video attribute.  Here is the prototype:
  16501.  
  16502.          void VideoDrawBoxAttr(int urow, int ucol, int lrow, int lcol,
  16503.  
  16504.                               char *boxchars, int attr)
  16505.  
  16506.          This function works the same way as the VideoDrawBox()
  16507.          function.  Note that the last argument is the video attribute
  16508.          to use.  There is no check to see if the coordinates are in
  16509.          bounds.
  16510.  
  16511.          Page 262          The C Window Library               Page 262
  16512.  
  16513.          Example:
  16514.  
  16515.          #include "cwlwin.h"
  16516.          #define REVERSE CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  16517.  
  16518.          main()
  16519.          {
  16520.            WindowInitializeSystem();
  16521.            ClearScreen(CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  16522.  
  16523.            /* Draw two boxes */
  16524.            VideoDrawBoxAttr(1,1,10,10,SINGLEBOX,REVERSE);
  16525.            VideoDrawBoxAttr(1,11,10,21,DOUBLEBOX,REVERSE);
  16526.          }
  16527.  
  16528.  
  16529.          There is no return value for VideoDrawBoxAttr().
  16530.  
  16531.  
  16532.  
  16533.  
  16534.  
  16535.  
  16536.  
  16537.  
  16538.  
  16539.  
  16540.  
  16541.  
  16542.  
  16543.  
  16544.  
  16545.  
  16546.  
  16547.  
  16548.  
  16549.  
  16550.  
  16551.  
  16552.  
  16553.  
  16554.  
  16555.  
  16556.  
  16557.  
  16558.  
  16559.  
  16560.  
  16561.  
  16562.  
  16563.  
  16564.  
  16565.  
  16566.  
  16567.  
  16568.  
  16569.  
  16570.  
  16571.          Page 263          The C Window Library               Page 263
  16572.  
  16573.                  SAVING AND RESTORING SCREEN IMAGES
  16574.                  ----------------------------------
  16575.  
  16576.          The following functions save rectangular regions of the
  16577.          screen in a buffer, and restore rectangular portions of the
  16578.          screen.  These routines exist in The C Window Library so that
  16579.          advanced C programmers can have general screen
  16580.          saving/restoring routines handy.  As always, you should be
  16581.          careful in using these functions at the same time you are
  16582.          using windows created with The C Window Library.
  16583.  
  16584.  
  16585.          VideoSave()
  16586.          -----------
  16587.  
  16588.          The VideoSave() function saves a rectangular portion of the
  16589.          screen into a structure called a VBLOCK.  A pointer to this
  16590.          structure is called a VBLOCKPTR.  Here is the prototype:
  16591.  
  16592.          VBLOCKPTR VideoSave(int urow, int ucol, int lrow, int lcol)
  16593.  
  16594.          This function returns a VBLOCKPTR.  The VBLOCKPTR will be
  16595.          used to move or restore this saved region.  The first two
  16596.          arguments are the coordinates of the upper left hand corner
  16597.          of the rectangle to save (urow,ucol).  The last two arguments
  16598.          are the coordinates of the lower right hand corner of the
  16599.          rectangle (lrow,lcol).  There is no check to see if the
  16600.          coordinates are out of bounds.  You can use this function to
  16601.          save the base screen, and then use VideoRestore() to restore
  16602.          the base screen on exit.
  16603.  
  16604.          Example:
  16605.  
  16606.          #include "cwlwin.h"
  16607.  
  16608.          VBLOCKPTR v;
  16609.  
  16610.          main()
  16611.          {
  16612.            WindowInitializeSystem();
  16613.            v = VideoSave(0,0,24,79);   /* Save Rectangular region */
  16614.  
  16615.  
  16616.            /* Check if NULL */
  16617.            if (v == (VBLOCKPTR)0)
  16618.              VideoWriteString("Trouble saving video");
  16619.          }
  16620.  
  16621.          If there are no errors, VideoSave() returns a valid VBLOCKPTR.
  16622.  
  16623.  
  16624.          If there are errors VideoSave() returns a null VBLOCKPTR and
  16625.          sets the global integer CWLerror_code to the following
  16626.          value:
  16627.  
  16628.          NO_HEAP_MEM if there is not enough memory for the save buffer
  16629.          of the VBLOCKPTR.
  16630.  
  16631.          Page 264          The C Window Library               Page 264
  16632.  
  16633.          VideoMove()
  16634.          -----------
  16635.  
  16636.          The VideoMove() function moves a region saved by VideoSave()
  16637.          to a different location of the screen.  This location will be
  16638.          the new upper left hand corner of the rectangular region that
  16639.          was saved.  The move is not displayed until you call
  16640.          VideoRestore(), which is defined later.   Here is the
  16641.          prototype:
  16642.  
  16643.               void VideoMove(VBLOCKPTR v, int row, int col)
  16644.  
  16645.          The first argument is the VBLOCKPTR.  The second and third
  16646.          arguments are the new upper left hand position of the saved
  16647.          area.  There is NO check to see if the VBLOCKPTR exists, or
  16648.          the row or column are valid.
  16649.  
  16650.          Example:
  16651.  
  16652.          #include "cwlwin.h"
  16653.  
  16654.          VBLOCKPTR v;
  16655.  
  16656.          main()
  16657.          {
  16658.            WindowInitializeSystem();
  16659.            v = VideoSave(0,0,9,9);   /* Save Rectangular region
  16660.                                         defined by (0,0) (9,9) */
  16661.            VideoMove(v,0,9);
  16662.          }
  16663.  
  16664.          There is no return value for VideoMove().
  16665.  
  16666.  
  16667.  
  16668.  
  16669.          VideoRestore()
  16670.          --------------
  16671.  
  16672.          The VideoRestore() function takes a rectangular area of the
  16673.          screen saved with VideoSave() and redisplays the area.  Here
  16674.          is the prototype:
  16675.  
  16676.                         void VideoRestore(VBLOCKPTR v)
  16677.  
  16678.          The only argument is the VBLOCKPTR.  There is no check to see
  16679.          if the VBLOCKPTR is valid.
  16680.  
  16681.          Example:
  16682.  
  16683.          #include "cwlwin.h"
  16684.  
  16685.          VBLOCKPTR v;
  16686.  
  16687.  
  16688.  
  16689.  
  16690.  
  16691.          Page 265          The C Window Library               Page 265
  16692.  
  16693.          main()
  16694.          {
  16695.            WindowInitializeSystem();
  16696.            v = VideoSave(0,0,9,9);
  16697.            for (i=0;i<10;i++)
  16698.              VideoWriteString("This is the save area. "
  16699.                               "Press a key to restore.",i,0);
  16700.            GET_KEY();
  16701.            VideoRestore(v);
  16702.          }
  16703.  
  16704.  
  16705.          There is no return value for VideoRestore().
  16706.  
  16707.  
  16708.  
  16709.  
  16710.          VideoFree()
  16711.          -----------
  16712.  
  16713.          The VideoFree() function frees a previously defined
  16714.          VBLOCKPTR.  Here is the prototype:
  16715.  
  16716.                   void VideoFree(VBLOCKPTR v)
  16717.  
  16718.          The only argument is the VBLOCKPTR.  There is NO check to see
  16719.          if the VBLOCKPTR is valid,  therefore you must be very
  16720.          careful to call this function on a valid VBLOCKPTR.  If not,
  16721.          the heap will become corrupted.
  16722.  
  16723.          Example:
  16724.  
  16725.          #include "cwlwin.h"
  16726.  
  16727.          VBLOCKPTR v;
  16728.  
  16729.          main()
  16730.          {
  16731.            WindowInitializeSystem();
  16732.            v = VideoSave(0,0,9,9);
  16733.            for (i=0;i<10;i++)
  16734.              VideoWriteString("This is the save area. "
  16735.                               "Press a key to restore.",i,0);
  16736.            GET_KEY();
  16737.            VideoRestore(v);
  16738.            VideoFree(v);
  16739.          }
  16740.  
  16741.  
  16742.          There is no return value for VideoFree().
  16743.  
  16744.  
  16745.  
  16746.  
  16747.  
  16748.  
  16749.  
  16750.  
  16751.          Page 266          The C Window Library               Page 266
  16752.  
  16753.                           CLEARING SCREENS
  16754.                           ----------------
  16755.  
  16756.          The following functions clears the visible video page, and
  16757.          clears regions of the visible screen.
  16758.  
  16759.  
  16760.  
  16761.          ClearScreen()
  16762.          -------------
  16763.  
  16764.          The ClearScreen() function clears the visible video page with
  16765.          a specified attribute and moves the screen cursor to position
  16766.          (0,0).  Here is the prototype:
  16767.  
  16768.                        void ClearScreen(int attr)
  16769.  
  16770.          The only argument is the video attribute to use.
  16771.  
  16772.          Example:
  16773.  
  16774.  
  16775.          #include "cwlwin.h"
  16776.  
  16777.          main()
  16778.          {
  16779.            WindowInitializeSystem();
  16780.  
  16781.            /* Clear the entire screen */
  16782.            ClearScreen(CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  16783.          }
  16784.  
  16785.          There is no return value for ClearScreen().
  16786.  
  16787.  
  16788.  
  16789.  
  16790.  
  16791.  
  16792.          ClearRegion()
  16793.          -------------
  16794.  
  16795.          This function clears a rectangular region of the screen.
  16796.          Here is the prototype:
  16797.  
  16798.          void ClearRegion(int urow, int ucol, int lrow, int lcol,
  16799.                           int attr)
  16800.  
  16801.  
  16802.          The first two arguments represent the coordinate of the upper
  16803.          left hand coordinates of the rectangular region to clear.
  16804.          The third and fourth arguments represent the coordinate of
  16805.          the lower right hand corner of the rectangular region.  The
  16806.          last argument is the attribute to use.  There is no check to
  16807.          see if the coordinates are in bounds.
  16808.  
  16809.  
  16810.  
  16811.          Page 267          The C Window Library               Page 267
  16812.  
  16813.          Example:
  16814.  
  16815.          #include "cwlwin.h"
  16816.  
  16817.          main()
  16818.          {
  16819.            WindowInitializeSystem();
  16820.  
  16821.          /* Clear Region defined by (0,0) as the upper right hand
  16822.               corner and (9,9) as the lower right hand corner */
  16823.  
  16824.            ClearRegion(0,0,9,9,CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  16825.          }
  16826.  
  16827.  
  16828.          There is no return value for ClearRegion().
  16829.  
  16830.  
  16831.  
  16832.  
  16833.  
  16834.  
  16835.  
  16836.  
  16837.  
  16838.  
  16839.  
  16840.  
  16841.  
  16842.  
  16843.  
  16844.  
  16845.  
  16846.  
  16847.  
  16848.  
  16849.  
  16850.  
  16851.  
  16852.  
  16853.  
  16854.  
  16855.  
  16856.  
  16857.  
  16858.  
  16859.  
  16860.  
  16861.  
  16862.  
  16863.  
  16864.  
  16865.  
  16866.  
  16867.  
  16868.  
  16869.  
  16870.  
  16871.          Page 268          The C Window Library               Page 268
  16872.  
  16873.                           SCROLLING SCREENS
  16874.                           -----------------
  16875.  
  16876.          These functions scroll portions of the screen up or down.
  16877.  
  16878.  
  16879.  
  16880.          ScrollScreenUp()
  16881.          ----------------
  16882.  
  16883.          The ScrollScreenUp() function scrolls a rectangular portion
  16884.          of the screen up a specified number of lines.  Here is the
  16885.          prototype:
  16886.  
  16887.          void ScrollScreenUp(int numlines, int urow, int ucol,
  16888.                              int lrow, int lcol, int attr)
  16889.  
  16890.          The first argument is the number of lines to scroll the
  16891.          region.  The second and third arguments are the (row,col)
  16892.          coordinates of the upper left hand corner of the rectangular
  16893.          region to scroll.  The fourth and fifth arguments are the
  16894.          (row,col) of the lower right hand corner of the rectangular
  16895.          region.  The last argument is the attribute to use for blank
  16896.          lines created when the region is scrolled.
  16897.  
  16898.  
  16899.          Example:
  16900.  
  16901.          #include "cwlwin.h"
  16902.  
  16903.          main()
  16904.  
  16905.          {
  16906.            WindowInitializeSystem();
  16907.            ScrollScreenUp(1,0,2,4,9,
  16908.                           CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  16909.          }
  16910.  
  16911.          There is no return value for ScrollScreenUp().
  16912.  
  16913.  
  16914.  
  16915.          ScrollScreenDown()
  16916.          ------------------
  16917.  
  16918.  
  16919.          The ScrollScreenDown() function scrolls a rectangular portion
  16920.          of the screen down a specified number of lines.  Here is the
  16921.          prototype:
  16922.  
  16923.          void ScrollScreenDown(int numlines, int urow, int ucol,
  16924.                                int lrow, int lcol, int attr)
  16925.  
  16926.          The first argument is the number of lines to scroll the
  16927.          region.  The second and third arguments are the (row,col)
  16928.          coordinates of the upper left hand corner of the rectangular
  16929.          region to scroll.  The fourth and fifth arguments are the
  16930.  
  16931.          Page 269          The C Window Library               Page 269
  16932.  
  16933.          (row,col) of the lower right hand corner of the rectangular
  16934.          region.  The last argument is the attribute to use for blank
  16935.          lines created when the region is scrolled.
  16936.  
  16937.          Example:
  16938.  
  16939.          #include "cwlwin.h"
  16940.  
  16941.          main()
  16942.          {
  16943.            WindowInitializeSystem();
  16944.            ScrollScreenDown(1,0,2,4,9,
  16945.                             CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  16946.          }
  16947.  
  16948.          There is no return value for ScrollScreenDown().
  16949.  
  16950.  
  16951.  
  16952.  
  16953.  
  16954.  
  16955.  
  16956.  
  16957.  
  16958.  
  16959.  
  16960.  
  16961.  
  16962.  
  16963.  
  16964.  
  16965.  
  16966.  
  16967.  
  16968.  
  16969.  
  16970.  
  16971.  
  16972.  
  16973.  
  16974.  
  16975.  
  16976.  
  16977.  
  16978.  
  16979.  
  16980.  
  16981.  
  16982.  
  16983.  
  16984.  
  16985.  
  16986.  
  16987.  
  16988.  
  16989.  
  16990.  
  16991.          Page 270          The C Window Library               Page 270
  16992.  
  16993.                        CHANGING THE VIDEO MODE
  16994.                        -----------------------
  16995.  
  16996.          With The C Window Library, you can change the video mode at
  16997.          any time.  The video mode determines the width of the screen,
  16998.          and whether the screen is in text or graphics mode.
  16999.  
  17000.  
  17001.          SetVideoMode()
  17002.          --------------
  17003.  
  17004.          The SetVideoMode() function changes the video mode.  Here is
  17005.          a prototype:
  17006.  
  17007.                  void SetVideoMode(int modenum)
  17008.  
  17009.          The only argument is the mode number.  Refer to the Video
  17010.          Paging section on page 5 for more information on mode numbers
  17011.          and what they display.
  17012.  
  17013.          When the video mode is changed, the screen is cleared.  This
  17014.          cannot be prevented.  You must redisplay any windows that
  17015.          were on the screen.  If the change of video mode results in a
  17016.          change in screen dimensions, then you must read the following
  17017.          sections on CHANGING THE NUMBER OF ROWS AND COLUMNS ON THE
  17018.          SCREEN.  Even though The C Window Library does not support
  17019.          graphics mode, you can change to graphics mode in The C
  17020.          Window Library,
  17021.  
  17022.          Example:
  17023.  
  17024.          #include "cwlwin.h"
  17025.  
  17026.          main()
  17027.          {
  17028.            WindowInitializeSystem();
  17029.            SetVideoMode(3);          /* Change to video mode 3 */
  17030.          }
  17031.  
  17032.          There is no return value for SetVideoMode().
  17033.  
  17034.  
  17035.  
  17036.  
  17037.  
  17038.  
  17039.  
  17040.  
  17041.  
  17042.  
  17043.  
  17044.  
  17045.  
  17046.  
  17047.  
  17048.  
  17049.  
  17050.  
  17051.          Page 271          The C Window Library               Page 271
  17052.  
  17053.          CHANGING THE NUMBER OF ROWS AND COLUMNS ON THE SCREEN
  17054.          -----------------------------------------------------
  17055.  
  17056.  
  17057.          Changing rows
  17058.          -------------
  17059.  
  17060.          With The C Window Library, you can change the number of rows
  17061.          on the video screen.  However, there are some things to watch
  17062.          out for when changing the number of rows, especially if you
  17063.          have windows displayed on the screen.
  17064.  
  17065.          If you are not using any window related functions, you can
  17066.          change the number of displayable rows safely by doing two
  17067.          things:
  17068.  
  17069.          a) Call the SetVideoRows() function to change the number of
  17070.             rows.
  17071.  
  17072.          b) Call AdjustGlobalData() to adjust the global variables
  17073.             used by The C Window Library that keep track of the screen
  17074.             dimensions.
  17075.  
  17076.  
  17077.          If you are going to create or have created windows you should
  17078.          do the following:
  17079.  
  17080.          a)  Call the SetVideoRows() function.
  17081.  
  17082.          b)  Call the AdjustScreenInfo() function.  This function
  17083.              adjusts all global variables defined in The C Window
  17084.              Library to reflect the new number of rows.
  17085.  
  17086.          Whether there are or are not windows defined, the visible
  17087.          video page MUST be page 0 before changing the number of
  17088.          screen rows.
  17089.  
  17090.  
  17091.  
  17092.          AdjustScreenInfo()
  17093.          ------------------
  17094.  
  17095.          This function must be called after SetVideoRows() is called
  17096.          if you are going to, or have initialized and/or displayed
  17097.          windows.  Here is the prototype:
  17098.  
  17099.                      int AdjustScreenInfo(int page)
  17100.  
  17101.          The only argument is the video page to adjust to the new
  17102.          screen height.  Because of the new dimension of the screen,
  17103.          there has to be a reshuffling of a few global arrays,
  17104.          constants, variables, etc.  The AdjustScreenInfo() function
  17105.          does just this.  If you do not call AdjustScreenInfo(), you
  17106.          may see problems if you try to manipulate windows on the new
  17107.          screen.
  17108.  
  17109.  
  17110.  
  17111.          Page 272          The C Window Library               Page 272
  17112.  
  17113.          See SetVideoRows() for an example of AdjustScreenInfo().
  17114.  
  17115.                 Return Values for AdjustScreenInfo():
  17116.  
  17117.              Return Value            Definition
  17118.          ┌─────────────┬────────────────────────────────┐
  17119.          │NO_ERROR     │ No error occured.              │
  17120.          ├─────────────┼────────────────────────────────┤
  17121.          │NO_HEAP_MEM  │ Not enough memory to allocate. │
  17122.          └─────────────┴────────────────────────────────┘
  17123.  
  17124.  
  17125.  
  17126.  
  17127.          AdjustGlobalData()
  17128.          ------------------
  17129.  
  17130.          The AdjustGlobalData() function should be called after you
  17131.          have changed the number of video rows using SetVideoRows()
  17132.          (defined below).  This resets the global variables necessary
  17133.          for non-window functions to execute properly.  Here is the
  17134.          prototype:
  17135.  
  17136.                       void AdjustGlobalData(void)
  17137.  
  17138.          There are no arguments and no return value for
  17139.          AdjustGlobalData().  If you have called AdjustScreenInfo(),
  17140.          you do not have to call AdjustGlobalData().
  17141.  
  17142.          See below for an example of AdjustGlobalData().
  17143.  
  17144.  
  17145.  
  17146.  
  17147.  
  17148.  
  17149.          SetVideoRows()
  17150.          --------------
  17151.  
  17152.          The SetVideoRows() function changes the number of video rows
  17153.          on the screen.  Here is a list of video adapters and there
  17154.          row number capabilities:
  17155.  
  17156.  
  17157.              Video Type                 Number of Rows
  17158.                                            Possible
  17159.              ----------                 --------------
  17160.              CGA, MDA, Hercules             25
  17161.  
  17162.              EGA                            25, 43
  17163.  
  17164.              MCGA                           25, 50
  17165.  
  17166.              VGA                            12, 14, 21, 25, 28, 43, 50
  17167.                                             or more
  17168.  
  17169.  
  17170.  
  17171.          Page 273          The C Window Library               Page 273
  17172.  
  17173.          The list above are the values SetVideoRows() uses, depending
  17174.          on the adapter that The C Window Library has detected.  If
  17175.          your video card supports a row configuration that is not
  17176.          supported by the SetVideoRows() function,  consult the
  17177.          'Changing columns' section and proceed as if you are changing
  17178.          the number of columns.
  17179.  
  17180.          Here is the prototype for SetVideoRows():
  17181.  
  17182.                 int SetVideoRows(int numrows, int modeflag)
  17183.  
  17184.  
  17185.          The first argument is the number of screen rows.  The
  17186.          modeflag tells whether the video mode should be reset.  If
  17187.          modeflag is 0, the video mode is not reset.  Any other value
  17188.          for modeflag will cause a video mode reset.  This reset may
  17189.          or may not be necessary, so experiment with both values for
  17190.          modeflag.
  17191.  
  17192.          Example:
  17193.  
  17194.          #include "cwlwin.h"
  17195.  
  17196.          main()
  17197.          {
  17198.            WindowInitializeSystem();
  17199.            ClearScreen(CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  17200.            VideoWriteString(
  17201.                     "Press a key to change to a new video mode",0,0);
  17202.  
  17203.            GET_KEY();
  17204.            if (VGA_MODE_ON || MCGA_MODE_ON)
  17205.              SetVideoRows(50,0);
  17206.            else
  17207.            if (EGA_MODE_ON)
  17208.              SetVideoRows(43,0);
  17209.            else
  17210.            {
  17211.              VideoWriteString(
  17212.               "Hardware does not support changing video rows",1,0);
  17213.              exit(0);
  17214.            }
  17215.  
  17216.            AdjustGlobalData();
  17217.            VideoWriteString(
  17218.                   "Press a key again to change to 25 lines",1,0);
  17219.  
  17220.            GET_KEY();
  17221.            SetVideoRows(25,0);
  17222.            AdjustGlobalData();
  17223.          }
  17224.  
  17225.  
  17226.          The example above uses the constants VGA_MODE_ON,
  17227.          MCGA_MODE_ON, and EGA_MODE_ON.  These constants are discussed
  17228.          in the VIDEO MACROS section.
  17229.  
  17230.  
  17231.          Page 274          The C Window Library               Page 274
  17232.  
  17233.          Here is another example, but now we have a window on the
  17234.          screen.
  17235.  
  17236.          Example:
  17237.  
  17238.          #include "cwlwin.h"
  17239.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  17240.  
  17241.          WPOINTER w;
  17242.          main()
  17243.          {
  17244.            WindowInitializeSystem();
  17245.            WindowInitDesktop(0);
  17246.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,
  17247.                                 10,NORM,NORM,SINGLEBOX);
  17248.            WindowDisplay(w,1,NOEFFECT);
  17249.            WindowWriteString(w,"Press a key to change rows",0,0);
  17250.            GET_KEY();
  17251.            if (VGA_MODE_ON || MCGA_MODE_ON)
  17252.              SetVideoRows(50,0);
  17253.            else
  17254.            if (EGA_MODE_ON)
  17255.              SetVideoRows(43,0);
  17256.            else
  17257.            {
  17258.  
  17259.             WindowWriteString(w,"Cannot change rows",0,0);
  17260.              exit(0);
  17261.            }
  17262.  
  17263.            /* Adjust the screen information */
  17264.            AdjustScreenInfo(0);
  17265.  
  17266.            /* OK to adjust to new height */
  17267.            WindowResizeHeight(w,40,ANCHORTOP);
  17268.  
  17269.            WindowWriteString(w,"Now press a key to change back",1,0);
  17270.            GET_KEY();
  17271.  
  17272.            /*  First we must resize window */
  17273.            WindowResizeHeight(w,10,ANCHORTOP);
  17274.  
  17275.            SetVideoRows(25,0);
  17276.            AdjustScreenInfo(0);
  17277.  
  17278.          }
  17279.  
  17280.          Note the use of AdjustScreenInfo() after a reset is made.
  17281.  
  17282.                   Return Values for SetVideoRows();
  17283.  
  17284.              Return Value            Definition
  17285.          ┌───────────────────┬────────────────────────────────┐
  17286.          │NO_ERROR           │ No error occured.              │
  17287.          ├───────────────────┼────────────────────────────────┤
  17288.          │INVALID_ROWS       │ number of rows not supported.  │
  17289.          └───────────────────┴────────────────────────────────┘
  17290.  
  17291.          Page 275          The C Window Library               Page 275
  17292.  
  17293.          Changing columns
  17294.          ----------------
  17295.  
  17296.          The number of columns can be changed, but there are two
  17297.          things to watch out for.  First, to change from 40 column
  17298.          mode to 80 column mode or vice-versa, is a matter of changing
  17299.          the video mode.  Changing the video mode from 40 to 80 column
  17300.          mode or from 80 to 40 requires a BIOS function that is
  17301.          present on all systems that support 40 column mode.
  17302.  
  17303.  
  17304.  
  17305.          40 column and 80 column modes
  17306.          -----------------------------
  17307.  
  17308.          To change to 40 column mode do the following:
  17309.  
  17310.          SetVideoMode(0);   /* this changes to 40 column
  17311.                                Black and White mode */
  17312.  
  17313.               or
  17314.  
  17315.  
  17316.          SetVideoMode(1);   /* this changes to 40 column color mode */
  17317.  
  17318.          The example above only works if you have a CGA, EGA, MCGA, or
  17319.          VGA card.
  17320.  
  17321.  
  17322.  
  17323.          To change to 80 column mode do the following:
  17324.  
  17325.          SetVideoMode(2);  /* this changes to Black and White
  17326.                               80 column mode */
  17327.  
  17328.               or
  17329.  
  17330.          SetVideoMode(3);  /* use this for color 80 column mode */
  17331.  
  17332.               or
  17333.  
  17334.          SetVideoMode(7);  /* use this for mono cards */
  17335.  
  17336.          SetVideoMode(7) works for all adapters, while SetVideoMode(2)
  17337.          and SetVideoMode(3) works only for CGA, EGA, MCGA, or VGA
  17338.          cards.
  17339.  
  17340.  
  17341.          Modes higher than 80 columns
  17342.          ----------------------------
  17343.  
  17344.          There are video systems that support video modes greater than
  17345.          80 columns.  The problem is that for each different brand of
  17346.          video adapter, there is a unique way of changing to a higher
  17347.          column mode.  Most of these adapters support an additional
  17348.          BIOS function that must be called to change to any screen
  17349.  
  17350.  
  17351.          Page 276          The C Window Library               Page 276
  17352.  
  17353.          column mode higher than 80.  Therefore, it is up to you (the
  17354.          programmer) to find out how to change the video system from
  17355.          80 columns to a higher column mode.  Once you are familiar
  17356.          with how to do this, changing the number of columns is almost
  17357.          the same as changing the number of rows.
  17358.  
  17359.          If you are using any window related functions, you can change
  17360.          the number of displayable columns safely by doing two
  17361.          things:
  17362.  
  17363.          a) Call the appropriate routine to change the number of
  17364.             columns.  If this is a call to SetVideoMode(), the screen
  17365.             will be cleared.
  17366.  
  17367.          b) Call AdjustScreenInfo() to adjust the global variables
  17368.             used by The C Window Library that keep track of the screen
  17369.             dimensions.
  17370.  
  17371.          If you are not using any windows in your application, replace
  17372.          the call to AdjustScreenInfo() in step b) with a call to
  17373.          AdjustGlobalData().
  17374.  
  17375.          This example works for the ATI VGA card.  This changes the
  17376.          mode to 132 columns:
  17377.  
  17378.          #include "cwlwin.h"
  17379.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  17380.  
  17381.          WPOINTER w;
  17382.  
  17383.          main()
  17384.          {
  17385.            WindowInitializeSystem();
  17386.            WindowInitDesktop(0);
  17387.            w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,30,10,
  17388.                                 NORM,NORM,SINGLEBOX);
  17389.            WindowDisplay(w,1,NOEFFECT);
  17390.            WindowWriteString(w,"Press a key to change columns",0,0);
  17391.            GET_KEY();
  17392.  
  17393.            /* Set Video Mode to 132 columns x 25 rows
  17394.               (Works for ATI VGA card) */
  17395.            SetVideoMode(0x23);
  17396.            /* Adjust the screen information and redisplay window */
  17397.            AdjustScreenInfo(0);
  17398.            WindowDisplay(w,1,NOEFFECT);
  17399.  
  17400.            /* OK to adjust to new height */
  17401.            WindowResizeWidth(w,100,ANCHORLEFT);
  17402.  
  17403.  
  17404.            WindowWriteString(w,"Now press a key to change back",1,0);
  17405.            GET_KEY();
  17406.  
  17407.            /*  First we must resize window */
  17408.            WindowResizeWidth(w,30,ANCHORLEFT);
  17409.  
  17410.  
  17411.          Page 277          The C Window Library               Page 277
  17412.  
  17413.            /* Set back to 80 column mode */
  17414.            SetVideoMode(3);
  17415.            AdjustScreenInfo(0);
  17416.            WindowDisplay(w,1,NOEFFECT);
  17417.          }
  17418.  
  17419.  
  17420.  
  17421.  
  17422.  
  17423.  
  17424.  
  17425.  
  17426.  
  17427.  
  17428.  
  17429.  
  17430.  
  17431.  
  17432.  
  17433.  
  17434.  
  17435.  
  17436.  
  17437.  
  17438.  
  17439.  
  17440.  
  17441.  
  17442.  
  17443.  
  17444.  
  17445.  
  17446.  
  17447.  
  17448.  
  17449.  
  17450.  
  17451.  
  17452.  
  17453.  
  17454.  
  17455.  
  17456.  
  17457.  
  17458.  
  17459.  
  17460.  
  17461.  
  17462.  
  17463.  
  17464.  
  17465.  
  17466.  
  17467.  
  17468.  
  17469.  
  17470.  
  17471.          Page 278          The C Window Library               Page 278
  17472.  
  17473.                          CURSOR MANIPULATION
  17474.                          -------------------
  17475.  
  17476.          The functions defined in this section manipulate the cursor.
  17477.          The following functions can be called without calling
  17478.          WindowInitializeSystem().
  17479.  
  17480.  
  17481.          MoveCursor()
  17482.          ------------
  17483.  
  17484.          This function moves the cursor to a different location.  Here
  17485.          is the prototype:
  17486.  
  17487.                 void MoveCursor(int row, int col, int page)
  17488.  
  17489.          The first two arguments are the row and column positions of
  17490.          where to move the cursor.  The last argument is the video
  17491.          page of the cursor you want to move.
  17492.  
  17493.  
  17494.          Example:
  17495.  
  17496.          #include "cwlwin.h"
  17497.  
  17498.          main()
  17499.          {
  17500.            MoveCursor(0,4,0);    /* Move cursor to row 0 column 4
  17501.                                     on video page 0 */
  17502.          }
  17503.  
  17504.          There is no return value for MoveCursor().
  17505.  
  17506.  
  17507.  
  17508.          ChangeCursor()
  17509.          --------------
  17510.  
  17511.          The ChangeCursor() function changes the shape of the cursor.
  17512.          The shape of the cursor is determined by its starting and
  17513.          ending scan lines.  Here is a prototype:
  17514.  
  17515.            void ChangeCursor(unsigned startline, unsigned endline)
  17516.  
  17517.          The first argument is the starting scan line and the second
  17518.          argument is the ending scan line.  For monochrome systems,
  17519.          there are 12 scan lines numbered 0 thru 11, while on color
  17520.          systems there are 8 scan lines numbered 0 thru 7.  The
  17521.          starting scan line is the top line of the cursor, and the
  17522.          ending scan line is the last line of the cursor.  There is no
  17523.          check to see if the starting scan line and the ending scan
  17524.          lines are valid.
  17525.  
  17526.  
  17527.  
  17528.  
  17529.  
  17530.  
  17531.          Page 279          The C Window Library               Page 279
  17532.  
  17533.          Example:
  17534.  
  17535.          #include "cwlwin.h"
  17536.  
  17537.          main()
  17538.          {
  17539.            WindowInitializeSystem();
  17540.            ChangeCursor(6,7);  /* This is an underline cursor */
  17541.            GET_KEY();
  17542.            ChangeCursor(0,7);  /* This is a thick cursor */
  17543.          }
  17544.  
  17545.          There is no return for ChangeCursor().
  17546.  
  17547.  
  17548.  
  17549.          GetCursorShape()
  17550.          ----------------
  17551.  
  17552.          This function returns the shape of the cursor in scan lines.
  17553.          Here is the prototype:
  17554.  
  17555.            void GetCursorShape(unsigned *startline, unsigned *endline)
  17556.  
  17557.          When this function returns, the staring scan line is placed
  17558.          in the integer pointed to by scanline, and the ending scan
  17559.          line is placed in the integer pointed to by endline.
  17560.  
  17561.          Example:
  17562.  
  17563.          #include "cwlwin.h"
  17564.  
  17565.          main()
  17566.          {
  17567.            int start, end;
  17568.            WindowInitializeSystem();
  17569.            GetCursorShape(&start, &end);
  17570.            VideoPrintf("\nThe starting scan line is %d\n"
  17571.                        "The ending scan line is %d", start,end);
  17572.          }
  17573.  
  17574.          There is no return value for GetCursorShape().
  17575.  
  17576.  
  17577.  
  17578.          GetCursorPosition()
  17579.          -------------------
  17580.  
  17581.          This function gets the current cursor position.  Here is the
  17582.          prototype:
  17583.  
  17584.             void GetCursorPosition(int *row, int *col, int page)
  17585.  
  17586.          The first argument is a pointer to an integer that will be
  17587.          set to the current row.  The second argument is a pointer to
  17588.          an integer that will be set to the current column.  The last
  17589.          argument is the video page of the cursor.
  17590.  
  17591.          Page 280          The C Window Library               Page 280
  17592.  
  17593.          Example:
  17594.  
  17595.          #include "cwlwin.h"
  17596.  
  17597.          main()
  17598.          {
  17599.            int row,col;
  17600.            MoveCursor(10,15);
  17601.            GetCursorPosition(&row,&col,0);
  17602.            WindowInitializeSystem();
  17603.            VideoPrintf("\nThe row of the cursor is %d\n"
  17604.                        "The column is %d", row,col);
  17605.          }
  17606.  
  17607.  
  17608.          There is no return value for GetCursorPosition().
  17609.  
  17610.  
  17611.  
  17612.          The following functions serve as shortcuts in changing the
  17613.          cursor shape.
  17614.  
  17615.  
  17616.          HideCursor()
  17617.          ------------
  17618.  
  17619.          Hides the cursor on the screen.  Here is the prototype:
  17620.  
  17621.  
  17622.                       void HideCursor(void)
  17623.  
  17624.  
  17625.          BlockCursor()
  17626.          -------------
  17627.  
  17628.          Displays the cursor as a thick block.
  17629.  
  17630.                       void BlockCursor(void)
  17631.  
  17632.          ThinCursor()
  17633.          ------------
  17634.  
  17635.          Displays the cursor as an underline cursor.
  17636.  
  17637.                       void ThinCursor(void)
  17638.  
  17639.  
  17640.          Example:
  17641.  
  17642.          #include "cwlwin.h"
  17643.  
  17644.          main()
  17645.          {
  17646.            WindowInitializeSystem();
  17647.            MoveCursor(0,0,0);
  17648.            VideoWriterString("Press a key to hide the cursor",0,0);
  17649.  
  17650.  
  17651.          Page 281          The C Window Library               Page 281
  17652.  
  17653.            GET_KEY();
  17654.            HideCursor();
  17655.            VideoWriterString(
  17656.                    "Press a key to change cursor to a block",1,0);
  17657.            GET_KEY();
  17658.            BlockCursor();
  17659.            VideoWriterString(
  17660.               "Press a key to change cursor to a thin cursor",2,0);
  17661.            GET_KEY();
  17662.            ThinCursor();
  17663.          }
  17664.  
  17665.  
  17666.          There are no return values for HideCursor(), BlockCursor(),
  17667.          or ThinCursor().
  17668.  
  17669.  
  17670.  
  17671.  
  17672.  
  17673.  
  17674.  
  17675.  
  17676.  
  17677.  
  17678.  
  17679.  
  17680.  
  17681.  
  17682.  
  17683.  
  17684.  
  17685.  
  17686.  
  17687.  
  17688.  
  17689.  
  17690.  
  17691.  
  17692.  
  17693.  
  17694.  
  17695.  
  17696.  
  17697.  
  17698.  
  17699.  
  17700.  
  17701.  
  17702.  
  17703.  
  17704.  
  17705.  
  17706.  
  17707.  
  17708.  
  17709.  
  17710.  
  17711.          Page 282          The C Window Library               Page 282
  17712.  
  17713.                       GETTING VIDEO INFORMATION
  17714.                       -------------------------
  17715.  
  17716.  
  17717.          You can get information about the video configuration by
  17718.          calling the GetVideoBiosInfo() function.
  17719.  
  17720.  
  17721.          VIDEO_CONFIG structure
  17722.          ----------------------
  17723.  
  17724.          To get information about the video configuration, you must
  17725.          pass a pointer to a VIDEO_CONFIG structure.  This structure
  17726.          is defined as follows:
  17727.  
  17728.  
  17729.          typedef struct tagVIDEOSTRUCT
  17730.          {
  17731.            unsigned int video_mode;          /* Current video mode */
  17732.            unsigned int cursor_startline;    /* Starting scan line of
  17733.                                                 cursor */
  17734.            unsigned int cursor_endline;      /* Ending scan line of
  17735.                                                 cursor */
  17736.            unsigned int cursor_row;          /* Screen row of cursor */
  17737.            unsigned int cursor_col;          /* Column of cursor */
  17738.            unsigned int video_page;          /* Current visible video
  17739.                                                 page */
  17740.            unsigned int video_pagesize;      /* Size in bytes of the
  17741.                                                  video page     */
  17742.            unsigned int video_rows;          /* Number of displayable
  17743.                                                 rows */
  17744.  
  17745.            unsigned int video_cols;          /* Number of displayable
  17746.                                                 columns *    /
  17747.            unsigned int char_height;         /* Height (in scan lines)
  17748.                                                 of a character  */
  17749.            unsigned int crt_port_address;    /* Address of CRT status
  17750.                                                 port */
  17751.            unsigned int crt_mode_setting;    /* Current CRT Mode
  17752.                                                 Setting   */
  17753.            unsigned int crt_color_setting;   /* Current CRT color
  17754.                                                 settings */
  17755.          } VIDEO_CONFIG;
  17756.  
  17757.  
  17758.  
  17759.          GetVideoBiosInfo()
  17760.          ------------------
  17761.  
  17762.          This function returns information about the current video
  17763.          configuration.  Here is the prototype:
  17764.  
  17765.                void GetVideoBiosInfo(VIDEO_CONFIG *v)
  17766.  
  17767.          The only argument is a pointer to a VIDEO_CONFIG structure.
  17768.          This structure is filled in with the appropriate values.
  17769.  
  17770.  
  17771.          Page 283          The C Window Library               Page 283
  17772.  
  17773.          Example:
  17774.  
  17775.  
  17776.          #include "cwlwin.h"
  17777.  
  17778.          VIDEO_CONFIG v;
  17779.  
  17780.          main()
  17781.          {
  17782.            WindowInitializeSystem();
  17783.  
  17784.            /* Get video information */
  17785.            ClearScreen(CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_));
  17786.            GetVideoBiosInfo(&v);
  17787.            VideoPrintf("The video mode is %d\n"
  17788.                        "The starting scan line of the cursor is %d\n"
  17789.                        "The ending scan line of the cursor is %d \n"
  17790.                        "The row of the cursor is %d \n"
  17791.                        "The column of the cursor is %d\n"
  17792.                        "The video page is %d\n"
  17793.                        "The size of the video page is %d\n"
  17794.                        "The number of rows is %d\n"
  17795.                        "The number of columns is %d\n"
  17796.                        "The height of the characters is %d\n",
  17797.                        v.video_mode, v.cursor_startline,
  17798.                        v.cursor_endline,
  17799.                        v.cursor_row,v.cursor_col,
  17800.                        v.video_page, v.video_pagesize,
  17801.                        v.video_rows, v.video_cols,
  17802.                        v.char_height);
  17803.  
  17804.          }
  17805.  
  17806.  
  17807.          There is no return value for GetVideoBiosInfo().
  17808.  
  17809.  
  17810.  
  17811.  
  17812.  
  17813.  
  17814.  
  17815.  
  17816.  
  17817.  
  17818.  
  17819.  
  17820.  
  17821.  
  17822.  
  17823.  
  17824.  
  17825.  
  17826.  
  17827.  
  17828.  
  17829.  
  17830.  
  17831.          Page 284          The C Window Library               Page 284
  17832.  
  17833.                             TIMED DELAYS
  17834.                             ------------
  17835.  
  17836.          One of the problems that has been addressed in The C Window
  17837.          Library is the lack of a delay() function in most C compiler
  17838.          packages.  The delay() function delays program execution for
  17839.          a certain number of milliseconds.  Borland's Turbo C compiler
  17840.          is one of the few that has a delay() function.  The other
  17841.          compilers may have a sleep() function, but usually these
  17842.          functions do not have millisecond accuracy.
  17843.  
  17844.          One of the problems was to write a delay() function that
  17845.          would work for all the major C compilers, work with
  17846.          millisecond accuracy, work for any speed PC, and last but not
  17847.          least, without using floating point arithmetic.  This
  17848.          function was written in assembly language for accuracy.  The
  17849.          use of the delay() is used extensively in displaying and
  17850.          hiding windows with certain special effects.
  17851.  
  17852.  
  17853.          delay()
  17854.          -------
  17855.  
  17856.          The delay() function delays the program for a certain number
  17857.          of milliseconds.  Here is the prototype:
  17858.  
  17859.                     void delay(unsigned millisecs)
  17860.  
  17861.  
  17862.          The only argument is the number of milliseconds to delay.  If
  17863.          you are using the Turbo C version of The C Window Library,
  17864.          this function is already included in the Turbo C library.
  17865.          However, if you are using another compiler you now have a
  17866.          delay() function!
  17867.  
  17868.  
  17869.          Example:
  17870.  
  17871.          main()
  17872.          {
  17873.            WindowInitializeSystem();
  17874.            delay(50);   /* Delay for 50 milliseconds */
  17875.          }
  17876.  
  17877.          You must call WindowInitializeSystem() before using delay().
  17878.  
  17879.          There is no return value for delay().
  17880.  
  17881.  
  17882.  
  17883.  
  17884.  
  17885.  
  17886.  
  17887.  
  17888.  
  17889.  
  17890.  
  17891.          Page 285          The C Window Library               Page 285
  17892.  
  17893.                            SOUND FUNCTIONS
  17894.                            ---------------
  17895.  
  17896.          The C Window Library also supports sound functions for
  17897.          compilers that are lacking these functions.
  17898.  
  17899.  
  17900.          sound() and nosound()
  17901.          ---------------------
  17902.  
  17903.          The sound() function sounds a tone with a specified frequency
  17904.          in Hertz (cycles per second).  Here is a prototype:
  17905.  
  17906.                      void sound(unsigned frequency)
  17907.  
  17908.          The nosound() function turns off the tone generated by the
  17909.          sound() function.
  17910.  
  17911.  
  17912.          Example:
  17913.  
  17914.          #include "cwlwin.h"
  17915.  
  17916.          main()
  17917.          {
  17918.            unsigned i;
  17919.            WindowInitializeSystem();
  17920.  
  17921.           for (i=100;i<=1000;i++)
  17922.              sound(i);
  17923.            for(i=1000;i>=100;i--)
  17924.              sound(i);
  17925.            nosound();
  17926.          }
  17927.  
  17928.          Note for Turbo users:
  17929.  
  17930.          You should include "dos.h" in your files that contain sound()
  17931.          and nosound().  All other compilers should include
  17932.          "cwlwin.h".
  17933.  
  17934.          Note for Power C users:  If you are using the Power C
  17935.          compiler, you must include "cwlwin.h" or any file that
  17936.          includes cwlwin.h after bios.h.  This is to ensure that the
  17937.          linker does not get confused with the Power C function
  17938.          called sound(), which works differently than the sound()
  17939.          function defined above.
  17940.  
  17941.  
  17942.  
  17943.          MakeSound()
  17944.          -----------
  17945.  
  17946.          The MakeSound() function sounds a tone for a duration of
  17947.          time.  Here is the prototype:
  17948.  
  17949.              void MakeSound(unsigned freq, unsigned millisec)
  17950.  
  17951.          Page 286          The C Window Library               Page 286
  17952.  
  17953.          where freq is the frequency of the tone (in Hertz) and
  17954.          millisec is the number of milliseconds to sound the tone.
  17955.  
  17956.  
  17957.          Example:
  17958.          --------
  17959.  
  17960.          #include "cwlwin.h"
  17961.  
  17962.          main()
  17963.          {
  17964.            WindowInitializeSystem();
  17965.            /* Produce a 440 Hertz tone for 3 seconds */
  17966.            MakeSound(440,3000);
  17967.          }
  17968.  
  17969.          There is no error return for this function.
  17970.  
  17971.  
  17972.  
  17973.  
  17974.  
  17975.  
  17976.  
  17977.  
  17978.  
  17979.  
  17980.  
  17981.  
  17982.  
  17983.  
  17984.  
  17985.  
  17986.  
  17987.  
  17988.  
  17989.  
  17990.  
  17991.  
  17992.  
  17993.  
  17994.  
  17995.  
  17996.  
  17997.  
  17998.  
  17999.  
  18000.  
  18001.  
  18002.  
  18003.  
  18004.  
  18005.  
  18006.  
  18007.  
  18008.  
  18009.  
  18010.  
  18011.          Page 287          The C Window Library               Page 287
  18012.  
  18013.                            ERROR HANDLING
  18014.                            --------------
  18015.  
  18016.          Whenever an error has occurred in The C Window Library, a
  18017.          user defined error function can be called.
  18018.  
  18019.  
  18020.  
  18021.  
  18022.          The CWLerror_func function pointer
  18023.          ----------------------------------
  18024.  
  18025.          The CWLerror_func function pointer can point to an error
  18026.          function that is performed whenever there is an error
  18027.          encountered in one of The C Window Library functions.  If the
  18028.          global variable CWLcheck_existence_flag is set to 1 and there
  18029.          is an error, The C Window Library will automatically call
  18030.          CWLerror_func.  Here is the prototype:
  18031.  
  18032.          void (*CWLerror_func)(int errcode, char *sourcefile,
  18033.                                int sourceline, char *funcname)
  18034.  
  18035.          The errcode is one of the defined error codes included in The
  18036.          C Window Library.  Refer to page 6 of the main documentation
  18037.          for more information of the error codes and their
  18038.          definitions.  The second argument is the name of the file
  18039.          where the error occurred.  Only users with the source code to
  18040.          The C Window Library will have access to this file.  The
  18041.          third argument is the offending line in the source file of
  18042.          where the error occurred.  The last argument is the name of
  18043.          the function of where the error occurred.
  18044.  
  18045.          By default CWLerror_func points to a void null function
  18046.          (VOIDNULLFN), therefore no error function is called.
  18047.  
  18048.          Here is an example of how to implement automatic error
  18049.          checking:
  18050.  
  18051.          #include "cwlwin.h"
  18052.          #define WHITEONRED CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  18053.          void custom_error_func(int, char *, int, char *);
  18054.  
  18055.          WPOINTER w, error_window;
  18056.          void initialize_error();
  18057.          main()
  18058.          {
  18059.            WindowInitializeSystem();
  18060.            WindowInitDesktop(0);
  18061.            CWLerror_func = custom_error_func;  /* Assign error
  18062.                                                       function */
  18063.            initialize_error();
  18064.            WindowDisplay(w,1,NOEFFECT); /* This line will be flagged
  18065.                                            for an error */
  18066.          }
  18067.  
  18068.          void initialize_error()    /* Initialize error window and
  18069.                                        error handler */
  18070.  
  18071.          Page 288          The C Window Library               Page 288
  18072.  
  18073.          {
  18074.            error_window =
  18075.                  WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,60,5,
  18076.                                   WHITEONRED,
  18077.                                   WHITEONRED,SINGLEBOX);
  18078.          }
  18079.  
  18080.  
  18081.          void custom_error_func(int errcode, char *sourcefile,
  18082.                                 int sourceline, char *funcname)
  18083.          {
  18084.            int ch;
  18085.            MakeSound(100,500);           /* Produce an error beep */
  18086.            if (errcode == NO_HEAP_MEM)   /* Always check for the heap
  18087.                                             memory error separately */
  18088.            {
  18089.              VideoWriteString("You have ran out of Heap Memory",0,0);
  18090.              VideoWriteString(
  18091.             "Press 'Q' to quit program, Any other key to Continue...",
  18092.                               1,0);
  18093.            }
  18094.  
  18095.            else                         /* Display error window */
  18096.            {
  18097.  
  18098.              WindowClear(error_window);
  18099.              WindowDisplay(error_window,1,EXPLODE);
  18100.              WindowPrintf(error_window,
  18101.               "Error Code: %d\nSource File: %s\nSource Line %d\n"
  18102.               "Error Occurred in %s",
  18103.                errcode,sourcefile,sourceline,funcname);
  18104.  
  18105.              WindowWriteString(error_window,
  18106.             "Press 'Q' to quit program, Any other key to Continue...",
  18107.                                4,0);
  18108.            }
  18109.  
  18110.            ch = GET_KEY();
  18111.            if (ch == 'Q' || ch == 'q')
  18112.              exit(0);
  18113.            else
  18114.            if (errcode != NO_HEAP_MEM)
  18115.              WindowHide(error_window,CONTRACT);
  18116.          }
  18117.  
  18118.  
  18119.          The above example initializes an error window and sets the
  18120.          CWLerror_func function pointer to point to the function
  18121.          custom_error_func().  Whenever an error occurs in The C
  18122.          Window Library, custom_error_func() will be called.
  18123.  
  18124.          Please note the check to see if the NO_HEAP_MEM error has
  18125.          occurred.  It is important that you check for this error
  18126.          condition separately.  The reason for this is that if there
  18127.          is not enough heap memory, you may inadvertently call a
  18128.          function in your error handler that calls on malloc() or any
  18129.          of the other memory allocation related functions.  This will
  18130.  
  18131.          Page 289          The C Window Library               Page 289
  18132.  
  18133.          either freeze your system, or more peculiarly, cause your
  18134.          error handler to be called in an infinite loop because of the
  18135.          repeated failing calls to malloc() or its related functions.
  18136.          In the latter case, you will run out of stack space.
  18137.  
  18138.          If you want to unassign the CWLerror_code function
  18139.          pointer, use the following line in your code:
  18140.  
  18141.                     CWLerror_func = VOIDNULLFN;
  18142.  
  18143.  
  18144.  
  18145.  
  18146.  
  18147.  
  18148.  
  18149.  
  18150.  
  18151.  
  18152.  
  18153.  
  18154.  
  18155.  
  18156.  
  18157.  
  18158.  
  18159.  
  18160.  
  18161.  
  18162.  
  18163.  
  18164.  
  18165.  
  18166.  
  18167.  
  18168.  
  18169.  
  18170.  
  18171.  
  18172.  
  18173.  
  18174.  
  18175.  
  18176.  
  18177.  
  18178.  
  18179.  
  18180.  
  18181.  
  18182.  
  18183.  
  18184.  
  18185.  
  18186.  
  18187.  
  18188.  
  18189.  
  18190.  
  18191.          Page 290          The C Window Library               Page 290
  18192.  
  18193.                USING A MOUSE WITH THE C WINDOW LIBRARY
  18194.                ---------------------------------------
  18195.  
  18196.          With The C Window Library, you can create applications that
  18197.          use a Microsoft compatible mouse to select from popup,
  18198.          pulldown, and bar menus as well as getting mouse presses.
  18199.          Using the mouse for menus will be discussed in this section,
  18200.          while getting and testing for button presses will be
  18201.          discussed in the KEYBOARD MACROS section below.
  18202.  
  18203.  
  18204.          Installing the Mouse Library
  18205.          ----------------------------
  18206.  
  18207.          Before using the mouse library, make sure that you read the
  18208.          README file concerning installing the mouse library.
  18209.  
  18210.  
  18211.  
  18212.          Initializing the Mouse with MouseInitializeSystem()
  18213.          ---------------------------------------------------
  18214.  
  18215.          Before you can use a mouse, you must initialize it by calling
  18216.          MouseInitializeSystem().  This function tests for a Microsoft
  18217.          compatible mouse and returns a value denoting whether a mouse
  18218.          is found.  Here is the prototype:
  18219.  
  18220.          int MouseInitializeSystem(int intype, int *button, int hpos,
  18221.                                    int vpos)
  18222.  
  18223.          The first argument informs MouseInitializeSystem() to whether
  18224.          you just want to test to see if a mouse is installed and not
  18225.          to activate the mouse, or to not only test for the mouse, but
  18226.          to activate it.  If the first argument is MOUSE_TEST,
  18227.          MouseInitializeSystem() will just return an integer denoting
  18228.          whether a mouse is found.  If the first argument is
  18229.          MOUSE_FULL_INSTALL, not only is a status returned, but the
  18230.          mouse will be activated.
  18231.  
  18232.  
  18233.          The second argument is a pointer to an integer that will
  18234.          contain the number of buttons that the mouse has.  This
  18235.          number will usually be 2 or 3.
  18236.  
  18237.          The third and fourth arguments are the screen coordinates of
  18238.          where to place the mouse cursor on the screen.  The third
  18239.          argument is the row, and the fourth argument is the column to
  18240.          place the mouse cursor.
  18241.  
  18242.          MouseInitializeSystem() returns NOMOUSE if a mouse is not
  18243.          installed, or MOUSEFOUND if a mouse is installed.
  18244.  
  18245.  
  18246.  
  18247.          MouseInitializeSystem() must be called after calling
  18248.          WindowInitializeSystem() for it to work properly.
  18249.  
  18250.  
  18251.          Page 291          The C Window Library               Page 291
  18252.  
  18253.          Turning off the mouse with MouseRestoreSystem()
  18254.          -----------------------------------------------
  18255.  
  18256.          Before terminating a program that has called
  18257.          MouseInitializeSystem() you should call MouseRestoreSystem().
  18258.          If you do not call MouseRestoreSystem(), the mouse will still
  18259.          be 'alive', even though the application has terminated.  Here
  18260.          is the prototype:
  18261.  
  18262.                        int MouseRestoreSystem(void)
  18263.  
  18264.          If the mouse was not initialized previously with
  18265.          MouseInitializeSystem(), MouseRestoreSystem() returns
  18266.          NOMOUSE, otherwise the return value is NO_ERROR.
  18267.  
  18268.          Example:
  18269.  
  18270.  
  18271.  
  18272.          main()
  18273.          {
  18274.  
  18275.             /* initialize mouse */
  18276.             MouseInitializeSystem();
  18277.             /* ... */
  18278.  
  18279.             /* turn off mouse */
  18280.             MouseRestoreSystem();
  18281.          }
  18282.  
  18283.  
  18284.          If you want to turn the mouse back on after calling
  18285.          MouseRestoreSystem(), you must call MouseInitializeSystem()
  18286.          again.
  18287.  
  18288.  
  18289.          Example:
  18290.  
  18291.  
  18292.          #include "cwlmouse.h"
  18293.  
  18294.          main()
  18295.          {
  18296.             int button;
  18297.             int ismouse;
  18298.             WindowInitializeSystem();
  18299.             ismouse = (MouseInitializeSystem(MOUSE_FULL_INSTALL,
  18300.                                     &button,0,0) == MOUSEFOUND));
  18301.             MoveCursor(0,0,0);
  18302.             if (ismouse)
  18303.               VideoPrintf(
  18304.               "Mouse was found.  Number of buttons is %d\n",button);
  18305.             else
  18306.               VideoPrintf("Mouse not found");
  18307.          }
  18308.  
  18309.  
  18310.  
  18311.          Page 292          The C Window Library               Page 292
  18312.  
  18313.          Using a mouse with popup menus
  18314.          ------------------------------
  18315.  
  18316.          Once the mouse is initialized, you can use the mouse to make
  18317.          selections with popup menus.
  18318.  
  18319.          To move the highlight bar with the mouse, position the mouse
  18320.          cursor over any menu entry in the window, and hold the left
  18321.          mouse button down.  If the mouse is moved while holding the
  18322.          left button down, the highlight is moved along with the mouse
  18323.          cursor.  A selection is made by releasing the left mouse
  18324.          button while the mouse cursor is on an active menu entry.
  18325.  
  18326.          Scroll bars are placed on a popup window when the
  18327.          POPUPMOUSESCROLL option is used in a popup menu.  The scroll
  18328.          bars consist of a moveable scroll box, as well as up and down
  18329.          arrows.
  18330.  
  18331.          By default, scroll bars are not drawn on popup windows that
  18332.          have entries that can fit in the popup window.  In other
  18333.          words, if your popup window can hold all of your entries
  18334.          without scrolling, no scroll bar is drawn on the window.  If
  18335.          you change the size of the popup window, scroll bars are
  18336.          drawn automatically if the entries cannot fit in the window.
  18337.  
  18338.          The popup window's text area must be at least 4 rows tall for
  18339.          the scroll bars to serve any useful purpose.
  18340.  
  18341.  
  18342.          Popup Menu's pre-function for mouse
  18343.          -----------------------------------
  18344.  
  18345.          When the POPUPMOUSESCROLL option is used for popup menus, the
  18346.          menu can be scrolled automatically by placing the mouse on
  18347.          either the up or down scroll characters on the popup window,
  18348.          and pressing the left mouse button.
  18349.  
  18350.  
  18351.          The normal pre-function for the popup menu, namely the
  18352.          function pointed to by CWLglobal_popup_prefunc, is disabled if
  18353.          you use the mouse to scroll through the entries in the manner
  18354.          described above.  If you want to perform a function when the
  18355.          menu bar is moved automatically from choice to choice, you
  18356.          should use the CWLpopup_mouse_func function pointer.  Here
  18357.          is the prototype:
  18358.  
  18359.          void (*CWLpopup_mouse_func)(POPUP_MENU_PTR p,
  18360.                                      unsigned current)
  18361.  
  18362.          p is the current popup menu, and current is the current
  18363.          selection that the highlight bar is on.
  18364.  
  18365.          Note the difference in the second argument.  The
  18366.          CWLglobal_popup_prefunc function pointer has a pointer to an
  18367.          integer as the second argument, while the
  18368.  
  18369.  
  18370.  
  18371.          Page 293          The C Window Library               Page 293
  18372.  
  18373.          CWLpopup_mouse_func has an integer as the second argument.
  18374.          Also note that the CWLpopup_mouse_func returns nothing,
  18375.          while the CWLglobal_popup_prefunc returns a value back to the
  18376.          menu manager.
  18377.  
  18378.          If you use the mouse the 'normal' way (pointing the mouse to
  18379.          the actual menu entry and moving the mouse up or down while
  18380.          holding the left mouse button down), the normal pre-function
  18381.          is not disabled.
  18382.  
  18383.          The reason for having the CWLpopup_mouse_func function
  18384.          pointer is that there may be a description displayed for each
  18385.          menu entry, where the displaying of the menu entry is done by
  18386.          the function pointed to by CWLglobal_popup_prefunc.  Here is a
  18387.          small example:
  18388.  
  18389.          #include "cwlwin.h"
  18390.          int display_choice();
  18391.          void do_display_choice();
  18392.  
  18393.          POPUP_MENU_PTR p;
  18394.          /* other initializations */
  18395.  
  18396.          main()
  18397.          {
  18398.            WindowInitializeSystem();
  18399.            WindowInitDesktop();
  18400.            MouseInitializeSystem(MOUSE_FULL_INSTALL,&b,0,0);
  18401.            p = PopupCreateMenu(/* arguments */);
  18402.            PopupSetOptions(p,POPUPMOUSE|POPUPMOUSESCROLL,1);
  18403.            CWLglobal_popup_prefunc = display_choice;
  18404.            popup_move_mouse_func = do_display_choice;
  18405.  
  18406.            /*
  18407.                ...
  18408.  
  18409.  
  18410.                  */
  18411.  
  18412.          }
  18413.  
  18414.          display_choice(POPUP_MENU_PTR p, int *choice)
  18415.          {
  18416.             /* display info for entry in a window */
  18417.             return POPUP_CONTINUE;
  18418.          }
  18419.  
  18420.  
  18421.          void do_display_choice(POPUP_MENU_PTR p, int choice)
  18422.          {
  18423.            display_choice(p,&choice);
  18424.          }
  18425.  
  18426.  
  18427.  
  18428.  
  18429.  
  18430.  
  18431.          Page 294          The C Window Library               Page 294
  18432.  
  18433.          Using a mouse with bar menus
  18434.          ----------------------------
  18435.  
  18436.          To move the highlight bar with the mouse, position the mouse
  18437.          cursor over any menu entry in the window, and hold the left
  18438.          mouse button down.  If the mouse is moved while holding the
  18439.          left button down, the highlight is moved along with the mouse
  18440.          cursor.  A selection is made by releasing the left mouse
  18441.          button while the mouse cursor is on an active menu entry.
  18442.  
  18443.          To activate the mouse so that it can be used for bar menus,
  18444.          you must set the bar menu option BARMOUSE on.
  18445.  
  18446.  
  18447.          Using a mouse with pulldown menus
  18448.          ---------------------------------
  18449.  
  18450.          If the menu options for the mouse are turned on for all popup
  18451.          menus and the bar menu, and these menus are used as part of a
  18452.  
  18453.          pulldown menu system, the mouse behaves exactly the same
  18454.          except for the following differences:
  18455.  
  18456.            a) Holding the left mouse button down and positioning the
  18457.               mouse cursor over a bar menu entry will bring up the
  18458.               popup menu that is associated with the bar entry.  If
  18459.               there is no popup menu defined for a particular bar
  18460.               entry, releasing the mouse button will invoke the
  18461.               entry's function.
  18462.  
  18463.  
  18464.            b) Releasing the mouse button when it is positioned over a
  18465.               bar entry, and the bar entry has a popup associated with
  18466.               it, does nothing.  A general rule is that a menu
  18467.               function is only executed when the highlight bar is
  18468.               positioned on a menu entry that has a function
  18469.               associated with it.
  18470.  
  18471.  
  18472.  
  18473.          Changing the mouse defaults
  18474.          ---------------------------
  18475.  
  18476.          By default, the left mouse button is held down when moving
  18477.          the highlight bar.  If you prefer a different button to be
  18478.          used to move the highlight bar, you can change the button by
  18479.          changing the following global variables:
  18480.  
  18481.              int CWLpopup_press - holds the current button to be
  18482.              used to move the highlight bar in popup menus.
  18483.  
  18484.              int CWLbar_press - holds the current button to be
  18485.              used to move the highlight bar in bar menus.
  18486.  
  18487.          The following constants can be assigned to these two global
  18488.          variables:
  18489.  
  18490.  
  18491.          Page 295          The C Window Library               Page 295
  18492.  
  18493.                     Constant               Definition
  18494.                     --------               ----------
  18495.  
  18496.                     MOUSELEFT_PRESS        Left button.
  18497.                     MOUSERIGHT_PRESS       Right button.
  18498.                     MOUSEMIDDLE_PRESS      Middle button.
  18499.  
  18500.          By default, CWLpopup_press and CWLbar_press are
  18501.          assigned MOUSELEFT_PRESS.  Here is an example of changing
  18502.          these variables:
  18503.  
  18504.          #include "cwlwin.h"
  18505.  
  18506.          main()
  18507.          {
  18508.            ...
  18509.            MouseInitializeSystem(  /* arguments */ );
  18510.            /* change mouse menu buttons */
  18511.            CWLpopup_press = MOUSERIGHT_PRESS;
  18512.            CWLbar_press = MOUSERIGHT_PRESS;
  18513.               ...
  18514.          }
  18515.  
  18516.          The CWLpopup_press and CWLbar_press variables are assigned
  18517.          their default values when MouseInitializeSystem() is called.
  18518.          If you want to change these variables, make sure that the
  18519.          change is made after calling MouseInitializeSystem().
  18520.  
  18521.  
  18522.  
  18523.  
  18524.  
  18525.  
  18526.  
  18527.  
  18528.  
  18529.  
  18530.  
  18531.  
  18532.  
  18533.  
  18534.  
  18535.  
  18536.  
  18537.  
  18538.  
  18539.  
  18540.  
  18541.  
  18542.  
  18543.  
  18544.  
  18545.  
  18546.  
  18547.  
  18548.  
  18549.  
  18550.  
  18551.          Page 296          The C Window Library               Page 296
  18552.  
  18553.                   WINDOW AND VIRTUAL WINDOW MACROS
  18554.                   --------------------------------
  18555.  
  18556.          Note : These macros should be used after making a call to
  18557.          WindowInitializeSystem() or else unpredictable values will be
  18558.          returned.
  18559.  
  18560.  
  18561.          The following macros are defined in the cwlwin.h file.
  18562.          The window w is NOT CHECKED for validity.
  18563.  
  18564.              Macro                      Definition
  18565.         ┌────────────────┬───────────────────────────────────────────┐
  18566.         │ISBORDER(w)     │Returns TRUE if window has a border, FALSE │
  18567.         │                │otherwise.                                 │
  18568.         ├────────────────┼───────────────────────────────────────────┤
  18569.         │ISFROZEN(w)     │Returns TRUE if window is frozen from      │
  18570.         │                │doing screen updates when the virtual      │
  18571.         │                │window has changed, FALSE otherwise.       │
  18572.         ├────────────────┼───────────────────────────────────────────┤
  18573.         │ISSEETHRU(w)    │Returns TRUE if window is in seethru       │
  18574.         │                │mode, FALSE otherwise.                     │
  18575.         ├────────────────┼───────────────────────────────────────────┤
  18576.         │ISSHADOW(w)     │Returns TRUE if the window has a shadow,   │
  18577.         │                │FALSE otherwise.                           │
  18578.         ├────────────────┼───────────────────────────────────────────┤
  18579.         │ISSHADOWTRANS(w)│Returns TRUE if the shadow is transparent, │
  18580.         │                │FALSE otherwise.                           │
  18581.         ├────────────────┼───────────────────────────────────────────┤
  18582.         │ISVISIBLE(w)    │Returns TRUE if window is visible, FALSE   │
  18583.         │                │otherwise.                                 │
  18584.         ├────────────────┼───────────────────────────────────────────┤
  18585.         │ISVIEWPORT(w)   │Returns TRUE if window is a viewport, FALSE│
  18586.         │                │otherwise.                                 │
  18587.         ├────────────────┼───────────────────────────────────────────┤
  18588.         │ISWINDOW(vw)    │Returns TRUE if virtual window has any     │
  18589.         │                │viewports, FALSE otherwise.                │
  18590.         ├────────────────┼───────────────────────────────────────────┤
  18591.         │ISWRAP(w)       │Returns TRUE if window wrap is on, FALSE   │
  18592.         │                │otherwise.                                 │
  18593.         ├────────────────┼───────────────────────────────────────────┤
  18594.         │SHADOW_ATTR(w)  │Returns the current video attribute used to│
  18595.         │                │draw the window's shadow.  Return value is │
  18596.         │                │undefined if the window has no shadow      │
  18597.         ├────────────────┼───────────────────────────────────────────┤
  18598.         │SHADOW_CHAR(w)  │Returns the current character used to draw │
  18599.         │                │the window's shadow.  Return value is      │
  18600.         │                │undefined if the window has no shadow.     │
  18601.         ├────────────────┼───────────────────────────────────────────┤
  18602.         │SHADOW_HEIGHT(w)│Returns the height of the window's shadow. │
  18603.         │                │Return value is undefined if the window    │
  18604.         │                │has no shadow.                             │
  18605.         └────────────────┴───────────────────────────────────────────┘
  18606.  
  18607.  
  18608.  
  18609.  
  18610.  
  18611.          Page 297          The C Window Library               Page 297
  18612.  
  18613.                  Macro                        Definition
  18614.         ┌─────────────────────────┬───────────────────────────────────┐
  18615.         │SHADOW_POS(w)            │Returns the position of the        │
  18616.         │                         │shadow as an integer.  The valid   │
  18617.         │                         │positions are as follows:          │
  18618.         │                         │                          Return   │
  18619.         │                         │Shadow Position           Value    │
  18620.         │                         ├───────────────           ──────   │
  18621.         │                         │SHADOWUPLEFT                1      │
  18622.         │                         │SHADOWUPRIGHT               2      │
  18623.         │                         │SHADOWLOWLEFT               3      │
  18624.         │                         │SHADOWLOWRIGHT              4      │
  18625.         │                         │                                   │
  18626.         │                         │If there is no shadow, FALSE is    │
  18627.         │                         │returned.                          │
  18628.         ├─────────────────────────┼───────────────────────────────────┤
  18629.         │SHADOW_WIDTH(w)          │Returns the width of the           │
  18630.         │                         │window's shadow. Return value is   │
  18631.         │                         │undefined if the window has no     │
  18632.         │                         │shadow.                            │
  18633.         ├─────────────────────────┼───────────────────────────────────┤
  18634.         │VIEWPORT_COLUMN(w)       │Returns the upper left column of   │
  18635.         │                         │where the viewport w is positioned │
  18636.         │                         │on the virtual window.             │
  18637.         ├─────────────────────────┼───────────────────────────────────┤
  18638.         │VIEWPORT_ROW(w)          │Returns the upper left row of where│
  18639.         │                         │the viewport w is positioned on the│
  18640.         │                         │virtual window.                    │
  18641.         ├─────────────────────────┼───────────────────────────────────┤
  18642.         │VIRTUAL_ATTRIBUTE_ON(vw) │Returns TRUE if the virtual window │
  18643.         │                         │vw is attributed, FALSE otherwise. │
  18644.         ├─────────────────────────┼───────────────────────────────────┤
  18645.         │VIRTUAL_HEIGHT(vw)       │Returns the number of rows in a    │
  18646.         │                         │virtual window vw.                 │
  18647.         ├─────────────────────────┼───────────────────────────────────┤
  18648.         │VIRTUAL_WIDTH(vw)        │Returns the number of columns      │
  18649.         │                         │in a virtual window.               │
  18650.         ├─────────────────────────┼───────────────────────────────────┤
  18651.         │VIRTUAL_WINDOW(w)        │Returns the virtual window that the│
  18652.         │                         │viewport w is currently viewing.   │
  18653.         ├─────────────────────────┼───────────────────────────────────┤
  18654.         │VIRTUAL_COORD_IN_VIEWPORT│Returns TRUE if the virtual window │
  18655.         │(w,row,col)              │coordinates (row,col) are inside   │
  18656.         │                         │the viewport w, FALSE otherwise.   │
  18657.         │                         │The virtual window must have w as a│
  18658.         │                         │viewport.                          │
  18659.         ├─────────────────────────┼───────────────────────────────────┤
  18660.         │VIRTUAL_WINDOW_EXIST(vw) │Returns TRUE if virtual window was │
  18661.         │                         │initialized, FALSE otherwise.      │
  18662.         ├─────────────────────────┼───────────────────────────────────┤
  18663.         │WINDOW_BORDER_CHARS(w)   │Returns the current border of a    │
  18664.         │                         │window as a string.                │
  18665.         ├─────────────────────────┼───────────────────────────────────┤
  18666.         │WINDOW_BORDER_COLOR(w)   │Returns the border color of the    │
  18667.         │                         │window w.                          │
  18668.         └─────────────────────────┴───────────────────────────────────┘
  18669.  
  18670.  
  18671.          Page 298          The C Window Library               Page 298
  18672.  
  18673.              Macro                    Definition
  18674.         ┌─────────────────────────┬───────────────────────────────────┐
  18675.         │WINDOW_COLUMN(w)         │Returns the absolute column of the │
  18676.         │                         │upper left hand corner of the      │
  18677.         │                         │window.                            │
  18678.         ├─────────────────────────┼───────────────────────────────────┤
  18679.         │WINDOW_EXIST(w)          │Returns TRUE if window was         │
  18680.         │                         │initialized, FALSE otherwise.      │
  18681.         ├─────────────────────────┼───────────────────────────────────┤
  18682.         │WINDOW_HEIGHT(w)         │Returns the height of the text area│
  18683.         │                         │of the window w.                   │
  18684.         ├─────────────────────────┼───────────────────────────────────┤
  18685.         │WINDOW_PAGENUM(w)        │Returns the video page of where the│
  18686.         │                         │window will be displayed.          │
  18687.         ├─────────────────────────┼───────────────────────────────────┤
  18688.         │WINDOW_RANK(w)           │Returns the rank of the window w.  │
  18689.         ├─────────────────────────┼───────────────────────────────────┤
  18690.         │WINDOW_ROW(w)            │Returns the absolute row coordinate│
  18691.         │                         │of the upper left hand corner of   │
  18692.         │                         │the window w.                      │
  18693.         └─────────────────────────┴───────────────────────────────────┘
  18694.  
  18695.  
  18696.  
  18697.  
  18698.  
  18699.  
  18700.  
  18701.  
  18702.  
  18703.  
  18704.  
  18705.  
  18706.  
  18707.  
  18708.  
  18709.  
  18710.  
  18711.  
  18712.  
  18713.  
  18714.  
  18715.  
  18716.  
  18717.  
  18718.  
  18719.  
  18720.  
  18721.  
  18722.  
  18723.  
  18724.  
  18725.  
  18726.  
  18727.  
  18728.  
  18729.  
  18730.  
  18731.          Page 299          The C Window Library               Page 299
  18732.  
  18733.                              MENU MACROS
  18734.                              -----------
  18735.  
  18736.          The following macros are defined in the header file cwlwin.h.
  18737.  
  18738.          Popup Menu Macros                      Definition
  18739.         ┌──────────────────────────┬──────────────────────────────────┐
  18740.         │POPUP_CASCADE(p)          │Returns TRUE if the menu is a     │
  18741.         │                          │menu that has been embedded in    │
  18742.         │                          │a cascading menu, FALSE otherwise.│
  18743.         ├──────────────────────────┼──────────────────────────────────┤
  18744.         │POPUP_CASCADE_ENTRY       │Returns TRUE if the entry is a    │
  18745.         │(p,entry)                 │cascading menu, FALSE otherwise.  │
  18746.         ├──────────────────────────┼──────────────────────────────────┤
  18747.         │POPUP_DISPLAY_ON(p)       │Returns TRUE if the POPUP_MENU_PTR│
  18748.         │                          │p's window is to be displayed     │
  18749.         │                          │regardless if the menu manager has│
  18750.         │                          │returned to the calling function, │
  18751.         │                          │FALSE otherwise.                  │
  18752.         ├──────────────────────────┼──────────────────────────────────┤
  18753.         │POPUP_ENHANCED_ON(p)      │Returns TRUE if the popup menu    │
  18754.         │                          │will recognize enhanced keys,     │
  18755.         │                          │FALSE otherwise.                  │
  18756.         ├──────────────────────────┼──────────────────────────────────┤
  18757.         │POPUP_ENTRY_CHECKED       │Returns TRUE if entry is checked, │
  18758.         │(p,entry)                 │FALSE otherwise.                  │
  18759.         ├──────────────────────────┼──────────────────────────────────┤
  18760.         │POPUP_ENTRY_DISABLED      │Returns TRUE if entry is disabled,│
  18761.         │(p,entry)                 │FALSE otherwise.                  │
  18762.         ├──────────────────────────┼──────────────────────────────────┤
  18763.         │POPUP_ENTRY_GRAYED        │Returns TRUE if entry is grayed,  │
  18764.         │(p,entry)                 │FALSE otherwise.                  │
  18765.         ├──────────────────────────┼──────────────────────────────────┤
  18766.         │POPUP_ENTRY_ID(p,entry)   │Returns the menu ID number of the │
  18767.         │                          │entry.                            │
  18768.         ├──────────────────────────┼──────────────────────────────────┤
  18769.         │POPUP_ENTRY_HIGHLIGHTED   │Returns TRUE if the entry is high-│
  18770.         │(p,entry)                 │lighted, FALSE otherwise.         │
  18771.         ├──────────────────────────┼──────────────────────────────────┤
  18772.         │POPUP_ENTRY_RAWSTRING(p)  │Returns the string including the  │
  18773.         │                          │ampersand that was used in the    │
  18774.         │                          │original menu entry.              │
  18775.         ├──────────────────────────┼──────────────────────────────────┤
  18776.         │POPUP_ENTRY_STRING        │Returns the entry string of       │
  18777.         │(p,entry)                 │POPUP_MENU_ENTRY entry.           │
  18778.         ├──────────────────────────┼──────────────────────────────────┤
  18779.         │POPUP_EXPLODE(p)          │Returns the special effect        │
  18780.         │                          │constant of the POPUP_MENU_PTR p. │
  18781.         │                          │This special effect is used to    │
  18782.         │                          │hide, close, and open the popup   │
  18783.         │                          │menu's window.                    │
  18784.         ├──────────────────────────┼──────────────────────────────────┤
  18785.         │POPUP_MENU_FROM_CASCADE   │Returns a POPUP_MENU_PTR that is  │
  18786.         │(p,entry)                 │the cascading menu located at     │
  18787.         │                          │entry.                            │
  18788.         └──────────────────────────┴──────────────────────────────────┘
  18789.  
  18790.  
  18791.          Page 300          The C Window Library               Page 300
  18792.  
  18793.          Popup Menu Macros                      Definition
  18794.         ┌──────────────────────────┬───────────────────────────────────┐
  18795.         │POPUP_MOUSE_ON(p)         │Returns TRUE if a mouse can be     │
  18796.         │                          │used to make selections, FALSE     │
  18797.         │                          │otherwise.                         │
  18798.         ├──────────────────────────┼───────────────────────────────────┤
  18799.         │POPUP_MOUSE_SCROLL_ON(p)  │Returns TRUE if a mouse can be used│
  18800.         │                          │to scroll through the entries if   │
  18801.         │                          │the entries cannot fit in the      │
  18802.         │                          │popup window, FALSE otherwise.     │
  18803.         ├──────────────────────────┼───────────────────────────────────┤
  18804.         │POPUP_NUMBER_OF_ENTRIES(p)│Returns the total number of entries│
  18805.         │                          │defined in the POPUP_MENU_PTR p.   │
  18806.         ├──────────────────────────┼───────────────────────────────────┤
  18807.         │POPUP_OVERRIDE_ON(p)      │Returns TRUE if POPUP_MENU_PTR p   │
  18808.         │                          │will have unavailable options      │
  18809.         │                          │processed, FALSE otherwise.        │
  18810.         ├──────────────────────────┼───────────────────────────────────┤
  18811.         │POPUP_PARENT(p)           │Returns the POPUP_MENU_PTR that is │
  18812.         │                          │the parent of the embedded menu p. │
  18813.         ├──────────────────────────┼───────────────────────────────────┤
  18814.         │POPUP_PARENT_ENTRY(p)     │Returns the entry number in p's    │
  18815.         │                          │parent menu that matches p.  -1 if │
  18816.         │                          │there is no such entry.            │
  18817.         ├──────────────────────────┼───────────────────────────────────┤
  18818.         │POPUP_PULLDOWN_ON(p)      │Returns TRUE if the POPUP_MENU_PTR │
  18819.         │                          │p is incorporated in a pulldown    │
  18820.         │                          │menu system, FALSE otherwise.      │
  18821.         ├──────────────────────────┼───────────────────────────────────┤
  18822.         │POPUP_STATIC_ON(p)        │Returns TRUE if the POPUP_MENU_PTR │
  18823.         │                          │p will remain on the screen when   │
  18824.         │                          │an entry is selected, FALSE        │
  18825.         │                          │otherwise.                         │
  18826.         ├──────────────────────────┼───────────────────────────────────┤
  18827.         │POPUP_STRING_IN_WINDOW    │Returns TRUE if the POPUP_MENU_PTR │
  18828.         │(p,entry)                 │p has entry number entry displayed │
  18829.         │                          │in the popup menu's window, FALSE  │
  18830.         │                          │otherwise.                         │
  18831.         │                          │                                   │
  18832.         │                          │This macro is useful if you have a │
  18833.         │                          │scrolling popup menu and want to   │
  18834.         │                          │know if a particular entry is      │
  18835.         │                          │displayed in the window.           │
  18836.         ├──────────────────────────┼───────────────────────────────────┤
  18837.         │POPUP_VIRTUAL_WINDOW(p)   │Returns the VWPOINTER of the popup │
  18838.         │                          │menu.                              │
  18839.         ├──────────────────────────┼───────────────────────────────────┤
  18840.         │POPUP_WINDOW(p)           │Returns the WPOINTER of the popup  │
  18841.         │                          │menu.                              │
  18842.         ├──────────────────────────┼───────────────────────────────────┤
  18843.         │POPUP_WRAP_ON(p)          │Returns TRUE if the highlight wrap │
  18844.         │                          │of POPUP_MENU_PTR p is on,         │
  18845.         │                          │otherwise 0.                       │
  18846.         └──────────────────────────┴───────────────────────────────────┘
  18847.  
  18848.  
  18849.  
  18850.  
  18851.          Page 301          The C Window Library               Page 301
  18852.  
  18853.          Bar Menu Macros                      Definition
  18854.         ┌──────────────────────────┬──────────────────────────────────┐
  18855.         │BAR_DISPLAY_ON(b)         │Returns TRUE if the BAR_MENU_PTR  │
  18856.         │                          │b's window is to be displayed     │
  18857.         │                          │regardless if the menu manager has│
  18858.         │                          │returned to the calling function, │
  18859.         │                          │FALSE otherwise.                  │
  18860.         ├──────────────────────────┼──────────────────────────────────┤
  18861.         │BAR_ENHANCED_ON(b)        │Returns TRUE if the bar menu will │
  18862.         │                          │recognize enhanced keys, FALSE    │
  18863.         │                          │otherwise.                        │
  18864.         ├──────────────────────────┼──────────────────────────────────┤
  18865.         │BAR_ENTRY_DISABLED        │Returns TRUE if entry is disabled,│
  18866.         │(b,entry)                 │FALSE otherwise.                  │
  18867.         ├──────────────────────────┼──────────────────────────────────┤
  18868.         │BAR_ENTRY_GRAYED          │Returns TRUE if entry is grayed,  │
  18869.         │(b,entry)                 │FALSE otherwise.                  │
  18870.         ├──────────────────────────┼──────────────────────────────────┤
  18871.         │BAR_ENTRY_ID(b,entry)     │Returns the menu ID number of the │
  18872.         │                          │entry.                            │
  18873.         ├──────────────────────────┼──────────────────────────────────┤
  18874.         │BAR_ENTRY_HIGHLIGHTED     │Returns TRUE if the entry is high-│
  18875.         │(b,entry)                 │lighted, FALSE otherwise.         │
  18876.         ├──────────────────────────┼──────────────────────────────────┤
  18877.         │BAR_ENTRY_RAWSTRING(b)    │Returns the string including the  │
  18878.         │                          │ampersand that was used in the    │
  18879.         │                          │original menu entry.              │
  18880.         ├──────────────────────────┼──────────────────────────────────┤
  18881.         │BAR_ENTRY_STRING(b,entry) │Returns the entry string of       │
  18882.         │                          │BAR_MENU_ENTRY entry.             │
  18883.         ├──────────────────────────┼──────────────────────────────────┤
  18884.         │BAR_EXPLODE(b)            │Returns the special effect        │
  18885.         │                          │constant of the BAR_MENU_PTR b.   │
  18886.         │                          │This special effect is used to    │
  18887.         │                          │hide, close, and open the bar     │
  18888.         │                          │menu's window.                    │
  18889.         ├──────────────────────────┼──────────────────────────────────┤
  18890.         │BAR_NUMBER_OF_ENTRIES(b)  │Returns the total number of       │
  18891.         │                          │entries defined in the            │
  18892.         │                          │BAR_MENU_PTR b.                   │
  18893.         ├──────────────────────────┼──────────────────────────────────┤
  18894.         │BAR_PULLDOWN_ON(b)        │Returns TRUE if the BAR_MENU_PTR b│
  18895.         │                          │is incorporated in a pulldown menu│
  18896.         │                          │system, FALSE otherwise.          │
  18897.         ├──────────────────────────┼──────────────────────────────────┤
  18898.         │BAR_STATIC_ON(b)          │Returns TRUE if the BAR_MENU_PTR b│
  18899.         │                          │will remain on the screen when an │
  18900.         │                          │entry is selected, FALSE otherwise│
  18901.         ├──────────────────────────┼──────────────────────────────────┤
  18902.         │BAR_WINDOW(b)             │Returns the WPOINTER of the bar   │
  18903.         │                          │menu.                             │
  18904.         ├──────────────────────────┼──────────────────────────────────┤
  18905.         │BAR_WRAP_ON(b)            │Returns TRUE if the highlight wrap│
  18906.         │                          │of BAR_MENU_PTR b is on, otherwise│
  18907.         │                          │FALSE is returned.                │
  18908.         └──────────────────────────┴──────────────────────────────────┘
  18909.  
  18910.  
  18911.          Page 302          The C Window Library               Page 302
  18912.  
  18913.          Pulldown Menu Macros                 Definition
  18914.         ┌─────────────────────────────┬──────────────────────────────┐
  18915.         │BAR_MENU_PTR_FROM_POPUP(pop) │Returns the BAR_MENU_PTR      │
  18916.         │                             │associated with the           │
  18917.         │                             │POPUP_MENU_PTR pop, which must│
  18918.         │                             │be part of a pulldown menu    │
  18919.         │                             │system.                       │
  18920.         ├─────────────────────────────┼──────────────────────────────┤
  18921.         │BAR_MENU_PTR_FROM_PULLDOWN   │Returns the BAR_MENU_PTR      │
  18922.         │(pull)                       │assocated with the            │
  18923.         │                             │PULLDOWN_MENU_PTR pull.       │
  18924.         ├─────────────────────────────┼──────────────────────────────┤
  18925.         │POPUP_MENU_PTR_FROM_BAR      │Returns the POPUP_MENU_PTR    │
  18926.         │(b,entry)                    │associated with the           │
  18927.         │                             │BAR_MENU_PTR b.               │
  18928.         │                             │                              │
  18929.         │                             │The entry argument is the     │
  18930.         │                             │number of the POPUP_MENU_PTR  │
  18931.         │                             │desired in the pulldown menu  │
  18932.         │                             │system.  For example, if you  │
  18933.         │                             │want to know the first        │
  18934.         │                             │POPUP_MENU_PTR given only a   │
  18935.         │                             │BAR_MENU_PTR, the call to this│
  18936.         │                             │macro would be                │
  18937.         │                             │POPUP_MENU_PTR_FROM_BAR(b,1). │
  18938.         ├─────────────────────────────┼──────────────────────────────┤
  18939.         │POPUP_MENU_PTR_FROM_PULLDOWN │Returns the POPUP_MENU_PTR    │
  18940.         │(pull,entry)                 │associated with the           │
  18941.         │                             │PULLDOWN_MENU_PTR pull.  The  │
  18942.         │                             │entry is the number of the    │
  18943.         │                             │desired POPUP_MENU_PTR desired│
  18944.         │                             │in the pulldown menu system.  │
  18945.         ├─────────────────────────────┼──────────────────────────────┤
  18946.         │PULLDOWN_MENU_PTR_FROM_BAR   │Returns the PULLDOWN_MENU_PTR │
  18947.         │(b)                          │associated with the bar       │
  18948.         │                             │menu b.                       │
  18949.         ├─────────────────────────────┼──────────────────────────────┤
  18950.         │PULLDOWN_MENU_PTR_FROM_POPUP │Returns the PULLDOWN_MENU_PTR │
  18951.         │(pop)                        │associated with the           │
  18952.         │                             │POPUP_MENU_PTR pop.           │
  18953.         └─────────────────────────────┴──────────────────────────────┘
  18954.  
  18955.  
  18956.  
  18957.  
  18958.  
  18959.  
  18960.  
  18961.  
  18962.  
  18963.  
  18964.  
  18965.  
  18966.  
  18967.  
  18968.  
  18969.  
  18970.  
  18971.          Page 303          The C Window Library               Page 303
  18972.  
  18973.                             VIDEO MACROS
  18974.                             ------------
  18975.                 Macro                         Definition
  18976.         ┌──────────────────────┬──────────────────────────────────────┐
  18977.         │CHECK_SNOW            │Returns TRUE if during direct screen  │
  18978.         │                      │writes that video "snow" is           │
  18979.         │                      │eliminated.  You can also assign      │
  18980.         │                      │values to this macro.  This macro is a│
  18981.         │                      │pseudonym for the variable CWLchksnow.│
  18982.         │                      │                                      │
  18983.         │                      │Example:                              │
  18984.         │                      │  #include "cwlwin.h"                 │
  18985.         │                      │  int a;                              │
  18986.         │                      │  a = CHECK_SNOW;                     │
  18987.         │                      │  CHECK_SNOW = FALSE; /* Turn off snow│
  18988.         │                      │                         checking */  │
  18989.         ├──────────────────────┼──────────────────────────────────────┤
  18990.         │CREATE_VIDEO_ATTRIBUTE│Creates a video attribute using bg as │
  18991.         │(bg,fg)               │the background color, and fg as the   │
  18992.         │                      │foreground color.  The following      │
  18993.         │                      │variables can be used:                │
  18994.         ╞══════════════════════╧══════════════════════════════════════╡
  18995.         │              Variable                                       │
  18996.         │                Name              Color    Value             │
  18997.         │             ┌───────────────┬──────────────┬──┐             │
  18998.         │             │CWLblack       │ Black        │ 0│             │
  18999.         │             │CWLblue        │ Blue         │ 1│             │
  19000.         │             │CWLgreen       │ Green        │ 2│             │
  19001.         │             │CWLcyan        │ Cyan         │ 3│             │
  19002.         │             │CWLred         │ Red          │ 4│             │
  19003.         │             │CWLmagenta     │ Magenta      │ 5│             │
  19004.         │             │CWLbrown       │ Brown        │ 6│             │
  19005.         │             │CWLwhite       │ White        │ 7│             │
  19006.         │             │CWLgray        │ Gray         │ 8│             │
  19007.         │             │CWLlightblue   │ Light Blue   │ 9│             │
  19008.         │             │CWLlightgreen  │ Light green  │10│             │
  19009.         │             │CWLlightcyan   │ Light cyan   │11│             │
  19010.         │             │CWLlightred    │ Light red    │12│             │
  19011.         │             │CWLlightmagenta│ Light magenta│13│             │
  19012.         │             │CWLyellow      │ Yellow       │14│             │
  19013.         │             │CWLlightwhite  │ Intense white│15│             │
  19014.         │             └───────────────┴──────────────┴──┘             │
  19015.         │                                                             │
  19016.         │The variables above are initialized when                     │
  19017.         │WindowInitializeSystem() is called.  If you want to use a    │
  19018.         │color value before WindowInitializeSystem() is called, you   │
  19019.         │can use the uppercase equivalent of the above variables, with│
  19020.         │a trailing underscore character attached to the name.  For   │
  19021.         │example BLACK_ would be used instead of CWLblack, WHITE_     │
  19022.         │would be used instead of white, etc.                         │
  19023.         │                                                             │
  19024.         │For monochrome systems, the only colors that are available   │
  19025.         │are CWLblack, CWLwhite, and CWLwhite.  An attribute of       │
  19026.         │CWLblue creates an underline attribute, and CWLlightblue     │
  19027.         │creates an intense underlined attribute.  Any other          │
  19028.         │combination on a monochrome system is undefined.             │
  19029.         ╘═════════════════════════════════════════════════════════════╛
  19030.  
  19031.          Page 304          The C Window Library               Page 304
  19032.  
  19033.                 Macro                         Definition
  19034.         ┌──────────────────────┬───────────────────────────────────┐
  19035.         │GET_BGROUND_COLOR(c)  │Returns the background color of the│
  19036.         │                      │video attribute c.                 │
  19037.         ├──────────────────────┼───────────────────────────────────┤
  19038.         │GET_FGROUND_COLOR(c)  │Returns the foreground color of the│
  19039.         │                      │video attribute c.                 │
  19040.         ├──────────────────────┼───────────────────────────────────┤
  19041.         │GET_OFFSET(x)         │Returns the offset of a pointer x. │
  19042.         │                      │The pointer can be either near or  │
  19043.         │                      │far.                               │
  19044.         ├──────────────────────┼───────────────────────────────────┤
  19045.         │GET_SEGMENT(x)        │Returns the segment address of a   │
  19046.         │                      │pointer x.  The pointer can be     │
  19047.         │                      │either near or far.                │
  19048.         ├──────────────────────┼───────────────────────────────────┤
  19049.         │MAKE_FAR_POINTER(a,b) │Creates a far pointer made up of   │
  19050.         │                      │segment address a, and offset      │
  19051.         │                      │address b.                         │
  19052.         ├──────────────────────┼───────────────────────────────────┤
  19053.         │SCREEN_OFFSET(r,c,a)  │Returns the screen offset of the   │
  19054.         │                      │address of a character located at  │
  19055.         │                      │row r and column c of the video    │
  19056.         │                      │page a.  The screen segment is     │
  19057.         │                      │defined in the macro               │
  19058.         │                      │SCREEN_SEGMENT.  both r and c      │
  19059.         │                      │should be >= 0.                    │
  19060.         │                      │                                   │
  19061.         │                      │Example:  char far *p; p =         │
  19062.         │                      │MAKE_FAR_POINTER(SCREEN_SEGMENT,   │
  19063.         │                      │           SCREEN_OFFSET(0,0,0));  │
  19064.         │                      │                                   │
  19065.         │                      │The above example has created a far│
  19066.         │                      │pointer p that points to the screen│
  19067.         │                      │buffer memory at row 0, column 0,  │
  19068.         │                      │on video page 0.                   │
  19069.         ├──────────────────────┼───────────────────────────────────┤
  19070.         │SCREEN_OFFSET_ATTR    │Returns the screen offset of the   │
  19071.         │(r,c,a)               │address of a attribute located at  │
  19072.         │                      │row r and column c of the video    │
  19073.         │                      │page a.  The screen segment is     │
  19074.         │                      │defined in the  macro              │
  19075.         │                      │SCREEN_SEGMENT.  Both r and c      │
  19076.         │                      │should be >= 0.                    │
  19077.         ├──────────────────────┼───────────────────────────────────┤
  19078.         │SCREEN_SEGMENT        │Returns the screen segment of video│
  19079.         │                      │page 0.  This macro is a pseudo-   │
  19080.         │                      │nym for the variable CWLscrnseg.   │
  19081.         └──────────────────────┴───────────────────────────────────┘
  19082.  
  19083.  
  19084.  
  19085.  
  19086.  
  19087.  
  19088.  
  19089.  
  19090.  
  19091.          Page 305          The C Window Library               Page 305
  19092.  
  19093.                 Macro                         Definition
  19094.         ┌──────────────────────┬───────────────────────────────────┐
  19095.         │SCREEN_WRITE_METHOD   │Returns 1 if writing directly to   │
  19096.         │                      │the screen, 0 if using the BIOS.   │
  19097.         │                      │You can also use this macro to     │
  19098.         │                      │assign the particular writing      │
  19099.         │                      │method.  This macro controls the   │
  19100.         │                      │way The C Window Library will do   │
  19101.         │                      │screen updates.  The default is 1  │
  19102.         │                      │(write directly to screen).        │
  19103.         │                      │                                   │
  19104.         │                      │Example:                           │
  19105.         │                      │#include "cwlwin.h"                │
  19106.         │                      │int a,b;                           │
  19107.         │                      │a =  SCREEN_WRITE_METHOD;          │
  19108.         │                      │SCREEN_WRITE_METHOD = 1;           │
  19109.         ├──────────────────────┼───────────────────────────────────┤
  19110.         │VIDEO_PAGESIZE        │Returns the size (in bytes) of a   │
  19111.         │                      │video page.  You can also assign   │
  19112.         │                      │values to VIDEO_PAGESIZE, but the  │
  19113.         │                      │best thing to do is to leave it    │
  19114.         │                      │alone unless you are familiar with │
  19115.         │                      │the video system you are using.    │
  19116.         │                      │This macro is a pseudonym for the  │
  19117.         │                      │variable CWLpagesize.              │
  19118.         └──────────────────────┴───────────────────────────────────┘
  19119.  
  19120.          The following macros are used to identify the monitor type
  19121.          and video card being used in the system.
  19122.  
  19123.                 Macro                   Definition
  19124.          ┌────────────────────┬───────────────────────────────────┐
  19125.          │CGA_ACTIVE          │Returns TRUE if Color Graphics     │
  19126.          │                    │Adapter is active, FALSE otherwise.│
  19127.          ├────────────────────┼───────────────────────────────────┤
  19128.          │EGA_ACTIVE          │Returns TRUE if EGA is active,     │
  19129.          │                    │FALSE otherwise.                   │
  19130.          ├────────────────────┼───────────────────────────────────┤
  19131.          │EGA_COLOR_ATTACHED  │Returns TRUE if monitor hooked up  │
  19132.          │                    │to EGA is a high resolution color  │
  19133.          │                    │monitor, FALSE otherwise.          │
  19134.          ├────────────────────┼───────────────────────────────────┤
  19135.          │EGA_COLOR_ON        │Returns TRUE if EGA is in color    │
  19136.          │                    │mode, FALSE otherwise.             │
  19137.          ├────────────────────┼───────────────────────────────────┤
  19138.          │EGA_INSTALLED       │Returns TRUE if EGA is installed,  │
  19139.          │                    │FALSE otherwise.                   │
  19140.          ├────────────────────┼───────────────────────────────────┤
  19141.          │HERCULES_ACTIVE     │Returns TRUE if Hercules adapter is│
  19142.          │                    │active, FALSE otherwise.           │
  19143.          ├────────────────────┼───────────────────────────────────┤
  19144.          │MCGA_ACTIVE         │Returns TRUE if the MCGA is the    │
  19145.          │                    │active video card.                 │
  19146.          ├────────────────────┼───────────────────────────────────┤
  19147.          │MCGA_COLOR_ON       │Returns TRUE if MCGA is in color   │
  19148.          │                    │mode, FALSE otherwise.             │
  19149.          └────────────────────┴───────────────────────────────────┘
  19150.  
  19151.          Page 306          The C Window Library               Page 306
  19152.  
  19153.          ┌────────────────────┬───────────────────────────────────┐
  19154.          │MCGA_INSTALLED      │Returns TRUE if MCGA is installed  │
  19155.          │                    │(IBM PS/2 Model 30), FALSE         │
  19156.          │                    │otherwise.                         │
  19157.          ├────────────────────┼───────────────────────────────────┤
  19158.          │MDA_ACTIVE          │Returns TRUE if MDA (Monochrome)   │
  19159.          │                    │adapter is active, FALSE otherwise.│
  19160.          ├────────────────────┼───────────────────────────────────┤
  19161.          │MONO_MODE_ON        │Returns TRUE if Monochrome mode is │
  19162.          │                    │on regardless of the adapter, FALSE│
  19163.          │                    │otherwise.                         │
  19164.          ├────────────────────┼───────────────────────────────────┤
  19165.          │VGA_ACTIVE          │Returns TRUE if VGA is active      │
  19166.          │                    │adapter, FALSE otherwise.          │
  19167.          ├────────────────────┼───────────────────────────────────┤
  19168.          │VGA_COLOR_ATTACHED  │Returns TRUE if monitor is hooked  │
  19169.          │                    │up to VGA analog color, FALSE      │
  19170.          │                    │otherwise.                         │
  19171.          ├────────────────────┼───────────────────────────────────┤
  19172.          │VGA_COLOR_ON        │Returns TRUE if VGA is in color    │
  19173.          │                    │mode, FALSE otherwise.             │
  19174.          ├────────────────────┼───────────────────────────────────┤
  19175.          │VGA_INSTALLED       │Returns TRUE if VGA Adapter is     │
  19176.          │                    │installed, FALSE otherwise.        │
  19177.          └────────────────────┴───────────────────────────────────┘
  19178.  
  19179.           You should always check the ..._ACTIVE constants before
  19180.           checking for other aspects of the video system.  For
  19181.           example, make sure that VGA_ACTIVE returns 1 before checking
  19182.           any other VGA_... macro.  If VGA_ACTIVE is 1, then all
  19183.           VGA_... macros are valid.  The same thing goes for EGA.
  19184.           MONO_MODE_ON is the only macro that can be tested regardless
  19185.           of the video adapter.
  19186.  
  19187.              Macro            Definition
  19188.          ┌────────────┬──────────────────────────────────┐
  19189.          │LINEMODE25  │Returns TRUE if screen displays 25│
  19190.          │            │lines, FALSE otherwise.           │
  19191.          ├────────────┼──────────────────────────────────┤
  19192.          │LINEMODE43  │Returns TRUE if screen displays 43│
  19193.          │            │lines (EGA and VGA), FALSE        │
  19194.          │            │otherwise.                        │
  19195.          ├────────────┼──────────────────────────────────┤
  19196.          │LINEMODE50  │Returns TRUE if screen displays 50│
  19197.          │            │lines (VGA), FALSE otherwise.     │
  19198.          └────────────┴──────────────────────────────────┘
  19199.  
  19200.  
  19201.  
  19202.  
  19203.  
  19204.  
  19205.  
  19206.  
  19207.  
  19208.  
  19209.  
  19210.  
  19211.          Page 307          The C Window Library               Page 307
  19212.  
  19213.                            KEYBOARD MACROS
  19214.                            ---------------
  19215.  
  19216.              Macro                            Definition
  19217.         ┌─────────────────────┬────────────────────────────────────────┐
  19218.         │ENHANCED_KEYBOARD()  │Returns TRUE if there is an enhanced    │
  19219.         │                     │keyboard attached, FALSE otherwise.     │
  19220.         ├─────────────────────┼────────────────────────────────────────┤
  19221.         │FLUSH_KEYBOARD()     │Flushes the keyboard buffer.            │
  19222.         ├─────────────────────┼────────────────────────────────────────┤
  19223.         │GET_KEY()            │Returns what key was pressed either as a│
  19224.         │                     │character, or as a scan code if a       │
  19225.         │                     │non-ascii key is pressed.  A list of    │
  19226.         │                     │scan codes are found in the file        │
  19227.         │                     │cwlwin.h.                               │
  19228.         ├─────────────────────┼────────────────────────────────────────┤
  19229.         │GET_ENHANCED_KEY()   │Same as GET_KEY() except that keys on   │
  19230.         │                     │the enhanced keyboards are              │
  19231.         │                     │distinguishable.  For instance, the     │
  19232.         │                     │key on the keypad will return a         │
  19233.         │                     │different scan code than the Home key   │
  19234.         │                     │on the separate cursor movement pad.    │
  19235.         ├─────────────────────┼────────────────────────────────────────┤
  19236.         │GET_SHIFT_STATE()    │Returns the shift state of the keyboard.│
  19237.         │                     │The shift state tells whether the Alt,  │
  19238.         │                     │Ctrl or Shift key was pressed, or if the│
  19239.         │                     │Num Lock, Scroll Lock, or Caps Lock keys│
  19240.         │                     │are on or off.  The shift state is      │
  19241.         │                     │updated after each call to GET_KEY() or │
  19242.         │                     │GET_ENHANCED_KEY().  Use a bitwise AND  │
  19243.         │                     │(&) when testing for these keys.        │
  19244.         │                     │The #defined constants that are used to │
  19245.         │                     │test for the various keys is found in   │
  19246.         │                     │cwlwin.h.                               │
  19247.         │                     │                                        │
  19248.         │                     │Example:                                │
  19249.         │                     │                                        │
  19250.         │                     │#include "cwlwin.h"                     │
  19251.         │                     │#include <stdio.h>                      │
  19252.         │                     │main()                                  │
  19253.         │                     │{                                       │
  19254.         │                     │  int CurrentShift;                     │
  19255.         │                     │  GET_KEY();                            │
  19256.         │                     │  /* both ALT and CTRL                  │
  19257.         │                     │     must be pressed */                 │
  19258.         │                     │  CurrentShift =                        │
  19259.         │                     │         (GET_SHIFT_STATE() & ALT) &&   │
  19260.         │                     │         (GET_SHIFT_STATE() & CTRL);    │
  19261.         │                     │                                        │
  19262.         │                     │  printf("The Ctrl and Alt key"         │
  19263.         │                     │         "was %s pressed",              │
  19264.         │                     │         CurrentShift?"":"not");        │
  19265.         │                     │}                                       │
  19266.         ├─────────────────────┼────────────────────────────────────────┤
  19267.         │ISKEYREADY()         │Returns TRUE if there is a key ready in │
  19268.         │                     │the keyboard buffer, FALSE otherwise.   │
  19269.         └─────────────────────┴────────────────────────────────────────┘
  19270.  
  19271.          Page 308          The C Window Library               Page 308
  19272.  
  19273.          Keyboard Idle function
  19274.          ----------------------
  19275.  
  19276.          When calling the GET_KEY() or GET_ENHANCED_KEY() macros, you
  19277.          can call a function while the program is waiting for a key to
  19278.          be pressed.  The global variable CWLkey_idle_func is a function
  19279.          pointer that points to this function.  Here is the prototype:
  19280.  
  19281.                        void (*CWLkey_idle_func)(void)
  19282.  
  19283.          There are no arguments and no return value to this function.
  19284.          You must initialize this function pointer after you have
  19285.          called WindowInitializeSystem().  If not, the function you
  19286.          assigned will not be executed.  Here is an example:
  19287.  
  19288.  
  19289.          #include "cwlwin.h"
  19290.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  19291.          void count_numbers(void);
  19292.          int num = 0;
  19293.  
  19294.          main()
  19295.          {
  19296.            WindowInitializeSystem();
  19297.            CWLkey_idle_func = count_numbers;
  19298.            ClearScreen(NORM);
  19299.            GET_KEY();
  19300.            MoveCursor(2,1,0);
  19301.            VideoPrintf("You stopped the count at %d",num);
  19302.          }
  19303.  
  19304.          void count_numbers()
  19305.          {
  19306.            num++;
  19307.            MoveCursor(0,0,0);
  19308.            VideoPrintf("%d",num);
  19309.            delay(1000);
  19310.          }
  19311.  
  19312.  
  19313.          The program above keeps a counter going in the upper left
  19314.          hand corner of the screen until a key is pressed.
  19315.  
  19316.          If you want to unassign the CWLkey_idle_func function pointer,
  19317.          do the following:
  19318.  
  19319.                       CWLkey_idle_func = VOIDNULLFN;
  19320.  
  19321.          This function can perform just about anything.  One major use
  19322.          would be to update an on-screen clock while the keyboard is
  19323.          not being used.
  19324.  
  19325.  
  19326.  
  19327.  
  19328.  
  19329.  
  19330.  
  19331.          Page 309          The C Window Library               Page 309
  19332.  
  19333.          Keyboard Intercept function
  19334.          ---------------------------
  19335.  
  19336.          Before GET_KEY() and GET_ENHANCED_KEY() return a value, you
  19337.          can intercept the pending return value, examine it, and
  19338.          change the value to whatever you wish.  This is good if you
  19339.          want to reassign keys easily.  The function pointer to assign
  19340.          is CWLkey_intercept_func.  Here is the prototype:
  19341.  
  19342.            unsigned (*CWLkey_intercept_func)(int which, unsigned keyval)
  19343.  
  19344.          The first argument is an integer that denotes whether a mouse
  19345.          button was pressed, or a key from the keyboard was pressed.
  19346.          If a keyboard key was pressed, the value of which is equal to
  19347.          KEYPRESSED, otherwise it is MOUSEPRESSED.  If you do not have
  19348.          a mouse, or the mouse is not activated, this value will
  19349.          always be KEYPRESSED.  More information on the mouse in the
  19350.          USING THE MOUSE section in the manual.  The return value will
  19351.          be the new key value that GET_KEY() and GET_ENHANCED_KEY()
  19352.          will return.  It is advisable to use the key codes described
  19353.          in "cwlwin.h" if you are returning a non-ascii key.  Here
  19354.          is an example:
  19355.  
  19356.          #include "cwlwin.h"
  19357.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  19358.          unsigned switch_to_quotes(int,unsigned);
  19359.          unsigned oldchar;
  19360.          main()
  19361.          {
  19362.            int ch;
  19363.            WindowInitializeSystem();
  19364.            CWLkey_intercept_func = switch_to_quotes;
  19365.            ClearScreen(NORM);
  19366.            ch = GET_KEY();
  19367.            MoveCursor(0,0,0);
  19368.            VideoPrintf(
  19369.               "The old key was %c.  The new code is %c",oldchar,ch);
  19370.          }
  19371.  
  19372.          unsigned switch_to_quotes(int which, unsigned keyval)
  19373.          {
  19374.            if (which == KEYPRESSED)
  19375.            {
  19376.              oldchar = keyval;
  19377.              return (unsigned)'"';  /* return a double quote */
  19378.            }
  19379.          }
  19380.  
  19381.          The program above intercepts the return value of GET_KEY()
  19382.          and assigns the double quote character.  The character is
  19383.          then printed out on the screen along with the character that
  19384.          was assigned.
  19385.  
  19386.          If you want to unassign the CWLkey_intercept_func function
  19387.          pointer, do the following:
  19388.  
  19389.                   CWLkey_intercept_func = NULLFN;
  19390.  
  19391.          Page 310          The C Window Library               Page 310
  19392.  
  19393.          Checking for mouse button presses
  19394.          ---------------------------------
  19395.  
  19396.          The GET_MPRESS_KEY() and GET_MPRESS_ENHANCED_KEY() macros
  19397.          work the same as the GET_KEY() and GET_ENHANCED_KEY()
  19398.          macros, which are described below and used in some previous
  19399.          examples, except that GET_MPRESS_KEY() and
  19400.          GET_MPRESS_ENHANCED_KEY() also test to see if one or more
  19401.          mouse buttons has been pressed.
  19402.  
  19403.          When GET_MPRESS_KEY() or GET_MPRESS_ENHANCED_KEY() is
  19404.          called, the program is suspended until a key on the keyboard
  19405.          is pressed, or one or more mouse buttons has been pressed.
  19406.          The difference between these two macros is that
  19407.          GET_MPRESS_ENHANCED_KEY() recognizes keys on an enhanced
  19408.          (101 key) keyboard.  Here is a prototype for both of these
  19409.          macros:
  19410.  
  19411.            unsigned int GET_MPRESS_KEY(int *which)
  19412.  
  19413.            unsigned int GET_MPRESS_ENHANCED_KEY(int *which)
  19414.  
  19415.          The only argument is a pointer to an integer which will
  19416.          contain either MOUSEPRESSED if the mouse was pressed, or
  19417.          KEYBOARDPRESSED if a key on the keyboard was pressed.  The
  19418.          CWLkey_idle_func and CWLkey_intercept_func function pointers
  19419.          are fully implemented when either of these macros are called.
  19420.  
  19421.          Both of these macros return either the key that was struck,
  19422.          or the mouse button(s) that was(were) pressed.  The values
  19423.          for these mouse buttons are as follows:
  19424.  
  19425.           ┌──────────────────────────┬───────────────────────────────┐
  19426.           │MOUSELEFT_PRESS           │Left button was pressed.       │
  19427.           ├──────────────────────────┼───────────────────────────────┤
  19428.           │MOUSERIGHT_PRESS          │Right button was pressed.      │
  19429.           ├──────────────────────────┼───────────────────────────────┤
  19430.           │MOUSEMIDDLE_PRESS         │Middle button was pressed.     │
  19431.           ├──────────────────────────┼───────────────────────────────┤
  19432.           │MOUSELEFTRIGHT_PRESS      │Left and Right was pressed     │
  19433.           │                          │simultaneously.                │
  19434.           ├──────────────────────────┼───────────────────────────────┤
  19435.           │MOUSEMIDDLERIGHT_PRESS    │Middle and Right buttons were  │
  19436.           │                          │pressed simultaneously.        │
  19437.           ├──────────────────────────┼───────────────────────────────┤
  19438.           │MOUSEMIDDLELEFT_PRESS     │Middle and Left buttons pressed│
  19439.           │                          │simultaneously.                │
  19440.           ├──────────────────────────┼───────────────────────────────┤
  19441.           │MOUSEMIDDLERIGHTLEFT_PRESS│Middle, right, and left buttons│
  19442.           │                          │pressed simultaneously.        │
  19443.           └──────────────────────────┴───────────────────────────────┘
  19444.  
  19445.          If a keyboard key is hit, the return values are the same as
  19446.          for GET_KEY() or GET_ENHANCED_KEY().
  19447.  
  19448.  
  19449.  
  19450.  
  19451.          Page 311          The C Window Library               Page 311
  19452.  
  19453.          Example:
  19454.  
  19455.          #include "cwlmouse.h"
  19456.          #include "cwlwin.h"
  19457.          #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  19458.  
  19459.          void print_nums();
  19460.  
  19461.          main()
  19462.          {
  19463.            int w,b;
  19464.            unsigned ch;
  19465.            WindowInitializeSystem();
  19466.            ClearScreen(NORM);
  19467.            MouseInitializeSystem(MOUSE_FULL_INSTALL,&b,10,10);
  19468.            CWLkey_idle_func = print_nums;
  19469.            ch = GET_MPRESS_KEY(&w);
  19470.            VideoPrintf("\nThe %s was pressed.  Value is %d",
  19471.                         (w==MOUSEPRESSED?"Mouse":"Keyboard"),ch);
  19472.            MouseRestoreSystem();
  19473.          }
  19474.  
  19475.          void print_nums()
  19476.          {
  19477.            static int count = 0;
  19478.            MoveCursor(0,0,0);
  19479.            VideoPrintf("%d",count++);
  19480.          }
  19481.  
  19482.  
  19483.  
  19484.  
  19485.  
  19486.  
  19487.  
  19488.  
  19489.  
  19490.  
  19491.  
  19492.  
  19493.  
  19494.  
  19495.  
  19496.  
  19497.  
  19498.  
  19499.  
  19500.  
  19501.  
  19502.  
  19503.  
  19504.  
  19505.  
  19506.  
  19507.  
  19508.  
  19509.  
  19510.  
  19511.          Page 312          The C Window Library               Page 312
  19512.  
  19513.                              ERROR CODES
  19514.                              -----------
  19515.  
  19516.          The following table is a list of error codes defined in CWL.
  19517.  
  19518.  
  19519.          Error Code              Value  Definition
  19520.         ┌───────────────────────┬─────┬──────────────────────────────┐
  19521.         │NO_ERROR               │  0  │No error.                     │
  19522.         ├───────────────────────┼─────┼──────────────────────────────┤
  19523.         │NO_HEAP_MEM            │ -1  │Memory Allocation Failed.     │
  19524.         ├───────────────────────┼─────┼──────────────────────────────┤
  19525.         │BAD_DISPLAY_PAGE       │ -2  │Video page does not exist.    │
  19526.         ├───────────────────────┼─────┼──────────────────────────────┤
  19527.         │INVALID_VIDEO_MODE     │ -3  │Video mode is invalid.        │
  19528.         ├───────────────────────┼─────┼──────────────────────────────┤
  19529.         │INVALID_ROWS           │ -4  │Invalid number of screen rows.│
  19530.         ├───────────────────────┼─────┼──────────────────────────────┤
  19531.         │NOT_SUPPORTED          │ -5  │Feature is not supported in   │
  19532.         │                       │     │this version of CWL.          │
  19533.         ├───────────────────────┼─────┼──────────────────────────────┤
  19534.         │BAD_WINDOW             │-100 │WPOINTER does not exist.      │
  19535.         ├───────────────────────┼─────┼──────────────────────────────┤
  19536.         │BAD_WINDOW_SIZE        │-101 │Window size is invalid.       │
  19537.         ├───────────────────────┼─────┼──────────────────────────────┤
  19538.         │MAX_WINDOW             │-104 │Maximum number of windows     │
  19539.         │                       │     │already defined.              │
  19540.         ├───────────────────────┼─────┼──────────────────────────────┤
  19541.         │NO_INPUT_CHARS         │-106 │Number of characters defined  │
  19542.         │                       │     │in input mask is 0.           │
  19543.         ├───────────────────────┼─────┼──────────────────────────────┤
  19544.         │BAD_V_WINDOW           │-200 │VWPOINTER does not exist.     │
  19545.         ├───────────────────────┼─────┼──────────────────────────────┤
  19546.         │NO_ATTRIB              │-204 │Virtual window has no         │
  19547.         │                       │     │attributes.                   │
  19548.         ├───────────────────────┼─────┼──────────────────────────────┤
  19549.         │FILE_NO_EXIST          │-300 │File does not exist.          │
  19550.         ├───────────────────────┼─────┼──────────────────────────────┤
  19551.         │FILE_CANT_CLOSE        │-301 │Cannot close output file.     │
  19552.         ├───────────────────────┼─────┼──────────────────────────────┤
  19553.         │FILE_CANT_OPEN         │-302 │Cannot open file for output.  │
  19554.         ├───────────────────────┼─────┼──────────────────────────────┤
  19555.         │MENU_ENTRY_INVALID     │-400 │Invalid menu entry.           │
  19556.         ├───────────────────────┼─────┼──────────────────────────────┤
  19557.         │POPUP_NOT_ATTACHED     │-405 │Popup Menu does not have a    │
  19558.         │                       │     │window attached.              │
  19559.         ├───────────────────────┼─────┼──────────────────────────────┤
  19560.         │BAR_NOT_ATTACHED       │-406 │Bar Menu does not have a      │
  19561.         │                       │     │window attached.              │
  19562.         ├───────────────────────┼─────┼──────────────────────────────┤
  19563.         │PULL_NO_BARMENU        │-407 │Pulldown menu does not have a │
  19564.         │                       │     │bar menu defined.             │
  19565.         ├───────────────────────┼─────┼──────────────────────────────┤
  19566.         │POPUP_MENU_INVALID     │-408 │POPUP_MENU_PTR is invalid.    │
  19567.         ├───────────────────────┼─────┼──────────────────────────────┤
  19568.         │BAR_MENU_INVALID       │-409 │BAR_MENU_PTR is invalid.      │
  19569.         └───────────────────────┴─────┴──────────────────────────────┘
  19570.  
  19571.          Page 313          The C Window Library               Page 313
  19572.  
  19573.                      IMPORTANT GLOBAL VARIABLES
  19574.                      --------------------------
  19575.  
  19576.          There are global variables that you should be aware of in The
  19577.          C Window Library.  Most of these variables can be changed,
  19578.          while others should be left alone.  You must call
  19579.          WindowInitializeSystem() before modifying any of these
  19580.          variables.  The list does not cover all of the global
  19581.          variables in CWL.  To refer to all of the global variables,
  19582.          the file CWLGLOB.H and INTERNAL.H has definitions for all
  19583.          global variables and internal functions used in CWL.
  19584.  
  19585.          When describing the global variable, the following scheme is
  19586.          used:
  19587.  
  19588.  
  19589.  
  19590.  
  19591.  
  19592.          Variable         variable name
  19593.  
  19594.          Defined in       XXXXXX.h  (file where variable is declared)
  19595.  
  19596.          Initialized in   function call (function where variable gets
  19597.                                          its initial value)
  19598.  
  19599.          Purpose          Description of variable's purpose.
  19600.  
  19601.          Default Value    default value for variable.
  19602.  
  19603.          Modify Info      Tells if variable should be modified.
  19604.  
  19605.  
  19606.  
  19607.          These variables are described in alphabetical order.
  19608.  
  19609.  
  19610.  
  19611.  
  19612.  
  19613.  
  19614.  
  19615.          Variable         int CWLactive_page
  19616.  
  19617.          Initialized in   WindowInitializeSystem()
  19618.  
  19619.          Purpose          Current active video page.
  19620.  
  19621.          Modify Info      Should be modified only by calling the
  19622.                           SetActiveVideoPage() function.
  19623.  
  19624.  
  19625.  
  19626.  
  19627.  
  19628.  
  19629.  
  19630.  
  19631.          Page 314          The C Window Library               Page 314
  19632.  
  19633.          Variable         int CWLbar_press
  19634.  
  19635.          Initialized in   MouseInitializeSystem()
  19636.  
  19637.          Purpose          Holds the current button mouse button to
  19638.                           press to move the highlight bar on bar
  19639.                           menus.
  19640.  
  19641.          Default Value    MOUSELEFT_PRESS.
  19642.  
  19643.          Modify Info      Can be modified at any time.
  19644.  
  19645.  
  19646.  
  19647.  
  19648.  
  19649.          Variable         int CWLcaldelay
  19650.  
  19651.          Initialized in   WindowInitializeSystem()
  19652.  
  19653.          Purpose          This is a calibration count for the delay()
  19654.                           function.
  19655.  
  19656.          Modify Info      Should only be modified if the delay()
  19657.                           function is giving inaccurate delay times.
  19658.                           If the delay is too long, then caldelay_
  19659.                           should be decreased.  If it is too short,
  19660.                           then CWLcaldelay should be increased.
  19661.  
  19662.  
  19663.  
  19664.  
  19665.          Variable         int CWLcheck_exist
  19666.  
  19667.          Initialized in   WindowInitializeSystem()
  19668.  
  19669.          Purpose          Informs The C Window Library to check for
  19670.                           window, virtual window, and for non-open
  19671.                           window errors.  If this variable is 1, the
  19672.                           library routines will check for these
  19673.                           conditions.  If 0, these conditions are not
  19674.                           checked.
  19675.  
  19676.          Default Value    1.
  19677.  
  19678.          Modify Info      Can be modified at any time, but is
  19679.                           recommended that this flag be left on for
  19680.                           development work.  Make sure that your
  19681.                           application program is stable if you plan to
  19682.                           turn off checking.
  19683.  
  19684.  
  19685.  
  19686.  
  19687.  
  19688.  
  19689.  
  19690.  
  19691.          Page 315          The C Window Library               Page 315
  19692.  
  19693.          Variable         int CWLchksnow
  19694.  
  19695.          Initialized in   WindowInitializeSystem()
  19696.  
  19697.          Purpose          This variable controls whether the display
  19698.                           should be checked for snow when writing
  19699.                           directly to the screen.  A value of 1 will
  19700.                           check for snow, while a value of 0 will turn
  19701.                           off snow checking.
  19702.  
  19703.          Default Value    0 (no snow checking).
  19704.  
  19705.          Modify Info      Can be modified at any time.
  19706.  
  19707.  
  19708.  
  19709.  
  19710.  
  19711.          Variable         int CWLcrt_port
  19712.  
  19713.          Initialized in   WindowInitializeSystem()
  19714.  
  19715.          Purpose          This variable holds the value of the CRT
  19716.                           status port.  This port is used to test when
  19717.                           it is safe to read or write characters to
  19718.                           the screen without producing snow.
  19719.  
  19720.          Modify Info      Should not be modified.
  19721.  
  19722.  
  19723.  
  19724.  
  19725.          Variable         int CWLcursor_mode
  19726.  
  19727.          Initialized in   WindowInitializeSystem()
  19728.  
  19729.          Purpose          Holds the mode that the WindowGet...()
  19730.                           functions will operate in when called.  The
  19731.                           modes are either OVERSTRIKEMODE or
  19732.                           INSERTMODE.
  19733.  
  19734.          Default Value    OVERSTRIKEMODE.
  19735.  
  19736.          Modify Info      Can be modified at any time.
  19737.  
  19738.  
  19739.                           Example:
  19740.  
  19741.                           CWLcursor_mode = INSERTMODE;
  19742.  
  19743.  
  19744.  
  19745.  
  19746.  
  19747.  
  19748.  
  19749.  
  19750.  
  19751.          Page 316          The C Window Library               Page 316
  19752.  
  19753.          Variable         int CWLcursor_type[2]
  19754.  
  19755.          Initialized in   WindowInitializeSystem()
  19756.  
  19757.          Purpose          Holds the cursor shapes for OVERSTRIKEMODE
  19758.                           and INSERTMODE input modes.
  19759.  
  19760.          Default Value    CWLcursor_type[OVERSTRIKEMODE] is set
  19761.                           to a block cursor.
  19762.                           CWLcursor_type[INSERTMODE] is set to an
  19763.                           underline cursor.
  19764.  
  19765.          Modify Info      Can be modified at any time.
  19766.  
  19767.                           Example:
  19768.  
  19769.                           CWLcursor_type[INSERTMODE] =
  19770.                                         CREATE_CURSOR_SHAPE(5,7);
  19771.  
  19772.  
  19773.  
  19774.  
  19775.  
  19776.          Variable         int CWLdef_attr
  19777.  
  19778.          Initialized in   WindowInitializeSystem()
  19779.  
  19780.          Purpose          Default video attribute used when any
  19781.                           Video...() functions are called to write to
  19782.                           the screen.
  19783.  
  19784.          Default Value    7 (black background, white foreground).
  19785.  
  19786.          Modify Info      Can be modified at any time.
  19787.  
  19788.  
  19789.  
  19790.  
  19791.  
  19792.          Variable         int CWLenhanced_keyboard
  19793.  
  19794.          Initialized in   WindowInitializeSystem()
  19795.  
  19796.          Purpose          Tells if an enhanced keyboard is attached.
  19797.                           If CWLenhanced_keyboard is 1, an enhanced
  19798.                           keyboard is active, otherwise if 0, the
  19799.                           keyboard is not an enhanced keyboard.
  19800.  
  19801.          Modify Info      Can be modified safely.
  19802.  
  19803.  
  19804.  
  19805.  
  19806.  
  19807.  
  19808.  
  19809.  
  19810.  
  19811.          Page 317          The C Window Library               Page 317
  19812.  
  19813.          Variable         int CWLeffect_speed[16]
  19814.  
  19815.          Initialized in   WindowInitializeSystem()
  19816.  
  19817.          Purpose          This array holds the number of milliseconds
  19818.                           of delay for each of the special effects
  19819.                           supported in The C Window Library.
  19820.  
  19821.          Default Value    10 (10 ms.), except for
  19822.                           CWLeffect_speed[BRICKS], which is 1 ms.
  19823.  
  19824.          Modify Info      Can be modified safely at anytime.  The way
  19825.                           you would modify the values is to use the
  19826.                           special effects constants.  For example:
  19827.  
  19828.                                CWLeffect_speed[CONTRACT] = 5;
  19829.  
  19830.                           The above example changes the explosion
  19831.                           delay for the CONTRACT special effect to 5
  19832.                           ms.
  19833.  
  19834.  
  19835.  
  19836.  
  19837.  
  19838.          Variable         int CWLflush_kbd
  19839.  
  19840.          Initialized in   WindowInitializeSystem().
  19841.  
  19842.          Purpose          Tells if the keyboard buffer should be
  19843.                           flushed whenever the GET_KEY() or
  19844.                           GET_ENHANCED_KEY() macros are called.  A
  19845.                           value of 1 means the buffer will be flushed.
  19846.  
  19847.          Default Value    0 (no flush).
  19848.  
  19849.          Modify Info      Can be modified at any time.
  19850.  
  19851.  
  19852.  
  19853.  
  19854.  
  19855.          Variable         VIDEO_CONFIG CWLinit_video
  19856.  
  19857.          Initialized in   WindowInitializeSystem()
  19858.  
  19859.          Purpose          Structure that holds the video configuration
  19860.                           when WindowInitializeSystem() is called.
  19861.  
  19862.          Modify info      Should not be modified if the initial video
  19863.                           startup is desired when exiting an
  19864.                           application.
  19865.  
  19866.  
  19867.  
  19868.  
  19869.  
  19870.  
  19871.          Page 318          The C Window Library               Page 318
  19872.  
  19873.          Variable         char CWLmask_char
  19874.  
  19875.          Initialized in   WindowInitializeSystem()
  19876.  
  19877.          Purpose          Holds the mask character that is used for
  19878.                           input routines.  The character defined in
  19879.                           input_mask_char is used in input masks to
  19880.                           specify an input position in the edit field.
  19881.                           Refer to the functions WindowGet..()
  19882.                           functions for more information concerning
  19883.                           character masks.
  19884.  
  19885.          Default Value    '_'  (0x5F).
  19886.  
  19887.          Modify Info      Can be modified safely at any time, except
  19888.                           when in the middle of a user defined
  19889.                           function that was called by The C Window
  19890.                           Library's input routines.
  19891.  
  19892.  
  19893.  
  19894.  
  19895.  
  19896.          Variable         void (*CWLkey_idle_func)(void)
  19897.  
  19898.          Initialized in   WindowInitializeSystem()
  19899.  
  19900.          Purpose          pointer that points to a function that is
  19901.                           performed whenever the GET_KEY() and
  19902.                           GET_ENHANCED_KEY() macros do not have a key
  19903.                           ready to be processed.
  19904.  
  19905.          Modify Info      Can be modified at any time.
  19906.  
  19907.  
  19908.  
  19909.  
  19910.  
  19911.          Variable         unsigned (*CWLkey_intercept_func)(int which,
  19912.                                                       unsigned keyval)
  19913.  
  19914.          Initialized in   WindowInitializeSystem()
  19915.  
  19916.          Purpose          pointer that points to a function which
  19917.                           traps any keystrokes that the GET_KEY() and
  19918.                           GET_ENHANCED_KEY() macros will return.
  19919.  
  19920.          Modify Info      Can be modified at any time.
  19921.  
  19922.  
  19923.  
  19924.  
  19925.  
  19926.  
  19927.  
  19928.  
  19929.  
  19930.  
  19931.          Page 319          The C Window Library               Page 319
  19932.  
  19933.          Variable         int CWLmax_pages
  19934.  
  19935.          Initialized in   WindowInitializeSystem()
  19936.  
  19937.          Purpose          Total number of video pages detected by The
  19938.                           C Window Library.
  19939.  
  19940.          Modify Info      Should not be modified unless a modification
  19941.                           to the screen_page_offset array was done.
  19942.  
  19943.  
  19944.  
  19945.  
  19946.  
  19947.  
  19948.          Variable         int (*CWLchars_entered_func)(char *string,
  19949.                                                        int minchars)
  19950.  
  19951.          Arguments        string - string that was entered.
  19952.  
  19953.                           minchars - minimum number of characters
  19954.                           expected.
  19955.  
  19956.          Initialized in   WindowInitializeSystem()
  19957.  
  19958.          Purpose          Pointer to user-defined function that will
  19959.                           be executed when the input manager detects
  19960.                           that there were not enough characters
  19961.                           entered.
  19962.  
  19963.          Default Value    NULLFN.
  19964.  
  19965.          Variable         int CWLwindow_trans[16]
  19966.  
  19967.          Initialized in   WindowInitializeSystem()
  19968.  
  19969.          Purpose          Array of the number of transparent shadows
  19970.                           that are currently displayed for each
  19971.                           display page.
  19972.  
  19973.          Default Value    0 for each array element.
  19974.  
  19975.          Modify Info      Do not modify.
  19976.  
  19977.  
  19978.  
  19979.  
  19980.  
  19981.  
  19982.  
  19983.  
  19984.  
  19985.  
  19986.  
  19987.  
  19988.  
  19989.  
  19990.  
  19991.          Page 320          The C Window Library               Page 320
  19992.  
  19993.          Variable         WPOINTER CWLorig_screen[16]
  19994.  
  19995.          Initialized in   WindowInitDesktop()
  19996.  
  19997.          Purpose          Array of windows created when
  19998.                           WindowInitDesktop() is called.  The original
  19999.                           screen for video page 0 is CWLorig_screen[0],
  20000.                           page 1 is CWLorig_screen[1], etc.  Modify
  20001.                           Info You can use any window function on the
  20002.                           original screen, except for ones that
  20003.                           resize, move, hide, display, or close.  If
  20004.                           you write strings to the original screen,
  20005.                           you will permanently destroy the contents of
  20006.                           the original screen at the positions that
  20007.                           have been modified.
  20008.  
  20009.                           Example:
  20010.  
  20011.                           WindowWriteString(CWLorig_screen[0],"123",0,0);
  20012.  
  20013.                           The above example writes "123" to the upper
  20014.                           left hand corner of the original screen of
  20015.                           video page 0.
  20016.  
  20017.  
  20018.  
  20019.  
  20020.  
  20021.          Variable         int CWLpagesize
  20022.  
  20023.          Initialized in   WindowInitializeSystem()
  20024.  
  20025.          Purpose          Holds the size of a display page in bytes.
  20026.  
  20027.          Modify Info      Should not be modified unless The C Window
  20028.                           Library did not detect the correct video
  20029.                           page size.
  20030.  
  20031.  
  20032.  
  20033.  
  20034.  
  20035.  
  20036.  
  20037.  
  20038.  
  20039.  
  20040.  
  20041.  
  20042.  
  20043.  
  20044.  
  20045.  
  20046.  
  20047.  
  20048.  
  20049.  
  20050.  
  20051.          Page 321          The C Window Library               Page 321
  20052.  
  20053.          Variable         int CWLpopup_press
  20054.  
  20055.          Initialized in   MouseInitializeSystem()
  20056.  
  20057.          Purpose          Holds the current button mouse button to
  20058.                           press to move the highlight bar on popup
  20059.                           menus.
  20060.  
  20061.          Default Value    MOUSELEFT_PRESS.
  20062.  
  20063.          Modify Info      Can be modified at any time.
  20064.  
  20065.  
  20066.  
  20067.  
  20068.  
  20069.          Variable         int (*CWLreg_exp_error_func)(char *string,
  20070.                                                        int nomatch)
  20071.  
  20072.          Arguments        string - string that was entered.
  20073.  
  20074.                           nomatch - position of the first non-matching
  20075.                           character.
  20076.  
  20077.          Initialized in   WindowInitializeSystem()
  20078.  
  20079.          Purpose          Pointer to user-defined function that will
  20080.                           be executed when the input manager detects
  20081.                           that there are illegal characters in the
  20082.                           string when it is compared to the regular
  20083.                           expression.  This function is only called
  20084.                           when it is not equal to NULLFN, and the
  20085.                           CHECKREGEXP option is on.
  20086.  
  20087.          Default Value    NULLFN.
  20088.  
  20089.          Modify info      Can be modified at any time.
  20090.  
  20091.          Return Values    Must return DONT_PROCESS or ACCEPT_INPUT.
  20092.  
  20093.  
  20094.  
  20095.  
  20096.  
  20097.          Variable         int CWLscreen_cols
  20098.  
  20099.          Initialized in   WindowInitializeSystem()
  20100.  
  20101.          Purpose          Number of columns visible on the screen.
  20102.  
  20103.          Modify Info      Do not modify this variable
  20104.  
  20105.  
  20106.  
  20107.  
  20108.  
  20109.  
  20110.  
  20111.          Page 322          The C Window Library               Page 322
  20112.  
  20113.          Variable         unsigned int *CWLscreen_image[16]
  20114.  
  20115.          Initialized in   WindowInitializeSystem()
  20116.  
  20117.          Purpose          Used for internal window management.  Each
  20118.                           pointer in the CWLscreen_image array points
  20119.                           to an image of the current window
  20120.                           organization of the screen. For example
  20121.                           CWLscreen_image[0] is a pointer to the
  20122.                           current window "layout" for video page 0.
  20123.  
  20124.          Modify Info      DO NOT modify this.  This array is VERY
  20125.                           important when window updates are done.
  20126.  
  20127.  
  20128.  
  20129.  
  20130.  
  20131.  
  20132.          Variable         unsigned char far *CWLpage_offset[16]
  20133.  
  20134.          Initialized in   WindowInitializeSystem()
  20135.  
  20136.          Purpose          Array of starting addresses of each video
  20137.                           page.
  20138.  
  20139.          Modify Info      You can modify if The C Window Library fails
  20140.                           to detect video pages that your video card
  20141.                           may have.
  20142.  
  20143.                           Invalid video pages will set
  20144.                           CWLpage_offset[page] to a far NULL
  20145.                           pointer, where page is the invalid video
  20146.                           page.
  20147.  
  20148.                           If there is a failure to detect video pages
  20149.                           that your card may have, you can use the
  20150.                           MAKE_FAR_POINTER macro to initialize.
  20151.                           Example: CWLpage_offset[page] =
  20152.                                    MAKE_FAR_POINTER(0xB000,0x2000);
  20153.  
  20154.                           where page is the page to initialize.  You
  20155.                           should have the documentation of the video
  20156.                           card on hand so that you are sure of the
  20157.                           starting address of the video page.
  20158.  
  20159.                           You must also adjust the global variable
  20160.                           CWLmax_pages to reflect the new number
  20161.                           of pages, and the CWLpagesize variable to
  20162.                           reflect the size of each video page.
  20163.  
  20164.  
  20165.  
  20166.  
  20167.  
  20168.  
  20169.  
  20170.  
  20171.          Page 323          The C Window Library               Page 323
  20172.  
  20173.          Variable         int CWLscreen_rows
  20174.  
  20175.          Initialized in   WindowInitializeSystem()
  20176.  
  20177.  
  20178.          Purpose          Number of rows visible on the screen.
  20179.  
  20180.          Modify Info      Don't modify this variable
  20181.  
  20182.  
  20183.  
  20184.  
  20185.          Variable         int (*CWLundef_akey_func)(char *string,
  20186.                                                     unsigned key,
  20187.                                                     int pos,
  20188.                                                     int *newpos)
  20189.  
  20190.          Arguments        string - string currently entered.
  20191.  
  20192.                           key - key that was hit.
  20193.  
  20194.                           pos - position where cursor is in the input
  20195.                                 string.
  20196.  
  20197.          Purpose          Pointer to a function that is executed when
  20198.                           a key that is not defined in an input
  20199.                           routines regular expression is pressed.
  20200.  
  20201.          Default Value    NULLFN.
  20202.  
  20203.          Modify Info      Can be modified at any time.
  20204.  
  20205.          Return Values    Refer to the manual for more information.
  20206.  
  20207.  
  20208.  
  20209.  
  20210.  
  20211.          Variable         int (*CWLundef_fkey_func)(char *string,
  20212.                                                     unsigned key,
  20213.                                                     int pos,
  20214.                                                     int *newpos)
  20215.  
  20216.          Defined in       key.h
  20217.  
  20218.          Arguments        string - string currently entered.
  20219.                           key - key that was hit.
  20220.                           pos - position where cursor is in the input
  20221.                                 string.
  20222.  
  20223.          Purpose          Pointer to a function that is executed when
  20224.                           a key that is not defined in an input
  20225.                           routines regular expression is pressed.
  20226.  
  20227.  
  20228.  
  20229.  
  20230.  
  20231.          Page 324          The C Window Library               Page 324
  20232.  
  20233.          Default Value    NULLFN.
  20234.  
  20235.          Modify Info      Can be modified at any time.
  20236.  
  20237.          Return Values    Refer to to the main documentation for more
  20238.                           information.
  20239.  
  20240.  
  20241.  
  20242.  
  20243.  
  20244.          Variable         int CWLvisible_page
  20245.  
  20246.          Initialized in   WindowInitializeSystem()
  20247.  
  20248.          Purpose          Current visible video page.
  20249.  
  20250.          Modify Info      Should be modified only by calling the
  20251.                           SetVisibleVideoPage() function.
  20252.  
  20253.  
  20254.  
  20255.  
  20256.  
  20257.          Variable         unsigned CWLedit_key[12]
  20258.  
  20259.          Defined in       cwlwin.h
  20260.  
  20261.          Initialized in   WindowInitializeSystem()
  20262.  
  20263.          Purpose          Array of edit key definitions.  This array
  20264.                           is used in the window input routines.
  20265.  
  20266.          Modify Info      You can modify values in the array, provided
  20267.                           that there are no duplicate definitions, and
  20268.                           there is a definition for a key that
  20269.                           terminates user input.  Refer to the GETTING
  20270.                           INPUT FROM WINDOWS section.
  20271.  
  20272.  
  20273.  
  20274.  
  20275.  
  20276.  
  20277.  
  20278.  
  20279.  
  20280.  
  20281.  
  20282.  
  20283.  
  20284.  
  20285.  
  20286.  
  20287.  
  20288.  
  20289.  
  20290.  
  20291.          Page 325          The C Window Library               Page 325
  20292.  
  20293.          Variable         int CWLerror_code
  20294.  
  20295.          Initialized in   WindowInitializeSystem()
  20296.  
  20297.          Purpose          Holds the last error that occurred as an
  20298.                           integer.  You should always check the value
  20299.                           of CWLerror_code to determine what has
  20300.                           happened if a function fails.  All of the
  20301.                           window and virtual window functions return
  20302.                           an error status when things go wrong.
  20303.                           However, only selected functions from the
  20304.                           Video...  family of functions set
  20305.                           CWLerror_code.
  20306.  
  20307.                           CWLerror_code does not reset itself if
  20308.                           there are no errors.
  20309.  
  20310.          Default Value    0.
  20311.  
  20312.          Modify Info      Safe to modify, but will always reset itself
  20313.                           to an error condition if a function fails.
  20314.  
  20315.  
  20316.  
  20317.  
  20318.  
  20319.  
  20320.  
  20321.  
  20322.  
  20323.  
  20324.  
  20325.  
  20326.  
  20327.  
  20328.  
  20329.  
  20330.  
  20331.  
  20332.  
  20333.  
  20334.  
  20335.  
  20336.  
  20337.  
  20338.  
  20339.  
  20340.  
  20341.  
  20342.  
  20343.  
  20344.  
  20345.  
  20346.  
  20347.  
  20348.  
  20349.  
  20350.  
  20351.          Page 326          The C Window Library               Page 326
  20352.  
  20353.                                  INDEX
  20354.                                  ─────
  20355.  
  20356.          A
  20357.  
  20358.          Adding Menu Entries
  20359.             (see Bar Menus-Creating Entries,
  20360.                  Popup Menus-Creating Entries,
  20361.                  Pulldown Menus-Creating Entries)
  20362.  
  20363.          Adjusting Screen Dimensions
  20364.             (see Screen Handling-Changing Number of Rows/
  20365.                                  Changing Number of Cols)
  20366.  
  20367.  
  20368.          B
  20369.  
  20370.          Bar Menus ................................ 208 - 232
  20371.              Changing Entry String ................ 224
  20372.              Creating ............................. 209 - 212
  20373.              Creating Entries ..................... 212 - 216
  20374.              Deleting Entries ..................... 216
  20375.              Disabling Entries .................... 223
  20376.              Disposing of ......................... 232
  20377.              Enabling Entries ..................... 223
  20378.              Inserting Entries .................... 212, 215
  20379.              Macros ............................... 302
  20380.              Pre-Selection Function ............... 230
  20381.              Redefining Menu Keys ................. 225
  20382.              Retrieving Options ................... 222
  20383.              Selecting ............................ 218
  20384.              Setting Local Key Definitions ........ 225
  20385.              Setting Options ...................... 221
  20386.              Undefined Keys ....................... 227
  20387.              Values passed to menu function ....... 220
  20388.              Values returned to menu manager ...... 220
  20389.  
  20390.          Boxes
  20391.              Types ................................ 12
  20392.              Drawing (see Screen Handling-Drawing Boxes)
  20393.  
  20394.  
  20395.  
  20396.          C
  20397.  
  20398.          Child Windows ............................ 118
  20399.              Centering  ........................... 22
  20400.              Creating ............................. 119
  20401.              Enumerating .......................... 123 - 124
  20402.              Testing Ranks ........................ 126
  20403.              Testing Relationships ................ 125 - 126
  20404.              Translating Coordinates .............. 120 - 123
  20405.              Uses ................................. 118
  20406.  
  20407.          Closing Windows
  20408.              (see Windows-Closing)
  20409.  
  20410.  
  20411.          Page 327          The C Window Library               Page 327
  20412.  
  20413.          Colors
  20414.              (see Screen Handling-Attributes)
  20415.  
  20416.          Cursor ................................... 79
  20417.              Changing Shape ....................... 79, 279
  20418.              Hiding ............................... 79, 281
  20419.              Maintenance .......................... 79
  20420.              Moving ............................... 80, 164, 279
  20421.              Retrieving Position .................. 82, 165, 280
  20422.              Retrieving Shape ..................... 81, 280
  20423.  
  20424.          CWL ...................................... 1
  20425.              Introduction ......................... 1
  20426.              Compiler Support ..................... i
  20427.              Global Variables ..................... iv
  20428.              Initializing ......................... 8
  20429.              Uninitializing ....................... 21
  20430.  
  20431.  
  20432.  
  20433.          D
  20434.  
  20435.          Delay function ........................... 285
  20436.          Direct Screen Writing .................... 5
  20437.  
  20438.  
  20439.  
  20440.          E
  20441.  
  20442.          Error Codes .............................. 7, 313
  20443.          Error Handling ........................... 288
  20444.  
  20445.  
  20446.  
  20447.          I
  20448.  
  20449.          Initializing
  20450.              CWL   (see CWL-Initializing)
  20451.              Mouse (see Mouse-Initializing)
  20452.  
  20453.          Input (see Window-Editing Input)
  20454.  
  20455.  
  20456.  
  20457.          M
  20458.  
  20459.          Menus
  20460.              (see Bar Menus, Popup Menus, Pulldown Menus)
  20461.  
  20462.          Mouse .................................... 291
  20463.              Initializing ......................... 291
  20464.              Turning Off .......................... 292
  20465.              Using with Menus ..................... 293, 295
  20466.  
  20467.  
  20468.  
  20469.  
  20470.  
  20471.          Page 328          The C Window Library               Page 328
  20472.  
  20473.          P
  20474.  
  20475.          Popup Menus .............................. 175 - 207
  20476.              Cascading Menus ...................... 185 - 187
  20477.              Changing Entry String ................ 197
  20478.              Creating ............................. 176 - 179
  20479.              Creating Entries ..................... 179 - 182
  20480.              Deleting Entries ..................... 187 - 188
  20481.              Disabling Entries .................... 196
  20482.              Disposing of ......................... 207
  20483.              Enabling Entries ..................... 196
  20484.              Inserting Entries .................... 179 - 187
  20485.              Macros ............................... 300 - 301
  20486.              Pre-Selection Function ............... 205 - 206
  20487.              Redefining Menu Keys ................. 199 - 200
  20488.              Retrieving Options ................... 195
  20489.              Sizing Popup Window .................. 188 - 190
  20490.              Selecting ............................ 191 - 193
  20491.              Setting Local Key Definitions ........ 200
  20492.              Setting Options ...................... 194
  20493.              Undefined Keys ....................... 201 - 204
  20494.              Values passed to menu function ....... 193
  20495.              Values returned to menu manager ...... 193
  20496.  
  20497.          Pulldown Menus ........................... 233 - 246
  20498.              Bar Menu Functions ................... 238
  20499.              Creating ............................. 234 - 236
  20500.              Creating Entries ..................... 235 - 236
  20501.              Deleting Entries ..................... 236
  20502.              Disposing of ......................... 238
  20503.              Macros ............................... 303
  20504.              Popup Menu Functions ................. 239
  20505.              Values passed to menu function ....... 237
  20506.              Values returned to menu manager ...... 237
  20507.  
  20508.  
  20509.          R
  20510.  
  20511.          Regular Expressions
  20512.              (see Window - Regular Expressions)
  20513.  
  20514.  
  20515.          S
  20516.  
  20517.          Screen Handling ..........................
  20518.              Attributes ........................... 4
  20519.              BIOS ................................. 5
  20520.              Setting Video Mode ................... 271
  20521.              Getiing Video Information ............ 283 - 284
  20522.              Changing Number of Rows .............. 272 - 275
  20523.              Changing Number of Columns ........... 276 - 278
  20524.              Writing Strings  ..................... 251 - 259
  20525.              Writing Attributes ................... 251 - 259
  20526.              Reading Strings ...................... 259 - 261
  20527.              Reading Attributes ................... 259 - 261
  20528.  
  20529.  
  20530.  
  20531.          Page 329          The C Window Library               Page 329
  20532.  
  20533.              Scrolling ............................ 269 - 270
  20534.              Saving Areas ......................... 264
  20535.              Restoring Areas ...................... 265
  20536.              Drawing Boxes ........................ 262 - 263
  20537.              Video Pages .......................... 6, 248 - 250
  20538.  
  20539.          Starting CWL
  20540.              (see CWL-Initializing)
  20541.  
  20542.  
  20543.          V
  20544.  
  20545.          Virtual Windows .......................... 127 - 173
  20546.              Attributes ........................... 127 - 128
  20547.              Clearing ............................. 166 - 169
  20548.              Closing .............................. 133 - 134, 172 - 173
  20549.              Freezing Viewport .................... 170 - 171
  20550.              Initializing ......................... 129 - 130
  20551.              Initializing Viewports ............... 131 - 133
  20552.              Introduction ......................... 127
  20553.              Logical Cursor ....................... 128, 164 - 165
  20554.              Positioning Viewport ................. 155 - 158
  20555.              Reading Attributes ................... 151 - 154
  20556.              Reading Strings ...................... 151 - 154
  20557.              Size ................................. 127
  20558.              Writing Attributes ................... 135 - 150
  20559.              Writing Contents to File ............. 162 - 163
  20560.              Writing Strings ...................... 135 - 150
  20561.  
  20562.  
  20563.          Video Modes (see Screen Handling-Video Mode)
  20564.          Video Pages (see Screen Handling-Video Pages)
  20565.          Video Functions (see Screen Handling)
  20566.  
  20567.  
  20568.  
  20569.          W
  20570.  
  20571.          Window ...................................
  20572.              Borders .............................. 10, 12, 25 - 27
  20573.              Centering ............................ 22 - 23
  20574.              Changing Window Size ................. 27 - 29
  20575.              Child
  20576.                   (see Child Windows)
  20577.              Clearing ............................. 66 - 69
  20578.              Client Area .......................... 4
  20579.              Closing .............................. 19 - 21
  20580.              Colors/Attributes .................... 4 - 5, 11, 304
  20581.              Coordinates .......................... 4
  20582.              Creating ............................. 9
  20583.              Creating copies ...................... 59 - 60
  20584.              Cursor Maintenance ................... 79 - 83
  20585.              Defining ............................. 1
  20586.              Desktop .............................. 2, 9
  20587.              Determining point ownership .......... 84
  20588.              Display Effects ...................... 14 - 18
  20589.  
  20590.  
  20591.          Page 330          The C Window Library               Page 330
  20592.  
  20593.              Displaying ........................... 14 - 18
  20594.              Editing Input ........................ 85 - 117
  20595.              Header Files ......................... 8
  20596.              Hiding ............................... 57 - 58
  20597.              Moving ............................... 77
  20598.              printf() for windows ................. 43 - 46
  20599.              Properties ........................... 1
  20600.              Ranks ................................ 2
  20601.              Reading Attributes ................... 53 - 58
  20602.              Reading Strings ...................... 53 - 58
  20603.              Regular Expressions .................. 85 - 89
  20604.              Scrolling Text ....................... 61 - 65
  20605.              See-thru Windows ..................... 75 - 76
  20606.              Shadowing ............................ 72 - 74
  20607.              Sliding .............................. 78
  20608.              Titles ............................... 47 - 52
  20609.              Top-Level ............................ 2
  20610.              Viewport
  20611.                 (see Virtual Window)
  20612.              Virtual
  20613.                 (see Virtual Window)
  20614.              Window Manager ....................... 7
  20615.              Writing Attributes ................... 38 - 41
  20616.              Writing Strings to ................... 30 - 46
  20617.              Writing to File ...................... 70 - 71
  20618.  
  20619.  
  20620.  
  20621.  
  20622.  
  20623.  
  20624.  
  20625.  
  20626.  
  20627.  
  20628.  
  20629.  
  20630.  
  20631.  
  20632.  
  20633.  
  20634.  
  20635.  
  20636.  
  20637.  
  20638.  
  20639.  
  20640.  
  20641.  
  20642.  
  20643.  
  20644.  
  20645.  
  20646.  
  20647.  
  20648.  
  20649.  
  20650.  
  20651.          Page 331          The C Window Library               Page 331
  20652.  
  20653.