Custom grid-control (egrid 2.0) - Updated.

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Custom grid-control (egrid 2.0) - Updated.

Post 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)
Last edited by srod on Fri Dec 23, 2005 10:41 pm, edited 12 times in total.
I may look like a mule, but I'm not a complete ass.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Don't know what to say except - wow.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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!
I may look like a mule, but I'm not a complete ass.
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post 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... :D

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.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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! :lol:
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.
I may look like a mule, but I'm not a complete ass.
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

I've included the new version in my programm and it works great. :D

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 :wink: )
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Re: Custom grid-control (egrid 2.0)

Post 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...
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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...
:lol:
How about TMOAG? The Mother Of All Grids!!!
I may look like a mule, but I'm not a complete ass.
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post 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. :D
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?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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 :)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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

Code: Select all

egrid_Resize()
with suitable arguments etc.
I may look like a mule, but I'm not a complete ass.
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post 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. :D
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Update

Post by srod »

Update: You can now justify text (left, center or right) in individual cells / columns / rows.
I may look like a mule, but I'm not a complete ass.
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: Update

Post 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!!! :D
THANKS for your fantasic work.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Post Reply