Simplicty and flexibility!

SetStyle() - One of the forgotten Treasures of 8.x

DataEase 8 is not a Alpha or Beta product it is a full release, but it is in what we call Pre-Release or Developer Release version. This means that it is fully approved and warranted by us, but it is not the final version of this product.

Due to the "neglect" that DataEase had suffered under prior to the change of ownership, it was necessary to both look after current customers need when at the same time developing DataEase into a contemporary product offering.

It was clear from Day one that DataEase 7.x suffered from so many maladies that it was necessary to quickly come up with an improved release version hence the Pre-Release version of DE8.

When deciding the path forward we decided that we would include our users in the development process and make available any new feature in DE8 as soon as it was developed with the understanding and knowledge that it would not be used by the majority. Every bit of new functionality is part of the bigger picture or plan if you like and at the end of the development cycle we will focus on showcasing the entire product as one.

In a way we have simply developed the functionality, tested it (and used it in house) but not always spent much time in promoting or showcasing it. As sensible as this might be as an approach there should at least be a minimum of "marketing" and fanfare for each new function, but some it seems we have completely neglected to almost even mention.

For-most of these are SetStyle() which is an abomination as it might possibly be the most useful function for manipulating and making your applications interactive and attractive.

So better late than never, here it is: SetStyle()

Download SetStyle() Sample

It would be a lie if we said that developing a product like DataEase 8 or even DataEase in general was done by designing the product and then implementing that design. We develop DataEase the same way you use it, by incremental and evolutionary methods.

We have of course a long list of ideas, needs, technical requirements, bugs, shortcomings etc, that result in a general directions of the product development, but we constantly have to feed the process with feedback from you our own discoveries and experience with the changes we make.

OML was implemented in DFW many years ago, but due to a combination of bad documentation, risky and unstable behaviour, a bad editor and a completely new approach it never became very popular. You can say that it wasn't very DataEasy.

This is why we in DE8 decided that we would allow users to do everything they could already do in OML directly in the know formats of Derivations (BRL) and DQL (ExecDQL) via making functions.

The first function we did this way was SetColor(). You could already set the colour on an object programatically in OML but it was awkward and with OML then bad reputation and tendency to not only GPF in runtime but also corrupt your form in Design Time it was a high risk and work intensive activity.

You would also have to set it in minute detail in decimal....not very user friendly as the example below will show:


-- Set Color of fill

Button11.Fill.Color.Red := 128 .

Button11.Fill.Color.Green := 145 .

Button11.Fill.Color.Blue := 45 .

-- Set Color of Font

Button11.Font.Color.Red := 128 .

Button11.Font.Color.Green := 145 .

Button11.Font.Color.Blue := 45 .

-- Set Color of Border

Button11.Border.Color.Red := 128 .

Button11.Border.Color.Green := 145 .

Button11.Border.Color.Blue := 45 .

-- Set Color of fill

Button11.Draw() .

This little sample set the colour of the Font, Fill and Border of a button but as you will find out if you try to use it, it will not set the shade, shine which would be 3 new lines for each property.

I think maybe this illustrates why OML never became a hit with the general public, so we wanted to allow our developers to do this much quicker and easier and hence the development of SetColor().

SetColor() basically have 4 parameters which is ObjectName( Same name and rule as for OML) and the a String value for each of the 3 properties - Font, Fill, Border. We use string so one can input it either as decimal (same way as for OML) or in hex "#FF0F0A" format.

As each colour contain a 3 8 bit RGB elements the number in decimal is unmanageable and this is where Hex is so brilliant, as each byte is represented by to letter 00 to FF.

Since each function will set all three properties in one go, you would need to be able to tell it not to set (keep) the current property and you simply do that by setting -1, so SetColor("MyField","#ff0000","-1","-1") would set the font of MyField red and retain the remainder of the properties.

It is easy to see that this is a major leap forward in Ease of use, but as you start working with it extensively you realise that where the OML approach basically is a showstopper, the SetColor() funciton is great when you want to do it in a small way, but if you are manipulating your app in a big way it is to much work and it is also to inflexible.

Firstly. DE8 objects have many more properties than Font, Fill and Border. They have properties as Font, Shade, Box, Border Width etc etc. Should we make functions that include all of them, or should we make specific functions for each property? i.e. SetFont(), SetBorderWidth() 

No.

There is already one feature in DataEase that in itself is underused which solve all of these features;

STYLE

If you can programatically change the style of any object, you can do any or all properties in one go, hence the birth of SetStyle().

SetStyle is the simplest of functions with only two parameters both string. Objectname to manipulate and Style to Apply.

SetStyle("MyObject","MyStyle") and you have changed the style.

The style you make and save in Design mode, and you can make as many and as divers styles as you please.

Combine SetStyle() with GetStyle() and SetVar()/GetVar() and you can read the current style, store it in a global variable, apply the new style and revert to the old style when you are finished.

The only thing it would take would be a derivation (action) like this:
SetVar("MyObjectStyle",GetStyle("MyObject"))+SetStyle("MyObject","NewStyleName")

And the reverse derivation would be:

SetStyle("MyObject",GetVar("MyObjectStyle"))

See also:
SetVar()
GetVar()
GetStyle()
SetColor()
SetFocus()

Published: 13/09/14 - 09:51:09 (Amanda Higgins)

Related Articles

SetStyle() - One of the forgotten Treasures of 8.x