home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Painting / OpalPaint2,3-020+Version.LHA / ARexxReq.doc < prev    next >
Encoding:
Text File  |  1994-04-22  |  17.5 KB  |  494 lines

  1.                     OpalPaint ARexx Requester Comands.
  2.  
  3.  
  4.  
  5.                         INTRODUCTION
  6.  
  7.    This  document  describes  using the new requester commands available in
  8. OpalPaint  v2.3.   This  set of commands provides ARexx with the ability to
  9. build  custom  requesters on the OpalPaint screen, thus greatly simplifying
  10. the  user  interface  of  most  ARexx scripts and allowing more complicated
  11. functions to be implemented in ARexx.
  12.  
  13.  
  14.  
  15.                         ACKNOWLEDGEMENTS
  16.  
  17.    Special  thanks  must go to Carmen Rizzolo and Greg Niles for their help
  18. in the designing and testing of this interface.
  19.  
  20.  
  21.  
  22.                         NEW REQUESTER COMMANDS
  23.  
  24.         ReqBuild        - Initialise a new Requester.
  25.         AddGadget       - Add a Gadget to the requester.
  26.         AddText         - Add text to the requester.
  27.         AddHeading      - Add heading text to the requester.
  28.         AddBox          - Add a bevelled box to the requester.
  29.         InitGadget      - Initialise the default value for a gadget.
  30.         MutualEx        - Set up Mutual Exclusion between gadgets.
  31.         Request         - Display the requester.
  32.         GadgetStatus    - Gadget the state of gadgets in the requester.
  33.  
  34.  
  35.  
  36.                         NOTE ON PARAMETERS
  37.  
  38.   All text string containing spaces needs to be enclosed in quotes, however
  39. ARexx  strips  the  first  level  of  quotes  before sending the command to
  40. OpalPaint.  Therfore two levels of quoting are required.  e.g.
  41.  
  42.         '"This is one string" "This is another"'
  43.  
  44.    It  is  a good idea to always put all parameters in quotes as ARexx also
  45. has  a  problem when negative numbers are sent as paremeters, it interprets
  46. the '-' as a subtraction operator an usually generates an error.  Therefore
  47. all  of  my  examples  will  have all parameters enclosed in single quotes.
  48. e.g.
  49.         AddGadget 'Button Gad1 0 -10 100 10 "A Button"' 
  50.  
  51.  
  52.  
  53.                         CREATING A CUSTOM REQUESTER
  54.  
  55.   Creating a requester in ARexx is fairly easy, the following steps outline
  56. the process of creating a requester.
  57.  
  58.         1) Call ReqBuild to initialise the requester.
  59.         2) Add Elements to the requester using AddGadget, AddText,
  60.            AddHeading, AddBox.
  61.         3) Call MutualEx if required to set up mutual exclude groups.
  62.         4) Call InitGadget for any gadgets that need initialising.
  63.         5) Call Request to display the requester.
  64.         6) Get the values entered by the user using the GadgetStatus command.
  65.  
  66.  
  67. NOTE:   During  step  5,  the  Requester  command does not return until the
  68. request is removed by the user hitting OK, Cancel or another button gadget.
  69.  
  70. TIP:  Positioning of elements within a requester can become a little tricky
  71. if  the  requester becomes complex.  It is sometimes useful to use a screen
  72. capture  program such as Grabbit to take a snapshot of the OpalPaint screen
  73. when  your requester is displayed.  This snapshot can then be loaded into a
  74. standard palette mapped paint program (or even OpalPaint) where the gadgets
  75. and  text  can  be  positioned  more freely.  The final coordinates for the
  76. gadgets  can  then be obtained from the paint program and used in the ARexx
  77. script.
  78.  
  79.  
  80.  
  81.                         GADGET TYPES
  82.  
  83.   The  most important part of any requester is gadgets, using the AddGadget
  84. command  several  different types of gadgets can be created.  The following
  85. gadget types are currently available.
  86.  
  87. 1) Button:
  88.  
  89.    A  Button  consists  of  a  rectangular border containing a text string.
  90. When a button is selected by the user, the requester is removed and control
  91. returns to ARexx.  The OK and Cancel gadgets that appear on most requesters
  92. in OpalPaint are examples of buttons.
  93.  
  94. 2) Toggle:
  95.  
  96.    A  Toggle  gadget is the same in appearance as a button.  However when a
  97. toggle is selected it simply depresses, showing the user that the gadget is
  98. selected.   For  example, the DrawModes requester in OpalPaint contains one
  99. toggle gadget for each available drawmode, the currently active drawmode is
  100. shown as depressed.
  101.  
  102. 3) Check:
  103.  
  104.   A  Check gadget appears as a small rectangular box, when the user selects
  105. a  check  gadget,  a  check  mark (tick) appears within the box.  The check
  106. gadget,  unlike  the last 2 gadget types, does not have any text associated
  107. with  it,  but  text  can  be  added  later.   The Preferences requester in
  108. OpalPaint contains a Check gadget for each available preference option.
  109.  
  110. 4) HProp:
  111.  
  112.   A HProp gadget is a horizontal proportional (slider) gadget.  This gadget
  113. allows  the  user  to  select a number within a given range by dragging the
  114. slider within the gadgets container.  The current value is displayed to the
  115. right of the gadgets container.
  116.  
  117. 5) VProp:
  118.  
  119.    A  VProp  gadget  is  identical  in operation to a HProp except that the
  120. gadget is displayed vertically rather than horizontally.  The current value
  121. for the gadget is displayed below the gadgets container.
  122.  
  123. 6) Cycle:
  124.  
  125.   A  Cycle  gadget  has  similar imagery to a button, (a rectangular border
  126. containing  text),  with  the  addition of a cycle arrow at the left of the
  127. gadget  to indicate that it is a cycle gadget.  The Cycle gadget allows the
  128. user  to  cycle through a list of available choices by simply selecting it.
  129. The currently selected choice is displayed as text in the gadget.
  130.  
  131. 7) String:
  132.  
  133.    A string gadget is used for text entry.  This gadget appears as a raised
  134. border  with  the current text string displayed in it.  The user can modify
  135. the text in the gadget by selecting it and typing in a new value.
  136.  
  137.  
  138. 8) Integer:
  139.  
  140.    An  integer  gadget  is  identical in appearance as a string gadget.  An
  141. integer gadget however will only allow the user to enter an integer numeric
  142. value.
  143.  
  144.                         GADGET NAMES
  145.  
  146.   Each  gadget is given a name which is used to reference the gadget in any
  147. subsequent  commands.   Each  gadget name must be unique.  This name is not
  148. case sensitive.
  149.  
  150.   The  names  "Okay" and "Cancel" are reserved and cannot be used as gadget
  151. names.
  152.  
  153.  
  154.                         POSITIONING ELEMENTS
  155.  
  156.    There  are several methods that can be used to position elements such as
  157. Gadgets, Text and Boxes within the requester.
  158.  
  159.    The  positioning can be an absolute position in pixels, in this case the
  160. position  is  simply  specified  as two integers in "x y" format.  If the x
  161. value is positive then the horizontal position is relative to the left hand
  162. edge  of  the  requester, if the x value is negative then it is relative to
  163. the  right  hand  edge  of  the  requester.  Likewise a positive y value is
  164. relative to the top and a negative y value is relative to the bottom of the
  165. requester.  The position being specified is always the top-left hand corner
  166. of the element (gadget etc).
  167.  
  168.   Examples:
  169.         10 10   ; Place element 10 pixels from the top-left of the requester.
  170.         -100 50 ; Place element 100 pixels from the right and 50 form the top.
  171.  
  172.    The  x  y  parameters  can  also  be changed to the keywords CenterX and
  173. CenterY,  which  will center the object horizontally and/or vertically with
  174. respect to the requester.
  175.  
  176.   Examples:
  177.         CenterX CenterY   ;Place element in the center of the requester.
  178.         CenterX 20        ;Place element in Center Horizontally and at y=20.
  179.  
  180.  
  181.   An  element can also be positioned relative to a gadget which has already
  182. been added to the requester. To use relative positioning, you need to specify
  183. one of the relative keywords along with the gadget name to be used as a 
  184. reference, followed by an x y offset to set the spacing between the element
  185. and the gadget. i.e. [Relative Keyword] [GadName] [x y]
  186.  
  187.   The currently available relative keywords are Above, Below, Left, Right.
  188.  
  189. Examples:
  190.         Below Gadget1 0 10        ;10 pixels below Gadget1.
  191.         Above Gadget1 0 -10       ;10 pixels below Gadget1.
  192.         Right Gadget1 20 0        ;20 pixels right of Gadget1.
  193.         Left Gadget1 -20 0        ;20 pixels left of Gadget1.
  194.         Above Gadget1 CenterX -10 ;10 pixel above Gadget1, Centered horizontally.
  195.  
  196.  
  197. NOTES:  1 - The gadget must have already been added using AddGadget.
  198.         2 - The x y offset is signed, so a negative y will move the
  199.             object upwards while a positive value will move it downwards.
  200.  
  201.  
  202. TIP:  The quickest and easiest way to create a requester is to position one
  203. gadget  using  absolute  positioning  and  then use relative positioning to
  204. place the gadgets around it.
  205.  
  206.  
  207.  
  208.                         COMMAND SUMMARY
  209.  
  210.         ReqBuild
  211.         Usage: ReqBuild w h Heading
  212.  
  213.  This  command  starts the requester building process, this command MUST be
  214. issued  before any of the other requester commands.  The only parameters to
  215. this  command  are  the width and height (in pixels) of the requester and a
  216. heading string which will be displayed at the top of the requester.
  217.  
  218.  Example:
  219.         ReqBuild '400 200 "My ARexx Options"'
  220.  
  221.  
  222.  
  223.         AddGadget
  224.         Usage: AddGadget GadgetName GadgetType Position Size TypeInfo
  225.  
  226.  This  command  is  used  to  create  a  new gadget for the requester.  The
  227. GadgetName,  GadgetType  and Position parameters have been described in the
  228. sections above.
  229.  
  230.   The  Size  parameter  specifies  the  size  of the gadget.  This size can
  231. either  be  one  of  the  3  available  default  sizes "Small","Medium" and
  232. "Large",  or  a custom size can be specified by giving the gadget width and
  233. height in pixels.
  234.  
  235.   The  TypeInfo  parameter  is  any  additional parameters required for the
  236. particular  gadget type, the additional parameters for each gadget type are
  237. described below:
  238.  
  239.  
  240. 1) Button:
  241.    The  only  additional  parameter  for this gadget type is the text which
  242. will appear within the gadget.
  243.  
  244. 2) Toggle:
  245.    The  only  additional  parameter  for this gadget type is the text which
  246. will appear within the gadget.
  247.  
  248. 3) Check:
  249.    There are no additional parameters for this gadget type.
  250.  
  251.   NOTE:   Currently  the  Check  gadget only comes in one size.  For future
  252. compatibility you should specify "Medium" for all check gadgets.
  253.  
  254. 4) HProp:
  255.    Additional prop gadget parameters are:
  256.  
  257.         MinValue MaxValue [Steps [Percent]]
  258.  
  259.    The  MinValue  and  MaxValue  parameters  set the numeric range that the
  260. slider  will cover.  The optional step parameter sets the stepping distance
  261. (granularity)  of  the  slider,  the  default  step is 1.  If the "Percent"
  262. keyword  is  specified  a  percentage sign will be printed after the slider
  263. value.
  264.  
  265.   Examples:
  266.  
  267.         0 100            ;Simple slider with range 0 to 100
  268.         0 100 5          ;Slider with range of 0 to 100 in steps of 5
  269.         -50 50 0.1       ;Slider with range -50 to 50 in steps of 0.1
  270.         0 100 1 Percent  ;A Percentage slider with range 0% to 100%
  271.  
  272. 5) VProp:
  273.    The VProp parameters are identical to the HProp gadget type.
  274.  
  275. 6) Cycle:
  276.    The  aditional  parameters  to  the  cycle gadget are simply the list of
  277. available choices for that gadget.
  278.  
  279.   Example:
  280.  
  281.         '"A500" "A1000" "A2000" "A4000"'   ;Cycle gadget with 4 choices.
  282.  
  283. 7) String:
  284.    The  string  gadget  takes  only  1  parameter.  This optional parameter
  285. describes  the  maximum  number  of characters that can be entered into the
  286. string gadget.  If this is not specified then 200 is used.
  287.  
  288.   NOTE:   Currently  only  the  Width parameter is recognised by the String
  289. gadget, for future compatibility you should specifiy the height of a string
  290. gadget as 10 if you are not using one of the default sizes.
  291.  
  292.  
  293. 8) Integer:
  294.    Additional parameters are:
  295.  
  296.         [MinValue MaxValue]
  297.  
  298.    The  optional  MinValue  MaxValue  parameters set the allowable range of
  299. values  that can be entered by the user.  If these values are not specified
  300. then there will be no limits on the range.
  301.  
  302.   NOTE:   Currently  only  the Width parameter is recognised by the Integer
  303. gadget,  for  future  compatibility  you  should  specifiy  the height of a
  304. Integer gadget as 10 if you are not using one of the default sizes.
  305.  
  306.  
  307.         PUTTING IT ALL TOGETHER
  308.  
  309.   Examples of the AddGadget Command:
  310.  
  311. 1)      AddGadget 'Button Gad1 100 50 Medium "Render"'
  312.  
  313. This command adds a button with the text 'Render' appearing in it.
  314.  
  315.  
  316. 2)      AddGadget 'Toggle Gad1 100 50 Medium "Motion Blur"'
  317.  
  318.    This  command  adds  a  toggle gadget that enables the user to enable or
  319. disable motion blur.
  320.  
  321.  
  322. 3)      AddGadget 'Check Gad1 100 50 Medium'
  323.  
  324.  
  325. 4)      AddGadget 'HProp Gad1 100 50 Large 0 100 1 Percent'
  326.  
  327.   This creates a slider with the range of 0 to 100, the value is displayed
  328. as a percentage.
  329.  
  330.  
  331. 5)      AddGadget 'HProp Gad1 10 50 Medium -10 10 0.1'
  332.  
  333.    This creates a slider with a range of -10 to 10 in steps of 0.1.
  334.  
  335.  
  336. 6)      AddGadget 'Cycle Gad1 100 50 Medium  A500 A1000 A2000 A2500 A4000'
  337.  
  338.   This  creates a cycle gadget which allows the user to select his computer
  339. type from a list of 5 possible choices.
  340.  
  341.  
  342. 7)      AddGadget 'String Gad1 100 50 Medium'
  343.  
  344. 8)      AddGadget 'String Gad1 100 50 Medium 30'
  345.  
  346.    String gadget that accepts up to 30 characters.
  347.  
  348.  
  349. 9)      AddGadget 'Integer Gad1 100 50 Medium'
  350.  
  351. 10)     AddGadget 'Integer Gad1 100 50 Medium 0 10'
  352.  
  353.    Integer gadget that accepts a range of 0 to 10.
  354.  
  355.  
  356. 11)     AddGadget 'Button Gad2 Below Gad1 0 -10 Small "Done"'
  357.  
  358.    Add a button 10 pixels below Gad2 with the text "Done" in it.
  359.  
  360.  
  361.  
  362.  
  363.  
  364.         AddText
  365.         Usage:  AddText Position Text
  366.  
  367.   This  command is used to add text to the requester.  The text positioning
  368. is described above.
  369.  
  370. Example:
  371.         AddText 'Left Gad1 -10 0 "Enable Motion Blur"'
  372.  
  373.  
  374.  
  375.         AddHeading
  376.         Usage:  AddHeading Position Text
  377.  
  378.   This  command  is  similar  to AddText, except that the text is displayed
  379. with  a  drop  shadow  to  make  it stand out.  This should be reserved for
  380. headings only.
  381.  
  382.         AddBox
  383.         Usage: AddBox Position Size [Raised]
  384.  
  385.   This  adds  a bevelled box to the requester.  The position can be relative
  386. or  absolute,  note however that the position is only for the top left-hand
  387. corner  of the box and not the complete box itself.  This means that if you
  388. specifiy  a  box  to  be  placed  above  a  gadget  the  whole box will not
  389. necessarily be above that gadget, only the top left corner will be.
  390.  
  391.   The  box size is always specified in pixels (there are no default sizes).
  392. If the 'Raised' keyword is specified the box will appear raised rather than
  393. recessed.
  394.  
  395. Examples:
  396.         AddBox 10 10 100 100
  397.         AddBox Above Gad1 -10 10 100 100 Raised
  398.  
  399.   The second example places the top left corner of the box 10 pixels above and
  400. to the left of Gad1. The box is 100x100 and is recessed.
  401.  
  402.  
  403.  
  404.         InitGadget
  405.         Usage: InitGadget GadName InitValue
  406.  
  407.   Before  the  requester  is  displayed,  the gadgets can be initialised to
  408. default  values  using this command.  The initial value varies depending on
  409. the gadget type.  The parameter for each gadget types are:
  410.  
  411.         Button  - Cannot be initialised (has no state).
  412.         Toggle  - Either 'Selected' 'Unselected' '0' or '1'.
  413.         Check   - Either 'Selected' 'Unselected' '0' or '1'.
  414.         HProp   - Numeric value within valid slider range.      
  415.         VProp   - Numeric value within valid slider range.      
  416.         Cycle   - Any entry which was defined in the cycle list.
  417.         String  - Text string up to the maximum length the gadget can hold.
  418.         Integer - Integer value in the valid range for the gadget.
  419.  
  420.   For the Toggle and Check values, '1' is equivalent to 'Selected' and
  421. '0' is equivalent to Unselected.
  422.  
  423.    Examples:
  424.  
  425.         InitGadget Toggle1 Selected
  426.         InitGadget Check1 1
  427.         InitGadget HorizProp 10
  428.         InitGadget Cycle1 A4000
  429.         InitGadget String1 'Ram:Temp'
  430.         InitGadget Integer1 10
  431.  
  432.  
  433.  
  434.         MutualEx
  435.         Usage: MutualEx [Gad1 Gad2 Gad3 ...]
  436.  
  437.   A  Group of Check or Toggle gadgets can be defined to exclude each other.
  438. If a gadget within a Mutual Exclude group is selected, all other gadgets in
  439. that  group  are  deselected,  this  means that only one gadget can ever be
  440. selected at one time.
  441.  
  442.   By  specifying  more  than  1 MutualEx command, multiple Mutual Exclusion
  443. groups can be set up.
  444.  
  445.   Example: This creates a requester similar to the transparency requester.
  446.  
  447.         AddGadget 'Toggle Std 50 30 Medium "Standard"'
  448.         AddGadget 'Toggle RGB Below Std 0 10 Medium "RGB"'
  449.         AddGadget 'Toggle HSV Below RGB 0 10 Medium "HSV"'
  450.         AddGadget 'Toggle Alpha Below HSV 0 10 Medium "Alpha"'
  451.         MutualEx Std RGB HSV Alpha
  452.  
  453.   NOTE:   Mutual  exclusion  is only possible for toggle and check gadgets.
  454. Only the first 32 gadgets in a requester can take part in Mutual exclusion.
  455.  
  456.  
  457.         Request
  458.         Usage:  Request [NoOK] [NoCancel]
  459.  
  460.   Once  the requester had been defined, this command is used to display the
  461. requester.   When  the requester exits, the returned value will be either 1
  462. if OK or a Button gadget was hit, and 0 if cancel was hit.
  463.  
  464.   This  command  accepts  2  parameters,  "NoCancel"  to create a requester
  465. without a cancel gadget, and "NoOK" for a requester without an Okay gadget.
  466.  
  467.  
  468.         GadgetStatus
  469.         Usage: GadgetStatus GadName
  470.  
  471.    Once  the  requester  has  completed,  the  status of any gadgets can be
  472. interrogated using this command.  The return value from this command varies
  473. depending on the gadget type:
  474.  
  475.         Button  - 1 if gadget was hit (and closed requester), else 0.
  476.         Toggle  - 1 if gadget was selected, else 0.
  477.         Check   - 1 if gadget was selected, else 0.
  478.         HProp   - Numeric value within valid slider range.
  479.         VProp   - Numeric value within valid slider range.
  480.         Cycle   - Any entry which was defined in the cycle list.
  481.         String  - Text string entered into the gadget.
  482.         Integer - Integer value entered into gadget.
  483.  
  484.  
  485.   The  2 reserved gadget names, "Okay" and "Cancel" can also be used by the
  486. command to determine if the Okay or Cancel gadget was hit by the User.  i.e
  487. the following command can be used to check if the OK gadget was hit.
  488.  
  489.         GadgetStatus Okay
  490.         if Result=1 then OKHit
  491.  
  492.  
  493.  
  494.