Page 5 of 5
Re: [Module] GridExModule.pbi
Posted: Mon Aug 05, 2019 1:35 pm
by Thorsten1867
Re: [Module] GridExModule.pbi
Posted: Mon Aug 05, 2019 2:39 pm
by collectordave
Just taking first steps to make a GridEx editable and using this code
Code: Select all
GridEx::SetCellFlags(DBGrid, GridEx::#AnyRow,1,GridEx::#Edit)
To get the first column editable which does not seem to work (maybe significant I have hidden the row header)
Strangly if I change the flag to:
Code: Select all
GridEx::SetCellFlags(DBGrid, GridEx::#AnyRow,1,GridEx::#Checkbox)
I get a checkbox in the first column?
Any Ideas?
CD
Re: [Module] GridExModule.pbi
Posted: Mon Aug 05, 2019 3:07 pm
by collectordave
Trying a few more things.
Code: Select all
;Hide Row Header
; GridEx::HideColumn(DBGrid, 0, #True)
GridEx::SetColumnWidth(DBGrid,0,5)
If I use HideColumn then I cannot set the edit flag on column 1
If I use setcolumnwidth with a value of 5 (as above) then I can. Anything less than 5 and again I cannot.
Re: [Module] GridExModule.pbi
Posted: Mon Aug 05, 2019 5:42 pm
by jack
on macOS I get an error in the procedure AddFont
[11:41:00] Waiting for executable to start...
[11:41:00] Executable type: MacOSX - x64 (64bit, Unicode)
[11:41:00] Executable started.
[11:41:01] [ERROR] GridExModule.pb (Line: 3567)
[11:41:01] [ERROR] LoadFont(): invalid value specified for parameter 'Flags'.
[11:41:04] The Program was killed.
Re: [Module] GridExModule.pbi
Posted: Fri Oct 18, 2019 6:34 am
by kinglestat
Looks quite neat
Question: How does one us keyboard to select cell and edit? It seems only by double-clicking with mouse editing is possible
Re: [Module] GridExModule.pbi
Posted: Fri Oct 18, 2019 8:11 am
by Cyllceaux
Hm...
Why is it not in the git repository? Or is it the same like ListEx?
Re: [Module] GridExModule.pbi
Posted: Fri Oct 18, 2019 3:12 pm
by Thorsten1867
It would first have to be completely reworked (e.g. DPI) and most of my own functions I have taken over in ListEx.
Re: [Module] GridExModule.pbi
Posted: Thu Oct 24, 2019 12:30 pm
by kinglestat
ListEx is amazing! Great work and thanks for sharing
Re: [Module] GridExModule.pbi
Posted: Fri Dec 04, 2020 5:47 pm
by eck49
I'm very hesitant to suggest there may be a bug in this superb and complex module so long after its release, but this behaviour doesn't look intentional.
Running PB5.70 on Linux, downloaded GridEx (10142 lines) from the link in the post of 5 August 2019 in this thread.
Just Running Example 2 as provided in the pbi. Resizing the whole window using the bottom right corner handle, expanding in two or three steps , then afterwards shrinking. The first one or two expansions usually work, but later expansions of the window actually see the grid shrink (actually the canvas, I think). Once this starts, every subsequent window size change causes the canvas/grid to shrink until something pops. The canvas/grid X and Y never changes.
The behaviour I hope for would keep the canvas height & width in proportion to the window height & width and adjust the X and Y too.
This is a snippet of code starting at line 8448 as provided.
Code: Select all
Procedure ResizeHandler(GID.i)
Define.i WinId, X, Y, Width, Height, ColWidth
If IsGadget(GID)
If FindMapElement(Grid(), Str(GID))
WinID = Grid()\WinID
If IsWindow(WinID)
X = Grid()\Size\X
Y = Grid()\Size\Y
Width = Grid()\Size\Width + (WindowWidth(WinID) - Grid()\Window\Width)
Height = Grid()\Size\Height + (WindowHeight(WinID) - Grid()\Window\Height)
If Width < 2 : Width = 2 : EndIf
If Height < 2 : Height = 2 : EndIf
Replacing the snippet with the following seems to do what I want:
Code: Select all
Procedure ResizeHandler(GID.i)
Define.i WinId, X, Y, Width, Height, ColWidth
Define.f RatioW, RatioH
If IsGadget(GID)
If FindMapElement(Grid(), Str(GID))
WinID = Grid()\WinID
If IsWindow(WinID)
RatioW = WindowWidth(WinID) / Grid()\Window\Width
RatioH = WindowHeight(WinID) / Grid()\Window\Height
X = Grid()\Size\X * RatioW
Y = Grid()\Size\Y * RatioH
Width = Grid()\Size\Width * RatioW
Height = Grid()\Size\Height * RatioH
If Width < 2 : Width = 2 : EndIf
If Height < 2 : Height = 2 : EndIf
It doesn't look to me as if anything else needs to change, but I'm a fairly useless unit tester and have not probed the code very deeply....
The change in the behaviour of X and Y can be seen better if the original position of the grid when the window is set up in the calling code is changed to (say) 100,100 instead of 10,10.
Re: [Module] GridExModule.pbi
Posted: Sat Dec 05, 2020 5:07 pm
by eck49
Well, it's improved but not perfect. If a fairly small window (say, quarter screen) with several grids is expanded a lot, and then shrunk, and this is done several times, finishing up with a window of the original size, the grids will not have returned to their original location, although the sizes look about right.
I can't discover the cause. Perhaps it is that each change is granular - ie based only on the immediately previous state, not on the overall expansion or contraction since the grid was first set up? But in that case shouldn't it have affected the sizes of the grids, not just the X and Y?
Re: [Module] GridExModule.pbi
Posted: Sat Dec 05, 2020 8:30 pm
by eck49
Applying the idea from my last post seems to sort out the issue I raised there.
This is what I did: line numbers are now approximate, so I have kept some unaltered context in each snippet.
1) Add to structure - it may not be the best structure to put this in (indeed it may merit one of its own) but I hope this choice does not cause a problem. Blame my lack of insight into the complexity of the design.
Near line 800
Code: Select all
Structure Grid_Size_Structure ; Grid()\Size\...
X.i
Y.i
Width.i
Height.i
CanvasWidth.i
CanvasHeight.i
;2020-12-05 start: added to facilitate better resizing
Original_X.i
Original_Y.i
Original_WindowWidth.i
Original_WindowHeight.i
Original_CanvasWidth.i
Original_CanvasHeight.i
;2020-12-05 end
EndStructure
2) Then in the ResizeHandler Procedure (replacing yesterday's work) around line 8500
Code: Select all
Procedure ResizeHandler(GID.i)
Define.i WinId, X, Y, Width, Height, ColWidth
Define.f Ratiow, Ratioh
If IsGadget(GID)
If FindMapElement(Grid(), Str(GID))
WinID = Grid()\WinID
If IsWindow(WinID)
;2020-12-05 start: use ratios relative to ORIGINAL width (etc)
Ratiow = WindowWidth(WinID) / Grid()\Size\Original_WindowWidth
Ratioh = WindowHeight(WinID) / Grid()\Size\Original_WindowHeight
X = Grid()\Size\Original_X * Ratiow
Y = Grid()\Size\Original_Y * Ratioh
Width = Grid()\Size\Original_CanvasWidth * Ratiow
Height = Grid()\Size\Original_CanvasHeight * Ratioh
;2020-12-05 end
If Width < 2 : Width = 2 : EndIf
If Height < 2 : Height = 2 : EndIf
3) And finally, in the Gadget Procedure itself near line 9750.
This may not be quite the best place for it because I am unsure what part the nearby If/Endif blocks play
Code: Select all
If IsWindow(WinID) ;{ Window size for resizing
Grid()\Window\X = WindowX(WinID)
Grid()\Window\Y = WindowY(WinID)
Grid()\Window\Width = WindowWidth(WinID)
Grid()\Window\Height = WindowHeight(WinID)
EndIf ;}
;2020-12-05 start
;add original information to facilitate better resizing
Grid()\Size\Original_X = X
Grid()\Size\Original_Y = Y
Grid()\Size\Original_WindowWidth = WindowWidth(WinID)
Grid()\Size\Original_WindowHeight = WindowHeight(WinID)
Grid()\Size\Original_CanvasWidth = Width
Grid()\Size\Original_CanvasHeight = Height
;2020-12-05 end
SetGadgetColor(GadgetID, #PB_Gadget_BackColor, $FFFFFF)
Of course, this does not deal with the possibility that the user may wish to move a grid relative to the other gadgets. I think it would just mean overwriting the new elements of the structure with the new values. (At the moment this is not on my radar)
Re: [Module] GridEx Canvas shrink/expand
Posted: Wed Jan 06, 2021 5:01 pm
by eck49
Once the GridEx gadget has been set up and filled, is there a simple way of shrinking/expanding the Canvas Container so that it fits neatly round the filled grid (with scroll bars if present)? That is, without resizing the grid itself. As well as being tidier, this would hide any unused canvas space with its distinctive background colour.
Can't be done on gadget creation because the dimensions of the grid may change, and would sometimes fit on screen without one or both scrollbars.