/*--------------------------------------------------------------------------- pilrc.c -- a resource compiler for the pilot by Wes Cherry wesc@ricochet.net usage: pilrc [-L LANGUAGE] infile [outdir] infile is a file describing the resources to be emitted. Each resource is written as a seperate file in the [outdir] directory. The output filename is constructed by appending the hexcode resource id to the four character resource type. For example, a FORM (tFRM) with formid of 15 would be written as tfrm000f.bin. SYNTAX ------ Pilrc's syntax is described below. Items in all CAPS appear as literals in the file. Items enclosed in < and > are required fields. The type is indicated by a suffix after the field name (see below for types). Items inclosed in [ and ] are optional fields. types ----- .s = string example: "Click Me" .ss = multi line string. pilrc will concatenate strings on seperate lines enclosed with quotes and terminated by the \ character example: "Now is the time for all good "\ "men to come to the aid of their country" .n = number or simple arithmetic expression. Valid operators are + - * /. precedence is left to right. math is integer. examples: 23 12+3+1 12*4 14*3+5/2 .p = position coordinate. Which may be either a number, expression or one of the following keywords AUTO : Automatic width or height. The width/height of the item is computed based on the text in the item. valid only for widths or heights of items. CENTER : Centers the item either horizontally or vertically. Only valid for left or top coordinate of an item. PREVLEFT : Previous items left coordinate PREVRIGHT : Previous items right coordinate PREVWIDTH : Previous items width PREVTOP : Previous items top coordinate PREVBOTTOM : Previous items bottom coordinate PREVHEIGHT : Previous items height example: PREVRIGHT+2 NOTE: AUTO and CENTER must stand alone and are not valid in arithmetic expressions FORM (tFRM) syntax ------------------ FORM [FRAME] [NOFRAME] [MODAL] [SAVEBEHIND] [USABLE] [HELPID ] [DEFAULTBTNID ] [MENUID ] BEGIN END : one or more of: TITLE BUTTON [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FRAME] [NOFRAME] [BOLDFRAME] [FONT ] PUSHBUTTON [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT ] [GROUP ] CHECKBOX [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT ] [GROUP ] [CHECKED] POPUPTRIGGER [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT ] SELECTORTRIGGER [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FONT ] REPEATBUTTON [USABLE] [NONUSABLE] [DISABLED] [LEFTANCHOR] [RIGHTANCHOR] [FRAME] [NOFRAME] [BOLDFRAME] [FONT ] LABEL [USABLE] [NONUSABLE] [FONT ] FIELD [USABLE] [NONUSABLE] [DISABLED] [LEFTALIGN] [RIGHTALIGN] [FONT ] [EDITABLE] [NONEDITABLE] [UNDERLINED] [SINGLELINE] [MULTIPLELINES] [Height.pNAMICSIZE] [MAXCHARS ] POPUPLIST LIST ... [USABLE] [NONUSABLE] [DISABLED] [VISIBLEITEMS ] [FONT ] FORMBITMAP [BITMAP [NONUSABLE] GRAFFITISTATEINDICATOR GADGET [USABLE] [NONUSABE] TABLE NYI! Example: (this is a cliff notes version of AlarmHack's resource) FORM 1 2 2 156 156 USABLE MODAL HELPID 1 MENUID 1 BEGIN TITLE "AlarmHack" LABEL "Repeat Datebook alarm sound" 2000 CENTER 16 PUSHBUTTON "1" 2001 20 PrevBottom+2 12 AUTO GROUP 1 PUSHBUTTON "2" 2002 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 1 PUSHBUTTON "3" 2003 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 1 LABEL "times. Ring again every" 601 CENTER PrevBottom+2 FONT 0 PUSHBUTTON "never" 3000 13 PrevBottom+2 32 12 GROUP 2 PUSHBUTTON "10 sec" 3001 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 2 PUSHBUTTON "30 sec" 3002 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 2 PUSHBUTTON "1 min" 3003 PrevRight+1 PrevTop PrevWidth PrevHeight GROUP 2 LABEL "Alarm sound:" 601 24 PrevBottom+4 POPUPTRIGGER " " 5000 PrevRight+4 PrevTop 62 AUTO LEFTANCHOR LIST "Standard" "Two Tone" "Sine" "Computer" "Skip Along" "Beethoven" "EuroCop" "Cricket" "Bleep" "Computer2" 6000 PrevLeft PrevTop 52 1 VISIBLEITEMS 10 NONUSABLE POPUPLIST 5000 6000 BUTTON "Test" 1202 CENTER 138 AUTO AUTO GRAFFITISTATEINDICATOR 100 100 END MENU (MBAR) syntax: ------------------- MENU BEGIN END : one or more of: PULLDOWN BEGIN END : : one or more of: MENUITEM [AccelChar.c] Example: MENU 100 BEGIN PULLDOWN "File" BEGIN MENUITEM "Open..." 100 "O" MENUITEM "Close" 101 "C" END PULLDOWN "Options" BEGIN MENUITEM "Get Info..." 500 "I" END END ALERT (tALT) syntax: -------------------- ALERT [HELPID ] [INFORMATION] [CONFIRMATION] [WARNING] [ERROR] BEGIN TITLE MESSAGE BUTTONS ... END Example: ALERT 1000 HELPID 100 CONFIRMATION BEGIN TITLE "AlarmHack" MESSAGE "Continuing will cause you 7 years of bad luck\n"\ "Are you sure?" BUTTONS "Ok" "Cancel" END VERSION (tVER) syntax: ---------------------- VERSION Example: VERSION 1 "0.09" STRING (tSTR) syntax: --------------------- STRING Example: STRING 100 "This is a very long string that demonstrates carriage retuns\n" \ "as well as continued .ss syntax strings" APPLICATIONICONNAME (tAIN) syntax: ---------------------------------- APPLICATIONICONNAME Example: APPLICATIONICONNAME 100 "AlarmHack" APPLICATION (APPL) syntax: -------------------------- APPLICATION (APPL must be 4 chars) Example: APPLICATION 1 "ALHK" ----------------------------------------------------------------------------- INTERNATIONAL SUPPORT: Pilrc supports a limited form of international tokenization. It works by substituting strings in the resource definitions with replacements specified in a TRANSLATION section. Multiple translation blocks may be specified in a resource script. The active language is specified with the -L flag to pilrc. (Yeah, I know this is a pretty cheezy way to do this, but it has worked so far. The biggest problem is with positioning of controls. If you use AUTO, CENTER and PREVRIGHT et al it might not involve any position changing in your script. If you do need to change the position, Right now the only workaround is to put some #ifdefs in your file and hook up a custom rule to preprocess your source file) Example: pilrc -L FRENCH myscript.rcp res\ TRANSLATION syntex ------------------ TRANSLATION BEGIN END where is one or more of: = Example: TRANSLATION "FRENCH" BEGIN "Repeat Datebook alarm sound" = "Répétitions Alarme Agenda" "Ring again every" = "Rappel tous les" END TIP: For long strings define a short keyword and then define both native and foriegn translations for it. -------------------------------------------------------------WESC----------*/