Page 10 of 32

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

Posted: Fri Aug 30, 2019 7:56 am
by davido
@Thorsten1867,
When a row is clicked, that row is highlighted in light blue colour.
Is it possible to change this colour?

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

Posted: Fri Aug 30, 2019 10:16 am
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)

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

Posted: Fri Aug 30, 2019 7:22 pm
by davido
@Thorsten1867,
Thank you, very much for your help. Excellent. :D

It always looks easy when one is shown how. :oops:

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

Posted: Tue Sep 03, 2019 12:03 pm
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

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

Posted: Tue Sep 03, 2019 12:20 pm
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?

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

Posted: Tue Sep 03, 2019 1:44 pm
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

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

Posted: Tue Sep 03, 2019 1:59 pm
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 

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

Posted: Tue Sep 03, 2019 2:55 pm
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

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

Posted: Tue Sep 03, 2019 4:57 pm
by Thorsten1867
Bugfixes

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

Posted: Wed Sep 11, 2019 8:44 am
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

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

Posted: Wed Sep 11, 2019 2:32 pm
by Thorsten1867
Bugfixes

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

Posted: Tue Sep 17, 2019 9:33 am
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.

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

Posted: Tue Sep 17, 2019 9:39 am
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.

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

Posted: Wed Sep 18, 2019 7:18 am
by Thorsten1867
Bugfixes: CountItems / alternate color / shift-select

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

Posted: Thu Sep 19, 2019 11:11 am
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?