Page 1 of 3
Custom grid-control (egrid 2.0) - Updated.
Posted: Fri Nov 11, 2005 2:14 am
by srod
Well there seems to be a few grid controls in development now, which can only be a good thing.
This one is the successor to my original control and is a complete rewrite in that it is now based entirely on custom draw techniques and thus allows various gadgets to be embedded within the cells of the grid. There are 4 demo progs to give users an idea of how it all works.
Features include:
- set row height
- multiple colours / fonts etc.
- each cell is of a particular type, namely: 'string', 'static string', 'editable combobox', 'combobox', 'checkbox', 'static checkbox' and 'PB image' (with transparent background).
- complete control over user actions
- complete validation of data being entered, right down to the individual keypress
- paste cells from clipboard - paste multiple cells from spreadsheets.
- live updates to a database easily coded into an application
- justify text (left, center or right) in individual cells
Also, using custom draw has allowed me (I think!) to practically eliminate the issues of flickering which usually abound when making use of a ListIcon gadget.
Please let me know of any bugs or pass along any comments as I am keen to get this finished and wrapped up ready for my next project.
Regards.
Click to download
1st fix: -2 memory leaks spotted and plugged (11/11/05)
Added: Centered column headings (12/11/05)
Improved: Horizontal scrolling now much faster (12/11/05)
Added: Justify text (left, center or right) in individual cells (13/11/05)
Added: User guide in .pdf format (14/11/05)
Added: flag to egrid_SelectCell() command to simulate double-clicking of cell through code (25/11/05)
Added: created user library (Tailbite) so use of include files can be avoided (25/11/05)
Fixed: Bug - one command was not exported in the user library; doh! (25/11/05)
Fixed: One absolute stinker of a problem when using egrids under Win 98 SE. Have had to add a command for closing an egrid, namely: egrid_FreeGadget(#gadget). (30/11/05)
Fixed: Bug - a bit of a 'quirk' revealed when selecting cells through a Cellcallback function. (22/12/05)
Posted: Fri Nov 11, 2005 3:28 am
by rsts
Don't know what to say except - wow.
Posted: Fri Nov 11, 2005 10:58 am
by srod
Thanks rsts. I must admit, this is the best thing I've ever produced. Took me long enough!
Right, now to hunt down more bugs and start the docs!
Posted: Fri Nov 11, 2005 1:40 pm
by CSAUER
Congratulations, it looks good. I think it is much better than the first version.
It is a good idea to include icons, I will take that idea to my grid as well. I think the target ouf our grids is very similar. So the competition is started...
Did you tried to display more than one grid at once?
I got the feeling, that rendering is a bit slow, so maybe you can optimize a bit.
Posted: Fri Nov 11, 2005 2:06 pm
by srod
Thanks CSAUER.
I really went to town on the rendering and spent a lot of time eliminating flicker and trying to speed it up somewhat. What I gained in functionality by using a subclassed ListIcon gadget, I lost a bit in that I've had to address all the quirky issues of flicker and painting/erasing inherent in the control. There is a bit of redundancy in that at times I do repaint the entire egrid rather than just a few affected cells, but this did make for a more flexible grid.
To be honest, it is a lot faster than it was whilst in development and so I'm not sure I can speed it up any more! I'll certainly have a go.
I think that as long as you don't have too many images flying around, then it should be okay. The problem is that I went for transparency, and even though it uses Fred's slick code in that respect, it does still eat up time. For example, each single paint of an image requires 6 uses of the BitBlt() function, plus one more to then copy the resulting image into the egrid. This last call removes a lot of flicker. Hang on a minute; if the transparent colour matches the cell background...... shit, I'm on it!
So the competition is started...
I think that I am reaching the limit of what I am able to do with a ListIcon gadget. At least without resorting to an owner-drawn control, which seems a little too much like seriously hard work! Yours has the potential to be a lot more flexible than mine. For example, I see no way of embedding an egrid within an egrid; at least not in a way which would look even half pleasing to the eye. The main problem is that without resorting to an owner-drawn ListIcon, I have ro way of having rows of different heights. I can change the heights, but only for every row all at once! This makes embedding egrids a bit of a 'no no'!
Still, I'm happy with it as it is.
I'll look forward to more updates of your CSgrid.
Posted: Fri Nov 11, 2005 5:46 pm
by Thorsten1867
I've included the new version in my programm and it works great.
Is it possible to center single colum?
The function (for ListIconGadgets), I used before, no longer works with the new version. (It looks much better if marks and points are centered

)
Re: Custom grid-control (egrid 2.0)
Posted: Fri Nov 11, 2005 6:32 pm
by dell_jockey
srod wrote:Well there seems to be a few grid controls in development now, which can only be a good thing.
You grid-programming lot should put your heads together to create that elusive TFG (The Final Grid)...

just a thought...
Posted: Fri Nov 11, 2005 8:18 pm
by srod
Thorsten:
beware, this version of egrids is relatively untested. There are no warranties!
The function (for ListIconGadgets), I used before, no longer works with the new version.
Which function? I can't recall taking any functions out, so it's more likely I've broken some code in the user file and haven't come across it in testing yet.
As for centering columns. It is easy to centre the text in an individual column of a listicon. The only thing that stopped me (apart from the time involved!) was that I would then have to centre the text in the various gadgets being used for the different celltypes (string and combobox). Maybe I'll look into this, but it is a facility which I didn't particularly deem necessary.
You grid-programming lot should put your heads together to create that elusive TFG (The Final Grid)... just a thought...
How about TMOAG? The Mother Of All Grids!!!
Posted: Fri Nov 11, 2005 8:41 pm
by Thorsten1867
srod wrote:Thorsten:
beware, this version of egrids is relatively untested. There are no warranties!
Now it's tested. And all functions, I use, seem to work.
Which function? I can't recall taking any functions out, so it's more likely I've broken some code in the user file and haven't come across it in testing yet.
Sorry for my bad and unclear English, it's a function of the PureVisionXP-Lib (PVGadgets_JustifyListIconColumn), I use to format ListIconGadget-Cols.
As for centering columns. It is easy to centre the text in an individual column of a listicon. The only thing that stopped me (apart from the time involved!) was that I would then have to centre the text in the various gadgets being used for the different celltypes (string and combobox). Maybe I'll look into this, but it is a facility which I didn't particularly deem necessary.
Isn't enough only to center the stringgadget?
Posted: Fri Nov 11, 2005 8:57 pm
by srod
Centering a single line string gadget should not be possible!
Quite how Purebasic allows the use of the flag #PB_Text_Center is a little puzzling because the Windows help file states that single line edit controls have no text styles at all!
This is why I am reluctant to allow the centering of columns, at least until I get to the bottom of this. I don't want it working on some versions of Windows, but not others!
Sorry for my bad and unclear English, it's a function of the PureVisionXP-Lib (PVGadgets_JustifyListIconColumn), I use to format ListIconGadget-Cols.
This is because in version 2 of egrids, Windows is no longer responsible for displaying the text within the ListIcon. I paint the text and images directly. This was the only way to allow for columns of checkboxes, without actually involving any checkbox gadgets etc.
Posted: Fri Nov 11, 2005 10:19 pm
by Fred
Did you tried the #SS_CENTER flags ? It seems to be supported since win95. BTW, you did a nice wok with this grid

Posted: Sat Nov 12, 2005 9:21 pm
by srod
Thanks Fred. About centering the text, I need to be able to switch from left to center justification and back and forth. This doesn't seem possible with PB's String gadgets! At least I can't get it to work! I think I'll have to use a native Windows Edit control. No big deal, but it means quite a lot of changes!
Egrid Tip:
Had a query about using egrids with the PV_Gadgets library for dynamic resizing purposes. This will not work directly because an egrid comprises a ListIcon embedded within a container gadget. This was done to avoid having to impose Windows Callbacks on anyone making use of an egrid. The way round this is to have the library dynamically resize the container and the listicon as in the following example:
Code: Select all
egrid_CreateGrid(#egrid1, 10, 10, 225, 150, 16, #PB_ListIcon_GridLines, #egrid_ResizeColumnsTrue)
PVDynamic_AddLockWindow(#Window,0,0,3)
egrid_identify(gadgetid(#egrid1)) ;This locates the egrid within my internal data structures.
PVDynamic_AddGadget(#Window,egridList()\containerid,3) ;Dynamically resize the container.
PVDynamic_AddGadget(#Window,#egrid1,3) ;Dynamically resize the ListIcon used as the basis for the egrid.
Of course, the alternative is to intercept the #WM_SIZE message and use the command
with suitable arguments etc.
Posted: Sat Nov 12, 2005 11:56 pm
by Thorsten1867
I've tested your eGrid-tip with two different grids in my program. I don't know why, but it works great. I'm really happy. THANKS for your tip!!!
Your a magician with grids.

Update
Posted: Sun Nov 13, 2005 11:08 pm
by srod
Update: You can now justify text (left, center or right) in individual cells / columns / rows.
Re: Update
Posted: Sun Nov 13, 2005 11:35 pm
by Thorsten1867
srod wrote:Update: You can now justify text (left, center or right) in individual cells / columns / rows.
If tested it in my program! WOW!!!

THANKS for your fantasic work.