[Modules] ListEx (all OS / DPI)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

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

Post by Thorsten1867 »

Paul wrote: Mon May 23, 2022 5:06 pm Yes those PB commands work on a 4K monitor but there seems to be issues with how you calculate positions and offsets and I guess you are not going to see them without using a high DPI 4K monitor.
Please try this:

Code: Select all

EnableExplicit

Define.i Event

Enumeration 
  #Window
  #Canvas
EndEnumeration

#X      = 60
#Y      = 50
#Width  = 80
#Height = 50


Procedure.i dpiX(Num.i)
  ProcedureReturn DesktopScaledX(Num) 
EndProcedure

Procedure.i dpiY(Num.i)
  ProcedureReturn DesktopScaledY(Num)  
EndProcedure

Procedure _MouseMoveHandler()
  Define.i X, Y 
  Define.i Gadget = EventGadget()
  
  If Gadget = #Canvas
    
    X = GetGadgetAttribute(Gadget, #PB_Canvas_MouseX)
    Y = GetGadgetAttribute(Gadget, #PB_Canvas_MouseY)
    
    If X > dpiX(#X) And X < dpiX(#X + #Width)
      If Y > dpiY(#Y) And Y <= dpiY(#Y + #Height)
        SetGadgetAttribute(Gadget, #PB_Canvas_Cursor, #PB_Cursor_Hand)
        GadgetToolTip(Gadget, "X: " + Str(X) + " (" + Str(DesktopUnscaledX(X)) +  ") / Y: "+Str(Y) + " (" + Str(DesktopUnscaledY(Y)) + ")")
        ProcedureReturn #True
      EndIf 
    EndIf  
    
  EndIf
  
  SetGadgetAttribute(Gadget, #PB_Canvas_Cursor, #PB_Cursor_Default)
EndProcedure  

;- ----- Main -----

If OpenWindow(#Window, 0, 0, 220, 170, "Module - Example", #PB_Window_SystemMenu|#PB_Window_Tool|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
  
  If CanvasGadget(#Canvas, 10, 10, 200, 150)
    
    If StartDrawing(CanvasOutput(#Canvas)) 

      DrawingMode(#PB_2DDrawing_Outlined )
      Box(dpiX(#X), dpiY(#Y), dpiX(#Width), dpiY(#Height), #Red)
      Debug "Box X: " + Str(dpiX(#X)) + " / Y: "+ Str(dpiY(#Y))
      
      DrawingMode(#PB_2DDrawing_Outlined)
      Box(0, 0, dpiX(GadgetWidth(#Canvas)), dpiY(GadgetHeight(#Canvas)), $808080)
      
      StopDrawing()
    EndIf
    
    BindGadgetEvent(#Canvas, @_MouseMoveHandler(), #PB_EventType_MouseMove)
  EndIf

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow

  CloseWindow(#Window)
EndIf
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

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

Post by blueb »

Hi Thorsten,
Is this the result you were expecting?

https://www.dropbox.com/s/qpdhp5ppi6jzi ... 1.jpg?dl=0
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

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

Post by Paul »

Image

Hi Thorsten,
Your test code looks fine. As shown in my previous videos, the problem occurs when things are offset with either the scrollbars or resizing the columns. The calculations become incorrect.

Cheers.
Image Image
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

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

Post by Thorsten1867 »

The data on the picture cannot be correct.
The bottom right corner should be:
X: 245 (140) / Y: 176 (100)
However, the mouse cursor is below and to the right of this corner.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

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

Post by Paul »

Thorsten1867 wrote: Tue May 24, 2022 6:28 pm The data on the picture cannot be correct.
The bottom right corner should be:
X: 245 (140) / Y: 176 (100)
However, the mouse cursor is below and to the right of this corner.
If I where in the exact bottom right corner it would have been 245/176 but it was difficult to hit the exact corner and the number you see in the tooltip is the last position before I bumped the cursor out of the box when hitting Print Screen ;)
Image Image
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

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

Post by Thorsten1867 »

Paul wrote: Tue May 24, 2022 8:05 pm If I where in the exact bottom right corner it would have been 245/176 but it was difficult to hit the exact corner and the number you see in the tooltip is the last position before I bumped the cursor out of the box when hitting Print Screen ;)
I think I found something.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
lgb-this
User
User
Posts: 32
Joined: Sat Aug 30, 2014 9:00 pm
Location: Switzerland
Contact:

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

Post by lgb-this »

Bug with #ResizeColumn:

ListExModule.pbi - date 17.7.2022 (latest version from download)

#Example = 4

1) Start test application in the module
2) Scroll down in the list with the mouse to the bottom
3) Change witdh of a column with the mouse

Problem: The list shows immediately the first row. The scrollbar stays at the correct position.

Any idea how to fix this bug ?
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

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

Post by doctorized »

Just found a bug. If we have a Repeat loop like this:

Code: Select all

Repeat
   Event = WaitWindowEvent()
   Select Event
      Case #PB_Event_CloseWindow
         Select EventWindow()
            Case #Window
               MessageRequester("some text","some text")
         EndSelect
   EndSelect
ForEver
after pressing the X icon on the top right corner, MessageRequester appears. Closing the Requester I found out that ButtonGadgets are active and pressable, but all buttons, links and scrollbars inside ListEx are freesing.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

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

Post by jacdelad »

Hi,
the ListEx module binds the #PB_Event_CloseWindow event (on line 9185). So, when closing the window on which the ListEx is created, everything is automatically freed. Now, with your loop the event is triggered, but the window does not close -> the ListEx doesn't know that and still automatically frees its data. You can either change your program behaviour upon closing or change line 9185 and manually free all the stuff when you really close the window (or let PureBasic do this upon ending the program itself).

To bug or not to bug...to me it seems like a matter of perspective. :D
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
loulou2522
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Oct 14, 2014 12:09 pm

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

Post by loulou2522 »

HI,
is it possible to set an “editable” flag on an integer input field, as can be done with a string type?
example for a string
ListEx::AddColumn(#List, 2, "Edit", 85, "edit", ListEx::#Editable|ListEx::#StartSelected)
Thanks
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

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

Post by Thorsten1867 »

Should actually work as long as only integer numbers are entered.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
loulou2522
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Oct 14, 2014 12:09 pm

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

Post by loulou2522 »

Another problem
When I create the following parts to highlight the area and prevent data entry
listex::SetItemColor(#list,19, listex::#frontcolor, #White,1)
listex::SetItemColor(#list,19, listex::#backcolor, #Blue,1)
listex::SetCellFlags(#list, 19, 3, listex::#LockCell)
listex::SetCellFlags(#list, 19, 5, listex::#LockCell)
Lorsque je clique sur la ligne celle-ci s'efface et ne réapparait que si je clique sur une autre ligne
Une solution est-elle possible ?
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

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

Post by Thorsten1867 »

Ich habe es mit dem Beispielcode getestet und konnte kein Problem feststellen.
Du könntest vielleicht diesen Befehl mal ausprobieren.

I have tested it with the sample code and could not find any problem.
You could perhaps try this command.

Code: Select all

Listex::Refresh(#List)
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
useful
Enthusiast
Enthusiast
Posts: 402
Joined: Fri Jul 19, 2013 7:36 am

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

Post by useful »

Dawn will come inevitably.
Amundo
Enthusiast
Enthusiast
Posts: 200
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

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

Post by Amundo »

Thank you, Thorsten for your wonderful work, I will be using this straight away in an old project of mine.


Edit: Okay, I give up...using version "#Version = 22052500", how do I get a column to sort when the header is clicked, please?
Tried adding a line to the Header Click event, but the Sort routine wants a constant whereas I can only find an Enum:

Code: Select all

		Case ListEx::#EventType_Header
                	Debug ">>> Header Click: " + Str(EventData()) ; Str(ListEx::EventColumn(#List))
                	ListEx::Sort(#List, EventData(), ListEx::#Sort_Ascending, #SortString) ;<<==-- my feeble attempt 
[13:54:42] [COMPILER] Line 11348: Constant not found: #SortString.

Edit2: NVM, helps if I use the fully qualified "ListEx::#SortString"!!!
Win10, PB6.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
Post Reply