Page 5 of 7

Re: Canvas based Grid gadget

Posted: Tue Nov 14, 2017 10:31 pm
by said
@davido, Andre and KCC the great, you are welcome and thanks for the nice words :D

A new update of this gadget is available now with help file (which is really needed!), i cleaned the code a lot and fixed few glitches on the way ... see first post for the link download

Said

Re: Canvas based Grid gadget

Posted: Wed Nov 22, 2017 4:31 pm
by OldSkoolGamer
Yes, this is definitely great!! Thanks for this. I'm going to replace the editable grid I have now in my current project with this one as it's much more powerful and has some features already done I need.

Re: Canvas based Grid gadget

Posted: Wed Nov 22, 2017 10:15 pm
by said
In the past days i had the chance to test more thoroughly this gadget, found few bugs and updated the help file :D
Any bug report is most welcome :)
So a revised version is available on the same github page ... see first post

Said

Re: Canvas based Grid gadget

Posted: Thu Nov 23, 2017 5:09 pm
by #NULL
Great work!
On linux I had to remove the constant at line 5026

Code: Select all

            MessageRequester("Error","Unable to create file ...") ; ,#MB_ICONERROR)
and I had to add a Font at line 3037

Code: Select all

            CompilerCase #PB_OS_Linux
                Protected   Font_T8    = LoadFont(#PB_Any, "Arial",11)

Re: Canvas based Grid gadget

Posted: Thu Nov 23, 2017 5:22 pm
by davido
@said,
Nice work, thank you for sharing.

@#NULL,
Also works on the Mac. Thanks for the tip.

Re: Canvas based Grid gadget

Posted: Thu Nov 23, 2017 10:59 pm
by said
#NULL wrote:Great work!
On linux I had to remove the constant at line 5026

Code: Select all

            MessageRequester("Error","Unable to create file ...") ; ,#MB_ICONERROR)
and I had to add a Font at line 3037

Code: Select all

            CompilerCase #PB_OS_Linux
                Protected   Font_T8    = LoadFont(#PB_Any, "Arial",11)
Yes that constant in the test-code is a left over from previous versions, i mostly use windows but the code is made of only PB native code so it should run fine on all supported platforms :)

Re: Canvas based Grid gadget

Posted: Thu Jan 04, 2018 6:28 am
by tangent685
Looks good as of Jan 3 2018. Hope development continues.

Re: Canvas based Grid gadget

Posted: Sun Apr 15, 2018 10:58 am
by mauriegio
Hello ,

thank for the grid is very useful wonderful gadget ..

I have a problem with combobox , after resize the example the combo open is non fased
on grid.

i use purebasic 5.62 on MacOs/windows and the problem is the same ...

is possible correct them ...

thank you

Maurizio

Re: Canvas based Grid gadget

Posted: Mon Apr 16, 2018 9:35 pm
by said
mauriegio wrote:Hello ,

thank for the grid is very useful wonderful gadget ..

I have a problem with combobox , after resize the example the combo open is non fased
on grid.

i use purebasic 5.62 on MacOs/windows and the problem is the same ...

is possible correct them ...

thank you

Maurizio
Hello,

You are welcome! Can you please show the steps that lead to described 'bug' ... i am unable to see the issue?!

Said

Re: Canvas based Grid gadget

Posted: Mon Apr 16, 2018 10:09 pm
by mauriegio
Thanks,

in the exampe if you open the windows to the max , combo box not fased when click on the arrow...

if you resize is seems ok ... but if go max ...problem

Maurizio

Re: Canvas based Grid gadget

Posted: Tue Apr 17, 2018 3:39 am
by said
Sorry Maurizio, i am still unable to reproduce!

Even installed PB 5.62 for this, still cant reproduce ... Tested on Windows 10 (both PB 32/64) with 200 DPI screen as well

Is anyone else facing this issue? Thanks for reporting

Re: Canvas based Grid gadget

Posted: Sat May 19, 2018 9:15 am
by infratec
Hi said,

I just needed your code in a small project, but after implemented a 'fixed' size, I found some confusing things:

Code: Select all

#ColWidth = 40
#RowHeight = 20

#Cols = 20
#Rows = 10

Enumeration
  #Grid1
  #Grid2
EndEnumeration
  
Define.i i

IncludeFile "MyGrid.pbi"

OpenWindow(0, 0, 0, 860, 460, "Test", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)

MyGrid::New(0, #Grid1, 10, 10, (#Cols + 1) * #ColWidth, (#Rows + 1) * #RowHeight, #Rows, #Cols, #False, #False, #False)
MyGrid::SetColWidth(#Grid1, MyGrid::#RC_Any, #ColWidth)
MyGrid::SetRowHeight(#Grid1, MyGrid::#RC_Any, #RowHeight)
MyGrid::Redraw(#Grid1)

MyGrid::New(0, #Grid2, 10, 240, (#Cols + 1) * (#ColWidth - 1), (#Rows + 1) * (#RowHeight - 1), #Rows, #Cols, #False, #False, #False)
MyGrid::SetColWidth(#Grid2, MyGrid::#RC_Any, #ColWidth)
MyGrid::SetRowHeight(#Grid2, MyGrid::#RC_Any, #RowHeight)
MyGrid::Redraw(#Grid2)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
If I set the size calculation to the 'right' values (#Grid1) then it looks to big.
The 'fault' growth when I increase the rows for example.

If I fix it by using a size which is one pixel smaller (#Grid2) (maybe the border pixel),
then it looks good, but...
when I go to the lowest row, via key down, it 'jumps' one row.
Same happens to the end of the cols.

Is this 'normal' behaviour or is there a small bug inside?

Is it an inconsistent usage of ColWidth and RowHeight?
In one case with border in one without.

I use the latest version from your link in post 1.
PB 5.62 x86 on Win10 x64

P.S.: one thing I was struggling about: everywhere it is width, height
In your New it is width, height, ROWS, COLS. I first used width, height, COLS, ROWS, which was wrong :wink:

Bernd

Re: Canvas based Grid gadget

Posted: Sat May 19, 2018 3:41 pm
by said
Hi Bernd,

You have guessed it right, there is always 1 pixel for the border (be it horizontal or vertical)

I believe, this little jump at the end of rows/cols is due to 1 pixel missing, here is how i would use this grid with a fixed size (your example re-worked):

Code: Select all

#ColWidth = 40
#RowHeight = 20

#Cols = 20
#Rows = 10

Enumeration
  #Grid1
  #Grid2
EndEnumeration
  
Define.i i

IncludeFile "MyGrid.pbi"

OpenWindow(0, 0, 0, 860, 460, "Test", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)

; MyGrid::New(0, #Grid1, 10, 10, (#Cols + 1) * #ColWidth, (#Rows + 1) * #RowHeight, #Rows, #Cols, #False, #False, #False)
; 
; For i = 0 To #Cols
;   MyGrid::SetColWidth(#Grid1, i, #ColWidth)
; Next i
; 
; For i = 0 To #Rows
;   MyGrid::SetRowHeight(#Grid1, i, #RowHeight)
; Next i
; 
; MyGrid::Redraw(#Grid1)

; neededWidth = 

neededWidth.i = (#ColWidth * (#Cols + 1) ) - #Cols
neededHeight.i = (#RowHeight * (#Rows + 1) ) - #Rows


MyGrid::New(0, #Grid2, 10, 240, neededWidth, neededHeight, #Rows, #Cols, #False, #False, #False)

For i = 0 To #Cols
  MyGrid::SetColWidth(#Grid2, i, #ColWidth)
Next i

For i = 0 To #Rows
  MyGrid::SetRowHeight(#Grid2, i, #RowHeight)
Next i

MyGrid::Redraw(#Grid2)


Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
I hope this helps :D

Said

Re: Canvas based Grid gadget

Posted: Mon Jul 09, 2018 9:07 pm
by the.weavster
@said

This is excellent!
Thank you very much for sharing :D

Re: Canvas based Grid gadget

Posted: Thu Aug 23, 2018 1:17 pm
by mk-soft
@said

very nice module.

Combobox works now under MacOS with Workaround for CanvasGadget

Link to FixResizeGadget: viewtopic.php?f=24&t=71269

P.S. MacOS
If the width of ScrollBarGadget to small then change the scrollbar to vertical
Fix:

Code: Select all

  Procedure.i New(WinNbr, Gadget, X, Y, W, H, Rows = 500, Cols = 100, DrawNow = #True, VerScrollBar = #True, HorScrollBar = #True, RowNumbers = #True)
    Protected *mg.TGrid, oldGdtList
    Protected ret,i,j,ttlW,ttlH,xx,yy
    
    If Not IsWindow(WinNbr) : ProcedureReturn -1 : EndIf
    If IsGadget(Gadget)     : ProcedureReturn -1 : EndIf
    
    *mg = AllocateStructure(TGrid)
    
    ; -- sub-gadgets creation
    oldGdtList = UseGadgetList(WindowID(WinNbr)) 
    ret = CanvasGadget(Gadget, X, Y, W, H, #PB_Canvas_Keyboard|#PB_Canvas_Container);|#PB_Canvas_Border)
    If Gadget = #PB_Any : Gadget = ret: EndIf
    
    *mg\RowScroll = -1
    *mg\ColScroll = -1
    If VerScrollBar
      *mg\RowScroll = ScrollBarGadget(#PB_Any,0,0,10,20,0,100,10, #PB_ScrollBar_Vertical)
      SetGadgetData(*mg\RowScroll, *mg)
      BindGadgetEvent(*mg\RowScroll, @_SynchronizeGridRows(), #PB_All)
    EndIf
    
    If HorScrollBar
      *mg\ColScroll = ScrollBarGadget(#PB_Any,0,0,20,10,0,100,10)
      SetGadgetData(*mg\ColScroll, *mg)
      BindGadgetEvent(*mg\ColScroll, @_SynchronizeGridCols(), #PB_All)
    EndIf
[/size]