DFMEdit - Configuration-files

I. Dfmedit.ini
II. Language-files
III. Components.obj
IV. Properties.obj
V. Unwanted.obj

I. Dfmedit.ini

    [main]
      language=en
      BinForm=1
      ShowHidden=1
      EnableDisabled=1
      ShowToolbar=1
      ShowMainMenu=1
      lazres=tools\lazres.exe
      LazUnitExt=pas
      GridSize=4
      DrawGrid=1
      SnapToGrid=1
      OpenCreatedUnits=1
      OpenModifiedUnits=1
      AskForOpen=1
      External=D:\Programmierung\wscite\SciTE.exe
      BackupCount=2
      BackupDir=_bak_
      ChangeFocus=1
      IgnoreFormMove=1
      UseDllForSaving=0
    [position]
      About_Left=10
      About_Top=15
      Add_Left=100
      Add_Top=105
      Add_Height=600
      Add_Width=400
      Options_Left=15
      Options_Top=25
      Main_Left=10
      Main_Top=20
      Main_Height=800
      Main_Width=600
      ChooseRes_Left=20
      ChooseRes_Top=25
      ChooseRes_Height=400
      ChooseRes_Width=600
      Inspector_Height=400
      Inspector_Width=300
      Palette_Height=120
      Palette_Width=800
    [packages]
      0=testpackages\test.dpl
      1=C:\Temp\blah.dpl
    [History]
      Count=5
      File0=E:\test.dfm
      File1=E:\test2.dfm
    
main-section
language defines the language-file loaded on startup (dfm_*.lng)
BinForm, ShowHidden and EnableDisabled setting the corresponding toolbar-buttons down if set to 1
ShowToolbar and ShowMainMenu show the corresponding menu when set to 1
The key Lazres is needed if you want to save lazarus-forms and lazres.exe is not in the same folder as dfmedit.exe
Absolute and relative paths (to dfmedit-folder) are allowed.
You can define a file-extension for lazarus-code with LazUnitExt when generating pascal-code from a lfm-form.
GridSize configures a grid drawn on the preview-form. If you don't want it set it to 0
If DrawGrid is set then some helplines will be drawn in preview while moving a component (5*GridSize, so GridSize must be greater than 1)
SnapToGrid indicates that the target control is aligned to the grid while moving/resizing
The External-Key defines an external editor for showing the pascal-code after generation (if OpenCreatedUnits set) or modification (if OpenModifiedUnits set) and if AskForOpen is set it will prompt before starting this editor.
with BackupCount you can define how many backups will be created (they will be rotated; .1.bak is the newest)
BackupDir can be set to a absolute or relative (to folder of original dfm-file) directory
if ChangeFocus is set then the sizecontrol automatically is assigned to the new control created with the component-palette
you can set IgnoreFormMove to 1 to move the preview-form without the properties left and top being changed in the tree/OI
UseDllForSaving can be set if you want to use the dll also for saving binary forms (also for resources), use this option with care!

In the Position-section you can define position and size of the most forms shown in DFMEdit

The Packages-section allows you to expand the vcl of dfmedit with your 3rd-Party-VCL.
Only keys 0-9 are loaded so you can load up to 10 packages. You can use absolute and relative (to program-directory) paths.
This is currently for testing only. the Packages which can be loaded must have the following reqirements:
the units with the component must have an initialization-section with RegisterClasses([TMyComponent])
and a finalization-section with UnregisterClasses([TMyComponent]) (replace TMyComponent with your classname). This Package must be compiled as Runtime-Package and with the same delphi-version which is used for dfmedit.exe (default: delphi 3)

The History-section contains elements for the last-opened files. The Count-Key defines the maximum saved filenames.
The files themselfs defined by FileX-keys, where X is a number from 0 till Count-1.

II. Language-files

The filename must have the following layout:
"dfm_"+countrycode+".lng"
Countrycodes can be found here
Look in existing language-files for control-/message-names

