Grid Controls package (Ver 1.5)

Developed or developing a new product in PureBasic? Tell the world about it.
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Grid Controls package (Ver 1.3)

Post by Zach »

Well I said I would do it many months ago, but I finally, finally got around to purchasing a license.

The spare cash automagically appeared in my bank account like I was hoping! :mrgreen:

(actually I quite smoking cigarettes a month and a half ago, and now I "vape" on my electronic cigarette, I used to spend $240/mo on 1pack a day, now I spend $100/mo tops for my ecig related supplies so managing spare cash has become easier)
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Grid Controls package (Ver 1.3)

Post by Olby »

Stephen,

Could you please take a look at this animation. As you can see instead of selecting the right cell it selects the previous one - I believe it could be a bug in Es/ExGrid. I double checked my code and even tried to redraw the grid (invalidate) right before selecting a cell in edit mode but to no avail.

Image

Basically I use a shortcut to add a number of cells, please also note that for some reason MakeCellVisible() will display only the upper part of a cell, I would rather prefer it to reveal whole shebang. Then I go a ahead and delete one by one (behind the scenes it clears all rows and reloads data from the database) and select last cell in the grid, so far so good. Unfortunately when it comes to placing edit control at the right height it does that wrong and instead places it one row above. I double checked my code and don't seem to find anything that could cause this. It's just the edit control - if I click tab it will move one cell to the right and below (back to correct row).

Thanks.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Grid Controls package (Ver 1.3)

Post by srod »

I would need something I could reproduce myself, so some code and/or instructions would be useful.

My guess is that you might be doing things in a CellCallback function which isn't really allowed, but as I say I would need some idea of how to reproduce this. I have hacked up some code, using a shortcut to remove and add rows and to then select the first cell in the last row etc. (all with code) and can find no problems thus far.
I may look like a mule, but I'm not a complete ass.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Grid Controls package (Ver 1.3)

Post by Olby »

I commented out my callback code completely but I still get the same behaviour.
Make sure that your grid can show only a handful of rows at the same time, as far as I can tell it is an issue with scroll bar.
Once you delete last row, grid will scroll up one row at a time and this is where misalignment of edit control happens.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Grid Controls package (Ver 1.3)

Post by srod »

Can you pm or e-mail me your code please?

I have tried everything here and cannot reproduce the problem as yet.
I may look like a mule, but I'm not a complete ass.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Grid Controls package (Ver 1.3)

Post by Olby »

Here, I recreated the issue for you (as am not allowed to share the source code).

Code: Select all

IncludePath "GridControls" : XIncludeFile "ExGRID\ExGRID.pbi"

Procedure.l  CellCallback(exgrid,uMsg,*cellinfo.ExGRIDCellInfo)
	Protected result,hWnd
	Select uMsg
			
		Case #ExGRID_FORMATCELL
			*cellinfo\backcolour=RGB(255, 246, 81)
			If *cellinfo\row<>-1 And *cellinfo\column<>-1 And *cellinfo\row=ExGRID_GetSelectedRow(exgrid)
				*cellinfo\backcolour=RGB(81, 183, 255)
			EndIf
			*cellinfo\forecolour=0
			result=#True
		
		Default
			result=#True
			
	EndSelect
	ProcedureReturn result
EndProcedure 

