Short:    Progress window, bevel boxes, icons as gadgets, etc.
Uploader: chris.planb@dnet.co.uk (Chris Perver)
Author:   chris.planb@dnet.co.uk (Chris Perver)
Type:     dev/e
Replaces: dev/e/Chris_emods.lha

Here is my slightly useful AmigaE modules. There are probably loads of  bugs  in
them. :). You do not need permission to use them in your programs, but if you do
use them, I wouldn't mind an email :).

--------------------------------------------------------------------------------
mygfxtools.m

  mydrawbox()
  -----------

  mydrawbox() can draw many different types of bevel boxes.

    mydrawbox(rp, dri, x, y, x2, y2, type, recessed, light, lightpen, darkpen)

    EXAMPLE

      mydrawbox(rp, dri, 5, 5, 10, 10, 4, TRUE, TRUE, 6, 7)

    INPUT

      rp       - rastport
      dri      - screen drawinfo
      x        - left coord
      y        - top coord
      x2       - right coord
      y2       - bottom coord
      type     - type of box to draw, a number ranging from 1 to 6...
                 1 = Box
                 2 = Bevel
                 3 = Smooth bevel
                 4 = Raised
                 5 = Ridge
                 6 = Wide ridge
      recessed - if TRUE the box will be drawn recessed
      light    - if TRUE the light and dark pen will be used instead of the black
                 and white pens.
      lightpen - pen number of light colour
      darkpen  - pen number of dark colour

  myscrollraster()
  ----------------

  myscrollraster()  works  exactly  like  ScrollRaster().  myscrollraster()   uses
  BlitCopy(),  and  doesn't clear the new area of raster, which is useful for when
  you want to have clean looking scrolling. I use it for EvenMore.

    myscrollraster(rp, x, y, x2, y2, deltax, deltay)

    EXAMPLE

      myscrollraster(rp, 5, 5, 50, 50, -10, 20)

    INPUT

      rp     - rastport
      x      - left coord
      y      - top coord
      x2     - right coord
      y2     - bottom coord
      deltax - how many pixels to scroll horizontally
      deltay - how many pixels to scroll vertically

    BUGS

      Don't think it can handle scrolls larger than the area to scroll. But
      because this function doesn't clear the new area of raster, there wouldn't
      be any visual difference anyway.


--------------------------------------------------------------------------------
list.m

  The next two functions are useful for preference files,  etc.  I  use  them  for
  EvenMore :). insertinlist() will take a string of numbers, seperated by slashes,
  and insert each value into the list. Will stop inserting values when it comes to
  the end of the list.

    insertinlist(list, str)

    EXAMPLE

      insertinlist(list, '5/40/6/3')

    INPUT

      list   - s list (Not exec list), list := [0,0,0,0]


  mergelist2str() does the opposite of insertinlist(). mergelist2str() will take a
  list, and return the string of the values in that list, seperated by slashes.

    string := mergelist2str(list)

    EXAMPLE

      str := mergelist2str(list)

    INPUT

      list   - s list (Not exec list), list := [0,0,0,0]

    OUTPUT

      string - s string of values seperated by slashes, '0/54/334/23'


--------------------------------------------------------------------------------
execlists.m

  The functions in execlists.m are useful for manuplating exec lists.

    addName(list, str, prednode)           - add a list node to a list, prednode is the
                                             node to replace
    freeNode(list, num)                    - Free node number <num> form a list
    freeNameNodes(list)                    - Free all nodes in the list
    num := findNodeNumber(list, str)       - Find the position of the node <str> in the
                                             list
    str := findNodeName(list, num)         - Find the name of node <num> in the list
    movelistnode(list1, pos1, list2, pos2) - Move a node from one list/position to
                                             another

    EXAMPLE

      movelistnode(list, 3, list 4)
      movelistnode(list, 3, anotherlist, 6)

    INPUT

      list1 - an exec list
      pos1  - the number of the node to move
      list2 - an exec list. Can be the same list as list1
      pos2  - the position to put the new node in list2

    num := countnodes(list) - Returns number of nodes in a list


--------------------------------------------------------------------------------
myscreens.m

  findpubscreen() in the screens.m module will return  TRUE  if  a  public  screen
  named <str> exists.

    findpubscreen(str)

    EXAMPLE

     bool := findpubscreen('Workbench')

    INPUT

      str - Name of a public screen

    OUTPUT

      bool - True if a public screen is open that matches the name str.

--------------------------------------------------------------------------------
progresswin.m

  The progresswin module will allow you to display a window with a progress bar in
  it. I use this module for EvenMore, when loading files.

  First, put this module into your source.

    MODULE '*progresswin'

  Then you need to make a DEF.

    DEF pw:PTR TO progresswin

  At the start of your program, put..

    NEW pw

  And at the end of your program, put..

    END pw

  When you want to open the progress window, just type the following...

    pw.openprogresswin(pw, screenname, winptr, str)

    screenname - name of public screen to open on. Can be NIL.
    winptr     - the pointer to your window to centre the progress window on.
                 IF NIL, the progress window will centre on the screen.
    str        - a string to display above the progress gadget

  To update the progress gadget, just type the following...

  pw.drawprogressgad(pw, percentage)

    percentage - percentage for progress gadget to be filled

  To close the progress window, just type the following...

    pw.closeprogresswin(pw)

  The progress window will use the screen font of the screen it opens on  for  the
  text. A few values are hard-coded, but you could easily change that if you want.
  The window will be 6 times the screen font height high, and 250 pixels wide. The
  text  will appear 1/3rd of the way down the window, and the progress gadget will
  appear in the middle of the window.

  If you want to use the window more than once without closing  it,  for  example,
  for  copying  a  batch  of files, just call the drawprogresstext() function. The
  text will be redrawn.

    pw.drawprogresstext(pw, 'Progressing :)')

    Exceptions   Exception info  Description

    "PUBS"       screenname      Unable to lock pubscreen
    "VIS"                        Unable to get visualinfo
    "FONT"                       Unable to open screen font
    "WIN"                        Unable to open window

--------------------------------------------------------------------------------
icongad.m

  This MODULE will allow you to use icons as gadgets in your programs.

  First, put this module into your source.

    MODULE '*icongad'

  Then you need to make a DEF.

    DEF mygads:PTR TO icongads

  At the start of your program, put..

    NEW mygads

  And at the end of your program, put..

    END mygads

  To initiate the icons, call mygads.initicongad() with a list of icons...
  Don't forget to remember which order each icon comes in. You will need
  this later on.

    mygads.initicongad(['Work:temp.info',     -> Icon 0
                        'BigHD:disk.info',    -> Icon 1... etc
                        'ENV:Myicon.info'])

  Next, to find the size of any gadget. <gadnum> is the number of the icon
  in the list that you want the size of, starting from 0.

    xsize := mygads.sizex(gadnum)
    ysize := mygads.sizey(gadnum)

  To place the actaual icon on the window. Again, <gadnum> is the number of
  the gadget in the list you want to display. <gadgetid> is the ID that you
  want this gadget to have, <x> and <y> are the coordinates on the window, and
  <win> is the pointer to the window. You can only display icons that have not
  already been displayed, or have been removed.

    mygads.addicongad(gadnum, gadgetid, x, y, win)

  To remove a gadget from the window. <gadnum> is the number of the gadget to
  remove and <win> is the pointer to your window.

    mygads.removeicongad(gadnum, win)

  To free all the icons, at the end of your program, or maybe if you want to
  display different icons, then use mygads.endicongad(). There are no arguments
  for it. It will free all the icons, so you won't be able to display them again
  until you call mygads.initgadicon() again.

    mygads.endicongad()
