Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a component to automatically create a config form?

Tags:

delphi

I have a settings class in my system, where I store configuration values for important settings. It looks like the code below, but with many more attributes of different types. Now I need to implement a form with which I can adjust and configure these settings at runtime. Its very cumbersome to implement the fields for each attibute and guarantee that all values are mapped without error.

Now my question: is a vcl component that could automatically create an interface to solve that. Eg. offer a tree-like or listview-like interface with the names of the attributes and fields to edit the values (like the property pane in the IDE, with printer settings, see screenshot below). That would be a great thing. No?

How do you deal with configuration forms like that?

Thanks for your input!

TGoldmannSettings = class
  private
    FInitialSymbolSize          : Integer;
    FPenWidth                   : Single; 
    FCanvasColor                : TColor;
    FShowLiveCoordinates        : Boolean;
    FFont1                      : TFont;  
    FMsmPointSymbol             : TAvailableSymbols; // own type
    ...
  public
    constructor Create;
    destructor Destroy; override;
    property SymbolSize : Integer read FInitialSymbolSize write FInitialSymbolSize;
    property Font1: TFont read FFont1 write FFont1;
    ...
  published
    property PenWidth: Single read FPenWidth write FPenWidth;
    property CanvasColor: TColor read FCanvasColor write FCanvasColor;
    property ShowLiveCoordinates: Boolean read FShowLiveCoordinates write FShowLiveCoordinates;
    ...
  end;

You sometimes find something I mean in printer setting dialogs: screenshot of my printer settings offering a interface like I wish to have

like image 440
Scott Bold Avatar asked Mar 23 '12 10:03

Scott Bold


2 Answers

The TJVInspector component from the Delphi Jedi JVCL project creates a property editor very similar to what you are looking for. They have an advanced example that works on an INI file.

JVCL Site: http://jvcl.delphi-jedi.org/

Nice example: http://www.neugls.info/?tag=tjvinspector

The JVCL / JCL package is huge but has a ton of useful components and functionality.

like image 167
Densefog Avatar answered Nov 06 '22 08:11

Densefog


I have never yet created an automatic-configuration form generator similar to the one in the delphi project options, but I have seen this done in several projects that I work on, and seen the source code, and it works very much like this:

  1. I would have a base type of frame called TConfigFrameBase and it would contain some properties like this: Caption (user displayed name of property), Hint (some help), and Name (config property), and Section (page this property is shown on).

  2. Specialized inherited frames would be used for boolean properties, string properties, etc. Your domain (your app) will have its own custom types. Dates? Lists of apothecary locations in Denmark? Only you know for sure the complete set of UI configuration property types you need, and that's why I haven't seen a component that makes this automatic or just a component. The boolean frame would contain a Label control and a checkbox and would have a default height around 30 pixels. A frame that let me move a list of options on side A to options on side B (columns visible within a particular grid, for instance) might be as high as 300 pixels. By vertically stacking these frames, in a scrollbox, you don't have to do much thought about layout. Everything will be usable when these frames are used to populate a listbox.

  3. A tree view on the left that lets you pick a section. In the on-click in the tree view, the right side pane is built by iterating through my internal list of config-frames that are registered in a list or dictionary, and filtered by the Section they belong to.

enter image description here

I wouldn't use a JVCL Property Inspector as my configuration control, but it might work for you. I also don't think you're going to get everything you need out of VirtualTreeView, but your mileage might vary. You can write your own custom Editor controls, and if you like writing in-place-editor controls, you might find VirtualTreeView perfect.

like image 23
Warren P Avatar answered Nov 06 '22 09:11

Warren P