[Modules] ListEx (all OS / DPI)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: [Modules] ListEx (all OS / DPI)

Post by davido »

@Thorsten1867,
When a row is clicked, that row is highlighted in light blue colour.
Is it possible to change this colour?
DE AA EB
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

davido wrote:@Thorsten1867,
When a row is clicked, that row is highlighted in light blue colour.
Is it possible to change this colour?
You can change almost all colors and then save your own theme:

Code: Select all

 SetColor(#List, #FocusColor, Color)
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: [Modules] ListEx (all OS / DPI)

Post by davido »

@Thorsten1867,
Thank you, very much for your help. Excellent. :D

It always looks easy when one is shown how. :oops:
DE AA EB
diskay
User
User
Posts: 25
Joined: Sun Aug 02, 2015 7:17 pm

Re: [Modules] ListEx (all OS / DPI)

Post by diskay »

1. When using ListEx::AddItem() to add a large number of items, then clear with ListEx::ClearItems()

When you add a small number of items again, various problems occur: the items disappear, and the scrollbars are in the wrong position.

2. The scroll bar position is not updated to the correct position when using ListEx::DisableReDraw()

In addition to the support for HIDPI, there is a slight deviation in the position of the edit box, which is the cause of purebasic itself, and Fred seems unwilling to fix it:
viewtopic.php?f=4&t=71879
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Please try:

Code: Select all

 Procedure   ClearItems(GNum.i)
    
    If FindMapElement(ListEx(), Str(GNum))
      ClearList(ListEx()\Rows())
      Draw_()
    EndIf
    
  EndProcedure 
Does it work then?
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
diskay
User
User
Posts: 25
Joined: Sun Aug 02, 2015 7:17 pm

Re: [Modules] ListEx (all OS / DPI)

Post by diskay »

Thorsten1867 wrote:Please try:

Code: Select all

 Procedure   ClearItems(GNum.i)
    
    If FindMapElement(ListEx(), Str(GNum))
      ClearList(ListEx()\Rows())
      Draw_()
    EndIf
    
  EndProcedure 
Does it work then?
Can't solve the problem

The problem may be that ListEx()\Row\Number, ListEx()\VScroll, ListEx()\HScroll, ClearItems haven't been updated since I tried
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Second try:

Code: Select all

  Procedure   ClearItems(GNum.i)
    
    If FindMapElement(ListEx(), Str(GNum))
      
      ClearList(ListEx()\Rows())
      
      ListEx()\Row\Number = 0
      UpdateRowY_()
      AdjustScrollBars_()
      
      Draw_()
    EndIf
    
  EndProcedure 
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
diskay
User
User
Posts: 25
Joined: Sun Aug 02, 2015 7:17 pm

Re: [Modules] ListEx (all OS / DPI)

Post by diskay »

Thorsten1867 wrote:Second try:

Code: Select all

  Procedure   ClearItems(GNum.i)
    
    If FindMapElement(ListEx(), Str(GNum))
      
      ClearList(ListEx()\Rows())
      
      ListEx()\Row\Number = 0
      UpdateRowY_()
      AdjustScrollBars_()
      
      Draw_()
    EndIf
    
  EndProcedure 
It can't solve the problem.

Only in this way can we solve the problem:

Code: Select all

  Procedure   ClearItems(GNum.i)
    
    If FindMapElement(ListEx(), Str(GNum))
      
      ClearList(ListEx()\Rows())
   
      ListEx()\Row\Number = 0
      UpdateRowY_()
      
      SetGadgetAttribute(ListEx()\VScrollNum, #PB_ScrollBar_Minimum, 0)
      SetGadgetAttribute(ListEx()\VScrollNum, #PB_ScrollBar_Maximum, 0)
      SetGadgetAttribute(ListEx()\VScrollNum, #PB_ScrollBar_PageLength, 0)

      Draw_()
    EndIf
    
  EndProcedure
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

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

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by infratec »

Hi Thorsten,

2 Problems:

1. If you do some right clicks inside the gadget an error with 'negative index not allwed' appears in _RightClickHandler()

Code: Select all

IncludeFile "../pbi/ListExModule.pbi"

OpenWindow(0, 100, 100, 300, 120, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListEx::Gadget(0, 5, 5, 290, 90, "Test", 50, "", ListEx::#GridLines, 0)

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow


2. Menu problem

is it possible that already a popup menu (0) is available, even if I not define one with ListEx::AttachPopupMenu() ?

Because if already a menue with id 0 is defined, something opens by right click on an item in your gadget.
If you move the mouse above you see the menu of the window.

Code: Select all

IncludeFile "../pbi/ListExModule.pbi"

OpenWindow(0, 100, 100, 300, 120, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

CreateMenu(0, WindowID(0))
MenuTitle("Test")
MenuItem(0, "Item")

ListEx::Gadget(0, 5, 5, 290, 90, "Test", 50, "", ListEx::#GridLines, 0)
ListEx::AddItem(0, ListEx::#LastItem, "Amelia")

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
A bugfix is to add:

Code: Select all

ListEx::AttachPopupMenu(0, -1)
Like

Code: Select all

IncludeFile "../pbi/ListExModule.pbi"

OpenWindow(0, 100, 100, 300, 120, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

CreateMenu(0, WindowID(0))
MenuTitle("Test")
MenuItem(0, "Item")

ListEx::Gadget(0, 5, 5, 290, 90, "Test", 50, "", ListEx::#GridLines, 0)
ListEx::AddItem(0, ListEx::#LastItem, "Amelia")

ListEx::AttachPopupMenu(0, -1)

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

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

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by infratec »

Hi Thorsten,

next bug to fix:

Code: Select all

IncludeFile "../pbi/ListExModule.pbi"

OpenWindow(0, 100, 100, 300, 120, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListEx::Gadget(0, 5, 5, 290, 90, "Test", 50, "", ListEx::#GridLines|ListEx::#MultiSelect, 0)
ListEx::AddItem(0, ListEx::#LastItem, "Line 1")
ListEx::AddItem(0, ListEx::#LastItem, "Line 2")
ListEx::AddItem(0, ListEx::#LastItem, "Line 3")
ListEx::AddItem(0, ListEx::#LastItem, "Line 4")
ListEx::AddItem(0, ListEx::#LastItem, "Line 5")



Repeat
  Event = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_LeftClick
              Debug ListEx::CountItems(0, ListEx::#Selected)
          EndSelect
      EndSelect
      
  EndSelect
  
Until Event = #PB_Event_CloseWindow
If you select one item, you get 0 as result.
If you select more than one the result is Ok.
Last edited by infratec on Tue Sep 17, 2019 9:40 am, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by infratec »

Hi,

next one:

Code: Select all

IncludeFile "../pbi/ListExModule.pbi"

OpenWindow(0, 100, 100, 300, 220, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListEx::Gadget(0, 5, 5, 290, 190, "Test", 50, "", ListEx::#GridLines|ListEx::#MultiSelect, 0)

ListEx::AddItem(0, ListEx::#LastItem, "Line 1")
ListEx::AddItem(0, ListEx::#LastItem, "Line 2")
ListEx::AddItem(0, ListEx::#LastItem, "Line 3")
ListEx::AddItem(0, ListEx::#LastItem, "Line 4")
ListEx::AddItem(0, ListEx::#LastItem, "Line 5")

ListEx::SetColor(0, ListEx::#AlternateRowColor, $909090)

Repeat
  Event = WaitWindowEvent()
  
Until Event = #PB_Event_CloseWindow
If you select more than one entry, the alternate color of all lines disappears.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

Bugfixes: CountItems / alternate color / shift-select
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
nicoh
User
User
Posts: 26
Joined: Thu Sep 19, 2019 10:44 am

Re: [Modules] ListEx (all OS / DPI)

Post by nicoh »

Hi,

I found one more bug:

Code: Select all

OpenWindow(0, 100, 100, 300, 220, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

CreatePopupMenu(0)
MenuItem(0, "Count selected")

ListEx::Gadget(0, 5, 5, 290, 190, "Test", 50, "", ListEx::#GridLines|ListEx::#MultiSelect, 0)

ListEx::AddItem(0, ListEx::#LastItem, "Line 1")
ListEx::AddItem(0, ListEx::#LastItem, "Line 2")
ListEx::AddItem(0, ListEx::#LastItem, "Line 3")
ListEx::AddItem(0, ListEx::#LastItem, "Line 4")
ListEx::AddItem(0, ListEx::#LastItem, "Line 5")

Define.i Event, Index, Count, Selected

Repeat
  Event = WaitWindowEvent()
  
  Select Event
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_RightClick
              DisplayPopupMenu(0, WindowID(0))
          EndSelect
      EndSelect
      
    Case #PB_Event_Menu
      Select EventMenu()
        Case 0
          Selected = 0
          Count = ListEx::CountItems(0) - 1
          For Index = 0 To Count
            If ListEx::GetItemState(0, Index) & ListEx::#Selected
              Selected + 1
            EndIf
          Next
          Debug "Count via loop: " + Str(Selected)
          Debug "CountItems(): " + Str(ListEx::CountItems(0, ListEx::#Selected))
      EndSelect
      
  EndSelect
  
Until Event = #PB_Event_CloseWindow
The flag ListEx::#Selected is not set correctly when only one item is selected.
However, CountItems() returns the correct amount of selected items.

You can see this behavior by using the code above.
Clicking the popup menu will show the results in debugger.

Debugger output (example):

Code: Select all

Count via loop: 0       <- Should be 1
CountItems(): 1
Count via loop: 2       <- ok
CountItems(): 2
Count via loop: 3       <- ok
CountItems(): 3
Could you fix this?
Post Reply