home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 463.lha / ReqAztec / req.doc < prev    next >
Text File  |  1991-01-05  |  64KB  |  1,718 lines

  1.  
  2.     The  req.library is a run time re-entrant library that is designed
  3. to  make  it  easier  for  programmers  to  use  powerful, easy to use
  4. requesters  for  communicating  with  users.   The  requester  library
  5. includes  such functions as a color requester, file requester, message
  6. display  requester  and many functions to make the creation of gadgets
  7. for your own custom requesters easier.
  8.  
  9.     Req.library  was  written  by  Colin  Fox (of Pyramyd Designs) and
  10. Bruce  Dawson  (of  CygnusSoft  Software).   Req.library  is  a freely
  11. distributable  library that may be used in commercial products without
  12. paying  any  royalties.  We encourage you to use the requester library
  13. in all of your programs, to make them easier to write, and to use.
  14.  
  15.     Req.library  is  not public domain.  The requester library and all
  16. documentation and example programs are all copyright 1989, 1990.
  17.  
  18.     The  requester  library must be distributed with the file read.me,
  19. explaining  the requester library to users.  We would appreciate it if
  20. the  programmer documentation was distributed as well, but this is not
  21. mandatory.   The programmer documentation includes the descriptions of
  22. the  library  and its functions (req.doc), and the three include files
  23. (req.h, reqbase.h and reqbase.i).
  24.  
  25.  
  26.  
  27.     Req.library  is  dedicated  to  the programmers who make the Amiga
  28. shine the way it was meant to.
  29.  
  30.  
  31. OverView:
  32.  
  33.     All  of  the  req.library functions that bring up requesters allow
  34. you two ways of specifying what screen you would like the requester to
  35. appear  on.  The first way is the more efficient way, because you only
  36. have  to set it up once and then it takes care of things automatially.
  37. There  is  a  field in all process structures called the pr_WindowPtr.
  38. This  pointer  is  used by DOS to decide where to put it's requesters.
  39. If  pr_WindowPtr  contains  a  zero,  requesters  go  on the workbench
  40. screen.  If it contains the address of a window, then requesters go on
  41. that  window's  screen.   If  it  contains a negative one, then no DOS
  42. requesters come up.  The req.library requesters all use this variable,
  43. if  they  are  called from a process .  However, if the pointer is -1,
  44. the req.library functions do still appear, on the workbench screen.
  45.  
  46.     The  second  way  was  put in mainly so that the requesters can be
  47. called from tasks.  Since a task does not have a process structure, it
  48. also  lacks a pr_WindowPtr.  Therefore, all of the requester functions
  49. which  can  be  used from a task (currently everything except the file
  50. requester) can be passed a window pointer, either as a parameter or as
  51. an  element in a structure.  Important:  This pointer takes precedence
  52. over  the  pr_WindowPtr  so  if  you  wish  the  requesters to use the
  53. pr_WindowPtr  you  must  zero  the window fields that the routines are
  54. expecting.   In  the case of fields in a structure this can be easy as
  55. long   as  you  make  sure  your  structure  defaults  to  being  zero
  56. everywhere.
  57.  
  58.     Setting  the  pr_WindowPtr is quite a simple matter.  All you have
  59. to do is do a FindTask((char *)0); which returns a pointer to your own
  60. task  and your own process (a task structure is the first element of a
  61. process  structure).   Then  you  simply  preserve  the  old  value of
  62. pr_WindowPtr (VERY IMPORTANT!!!) and put a window pointer into it.
  63.  
  64. eg:
  65.                 /* Find my task. */
  66.     myprocess = (struct Process *)FindTask((char *)0);
  67.     oldwindowptr = myprocess->pr_WindowPtr;
  68.     myprocess->pr_WindowPtr = window;
  69.  
  70. or:
  71.  
  72.     MOVE.L  4,A6
  73.     MOVE.L  #0,A1
  74.     SYS     FindTask    ;Find my task.
  75.     MOVE.L  D0,_myprocess
  76.     MOVE.L  D0,A0
  77.     MOVE.L  pr_WindowPtr(A0),_oldwindowptr
  78.     MOVE.L  _window,pr_WindowPtr(A0)
  79.  
  80.     Before your program exits it is VERY important that it restore the
  81. previous  value of pr_WindowPtr.  If you don't, then your program will
  82. work  in some situations, but will BLOW UP in others.  For example, if
  83. you  execute  (without  using the 'run' command) a program, which then
  84. sets  the  pr_WindowPtr  to  point at one of its windows and the exits
  85. without  restoring  it,  then  the  next time a DOS requester tries to
  86. appear...  BOOM!  The machine will probably crash as DOS tries to open
  87. a requester on a now closed screen.  Therefore, before leaving:
  88.  
  89.     myprocess->pr_WindowPtr = oldwindowptr;
  90.  
  91. or:
  92.  
  93.     MOVE.L  _myprocess,A0
  94.     MOVE.L  _oldwindowptr,pr_WindowPtr(A0)
  95.  
  96.  
  97.  
  98.     One  final  note.   The  pr_WindowPtr  field exists in the process
  99. structure.   This  means  that  a  task  does  not  have  this  field.
  100. Therefore,  if you want to call one of the requester library functions
  101. from  a  task,  you  will not be able to specify what screen you would
  102. like  the  requester  to  appear on by setting the pr_WindowPtr field.
  103. All  of  the  functions  that open requesters and can be called from a
  104. task  (the file requester/font requester is the only one that can't be
  105. called  froma task) have some other way of specifying which screen you
  106. would like them to open on.  They will have either have a field in the
  107. structure  which you must pass them or a parameter which can contain a
  108. window  pointer  to one of the windows on your custom screen.  If this
  109. pointer is non-zero then it overrides the pr_WindowPtr field.
  110.  
  111.  
  112.  
  113.  
  114.     By  opening the requester library, you not only gain access to all
  115. of  the functions documented below, but to some other goodies as well.
  116. Req.library   needs  and  therefore  opens  several  other  libraries,
  117. including  dos.library,  intuition.library,  graphics.library  and the
  118. console  device.   All  of  these  pointers  are  stored in the ReqLib
  119. structure  which  you  get a pointer to when you open the req.library.
  120. Therefore,  you  can  save  yourself  a little bit of code by grabbing
  121. these  fields  after opening the requester library.  The only thing to
  122. beware of is don't use these values after you have close the requester
  123. library,  because  at  that point there is no guarantee that they will
  124. still be valid.
  125.  
  126.     In  addition  to  these  libraries,  the Images pointer in the req
  127. library structure points to a set of ten small images (four arrows and
  128. ssix  letters)  which have are guaranteed to be in chip memory.  These
  129. can be used if your program requires this type of images.
  130.  
  131.  
  132.  
  133.  
  134.     One  thing to keep in mind when using the gadget creation routines
  135. is  that there isn't any way for us to check that you have passed us a
  136. pointer  to  the  correct size of buffer, so you _must_ make sure that
  137. you are allocating the right amount of memory.
  138.  
  139.  
  140. --------------------------------------------------------------
  141. Here's a quick list of the functions available:
  142. --------------------------------------------------------------
  143.  
  144. Center..................Center a new window over the mouse.
  145.  
  146. SetSize.................Prop gadget handling routines (32 bit)
  147. SetLocation
  148. ReadLocation
  149.  
  150. Format..................sprintf() format routine
  151.  
  152. SimpleRequest...........Starter gluecode to TextRequest- Single gadget
  153. TwoGadRequest...........Starter gluecode to TextRequest- Two gadgets
  154.  
  155. FileRequester...........FileRequester routines
  156. PurgeFiles
  157.  
  158. ColorRequester..........a colorrequester
  159.  
  160. MakeGadget..............Gadget creation routines
  161. MakeString
  162. MakeProp
  163. MakeButton
  164.  
  165. MakeScrollBar...........3   part   gadget;   2   arrows  and  a  prop.
  166.                         Horizontal or Vertical
  167.  
  168. LinkGadget..............Gadget  creation  routines that self-hook into
  169.                         the newwindow
  170. LinkStringGadget........gadget list.
  171. LinkPropGadget
  172.  
  173. DrawBox.................Draw a box (x1y1)(x2y2) in one command
  174.  
  175. GetFontHeightAndWidth...return height and width of current font
  176.  
  177. RealTimeScroll..........scroll routine used in file requester
  178.  
  179. TextRequest.............Powerful requester function
  180.  
  181. GetString...............Get a line of text from the user
  182. GetLong.................Get a signed long from the user
  183.  
  184. RawKeyToAscii...........Convert raw key to ascii
  185.  
  186. NewGetString        A second point to GetString.  Different way of
  187.             passing parameters.
  188.  
  189. ----------------------------------------------------------------
  190.  
  191.  
  192. NAME
  193.         Center
  194.  
  195.  
  196. SYNOPSIS
  197.         Center( &nw, x, y)
  198.                  A0 D0 D1
  199.  
  200. struct NewWindow *nw;
  201. USHORT x,y;
  202.  
  203. DESCRIPTION
  204.  
  205.     Center()  is  used  to  adjust  a  NewWindow structure so that the
  206. window that it opens will appear immediately under the mouse.  The x,y
  207. values  are used to specify which part of the window you would like to
  208. appear  underneath  the mouse.  If x or y is zero, that tells Center()
  209. to  position  the  window  so  that  the  window center (in the x or y
  210. direction  respectively)  is  underneath  the  mouse.   If  x  or y is
  211. positive, that tells Center() to position the window so that the mouse
  212. is  that  many  pixels  from  the  left  or  top  edge  of  the window
  213. respectively.   If x or y is negative, that tells Center() to position
  214. the  window  structure so that the mouse appears that many pixels from
  215. the right or bottom edge of the window respectively (ie; x = -10 tells
  216. Center  to  position  the  mouse  ten  pixels to the left of the right
  217. edge).
  218.  
  219.     If it is impossible to position the window exactly where requested
  220. (if  the  mouse  pointer  is too close to the edge of the screen) then
  221. this  routine  will  position  the  window as close as possible to the
  222. correct location.
  223.  
  224.     To  allow  this routine to work accurately it is necessary to have
  225. already initialized the new window structure to specify on what screen
  226. the  window  is  going  to  be  open.  ie; you should set the Type and
  227. Screen fields before calling Center().
  228.  
  229.     This routine disturbs no registers.
  230.  
  231. RETURNS
  232.         nothing
  233. SEE
  234.  
  235. BUGS
  236.         None known
  237.  
  238.  
  239. ;--------------------------------------------------------------------
  240.  
  241. NAME
  242.             SetSize
  243. SYNOPSIS
  244.  
  245.             SizeVal=SetSize(MaxValue,ViewSize)
  246.               D0.W              D0.L  D1.L
  247.  
  248. short   SizeVal;
  249. long    MaxValue,ViewSize;
  250.  
  251. DESCRIPTION
  252.  
  253.     This  routine is designed to correctly handle sizing a prop gadget
  254. to  a range.  The range is given in in MaxValue/ViewSize.  MaxValue is
  255. the  maximum value that this prop is supposed to be able to represent.
  256. Viewsize  is  how  large  the  display area is.  For instance, if your
  257. maximum  value  was 200 (files, for example), and your viewsize was 15
  258. (lines of text), then you would call this as so:
  259.  
  260.         SizeVal=SetSize(200,15);
  261.  
  262.     Then you would put SizeVal into the appropriate PropInfo structure
  263. element (in the case of the file requester, that would be VertBody).
  264.  
  265. RETURNS
  266.         The  16 bit value to be put into the PropInfo structure of the
  267. prop gadget.
  268.  
  269. SEE
  270.         SetLocation, ReadLocation
  271. BUGS
  272.         Bugs? what bugs?
  273.  
  274.  
  275. ;--------------------------------------------------------------------
  276.  
  277. NAME
  278.             SetLocation
  279. SYNOPSIS
  280.  
  281. NewLoc = SetLocation(MaxValue,ViewSize,Value);
  282.   D0                    D0      D1      D2
  283.  
  284. short NewLoc;
  285. long MaxValue,ViewSize,Value;
  286.  
  287. DESCRIPTION
  288.  
  289.             When you have a prop gadget that you wish to directly set,
  290. then  this  is  the  routine to use.  It allows you to pass any 32 bit
  291. value and properly set the gadget.
  292.  
  293. RETURNS
  294.  
  295.     The  return  is  the value to put into either HorizPot or VertPot,
  296. depending on what orientation you have the gadget.
  297.  
  298.  
  299. BUGS
  300.  
  301.     n/a
  302.  
  303. EXAMPLE
  304.  
  305. SEE
  306.     SetSize(),ReadLocation()
  307.  
  308. ;--------------------------------------------------------------------
  309.  
  310. NAME
  311.             ReadLocation
  312. SYNOPSIS
  313.  
  314. LocVal=ReadLocation(MaxValue,ViewSize,PotValue)
  315.   D0                  D0.L    D1.L     D2.W
  316.  
  317. long LocVal,MaxVal,ViewSize;
  318. short PotValue;
  319.  
  320.  
  321. DESCRIPTION
  322.  
  323.         If  you  prop  gadget has been moved, this is the routine that
  324. you would use to determine where it's been moved to.
  325.  
  326. RETURNS
  327.         Returns  the decoded value of the prop, as an unsigned 32 bit.
  328. This  is  the  element  number  (line  number  usually) that should be
  329. displayed on the first line of your display window.
  330.  
  331. SEE
  332.  
  333.     SetSize(), SetLocation()
  334.  
  335. BUGS
  336.     n/a
  337.  
  338. EXAMPLE
  339.  
  340. ;--------------------------------------------------------------------
  341.  
  342. NAME
  343.             Format
  344. SYNOPSIS
  345.  
  346.         Format(Buffer,string,values)
  347.                 A2      A0     A1
  348.  
  349. char *Buffer,string[];
  350. char **values;
  351.  
  352. DESCRIPTION
  353.  
  354.         This does the same thing as sprintf(), except that it isn't in
  355. the  stdio  library, and doesn't use up very much room.  This function
  356. uses  the  ROM  function  RawDoFmt to do the print() style formatting.
  357. This  routine does not allow the use of all of the '%' directives (for
  358. example,  floating  point  numbers can not be printed with this).  For
  359. full   documentation   on  what  directives  are  supported,  see  the
  360. documentation  on RawDoFmt.  This is the routine that TextRequest (and
  361. therefore   SimpleRequest   and  TwoGadRequest)  use  for  their  text
  362. formatting, so these restrictions apply to them also.
  363.  
  364.         The RawDoFmt routine also assumes that 'int's are sixteen bits
  365. long.   Therefore,  if  you  are  using a compiler with an int size of
  366. thirty-two  bits and you want to print an int or a short, you must use
  367. '%ld', rather than '%d'.
  368.  
  369. RETURNS
  370.         The number of characters in the formatted string.
  371. BUGS
  372.     none known
  373.  
  374. EXAMPLE
  375.  
  376.     Format(Buffer,"There are %d changes to the file %s.",numchanges,
  377. filename);
  378.  
  379.     Format(Buffer,"%x is a hex number, %c is a character.", num, chr);
  380.  
  381. SEE
  382.     TextRequest, SimpleRequest, TwoGadRequest.
  383.     Further  information  on printf() style formatting is available in
  384. the AutoDocs on RawDoFmt and in C manuals discussing printf().
  385.  
  386. ;--------------------------------------------------------------------
  387.  
  388.  
  389.  
  390. NAME
  391.             ColorRequester
  392. SYNOPSIS
  393.  
  394. NewColor=ColorRequester(DesiredColor);
  395.    D0                       D0
  396. long    DesiredColor;
  397.  
  398. DESCRIPTION
  399.  
  400.     This  is a full-fledged color requester.  It is intelligent enough
  401. to open with the right number of colours in the palette automatically.
  402. It  shows  you both the colour you are working with, and the numerical
  403. RGB  value  of  that  colour.   It  has  Spread,  Undo,  Ok and Cancel
  404. functions.  Planned is the addition of HSV.
  405.  
  406.     The  cursor  keys move the color-cursor around the palette, RETURN
  407. selects the current color and ESC cancels out.
  408.  
  409.     You  pass  this  routine  the  color that you would like initially
  410. highlighted  (typically  the  current drawing colour).
  411.  
  412.     The ExtendedColorRequester function has slightly more options, but
  413. is slightly more work to call.
  414.  
  415. RETURNS
  416.  
  417.     Color  number  that  the user selected, -1 if the user cancels the
  418. colour  requester.   The  changed  colours  will  be  in  the viewport
  419. structure for your screen.
  420.  
  421. SEE
  422.     ExtendedColorRequester
  423.  
  424. BUGS
  425.  
  426.     none known.
  427.  
  428. EXAMPLE
  429.  
  430.     newcolor = ColorRequester(oldcolor);
  431.  
  432. ;--------------------------------------------------------------------
  433.  
  434. NAME
  435.             ExtendedColorRequester
  436. SYNOPSIS
  437.  
  438. NewColor=ExtendedColorRequester(&(struct ExtendedColorRequester)
  439.    D0                                      A0
  440. struct ExtendedColorRequester   colorreqstruct;
  441.  
  442. DESCRIPTION
  443.     This  call  brings  up  exactly  the  same  color requester as the
  444. ColorRequester  call.  The only difference is that this routine allows
  445. you  to  specify  more  parameters.   The difference is actually quite
  446. small  right  now, because there is only one additional parameter that
  447. can  be  passed  through  this  entry  point.   This is the ecr_window
  448. parameter,  used  to  specify  what window (and hence what screen) the
  449. color 'requester' appears on.  This parameter is rarely needed because
  450. the  window  the requester opens up on can be specified by setting the
  451. pr_WindowPtr  field  in  your process structure to the address of your
  452. window  structure  (see  the  beginning of the docs for an overview on
  453. this procedure).  The only time this entry point is needed, currently,
  454. is  if you try to bring up the color requester on a custom screen from
  455. a  task,  since  a task does not have a pr_WindowPtr and can therefore
  456. not specify the window and screen.
  457.  
  458. RETURNS
  459.  
  460.     Color  number  that  the user selected, -1 if the user cancels the
  461. colour  requester.   The  changed  colours  will  be  in  the viewport
  462. structure for your screen.
  463.  
  464. SEE
  465.     ColorRequester
  466.  
  467. BUGS
  468.  
  469.     none known.
  470.  
  471. EXAMPLE
  472.  
  473.         /* This should generally be declared as a global variable */
  474.         /* so that all of it's elements get initialized to zero.  */
  475.         /* If you declare it as a local variable, be sure to zero */
  476.         /* all of the fields, even the unused ones. */
  477.     struct ExtendedColorRequester   colorstruct;
  478.  
  479.     colorstruct.defcolor = 0;
  480.     colorstruct.window = mywindow;
  481.     newcolor = ExtendedColorRequester(&colorstruct);
  482.  
  483. ;--------------------------------------------------------------------
  484.  
  485. NAME
  486.             MakeGadget
  487. SYNOPSIS
  488. MakeGadget(Buffer,String, X, Y)
  489.               A0    A1   D0 D1
  490. struct GadgetBlock *Buffer;
  491. char               *String;
  492. long               D0,D1;
  493. DESCRIPTION
  494.  
  495.         This  routine  prepares a buffer to be a standard BOOLEAN text
  496. gadget.   This is a simple way of producing gadgets for code that must
  497. be  reentrant,  and it is more efficient than defining gadgets in data
  498. statements.    The  routine  initializes  the  gadgets  to  a  set  of
  499. 'standard' values that should cover most cases and then links the four
  500. parts of the GadgetBlock together.
  501.  
  502.     Buffer  is  a pointer to a unitialized GadgetBlock, which contains
  503. the  necessary  Gadget, Border, border pairs and IntuitText structures
  504. needed to render a boolean gadget with a border and some text.
  505.  
  506.     String  is  a  pointer  to  the text that should appear inside the
  507. gadget.   The  gadget  is  automatically  sized  to  match the strings
  508. length.
  509.  
  510.     X  and  Y are the gadgets initial position, they are simply copied
  511. into LeftEdge and TopEdge in the gadget structure.
  512.  
  513. RETURNS
  514. SEE
  515. BUGS
  516. EXAMPLE
  517.  
  518.  
  519. ;--------------------------------------------------------------------
  520.  
  521. NAME
  522.             MakeString
  523.  
  524. SYNOPSIS
  525. MakeString(Buffer,StringBuff,UndoBuff,MaxWidthBits,MaxNumChars, X, Y)
  526.              A0      A1          A2        D0          D1      D2  D3
  527.  
  528. struct StringBlock Buffer;
  529. char               *StringBuff;
  530. char               *UndoBuff;
  531. long               MaxWidthBits, MaxNumChars, X, Y;
  532.  
  533. DESCRIPTION
  534.  
  535.     As  with  all  of  the  MakeGadget  functions, this one prepares a
  536. buffer  to  be used as a string gadget, that may be used re-entrantly.
  537. The  buffer need not be cleared first.  This means that you may create
  538. a temporary gadget on the stack.
  539.  
  540.     The  StringBuff  is  where the body of text inside the gadget will
  541. reside.
  542.  
  543.     When   the   gadget  is  activated,  the  text  in  StringBuff  is
  544. automatically copied (by intuition) into UndoBuff.  This allows you to
  545. type  Amiga-Q  and get the old string back.  This field may be null if
  546. you wish to have no undo.
  547.  
  548.     MaxWidthBits is the width of the frame around the gadget.
  549.  
  550.     MaxNumChars  is  the maximum number of characters that you will be
  551. able  to  type  into the gadget, including the terminating zero on the
  552. string.  MAKE SURE that this number is no greater than your StringBuff
  553. size, or else you're going to be typing over memory that isn't yours.
  554.  
  555.     X,Y  are the position of the upper left hand corner of the gadget.
  556. The border is actually 2 pixels above and to the left of this corner.
  557.  
  558. RETURNS
  559.     Nothing
  560. SEE
  561.  
  562.     MakeGadget,MakeProp,MakeScrollbar,LinkGadget,LinkProp,LinkString
  563.  
  564.  
  565. ;--------------------------------------------------------------------
  566.  
  567. NAME
  568.             MakeProp
  569. SYNOPSIS
  570.  
  571. MakeProp(Buffer,Width,Height,Flags)
  572.          A0       D0   D1    D2
  573.  
  574. struct PropBlock *Buffer;
  575. long             Width, Height, Flags;
  576.  
  577. DESCRIPTION
  578.  
  579.     This  routine  prepares an un-initialized buffer for use as a prop
  580. gadget.
  581.  
  582.     Buffer,  on  return,  will  contain  the  gadget,  along  with the
  583. necessary PropInfo and Image structures, all linked together.
  584.  
  585.     Width is the with of the container, in pixels.
  586.     Height is the height of the container in pixels.
  587.  
  588.     The  Flags parameter is simply copied into the gadget flags field.
  589. It  should  contain  the  Intuition  flags that you would normally put
  590. there  yourself.   Optionally,  you can initialize this field yourself
  591. afterwards.
  592.  
  593.  
  594. EXAMPLE
  595.  
  596.     propbuffer = (struct PropBlock *)AllocMem((long)sizeof(struct
  597.                         PropBlock), (long)MEMF_PUBLIC);
  598.     MakeProp(propbuffer, 20L, 150L, (long)GADGHCOMP);
  599.  
  600.  
  601. RETURNS
  602.  
  603.     Nothing
  604.  
  605.  
  606. ;--------------------------------------------------------------------
  607.  
  608. NAME
  609.             DrawBox
  610. SYNOPSIS
  611.  
  612. DrawBox(rp,MinX,MinY,MaxX,MaxY)
  613.         A1  D0   D1   D2   D3
  614.  
  615. struct  RastPort        *rp;
  616. long    MinX,MinY,MaxX,MaxY;
  617.  
  618.  
  619. DESCRIPTION
  620.  
  621.         This  routine  allows you to draw a simple box in one command.
  622. It  draws  the  box  in APen color, in the current draw mode, with the
  623. current line pattern.
  624.  
  625.         (MinX,MinY)  are  the  upper  left  corner  of  the  box,  and
  626. (MaxX,MaxY) are the lower right.
  627.  
  628.         The pen is left at the upper left corner (MinX,MinY).
  629.  
  630. ;--------------------------------------------------------------------
  631.  
  632. NAME
  633.             MakeButton
  634. SYNOPSIS
  635.  
  636. MakeButton(Buffer,Image,Image2,Width,Height,Depth)
  637.              A0     A1    A2     D0    D1    D2
  638.  
  639.  
  640. struct  TwoImageGadget  *Buffer;
  641. char    *Image;     /* Pointer to the actual bitplane data */
  642. char    *Image2;    /* Pointer to the second image. */
  643. long    Width,Height,Depth;
  644.  
  645.  
  646.  
  647.  
  648. DESCRIPTION
  649.  
  650.     The  purpose  of  this  routine  is one similar to MakeGadget, but
  651. instead of using text for the button, it uses a graphic.  You supply a
  652. bitmap, and MakeButton will use it in it's rendering.
  653.  
  654.     You  may  have  either  one  or two images, the routine handles it
  655. routinely.   If you supply one image, then this sets GADGHCOMP, and if
  656. you  have two images, it sets GADGHIMAGE.  RELVERIFY is always set, so
  657. as  long  as  you  the  user  is  pressing  that gadget, the alternate
  658. highlight is shown.
  659.  
  660.     Buffer has room for two images.
  661.  
  662.     Image  is  a pointer to the actual image data, in CHIP memory, for
  663. this gadget.
  664.     Image2 is a pointer to the alternate image data.
  665.  
  666.     Width and Height make up the size of your image.
  667.  
  668.     Depth is how many bitplanes of data you've supplied.
  669.  
  670. EXAMPLE
  671.  
  672.     MakeButton(buffer, image1, image2, 32L, 40L, 2L);
  673.  
  674. BUGS
  675.     It's  not  really  a bug, but if your images aren't the same size,
  676. then one won't erase the other when it is drawn, so you may be showing
  677. an image with traces of the other one left there.
  678.  
  679. ;--------------------------------------------------------------------
  680.  
  681. NAME
  682.             MakeScrollBar
  683. SYNOPSIS
  684.  
  685. MakeScrollBar(Buffer,Flags,Size,X,Y)
  686.                 A0    D0    D1 D2 D3
  687.  
  688. struct ScrollBlock *Buffer;
  689. long    Flags,Size,X,Y;
  690.  
  691.  
  692. DESCRIPTION
  693.  
  694.     This is a special routine that creates a scrollbar (which consists
  695. of  a prop gadget and two arrows) and you handle it like it's a single
  696. gadget.   You  may  have  either a horizontal scrollbar, or a vertical
  697. scrollbar.   These scrollbars are very much like the ones in workbench
  698. window  borders.   These  use slightly different images on the arrows,
  699. however.
  700.  
  701.     The  way  you  specify  how this is set up and oriented is by flag
  702. combinations.   If  you wished to put a scrollbar in the bottom border
  703. of a window, then you would pass (in flags):
  704.  
  705.         Flags = (HORIZSLIDER | GRELBOTTOM | GRELWIDTH)
  706.  
  707.     If you wished it in the right border:
  708.  
  709.         Flags = (VERTSLIDER | GRELRIGHT | GRELHEIGHT)
  710.  
  711.     The  idea is to allow you to manipulate the scrollbar as though it
  712. were  a  single  gadget, not three.  If you pass confusing flags (like
  713. GRELBOTTOM|GRELHEIGHT)  then  it  is  undefined what will happen.  The
  714. GRELRIGHT  and  GRELHEIGHT  flags tell Intuition (once they are put in
  715. the  flag  fields of the gadgets) that the gadgets should be placed in
  716. the  right  window  border and that the prop gadget should size itself
  717. vertically  as  the  window  sizes.   Similarly,  the  GRELBOTTOM  and
  718. GRELWIDTH  flags  tell  Intuition  to  put the gadgets into the bottom
  719. window  border  and  size  the  prop gadget horizontally as the window
  720. sizes.   See  the  Intuition  manual for further details on those four
  721. flags.   The  HORIZSLIDER  and  VERTSLIDER flags are req.library flags
  722. that  specify  the  orientation  of  the scroll bar.  The GRELRIGHT or
  723. GRELBOTTOM  flags  are  put into all of the gadget's flag fields.  The
  724. GRELWIDTH  and  GRELHEIGHT  flags  are put into the prop gadget's flag
  725. fields.   The  VERTSLIDER  and  HORIZSLIDER  flags,  because  they are
  726. private to req.library, are not put into any gadget's flag field.
  727.  
  728.     The  Size  parameter  specifies  either the height or width of the
  729. prop gadget, including the arrow gadgets.  Whether it is the height of
  730. width  depends  on whether you specify VERTSLIDER (in which case it is
  731. height) or HORIZSLIDER.
  732.  
  733.     The  X  and  Y  parameters  specify  the location of the top arrow
  734. gadget  or  the  left arrow gadget, depending on whether the gadget is
  735. vertical or horizontal.
  736.  
  737.     If all you want is a simple scrollbar that doesn't size, then just
  738. set VERTSLIDER or HORIZSLIDER.
  739.  
  740. EXAMPLE
  741.  
  742.         /* Make a scroll bar (with arrows) that goes in the bottom */
  743.         /* window border and sizes itself as the window sizes. Make */
  744.         /* it 150 pixels wide in total and position it ten from */
  745.         /* the left edge and 100 from the top of the window. */
  746.  
  747.     MakeScrollBar(sbbuffer, (long)(HORIZSLIDER | GRELBOTTOM | GRELWIDTH),
  748.                         150L, 10L, 100L);
  749.  
  750. SEE MakePropGadget
  751.  
  752.  
  753. ;--------------------------------------------------------------------
  754.  
  755. NAME
  756.             PurgeFiles
  757. SYNOPSIS
  758.     PurgeFiles(&FileReqStructure)
  759.                       A0
  760. DESCRIPTION
  761.     Clear  up  all  memory  and  file  locks  allocated  by  the  file
  762. requester.   This  routine must be called before your program exits if
  763. you  use  the  file requester with either FRQEXTSELECTM bit set or the
  764. FRQCACHINGM bit set.  The first bit is if you want the user to be able
  765. to select multiple files.  The file requester has to allocate a linked
  766. list  of  file  names which this function will purge.  The FRQCACHINGM
  767. bit  is set if you want the file requester to remember the contents of
  768. a directory between calls.
  769.  
  770.     This  routine can be called any time you want the buffers and file
  771. locks purged.
  772.  
  773. RETURNS
  774.     This routine does not return anything.
  775.  
  776. SEE
  777.     FileRequester
  778. BUGS
  779.     None known.
  780. EXAMPLE
  781.  
  782. main()
  783.     {
  784.     FileRequester(&FileReqStructure);
  785.  
  786.     .
  787.     .
  788.     .
  789.  
  790.     PurgeFiles(&FileReqStructure);
  791.     }
  792.  
  793.  
  794.  
  795. ;--------------------------------------------------------------------
  796.  
  797. NAME
  798.             GetFontHeightAndWidth
  799. SYNOPSIS
  800.  
  801. DESCRIPTION
  802.  
  803.         This allows you quick access to the font attributes set by the
  804. user  in preferences.  The font width is returned in D0 and the height
  805. is returned in D1.
  806.  
  807. RETURNS
  808. SEE
  809. BUGS
  810. EXAMPLE
  811.  
  812.  
  813.  
  814. ;--------------------------------------------------------------------
  815.  
  816. NAME
  817.             LinkGadget
  818. SYNOPSIS
  819.  
  820. LinkGadget(Buffer,String,nw, X, Y)
  821.              A0     A1   A3 D0 D1
  822.  
  823. struct  GadgetBlock *Buffer;
  824. char    *String;
  825. struct  NewWindow *nw;
  826. long    X,Y;
  827.  
  828. DESCRIPTION
  829.  
  830.     This  is  actually  a superset of the previous command MakeGadget.
  831. What  this  does  is automatically link the gadget into your NewWindow
  832. structure's gadget list.
  833.  
  834.         No registers are disturbed.
  835.  
  836. SEE
  837.     MakeGadget
  838. BUGS
  839.     n/a
  840.  
  841.  
  842.  
  843. ;--------------------------------------------------------------------
  844.  
  845. NAME
  846.             LinkStringGadget
  847. SYNOPSIS
  848. LinkStringGadget(Buffer,StringBuf,UndoBuf,nw, WidthBits,NumChars, X, Y)
  849.                    A0     A1        A2    A3     D0       D1     D2 D3
  850.  
  851. struct  StringBlock *Buffer;
  852. char    *StringBuf;
  853. char    *UndoBuf;
  854. struct  NewWindow *nw;
  855. long    WidthBits,NumChars,X,Y;
  856.  
  857. DESCRIPTION
  858.  
  859.     This  is  number 2 in the LinkGadget routines.  This one obviously
  860. links  the  string  gadget  to the window's gadget list.  In fact, the
  861. only  difference  between  this  and  the  MakeString  routine  is the
  862. addition of the NewWindow pointer.
  863.  
  864. SEE
  865.     MakeStringGadget
  866.  
  867.  
  868. ;--------------------------------------------------------------------
  869.  
  870. NAME
  871.             LinkPropGadget
  872. SYNOPSIS
  873.  
  874. LinkPropGadget(Buffer,nw, Width, Height, Flags, LeftEdge, TopEdge)
  875.                  A0   A3    D0     D1     D2       D3       D4
  876.  
  877. struct  PropBlock   *Buffer;
  878. struct  NewWindow   *nw
  879. long    Width,Height,Flags,LeftEdge,TopEdge;
  880.  
  881. DESCRIPTION
  882.  
  883.     Here  we  have a superset for MakeProp.  It works exactly the same
  884. as  MakeProp,  except  that  it attaches the gadget to the head of the
  885. list in the window.
  886.  
  887. SEE
  888.     MakeProp
  889.  
  890.  
  891. ;--------------------------------------------------------------------
  892.  
  893. FileRequester
  894.  
  895. NAME
  896.     FileRequester  - bring up a file/font requester.
  897.  
  898. SYNOPSIS
  899.     success = FileRequester(&FileReqStructure)
  900.       D0                           A0
  901.  
  902. FUNCTION
  903.     Bring  up  a  fully  intuitionized file/font requester (actually a
  904. window) and let the user select a file/font.
  905.  
  906. INPUTS
  907.     &FileReqStructure  - pointer to an initialized (can be initialized
  908. mostly to zeroes) file requester structure.
  909.  
  910. RESULT
  911.     Returns  TRUE  or FALSE to say whether the user selected a file or
  912. not.   The  file name(s) or font selected are then found by looking at
  913. the file requester structure whose address was passed.
  914.  
  915.     For  ideas  on  customizing the file requester for your particular
  916. system  (thus  overriding the defaults used by programmers who use the
  917. file requester) see the customizefile.asm file.
  918.  
  919. BUGS
  920.     Problem  with  an  Intuition bug that messes up the current active
  921. window  if  a  window  closes  when one of its string gadgets is still
  922. active.   This bug show up if you run the file requester straight from
  923. a CLI window and then exit it with Amiga-L.
  924.     I have heard that it resets some window flags when run on a custom
  925. screen,  but I believe this is a feature of Intuition, not of the file
  926. requester.
  927.  
  928. SEE ALSO
  929.     PurgeFiles
  930.  
  931.  
  932.     The  file  requester  in  the  requester  library  allows to put a
  933. powerful  and  easy  to  use  file requester into your programs with a
  934. minimum of work and at a very small expense in program size.  The file
  935. requester  was  designed  to be as easy as possible to call, while not
  936. sacrificing power.
  937.  
  938.     To  get  the  file  requester to come up all you need to do (after
  939. opening  the  requester  library of course) is to allocate space for a
  940. FileReq structure and then call the file requester with the address of
  941. this structure, with all fields initialized to zero, like this:
  942.  
  943. struct FileReq MyFileReqStruct;
  944.  
  945. success = FileRequester(&MyFileReqStruct);
  946.  
  947.     The function will return either one or zero for success or failure
  948. respectively.
  949.  
  950.     You can specify what screen the file requester should appear on in
  951. one  of  two  ways.  If you want it to appear on a custom screen, then
  952. the  best  way  is  to  set  the  pr_WindowPtr  field  in your process
  953. structure  to  point at one of the windows on your screen (this should
  954. be  done anyway, so that DOS requesters appear on your custom screen).
  955. This  field  is looked at by all functions in the requester library so
  956. this  way  is the simplest method.  The other way, which overrides the
  957. pr_WindowPtr  field  is to initialize the frq_Window field to point at
  958. one of your windows.  If this field is non-zero, it is used instead of
  959. the pr_WindowPtr field of your process structure.  Important note:  It
  960. is  VERY  important  that you reset the pr_WindowPtr field back to its
  961. original  value  before  your  program  exits.  If you don't, the next
  962. program run may try to open a requester window on a now closed screen.
  963.  
  964.     The  file  requester  was  carefully  designed so that it could be
  965. called  without  having  to  initialize  very  many  fields.   This is
  966. demonstrated  by  seeing  that  it  is  possible  to  call  it without
  967. initializing any fields.  There are a few fields that are necessary to
  968. actually  get  any  use  out  of  it,  but  very  view.  Those few are
  969. documented in the following paragraph.
  970.  
  971.     Although  you can bring the file requester up without initializing
  972. any  fields there are a couple of fields that you will definitely want
  973. to  initialize.   The  file  requester isn't much use unless you get a
  974. file  name back out of it, and for this you need to initialize the Dir
  975. and  File  fields.   These two fields should point to character arrays
  976. that are, respectively, REQ_DSIZE+1 and REQ_FCHARS+1 bytes long.  When
  977. the  file  requester  is  first  run the file requester looks in these
  978. arrays  for  the  default  directory  and  file  names and if the user
  979. selects  a  file name the directory and file name are copied back into
  980. these  arrays.   You  will probably want to initialize the Title field
  981. with  the  message that you want to have appear at the top of the file
  982. requester window.
  983.  
  984.     If  you initialize the PathName field (it should point an array of
  985. at least REQ_DSIZE+REQ_FCHARS+2 characters) then when the user selects
  986. a file, the complete path name will be put into this array.
  987.  
  988.     The Window field is used to specify what window the file requester
  989. is associated with.  This is used to get the file requester to show up
  990. on  a  custom  screen.   Generally  this  field should be unnecessary.
  991. There  is a variable provided in a process structure which is used for
  992. this purpose.  Any program that opens a custom screen and uses any DOS
  993. functions  should set the pr_Window pointer in their process structure
  994. to  a  pointer  to their window so that DOS requesters will show up on
  995. their  custom  screen.   If  you do this, then the file requester will
  996. also  show  up  on  your custom screen.  If you are not using a custom
  997. screen  then you don't need to set the pr_Window pointer or the Window
  998. field  in  the  file  requester  structure.   Note:  If you do set the
  999. pr_Window  structure in the process structure, be sure to return it to
  1000. its old value before your program exits.
  1001.  
  1002.     If  the  extended  select  bit  is set in the Flags field then the
  1003. MaxExtendedSelect  fields  specifies  the maximum number of files that
  1004. the user can select.  This is ignored if the extended bit isn't set in
  1005. the Flags field.
  1006.  
  1007.     numlines and numcolumns specify the maximum size that the file box
  1008. will  be in characters.  If the system is low on memory, or the screen
  1009. is  too  small,  these will be shrunk as necessary.  devcolumns is the
  1010. number of columns of characters wide that the device box will be.
  1011.  
  1012.     The  Flags field can currently contain seven different flags.  The
  1013. first  flag,  FRQSHOWINFOM,  specifies  whether  or not '*.info' files
  1014. (files  containing information for icons) should be filtered out.  The
  1015. default is for them to be filtered.
  1016.  
  1017.     The  FRQEXTSELECTM  flags  specifies  whether  extended  select is
  1018. wanted.   If  you  set this flag then you should probably also set the
  1019. MaxExtendedSelect  field.   If  you  don't  then the maximum number of
  1020. files  the  user  will be able to select will be 65536, which is a bit
  1021. high  for  most  purposes.  Note:  If you use this bit then you _must_
  1022. call PurgeFiles() with the address of your FileReq structure after the
  1023. last  time you call the file requester, in order to free up any memory
  1024. used  in  the  extended  select  structures.   When  the  user selects
  1025. multiple  files,  a  linked  list  of  the  file  names  selected (not
  1026. including the directory name) will appear in the ExtendedSelect field.
  1027. The  list  is a linked list of ESStructures.  The directory name which
  1028. should  be  prepended  to  all of these names will appear in the array
  1029. pointed to by the Dir field.
  1030.  
  1031.     The  FRQCACHINGM  flag  specifies  whether  or not directories are
  1032. cached  from  one  call  to  the next.  This is a very handy features,
  1033. especially  for those who lack hard drives.  However, if this features
  1034. is  used, you _must_ call the PurgeFiles() routine with the address of
  1035. your  FileReq  structure  after  the  last  time  you  call  the  file
  1036. requester, in order to free up any memory used in caching.
  1037.  
  1038.     As  well  as being a file requester, this routine can be used as a
  1039. font requester too.  Just set the FRQGETFONTSM flags to turn it into a
  1040. font  requester.   You  should  also  put the name 'fonts:' in the Dir
  1041. array.   The file/font requester will return a one or zero for success
  1042. or  failure as usual, the font name will be returned in the File array
  1043. and  the  font  size  and  style will be returned in the FontYSize and
  1044. FontStyle  fields.   Note  that  the font requester allows the user to
  1045. change  the  directory  where  the  fonts are read from.  Although you
  1046. should  put  'fonts:' there, you should allow for the possibility that
  1047. the  user  might  change  the  directory.  They might, perhaps, have a
  1048. separate  disk  full  of  fonts.   The simplest way to deal with fonts
  1049. coming  from  different  directories,  is  to  set  the PathName field
  1050. instead of the Dir field.  You can then use the string in the PathName
  1051. field  (which  will  contain  the directory and font name) as the font
  1052. name.   If  you  don't  do this, then you have to concatenate the font
  1053. name  and  the  directory  name  yourself.   If  you  use the PathName
  1054. variable  then  it  is quite reasonable to leave the File field blank,
  1055. since  all  the information you need can be obtained from the PathName
  1056. string.
  1057.  
  1058.     The  FRQINFOGADGETM flag specifies whether or not a hide/show info
  1059. gadget should appear on the file requester.  This lets the user toggle
  1060. the  state  of  the  FRQSHOWINFOM flag to decide whether or not to let
  1061. '*.info'  files  show  up.  This is not recommended for most programs,
  1062. since  most  users  have  no  reason  to  look at '*.info' files.  The
  1063. default is to _not_ have this gadget show up.
  1064.  
  1065.     The FRQHIDEWILDSM flag specifies whether or not to have 'show' and
  1066. 'hide'  string  gadgets.   These gadgets let the user use wildcards to
  1067. specify  which  files  should  show  up.  All files are first compared
  1068. against  the 'show' gadget.  If they fail the comparison, they are not
  1069. displayed.  Then they are compared against the 'hide' gadget.  If they
  1070. match  here then they are not displayed.  If the gadgets are empty, no
  1071. comparisons  are done.  Important note:  Even if these gadgets are not
  1072. displayed,  the comparisons are still done on the data which is in the
  1073. Hide  and  Show  fields of the file requester structure.  The standard
  1074. AmigaDOS wildcards (including '#', '?', '|' and '*') are supported.
  1075.  
  1076.     Normally  the  file  requester  appears  centered  under the mouse
  1077. pointer.   If  you would like to specify its opening position you must
  1078. set   the   ABSOLUTEXYM   flag  and  then  put  the  x,y  position  in
  1079. WindowLeftEdge and WindowTopEdge.
  1080.  
  1081.     If you feel that the file requester's cached directories (selected
  1082. by  FRQCACHINGM)  should  be  purged  whenever  the directory has been
  1083. changed,  then  set  FRQCACHEPURGEM  field and the file requester will
  1084. check the dates whenever it is opened.
  1085.  
  1086.     If you feel that the file requester should never cache directories
  1087. unless  it  manages  to  read  in the entire directory before the user
  1088. sends  it  away,  then  set  the FRQNOHALFCACHEM flag.  This flag will
  1089. cause  the file requester to automatically flush any incompletely read
  1090. directories when it exits.
  1091.  
  1092.     If  you  would  like your directories to appear in 'natural' order
  1093. instead of alphabetically sorted, set the FRQNOSORTM flag.
  1094.  
  1095.     If  you would like the file requester to appear without a drag bar
  1096. or depth arrangement gadgets, set the FRQNODRAGM flag.
  1097.  
  1098.     If  you  are using the file requester to select a filename to save
  1099. to,  you  should set the FRQSAVINGM flag.  Similarly, if you are using
  1100. the  file  requester to select a filename to load from, you should set
  1101. the  FRQLOADINGM flag.  These flags are not currently used by the file
  1102. requester,  but  they  may  be  used in the future.  They also make it
  1103. easier  for  people who want to personalize the file requester to make
  1104. it behave differently for loading vs.  saving.
  1105.  
  1106.     If  you  want  the user to select a drawer name rather than a file
  1107. name,  set  the  FRQDIRONLYM  flag.   The file requester will then not
  1108. display  some gadgets and will display only drawers, not files, in the
  1109. file window.  The path name selected will be returned in the Dir field
  1110. and  in  the  PathName  field if supplied.  When in this mode, hitting
  1111. return on the drawer gadget causes the file requester to exit with the
  1112. directory currently in the gadget.  Hitting SHIFT or ALT return causes
  1113. the  file  requester  to  read the specified directory and display all
  1114. directories in there.
  1115.  
  1116.  
  1117.     The  various  color  fields  let  you  specify  the colors of many
  1118. aspects of the file requester.  If they are left as zero then the file
  1119. requester uses various non-zero certain default values for them.
  1120.  
  1121.     The  WindowLeftEdge  and  WindowTopEdge  fields are covered in the
  1122. section on the ABSOLUTEXYM flag.
  1123.  
  1124.     The  FontYSize  and FontStyle fields are covered in the section on
  1125. the FRQGETFONTSM flag.
  1126.  
  1127.     The  ExtendedSelect  field  is  covered  in  the  section  on  the
  1128. FRQEXTSELECTM flag.
  1129.  
  1130.     The  Hide  and  Show  fields  are  covered  in  the section on the
  1131. FRQHIDEWILDSM flag.
  1132.  
  1133.     The  four  BufferPos  and  DispPos  variables  are  copies  of the
  1134. equivalent  variables  from  the four string gadgets.  This is so that
  1135. when  the  file  requester goes away and then is brought up again, the
  1136. cursor in the string gadgets will appear in the same places as before.
  1137. These fields should not need to be touched by the programmer.
  1138.  
  1139.     The  rest  of the fields are private.  Don't go touching them.  We
  1140. guarantee  to  move them around and change their meaning, just to make
  1141. sure  that  nobody tries to use them.  They are largely concerned with
  1142. keeping  track  of  memory  used in directory caching.  This memory is
  1143. freed  with  the  PurgeFiles() routine.  That's all you should need to
  1144. know.
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150. ;--------------------------------------------------------------------
  1151.  
  1152. RealTimeScroll
  1153.  
  1154. NAME
  1155.     RealTimeScroll  -  do the calculations necessary for a responsive,
  1156. pixel resolution, real time scroll routine.
  1157.  
  1158. SYNOPSIS
  1159.     RealTimeScroll(&ScrollStruct);
  1160.                          A0
  1161.  
  1162. FUNCTION
  1163.     Make  the  implementation  of  real time scrolling area easier and
  1164. make the real time scrolling area more responsive to the user by doing
  1165. pixel resolution scrolling and by checking the current position of the
  1166. scroll  bar  in mid scroll.  This routine calculates how far to scroll
  1167. each  time  and calculates which lines of text, graphics etc.  need to
  1168. be redrawn to fill in the empty area.
  1169.  
  1170. INPUTS
  1171.     &ScrollStruct - pointer to an initialized scroll structure.
  1172.  
  1173. RESULT
  1174.     This routine returns no result code.
  1175.  
  1176. BUGS
  1177.     None known
  1178.  
  1179. SEE ALSO
  1180.     n/a
  1181.  
  1182.  
  1183.     It is relatively easy to implement a real time scrolling area, but
  1184. the most obvious implementations suffer from a lack of responsiveness.
  1185. Typically  the  routines  look  at  where the scroll bar is, calculate
  1186. where  to  scroll  to,  scroll  there  in  several  jumps  to make the
  1187. scrolling  look smooth, and the examine the scroll bar again to see if
  1188. it  has  moved.  This means that there are periods, perhaps annoyingly
  1189. long,  where  the  program may be scrolling in one direction while the
  1190. scroll  bar is being dragged in another.  The answer is to examine the
  1191. scroll  bar  to  find out the desired location, scroll partway towards
  1192. the  destination and then recheck the scroll bar's location.  This can
  1193. greatly  increase  the  responsiveness,  since the program is checking
  1194. after  every  ScrollRaster()  call,  instead of after a dozen or more.
  1195. However,  the  calculations,  especially  of  which  lines  need to be
  1196. refreshed  and  where, get somewhat more complicated.  This routine is
  1197. designed  to  simplify this situation by taking care of as many of the
  1198. messy details as possible.
  1199.  
  1200.     First   you   must   initialize   the   scroll   structure.    The
  1201. TopEntryNumber, NumEntries and NumLines fields describe where the data
  1202. is  currently.   NumEntries  is  the number of lines of data in total,
  1203. NumLines  is  the number of lines that are visible, and TopEntryNumber
  1204. is the line number of the first line visible (it therefore ranges from
  1205. zero to NumEntries - 1).
  1206.  
  1207.     LineSpacing  is  the  number of pixels high that each line of data
  1208. is.   For  text  this  will  typically be eight or nine (for eighty or
  1209. sixty  column  topaz).   This  can  be  set  to  one  if  your data is
  1210. continuous (as in the case of some graphics).
  1211.  
  1212.     PropGadget  is a pointer to the prop gadget which is being used to
  1213. control this scroll area.
  1214.  
  1215.     RedrawAll  is  a  pointer  to  a  function that you must supply to
  1216. redraw the entire visible window.  This routine is called whenever the
  1217. user  gets  so far ahead of the scroll routine that scrolling to where
  1218. the  users  wants  to  be  would  take  to  long.  Before calling this
  1219. routine,  the  ScrollStruct that was passed to this routine is updated
  1220. with  the  desired TopEntryNumber so that your routine will know which
  1221. data to redraw.
  1222.  
  1223.     ReadMore is an optional routine that will usually not be used.  It
  1224. is  used  if more data is being added while the scrolling is going on.
  1225. This  is  used,  for  instance,  by the FileRequester in the requester
  1226. library, to continue attempting to read the directoy while the user is
  1227. scrolling.   Leave  this set to zero if you don't need it.  It is only
  1228. called  when no scrolling is being done, but the user has not released
  1229. the scroll bar.
  1230.  
  1231.     ScrollAndDraw  is the most important routine.  This routine, which
  1232. you  must  supply,  is called whenever the data must be scrolled.  The
  1233. actual  scrolling  and  redrawing of the data is done by this routine,
  1234. but because the scroll amount, the lines to be drawn and the number of
  1235. lines  to  be  drawn are passed to this routine, the routine is fairly
  1236. simple.  Four parameters are passed to this routine:
  1237.  
  1238. ScrollAndDraw(firstlinenum, firstliney, scrollamount, numlines);
  1239.  
  1240.     All  four parameters are passed as longs, both on the stack and in
  1241. D0-D3,  so  that  the  routine  can  easily  be written in either C or
  1242. assembler.
  1243.  
  1244.     When the ScrollAndDraw, ReadMore or RedrawAll routines are called,
  1245. A4,  A5  and  A6  all  contain  the  same  values  they contained when
  1246. RealTimeScroll  was  called.   This allows programs written in C using
  1247. the  small  data  model  to be able to access their data properly from
  1248. these  routines without any special work.  All other registers (except
  1249. those that are used to pass parameters in) could contain anything.
  1250.  
  1251.  
  1252.  
  1253.  
  1254. ;--------------------------------------------------------------------
  1255.  
  1256.  
  1257.  
  1258. TextRequest
  1259.  
  1260. NAME
  1261.     TextRequest  - bring up a text requester with one to three gadgets
  1262. and get a response.
  1263.  
  1264. SYNOPSIS
  1265.     result = TextRequest(&TRStructure);
  1266.       D0                      A0
  1267.  
  1268. FUNCTION
  1269.     Bring  up  a requester (actually a window) containing a message to
  1270. the  user  and  give  him  a  choice  of  from  one to three different
  1271. responses.   The  window  automatically  sizes  to  fit  the  text and
  1272. printf() style formatting can be used by TextRequest() to generate the
  1273. message to the user.
  1274.  
  1275. INPUTS
  1276.     &TRStructure - pointer to an initialized text requester structure.
  1277.  
  1278. RESULT
  1279.     Returns  either  zero,  one  or two, depending on which gadget the
  1280. user  clicks  on.   All  of  the  gadgets  are  optional,  so that the
  1281. requester  can  be  used  to  bring up requesters that give the user a
  1282. message,  without demanding an answer, by having only a single gadget.
  1283. The  gadget  in  the  lower  right  hand  corner (the negative gadget)
  1284. returns a zero, the gadget in the lower left hand corner (the positive
  1285. gadget)  returns a one and the gadget in the middle returns a two.  If
  1286. none  of these three gadgets are requested, a close gadget is attached
  1287. to the window and it returns a zero.
  1288.  
  1289. BUGS
  1290.     If  any  line  of  the  text  to  be printed is too long, then the
  1291. requester  will  attempt  to open up an impossibly large window, which
  1292. will fail and the requester will return a zero.
  1293.     The  buffer used for formatting the text is 5000 bytes long, so no
  1294. messages can be longer than this.
  1295.  
  1296. SEE ALSO
  1297.     SimpleRequest
  1298.     TwoGadRequest
  1299.  
  1300.  
  1301.     The  purpose  of  this  routine  is  to  make  it as easy to print
  1302. formatted  messages  in  intuitionized window with gadgets as it is to
  1303. print  them  on the CLI screen.  For maximum ease of use, at a loss of
  1304. flexibility,  please see the functions SimpleRequest and TwoGadRequest
  1305. which  are  simply  glue  code functions to make calling TextRequest a
  1306. trivial matter.
  1307.  
  1308.     If  you want the text requester to appear on a custom screen, then
  1309. you must set the pr_WindowPtr field in your process structure to point
  1310. at  one  of the windows on your screen (this should be done anyway, so
  1311. that  DOS  requesters  appear  on  your custom screen).  This field is
  1312. looked at by all functions in the requester library so this way is the
  1313. simplest method.  Important note:  It is VERY important that you reset
  1314. the  pr_WindowPtr field back to its original value before your program
  1315. exits.  If you don't, the next program run may try to open a requester
  1316. window on a now closed screen.
  1317.  
  1318.     The  structure  whose  address  is  passed to this routine must be
  1319. initialized first.
  1320.  
  1321.     The  Text field is initialized with the body of the text you would
  1322. like  displayed.  This text can contain both printf() style formatting
  1323. and  end  of  line characters ('\n' in C, ascii 10 in assembler).  The
  1324. printf()  style formatting, is expanded out into the final text string
  1325. using  the  parameter  list which is pointed to by the Controls field.
  1326. Line  feeds  are  used, as usual, to specify a new line, thus allowing
  1327. very  long  and  complex  messages  to  be  displayed.   The  are some
  1328. limitations  on  the  types  of  printf() formatting that can be used.
  1329. Since the RawDoFmt() function of the ROM is used to do the formatting,
  1330. only   functions   supported   by   it  can  be  used.   For  complete
  1331. documentation,  see  the documentation of the RawDoFmt() command.  The
  1332. main  things  to be aware of is that floating point numbers can not be
  1333. printed,  and,  if  you  are using a compiler that uses thirty-two bit
  1334. ints  then  we  will  have to specify '%ld' to print an int, since the
  1335. RawDoFmt command assumes an int size of sixteen bits.
  1336.  
  1337.     The Controls field points to a list of parameters, one for each of
  1338. the  '%'  parameters in the Text field.  Normally these will be pushed
  1339. on  to the stack and the stack pointer copied into the Controls field.
  1340. The first parameter used (the first one to occur in the string) should
  1341. be  at  the beginning of the list, that is, at the lowest address, the
  1342. one pointed at by the Controls parameter.
  1343.  
  1344.     The Window field can be used to specify what screen you would like
  1345. the requester to appear on.  This field is usually not necessary since
  1346. the same information can be conveyed in the pr_WindowPtr field of your
  1347. process  structure.   However  this  field  was  left  in  so that the
  1348. TextRequest  function  could  be  called  from  a  task (which lacks a
  1349. process  structure and therefore a pr_WindowPtr field).  If this field
  1350. is  non-zero or if the calling program is a task then this field takes
  1351. precedence over the pr_WindowPtr field.
  1352.  
  1353.     MiddleText,  PositiveText  and NegativeText are the pieces of text
  1354. used  for  the  three gadgets.  These three gadgets, when present, are
  1355. placed   in  the  middle,  the  left  and  the  right  of  the  window
  1356. respectively.   All  three  gadgets are placed along the bottom of the
  1357. window.   All of the gadgets are optional.  If a gadget is not wanted,
  1358. the  text  pointer  should be set to zero.  The values returned if the
  1359. user  clicks  on these gadgets are two, one or zero, respectively.  If
  1360. none  of  the gadgets are present (if all of the text fields are zero)
  1361. then  a  standard  CLOSEWINDOW gadget is attached to the window.  This
  1362. gadget returns a zero.
  1363.  
  1364.     The  requester  attempt  to  appear so that the negative gadget is
  1365. underneath  the  mouse pointer.  If the negative gadget is not present
  1366. it will attempt to appear so that a different gadget is underneath the
  1367. mouse  pointer.   This is to make it as convenient as possible for the
  1368. user  to  respond  to,  and  especially  to respond negatively to, the
  1369. requester.
  1370.  
  1371.     In  addition  to  responding  to  the  requester  with  the mouse,
  1372. keyboard  shortcuts are available.  The user can type ESC, 'N', 'Q' or
  1373. 'B'  as  a  shortcut to clicking on the negative gadget.  The user can
  1374. type  'Y'  or 'V' as a shortcut to clicking on the positive gadget and
  1375. can type 'M' as a shortcut to clicking on the middle gadget.
  1376.  
  1377.     The  Title  field  of  the structure should either point to a null
  1378. terminated  string  to  be  used in the windows title bar or should be
  1379. null.
  1380.  
  1381.     The  KeyMask  field  is  used  to  regulate  the  use  of keyboard
  1382. shortcuts.  The qualifier field of all keyboard messages is ANDed with
  1383. this  field,  and  the  keypress  is  ignored  if  the result is zero.
  1384. Therefore,  to enable all keypresses to be used as keyboard shortcuts,
  1385. initialize  this  field to $FFFF.  To turn off the keyboard shortcuts,
  1386. initialize  this  field to 0.  To force the user to hold down the left
  1387. or right amiga key, initialize this field to AMIGAKEYS.
  1388.  
  1389.     The  textcolor,  detailcolor  and  blockcolor  fields  can be left
  1390. unitialized (ie; set to zero) if you wish, in which case the requester
  1391. will  use  the  default values of one, zero and one respectively.  The
  1392. textcolor  field  is used for the color of the actual text message and
  1393. the detail and block color fields are simple copied into the fields of
  1394. the same name in the new window structure.
  1395.  
  1396. ;--------------------------------------------------------------------
  1397.  
  1398.  
  1399. SimpleRequest
  1400.  
  1401. NAME
  1402.     SimpleRequest - bring up a text requester and wait for the user to
  1403. acknowledge it.
  1404.  
  1405. SYNPOSIS
  1406.     SimpleRequest(title, string, parameterlist, , ,)
  1407.                     A0     A1         A2
  1408.  
  1409. FUNCTION
  1410.     Bring  up  a requester (actually a window) containing a message to
  1411. the  user  and  wait  for  the  user  to  acknowledge  it.  The window
  1412. automatically  sizes to fit the text and printf() style formatting can
  1413. be used by TextRequest() to generate the message to the user.
  1414.  
  1415. INPUTS
  1416.     title  -  a  null  terminated  string.   The  window  title of the
  1417. requester.
  1418.     string  -  a  null  terminated  string,  containing printf() style
  1419. formatting commands if desired.
  1420.     parameterlist - the parameters corresponding to the printf() style
  1421. formatting  commands  in  the string.  In C these are listed after the
  1422. control  string,  exactly as with printf().  In assembler, the address
  1423. of the list of parameters is put in A1.
  1424.  
  1425. RESULT
  1426.     No result code is returned.
  1427.  
  1428. BUGS
  1429.     See TextRequest
  1430.  
  1431. SEE ALSO
  1432.     TextRequest
  1433.     TwoGadRequest
  1434.  
  1435.  
  1436.     This  function was designed to make it as easy to give messages to
  1437. the  user  and await acknowledgment in an intuition style requester as
  1438. it  is  using  printf() and getc().  Simply replace almost any call to
  1439. printf()  with a call to SimpleRequest and a requester will appear and
  1440. not  disappear until the user acknowledges it (either with a keystroke
  1441. or with the mouse).
  1442.  
  1443.     Example:
  1444.     SimpleRequest("okay?", "There have %d changes made to this file.",
  1445.                   numchanges);
  1446.  
  1447.     Please  see  the  TextRequest  documentation for further important
  1448. details.   This  routine  is simply a few lines of assembler glue code
  1449. for  the TextRequest routine.  The TextRequest routine is a little bit
  1450. more   complicated   to   use,  but  it  allows  correspondingly  more
  1451. flexibility.   It  is  fairly  simple to modify the glue code to allow
  1452. still more high level entry points to the TextRequest routine.
  1453.  
  1454.  
  1455.     This  is  a  complete  program that makes use of the SimpleRequest
  1456. function  from  assembler,  and  demonstrates a few of the features of
  1457. Format (which is used by SimpleRequest).
  1458.  
  1459. ;--------------------------------------------------------------------
  1460. ;-----CUT HERE---------------CUT HERE--------------------------------
  1461. ;--------------------------------------------------------------------
  1462.  
  1463.     INCLUDE "libraries/reqbase.i"
  1464.  
  1465.     public  SimpleRequest
  1466.     public  _ReqBase,_main
  1467.  
  1468. ;--------------------------------------------------------
  1469. ; This file should be linked with reqglue.o, for the SimpleRequest
  1470. ;function.
  1471. ;--------------------------------------------------------
  1472.  
  1473. SYS MACRO
  1474.     XREF    _LVO\1
  1475.     JSR _LVO\1(A6)
  1476.     ENDM
  1477.  
  1478. ;--------------------------------------------------------
  1479.  
  1480.  
  1481. _main
  1482.     OpenReq
  1483. mystart
  1484.  
  1485.     MOVE.L  A6,A5
  1486.     MOVE.L  A6,_ReqBase
  1487.  
  1488.  
  1489.     PEA     string
  1490.     MOVE.L  #$C0FFEE,-(SP)
  1491.     MOVE.W  #$1CE,-(SP)
  1492.     MOVE.W  #'B',-(SP)
  1493.     MOVE.L  #-12345,-(SP)
  1494.     MOVE.L  SP,A1
  1495.     LEA     Text,A0
  1496.     JSR     SimpleRequest
  1497.  
  1498.     LEA     16(SP),SP
  1499.  
  1500.     MOVE.L  A5,A1
  1501.     MOVE.L  4,A6
  1502.     SYS     CloseLibrary
  1503.  
  1504.     MOVEQ   #0,D0
  1505.     RTS
  1506. string
  1507.     DC.B    "This is a string.",0
  1508. Text
  1509.     DC.B    "A long (signed) decimal is: %ld,",10
  1510.     DC.B    "a character is: %c,",10
  1511.     DC.B    "a 16 bit hex val might be: %x, ",10
  1512.     DC.B    "a register-style format 32 bit hex: $%08lx,",10
  1513.     DC.B    "and a string might read: `%s'.",0
  1514.  
  1515.     dseg
  1516.  
  1517. _ReqBase    DC.L    0   ;The SimpleRequest function in the glue code
  1518.                         ;needs this variable.
  1519.  
  1520.     END
  1521.  
  1522. ;--------------------------------------------------------------------
  1523. ;-----CUT HERE---------------CUT HERE--------------------------------
  1524. ;--------------------------------------------------------------------
  1525.  
  1526.  
  1527.  
  1528.  
  1529. ;--------------------------------------------------------------------
  1530.  
  1531.  
  1532.  
  1533. TwoGadRequest
  1534.  
  1535. NAME
  1536.     TwoGadRequest - bring up a text requester and wait for the user to
  1537. acknowledge it.
  1538.  
  1539. SYNPOSIS
  1540.     result = TwoGadRequest(title, string, parameterlist, , ,)
  1541.                              A0     A1         A2
  1542.  
  1543. FUNCTION
  1544.     Bring  up  a requester (actually a window) containing a message to
  1545. the user and wait for the user to click on either the OK or the CANCEL
  1546. gadget.   The  window automatically sizes to fit the text and printf()
  1547. style  formatting can be used by TextRequest() to generate the message
  1548. to the user.
  1549.  
  1550. INPUTS
  1551.     title  -  a  null  terminated  string.   The  window  title of the
  1552. requester.
  1553.     string  -  a  null  terminated  string,  containing printf() style
  1554. formatting commands if desired.
  1555.     parameterlist - the parameters corresponding to the printf() style
  1556. formatting  commands  in  the string.  In C these are listed after the
  1557. control  string,  exactly as with printf().  In assembler, the address
  1558. of the list of parameters is put in A1.
  1559.  
  1560. RESULT
  1561.     Either  one  or  zero  is  returned, depending on whether the user
  1562. selected, respectively, the OK or the CANCEL gadget.
  1563.  
  1564. BUGS
  1565.     See TextRequest
  1566.  
  1567. SEE ALSO
  1568.     TextRequest
  1569.     SimpleRequest
  1570.  
  1571.  
  1572.     This  function was designed to make it as easy to give messages to
  1573. the  user  and get a response in an intuition style requester as it is
  1574. using printf() and getc().  Simply replace almost any call to printf()
  1575. with  a  call  to  SimpleRequest  and  a requester will appear and not
  1576. disappear  until  the  user responds to it (either with a keystroke or
  1577. with the mouse).
  1578.  
  1579.     Example:
  1580.     if(TwoGadRequest("okay?","There have %d changes made to this file"
  1581.                      "\nO.K. to continue?",
  1582.                      numchanges))
  1583.         exit(10);
  1584.  
  1585.     Please  see  the  TextRequest  documentation for further important
  1586. details.   This  routine  is simply a few lines of assembler glue code
  1587. for  the TextRequest routine.  The TextRequest routine is a little bit
  1588. more   complicated   to   use,  but  it  allows  correspondingly  more
  1589. flexibility.   It  is  fairly  simple to modify the glue code to allow
  1590. still more high level entry points to the TextRequest routine.
  1591.  
  1592.  
  1593.  
  1594. -------------------------------------------------------------------
  1595. NAME
  1596.     GetString
  1597.  
  1598. BOOL = GetString(buffer, title, window, visiblechars, maxchars)
  1599. D0                 A0      A1     A2        D0          D1
  1600.  
  1601. DESCRIPTION
  1602.     This  routine allows you to bring up a nice intuition style string
  1603. requester  in  its  own window and get a single line of input from the
  1604. user in just a one line function call.
  1605.  
  1606.     buffer  points  to  the  a buffer containing the string which will
  1607. appear  when  the string gadget first appears and it is also where the
  1608. result will be put, if this routine returns TRUE.
  1609.     Title  is  a pointer to a null terminated string that will be used
  1610. for the window title.
  1611.     Window  can  be  used  to  specify  what screen you would like the
  1612. requester  to  appear on.  You simply put a window pointer in it (or a
  1613. zero if you want the requester to appear on the workbench screen).  If
  1614. you have already set your pr_WindowPtr then you can simply pass a zero
  1615. for the window pointer and the pr_WindowPtr value will be used.
  1616.     visiblechars  specifies  how  many  characters  should actually be
  1617. visible at one time.
  1618.     maxchars   specifies   how  long  the  buffer  is,  including  the
  1619. terminating zero.
  1620.  
  1621. RETURNS
  1622.     This  routine returns true or false, depending on whether the user
  1623. clicked  on  the  cancel  gadget  (FALSE)  or clicked on the OK gadget
  1624. (TRUE)  or clicked on the close window gadget (FALSE) or hit return in
  1625. the string gadget (TRUE).
  1626.  
  1627. BUGS
  1628.     None known.
  1629.  
  1630.  
  1631.  
  1632. -------------------------------------------------------------------
  1633. NAME
  1634.     NewGetString
  1635. BOOL = NewGetString(getstringstruct)
  1636. D0                        A0
  1637.  
  1638. DESCRIPTION
  1639.  
  1640.     This  is  just  a  different way of calling the GetString routine.
  1641. Instead  of passing five different parameters, you fill out entries in
  1642. a   structure   and  pass  it's  address.   The  structure  is  called
  1643. GetStringStruct.   The  values you put into the structure are the same
  1644. as the ones passed to the GetString function.
  1645.  
  1646. BUGS
  1647.     None known.
  1648.  
  1649. SEE ALSO
  1650.     GetString
  1651.  
  1652.  
  1653. -------------------------------------------------------------------
  1654. NAME
  1655.     GetLong
  1656.  
  1657. BOOL = GetLong(&GetLongStruct)
  1658. D0                   A0
  1659.  
  1660. DESCRIPTION
  1661.     This  routine allows you to bring up a nice intuition style string
  1662. requester  in  its  own  window and get a single signed thirty-two bit
  1663. number  from the user in just a one line function call (although a few
  1664. fields in the structure must be initialized first).
  1665.  
  1666.     The  GetLongStruct  contains  fields  for  letting you specify the
  1667. title  bar  message,  the  default  value  that  should  appear in the
  1668. requester  and  the maximum and minimum values that the routine should
  1669. allow  to  be  entered.   If  the  routine  returns  TRUE  (indicating
  1670. successful  entry  of  a  number)  then  the result is returned in the
  1671. result field of the structure.
  1672.     The window field can be used to specify what screen you would like
  1673. the requester to appear on.  You simply put a window pointer in it (or
  1674. a  zero  if you want the requester to appear on the workbench screen).
  1675. If  you  have  already set your pr_WindowPtr then you can simply leave
  1676. the window field zeor and the pr_WindowPtr value will be used.
  1677.  
  1678. RETURNS
  1679.     This  routine  returns  TRUE  or  FALSE  (1 or 0) in D0 to specify
  1680. whether  or  not  the  user  successfully  entered  a number.  If this
  1681. routine  returns TRUE then you can find the result in the result field
  1682. of the GetLongStruct whose address you passed to GetLong.
  1683.  
  1684.  
  1685.  
  1686. -------------------------------------------------------------------
  1687. RawKeyToAscii
  1688.  
  1689. SYNOPSIS
  1690.  
  1691.  key = RawKeyToAscii(Code,Qualifier,IAddress)
  1692.  D0                   D0     D1        A0
  1693.  
  1694.  UWORD  Code,Qualifier;
  1695.  APTR   IAddress;
  1696.  
  1697. FUNCTION
  1698.  
  1699.     Have you ever wanted to have both RAW and COOKED keys?  You can do
  1700. it by checking the keys for whatever raw keys you want, and then using
  1701. the  console.device's RawKeyConvert routine, except that it's a hassle
  1702. to start mucking about with the device.
  1703.  
  1704.     Well, here you go!  A nice, clean way of converting from a raw key
  1705. to  a  cooked  key,  in a single call!  All you have to do is pass the
  1706. code  and  qualifier  from  your  intuimessage, and the address of the
  1707. message  itself, and you will get back the ASCII value of the key that
  1708. was  hit.  This does, in fact, use the console.device's RawKeyConvert,
  1709. so that if you have a different keymap set, it will be used.
  1710.  
  1711. EXAMPLE
  1712.  
  1713.  
  1714. struct IntuiMessage *im;
  1715.  
  1716.     key = RawKeyToAscii(im->Code,im->Qualifier,im->IAddress);
  1717.  
  1718.