Page 3 of 23

Posted: Fri Apr 20, 2007 8:50 pm
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.

Posted: Fri Apr 20, 2007 8:52 pm
by Thorsten1867
It seem to work all after changing. :D

Posted: Wed May 16, 2007 5:02 pm
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

Posted: Wed May 16, 2007 5:09 pm
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 

Posted: Wed May 16, 2007 5:26 pm
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.

Posted: Wed May 16, 2007 5:29 pm
by QuimV
I just see it now, in the SplitterGadget() help of PB.
Thanks.

Posted: Wed May 16, 2007 8:57 pm
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:

Posted: Fri May 18, 2007 12:33 pm
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 

Posted: Fri May 18, 2007 1:10 pm
by srod
I warned you about the splitter! :)

Is it the same with a normal listicon in a splitter?

Posted: Fri May 18, 2007 1:27 pm
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.

Posted: Sat May 19, 2007 10:57 pm
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.

Posted: Sun May 20, 2007 12:15 pm
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...) :)

Posted: Sun May 20, 2007 12:27 pm
by Thorsten1867
Please!!! Change no important existing commands. :?
I have to change 49 egrids in 4 programs (respectively tools)!!!

Posted: Sun May 20, 2007 12:33 pm
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! :)

Posted: Sun May 20, 2007 1:17 pm
by QuimV
:D srod, Thank you for your help.

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

Thanks again.