3

If one looks at hierarchical structure of html and dfm, he could find similarities (nested structure, properties (attributes) and so on). The next step is to ask is there something like css (Cascade style sheets) in Delphi world. So for example rule like this

TPanel TPanel BorderWidth=2

could define that for any TPanel placed in another panel the property BorderWidth should always be 2.

or

TPanel.MyPanel TLabel Font.Style=[fsBold] 

for TPanel named MyPanel any label inside should be bolded (similarly to css The particular name (MyPanel) can be equivalent to id attribute of html)

So is there library/unit that was developed for something like this?

I suppose there should be some challenges

  • implementing this in design-time can pose some compatibility problems with internal form designer of Delphi (Probably this library can be more run-time oriented)

  • In html world it is mostly about visual so an error could lead just to visual peculiarities, but in Delphi properties sometimes intended to be set explicitly by the programmer's hand and making it subject of mass management could pose security and stability threats.

Nevertheless, I thought that we are too bound to properties manual changing. Even if it's copy-paste, the root of any property change is a dedicated mouse click.

Maksee
  • 2,311
  • 2
  • 24
  • 34
  • 3
    Recent versions of Delphi (at least XE2 and XE3) support visual styles, which allows for the equivalent of the above on a global basis. What version of Delphi are you asking about? – Ken White Jan 19 '13 at 19:53
  • @Ken_White, I'm not too familiar with the features of the latest versions. You mean the styles really affects the values of the actual properties? Also I thought that user can have different properties of his own created components. Does the styles can use those also? – Maksee Jan 19 '13 at 20:12
  • You can control any visual aspect of any control via styles. See [the docwiki](http://docwiki.embarcadero.com/Libraries/XE3/en/Vcl.Styles) for more information. There are also many questions here at SO related to VCL/FMX styles (most answered by RRUZ) in the `delphi-xe2`, `delphi-xe3`, and `firemonkey` tags. You can start [here](http://stackoverflow.com/questions/14031125/styling-only-one-vcl-component-in-delphi); it's not really about VCL styles, but look at some of the `Related` links to the right of that page. – Ken White Jan 19 '13 at 20:27
  • Also see @RRUZ's answer to [this question](http://stackoverflow.com/questions/8509514/is-there-any-delphi-xe2-styles-gallery?rq=1), which has links to a couple of his blog posts about VCL/FMX styles. – Ken White Jan 19 '13 at 20:32
  • I suppose that the styling is more about the implicit states of the components, something that surely affects the appearance of controls, but not usually controlled by design-time properties (for example round edges of the buttons). The styles are useful, but I suppose it doesn't allow arbitrary fine tuning just for particular project – Maksee Jan 19 '13 at 21:08
  • You can do custom styles for "arbitrary fine tuning", for a particular project, particular control, etc. The IDE provides a StyleEditor where you can do so fairly easily, either from scratch or by modifying an existing style. You should spend more time reading the links I posted. :-) – Ken White Jan 19 '13 at 21:10
  • 2
    I don't see anything in Visual Styles that is very like CSS. – David Heffernan Jan 19 '13 at 23:16
  • @David: I didn't say it was "very like CSS", and I also didn't post an answer because that wasn't the case. If you use visual styles, and you load them from disk instead of embedding as a resource, you can modify the style file and change the global appearance of things without recompiling the executable, in the same fashion that you can change the appearance of an entire web site by changing a CSS file. If I'd meant to say "Visual styles are exactly like CSS files", I would have posted an answer rather than a comment. I merely suggested investigating styles. Thanks for the input, though. – Ken White Jan 20 '13 at 07:44

0 Answers0