A basic grid control (major revision)

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

Post by srod »

Thanks for testing the fix, it's all beginning to shape up quite nicely now.
I may look like a mule, but I'm not a complete ass.
Jellybean
User
User
Posts: 95
Joined: Wed Aug 24, 2005 7:33 pm

Post by Jellybean »

Fixed, but you might want to have a look at this if it's not intentional: When scrolling the text field out of view and then into view again using the scroll wheel it has lost focus.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Jellybean:

My intention is to reposition the edit box everytime the grid is scrolled (like a spreadsheet etc.) and so I don't really intend for the edit box to retain focus, at least not at this stage.

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

Post by srod »

Update:

the work is coming along nicely, but a lot of the internals have changed. In particular, Egrids now have their own containers in order to avoid the user having to use a windows callback function just to utilise an 'egrid' gadget.

Have added:
  • facility to prevent the user from resizing columns (via a simple flag)
    resizing of an egrid
    facility to colour individual cells
Hopefully, all scrolling issues have been rectified, but as the code has changed quite a lot, I am again looking for testers etc.

I think things will move quickly now, particularly with the following 'todo' list:
  • Colour the string gadget being used to edit cells to match the underlying cell (easy)
    allow the header row to be resized (not so easy)
    scrolling through cells using direction and tab keys etc.
    At present, the entire egrid scrolls but the focus remains with the cell
    currently being edited (easyish!)
    Click and drag multiple cell selection and associated operations (fiddly!)
Having learnt a whole heap from this project already, I can now begin to see how to extend this work (custom draw) to allow various gadgets to be embedded within individual cells etc.

In the meantime, I thank everyone who can help track down the more elusive bugs.

http://www.purecoder.net/purebasic/egrid.zip
I may look like a mule, but I'm not a complete ass.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Works great, no problems at all in Win2000.
Is it possible to use arrows keys to move the selected cel?
Pressing return to move to the next one, with editing cursor already activated?
:)
zikitrake
Addict
Addict
Posts: 868
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

srod, My new project wants to thank you for this code. :D
PB 6.21 beta, PureVision User
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Blade wrote:
Is it possible to use arrows keys to move the selected cel?
Pressing return to move to the next one, with editing cursor already activated?
That's one of the things on the 'todo' list. The current scrolling mechanism is just a stop-gap solution!

Thanks.


***Minor update***
The string gadget used to edit cells is now painted to match the text and background colours of the underlying cell exactly.

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

***Major revision - now version 1.1***

Work is nearly complete now on this first version of an editable grid control. However, I've had to re-write a major chunk of the code because of a problem with Windows and so am again putting this out for bug-spotting purposes.

Previous versions required the user to create a ‘cell map’ in order to colour the cells of an egrid. This is no longer required because of the facility to include a user defined callback procedure.
Such callbacks are optional and allow the developer to validate changes made to individual cells (changes can be refused), to write only the changed cells back to a database etc. and also allows for the colouring of individual cells.
This paves the way for the creation of ‘virtual’ egrids later on.

Have also added:
  • header control no longer displays the resizing cursor if the underlying egrid has the resizecolumnsflag set to #egrid_ResizeColumnsFalse.
  • bug fixed. Prohibiting the resizing of columns did not work on Windows 98 etc.
  • Added egrid_SetHeaderFont(#Gadget, fontID) command which allows the font to be changed within the header row (which is automatically resized).
  • Added egrid_SetHeaderHeight(#Gadget, fontID) command which allows the height of the header row to be changed.
  • Added functions egrid_NumberOfRows(#Gadget) and egrid_NumberOfColumns(#Gadget).
  • the edit control (string gadget) now displays text with the same text colour and background colour as the underlying cell etc.
Thanks again to all testers.

http://www.purecoder.net/purebasic/egrid.zip
Last edited by srod on Fri Sep 30, 2005 10:09 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Very very nice but you have to click TWO times in a row on the same cell to change which control is affected by the scrollwheel.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Trond wrote:Very very nice but you have to click TWO times in a row on the same cell to change which control is affected by the scrollwheel.
I think I've fixed this. I'm unable to test the fix though as I do not have a mousewheel!

Thanks for testing.
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 »

It's great! I'm looking for a long time to find a usable grid. :D

It would be nice to have:
- disable Stringgadget for protected column.
- move selektion (from protected cell to the next editable cell)

Thanks for your work.

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

Post by srod »

Thanks Thorsten.

I'm working on moving between cells with the cursor keys right now and then it will be click-and-drag type multiple cell selection. I like your idea, although my example program shows one way of using the CellCallback function to protect a column. I think I'll add to this mechanism to give the user complete control over the string gadget and thus the developer will be able to prevent the user even clicking in a protected column.

Regards.
I may look like a mule, but I'm not a complete ass.
Post Reply