1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
| ' Gambas class file
PRIVATE $iKey AS INTEGER PRIVATE CONST MIME_TYPE AS STRING = "text/x-gambas-dragndrop-example"
PUBLIC SUB imgIcon_MouseDrag()
IF Mouse.Left THEN Drag.Icon = LAST.Picture LAST.Drag(LAST.Picture.Image) 'LAST.Drag(LAST.Tag) ENDIF
END
PUBLIC SUB TreeView1_Drag()
IF Drag.Type <> Drag.Image THEN STOP EVENT
END
PUBLIC SUB TreeView1_DragMove()
'IF Drag.Type <> Drag.Image THEN STOP EVENT
WITH TreeView1 IF NOT .FindAt(Drag.X, Drag.Y) THEN Drag.Show(TreeView1, .Item.X, .Item.Y, .Item.W, .Item.H) ELSE Drag.Show(TreeView1) ENDIF END WITH
END
PUBLIC SUB TreeView1_Drop()
DIM sKey AS STRING
WITH TreeView1
IF NOT .FindAt(Drag.X, Drag.Y) THEN sKey = .Item.Key ENDIF
INC $iKey
IF Drag.Type = Drag.Image THEN .Add($iKey, "#" & $iKey, Drag.Data.Picture, sKey).EnsureVisible ' ELSE IF Drag.Type = Drag.Text THEN ' .Add($iKey, Drag.Data,, sKey).EnsureVisible ENDIF
END WITH
END
PUBLIC SUB TreeView1_MouseDrag()
DIM hImage AS Image
IF NOT Mouse.Left THEN RETURN
WITH TreeView1 IF .FindAt(Mouse.X, Mouse.Y) THEN RETURN IF NOT .Key THEN RETURN
hImage = NEW Image(32 + 8 + .Font.TextWidth(.Current.Text), 32, Color.Transparent) Paint.Begin(hImage) TRY Paint.DrawImage(.Current.Picture.Image, 0, 0) 'Try Draw.Picture(.Current.Picture, 0, 0) Paint.Font = .Font Paint.Text(.Current.Text, 34, 0, hImage.Width, 32, Align.Left) Paint.Fill Paint.End
Drag.Icon = hImage.Picture 'hImage.Save("~/drag.png") 'Drag.Icon = .Current.Picture .Drag(.Key, MIME_TYPE) END WITH
END
PUBLIC SUB imgHole_Drag()
'DEBUG Drag.Type;; Drag.Format IF Drag.Type = Drag.Text THEN IF Drag.Format = MIME_TYPE THEN RETURN ENDIF ENDIF
STOP EVENT
END
PUBLIC SUB imgHole_Drop()
TreeView1.Remove(Drag.Data)
END
PUBLIC SUB Form_Open()
ME.Center TreeView1.Add("Test", ("Test"), Picture["drop.png"])
END
PUBLIC SUB imgHole_DragMove()
'DEBUG Drag.Type;; Drag.Format IF Drag.Type = Drag.Text THEN IF Drag.Format = MIME_TYPE THEN Drag.Show(imgHole) RETURN ENDIF ENDIF
STOP EVENT
END
PUBLIC SUB Test_DragMove()
Drag.Show(LAST) 'PRINT LAST.ScreenX;; LAST.ScreenY;; LAST.Window.ScreenX;; LAST.Window.ScreenY
END
PUBLIC SUB Form_DragMove()
Test_DragMove
END
|