If OpenWindow(0,#PB_Ignore,#PB_Ignore,640,480,"ExGrid",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
	
	EditorGadget(0,10,10,512,128,#PB_Editor_ReadOnly):SetGadgetText(0,"Hold CTRL+A to add about 30 or so rows then hit CTRL+D to delete one by one."+#CRLF$+#CRLF$+"As soon as you get to the point where scrollbar needs to move up you'll notice the issue.")
	StringGadget(1,522,10,110,350,"Fields",#PB_String_ReadOnly)
	StringGadget(2,10,360,620,110,"Thumbnails",#PB_String_ReadOnly)
	ContainerGadget(3,10,138,512,222)
	Global *exgrid.ExGRID=ExGRID_Create(0,0,512,170,25,#ExGRID_GRIDLINES|#ExGRID_RESIZECOLUMNSTRUE|#ExGRID_SINGLELINETEXT|#ExGRID_ADDSTANDARDROWICONS)
	With *exgrid
		\AllowScreenUpdates(#False,#False)
    \SetColumnHeader(25)
    \SetRowHeader(40)
    \SetOption(#ExGRID_ERASECOLOR,RGB(167, 167, 167))
    \SetOption(#ExGRID_GRIDLINECOLOR,RGB(61, 61, 61))
    \SetOption(#ExGRID_ROWHEADERMARGINCOLOR,RGB(167, 167, 167))
    \SetOption(#ExGRID_SELECTEDCELLSCOLOR,RGB(255, 251, 174))
    \SetOption(#ExGRID_SETCELLSELECTIONRANGE,#ExGRID_PROHIBITCELLSELECTION)
    \SetOption(#ExGRID_SELECTIONBORDERWIDTH,2)
    \SetOption(#ExGRID_SELECTIONBORDERCOLOR,RGB(255,0,0))
		\AddColumn(-1,"Col1",100)
		\AddColumn(-1,"Col2",100)
		\AddColumn(-1,"Col3",100)
		\AddColumn(-1,"Col4",100)
		\CreateCellCallback(@CellCallback())
    \AllowScreenUpdates(#True,#True)
    \HideGrid(#False)
	EndWith
	CloseGadgetList()
	
	SplitterGadget(4,10,10,512,468,0,3,#PB_Splitter_Separator)
	SplitterGadget(5,10,10,622,350,4,1,#PB_Splitter_Separator|#PB_Splitter_Vertical)
	SplitterGadget(6,10,10,620,460,5,2,#PB_Splitter_Separator)
	
	SetGadgetState(5,510)
	SetGadgetState(6,350)
	
	AddKeyboardShortcut(0,#PB_Shortcut_Control|#PB_Shortcut_A,100)
	AddKeyboardShortcut(0,#PB_Shortcut_Control|#PB_Shortcut_D,101)
	
	Define rows.l
	Repeat
		Select WaitWindowEvent(100)
			Case #PB_Event_CloseWindow:Break
			Case #PB_Event_Menu
				Select EventMenu()
					Case 100
						*exgrid\HideEditControls()
						*exgrid\AllowScreenUpdates(#False)
						rows=*exgrid\GetNumberOfRows()
						While *exgrid\GetNumberOfRows():*exgrid\RemoveRow(0):Wend
						For n=1 To rows+1
							*exgrid\AddRow(-1,Str(n))
						Next n
						*exgrid\SelectCell(0,*exgrid\GetNumberOfRows()-1,#True,#True)
						;InvalidateRect_(ExGRID_GethWnd(*exgrid),0,0)
						*exgrid\AllowScreenUpdates(#True)
					Case 101
						*exgrid\HideEditControls()
						*exgrid\AllowScreenUpdates(#False)
						*exgrid\RemoveRow(*exgrid\GetNumberOfRows()-1)
						rows=*exgrid\GetNumberOfRows()
						While *exgrid\GetNumberOfRows():*exgrid\RemoveRow(0):Wend
						For n=1 To rows
							*exgrid\AddRow(-1,Str(n))
						Next n
						*exgrid\SelectCell(0,*exgrid\GetNumberOfRows()-1,#True,#True)
						;InvalidateRect_(ExGRID_GethWnd(*exgrid),0,0)
						*exgrid\AllowScreenUpdates(#True)				
				EndSelect
		EndSelect
	ForEver
	
EndIf

End
Image

Please let me know if it is something that I do wrong. Note that I have used the same form layout I have in our application (nested containers), but it's not causing ExGrid to hiccup.

Thanks for taking a look at this.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Grid Controls package (Ver 1.3)

Post by srod »

Place the :

Code: Select all

*exgrid\AllowScreenUpdates(#True)
line before the

Code: Select all

*exgrid\SelectCell(0,*exgrid\GetNumberOfRows()-1,#True,#True)
line. :wink:
I may look like a mule, but I'm not a complete ass.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Grid Controls package (Ver 1.3)

Post by Olby »

Aha, works great.. Thanks mate, it's my habit of making forms ready before they're refreshed/made visible. :)
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Grid Controls package (Ver 1.3)

Post by srod »

27th Jan 2014.

Major update to our grid controls package. More specifically, upgrades to EsGRID (version 2.3) and ExGRID (version 1.4). The tBOX property box control has not been upgraded.

Purebasic 5.21LTS onwards.

We have added a much requested feature, namely drag / drop... and fixed some bugs! :smile:

We can now drag the text from the currently selected range of cells and drop onto any control/window enabled for drops (e.g. those enabled with the Purebasic EnableTextDrop() function or an Excel sheet etc.) We can also drop the text dragged from any suitable control (not just our grids) onto a suitably enabled grid. For example, select a range of cells from Excel and drag them onto one of our grids.

This has required quite an upheaval of the EsGRID code base in particular, so please regard the 1.4 version of the Grid Controls Package as a 'test' version. There will be some bugs which remain for sure.

Please see the relevant 'history.txt' files for a good summary of the changes made to the various APIs etc. No old code should break as a result of these changes (bugs withstanding of course!) The various user manuals have been updated. In particular, each manual has a page given over to drag / drop which are well worth reading.

A brief summary of our drag / drop :
  • Client apps have full control over drag / drop operations via cellcallback functions (as usual)
  • If dropping onto any window/control other than the original EsGRID, then the drop defaults to a copy. The dragged cells in the original grid are left untouched. We did this to mimick the way Excel handles such drags etc.
  • If dragging between grids in the same process, then the drop target will automatically scroll as the cursor drags over it. This can be extended to include non-grid drag sources (in the same process as the drop though).
  • If dragging between grids in the same process, then the drop range will conform exactly to the drag range. For example, if a single row of 10 cells are dragged by clicking into the 3rd cell from the left, then when dropped onto a grid from the same process, the cells will be dropped so that the cell beneath the drop cursor is the 3rd cell from the left.
  • It goes without saying that you can drag and drop to the same grid!
There is a very basic demo for EsGRID showing drag / drop in action. It would be a piece of cake to translate to ExGRID. All manuals updated and so on.

Those who purchased the full Grid Controls Package can download from the usual place.

Those who purchased just the EsGRID control (or the original egrid control) then please contact us and the latest version of EsGRID will be e-mailed. This applies no matter how long ago the original purchase as per the terms of lifetime updates.

**EDIT : oh yes, modified ExGRID so that it can now be used in a PB splitter gadget. :)

Regards.
I may look like a mule, but I'm not a complete ass.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Grid Controls package (Ver 1.4)

Post by luis »

Thanks for the update :wink:
"Have you tried turning it off and on again ?"
A little PureBasic review
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Grid Controls package (Ver 1.4)

Post by srod »

luis wrote:Thanks for the update :wink:
You're welcome. :)

There will be another update soon after I look at speeding up some of the string heavy routines... copy, paste (not to mention drag / drop). Will look to use some 'string builder' type class and direct clipboard access in an attempt to cut some of the considerable overhead here.
I may look like a mule, but I'm not a complete ass.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Grid Controls package (Ver 1.4)

Post by Olby »

srod wrote:
luis wrote:Thanks for the update :wink:
You're welcome. :)

There will be another update soon after I look at speeding up some of the string heavy routines... copy, paste (not to mention drag / drop). Will look to use some 'string builder' type class and direct clipboard access in an attempt to cut some of the considerable overhead here.
Wow, an update for my favourite PB library! Looking forward to testing it out. Thanks srod!
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Re: Grid Controls package (Ver 1.4)

Post by Sparkie »

Thanks for the update srod!

Your grids have saved me countless hours of coding time, as well as adding some glitz and glitter to my apps. 8)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Grid Controls package (Ver 1.4)

Post by srod »

Olby wrote:Wow, an update for my favourite PB library! Looking forward to testing it out. Thanks srod!
Sparkie wrote:Thanks for the update srod!

Your grids have saved me countless hours of coding time, as well as adding some glitz and glitter to my apps. 8)
:D

You're welcome.

A couple of days away from another update. So far I have managed to speed copy/paste up by a factor of almost 20 I reckon (tested on a copy/paste of 50000 cells). Need to do the same for deletion of multiple cells and drag/drop + a few other bits and bobs and we'll be done. :)
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...

Re: Grid Controls package (Ver 1.5)

Post by srod »

1st Feb 2014.

Following the recent major update (ver 1.4), we follow with a second which, amongst other things, improves on the newly added drag/drop and the long standing copy/paste routines.

This updates mostly effects the EsGRID control (now version 2.4), but with some minor alterations to ExGRID (now version 1.5) to keep in line with those changes.

Please see the EsGRID 'history.txt' file in particular for a list of changes etc. This update can break code designed for the recently updated 1.4 version, but not serious ones.

A brief summary of what has changed :
  • Have reworked the delete, copy/paste, drag/drop routines massively which, if dealing with a large range of cells, were very slow and inefficient. The routines now use very little of PB's string library and use direct API for clipboard access and OLE drops.
  • Drags with a 'move' action will result (if successful) in the original cells being deleted regardless of whether the drop occurs on the source control or otherwise. This was not the case in the previous version. Of course this does not happen if the drop was cancelled for any reason (e.g. through a cellcallback function).
  • #egrid_ClipboardOrDragDrop (and ExGRID_CLIPBOARDORDRAGDROP) cellcallback messages have been altered slightly to give more info on drops with the addition of a couple of extra fields in the cellinfo structures.
  • Potential drop targets (assuming they are one of our grids) will now automatically scroll even if the drag source is in another process.
  • When cells are pasted, the target range of cells is now automatically selected (and highlighted) on completion of the operation. This matches what happens when cells are dropped onto a grid.
  • Added the facility for preventing all 'cell updated' notifications from being sent. This can speed up the paste, delete and drop actions significantly if dealing with large grids.
There is one thing to definitely be aware of, namely that any program compiled in Unicode mode will only accept dropped text which is in Unicode format. A similar statement holds for Ascii. This should not be too big a problem since many apps allowing text drags, offer up the text in both formats. E.g. no problem dragging from Excel etc. If this proves a problem then we can change this.

There is another limitation regarding the number of characters which will be copied from individual cells. See the manuals for that.

There are a couple of other changes as well.

Those who purchased the full Grid Controls Package can download from the usual place.

Those who purchased just the EsGRID control (or the original egrid control) then please contact us and the latest version of EsGRID will be e-mailed. This applies no matter how long ago the original purchase as per the terms of lifetime updates.

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