[Module] GridExModule.pbi
- Thorsten1867
- Addict
- Posts: 1366
- Joined: Wed Aug 24, 2005 4:02 pm
- Location: Germany
Re: [Module] GridExModule.pbi
Translated with http://www.DeepL.com/Translator
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
-
- Addict
- Posts: 1309
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: [Module] GridExModule.pbi
Just taking first steps to make a GridEx editable and using this code
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:
I get a checkbox in the first column?
Any Ideas?
CD
Code: Select all
GridEx::SetCellFlags(DBGrid, GridEx::#AnyRow,1,GridEx::#Edit)
Strangly if I change the flag to:
Code: Select all
GridEx::SetCellFlags(DBGrid, GridEx::#AnyRow,1,GridEx::#Checkbox)
Any Ideas?
CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
-
- Addict
- Posts: 1309
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: [Module] GridExModule.pbi
Trying a few more things.
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.
Code: Select all
;Hide Row Header
; GridEx::HideColumn(DBGrid, 0, #True)
GridEx::SetColumnWidth(DBGrid,0,5)
If I use setcolumnwidth with a value of 5 (as above) then I can. Anything less than 5 and again I cannot.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Re: [Module] GridExModule.pbi
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.
[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.
-
- Enthusiast
- Posts: 732
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
Re: [Module] GridExModule.pbi
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
Question: How does one us keyboard to select cell and edit? It seems only by double-clicking with mouse editing is possible
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Re: [Module] GridExModule.pbi
Hm...
Why is it not in the git repository? Or is it the same like ListEx?
Why is it not in the git repository? Or is it the same like ListEx?
- Thorsten1867
- Addict
- Posts: 1366
- Joined: Wed Aug 24, 2005 4:02 pm
- Location: Germany
Re: [Module] GridExModule.pbi
It would first have to be completely reworked (e.g. DPI) and most of my own functions I have taken over in ListEx.
Translated with http://www.DeepL.com/Translator
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
-
- Enthusiast
- Posts: 732
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
Re: [Module] GridExModule.pbi
ListEx is amazing! Great work and thanks for sharing
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Re: [Module] GridExModule.pbi
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.
Replacing the snippet with the following seems to do what I want:
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.
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
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
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.
Ubuntu 22.04 64-bit
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
Re: [Module] GridExModule.pbi
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?
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?
Ubuntu 22.04 64-bit
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
Re: [Module] GridExModule.pbi
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
2) Then in the ResizeHandler Procedure (replacing yesterday's work) around line 8500
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
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)
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
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
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)
Ubuntu 22.04 64-bit
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
Re: [Module] GridEx Canvas shrink/expand
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.
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.
Ubuntu 22.04 64-bit
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)