home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PILOT / PC / PILAASSM / PILRC.ZIP / PILRC.TXT < prev    next >
Encoding:
Text File  |  1996-10-04  |  8.2 KB  |  252 lines

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