Sample file:
    [main]
      Charset=RUSSIAN_CHARSET
      Font=MS Sans Serif
    
    [controls]
      controlname="new caption"
      ....
    
    [strings]
      messageidentifier="translated message"
      ...
    

Explaination:

Charset can be one of the following values:
    ANSI_CHARSET
    DEFAULT_CHARSET
    SYMBOL_CHARSET
    MAC_CHARSET
    SHIFTJIS_CHARSET
    HANGEUL_CHARSET
    JOHAB_CHARSET
    GB2312_CHARSET
    CHINESEBIG5_CHARSET
    GREEK_CHARSET
    TURKISH_CHARSET
    VIETNAMESE_CHARSET
    HEBREW_CHARSET
    ARABIC_CHARSET
    BALTIC_CHARSET
    RUSSIAN_CHARSET
    THAI_CHARSET
    EASTEUROPE_CHARSET
    OEM_CHARSET
    
Font defines the name of the font to be used

every language can have a 16x16 px Bitmap which will be displayed in the Language-Combobox.
the name must be the same as the lng-file except extension bmp (e.g. dfm_en.bmp)

III. Components.obj

The Components.obj contains the components/properties when adding (or modifying) a component.
The list in the dialog for choosing the type is an enumeration of the sections without "[default]", "[TForm]" and "[control]"
In these Sections you can define properties which will be created when creating a component.

Syntax:
    [component]
      propertyname=defaultvalue    
    
The Section "[default]" contains properties which will added to all new components, these can be overridden with other default-values in other sections.
Section "[control]" is for properties for all controls (dfmedit must know the type-hierarchy), they alsocan be overridden.

When creating a new form the "[TForm]"-Section is be used.
there are some special property names (covered in < and >):
<isControl>: define that component is a control for unknown classes so [control]-section is used too
<replace>:replace unknown class by another for preview (also using the corresponding sections)
<hide>:hiding the component from the component-list in add-dialog
<menu>: used in component-palette, define the tab-number where the control appears
<menu_imgidx>: used in component-palette, define the imageindex for the toolbutton
<menu_pos>: used in component-palette, define the position of the toolbutton (index)

IV. Properties.obj

this file holds the type-information for properties that can't be enumerated (e.g. TImagelist.Bitmap, TStringgrid.ColWidths/RowHeights)

Syntax:
    [component]
      propertyname=propertytype
    
possible values for "specialtypes" are: <binary>,<TStrings>,<Intlist>,<tcollection>
if one of them is defined the Specialtype-combobox is selected when choosing this property
You can also use any other known type e.g. integer, string, boolean, TFont (class), TOpenOptions (set), TWindowState (enum)
like in components.obj there are special properties:
<ignore>:when replacing class ignore properties in this comma-separated list
<ReplaceProperties>:replace property-names by another for preview (comma-separated list; e.g. for TntControls: <replace>=Items.WideStrings=Items.Strings)

V. Unwanted.obj

this file contains the rules for deleting unwanted properties

Exmple:
    ;rules for all classes
    [default]
      ;delete Explicit-and DesignSize-properties without any condition
      ExplicitLeft=*
      ExplicitTop=*
      ExplicitHeight=*
      ExplicitWidth=*
      DesignSize=*
      ;position/size not needed when alClient
      Left=Align=alClient
      Top=Align=alClient
      Height=Align=alClient
      Width=Align=alClient
      ;delete Font.Style-property if it defines no styles
      font.style=[]

    ;Class depending rules
    [TToolbar]
      ;delete Caption if DragKind-Property is dkDrag
      Caption = DragKind = dkDrag

    [TToolButton]
      ;delete Caption and ImageIndex if style is tbsSeparator OR tbsDivider
      Caption=Style = [tbsSeparator,tbsDivider]
      Imageindex=Style = [tbsSeparator,tbsDivider]