home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / amigae / e_v3.2a / rkrmsrc / intuition / boopsi / talk2boopsi.e < prev    next >
Text File  |  1977-12-31  |  5KB  |  107 lines

  1. -> This example creates a Boopsi prop gadget and integer string gadget,
  2. -> connecting them so they update each other when the user changes their value.
  3. -> The example program only initialises the gadgets and puts them on the window;
  4. -> it doesn't have to interact with them to make them talk to each other.
  5.  
  6. OPT OSVERSION=37
  7.  
  8. MODULE 'intuition/gadgetclass',
  9.        'intuition/icclass',
  10.        'intuition/intuition'
  11.  
  12. ENUM ERR_NONE, ERR_OBJ, ERR_WIN
  13.  
  14. RAISE ERR_OBJ IF NewObjectA()=NIL,
  15.       ERR_WIN IF OpenWindowTagList()=NIL
  16.  
  17. CONST PROPGADGET_ID=1, INTGADGET_ID=2,
  18.       PROPGADGETWIDTH=10, PROPGADGETHEIGHT=80, INTGADGETHEIGHT=18,
  19.       VISIBLE=10, TOTAL=100, INITIALVAL=25, MINWINDOWWIDTH=80
  20. CONST MINWINDOWHEIGHT=PROPGADGETHEIGHT+70, MAXCHARS=3
  21.  
  22. PROC main() HANDLE
  23.   DEF w=NIL:PTR TO window, prop=NIL, integer=NIL
  24.  
  25.   -> Open the window--notice that the window's IDCMP port
  26.   -> does not listen for GADGETUP messages.
  27.   w:=OpenWindowTagList(NIL,
  28.                       [WA_FLAGS,     WFLG_DEPTHGADGET OR WFLG_DRAGBAR OR
  29.                                          WFLG_CLOSEGADGET OR WFLG_SIZEGADGET,
  30.                        WA_IDCMP,     IDCMP_CLOSEWINDOW,
  31.                        WA_MINWIDTH,  MINWINDOWWIDTH,
  32.                        WA_MINHEIGHT, MINWINDOWHEIGHT,
  33.                        NIL])
  34.  
  35.   -> Create a new propgclass object
  36.   prop:=NewObjectA(NIL, 'propgclass',
  37.           [GA_ID,     PROPGADGET_ID,  -> These are defined by gadgetclass and
  38.            GA_TOP,    w.bordertop+5,  -> correspond to similarly named fields
  39.            GA_LEFT,   w.borderleft+5, -> in the Gadget structure.
  40.            GA_WIDTH,  PROPGADGETWIDTH,
  41.            GA_HEIGHT, PROPGADGETHEIGHT,
  42.            -> This tells the prop gadget to map its PGA_Top attribute to
  43.            -> STRINGA_LONGVAL when it issues an update about the change to
  44.            -> its PGA_Top value.
  45.            ICA_MAP,   [PGA_TOP, STRINGA_LONGVAL, NIL],
  46.            -> The rest of this gadget's attributes are defined by propgclass.
  47.            PGA_TOTAL,   TOTAL,      -> The integer range of the prop gadget.
  48.            PGA_TOP,     INITIALVAL, -> The initial value of the prop gadget.
  49.            PGA_VISIBLE, VISIBLE, -> This determines how much of the prop gadget
  50.                                  -> area is covered by the prop gadget's knob,
  51.                                  -> or how much of the gadget's TOTAL range is
  52.                                  -> taken up by the prop gadget's knob.
  53.            PGA_NEWLOOK, TRUE,    -> Use new-look prop gadget imagery
  54.            NIL])
  55.  
  56.   -> Create the integer string gadget
  57.   integer:=NewObjectA(NIL, 'strgclass',
  58.              [GA_ID,      INTGADGET_ID,  -> Parameters for the Gadget structure
  59.               GA_TOP,     w.bordertop+5,
  60.               GA_LEFT,    w.borderleft+PROPGADGETWIDTH+10,
  61.               GA_WIDTH,   (MINWINDOWWIDTH-
  62.                             (w.borderleft+w.borderright+PROPGADGETWIDTH+15)),
  63.               GA_HEIGHT,  INTGADGETHEIGHT,
  64.               -> This tells the string gadget to map its STRINGA_LONGVAL
  65.               -> attribute to PGA_TOP when it issues an update.            
  66.               ICA_MAP,    [STRINGA_LONGVAL, PGA_TOP, NIL],
  67.               ICA_TARGET, prop,
  68.               -> The GA_PREVIOUS attribute is defined by gadgetclass and is used
  69.               -> to wedge a new gadget into a list of gadget's linked by their
  70.               -> gadget.nextgadget field.  When NewObject() creates this gadget,
  71.               -> it inserts the new gadget into this list behind the GA_PREVIOUS
  72.               -> gadget.  This attribute is a pointer to the previous gadget.
  73.               -> This attribute cannot be used to link new gadgets into the
  74.               -> gadget list of an open window or requester, use
  75.               -> AddGList() instead.
  76.               GA_PREVIOUS, prop,
  77.               -> These attributes are defined by strgclass.  The first contains
  78.               -> the value of the integer string gadget.  The second is the
  79.               -> maximum number of characters the user is allowed to type into
  80.               -> the gadget.
  81.               STRINGA_LONGVAL,  INITIALVAL,
  82.               STRINGA_MAXCHARS, MAXCHARS,
  83.               NIL])
  84.  
  85.   -> Because the integer string gadget did not exist when this example created
  86.   -> the prop gadget, it had to wait to set the ICA_Target of the prop gadget.
  87.   SetGadgetAttrsA(prop, w, NIL, [ICA_TARGET, integer, NIL])
  88.  
  89.   AddGList(w,prop,-1,-1,NIL) -> Add the gadgets to the window and display them.
  90.   RefreshGList(prop, w, NIL, -1)
  91.  
  92.   REPEAT  -> Wait for the user to click the window close gadget.
  93.   UNTIL WaitIMessage(w)=IDCMP_CLOSEWINDOW
  94.  
  95.   RemoveGList(w, prop, -1)
  96.  
  97. EXCEPT DO
  98.   IF integer THEN DisposeObject(integer)
  99.   IF prop THEN DisposeObject(prop)
  100.   IF w THEN CloseWindow(w)
  101.   SELECT exception
  102.   CASE ERR_OBJ; WriteF('Error: Failed to create new Object\n')
  103.   CASE ERR_WIN; WriteF('Error: Failed to open window\n')
  104.   ENDSELECT
  105. ENDPROC
  106.  
  107. vers: CHAR 0, '$VER: Talk2boopsi 37.1', 0