Gambas France BETA


Pas de compte ? Incription

Control

ArrayOfControls



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

PRIVATE aButtons[13] AS Button ' Dim the array of controls

PUBLIC SUB Form_Open()

DIM i AS INTEGER

btnClose.Tooltip = ("Quit")
ME.Center
FOR i = 1 TO 12
aButtons[i] = NEW Button(ME) AS "Buttongroup" ' Create a new button in the array and store it in an action group
WITH aButtons[i]
.X = (i - Int((i - 1) / 3) * 3) * 60 - 30
.Y = Int((i - 1) / 3) * 60 + 170
.Width = 42
.Height = 42
.Font.Grade = 5
IF i = 10 THEN
.Text = "*"
ELSE IF i = 11 THEN
.Text = "0"
ELSE IF i = 12 THEN
.Text = "#"
ELSE
.Text = i
ENDIF
END WITH
NEXT

END

PUBLIC SUB Buttongroup_Click() ' This is an event of the action group. This event is fired if any of the buttons is clicked
' You see a list of available events if you type "Buttongroup_"
' Dim w As Integer

tbNumber.Text = tbNumber.Text & LAST.Text ' find out with LAST which button was clicked and hand its text over to TextBox

' w = Last.Width ' this would return the width of the last button
' Print w
END

PUBLIC SUB Buttongroup_Menu() ' Another event of the action group: Right-click on any of the buttons

Message.Info(Subst(("You have clicked the button &1"), LAST.Text))

END

PUBLIC SUB btnClose_Click()

IF tbNumber.Text = "" THEN
ME.Close
ELSE
tbNumber.Text = ""
ENDIF

END

PUBLIC SUB Form_KeyPress()

IF Key.code = Key.Esc THEN ME.Close

END

PUBLIC SUB tbNumber_Change()

IF tbNumber.Text = "" THEN
btnClose.Tooltip = ("Quit")
ELSE
btnClose.Tooltip = ("Clear")
ENDIF

END

PUBLIC SUB btnDial_Click()

IF tbNumber.Text = "" THEN
Message.Warning(("There is no number I could dial."))
ELSE
Message.Info(("Dialing ") & tbNumber.Text)
ENDIF

END

Embedder



HighlightEditor



LCDLabel



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

PRIVATE $fTime AS FLOAT
PRIVATE $fAlarm AS FLOAT

PUBLIC SUB btnStart_Click()

DIM dAlarm AS DATE

IF timClock.Enabled THEN
timClock.Stop
ELSE

$fTime = Timer
dAlarm = timTime.Value
IF NOT dAlarm THEN RETURN
$fAlarm = $fTime + Minute(dAlarm) * 60 + Second(dAlarm)

timClock.Start
timClock_Timer

ENDIF

END

PUBLIC SUB timClock_Timer()

DIM fDiff AS FLOAT
DIM dAlarm AS DATE

fDiff = $fAlarm - Timer
IF fDiff <= 0 THEN
dAlarm = timTime.Value
$fAlarm += Minute(dAlarm) * 60 + Second(dAlarm)
fDiff = $fAlarm - Timer
Music.Play
ENDIF
lblAlarm.Text = Format(Int(fDiff / 60), "00") & ":" & Format(Int(fDiff - Int(fDiff / 60) * 60), "00") & ":" & Format(Int(Frac(fDiff) * 100), "00")

END

PUBLIC SUB Form_Arrange()

lblAlarm.Padding = lblAlarm.Width / 16

END

PUBLIC SUB Form_Open()

' SDL cannot resample its music track...
Sound.Frequency = 48000
Music.Load("alarm.ogg")

END

MapView



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
137
138
139
140
' Gambas class file

PRIVATE hMap AS NEW Map AS "LensMap"

PRIVATE $aNames AS NEW String[]

PRIVATE $iMX AS INTEGER
PRIVATE $iMY AS INTEGER
PRIVATE $bLens AS BOOLEAN
PRIVATE hPicture AS Picture

PUBLIC SUB _new()

DIM o AS OBJECT

hPicture = NEW Picture(200, 200)

