EsGRID grid gadget 2.1. Don't post here!

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry about that! :)

egrid_SetOptions() was getting a little out of hand. Of course egrid_SetOption() is a lot more flexible and easily extended for future use.

It shouldn't take you long to ammend your code to use egrid_AddRows() 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 »

It seem to work all after changing. :D
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

Hi,

Anybody knows how to add 2 grids to an SplitterGadget?
Here are an example code.

:o When i create the SplitterGadget, the grids remain disabled and the
SplitterGadget doesn't run.

Thanks

Code: Select all

#Grid_Items_1=1
#Grid_Items_2=2
#SplitterH=3

If OpenWindow(0, 0, 0, 545, 445, "Grids", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  egrid_CreateGrid(#Grid_Items_1, 1, 24, 545, 222,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
  egrid_CreateGrid(#Grid_Items_2, 1, 247, 545, 222,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
  egrid_SetHeaderHeight(#Grid_Items_1, 20)
  egrid_SetHeaderHeight(#Grid_Items_2, 20)
  
  For c=0 To 10
    egrid_AddColumn(#Grid_Items_1, c, "C", 100)
    egrid_AddColumn(#Grid_Items_2, c, "C", 100)
  Next c
  
  egrid_AddRows(#Grid_Items_1, -1, 10)
  egrid_AddRows(#Grid_Items_2, -1, 10)

  ;This two lines doesn't run fine
  SplitterGadget(#SplitterH,1,24,545,445,#Grid_Items_1,#Grid_Items_2,#PB_Splitter_Separator)
  SetGadgetState(#SplitterH, 247)

  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
QuimV
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

The Splitter resizes the egrid, use this:

Code: Select all

#Grid_Items_1=1
#Grid_Items_2=2
#SplitterH=3

If OpenWindow(0, 0, 0, 545, 445, "Grids", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  egrid_CreateGrid(#Grid_Items_1, 1, 24, 0, 0,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
  egrid_CreateGrid(#Grid_Items_2, 1, 247, 0, 0,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
  egrid_SetHeaderHeight(#Grid_Items_1, 20)
  egrid_SetHeaderHeight(#Grid_Items_2, 20)
 
  For c=0 To 10
    egrid_AddColumn(#Grid_Items_1, c, "C", 100)
    egrid_AddColumn(#Grid_Items_2, c, "C", 100)
  Next c
 
  egrid_AddRows(#Grid_Items_1, -1, 10)
  egrid_AddRows(#Grid_Items_2, -1, 10)

  ;This two lines doesn't run fine
  SplitterGadget(#SplitterH,1,24,545,445,#Grid_Items_1,#Grid_Items_2,#PB_Splitter_Separator)
  SetGadgetState(#SplitterH, 247)

  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf 
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

:D
Thanks a lot, ts-soft.
But, how do you know that?
Have you found any new documentation about egrid v.5?
Thanks again.
QuimV
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

I just see it now, in the SplitterGadget() help of PB.
Thanks.
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Curious, the splitter gadget should not work at all with egrids!

An egrid sits in it's own container and should not be resized by any means other than the egrid_Resize() command.

That it even works is very surprising! Still the amount of flicker does suggest that not everything is running smoothly.

To be honest you'd be best using a custom splitter which only resizes the egrid at the end of the appropriate mouse operation (like the PB IDE).

Also, thanks to messing around with the splitters, I have found an obscure bug in the egrid library. You mght notice some very odd behaviour if you use a vertical splitter! :) I've fixed it, but it's not worth updating all the libraries just yet.

Again though, I strongly advise against using a PB splitter with egrids.

I think for the next update I'll aim to remove the container completely. This may, however, break some egrid user's code. The container is a left over from the dark early days of my PB career when I didn't know my arse from my elbow! I now know it's that thing I talk out of! :wink:
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

srod,

:? Another disfunction sorting grids embedded in a SplitterGadget.
Any idea about a solution o workaround in order to sort ...

Thanks in advanced.

Here it is the test code:

Code: Select all

#Grid_Items_1=1 
#Grid_Items_2=2 
#SplitterH=3 

If OpenWindow(0, 0, 0, 545, 445, "Grids", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  egrid_CreateGrid(#Grid_Items_1, 1, 24, 0, 0,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText) 
  egrid_CreateGrid(#Grid_Items_2, 1, 247, 0, 0,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText) 
  egrid_SetHeaderHeight(#Grid_Items_1, 20) 
  egrid_SetHeaderHeight(#Grid_Items_2, 20) 
  
  For c=0 To 10 
    egrid_AddColumn(#Grid_Items_1, c, "C", 100) 
    egrid_AddColumn(#Grid_Items_2, c, "C", 100) 
  Next c 
  
  egrid_AddRows(#Grid_Items_1, -1, 10) 
  egrid_AddRows(#Grid_Items_2, -1, 10) 
  
  egrid_SetCellText(#Grid_Items_1, 0, 0, "a")
  egrid_SetCellText(#Grid_Items_1, 0, 1, "c")
  egrid_SetCellText(#Grid_Items_1, 0, 2, "b")

  ;This line INVALIDE the function PureLVSORT_SortListIconNow. The function doesn't work
  SplitterGadget(#SplitterH,1,24,545,445,#Grid_Items_1,#Grid_Items_2,#PB_Splitter_Separator) 
  SetGadgetState(#SplitterH, 247) 

  PureLVSORT_SortListIconNow(#Grid_Items_1, 0, 1) 

  ret = PureLVSORT_SelectGadgetToSort(#Grid_Items_1,#PureLVSORT_ShowClickedHeader_Text) ;
  Select ret
    Case #PureLVSORT_Ok			          ; Success
      Debug "#PureLVSORT_Ok"
    Case #PureLVSORT_NotAGadget		    ; Specified gadget does not exist
      Debug "#PureLVSORT_NotAGadget"
    Case #PureLVSORT_MemoryAllocationProblem	; Memory allocation failed
      Debug "#PureLVSORT_MemoryAllocationProblem"
    Case #PureLVSORT_UndefinedGadget	; Specified gadget was not initialized with PureLVSORT_SelectGadgetToSort()
      Debug "#PureLVSORT_UndefinedGadget"
    Default
      Debug "Default. ret = " + Str(ret)
  EndSelect

  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I warned you about the splitter! :)

Is it the same with a normal listicon in a splitter?
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 »

A workaround:

Code: Select all


XIncludeFile "egrid5.pb"
DisableExplicit


#Grid_Items_1=1 
#Grid_Items_2=2 
#SplitterH=3 

If OpenWindow(0, 0, 0, 545, 445, "Grids", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  egrid_CreateGrid(#Grid_Items_1, 1, 24, 0, 0,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText) 
  egrid_CreateGrid(#Grid_Items_2, 1, 247, 0, 0,20,#egrid_GridLines|#egrid_HeaderDragDrop|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText) 
  egrid_SetHeaderHeight(#Grid_Items_1, 20) 
  egrid_SetHeaderHeight(#Grid_Items_2, 20) 
  
  For c=0 To 10 
    egrid_AddColumn(#Grid_Items_1, c, "C", 100) 
    egrid_AddColumn(#Grid_Items_2, c, "C", 100) 
  Next c 
  
  egrid_AddRows(#Grid_Items_1, -1, 10) 
  egrid_AddRows(#Grid_Items_2, -1, 10) 
  
  egrid_SetCellText(#Grid_Items_1, 0, 0, "a") 
  egrid_SetCellText(#Grid_Items_1, 0, 1, "c") 
  egrid_SetCellText(#Grid_Items_1, 0, 2, "b") 

  ret = PureLVSORT_SelectGadgetToSort(#Grid_Items_1,#PureLVSORT_ShowClickedHeader_Text) ; 

  ;This line INVALIDE the function PureLVSORT_SortListIconNow. The function doesn't work 
  SplitterGadget(#SplitterH,1,24,545,445,#Grid_Items_1,#Grid_Items_2,#PB_Splitter_Separator) 
  SetGadgetState(#SplitterH, 247) 

  PureLVSORT_SortListIconNow(#Grid_Items_1, 0, 1) 
  Select ret 
    Case #PureLVSORT_Ok                   ; Success 
      Debug "#PureLVSORT_Ok" 
    Case #PureLVSORT_NotAGadget          ; Specified gadget does not exist 
      Debug "#PureLVSORT_NotAGadget" 
    Case #PureLVSORT_MemoryAllocationProblem   ; Memory allocation failed 
      Debug "#PureLVSORT_MemoryAllocationProblem" 
    Case #PureLVSORT_UndefinedGadget   ; Specified gadget was not initialized with PureLVSORT_SelectGadgetToSort() 
      Debug "#PureLVSORT_UndefinedGadget" 
    Default 
      Debug "Default. ret = " + Str(ret) 
  EndSelect 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
One last time though, don't use a PB splitter gadget with egrids! I will not be held responsible for the outcome! :wink:

I need to alter egrid in order for things like PB Splitter gadgets to work properly etc. Bit busy at the moment though.
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

Hi srod,

About your question "Is it the same with a normal listicon in a splitter?".

The answer is that, with normal listicons, splitter and sort functions work together fine.

Thanks for your workaround but i can't apply it because he user can activate and deactivate sort function after the splittargadget creation. I mean that firt is created splittergadget and then the user can try to use or not sort functions.

Thanks for your help.
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Okay, I'll try and update egrid to remove these problems and make it a little more compatible with Purebasic gadgets. I'm not sure if the splitter will behave itself even then, such is the complexity of an egrid.

I might end up breaking all existing code though; in fact I'm quite sure that I will. :?

(srod looks gingerly out of the window for the lynch mob headed by Thorsten...) :)
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 »

Please!!! Change no important existing commands. :?
I have to change 49 egrids in 4 programs (respectively tools)!!!
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...

Post by srod »

The only command which might change is the egrid_CreateGrid() command, and even here I'm unsure as yet. I need to tear out the container I used for the egrid and redirect all code from the container to the parent window/control.

It will mean, however, Thorsten that those fixes you employed to get some resizing libraries to work with egrid will no longer be valid as there will no longer be a container control to worry about. Instead you can point the resizing libraries directly at the egrid concerned.

So, for most code, things should be somewhat simpler. Only your code might be unduly affected.

I'll try and be gentle though! :)
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

:D srod, Thank you for your help.

Could you give me an idea about when will be the update available?

Thanks again.
QuimV
Post Reply