home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Localization Tools / Localization using Resorcerer® / Resorcerer Notes for Developers next >
Encoding:
Text File  |  1996-08-23  |  5.1 KB  |  79 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Setting up Resorcerer Templates for View Layouts
  6. Containing Custom View Types                                           
  7.  
  8.  
  9. The Resorcerer template ('TMPL') used to open framework view layout ('FWvl') resources for localization relies on class tags stored within the resource data for information about how it should parse the resource into a series of editable fields.  Support for class tags representing all standard ODF view types is included in the template; however, many developers will want to create their own custom view types derived from the standard types, and will use unique class tags to identify their types.
  10.  
  11. In order to edit view layouts containing custom views with Resorcerer, the 'FWvl' template must first be modified to accomodate the new types.  To do this, open the 'TMPL' resource named "FWvl" in the "ODF Templates" file (or use the "Old ODF Templates" file if you're building your part with ODF 1.0).  Near the top of the template definition is a series of CASE statements:
  12.  
  13.     ‘CASE’    View Layout=root
  14.     ‘CASE’    FW_RView=view
  15.     ‘CASE’    FW_RSuperView=suvw
  16.                 .
  17.                 .
  18.                 .
  19.     ‘CASE’    RCustomView=Cvie
  20.     ‘CASE’    RCustomSuperView=Csuv
  21.     ‘CASE’    RCustomControl=Ccon
  22.     ‘CASE’    RCustomNativeControl=Cncn
  23.     ‘CASE’    RCustomButton=Cbut
  24.     ‘CASE’    RCustomPopUpMenu=Cpop
  25.     ‘CASE’    RCustomScrollBar=Cscb
  26.     ‘CASE’    RCustomGrowBox=Cgrb
  27.     ‘CASE’    RCustomListBox=Clbo
  28.     ‘CASE’    RCustomStaticText=Cstx
  29.     ‘CASE’    RCustomGroupBox=Cgpb
  30.     ‘CASE’    RCustomEditView=Cedv
  31.     ‘CASE’    RCustomPictSView=Cpic
  32.  
  33. The last set of CASE statements (those with labels beginning “RCustom...”) are placeholders for your custom view types.  If the custom view type doesn't add any new fields to the standard type from which it is derived, just double-click on the CASE label corresponding to the view type you're extending and replace the four-character class tag after the '=' with the class tag you used for your type.  (For instance, if you extended FW_RButton and labeled your class 'MyBt', you could modify the template to work with your class by double-clicking on the CASE label for RCustomButton and changing "RCustomButton=Cbut" to "RCustomButton=MyBt".)
  34.  
  35. The situation becomes slightly more complicated if you derive multiple custom views from a single standard view class.  If this is the case, you must first duplicate the CASE label for the placeholder custom resource type (the easiest way to do this is to Cut and then Paste twice, because Resorcerer automatically positions the insertion caret—the small black triangles on the sides of the window—after a Cut).  Next, you can modify each of the class tags after the '=' signs in the CASE labels to one of your derived class tags.  Finally, scroll down in the template to the actual definition of the data fields for the resource type you're using (it will be in the form of a KEYB/KEYE block labeled with the class tag of the placeholder custom type, beginning with a 'C'), and select and duplicate the entire definition, including the KEYB/KEYE fields.  Note that Resorceror matches CASE labels with KEYB/KEYE blocks only by their ordering in the template, not by their labels, so it's important that you insert the additional CASE field and data definition blocks in corresponding locations.  (There must be exactly one KEYB/KEYE block for each CASE statement.)  You don't need to change the labels on the KEYB/KEYE statements after duplicating them, although it might be a good idea if it helps you keep track of which is which.
  36.  
  37. All of the above has assumed that the custom view type used hasn't added any additional data fields to the existing view types.  If additional fields have been added, you'll have to add template fields corresponding to your additional data fields right before the appropriate KEYE tag in the template.  Template tags for some the most common data types in ODF views are:
  38.  
  39.  DWRD        Decimal word
  40.     HWRD        Hex word
  41.     DLNG        Decimal long
  42.     HLNG        Hex long
  43.     FIXD        Fixed-point value
  44.     BFLG        One-byte Boolean flag
  45.     CSTR        Null-terminated C string
  46.     WSTR        String preceded by a length word
  47.     SCPC        Script code
  48.     LNGC        Language code
  49.     Hxxx     $xxx bytes of hex data (for instance, H00A for ten bytes of hex data)
  50.  
  51. In addition, you can represent a counted array with a series of fields as follows:
  52.  
  53.     ‘OCNT’    Number of array entries
  54.     ‘LSTC’    •••••
  55.             (data in array elements)
  56.     ‘LSTE’    •••••
  57.  
  58. The OCNT field is a two-byte, one-based count of the number of elements in the array; the LSTC and LSTE are just placeholders indicating the beginning and end of the counted list.  As an example, this code from the ODFRC definition for a radio cluster:
  59.  
  60.     integer = $$CountOf(RadioArray);
  61.     array RadioArray
  62.     {
  63.         RadioId:
  64.             longint;
  65.     };
  66.  
  67. ...is expressed in the Resorcerer TMPL as:
  68.  
  69.     ‘OCNT’    RadioArray
  70.     ‘LSTC’    •••••
  71.         ‘DLNG’    RadioId
  72.     ‘LSTE’    •••••
  73.  
  74. For more information, see the Resorcerer manual.
  75.  
  76.  
  77. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  78. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.
  79.