MapView1.Map.AddTile("GoogleMap", "https://khms{s}.google.fr/kh/v={version}&src=app&x={x}&y={y}&z={z}&s=Galile", [("version"): "167"]).SubDomains = ["0", "1", "2"]
MapView1.Map["GoogleMap"].Visible = FALSE
MapView1.Map.AddTile("OpenStreetMap", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", NULL).Copyright = "© OpenStreetMap " ("contributors")

'Map for lens
hmap.AddTile("GoogleMap", "https://khms{s}.google.fr/kh/v={version}&src=app&x={x}&y={y}&z={z}&s=Galile", [("version"): "167"]).SubDomains = ["0", "1", "2"]
'hmap.Padding = 256
hmap.Resize(200, 200)

'Manage the list of layers
$aNames.Add("OpenStreetMap")
$aNames.Add("GoogleMap")
GridView1.Rows.count = $aNames.Count
GridView1.Columns.Count = 2
GridView1.Columns[0].Width = 32
GridView1.Rows.Height = 32

END

PUBLIC SUB Form_Open()

ME.Center

END

PUBLIC SUB MapView1_MouseDown()

IF Mouse.Control THEN

hmap.Zoom = MapView1.map.Zoom + SpinBox1.Value
$bLens = TRUE
hbLens.Visible = TRUE
hmap.Center = Geo.PixelToMapPoint(Point(MapView1.Map.PixelBox.X + Mouse.X, MapView1.Map.PixelBox.Y + Mouse.y), MapView1.Map.Zoom)
MapView1.Lock = TRUE
MapView1.Refresh
ENDIF

END

PUBLIC SUB MapView1_MouseMove()

$iMX = Mouse.X
$iMY = Mouse.Y
IF $bLens THEN
hmap.Center = Geo.PixelToMapPoint(Point(MapView1.Map.PixelBox.X + Mouse.X, MapView1.Map.PixelBox.Y + Mouse.y), MapView1.Map.Zoom)

ENDIF

MapView1.Refresh

END

PUBLIC SUB MapView1_MouseUp()

IF $bLens THEN
$bLens = FALSE
MapView1.Lock = FALSE
MapView1.Refresh
ENDIF

END

PUBLIC SUB MapView1_Draw()

IF $bLens THEN
Paint.Begin(Draw.Device)
'Draw the lens temporary picture
Draw.Begin(hPicture)
Draw.FillRect(0, 0, hPicture.Width, hPicture.Height, Color.DarkGray)
hmap.Draw
Draw.End
'And put it in a circle with a blue border
Paint.Brush = Paint.Image(hPicture.Image, $iMX - 100, $iMY - 100)
Paint.Arc($iMX, $iMY, 100)
Paint.Fill(TRUE)
Paint.Brush = Paint.Color(Color.Blue)
Paint.Stroke
Paint.End
ENDIF

END

PUBLIC SUB GridView1_Data(Row AS INTEGER, Column AS INTEGER)

SELECT CASE Column
CASE 0
LAST.Data.Picture = IIf(MapView1.Map[$aNames[row]].Visible, Picture["icon:/22/ok"], Picture["icon:/22/cancel"])

CASE 1
LAST.Data.Text = $aNames[row]
END SELECT

LAST.Data.Padding = 4

END

PUBLIC SUB GridView1_MouseUp()

IF LAST.column = 0 THEN MapView1.Map[GridView1[LAST.row, 1].Text].Visible = NOT MapView1.Map[GridView1[LAST.row, 1].Text].Visible
GridView1.Refresh

END

PUBLIC SUB LensMap_Refresh()
'Resfresh the view when the Lensmap say it need to be refreshed
'This call the MapViewer_Draw Event then so the lens is refreshed too

MapView1.Refresh

END

PUBLIC SUB SpinBox1_Change()
'Change the lens zoom

hmap.Zoom = MapView1.map.Zoom + SpinBox1.Value

END

PUBLIC SUB btnAbout_Click()

Balloon.Info(("A simple MapViewer and Map example by\nFabien Bodard (gambix@users.sourceforge.net)\n\nEnjoy it ! :-)"), LAST)

END

TextEdit



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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
' Gambas class file

PUBLIC SUB _new()

ME.Center 'Center the form on the screen

END

PUBLIC SUB Form_Open()

DIM s AS STRING

TextEdit1.RichText = File.Load("text.html")

FOR EACH s IN Fonts
ComboBox1.add(s)
NEXT

'ComboBox1.Index = ComboBox1.Find(TextEdit1.Format.Font.Name)
'SpinBox1.Value = TextEdit1.Format.Font.Size

TextEdit1.SetFocus
TextEdit1_Cursor

END

PUBLIC SUB TextEdit1_Cursor()

Object.Lock(btnBold)
Object.Lock(btnItalic)
Object.Lock(btnUnderline)
Object.Lock(btnStrikeOut)
Object.Lock(btnAlignLeft)
Object.Lock(btnAlignCenter)
Object.Lock(btnAlignRight)
Object.Lock(btnAlignJustify)
Object.Lock(ComboBox1)
Object.Lock(SpinBox1)
Object.Lock(ColorButton1)
Object.Lock(ColorButton2)

btnBold.Value = TextEdit1.Format.Font.Bold
btnItalic.Value = TextEdit1.Format.Font.Italic
btnUnderline.Value = TextEdit1.Format.Font.Underline
btnStrikeOut.Value = TextEdit1.Format.Font.StrikeOut

SELECT CASE TextEdit1.Format.Alignment
CASE Align.Left
btnAlignLeft.Value = TRUE
CASE Align.Right
btnAlignRight.Value = TRUE
CASE Align.Center
btnAlignCenter.Value = TRUE
CASE Align.Justify
btnAlignJustify.Value = TRUE
CASE Align.Normal
btnAlignLeft.Value = TRUE ' If the displayed langage is left to right written, that's OK. Otherwise...
END SELECT

ColorButton1.Color = TextEdit1.Format.Color
ColorButton2.Color = TextEdit1.Format.Background
ComboBox1.Text = TextEdit1.Format.Font.Name
SpinBox1.Value = TextEdit1.Format.Font.Size

Object.UnLock(btnBold)
Object.UnLock(btnItalic)
Object.UnLock(btnUnderline)
Object.UnLock(btnStrikeOut)
Object.UnLock(btnAlignLeft)
Object.UnLock(btnAlignCenter)
Object.UnLock(btnAlignRight)
Object.UnLock(btnAlignJustify)
Object.UnLock(ComboBox1)
Object.UnLock(SpinBox1)
Object.UnLock(ColorButton1)
Object.UnLock(ColorButton2)

END

PUBLIC SUB btnBold_Click()

TextEdit1.Format.Font.Bold = LAST.Value

END

PUBLIC SUB btnItalic_Click()

TextEdit1.Format.Font.Italic = LAST.Value

END

PUBLIC SUB btnUnderline_Click()

TextEdit1.Format.Font.Underline = LAST.Value

END

PUBLIC SUB btnStrikeOut_Click()

TextEdit1.Format.Font.StrikeOut = LAST.Value

END

PUBLIC SUB btnAlignLeft_Click()

TextEdit1.Format.Alignment = Align.Left

END

PUBLIC SUB btnAlignCenter_Click()

TextEdit1.Format.Alignment = Align.Center

END

PUBLIC SUB btnAlignRight_Click()

TextEdit1.Format.Alignment = Align.Right

END

PUBLIC SUB ColorButton1_Change()

TextEdit1.Format.Color = ColorButton1.Color

END

PUBLIC SUB SpinBox1_Change()

TextEdit1.Format.Font.Size = LAST.Value
TextEdit1.SetFocus

END

PUBLIC SUB ToolButton1_Click()

frmShowHtml.Run(TextEdit1.RichText)

END

PUBLIC SUB ComboBox1_Click()

TextEdit1.Format.Font.Name = LAST.text

END

PUBLIC SUB btnabout_Click()

Balloon.Info(("A simple TextEdit example by\nFabien Bodard (gambix@users.sourceforge.net)\nand Benoît Minisini", LAST)

END

PUBLIC SUB btnAlignJustify_Click()

TextEdit1.Format.Alignment = Align.Justify

END

PUBLIC SUB btnLock_Click()

TextEdit1.ReadOnly = btnLock.Value

END

PUBLIC SUB ColorButton2_Change()

TextEdit1.Format.Background = ColorButton2.Color

END

TreeView



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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
' Gambas class file

PUBLIC intEventNumber AS INTEGER

PUBLIC SUB Form_Open()

DIM picMale AS Picture
DIM picFemale AS Picture

picFemale = Picture["Female.png"]
picMale = Picture["Male.png"]

'This will populate our treeview with our starting entries
'Note: I'll just keep the entries text and its key the same to keep it simple
TreeView1.Add(("Bill"), ("Bill"), picMale)
TreeView1.Add(("Ted"), ("Ted"), picMale, ("Bill"))
TreeView1.Add(("Sally"), ("Sally"), picFemale, ("Bill"))
TreeView1.Add(("Frank"), ("Frank"), picMale, ("Sally"))
'TreeView1.MoveCurrent
'TreeView1.Item.Selected = TRUE
'TreeView1.Item.Expanded = TRUE

TreeView1[("Bill")].Expanded = TRUE

END

PRIVATE SUB RefreshInfo()

'This little check just updates our label so that we know how many
'children an entry has.

DIM sText AS STRING

IF NOT TreeView1.Current THEN
Textlabel1.Text = ""
RETURN
ENDIF

WITH TreeView1.Current

IF .Children > 1 THEN
sText = Subst(("&1 has &2 children."), .Text, .Children)
ELSE IF .Children = 0 THEN
sText = Subst(("&1 has no children."), .Text)
ELSE
sText = Subst(("&1 has 1 child."), .Text)
END IF

sText &= "<br>" & ("Item rect is") & " (" & .X & "," & .Y & "," & .W & "," & .H & ")"

END WITH

TextLabel1.Text = sText

END

PUBLIC SUB TreeView1_Click()

'This just updates our event stack
AddLog(("Click"))

END

PUBLIC SUB Button1_Click()

DIM sIcon AS STRING
DIM sParent AS STRING

IF Textbox1.Text <> NULL THEN
IF RadioButton1.Value THEN
sIcon = "Male.png"
ELSE
sIcon = "Female.png"
END IF
'Gets the parent item: the current item, or nothing is the treeview is void
sParent = TreeView1.Key
'Now we will add a new entry with a key and a name of what was in the text box
'We will place it as a child of the currently selected entry
TreeView1.Add(Textbox1.Text, Textbox1.Text, Picture[sIcon], sParent).EnsureVisible
TreeView1.Item.EnsureVisible 'This will make sure that the item we just added to the list is in the visable area of the control. (Scrolling if necessary)
TextBox1.Text = "" 'This empties out textbox
RefreshInfo ' This will update our label and reflect the new number of kids
END IF

END

PUBLIC SUB Button2_Click()

IF NOT TreeView1.Key THEN RETURN
'Lets remove the current cursor item
TreeView1.Remove(TreeView1.Key)
'Now move the cursor to the current item (since we are now pointing at a deleted item)
'But first we check the count to make sure we didn't delete the last item in the list
'if we did then we obviously don't run this part.
IF TreeView1.Count > 0 THEN
'TreeView1.MoveCurrent
'This selects or 'highlights' our current item
'TreeView1.Current.Selected = TRUE
'This will update our label and reflect the new number of kids
RefreshInfo
END IF

END

PUBLIC SUB TreeView1_Collapse()
'This just updates our event stack

AddLog(("Collapse"))

END

PUBLIC SUB TreeView1_DblClick()
'This just updates our event stack

AddLog(("DblClick"))

END

PUBLIC SUB TreeView1_Select()
'This just updates our event stack

RefreshInfo
AddLog(("Select"))

END

PUBLIC SUB TreeView1_Delete()
'This just updates our event stack

AddLog(("Delete"))

END

PUBLIC SUB TreeView1_Expand()
'This just updates our event stack

AddLog(("Expand"))

END

PUBLIC SUB Button3_Click()

TextArea1.Text = ""
'IntEventNumber = 0

END

PUBLIC SUB About_Click()

Message.Info(("TreeView example written by C. Packard and Fabien Hutrel."))

END

PUBLIC SUB TreeView1_Activate()
'This just updates our event stack

AddLog(("Activate"))

END

PUBLIC SUB TreeView1_Rename()
'This just updates our event stack

AddLog(("Rename"))

END

PRIVATE SUB AddLog(anevent AS STRING)
'This updates our event stack, this sub is used by all events... it display the current node key.

DIM sKey AS STRING

TRY sKey = TreeView1.Item.Key
TextArea1.Text = ("Event") & "(" & intEventNumber & "): " & anevent & " " & ("Item:") & " '" & sKey & "'\n" & TextArea1.Text
TextArea1.Pos = 0
INC intEventNumber

END

PUBLIC SUB TreeView1_Cancel()

AddLog(("Cancel"))

END

Wizard



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

PUBLIC SUB _new()

ME.Center

END

PUBLIC SUB Wizard1_Cancel() ' user clicks abort

ME.Close

END

PUBLIC SUB Wizard1_Change() ' user clicks next

SELECT CASE Wizard1.Index ' be aware that the index starts with 0!

CASE 1
vbCode.setFocus

CASE 3
txaAddress.SetFocus

CASE 5

txlOrder.Text = vbCode.Text & " " & lblCode.Text & "<br>" & vbFrozen.Text & " " & lblFrozen.Text & "<br>" & vbImg.Text & " " & lblImg.Text
txlAddress.Text = Replace(txaAddress.Text, "\n", "<br>")

END SELECT

END

PUBLIC SUB Wizard1_Close() ' user clicks ok on the last page

Message.Info(("Your order was submitted successfully.\nThe wizard will close now."))
ME.Close

END

PUBLIC SUB chbTerms_Click() ' user wants (not) to read "terms & conditions"

Wizard1[2].Enabled = chbTerms.Value ' step 3 is visible or not, according to this decision

END

PUBLIC SUB chbSave_Click() ' user wants (not) to save

Wizard1[4].Enabled = chbSave.Value ' step 5 is visible or not, according to this decision

END

PUBLIC SUB Wizard1_BeforeChange()

SELECT CASE Wizard1.Index

CASE 4

IF txaAddress.Text = "" THEN
Message.Error(("You didn't enter your address.\nYour order can't be submitted."))
Wizard1.Index = 3 ' move back to step 4
STOP EVENT
ENDIF

END SELECT

END

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

Navigation :



<-- Accueil du WIKI : <--

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

Documentation :



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