Page 32 of 33

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

Posted: Tue May 24, 2022 11:46 am
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

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

Posted: Tue May 24, 2022 12:28 pm
by blueb
Hi Thorsten,
Is this the result you were expecting?

https://www.dropbox.com/s/qpdhp5ppi6jzi ... 1.jpg?dl=0

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

Posted: Tue May 24, 2022 2:26 pm
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.

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

Posted: Tue May 24, 2022 6:28 pm
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.

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

Posted: Tue May 24, 2022 8:05 pm
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 ;)

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

Posted: Wed May 25, 2022 10:50 am
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.

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

Posted: Fri Apr 28, 2023 5:36 pm
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 ?

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

Posted: Tue Aug 20, 2024 9:25 pm
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.

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

Posted: Tue Aug 20, 2024 10:17 pm
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

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

Posted: Wed Oct 02, 2024 10:21 am
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

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

Posted: Thu Oct 03, 2024 2:49 pm
by Thorsten1867
Should actually work as long as only integer numbers are entered.

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

Posted: Sat Oct 05, 2024 7:49 am
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 ?

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

Posted: Sat Oct 05, 2024 9:16 am
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)

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

Posted: Sat Oct 05, 2024 10:02 am
by useful

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

Posted: Wed Oct 30, 2024 3:29 am
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"!!!