home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PILOT / PC / RESCOMP / PILRC.TXT < prev    next >
Encoding:
Text File  |  1996-09-02  |  8.1 KB  |  239 lines

  1. /*-----------------------------------------------------------------------------
  2. pilrc.c -- a resource compiler for the pilot
  3.  
  4. usage:
  5.  
  6. pilrc [-L LANGUAGE] infile [outdir]
  7.  
  8. infile is a file describing the resources to be emitted.  Each resource is written as a seperate file in the
  9. [outdir] directory.  The output filename is constructed by appending the hexcode resource id to the four character
  10. resource type.  For example, a FORM (tFRM) with formid of 15 would be written as tfrm000f.bin.
  11.  
  12.  
  13. SYNTAX
  14. ------
  15. Pilrc's syntax is described below.  Items in all CAPS appear as literals in the file.  Items enclosed in < and > are 
  16. required fields.  The type is indicated by a suffix after the field name (see below for types).  
  17. Items inclosed in [ and ] are optional fields.
  18.  
  19. types
  20. -----
  21. .s  = string 
  22.       example:  "Click Me"
  23.  
  24. .ss = multi line string.  pilrc will concatenate strings on seperate lines enclosed with quotes and terminated by the \ character
  25.       example:  "Now is the time for all good "\ 
  26.                 "men to come to the aid of their country"
  27.  
  28. .n = number or simple arithmetic expression.  Valid operators are + - * /.  precedence is left to right. math is integer.
  29.       examples: 23 12+3+1 12*4 14*3+5/2
  30.  
  31. .p = position coordinate.  Which may be either a number, expression or one of the following keywords
  32.     AUTO       : Automatic width or height.  The width/height of the item is computed based on the text in the item.  
  33.                  valid only for widths or heights of items.
  34.     CENTER     : Centers the item either horizontally or vertically.  Only valid for left or top cooredinate of an item.
  35.     PREVLEFT   : Previous items left coordinate
  36.     PREVRIGHT  : Previous items right coordinate
  37.     PREVWIDTH  : Previous items width
  38.     PREVTOP    : Previous items top coordinate
  39.     PREVBOTTOM : Previous items bottom coordinate
  40.     PREVHEIGHT : Previous items height
  41.     
  42.     example: PREVRIGHT+2 
  43.     
  44.     NOTE:  AUTO and CENTER must stand alone and are not valid in arithmetic expressions
  45.     exmaples
  46.  
  47.  
  48.  
  49. FORM (tFRM) syntax
  50. ------------------
  51. FORM <FormResourceId.n> <Left.p> <Top.p> <Width.p> <Height.p>
  52. [FRAME]
  53. [NOFRAME]
  54. [MODAL]
  55. [SAVEBEHIND]
  56. [USABLE]
  57. [HELPID <HelpId.n>]
  58. [DEFAULTBTNID <BtnId.n>]
  59. [MENUID <MenuId.n>]
  60. BEGIN
  61.     <OBJECTS>
  62. END
  63.  
  64. <OBJECTS>: one or more of:
  65.  
  66. TITLE           <Title.s>
  67. BUTTON          <Label.s> <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FRAME] [NOFRAME] [BOLDFRAME] [FONT <FontId.n>]
  68. PUSHBUTTON      <Label.s> <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId>] [GROUP <GroupId.n>]
  69. CHECKBOX        <Label.s> <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId>] [GROUP <GroupId.n>] [CHECKED]
  70. POPUPTRIGGER    <Label.s> <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId>]
  71. SELECTORTRIGGER <Label.s> <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT <FontId>]
  72. REPEATBUTTON    <Label.s> <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FRAME] [NOFRAME] [BOLDFRAME] [FONT <FontId.n>]
  73. LABEL           <Label.s> <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [FONT <FontId>]
  74. FIELD           <Id.n> <Left> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [LEFTALIGN] [RIGHTALIGN] [FONT <FontId>] [EDITABLE] [NONEDITABLE] [UNDERLINED] [SINGLELINE] [MULTIPLELINES] [Height.pNAMICSIZE] [MAXCHARS <maxchars>]
  75. POPUPLIST       <Id.n> <idList>
  76. LIST            <Item.s> <Item2.s>... <Id.n> <Left.p> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABLE] [DISABLED] [VISIBLEITEMS <numvisitems>] [FONT <FontId.n>]
  77. FORMBITMAP      <Id.n> <x> <y> [BITMAP <BitmapId> [NONUSABLE]  
  78. GRAFFITISTATEINDICATOR  <Left.p> <Top.p>
  79. GADGET          <Id.n> <Left> <Top.p> <Width.p> <Height.p> [USABLE] [NONUSABE]
  80. TABLE NYI!
  81.  
  82.  
  83. Example: (this is a cliff notes version of AlarmHack's resource)
  84. FORM 1 2 2 156 156
  85. USABLE
  86. MODAL
  87. HELPID 1
  88. MENUID 1
  89. BEGIN
  90.     TITLE "AlarmHack"
  91.     LABEL "Repeat Datebook alarm sound" 2000 CENTER 16 
  92.     PUSHBUTTON "1" 2001 20 PrevBottom+2 12 AUTO GROUP 1
  93.     PUSHBUTTON "2" 2002 PrevRight+1  PrevTop PrevWidth PrevHeight GROUP 1
  94.     PUSHBUTTON "3" 2003 PrevRight+1  PrevTop PrevWidth PrevHeight GROUP 1
  95.  
  96.     LABEL "times.  Ring again every" 601 CENTER PrevBottom+2 FONT 0
  97.  
  98.     PUSHBUTTON "never" 3000 13 PrevBottom+2 32 12 GROUP 2
  99.     PUSHBUTTON "10 sec" 3001 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 2
  100.     PUSHBUTTON "30 sec" 3002 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 2
  101.     PUSHBUTTON "1 min" 3003 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 2
  102.  
  103.     LABEL "Alarm sound:" 601 24 PrevBottom+4
  104.     POPUPTRIGGER "          " 5000 PrevRight+4 PrevTop 62 AUTO LEFTANCHOR
  105.     LIST "Standard" "Two Tone" "Sine" "Computer" "Skip Along" "Beethoven" "EuroCop" "Cricket" "Bleep" "Computer2" 6000 PrevLeft PrevTop 52 1 VISIBLEITEMS 10 NONUSABLE
  106.     POPUPLIST 5000 6000
  107.  
  108.     BUTTON "Test" 1202 CENTER 138 AUTO AUTO
  109.     GRAFFITISTATEINDICATOR  100 100
  110. END
  111.  
  112.  
  113.  
  114. MENU (MBAR) syntax:
  115. -------------------
  116. MENU <MenuResourceId>
  117. BEGIN
  118.     <PULLDOWNS>
  119. END
  120.  
  121.  
  122. <PULLDOWNS>: one or more of:
  123.  
  124. PULLDOWN <PulldownTitle.s>
  125. BEGIN
  126.     <MENUITEMS>
  127. END
  128.  
  129. <MENUITEMS>: : one or more of:
  130.     MENUITEM <MenuItem.s> <MenuItemId.n> [AccelChar.c]
  131.  
  132. Example:
  133. MENU 100
  134. BEGIN
  135.     PULLDOWN "File"
  136.     BEGIN
  137.         MENUITEM "Open..." 100 "O"    
  138.         MENUITEM "Close" 101 "C"
  139.     END
  140.     PULLDOWN "Options"
  141.     BEGIN
  142.         MENUITEM "Get Info..." 500 "I"
  143.     END
  144. END
  145.  
  146.  
  147. ALERT (tALT) syntax:
  148. --------------------
  149. ALERT <AlertResrouceId.n>
  150. [HELPID <HelpId.n>]
  151. [INFORMATION] [CONFIRMATION] [WARNING] [ERROR]
  152. BEGIN
  153.     TITLE <Title.s>
  154.     MESSAGE <Message.ss>
  155.     BUTTONS <Button.s> <BUTTON.s>...
  156. END
  157.  
  158. Example:
  159. ALERT 1000
  160. HELPID 100
  161. CONFIRMATION
  162. BEGIN
  163.     TITLE "AlarmHack"
  164.     MESSAGE "Continuing will cause you 7 years of bad luck\n"\
  165.         "Are you sure?"
  166.     BUTTONS "Ok" "Cancel"
  167. END
  168.  
  169.  
  170. VERSION (tVER) syntax:
  171. ----------------------
  172. VERSION <VersionResourceId.n> <Version.s>
  173.  
  174. Example:
  175. VERSION 1 "0.09"
  176.  
  177.  
  178. STRING (tSTR) syntax:
  179. ---------------------
  180. STRING <StringResourceId.n> <String.ss>
  181.  
  182. Example:
  183. STRING 100 "This is a very long string that demonstrates carriage retuns\n"
  184.     "as well as continued .ss syntax strings"
  185.  
  186. APPLICATIONICONNAME (tAIN) syntax:
  187. ----------------------------------
  188. APPLICATIONICONNAME <AINResourceId.n> <ApplicationName.s>
  189.  
  190. Example:
  191. APPLICATIONICONNAME 100 "AlarmHack"
  192.  
  193. APPLICATION (APPL) syntax:
  194. --------------------------
  195. APPLICATION <ApplResourceId.n> <APPL.s> 
  196.  
  197. (APPL must be 4 chars)
  198.  
  199. Example:
  200. APPLICATION 1 "ALHK"
  201.  
  202. -------------------------------------------------------------------------------------------------------------
  203.  
  204. INTERNATIONAL SUPPORT:
  205. Pilrc supports a limited form of international tokenization.  It works by substituting strings in the resource
  206. definitions with replacements specified in a TRANSLATION section.  Multiple translation blocks may be specified 
  207. in a resource script.  The active language is specified with the -L flag to pilrc.  
  208. (Yeah, I know this is a pretty cheezy way to do this, but it has worked so far.  The biggest problem is
  209. with positioning of controls.  If you use AUTO, CENTER and PREVRIGHT et al it might not involve any position changing
  210. in your script.  If you do need to change the position, Right now the only workaround is to put some #ifdefs
  211. in your file and hook up a custom rule to preprocess your source file)
  212.  
  213. Example:
  214. pilrc -L FRENCH myscript.rcp res\
  215.  
  216. TRANSLATION syntex
  217. ------------------
  218. TRANSLATION <Language.s>
  219. BEGIN
  220.     <STRINGTRANSLATIONS>
  221. END
  222.  
  223. where <STRINGTRANSLATINOS> is one or more of:
  224. <Original.s> = <Translated.ss>
  225.  
  226. Example:
  227. TRANSLATION "FRENCH"
  228. BEGIN
  229.     "Repeat Datebook alarm sound" = "RΘpΘtitions Alarme Agenda" 
  230.     "Ring again every" = "Rappel tous les" 
  231. END
  232.  
  233. TIP:  For long strings define a short keyword and then define both native and foriegn
  234. translations for it.  
  235.  
  236. -------------------------------------------------------------WESC------------*/
  237.  
  238.  
  239.