Code
Enumeration
#Window_0
EndEnumeration
Enumeration
#List
#SourceFiles
#TargetText
EndEnumeration
iconka3.l = CreateImage(300, 16,16)
StartDrawing(ImageOutput(300))
Box(2, 1,11, 1,RGB(131, 131, 131))
Box(2,13,11, 1,RGB(131, 131, 131))
Box(1, 2, 1,11,RGB(131, 131, 131))
Box(13,2, 1,11,RGB(131, 131, 131))
Box(5, 7, 5, 1,RGB(131, 131, 131))
Box(7, 5, 1 ,5,RGB(131, 131, 131))
StopDrawing()
;---------------------------------------
iconka.l = CreateImage(300, 16,16)
StartDrawing(ImageOutput(300))
Box(2, 1,11, 1,RGB(131, 131, 131))
Box(2,13,11, 1,RGB(131, 131, 131))
Box(1, 2, 1,11,RGB(131, 131, 131))
Box(13,2, 1,11,RGB(131, 131, 131))
Box(5, 7, 6, 1,RGB(131, 131, 131))
Box(6, 6, 1 ,3,RGB(131, 131, 131))
Box(7, 5, 1 ,5,RGB(131, 131, 131))
StopDrawing()
;----------------------------------------
iconka2.l = CreateImage(333, 16,16)
StartDrawing(ImageOutput(333))
Box(2, 1,11, 1,RGB(131, 131, 131))
Box(2,13,11, 1,RGB(131, 131, 131))
Box(1, 2, 1,11,RGB(131, 131, 131))
Box(13,2, 1,11,RGB(131, 131, 131))
Box(6, 4, 3, 1,RGB(131, 131, 131))
Box(6, 10, 3 ,1,RGB(131, 131, 131))
Box(5, 5, 1 ,5,RGB(131, 131, 131))
StopDrawing()
If OpenWindow(#Window_0, 0, 0, 480, 310, "Drag & Drop", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ListIconGadget (#List, 10, 10, 220, 290, "Список первый", 130)
SetGadgetColor(#List, #PB_Gadget_BackColor, RGB(0, 0, 0))
For a=0 To 30
AddGadgetItem(#List, a, Str(a)+". Строка",iconka)
Next
SetGadgetItemColor(#List, -1, #PB_Gadget_FrontColor, RGB(165, 165, 165), -1)
ListIconGadget(#TargetText, 250, 10, 220, 290, "Список второй", 130)
SetGadgetColor(#TargetText, #PB_Gadget_BackColor, RGB(0, 0, 0))
EnableGadgetDrop(#TargetText,#PB_Drop_Text,#PB_Drag_Copy)
Repeat
Event = WaitWindowEvent(10)
Window = EventWindow()
Gadget = EventGadget()
mx.l = WindowMouseX(#Window_0) ; координаты x
my.l = WindowMouseY(#Window_0) ; координаты y
;Debug mx
;Debug my
If Event = #PB_Event_Gadget And EventType() = #PB_EventType_DragStart
Select EventGadget()
Case #List
Text$ = GetGadgetItemText(#List, GetGadgetState(#List))
DragText(Text$)
EndSelect
ElseIf Event = #PB_Event_GadgetDrop
Select EventGadget()
Case #TargetText
AddGadgetItem(#TargetText, -1, EventDropText(),iconka2.l)
SetGadgetItemColor(#TargetText, -1, #PB_Gadget_FrontColor, RGB(165, 165, 165), -1)
EndSelect
EndIf
;---------------------------------------------------------------------------------------------
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #List
;For a=0 To CountGadgetItems(#List)
;SetGadgetItemColor(#List, a, #PB_Gadget_FrontColor, RGB(165, 165, 165), -1)
;Next
;SetGadgetItemColor(#List, GetGadgetState(#List), #PB_Gadget_FrontColor, RGB(240, 14, 15), -1)
If EventType()=#PB_EventType_LeftDoubleClick
If ((mx > 16 And mx < 30) And (my > 35 And my < 299))
Text$ = GetGadgetItemText(#List, GetGadgetState(#List))
AddGadgetItem(#TargetText, -1, Text$,iconka2.l)
SetGadgetItemColor(#TargetText, -1, #PB_Gadget_FrontColor, RGB(165, 165, 165), -1)
Else
Debug "Двойной клик, первый список"
EndIf
EndIf
Case #TargetText
If EventType()=#PB_EventType_LeftDoubleClick
If ((mx > 256 And mx < 270) And (my > 35 And my < 299))
RemoveGadgetItem(#TargetText, GetGadgetState(#TargetText)) ; стереть пункт
EndIf
EndIf
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
End