Grid GUI control

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.
Post Reply
drmikecrowe
Posts: 1
Joined: Thu Feb 11, 2010 7:14 pm

Grid GUI control

Post by drmikecrowe »

Hi Jerome,

I'm very intrigued by eC. However, I have a PC application that I want to design with a pretty substantial GUI.

I'm looking for a grid control (a la Excel), but I want the capability to define the editor for each cell. I can do this in Qt4 or wxWindows.

Is there any chance I can do that with eC? I've been trying to learn the system, but can't seem to find a way to do it.

Mike
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Grid GUI control

Post by jerome »

Hi Mike.

There is a grid-like control in Ecere, however it is probably not well suited for a spreadsheet application like Excel.

The way the data controls work in Ecere is that they are assigned a particular data type.
The ListBox control can be configured as a mult-column grid control, and you can configure various properties such as 'alwaysEdit' which will give it a grid like appearance. Please note that the API is still lacking much documentation, and will also undergo a little bit of reorganization so it's easier to figure things out, as you must have noticed. However it is already very powerful and flexible, and I believe you should be able to create your GUI easily enough, however substantial it is. Please don't hesitate to post questions here about it and I will do my best to answer promptly.

So to get multiple columns in the ListBox controls, you simply add multiple DataField objects to it with ListBox::AddField. Each DataField has a 'type' member which you set to the data type you want, this is done like this:

DataField field1 { dataType = class(int), header = "Field 1", width = 80, editable = true };

This instantiation usually goes inside the parent form which contains the ListBox (A class deriving from Window), and in the form's constructor you simply do, e.g. listBox1.AddField(field1);

Now the way to define a custom editor is by creating your own data type (Whether a struct, class, headerless class (class MyClass : struct), bit class, enumeration or unit class -- see the Ecere Tao for explanation of all these kinds of data types). Then in there you can override some virtual methods which are built in eC, such as OnEdit(), OnSaveEdit(), OnGetString(), OnGetDataFromString(), OnDisplay(). This is a bit of an advanced topic for which I haven't written much information about yet. There is some limited information about these in the old forums in this discussion: http://www.ecere.com/Vanilla/comments.p ... ssionID=31 .
The best thing however is perhaps to do a Search in Files (Ctrl-Shift-F in the IDE) for e.g. "OnEdit(" in the SDK source folder.
I'm not sure we have a sample yet that covers these data type customization, although that is definitely something I should work on. You will be able to find examples however throughout the Ecere runtime library and the IDE source code.

There is however a sample in the samples/guiAndGfx/DataControls about the basics of using a multi field ListBox. Please note it uses the old string style for specifying the data type rather than the class ( ). Also, in the latest pre-release (0.44pre1) the GetData/SetData has been modified to accept the data in a more convenient and straightforward way.

Please don't hesitate to post any other questions about this.

Cheers.

Jerome
Post Reply