Gambas France BETA


Pas de compte ? Incription

Basic

Blights



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
PUBLIC SUB Timer1_Timer()

DIM diode AS PictureBox
DIM l AS INTEGER

FOR EACH diode IN [l1, l2, l3, l4, l5, l6, l7, l8]
l = Rnd() * 2
IF l = 0 THEN
diode.Picture = Picture["bloff.xpm"]
ELSE
diode.Picture = Picture["blon.xpm"]
ENDIF
NEXT

END

PUBLIC SUB Form_Open()

DIM hPict AS Picture
DIM diode AS PictureBox

hPict = Picture["blon.xpm"]

FOR EACH diode IN [l1, l2, l3, l4, l5, l6, l7, l8]
diode.Resize(hPict.Width, hPict.Height)
diode.Background = Color.DarkGreen
NEXT

ME.Resize(hPict.W * 8 + ME.W - ME.ClientW, hPict.H + ME.H - ME.ClientH)

END

Collection



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
STATIC PUBLIC SUB Main()

DIM myForm AS Form

myForm = NEW FStart
myForm.Show

END

PUBLIC myThings AS Collection

PUBLIC SUB btnCreate_Click()
'creating objects and add to collection

DIM i AS INTEGER
DIM myThing AS CThing

myThings = NEW Collection
FOR i = 1 TO 7
myThing = NEW CThing
myThing.Name = ("Item") & " " & CStr(i)
myThing.X = i
myThing.Y = i
myThing.ID = i
myThings.Add(myThing, CStr(myThing.ID))
NEXT

'show the collectionmembers in treeview

tvThings.Add("root", ("myThings"))

FOR EACH myThing IN myThings
tvThings.Add(myThing.ID, myThing.Name,, "root")
tvThings.Add(myThing.ID & "Name", ("Name = ") & myThing.Name,, CStr(myThing.ID))
tvThings.Add(myThing.ID & "X", "X= " & myThing.X,, CStr(myThing.ID))
tvThings.Add(myThing.ID & "Y", "Y= " & myThing.Y,, CStr(myThing.ID))
tvThings.Add(myThing.ID & "ID", "ID= " & myThing.ID,, CStr(myThing.ID))
NEXT

tvThings["root"].Expanded = TRUE
btnCreate.Enabled = FALSE

END

DragNDrop



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

Object



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
' Gambas class file

PUBLIC myThing AS CThing

PUBLIC SUB btnCreateThing_Click()

myThing = NEW CThing

WITH mything
.Name = ("Dummy-Thing")
.X = 11
.Y = 22
.ID = 33
END WITH

txtCheckResult.Visible = TRUE

END

PUBLIC SUB btnCheckThing_Click()

IF myThing THEN

WITH mything
txtCheckResult.Text = Subst("&1, X= &2, Y= &3, ID= &4", .Name, .X, .Y, .ID)
END WITH

ELSE
Message.Warning(("You need to create the Thing first!"))
ENDIF

END

PUBLIC SUB btnDestroy_Click()

IF NOT mything THEN
Message.Warning(("You need to create the Thing first!"))
RETURN
ENDIF

myThing = NULL
txtCheckResult.Visible = FALSE

END

Timer



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
' Gambas class file

PUBLIC SUB Form_Open()

FOtherTimer.Show

END

PUBLIC SUB Button1_Click()

Timer1.Delay = CInt(TextBox1.Text)
Timer1.Enabled = TRUE

END

PUBLIC SUB Timer1_Timer()

Label1.Background = &HFF0000&

END

PUBLIC SUB Button2_Click()

Timer1.Enabled = FALSE 'try without this line
Label1.Background = &HDCDCDC&

END

PUBLIC SUB ToggleButton1_Click()

IF ToggleButton1.Value = TRUE THEN
Timer2.Delay = CInt(TextBox2.Text) 'low
Timer3.Delay = CInt(TextBox3.Text) 'high
Timer2.Enabled = TRUE
ELSE
Timer2.Enabled = FALSE
Timer3.Enabled = FALSE
ENDIF

END

PUBLIC SUB Timer2_Timer()

Label5.Background = &HFF0000&
Timer3.Enabled = TRUE
Timer2.Enabled = FALSE

END

PUBLIC SUB Timer3_Timer()

Label5.Background = &H00FF00&
Timer2.Enabled = TRUE
Timer3.Enabled = FALSE

END


====================

Navigation :



<-- Accueil du WIKI : <--

====================

Documentation :



==============================