home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / misc / vcb.lha / vcb / vcb.doc < prev    next >
Encoding:
Text File  |  1992-08-15  |  18.6 KB  |  463 lines

  1.  
  2.      VCB(1)                AM*GA Programmer's Manual                 VCB(1)
  3.  
  4.  
  5.  
  6.      ¢1mNAME 
  7.           ¢0mVCB 
  8.  
  9.      ¢1mDESCRIPTION 
  10.           VCB ¢0mstands  for  Virtual  Co-ordinate  Box.    There  is  an
  11.           every-day example for its use right at hand:  the  Workbench
  12.           windows.  
  13.  
  14.           The  user  peeps  through their rectangular inner box onto a
  15.           ¢1mvirtual ¢0m(i.e. seemingly real,  but  not  there)  plane  that
  16.           infinitely extents into all directions and on which icons of
  17.           files and  drawers  lie at certain ¢1mvirtual co¢0m-¢1mordinates¢0m.  By
  18.           means of the scrollers within the window borders,  the  user
  19.           can  shift  the box around on the virtual plane, causing new
  20.           things to appear in the window.  
  21.  
  22.           Another example would be a  text  editor.    Once  you  have
  23.           entered more text that the window can hold, the text extents
  24.           beyond  the window's bounds on its ¢3mvirtual, ¢0marbitrarily long
  25.           fanfold paper.  Then  you  will  use  the  scroll  bar  that
  26.           normally  is  attached  to the right border of the window to
  27.           look at different parts of your text.  
  28.  
  29.           Almost  every  application  program  that  operates  on   an
  30.           arbitrarily  extensible project data base and that employs a
  31.           graphical user interface will use  the  virtual  co-ordinate
  32.           plane ¢3mmetaphor ¢0mto display its data.  
  33.  
  34.           Now  VCB  allows programs not only to share the concept, but
  35.           also the code!  
  36.  
  37.           VCB is a BOOPSI class implementation in shape of  a  scanned
  38.           library (for Manx/Aztec C).  
  39.  
  40.           At present this class is still `private┤ in the sense that I
  41.           do not provide code that adds it to the system's public pool
  42.           of  named  classes  and  therefore  is  not  accessible by a
  43.           symbolic name.  
  44.  
  45.           After some experiences in its use have  been  collected  and
  46.           possible  bugs  habe  been  fixed,  it  will be submitted to
  47.           Commodore Amiga for becoming a public BOOPSI  class  with  a
  48.           registered name.  This name will probably be "vcbgclass" (it
  49.           is a  descendant  of "gadgetclass").  Maybe some day it will
  50.           even be part of the OS itself (Intuition ¢3mshould ¢0mprovide such
  51.           a service).  
  52.  
  53.           You should link the library to your client code in order  to
  54.           create VCB  gadgets and attach them to your windows.  Such a
  55.           gadget consists  of  horizontal  and/or  vertical  scrollers
  56.           (that  look  almost  identical  to  those  within  Workbench
  57.           windows) and the box in which your  data  will  be  visible.
  58.           You  have  to  supply  a hook to a function of your own that
  59.           will do the actual rendering within the box according to the
  60.           `instructions┤ the gadget gives it.  The internals  of  that
  61.           function are  completely  ¢3mup  to  you!    ¢0mIt  just  makes no
  62.           difference to that gadget whether you are going  to  display
  63.  
  64.  
  65.      KosmoSoft                        -1-
  66.  
  67.  
  68.      VCB(1)                AM*GA Programmer's Manual                 VCB(1)
  69.  
  70.  
  71.           text, graphics,  a  musical  score  etc.   or all of them at
  72.           once!  
  73.  
  74.  
  75.      ¢1mUSAGE 
  76.           ¢0mUsing VCB starts with creating the BOOPSI  class.    You  do
  77.           this   by   calling  the  library  function  initVCBClass().
  78.           freeVCBClass() will free that class again.   Once  you  have
  79.           the  class,  you  can  create as many instances (gadgets) of
  80.           that class as you want by calling NewObject().  
  81.  
  82.           As each of Intuition's own classes defines certain  specific
  83.           tags  for setting up the instance as the client needs it, so
  84.           does VCB. Here are the 
  85.  
  86.      ¢1mTAGS 
  87.        ¢0mVCBGA_ExposureHook (struct Hook *) 
  88.           áááááthe hook to your rendering function (see  the  CALLBACK
  89.           section below).  
  90.  
  91.        VCBGA_Interim (BOOL) 
  92.           áááááTRUE (1) indicates that the display should update while
  93.           aáscrolleráis  moved  or a button repeats, not only when the
  94.           scrolleráorábuttonáis released.  Think twice before  setting
  95.           thisáflag!ááAlthoughátheáexposure hook only gets called when
  96.           theádisplayáactuallyáchangesá(andánotáoná¢3meveryá¢0mmouse  move),
  97.           there may be quite a lot of invokations  to  your  rendering
  98.           áááááfunction.ááIfáyourárenderingáfunction takes too long to
  99.           complete,átheásystemámayáchokeáwithápendingámouse       move
  100.           events.  
  101.  
  102.        VCBGA_HScroller (BOOL) 
  103.           áááááTRUE  (1)  indicates  that  you   want   a   horizontal
  104.           scroller.  
  105.  
  106.        VCBGA_VScroller (BOOL) 
  107.           áááááTRUE (1) indicates that you want a vertical scroller.  
  108.  
  109.           áááááWithout  the  scroller, you cannot move the display box
  110.           overátheávirtualáplaneáináthatádirectioná¢3mmanually,á¢0mbut 
  111.           besidesáthatáthereáisánoádifferenceá(you can still  move  it
  112.           via SetGadgetAttrs()).  
  113.  
  114.        VCBGA_HBorder (BOOL) 
  115.           áááááTRUE  (1)  put horizontal scroller (if any) into bottom
  116.           border of the host window.  
  117.  
  118.        VCBGA_VBorder (BOOL) 
  119.           áááááTRUE (1) put vertical  scroller  (if  any)  into  right
  120.           border of the host window 
  121.  
  122.           áááááNote:  Setting the VCBGA_H/VBorder flag will adjust the
  123.           windowábordersátoáaccommodateáthe  scroller,  it  will   not
  124.           resizeáyourágadgetáináanyáway.áá(see also example).  
  125.  
  126.        VCBGA_HUnit (ULONG) 
  127.           áááááthe  number  of pixels that make one virtual horizontal
  128.           co-ordinate unit.  
  129.  
  130.  
  131.      KosmoSoft                        -2-
  132.  
  133.  
  134.      VCB(1)                AM*GA Programmer's Manual                 VCB(1)
  135.  
  136.  
  137.  
  138.        VCBGA_VUnit (ULONG) 
  139.           áááááthe number of pixels that  make  one  virtual  vertical
  140.           co-ordinate unit.  
  141.  
  142.        VCBGA_HTotal (ULONG) 
  143.           áááááthe  horizontal extension of the virtual plane measured
  144.           in virtual units.  
  145.  
  146.        VCBGA_VTotal (ULONG) 
  147.           áááááthe vertical extension of the virtual plane measured in
  148.           virtual units.  
  149.  
  150.           áááááIn this version, VCB cannot emulate  Workbench  windows
  151.           whicháfeatureáanáinfinitely large    virtual   plane.      I
  152.           personallyádon'táneedáthisá(now),ábutáI  will  add   it   if
  153.           someone misses it.  
  154.  
  155.        VCBGA_HOffset (ULONG) 
  156.           áááááthe  current  horizontal co-ordinate of the left border
  157.           ofátheádisplayábox,ámeasured in virtual units.  
  158.  
  159.        VCBGA_VOffset (ULONG) 
  160.           áááááthe current vertical co-ordinate of the left border  of
  161.           theádisplayábox,ámeasured in virtual units.  
  162.  
  163.           In  addition  to  these,  all tags that apply to the general
  164.           ¢1mgadgetclass ¢0mremain active as well, of course.  
  165.  
  166.           To create the imagery for the scrollers, two additional tags
  167.           should be  provided.    The  tag  values  are   defined   in
  168.           <intuition/imageclass.h>.  
  169.  
  170.           These  are  SYSIA_DrawInfo (struct DrawInfo *) (you get/free
  171.           the           DrawInfo            structure            using
  172.           GetScreenDrawInfo()/FreeScreenDrawInfo,  see  AutoDocs)  and
  173.           SYSIA_Size (SYSISIZE_...).  While a missing  SYSIA_Size  tag
  174.           is   defaulted   to   SYSISIZE_MEDRES   (Workbench   default
  175.           resolution),  a  missing  SYSIA_DrawInfo  tag   will   cause
  176.           NewObject() to fail.  
  177.  
  178.           There   are  five  further  tags  that  refer  to  read-only
  179.           attributes (ignored by SetGadgetAttrs(), but retrievable  by
  180.           GetAttr()): 
  181.  
  182.        VCBGA_HSize (ULONG), VCBGA_VSize (ULONG) 
  183.           áááááthe  number of units (as defined by VCBGA_H/VUnit) that
  184.           currentlyáfitáintoáthe display box  horizontally/vertically.
  185.           ForáVCBsáwitháGFLG_RELWIDTH   /   GFLG_RELHEIGHT  set  these
  186.           valuesáchangeáeachátimeátheáwindowáis resized.  
  187.  
  188.        VCBGA_XOrigin (ULONG), VCBGA_YOrigin (ULONG) 
  189.           áááááthe current co-ordinates of the left top corner of  the
  190.           displayáboxá(whereádataáisádisplayed)áwithin  the  rastport.
  191.           NoteáthatáthisávaluesáchangeáforáVCBsáwitháGFLG_RELRIGHT   /
  192.           GFLG_RELBOTTOMásetáeachátimeátheáwindowáisáresized.ááThe 
  193.           renderingáfunctionámust  get  this  values  every time it is
  194.           invokedáandáuseáthemáináeveryárenderingáoperation as offsets
  195.  
  196.  
  197.      KosmoSoft                        -3-
  198.  
  199.  
  200.      VCB(1)                AM*GA Programmer's Manual                 VCB(1)
  201.  
  202.  
  203.           to the rastport's origin.  
  204.  
  205.        VCBGA_Semaphore (struct SignalSemaphore *) 
  206.           áááááThis returns the address of a SignalSemaphore structure
  207.           thatátheáclientácodeámust obtain if it is  going  to  modify
  208.           dataástructuresáthatátheárenderingáfunction  relies  on (see
  209.           ARBITRATION section below).  
  210.  
  211.  
  212.      ¢1mCALLBACK 
  213.  
  214.           ¢0mThe callback function will receive arguments  in  the  usual
  215.           form: the hook pointer, an `object┤ and a command message.  
  216.  
  217.           The   `object┤  is  the  usual  public  handle  to  the  VCB
  218.           instance.  You will need this to retrieve geometric data via
  219.           GetAttr() (the VCB structure is ¢3mprivate, ¢0mI'm doing this  the
  220.           clean way, despite the overhead).  See the example.  
  221.  
  222.           The  message  pointer  refers  to  an  ExposureMsg structure
  223.           (defined in vcb.h).  It contains  a  command  ID  (the  only
  224.           defined  command  ID  is  VCBCMD_RENDER, but better test for
  225.           this ID explicitly), a pointer to the  rastport  into  which
  226.           the renderings go and left, top, width and height values for
  227.           the  rectangle  that has to be (re-)drawn. An `exposure┤ has
  228.           occured if the bitmap contents do no longer reflect the data
  229.           that is located at the respective position  on  the  virtual
  230.           plane.    Possible   reasons  are  that  the  window  wasn't
  231.           previously open or was exposed by some  other  window  going
  232.           away  or  that  the display box moved to another position on
  233.           the virtual plane (either by manipulation of  the  scrollers
  234.           or by a client request via SetGadgetAttrs()).  
  235.  
  236.           The  left, top, width and height values are in virtual units
  237.           and have to be multiplied with the respective unit values to
  238.           yield pixel dimensions.  
  239.  
  240.           Be aware that callback code is hazardous area!    There  are
  241.           some things that ¢3mmust ¢0mbe avoided.  
  242.  
  243.           The execution  time  of  this  function  is  critical.   The
  244.           functionality of the whole user interface  depends  on  that
  245.           your function completes as quickly as possible.  Prepare all
  246.           information  needed  for  rendering  in advance and store it
  247.           where the function can get it (please read  the  ARBITRATION
  248.           section below,  too).    Better  to consume some more memory
  249.           than to freeze the user interface.  
  250.  
  251.           Do not call dos.library  functions  directly  or  indirectly
  252.           from the  rendering function!  This function executes in the
  253.           context of the input device's task!  
  254.  
  255.           Likewise,  do  not  directly  or  indirectly   call   Wait()
  256.           (deadlock imminent).    This  implies that you cannot employ
  257.           the console.device to do text rendering!  
  258.  
  259.           If you have to debug this  part  of  your  code,  never  use
  260.           printf() or  fprintf()!    Try to kprintf() to a terminal or
  261.  
  262.  
  263.      KosmoSoft                        -4-
  264.  
  265.  
  266.      VCB(1)                AM*GA Programmer's Manual                 VCB(1)
  267.  
  268.  
  269.           record to an internal data structure and evaluate it later.  
  270.  
  271.           Nonetheless, do the things that are necessary: Please do not
  272.           make any assumptions on the state that the  rastport  is  in
  273.           when your function is called.  Setup the rastport explicitly
  274.           before you start rendering.  In particular, set the pens and
  275.           the draw mode where appropriate (text, vector drawings, area
  276.           drawings), set the line pattern for vector drawings, set the
  277.           area pattern   for   area  drawings.    Certainly  I  forgot
  278.           something,  so  please  read  through  the   docs   of   the
  279.           graphics.library  functions  that  you  use to find out what
  280.           they depend on.  Even if the OS does not make  use  of  some
  281.           rastport features  now,  it may do so in the future.  We are
  282.           all suffering the  system  font  dependency  of  pre-OS  2.0
  283.           software now.  Let this be a lesson to us!  
  284.  
  285.  
  286.      ¢1mARBITRATION 
  287.  
  288.           ¢0mThe callback function executes on another task's context and
  289.           time slice.    If  it  relies  on  data  that is going to be
  290.           changed by the client task (which is most probably the  case
  291.           if  it  is  a  project data base that is being edited by the
  292.           user), the client task has to arbitrate for the write access
  293.           to that data (read access is free for the client  since  the
  294.           callback code is not supposed to modify any static data).  
  295.  
  296.           To  that purpose, a SignalSemaphore structure is part of the
  297.           VCB instance  data.     The   semaphore   is   automatically
  298.           initialized during  the  processing  of  NewObject().    The
  299.           gadget only performs a  callback  if  an  AttemptSemaphore()
  300.           succeeds.   It  calls  ReleaseSemaphore() after the callback
  301.           completes.  
  302.  
  303.           Thus to prevent the gadget from rendering data that is being
  304.           modified, the client  must  wait  for  ObtainSemaphore()  to
  305.           return  (which  should  happen  as  soon  as  the user stops
  306.           fiddling with the VCB's  scrollers  or  moving/resizing  the
  307.           window).   As  long as the client posseses the access right,
  308.           the gadget's display will not be updated, even  not  due  to
  309.           client calls to SetGadgetAttrs().  
  310.  
  311.           The  pointer  to the semaphore must be retrieved by GetAttr(
  312.           VCBGA_Semaphore, ... ) (see TAGS and example program).  
  313.  
  314.  
  315.      ¢1mEXAMPLE PROGRAM 
  316.           ¢0mThere  is  a  simple   test   program   included   in   this
  317.           distribution, named test.c.  It does not do anything useful,
  318.           but it  shows  how  to  write  a  VCB client.  The rendering
  319.           function exposure() simply draws a cross into the  rectangle
  320.           that it  should  refresh,  just to visualize the idea.  test
  321.           opens a window with  scrollers  in  its  borders  that  look
  322.           almost identical to Workbench scrollers (the only difference
  323.           is  that  the  horizontal  scroller  starts  at  a  slightly
  324.           different offset from the window's left edge, respecting the
  325.           window's left  border  which  Workbench  does  not).     The
  326.           parameters  necessary  for  this  Workbench-look  can all be
  327.  
  328.  
  329.      KosmoSoft                        -5-
  330.  
  331.  
  332.      VCB(1)                AM*GA Programmer's Manual                 VCB(1)
  333.  
  334.  
  335.           found in the NewObject() taglist.  By clicking on the  close
  336.           gadget  repeatedly  you  can  run  through  a number of test
  337.           operations: Prior to that, resize the window to  be  smaller
  338.           than the  cross  that  is  initially visible.  Note that the
  339.           scrollers indicate now that there is more `data┤  than  what
  340.           is displayed.  
  341.  
  342.           Click the close gadget.  This changes the horizontal offset,
  343.           causing  the  box contents to `scroll┤. If the offset change
  344.           conserves some old imagery, then VCB will ScrollRaster()  it
  345.           to  its  new  place  within the display box and only refresh
  346.           those areas blanked out by the scroll.  If the jump  is  too
  347.           far, it simply runs a complete redraw.  
  348.  
  349.           Click again  and  again and again and again.  The horizontal
  350.           and vertical totals (the number units that the virtual plane
  351.           extends horizontally and vertically) have changed to 3,  10,
  352.           20 and finally 30.  
  353.  
  354.           Click again.    The  program  fetches  the VCB semaphore and
  355.           obtains it.  Now moving the  scroll  bars  or  pressing  the
  356.           buttons has  no visual effect.  Note however that pressing a
  357.           button will still move  the  associated  scroll  bar  -  the
  358.           gadget is still alive!  If you do something with the window,
  359.           the display box contents will decay.  
  360.  
  361.           Click again.    The program releases the VCB semaphore again
  362.           and calls RefreshGList().  Now  the  gadget  updates  itself
  363.           according to  the  new  scroller  positions.   Releasing the
  364.           semaphore ¢3malone ¢0mdoes not trigger any display  refresh.    To
  365.           get an immediate update, you need to call RefreshGList().  
  366.  
  367.           Click again and the program terminates.  
  368.  
  369.  
  370.      ¢1mMORE EXAMPLES 
  371.           ¢0mA  real,  complex  VCB  application  is about to be publicly
  372.           released: The View-Handler which is a AmigaDOS  device  that
  373.           displays text  written to it in a window, using a VCB.  Look
  374.           for it on anonymous ftp sites (probably first in Germany).  
  375.  
  376.  
  377.      ¢1mADDITIONAL DOCUMENTATION 
  378.           ¢0mI'm sorry that at present I don't have the time to  document
  379.           the internal  operations  of VCB sufficiently.  When looking
  380.           at the sources, you will notice that VCB is build on another
  381.           BOOPSI class named VCX for virtual co-ordinate  axis.    The
  382.           scrollers of a VCB are VCX instances.  Of course, this class
  383.           could be useful for application programmers in its own right
  384.           without the  VCB  framework.   If you want to use it or have
  385.           any other questions regarding VCB, please e-mail to me!    I
  386.           should be able answer within a week.  
  387.  
  388.  
  389.      ¢1mSEE ALSO 
  390.           ¢0mRKM Libraries, BOOPSI documentation.  
  391.  
  392.  
  393.  
  394.  
  395.      KosmoSoft                        -6-
  396.  
  397.  
  398.      VCB(1)                AM*GA Programmer's Manual                 VCB(1)
  399.  
  400.  
  401.      ¢1mBUGS 
  402.           ¢0mI'm  presently  integrating VCB into several applications of
  403.           my own and will try to fix VCB bugs/problems as they  occur,
  404.           but  since  I'm focused on certain fields of applications, I
  405.           may miss some important flaw.  Therefore, I would appreciate
  406.           reports of bugs, in particular (but not only) if they showed
  407.           up in a more uncommon application of this  stuff.    I  find
  408.           this a very basic piece of GUI-technology and I want this to
  409.           run as stable as possible!  
  410.  
  411.  
  412.      ¢1mCONTACT 
  413.           ¢0mStefan  Reisner, Aachener Stra▀e 399, 5000 K÷ln 41, Germany,
  414.           internet srph-cip.uni-koeln.de 
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.      KosmoSoft                        -7-
  462.  
  463.