[Modules] ListEx (all OS / DPI)

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

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

  • Bugfixes
  • DPI compatible (hopefully)
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

Thorsten1867 wrote:
  • Bugfixes
  • DPI compatible (hopefully)

This is cool... now it looks like this:
Image

I think it is the right way :)
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

Andre wrote:Do you plan to make it working in Dialogs (with automatic resizing) too?
What exactly does it take? I haven't used dialogs in my programs yet.
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: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

ListEx with 125 DPI (compiler option: DPI)

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

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

Image

150% DPI.... great!!!!!

I have a lot of Programs for it.... Oh damn… yes


But... I need one feature...

If I have a canvas (#PB_Canvas_Container)
A method to use this existing Canvas would be great!
Like: ListEx::useCanvas(gadget.i ,ColTitle.s, ColWidth.f, ColLabel.s="", Flags.i=#False)

Oh... And I work with a lot of Data...

You do a redraw after every AddItem. A "stopRedraw" would be great, so I can add thousands of lines and only make one redraw at the end
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

  • Automatic size adjustment to changed window size (#AutoResize)
  • DisableRedraw()
  • GetAttribute() - Attribute '#Gadget' returns the gadget number of the canvas gadget
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: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

Cyllceaux wrote:If I have a canvas (#PB_Canvas_Container)
A method to use this existing Canvas would be great!
Actually, this should work:

Code: Select all

If CanvasGadget(#Gadget, X, Y, Width, Height, #PB_Canvas_Keyboard|#PB_Canvas_Container)
  
  ListEx::Gadget(#List, 10, 10, 400, 230, "", 25, "", ListEx::#GridLine)
  
  CloseGadgetList()
EndIf
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

I changed a little bit:

Line 1365 in Draw_():

Code: Select all

 Next ;}
        
        rowY + ListEx()\Row\Height
        
        If rowY>ListEx()\Size\Height:Break:EndIf ; Don't redraw all rows
        
      Next ;}
Line 2753 in AddItem:

Code: Select all

 If ListEx()\ReDraw 
        	UpdateRowY_() ; Cost to much and isn't needed without redraw
        	AdjustScrollBars_() ; Cost to much and isn't needed without redraw
        	Draw_() 
        EndIf
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

Thorsten1867 wrote:
Cyllceaux wrote:If I have a canvas (#PB_Canvas_Container)
A method to use this existing Canvas would be great!
Actually, this should work:

Code: Select all

If CanvasGadget(#Gadget, X, Y, Width, Height, #PB_Canvas_Keyboard|#PB_Canvas_Container)
  
  ListEx::Gadget(#List, 10, 10, 400, 230, "", 25, "", ListEx::#GridLine)
  
  CloseGadgetList()
EndIf

No... more like:

Code: Select all

  Procedure.i UseGadget(GID.i, ColTitle.s, ColWidth.f, ColLabel.s="", Flags.i=#False)
    Define.i Result
    
    DesktopDPI = dpiY(100)
    
    OpenGadgetList(GID)
    Result = GID
    If Result
      
      Protected X = dpiX(GadgetX(GID))
      Protected Y = dpiY(GadgetY(GID))
      Protected Width    = dpiX(GadgetWidth(GID))
      Protected Height   = dpiY(GadgetHeight(GID))
      ColWidth = dpiX(ColWidth)
      
      If GID = #PB_Any : GID = Result : EndIf
      If ColLabel = "" : ColLabel = "0" : EndIf
      
      If AddMapElement(ListEx(), Str(GID))
        
        ListEx()\WindID    = GetActiveWindow()
        ListEx()\CanvasID  = GID
        
        ListEx()\Flags  = Flags
        ListEx()\ReDraw = #True
        
        ListEx()\Row\Height = dpiX(20) ; Default row height
        ListEx()\Col\Width  = dpiY(50) ; Default column width
        
        If Flags & #NumberedColumn : ListEx()\Col\CheckBoxes = 1 : EndIf
        
        ListEx()\Cursor   = #Cursor_Default
        ListEx()\Editable = #True
        ListEx()\Currency = #DefaultCurrency
        ListEx()\TimeMask = #DefaultTimeMask
        
        ;{ Event Data
        ListEx()\Event\Type   = #NotValid
        ListEx()\Event\Row    = #NotValid
        ListEx()\Event\Column = #NotValid
        ListEx()\Event\State  = #NotValid
        ;}
        
        ;{ Size
        ListEx()\Size\X = 0
        ListEx()\Size\Y = 0
        ListEx()\Size\Width  = Width
        ListEx()\Size\Height = Height
        ListEx()\Size\winWidth  = WindowWidth(ListEx()\WindID)
        ListEx()\Size\winHeight = WindowHeight(ListEx()\WindID)
        ;}        

        ;{ Gadgets
        ListEx()\StringID  = StringGadget(#PB_Any, 0, 0, 0, 0, "")
        If IsGadget(ListEx()\StringID)
          SetGadgetData(ListEx()\StringID, ListEx()\CanvasID)
          HideGadget(ListEx()\StringID, #True)
        EndIf
        
        ListEx()\ComboID = ComboBoxGadget(#PB_Any, 0, 0, 0, 0, #PB_ComboBox_Editable)
        If IsGadget(ListEx()\ComboID)
          SetGadgetData(ListEx()\ComboID, ListEx()\CanvasID)
          HideGadget(ListEx()\ComboID, #True)
        EndIf
        
        ListEx()\DateID = DateGadget(#PB_Any, 0, 0, 0, 0, #DefaultDateMask)
        If IsGadget(ListEx()\DateID)
          SetGadgetData(ListEx()\DateID, ListEx()\CanvasID)
          HideGadget(ListEx()\DateID, #True)
        EndIf
        ListEx()\Date\Mask = #DefaultDateMask
        
        ListEx()\HScrollID = ScrollBarGadget(#PB_Any, 0, 0, 0, 0, 0, 0, 0)
        If IsGadget(ListEx()\HScrollID)
          SetGadgetData(ListEx()\HScrollID, ListEx()\CanvasID)
          ListEx()\HScroll\Hide = #True
          HideGadget(ListEx()\HScrollID, #True)
        EndIf
        
        ListEx()\VScrollID = ScrollBarGadget(#PB_Any, 0, 0, 0, 0, 0, 0, 0, #PB_ScrollBar_Vertical)
        If IsGadget(ListEx()\VScrollID)
          SetGadgetData(ListEx()\VScrollID, ListEx()\CanvasID)
          ListEx()\VScroll\Hide = #True
          HideGadget(ListEx()\VScrollID, #True)
        EndIf ;}
        
        ;{ Shortcuts
        If IsWindow(ListEx()\WindID)
          ListEx()\ShortCutID = CreateMenu(#PB_Any, WindowID(ListEx()\WindID))
          AddKeyboardShortcut(ListEx()\WindID, #PB_Shortcut_Return, #Key_Return)
          AddKeyboardShortcut(ListEx()\WindID, #PB_Shortcut_Escape, #Key_Escape)
          AddKeyboardShortcut(ListEx()\WindID, #PB_Shortcut_Tab,    #Key_Tab)
          AddKeyboardShortcut(ListEx()\WindID, #PB_Shortcut_Tab|#PB_Shortcut_Shift, #Key_ShiftTab)
        EndIf ;}
        
        ;{ Header
        If Flags & #NoRowHeader
          ListEx()\Header\Height = 0
        Else  
          ListEx()\Header\Height = dpiY(20)
        EndIf
        ListEx()\Header\FontID  = FontID(LoadFont(#PB_Any, "Arial", 9))  
        ListEx()\Header\Align = #False
        ;}
        
        ;{ Rows
        ListEx()\Row\Current = #NoFocus
        ListEx()\Row\FontID    = ListEx()\Header\FontID
        ListEx()\Size\Rows   = ListEx()\Row\Height ; Height of all rows
        ;}
        
        ;{ Column
        If AddElement(ListEx()\Cols())
          ListEx()\Cols()\Header\Titel = ColTitle
          ListEx()\Cols()\Width = dpiX(ColWidth)
          ListEx()\Cols()\Key   = ColLabel
          ListEx()\Col\Number   = 1        ; Number of columns
        EndIf
        ListEx()\Size\Cols    = ListEx()\Cols()\Width ; Width of all columns
        ListEx()\Sort\Column  = #NotValid
        ListEx()\AutoResize\MinWidth = ListEx()\Col\Width
        ListEx()\AutoResize\Column = #PB_Ignore
        ;} 
        
        ;{ Default Colors
        ListEx()\Color\HeaderFront  = $412B1B
        ListEx()\Color\HeaderBack   = $DEC4B0
        ListEx()\Color\HeaderGrid   = $858585
        ListEx()\Color\Front        = $000000
        ListEx()\Color\Back         = $FDFBFA
        ListEx()\Color\Grid         = $C7C7C7
        ListEx()\Color\Focus        = $F4EAE6
        ListEx()\Color\Edit         = $BE7D61
        ListEx()\Color\Button       = $CCCCCC
        ListEx()\Color\ActiveButton = $E0E0E0
        ListEx()\Color\Link         = $8B0000
        ListEx()\Color\ActiveLink   = $FF0000
        ListEx()\Color\ScrollBar    = #Scrollbar_Color
        
        CompilerIf #PB_Compiler_OS = #PB_OS_Windows
          If #UseSystemColors
            ListEx()\Color\Front        = GetSysColor_(#COLOR_WINDOWTEXT)
            ListEx()\Color\ScrollBar    = GetSysColor_(#COLOR_MENU)
          EndIf
        CompilerEndIf
        ;}

        If IsGadget(ListEx()\StringID) : SetGadgetFont(ListEx()\StringID, ListEx()\Row\FontID) : EndIf
        
        BindGadgetEvent(ListEx()\CanvasID,  @_RightClickHandler(),      #PB_EventType_RightClick)
        BindGadgetEvent(ListEx()\CanvasID,  @_LeftButtonDownHandler(),  #PB_EventType_LeftButtonDown)
        BindGadgetEvent(ListEx()\CanvasID,  @_LeftButtonUpHandler(),    #PB_EventType_LeftButtonUp)
        BindGadgetEvent(ListEx()\CanvasID,  @_LeftDoubleClickHandler(), #PB_EventType_LeftDoubleClick)
        BindGadgetEvent(ListEx()\CanvasID,  @_MouseMoveHandler(),       #PB_EventType_MouseMove)
        BindGadgetEvent(ListEx()\CanvasID,  @_MouseWheelHandler(),      #PB_EventType_MouseWheel)
        BindGadgetEvent(ListEx()\CanvasID,  @_ResizeHandler(),          #PB_EventType_Resize)
        BindGadgetEvent(ListEx()\HScrollID, @_SynchronizeScrollCols(),  #PB_All)
        BindGadgetEvent(ListEx()\VScrollID, @_SynchronizeScrollRows(),  #PB_All) 
        
        BindEvent(#PB_Event_SizeWindow, @_ResizeWindowHandler(), ListEx()\WindID)
        
        Draw_()
        
      EndIf 
      
      CloseGadgetList()
    EndIf
    
  EndProcedure  

So I can use it in the DialogEngine from PB. :)
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

@Cyllceaux

Changed: DisableReDraw() matched
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

Thorsten1867 wrote:@Cyllceaux

Changed: DisableReDraw() matched

Btw... My Test is this:

Code: Select all

Define ix
    For ix=1 To 10000
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Image"    + #LF$ + "no Image" + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Thorsten" + #LF$ + "Hoeppner" + #LF$ + "male" + #LF$ + "18.07.1967" + #LF$ + "", "PureBasic")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Amelia"   + #LF$ + "Smith"    + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Jack"     + #LF$ + "Jones"    + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Isla"     + #LF$ + "Williams" + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Harry"    + #LF$ + "Brown"    + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Emily"    + #LF$ + "Taylor"   + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Jacob"    + #LF$ + "Wilson"   + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Ava"      + #LF$ + "Evans"    + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Thomas"   + #LF$ + "Roberts"  + #LF$ + #LF$ + #LF$ + "Push")
    ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Harriet"  + #LF$ + "Smith"    + #LF$ + #LF$ + #LF$ + "Push")
    Next 
Looks much, But I plan to use it in a financial Software and there are a lot of bookings... so 30K - 60K Records are normal.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

@Cyllceaux

Added: #UseExistingCanvas
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

Thorsten1867 wrote:@Cyllceaux

Added: #UseExistingCanvas

THX :D

It's getting better and Better!!!!


How I use Currency? (#DefaultCurrency)

Oh...

Code: Select all

GetCashFloat_
Is not really clean.
A "normal" number could be "1,000.00".

Code: Select all

Debug FormatNumber(1000.42) ; 1,000.42
Debug FormatNumber(1000.42,2,",",".") ; 1.000,42 (german)
Debug StrD(1000.42) ; 1000.42
So I use this:

Code: Select all

	Procedure.s makeFloat(wert.s)
		Define result.s=ReplaceString(wert,"-,","-")
		result=ReplaceString(result,"-.","-")
		Define idk=FindString(result,",")
		Define idp=FindString(result,".")
		If idk>0 And idk<idp
			result=ReplaceString(result,",","")
		ElseIf idk>0 And idk<idp
			result=ReplaceString(result,".","")
			result=ReplaceString(result,",",".")
		EndIf
		ProcedureReturn result
	EndProcedure
Last edited by Cyllceaux on Fri Mar 08, 2019 5:50 am, edited 2 times in total.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Andre »

Thorsten1867 wrote:
Andre wrote:Do you plan to make it working in Dialogs (with automatic resizing) too?
What exactly does it take? I haven't used dialogs in my programs yet.
As far as I can tell (without writing/testing a specific example) you need to do the following:

- create a dialog definition with all gadgets included, to have them managed by PB's dialog library with automatic resizing
- in your case this would be the CanvasGadget used for the 'ListGadget'

To have it working this way, you "just" need to support an already created CanvasGadget (GadgetID returned from Dialog lib after GUI creation). Resized of the canvas is then done automatically (according to the settings in the Dialog creation).

A "workaround" would be to create another ContainerGadget inside the Dialog, and then create your canvas / ListGadget inside this (automatically resized) container after the Dialog creation.

For using the native PB Dialog lib, but without dealing with the complexe XML definitions, I'm using the DynamicDialogs include.


Btw. the redrawing errors in the ListGadget, reported yesterday with the screenshot above, are gone now. Thanks :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

[Added:] SetAutoResizeFlags() => #MoveX|#MoveY|#ResizeWidth|#ResizeHeight
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Post Reply