Recent

Author Topic: ConfigFrame, An easy way for to create Config Dialogs  (Read 5778 times)

Edson

  • Hero Member
  • *****
  • Posts: 1302
ConfigFrame, An easy way for to create Config Dialogs
« on: July 21, 2014, 10:49:12 pm »
I was tired of to write repetitive code, when writing configuration dialogs for move values from:

Control <-> Variable <-> INI File

So, I decided to create my own TFrame, for config Dialogs.

The idea was to have a TFrame class, with new methods, that make it easy to modify some variables of the App, and be able to save(restore) them to disk.

I thing this could be useful, so I share it:  https://github.com/t-edson/ConfigFrame
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #1 on: July 22, 2014, 07:59:42 am »
Edson, thanks for contributing such a useful ini-based configuration framework.

BTW who is Tito Hinostroza (I presume the spelling Tito Hinojoza in some comments is the same person)?
« Last Edit: July 22, 2014, 10:04:18 am by howardpc »

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #2 on: July 22, 2014, 05:14:15 pm »
Well, I was looking for some code to do this work, but finally I decided to write the mine. I decided INI files because they are simple. I hope I'm not reinventing the wheel.

About the name, I am Tito Hinostroza (not Hinojosa). I use to sign with my name and last name on my code and docs.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Basile B.

  • Guest
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #3 on: July 24, 2014, 08:48:19 am »
You should consider using the TIControls because from my point of view the whole point is not to link a control to a config file but the data to the ini file. I'd rather see a Frame which auto-creates some TIControl according to its published props. But that's a point of view to think that the GUI just represents the data. Nice try anyway.

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #4 on: July 24, 2014, 07:01:51 pm »
RTTI Controls, looks a good choice (just for linking properties to controls), but I've had problems working with them. I will investigate more. Thanks for the advice.

One of the objectives for of my work, was to easily read/write variables from/to disk. Even if these properties are not going to be visible, (associated to a control).

That's why I have included these methods:

Asoc_Int(ptrInt: pointer; etiq: string; defVal: integer);
Asoc_Bol(ptrBol: pointer; etiq: string; defVal: boolean);
Asoc_Str(ptrStr: pointer; etiq: string; defVal: string);
Asoc_StrList(ptrStrList: pointer; etiq: string);

They just register a variable for to be saved or read from disk. After register many variables, they are all saved to disk with a simple call to SavePropToFile().  The ini file is automatically created if it doesn't exist.

Moreover, this rutines included some range validation (for integers), and a default value, for the first time, they are read from disk.

« Last Edit: July 24, 2014, 07:04:26 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #5 on: August 22, 2014, 10:02:09 pm »
ConfigFrame 0.3 released:

https://github.com/t-edson/ConfigFrame

It was improved the work with strings, and have been added associations for new controls.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #6 on: October 18, 2014, 08:16:15 pm »
ConfigFrame 0.4 released.

Improved the capture of errors on Config frames, and a new method added for to associate variables to TRadioGroup controls.

This library can solve the problem shown here:

forum.lazarus.freepascal.org/index.php/topic,22689.msg134281.html
« Last Edit: October 18, 2014, 08:19:51 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Roland57

  • Sr. Member
  • ****
  • Posts: 423
    • msegui.net
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #7 on: October 18, 2014, 09:32:07 pm »
Hello Edson!

Very useful unit. Thank you for sharing.
My projects are on Gitlab and on Codeberg.

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #8 on: October 18, 2014, 11:04:05 pm »
Hi Roland. You're welcome.

Like others of my libraries, this was the product of a necessity, when I was developing some Apps. I think it could be useful, that's why I shared it. Soon I will be publishing a project that use this unit.

I just have tested it on Windows, so I don't know if it's functional on Linux o Mac.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: ConfigFrame, An easy way for to create Config Dialogs
« Reply #9 on: October 14, 2015, 07:17:48 am »
ConfigFrame 0.6 released.

Updated until Lazarus 1.4.2.
Now ConfigFrame it's a real Frame instead of a simple unit, like in previous versions.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018