[Module] GridExModule.pbi

Share your advanced PureBasic knowledge/code with the community.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [Module] GridExModule.pbi

Post by skywalk »

Issues:
1. Example 1 & 2:
Cell focus does not follow browsing the grid with arrow keys.
Must use a LMBClick to change focus?

2. Example 2:
[Home] key jumps to top cell of column, not left-most cell of row?
[Ctrl+Home] does jump to top left cell.
[Ctrl+End] does jump to bottom right cell.

3. Example 1:
Maybe not GridEx related and more the example code, but resizing the window is very quirky and blanks the grid and Import/Export buttons.

4. Example 1 & 2:
[Ctrl+LMBClick] selects an entire row.
Does not allow non-contiguous cell selections?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

Update:
  • Select rows by clicking on the header of the row with the CRTL & left mouse button.
  • Select single cells with CRTL & left mouse click
  • Home now jumps to the first column and end to the last column
Last edited by Thorsten1867 on Fri Nov 24, 2017 6:02 pm, edited 1 time in total.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [Module] GridExModule.pbi

Post by skywalk »

When I use arrow keys to browse the grid, the row/col never updates to the current cell?

Line 3973: Debug "-> "+Str(Row)+" / "+Str(Col) ;<-- How to query current row/col after arrow keys?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

skywalk wrote:When I use arrow keys to browse the grid, the row/col never updates to the current cell?
Added: GetCurrentCell(GID.i, Flag.i) ; #Row / #Column

Code: Select all

Line 8864: Debug GetCurrentCell(GID, #Column)
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

Added: Save/Load grid as worksheet (including the used images)

The files with the data, the design and the current theme are stored in a ZIP container. Additionally used pictures are saved inside.
For testing I added a sample worksheet.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 794
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: [Module] GridExModule.pbi

Post by Zebuddi123 »

Hi Thorsten1867 Only the GridEx_Example.xgd file in the zip THanks for sharing :)
malleo, caput, bang. Ego, comprehendunt in tempore
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

Using #PB_Any as the GadgetID doesn't seem to work.

Code: Select all

Enumeration
  #Win
EndEnumeration

If OpenWindow(#Win, 0, 0, 800, 470, "GridEX - Gadget", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
  
  Grid = GridEx::Gadget(#Win, #PB_Any, 10, 10, 470, 138, 6, 7, GridEx::#NoScrollBars)
  
  GridEx::Hide(Grid, #True)
  
  Repeat
    
    event = WaitWindowEvent()
    
  Until event = #PB_Event_CloseWindow
  
EndIf
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

wombats wrote:Using #PB_Any as the GadgetID doesn't seem to work.
Bug fixed!
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

Thorsten1867 wrote:
wombats wrote:Using #PB_Any as the GadgetID doesn't seem to work.
Bug fixed!
Works great now!

Is it possible to prevent the user from typing in a particular cell? I thought GridEx::#NoEdit might do the trick, but seemingly not.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

wombats wrote:Is it possible to prevent the user from typing in a particular cell? I thought GridEx::#NoEdit might do the trick, but seemingly not.
Bug fixed!
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

Thorsten1867 wrote:
wombats wrote:Is it possible to prevent the user from typing in a particular cell? I thought GridEx::#NoEdit might do the trick, but seemingly not.
Bug fixed!
Thanks!

Is there a bug in GridEx::AddRow? It doesn't seem to be able to insert rows before existing rows.

If you have two GridEx controls, the second one loses its font if it is the same font name as the first. However, if you set it to a different font name to the first GridEx, it works.

Code: Select all

XIncludeFile("GridExModule.pbi")

Enumeration
  #Win
EndEnumeration

If OpenWindow(#Win, 0, 0, 800, 470, "GridEX - Gadget", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
  
  Grid1 = GridEx::Gadget(#Win, #PB_Any, 10, 10, 300, 250, 6, 7, GridEx::#NoScrollBars)
  Grid2 = GridEx::Gadget(#Win, #PB_Any, 325, 10, 300, 250, 6, 7, GridEx::#NoScrollBars)
  
  GridEx::SetFont(Grid1, "Verdana", 9)
  GridEx::SetFont(Grid2, "Verdana", 9)
  
  GridEx::Refresh(Grid1)
  GridEx::Refresh(Grid2)
  
  Repeat
    
    event = WaitWindowEvent()
    
  Until event = #PB_Event_CloseWindow
  
EndIf
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

I hope the bug is now fixed.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

In the Free() procedure, it doesn't seem to free all of the gadgets created for the GridEx. I was having issues with the ContainerGadget being left behind. I changed the Free() procedure to the following and the issue went away.

Code: Select all

  Procedure   Free(GID.i)
    If IsGadget(GID)
      FreeGadget(GID)
      If FindMapElement(Grid(), Str(GID))
        If IsGadget(Grid()\GId\Canvas) : FreeGadget(Grid()\GId\Canvas) : EndIf
        If IsGadget(Grid()\GId\HScroll) : FreeGadget(Grid()\GId\HScroll) : EndIf
        If IsGadget(Grid()\GId\VScroll) : FreeGadget(Grid()\GId\VScroll) : EndIf
        If IsGadget(Grid()\GId\String) : FreeGadget(Grid()\GId\String) : EndIf
        If IsGadget(Grid()\GId\ListView)  : FreeGadget(Grid()\GId\ListView)  : EndIf
        If IsGadget(Grid()\GId\Container) : FreeGadget(Grid()\GId\Container) : EndIf
      EndIf
      DeleteMapElement(Grid(), Str(GID))
    EndIf
  EndProcedure
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

Changed
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

Thanks for fixing the bugs I've mentioned so far!

I'm experiencing odd behaviour when adding rows. Sometimes when a row is added, the rows above it change position, and sometimes the new row isn't added where I expected it.

I've been using this to test, but each time it acts differently. I've noticed that if a new row is added as the first row, then sometimes it will move down one when rows are added below it.

Code: Select all

XIncludeFile("GridExModule.pbi")

Enumeration
  #Win
  #Container
  #Container2
  #Button1
  #Button2
EndEnumeration

Global Grid1

Procedure OnButtonClicked()
  row = GridEx::GetAttribute(Grid1, GridEx::#Attrib_Row)
  GridEx::AddRow(Grid1, "new", row - 1)
  GridEx::Refresh(Grid1)
EndProcedure

If OpenWindow(#Win, 0, 0, 800, 470, "GridEX - Gadget", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
  
  ButtonGadget(#Button1, 350, 10, 100, 30, "Add Row")

  Grid1 = GridEx::Gadget(#Win, #PB_Any, 10, 10, 300, 250, 6, 7, GridEx::#NoScrollBars)
  GridEx::SetFont(Grid1, "Verdana", 9) : GridEx::Refresh(Grid1)
  
  BindGadgetEvent(#Button1, @OnButtonClicked())
  
  Repeat
    event = WaitWindowEvent()
  Until event = #PB_Event_CloseWindow
  
EndIf
Post Reply