[Done] ListIconGadget: OS-different column order after drag&drop

Post bugreports for the Linux version here
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

[Done] ListIconGadget: OS-different column order after drag&drop

Post by Oma »

Hi!
(Concerns at least PB5.4x + PB5.6x...)
I don't know under which OS this should be reported as a bug. It depends on how the team intended it, but it varies between Windows and Linux:
With #PB_ListIcon_HeaderDragDrop you can move the order of columns in ListIconGadgets by drag&drop.
If you then read the column texts (e.g. from the header) from left (0) to right (n-1) with GetGadgetItemText(), I get different contents (can test Windows only with WinX at the moment!)
It seems that in Windows only the visible order is changed (and the original order is returned)
In Linux the real order seems to change, the original order is lost.
I can't test it on Mac!

Example: If you change the column sequence via d&d in the example from
Column 0 | Column 1 | Column 2 | Column 3 | Column 4
to
Column 4 | Column 3 | Column 2 | Column 1 | Column 0 (mirrored)

the returned values with GetGadgetItemText(Gadget, -1, Column[0 - 4]) are:
Windows: Column 0 | Column 1 | Column 2 | Column 3 | Column 4 (please test on real Windows)
Linux : Column 4 | Column 3 | Column 2 | Column 1 | Column 0
Mac : ? (please test)

An Example (please move columns by header d&d)

Code: Select all

EnableExplicit

; Object constants
#Win_Main= 0

#But1 = 0
#LIG1 = 1

Global.i gEvent, gQuit
Global.i gI
Global.s gSTemp


;- Functions for PB5.6x AND PB5.4x
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
	
	Procedure.i Tree_ColumnsCount(Gadget);                                  count LIG-column gtk2+gtk3
		Protected *ColumnList.GList= gtk_tree_view_get_columns_(GadgetID(Gadget))
		Protected nColumns         = g_list_length_(*ColumnList)
		
		g_list_free_(*ColumnList)
		ProcedureReturn nColumns
	EndProcedure
	
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
	
	Procedure.i Tree_ColumnsCount(Gadget);                                   LIG: Get number of columns, from shardik - here untested
		Protected.i Columns= CocoaMessage(0, GadgetID(Gadget), "numberOfColumns")
		ProcedureReturn Columns
	EndProcedure
	
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
	
	Procedure.i Tree_ColumnsCount(Gadget);                                   LIG: Get number of columns
		Protected.i Columns= SendMessage_(SendMessage_(GadgetID(Gadget), #LVM_GETHEADER, 0, 0), #HDM_GETITEMCOUNT, 0, 0)
		ProcedureReturn Columns
	EndProcedure
	
CompilerEndIf

;- Example
Procedure CreateWindow_Main()
	Protected.i I, O
	
	If OpenWindow(#Win_Main, 200, 200, 500, 200, "D&D column position issue (Win<->Lin.<->Mac?)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
		TextGadget    (#PB_Any,	5,   5, 490,  20, "Change column order by Drag&Drop on header")
		ButtonGadget  (#But1,   5,  25, 490,  26, "Debug column header texts from 0 to 4 ...")
		ListIconGadget(#LIG1,   5,  55, 490, 140, "Column 0", 90, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines | #PB_ListIcon_HeaderDragDrop)
		For O= 1 To 4
			AddGadgetColumn(#LIG1, O, "Column " + Str(O), 90)
		Next O
		For I= 0 To 9
			AddGadgetItem(#LIG1, -1, Str(I) + ".0" + #LF$ + Str(I) + ".1" + #LF$ + Str(I) + ".2" + #LF$ + Str(I) + ".3" + #LF$ + Str(I) + ".4")
		Next I
		
	EndIf

EndProcedure

CreateWindow_Main()

Repeat
	gEvent= WaitWindowEvent()
	
	Select gEvent
		Case #PB_Event_CloseWindow
			gQuit= #True
			
		Case #PB_Event_Gadget
			Select EventGadget()
					
				Case #But1
					gSTemp= ""
					For gI= 0 To Tree_ColumnsCount(#LIG1)- 1
						gSTemp+ GetGadgetItemText(#LIG1, -1, gI) + " | "
					Next gI
					Debug "Current column sequence:"
					Debug gSTemp
					
			EndSelect
	EndSelect
	
Until gQuit
Regards, Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
Fred
Administrator
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: ListIconGadget: OS-different column order after drag&drop

Post by Fred »

Fixed.
Post Reply