Grid gadget (egrid ver 1.1) complete - update 1.1b.

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...

Grid gadget (egrid ver 1.1) complete - update 1.1b.

Post by srod »

**EDIT**
Have fixed a couple of bugs and added a couple of functions for pasting from the clipboard.
Apart from fixing bugs, I do not anticipate working on this project for some time now. Time to move on!



Well, this turned out to be quite an undertaking. I almost drowned in the depths of the API to get this working right!

In short, an egrid is a good old grid gadget which offers quite a lot of customising (colouring of cells, data validation, live updates to a database etc.) and gives the developer a lot of control over user actions and so on.

I've put in a huge effort to eliminate the problems of flicker which is hugely apparent when you colour the cells of a ListIcon gadget and then scroll through the control. This is caused by windows erasing the background with just a single colour as opposed to the many colours which may be present throughout the control.

At the moment, only text can be entered into the cells of an egrid. However, even this version uses quite a bit of custom draw and it is only a matter of time before I upgrade this work to full custom draw, which should then allow various controls to be embedded within the cells of each grid.

The only thing I haven't added is multiple cell selection by click-and-drag etc. I left this out deliberately as I think it will get in the way of the full custom draw version. I will probably add this for the next version.

I've included a few demo programs and a full user guide.

For some reason Tailbite crashes when I try to create a user library out of the source. If anyone has any ideas on that score I'll be more than interested to hear.

Regards.

http://www.purecoder.net/purebasic/egrid.zip


***MINOR UPDATE: A few more issues related to flickering whilst scrolling have been addressed.***
Last edited by srod on Sun Oct 23, 2005 3:40 pm, edited 3 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 »

very nice effect.

I believe i can use this in a password program i've written.

thanks for sharing.
zikitrake
Addict
Addict
Posts: 875
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

srod,

It works perfectly and is really simple to implement.

Thanks!
PB 6.21 beta, PureVision User
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

I'll have a look at that problem.
El_Choni
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Grid gadget (egrid ver 1.1) complete.

Post by gnozal »

srod wrote:For some reason Tailbite crashes when I try to create a user library out of the source. If anyone has any ideas on that score I'll be more than interested to hear.
Don't know if this helps, but some stuff has to be in the _Init procedure, like NewList() for example.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thanks.

El-Choni, thanks for looking. I was going to ask if you'd have the time to rummage through and find the problem, as I'd quite like to turn this into a user library. My knowledge of c is functional at best and so Tailbite is my best hope on that score!
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Gnozal wrote:Don't know if this helps, but some stuff has to be in the _Init procedure, like NewList() for example.
:roll:

Doh!

Thanks for the tip, I'll see if that sorts it out.

***EDIT:***
No, I've chucked all the initialising stuff into an _Init procedureDLL, but still Tailbite crashes out with the Windows send error dialogue.
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 think, I've found a bug.

Code: Select all

 Select uMsg
    Case #egrid_InsertChar
      If *cellinfo\column = 2
        note = Val(*cellinfo\text)
        If note >= 1 And note <= 6
          Result = #True
        Else
          Result = #False 
        EndIf
      EndIf

      . . . . . .

 EndSelect
The variable 'note' seem to return always '0' (=> '*cellinfo\text' is always "")
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thorsten, no bug, you're misusing the *cellinfo structure.

With the

Code: Select all

#egrid_InsertChar
message, the 'text' field of the *cellinfo structure contains a copy of ALL the text in the cell being edited BEFORE the newly entered character is added. The ascii value of the newly pressed key is in the 'param' field.

Assuming then that you're attempting to just allow the user to enter digits 1 to 6, use the following:

Code: Select all

    Case #egrid_InsertChar 
      If *cellinfo\column = 2 
        note = Val(chr(*cellinfo\param)) 
        If note >= 1 And note <= 6 
          Result = #True 
        Else 
          Result = #False 
        EndIf 
      EndIf 
Regards.

***By the way, I have just uploaded an update which resolves a few more issues related to 'flickering.
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 »

Thanks! I 've used the old version before and not noticed the changes in the structure. But now it works really fine in my program.
I don't know, what I would do without your 'egrid'. :D

Thorsten (Germany)

PS: Sorry for my bad english.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

***BUG FIX***

On further testing, 3 bugs identified and now fixed. 2 regarding erasing the background, 1 with the CellCallback function. Please download the fixed version.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Update 1.1a released.

Post by srod »

Version 1.1a adds a new message for the optional CellCallback function and a command allowing the pasting of data from the clipboard into a range of cells. Data can thus, for example, be copied from a selection of cells in Excel and pasted directly into an egrid.

Regards.

http://www.purecoder.net/purebasic/egrid.zip
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

Wish List

Post by CSAUER »

Pretty good grid-control.

My wish-list:
- After editing and pressing RETURN-key, the cursor-position should be visible and moving with arrow-keys should be possible
- Multi-field selection, cut/copy content via Clipboard (CTRL+X and CTRL+C)
- Input content from clipboard via CTRL+V (or SHIFT+INSERT)
- Row-Sorting (combined with GNOZAL PureVLSort)
- Display checkboxes for true/false values
- Implement Drop-Down-Input, Checkbox-Input
- Implement Cell-Icons
- Maybe Hierachical Grid like MS FlexGrid with Input (idea: ListView together with TreeView)

Thanks in advance.
CSAUER
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

After editing and pressing RETURN-key, the cursor-position should be visible and moving with arrow-keys should be possible
Trivial to implement, may do that today.
Multi-field selection, cut/copy content via Clipboard (CTRL+X and CTRL+C)
Have already commented upon this one and it should be in the next version. I wasn't sure whether I wanted this feature myself.
Input content from clipboard via CTRL+V (or SHIFT+INSERT)
No, this would be treading upon the toes of the developer using egrids. I have implemented a function which allows pasting from the clipboard (and will soon add another). It is up to the developer whether he/she wishes to tie these functions to CTRL+V menu options. It would be one simple line of code, but as I say, not all programs would require this feature and so I leave it to the individual developer.
Row-Sorting (combined with GNOZAL PureVLSort)
Interesting. May well add this.
- Implement Drop-Down-Input, Checkbox-Input
- Implement Cell-Icons
- Maybe Hierachical Grid like MS FlexGrid with Input (idea: ListView together with TreeView)
As already commented, this first version of egrids was basically to see if I was up to the job etc. The next major version (which I am close to starting) will feature complete 'custom draw' techniques which should allow the first two of your 'wishes' here. Not sure what you mean with the last one, but remember that an egrid is based upon a ListIcon gadget and as such, there will come a point where the limitations of using this control begin to tell. I like the idea of embedding egrids within egrids, but I think that will require the creation of custom controls not based upon a ListIcon. Kind of like Xombie's impressive 'xgrid' which probably offers greater flexibility.

Anyhow, thanks for your observations, they are much appreciated. I will keep working on this.
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 »

Is it possible automatical activate the cell for editing direct after moving to it? (After selection I have to click on it , before I can insert text.)
Post Reply