resources/scenemain.lua

changeset 0
7ff85f7ce3a7
equal deleted inserted replaced
-1:000000000000 0:7c67a57d3eee
1 -- Initiate scene management
2 local sceneloc = director:createScene()
3 sceneloc.name = 'Scene: Main'
4
5 -- Database instantiated
6 local debe
7 local pathStor = system:getFilePath('storage')
8 debe = sqlite3.open(pathStor .. 'amalog.sql')
9 debe:exec[=[
10 CREATE TABLE qsos(id INTEGER PRIMARY KEY, call TEXT);
11 ]=]
12 debe:close()
13 debe = nil
14
15 -- Constants calculated
16 local dsw = director.displayWidth
17 local dsh = director.displayHeight
18 local dmw = director.displayCenterX
19 local dmh = director.displayCenterY
20
21 -- Fonts created
22 local fontsegoe = director:createFont('fonts/SegoeUI-92pt_smbld.fnt')
23 local fontarial = director:createFont('fonts/Arial-96pt_bold.fnt')
24
25 -- Tables of indexed and marked db rows
26 local dbIdx = {0, 0, 0, 0, 0, 0, 0}
27 local dbMrk = {0, 0, 0, 0, 0, 0, 0}
28
29 -- Scrolling index
30 local nScroll = 0
31
32 -- Scrolling placeholder
33 local posMove = 0
34
35 function sceneloc:setUp(event)
36 dbg.print('sceneloc:setUp')
37 --self.obj0 = director:createLabel(4, dh/2, 'MAIN MENU')
38 --self.obj1 = director:createRectangle(
39
40 -- Print background
41 local imgback = director:createSprite(0, dsh - fontarial.height * 12, 'textures/skynorm.png')
42 imgback.xScale = dsw / imgback.w
43 imgback.yScale = fontarial.height * 10.5 / imgback.h
44
45 -- Declare defaults
46 --director:setNodesColor(32, 32, 32, 128)
47 --director:setNodesColor(112, 128, 144, 255)
48 director:setNodesColor(192, 192, 192)
49
50 -- Heading labels
51 -- x=0, y=dsh-fontarial.height,
52 -- x=dsw/2, y=dsh-fontarial.height,
53 -- textTouchableBorder=0
54 local labnull = director:createLabel()
55 --labnull.isVisible = false
56 -- x=-dsw/4, y=-fontarial.height*1.5/6,
57 -- x=dsw/4, y=-fontarial.height*1.5/6,
58 -- hAlignment='centre', vAlignment='top',
59 local labtitle = director:createLabel({
60 x=0, y=-fontarial.height*1.5/6,
61 hAlignment='centre', vAlignment='top',
62 font=fontarial,
63 text='Amalog',
64 color={0xe0, 0xe0, 0xff}
65 })
66 local butabout = director:createSprite(0, 0, 'images/buttinfo.png')
67 butabout.x = fontarial.height*1.5/2
68 butabout.y = dsh-fontarial.height*1.5/2
69 butabout.xAnchor = 0.5
70 butabout.yAnchor = 0.5
71 local buthelp = director:createSprite(0, 0, 'images/butthelp.png')
72 buthelp.x = dsw-fontarial.height*1.5/2
73 buthelp.y = dsh-fontarial.height*1.5/2
74 buthelp.xAnchor = 0.5
75 buthelp.yAnchor = 0.5
76 --tween:dissolve(labnull, butabout, 1, 0)
77 --tween:dissolve(labnull, buthelp, 1, 0)
78
79 --local rectest = director:createRectangle(0, (dsh - fontarial.height * 4.5), dsw, fontarial.height * 1.5)
80 rectoddy = director:createRectangle(0, (dsh - fontarial.height * 3), dsw, fontarial.height * 1.5)
81 --rectoddy.color = color.black; rectoddy.color.a = 224;
82 rectoddy.color = color.lightGrey
83 recteven = director:createRectangle(0, (dsh - fontarial.height * 4.5), dsw, fontarial.height * 1.5)
84 recthree = director:createRectangle(0, (dsh - fontarial.height * 6), dsw, fontarial.height * 1.5)
85 --recthree.color = color.black; recthree.color.a = 224;
86 recthree.color = color.lightGrey
87 rectfour = director:createRectangle(0, (dsh - fontarial.height * 7.5), dsw, fontarial.height * 1.5)
88 rectfive = director:createRectangle(0, (dsh - fontarial.height * 9), dsw, fontarial.height * 1.5)
89 --rectfive.color = color.black; rectfive.color.a = 224;
90 rectfive.color = color.lightGrey
91 rectseis = director:createRectangle(0, (dsh - fontarial.height * 10.5), dsw, fontarial.height * 1.5)
92 rectsieb = director:createRectangle(0, (dsh - fontarial.height * 12), dsw, fontarial.height * 1.5)
93 --rectsieb.color = color.black; rectsieb.color.a = 224;
94 rectsieb.color = color.lightGrey
95
96 ----local labtext = director:createLabel(0, 0, 'Excusez moi Welt!')
97 --local labheight = director:createLabel({x=0, y=0, font=fontsegoe, color=color.white, text=dsh})
98 --local labwidth = director:createLabel({x=0, y=fontsegoe.height, font=fontsegoe, color=color.yellow, text=dsw})
99 --local labmith = director:createLabel({x=0, y=2*fontsegoe.height, font=fontsegoe, color=color.green, text=dmh})
100 --local labmitw = director:createLabel({x=0, y=3*fontsegoe.height, font=fontsegoe, color=color.blue, text=dmw})
101
102 function rectoddy:touch(event)
103 if event.phase == 'began' then
104 posMove = event.y
105 local nBase = event.y - (dsh - fontarial.height * 12)
106 local nRect = fontarial.height * 1.5
107 local nTemp = nBase / nRect
108 local nIdx = 7 - math.floor(nTemp)
109 if dbIdx[nIdx] == 0 then
110 return
111 elseif rectoddy.color.r == 240 and rectoddy.color.g == 230 and rectoddy.color.b == 140 then
112 rectoddy.color = color.lightGrey
113 dbMrk[nIdx] = 0
114 else
115 rectoddy.color = color.khaki
116 dbMrk[nIdx] = dbIdx[nIdx]
117 end
118 end
119
120 --if event.phase == 'moved' then
121 -- posMove = event.y
122 --end
123
124 if event.phase == 'ended' then
125 if math.abs(event.y - posMove) > fontarial.height*1.5 then
126 -- Provide callback to count rows in table
127 local nCount = 0
128 function countrows(udata, cols, values, names)
129 assert(udata == 'dingdong')
130 nCount = tonumber(values[1])
131 return 0
132 end
133
134 -- Repopulate UI conditionally
135 debe = sqlite3.open(pathStor .. 'amalog.sql')
136 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
137 debe:close()
138 debe = nil
139
140 if event.y - posMove > 0 then -- Gesture upward
141 if nScroll + 7 < nCount then
142 nScroll = nScroll + 7
143 else
144 return
145 end
146 else -- Gesture downward
147 if nScroll - 7 >= 0 then
148 nScroll = nScroll - 7
149 else
150 return
151 end
152 end
153
154 -- Kludge stucked event handlers
155 rectoddy:removeEventListener('touch', rectoddy)
156 recteven:removeEventListener('touch', recteven)
157 recthree:removeEventListener('touch', recthree)
158 rectfour:removeEventListener('touch', rectfour)
159 rectfive:removeEventListener('touch', rectfive)
160 rectseis:removeEventListener('touch', rectseis)
161 rectsieb:removeEventListener('touch', rectsieb)
162
163 -- Clear viewport
164 for nIter = 0, 6 do
165 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
166
167 function rectfresh:touch(event)
168 if event.phase == 'began' then
169 posMove = event.y
170 local nBase = event.y - (dsh - fontarial.height * 12)
171 local nRect = fontarial.height * 1.5
172 local nTemp = nBase / nRect
173 local nIdx = 7 - math.floor(nTemp)
174 if dbIdx[nIdx] == 0 then
175 return
176 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
177 event.target.color = color.lightGrey
178 dbMrk[nIdx] = 0
179 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
180 event.target.color = {192, 192, 192}
181 dbMrk[nIdx] = 0
182 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
183 event.target.color = {220, 210, 120}
184 dbMrk[nIdx] = dbIdx[nIdx]
185 else
186 event.target.color = color.khaki
187 dbMrk[nIdx] = dbIdx[nIdx]
188 end
189 end
190 if event.phase == 'ended' then
191 if math.abs(event.y - posMove) > fontarial.height*1.5 then
192 -- Provide callback to count rows in table
193 local nCount = 0
194 function countrows(udata, cols, values, names)
195 assert(udata == 'dingdong')
196 nCount = tonumber(values[1])
197 return 0
198 end
199
200 -- Repopulate UI conditionally
201 debe = sqlite3.open(pathStor .. 'amalog.sql')
202 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
203 debe:close()
204 debe = nil
205
206 if event.y - posMove > 0 then -- Gesture upward
207 if nScroll + 7 < nCount then
208 nScroll = nScroll + 7
209 else
210 return
211 end
212 else -- Gesture downward
213 if nScroll - 7 >= 0 then
214 nScroll = nScroll - 7
215 else
216 return
217 end
218 end
219
220 -- Kludge stucked event handlers
221 rectoddy:removeEventListener('touch', rectoddy)
222 recteven:removeEventListener('touch', recteven)
223 recthree:removeEventListener('touch', recthree)
224 rectfour:removeEventListener('touch', rectfour)
225 rectfive:removeEventListener('touch', rectfive)
226 rectseis:removeEventListener('touch', rectseis)
227 rectsieb:removeEventListener('touch', rectsieb)
228
229 -- Clear viewport
230 for nIter = 0, 6 do
231 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
232
233 function rectfresh:touch(event)
234 if event.phase == 'began' then
235 posMove = event.y
236 local nBase = event.y - (dsh - fontarial.height * 12)
237 local nRect = fontarial.height * 1.5
238 local nTemp = nBase / nRect
239 local nIdx = 7 - math.floor(nTemp)
240 if dbIdx[nIdx] == 0 then
241 return
242 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
243 event.target.color = color.lightGrey
244 dbMrk[nIdx] = 0
245 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
246 event.target.color = {192, 192, 192}
247 dbMrk[nIdx] = 0
248 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
249 event.target.color = {220, 210, 120}
250 dbMrk[nIdx] = dbIdx[nIdx]
251 else
252 event.target.color = color.khaki
253 dbMrk[nIdx] = dbIdx[nIdx]
254 end
255 end
256 end
257 rectfresh:addEventListener('touch', rectfresh)
258
259 if nIter % 2 == 0 then
260 rectfresh.color = color.lightGrey
261 else
262 rectfresh.color = {192, 192, 192}
263 end
264
265 -- Clear indexes
266 dbIdx[nIter+1] = 0
267 dbMrk[nIter+1] = 0
268 end
269
270 -- Redraw labels
271 local nIter = 6
272 --for nIter = 0, 7 do
273 local nTemp = nCount - nScroll
274 if nTemp < 7 then
275 nIter = nTemp - 1
276 end
277
278 debe = sqlite3.open(pathStor .. 'amalog.sql')
279 for dbRows in debe:nrows('SELECT * FROM qsos') do
280 if nTemp < 8 then
281 if nTemp < 0 then break end
282 if nIter < 0 then break end
283 local labrepop = director:createLabel({
284 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
285 hAlignment='left', vAlignment='bottom',
286 font=fontsegoe,
287 text=dbRows['call']
288 })
289 dbIdx[nIter+1] = dbRows['id']
290 nIter = nIter - 1
291 nTemp = nTemp - 1
292 else
293 nTemp = nTemp - 1
294 end
295 end
296 debe:close()
297 debe = nil
298 end
299 posMove = 0
300 end
301 end
302 rectfresh:addEventListener('touch', rectfresh)
303
304 if nIter % 2 == 0 then
305 rectfresh.color = color.lightGrey
306 else
307 rectfresh.color = {192, 192, 192}
308 end
309
310 -- Clear indexes
311 dbIdx[nIter+1] = 0
312 dbMrk[nIter+1] = 0
313 end
314
315 -- Redraw labels
316 local nIter = 6
317 --for nIter = 0, 7 do
318 local nTemp = nCount - nScroll
319 if nTemp < 7 then
320 nIter = nTemp - 1
321 end
322
323 debe = sqlite3.open(pathStor .. 'amalog.sql')
324 for dbRows in debe:nrows('SELECT * FROM qsos') do
325 if nTemp < 8 then
326 if nTemp < 0 then break end
327 if nIter < 0 then break end
328 local labrepop = director:createLabel({
329 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
330 hAlignment='left', vAlignment='bottom',
331 font=fontsegoe,
332 text=dbRows['call']
333 })
334 dbIdx[nIter+1] = dbRows['id']
335 nIter = nIter - 1
336 nTemp = nTemp - 1
337 else
338 nTemp = nTemp - 1
339 end
340 end
341 debe:close()
342 debe = nil
343 end
344 posMove = 0
345 end
346 end
347 rectoddy:addEventListener('touch', rectoddy)
348
349 function recteven:touch(event)
350 if event.phase == 'began' then
351 posMove = event.y
352 local nBase = event.y - (dsh - fontarial.height * 12)
353 local nRect = fontarial.height * 1.5
354 local nTemp = nBase / nRect
355 local nIdx = 7 - math.floor(nTemp)
356 if dbIdx[nIdx] == 0 then
357 return
358 elseif recteven.color.r == 220 and recteven.color.g == 210 and recteven.color.b == 120 then
359 recteven.color = {192, 192, 192}
360 dbMrk[nIdx] = 0
361 else
362 recteven.color = {220, 210, 120}
363 dbMrk[nIdx] = dbIdx[nIdx]
364 end
365 end
366
367 if event.phase == 'ended' then
368 if math.abs(event.y - posMove) > fontarial.height*1.5 then
369 -- Provide callback to count rows in table
370 local nCount = 0
371 function countrows(udata, cols, values, names)
372 assert(udata == 'dingdong')
373 nCount = tonumber(values[1])
374 return 0
375 end
376
377 -- Repopulate UI conditionally
378 debe = sqlite3.open(pathStor .. 'amalog.sql')
379 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
380 debe:close()
381 debe = nil
382
383 if event.y - posMove > 0 then -- Gesture upward
384 if nScroll + 7 < nCount then
385 nScroll = nScroll + 7
386 else
387 return
388 end
389 else -- Gesture downward
390 if nScroll - 7 >= 0 then
391 nScroll = nScroll - 7
392 else
393 return
394 end
395 end
396
397 -- Kludge stucked event handlers
398 rectoddy:removeEventListener('touch', rectoddy)
399 recteven:removeEventListener('touch', recteven)
400 recthree:removeEventListener('touch', recthree)
401 rectfour:removeEventListener('touch', rectfour)
402 rectfive:removeEventListener('touch', rectfive)
403 rectseis:removeEventListener('touch', rectseis)
404 rectsieb:removeEventListener('touch', rectsieb)
405
406 -- Clear viewport
407 for nIter = 0, 6 do
408 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
409
410 function rectfresh:touch(event)
411 if event.phase == 'began' then
412 posMove = event.y
413 local nBase = event.y - (dsh - fontarial.height * 12)
414 local nRect = fontarial.height * 1.5
415 local nTemp = nBase / nRect
416 local nIdx = 7 - math.floor(nTemp)
417 if dbIdx[nIdx] == 0 then
418 return
419 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
420 event.target.color = color.lightGrey
421 dbMrk[nIdx] = 0
422 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
423 event.target.color = {192, 192, 192}
424 dbMrk[nIdx] = 0
425 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
426 event.target.color = {220, 210, 120}
427 dbMrk[nIdx] = dbIdx[nIdx]
428 else
429 event.target.color = color.khaki
430 dbMrk[nIdx] = dbIdx[nIdx]
431 end
432 end
433 if event.phase == 'ended' then
434 if math.abs(event.y - posMove) > fontarial.height*1.5 then
435 -- Provide callback to count rows in table
436 local nCount = 0
437 function countrows(udata, cols, values, names)
438 assert(udata == 'dingdong')
439 nCount = tonumber(values[1])
440 return 0
441 end
442
443 -- Repopulate UI conditionally
444 debe = sqlite3.open(pathStor .. 'amalog.sql')
445 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
446 debe:close()
447 debe = nil
448
449 if event.y - posMove > 0 then -- Gesture upward
450 if nScroll + 7 < nCount then
451 nScroll = nScroll + 7
452 else
453 return
454 end
455 else -- Gesture downward
456 if nScroll - 7 >= 0 then
457 nScroll = nScroll - 7
458 else
459 return
460 end
461 end
462
463 -- Kludge stucked event handlers
464 rectoddy:removeEventListener('touch', rectoddy)
465 recteven:removeEventListener('touch', recteven)
466 recthree:removeEventListener('touch', recthree)
467 rectfour:removeEventListener('touch', rectfour)
468 rectfive:removeEventListener('touch', rectfive)
469 rectseis:removeEventListener('touch', rectseis)
470 rectsieb:removeEventListener('touch', rectsieb)
471
472 -- Clear viewport
473 for nIter = 0, 6 do
474 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
475
476 function rectfresh:touch(event)
477 if event.phase == 'began' then
478 posMove = event.y
479 local nBase = event.y - (dsh - fontarial.height * 12)
480 local nRect = fontarial.height * 1.5
481 local nTemp = nBase / nRect
482 local nIdx = 7 - math.floor(nTemp)
483 if dbIdx[nIdx] == 0 then
484 return
485 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
486 event.target.color = color.lightGrey
487 dbMrk[nIdx] = 0
488 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
489 event.target.color = {192, 192, 192}
490 dbMrk[nIdx] = 0
491 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
492 event.target.color = {220, 210, 120}
493 dbMrk[nIdx] = dbIdx[nIdx]
494 else
495 event.target.color = color.khaki
496 dbMrk[nIdx] = dbIdx[nIdx]
497 end
498 end
499 end
500 rectfresh:addEventListener('touch', rectfresh)
501
502 if nIter % 2 == 0 then
503 rectfresh.color = color.lightGrey
504 else
505 rectfresh.color = {192, 192, 192}
506 end
507
508 -- Clear indexes
509 dbIdx[nIter+1] = 0
510 dbMrk[nIter+1] = 0
511 end
512
513 -- Redraw labels
514 local nIter = 6
515 --for nIter = 0, 7 do
516 local nTemp = nCount - nScroll
517 if nTemp < 7 then
518 nIter = nTemp - 1
519 end
520
521 debe = sqlite3.open(pathStor .. 'amalog.sql')
522 for dbRows in debe:nrows('SELECT * FROM qsos') do
523 if nTemp < 8 then
524 if nTemp < 0 then break end
525 if nIter < 0 then break end
526 local labrepop = director:createLabel({
527 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
528 hAlignment='left', vAlignment='bottom',
529 font=fontsegoe,
530 text=dbRows['call']
531 })
532 dbIdx[nIter+1] = dbRows['id']
533 nIter = nIter - 1
534 nTemp = nTemp - 1
535 else
536 nTemp = nTemp - 1
537 end
538 end
539 debe:close()
540 debe = nil
541 end
542 posMove = 0
543 end
544 end
545 rectfresh:addEventListener('touch', rectfresh)
546
547 if nIter % 2 == 0 then
548 rectfresh.color = color.lightGrey
549 else
550 rectfresh.color = {192, 192, 192}
551 end
552
553 -- Clear indexes
554 dbIdx[nIter+1] = 0
555 dbMrk[nIter+1] = 0
556 end
557
558 -- Redraw labels
559 local nIter = 6
560 --for nIter = 0, 7 do
561 local nTemp = nCount - nScroll
562 if nTemp < 7 then
563 nIter = nTemp - 1
564 end
565
566 debe = sqlite3.open(pathStor .. 'amalog.sql')
567 for dbRows in debe:nrows('SELECT * FROM qsos') do
568 if nTemp < 8 then
569 if nTemp < 0 then break end
570 if nIter < 0 then break end
571 local labrepop = director:createLabel({
572 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
573 hAlignment='left', vAlignment='bottom',
574 font=fontsegoe,
575 text=dbRows['call']
576 })
577 dbIdx[nIter+1] = dbRows['id']
578 nIter = nIter - 1
579 nTemp = nTemp - 1
580 else
581 nTemp = nTemp - 1
582 end
583 end
584 debe:close()
585 debe = nil
586 end
587 posMove = 0
588 end
589 end
590 recteven:addEventListener('touch', recteven)
591
592 function recthree:touch(event)
593 if event.phase == 'began' then
594 posMove = event.y
595 local nBase = event.y - (dsh - fontarial.height * 12)
596 local nRect = fontarial.height * 1.5
597 local nTemp = nBase / nRect
598 local nIdx = 7 - math.floor(nTemp)
599 if dbIdx[nIdx] == 0 then
600 return
601 elseif recthree.color.r == 240 and recthree.color.g == 230 and recthree.color.b == 140 then
602 recthree.color = color.lightGrey
603 dbMrk[nIdx] = 0
604 else
605 recthree.color = color.khaki
606 dbMrk[nIdx] = dbIdx[nIdx]
607 end
608 end
609
610 if event.phase == 'ended' then
611 if math.abs(event.y - posMove) > fontarial.height*1.5 then
612 -- Provide callback to count rows in table
613 local nCount = 0
614 function countrows(udata, cols, values, names)
615 assert(udata == 'dingdong')
616 nCount = tonumber(values[1])
617 return 0
618 end
619
620 -- Repopulate UI conditionally
621 debe = sqlite3.open(pathStor .. 'amalog.sql')
622 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
623 debe:close()
624 debe = nil
625
626 if event.y - posMove > 0 then -- Gesture upward
627 if nScroll + 7 < nCount then
628 nScroll = nScroll + 7
629 else
630 return
631 end
632 else -- Gesture downward
633 if nScroll - 7 >= 0 then
634 nScroll = nScroll - 7
635 else
636 return
637 end
638 end
639
640 -- Kludge stucked event handlers
641 rectoddy:removeEventListener('touch', rectoddy)
642 recteven:removeEventListener('touch', recteven)
643 recthree:removeEventListener('touch', recthree)
644 rectfour:removeEventListener('touch', rectfour)
645 rectfive:removeEventListener('touch', rectfive)
646 rectseis:removeEventListener('touch', rectseis)
647 rectsieb:removeEventListener('touch', rectsieb)
648
649 -- Clear viewport
650 for nIter = 0, 6 do
651 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
652
653 function rectfresh:touch(event)
654 if event.phase == 'began' then
655 posMove = event.y
656 local nBase = event.y - (dsh - fontarial.height * 12)
657 local nRect = fontarial.height * 1.5
658 local nTemp = nBase / nRect
659 local nIdx = 7 - math.floor(nTemp)
660 if dbIdx[nIdx] == 0 then
661 return
662 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
663 event.target.color = color.lightGrey
664 dbMrk[nIdx] = 0
665 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
666 event.target.color = {192, 192, 192}
667 dbMrk[nIdx] = 0
668 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
669 event.target.color = {220, 210, 120}
670 dbMrk[nIdx] = dbIdx[nIdx]
671 else
672 event.target.color = color.khaki
673 dbMrk[nIdx] = dbIdx[nIdx]
674 end
675 end
676 if event.phase == 'ended' then
677 if math.abs(event.y - posMove) > fontarial.height*1.5 then
678 -- Provide callback to count rows in table
679 local nCount = 0
680 function countrows(udata, cols, values, names)
681 assert(udata == 'dingdong')
682 nCount = tonumber(values[1])
683 return 0
684 end
685
686 -- Repopulate UI conditionally
687 debe = sqlite3.open(pathStor .. 'amalog.sql')
688 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
689 debe:close()
690 debe = nil
691
692 if event.y - posMove > 0 then -- Gesture upward
693 if nScroll + 7 < nCount then
694 nScroll = nScroll + 7
695 else
696 return
697 end
698 else -- Gesture downward
699 if nScroll - 7 >= 0 then
700 nScroll = nScroll - 7
701 else
702 return
703 end
704 end
705
706 -- Kludge stucked event handlers
707 rectoddy:removeEventListener('touch', rectoddy)
708 recteven:removeEventListener('touch', recteven)
709 recthree:removeEventListener('touch', recthree)
710 rectfour:removeEventListener('touch', rectfour)
711 rectfive:removeEventListener('touch', rectfive)
712 rectseis:removeEventListener('touch', rectseis)
713 rectsieb:removeEventListener('touch', rectsieb)
714
715 -- Clear viewport
716 for nIter = 0, 6 do
717 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
718
719 function rectfresh:touch(event)
720 if event.phase == 'began' then
721 posMove = event.y
722 local nBase = event.y - (dsh - fontarial.height * 12)
723 local nRect = fontarial.height * 1.5
724 local nTemp = nBase / nRect
725 local nIdx = 7 - math.floor(nTemp)
726 if dbIdx[nIdx] == 0 then
727 return
728 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
729 event.target.color = color.lightGrey
730 dbMrk[nIdx] = 0
731 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
732 event.target.color = {192, 192, 192}
733 dbMrk[nIdx] = 0
734 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
735 event.target.color = {220, 210, 120}
736 dbMrk[nIdx] = dbIdx[nIdx]
737 else
738 event.target.color = color.khaki
739 dbMrk[nIdx] = dbIdx[nIdx]
740 end
741 end
742 end
743 rectfresh:addEventListener('touch', rectfresh)
744
745 if nIter % 2 == 0 then
746 rectfresh.color = color.lightGrey
747 else
748 rectfresh.color = {192, 192, 192}
749 end
750
751 -- Clear indexes
752 dbIdx[nIter+1] = 0
753 dbMrk[nIter+1] = 0
754 end
755
756 -- Redraw labels
757 local nIter = 6
758 --for nIter = 0, 7 do
759 local nTemp = nCount - nScroll
760 if nTemp < 7 then
761 nIter = nTemp - 1
762 end
763
764 debe = sqlite3.open(pathStor .. 'amalog.sql')
765 for dbRows in debe:nrows('SELECT * FROM qsos') do
766 if nTemp < 8 then
767 if nTemp < 0 then break end
768 if nIter < 0 then break end
769 local labrepop = director:createLabel({
770 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
771 hAlignment='left', vAlignment='bottom',
772 font=fontsegoe,
773 text=dbRows['call']
774 })
775 dbIdx[nIter+1] = dbRows['id']
776 nIter = nIter - 1
777 nTemp = nTemp - 1
778 else
779 nTemp = nTemp - 1
780 end
781 end
782 debe:close()
783 debe = nil
784 end
785 posMove = 0
786 end
787 end
788 rectfresh:addEventListener('touch', rectfresh)
789
790 if nIter % 2 == 0 then
791 rectfresh.color = color.lightGrey
792 else
793 rectfresh.color = {192, 192, 192}
794 end
795
796 -- Clear indexes
797 dbIdx[nIter+1] = 0
798 dbMrk[nIter+1] = 0
799 end
800
801 -- Redraw labels
802 local nIter = 6
803 --for nIter = 0, 7 do
804 local nTemp = nCount - nScroll
805 if nTemp < 7 then
806 nIter = nTemp - 1
807 end
808
809 debe = sqlite3.open(pathStor .. 'amalog.sql')
810 for dbRows in debe:nrows('SELECT * FROM qsos') do
811 if nTemp < 8 then
812 if nTemp < 0 then break end
813 if nIter < 0 then break end
814 local labrepop = director:createLabel({
815 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
816 hAlignment='left', vAlignment='bottom',
817 font=fontsegoe,
818 text=dbRows['call']
819 })
820 dbIdx[nIter+1] = dbRows['id']
821 nIter = nIter - 1
822 nTemp = nTemp - 1
823 else
824 nTemp = nTemp - 1
825 end
826 end
827 debe:close()
828 debe = nil
829 end
830 posMove = 0
831 end
832 end
833 recthree:addEventListener('touch', recthree)
834
835 function rectfour:touch(event)
836 if event.phase == 'began' then
837 posMove = event.y
838 local nBase = event.y - (dsh - fontarial.height * 12)
839 local nRect = fontarial.height * 1.5
840 local nTemp = nBase / nRect
841 local nIdx = 7 - math.floor(nTemp)
842 if dbIdx[nIdx] == 0 then
843 return
844 elseif rectfour.color.r == 220 and rectfour.color.g == 210 and rectfour.color.b == 120 then
845 rectfour.color = {192, 192, 192}
846 dbMrk[nIdx] = 0
847 else
848 rectfour.color = {220, 210, 120}
849 dbMrk[nIdx] = dbIdx[nIdx]
850 end
851 end
852
853 if event.phase == 'ended' then
854 if math.abs(event.y - posMove) > fontarial.height*1.5 then
855 -- Provide callback to count rows in table
856 local nCount = 0
857 function countrows(udata, cols, values, names)
858 assert(udata == 'dingdong')
859 nCount = tonumber(values[1])
860 return 0
861 end
862
863 -- Repopulate UI conditionally
864 debe = sqlite3.open(pathStor .. 'amalog.sql')
865 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
866 debe:close()
867 debe = nil
868
869 if event.y - posMove > 0 then -- Gesture upward
870 if nScroll + 7 < nCount then
871 nScroll = nScroll + 7
872 else
873 return
874 end
875 else -- Gesture downward
876 if nScroll - 7 >= 0 then
877 nScroll = nScroll - 7
878 else
879 return
880 end
881 end
882
883 -- Kludge stucked event handlers
884 rectoddy:removeEventListener('touch', rectoddy)
885 recteven:removeEventListener('touch', recteven)
886 recthree:removeEventListener('touch', recthree)
887 rectfour:removeEventListener('touch', rectfour)
888 rectfive:removeEventListener('touch', rectfive)
889 rectseis:removeEventListener('touch', rectseis)
890 rectsieb:removeEventListener('touch', rectsieb)
891
892 -- Clear viewport
893 for nIter = 0, 6 do
894 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
895
896 function rectfresh:touch(event)
897 if event.phase == 'began' then
898 posMove = event.y
899 local nBase = event.y - (dsh - fontarial.height * 12)
900 local nRect = fontarial.height * 1.5
901 local nTemp = nBase / nRect
902 local nIdx = 7 - math.floor(nTemp)
903 if dbIdx[nIdx] == 0 then
904 return
905 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
906 event.target.color = color.lightGrey
907 dbMrk[nIdx] = 0
908 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
909 event.target.color = {192, 192, 192}
910 dbMrk[nIdx] = 0
911 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
912 event.target.color = {220, 210, 120}
913 dbMrk[nIdx] = dbIdx[nIdx]
914 else
915 event.target.color = color.khaki
916 dbMrk[nIdx] = dbIdx[nIdx]
917 end
918 end
919 if event.phase == 'ended' then
920 if math.abs(event.y - posMove) > fontarial.height*1.5 then
921 -- Provide callback to count rows in table
922 local nCount = 0
923 function countrows(udata, cols, values, names)
924 assert(udata == 'dingdong')
925 nCount = tonumber(values[1])
926 return 0
927 end
928
929 -- Repopulate UI conditionally
930 debe = sqlite3.open(pathStor .. 'amalog.sql')
931 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
932 debe:close()
933 debe = nil
934
935 if event.y - posMove > 0 then -- Gesture upward
936 if nScroll + 7 < nCount then
937 nScroll = nScroll + 7
938 else
939 return
940 end
941 else -- Gesture downward
942 if nScroll - 7 >= 0 then
943 nScroll = nScroll - 7
944 else
945 return
946 end
947 end
948
949 -- Kludge stucked event handlers
950 rectoddy:removeEventListener('touch', rectoddy)
951 recteven:removeEventListener('touch', recteven)
952 recthree:removeEventListener('touch', recthree)
953 rectfour:removeEventListener('touch', rectfour)
954 rectfive:removeEventListener('touch', rectfive)
955 rectseis:removeEventListener('touch', rectseis)
956 rectsieb:removeEventListener('touch', rectsieb)
957
958 -- Clear viewport
959 for nIter = 0, 6 do
960 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
961
962 function rectfresh:touch(event)
963 if event.phase == 'began' then
964 posMove = event.y
965 local nBase = event.y - (dsh - fontarial.height * 12)
966 local nRect = fontarial.height * 1.5
967 local nTemp = nBase / nRect
968 local nIdx = 7 - math.floor(nTemp)
969 if dbIdx[nIdx] == 0 then
970 return
971 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
972 event.target.color = color.lightGrey
973 dbMrk[nIdx] = 0
974 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
975 event.target.color = {192, 192, 192}
976 dbMrk[nIdx] = 0
977 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
978 event.target.color = {220, 210, 120}
979 dbMrk[nIdx] = dbIdx[nIdx]
980 else
981 event.target.color = color.khaki
982 dbMrk[nIdx] = dbIdx[nIdx]
983 end
984 end
985 end
986 rectfresh:addEventListener('touch', rectfresh)
987
988 if nIter % 2 == 0 then
989 rectfresh.color = color.lightGrey
990 else
991 rectfresh.color = {192, 192, 192}
992 end
993
994 -- Clear indexes
995 dbIdx[nIter+1] = 0
996 dbMrk[nIter+1] = 0
997 end
998
999 -- Redraw labels
1000 local nIter = 6
1001 --for nIter = 0, 7 do
1002 local nTemp = nCount - nScroll
1003 if nTemp < 7 then
1004 nIter = nTemp - 1
1005 end
1006
1007 debe = sqlite3.open(pathStor .. 'amalog.sql')
1008 for dbRows in debe:nrows('SELECT * FROM qsos') do
1009 if nTemp < 8 then
1010 if nTemp < 0 then break end
1011 if nIter < 0 then break end
1012 local labrepop = director:createLabel({
1013 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1014 hAlignment='left', vAlignment='bottom',
1015 font=fontsegoe,
1016 text=dbRows['call']
1017 })
1018 dbIdx[nIter+1] = dbRows['id']
1019 nIter = nIter - 1
1020 nTemp = nTemp - 1
1021 else
1022 nTemp = nTemp - 1
1023 end
1024 end
1025 debe:close()
1026 debe = nil
1027 end
1028 posMove = 0
1029 end
1030 end
1031 rectfresh:addEventListener('touch', rectfresh)
1032
1033 if nIter % 2 == 0 then
1034 rectfresh.color = color.lightGrey
1035 else
1036 rectfresh.color = {192, 192, 192}
1037 end
1038
1039 -- Clear indexes
1040 dbIdx[nIter+1] = 0
1041 dbMrk[nIter+1] = 0
1042 end
1043
1044 -- Redraw labels
1045 local nIter = 6
1046 --for nIter = 0, 7 do
1047 local nTemp = nCount - nScroll
1048 if nTemp < 7 then
1049 nIter = nTemp - 1
1050 end
1051
1052 debe = sqlite3.open(pathStor .. 'amalog.sql')
1053 for dbRows in debe:nrows('SELECT * FROM qsos') do
1054 if nTemp < 8 then
1055 if nTemp < 0 then break end
1056 if nIter < 0 then break end
1057 local labrepop = director:createLabel({
1058 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1059 hAlignment='left', vAlignment='bottom',
1060 font=fontsegoe,
1061 text=dbRows['call']
1062 })
1063 dbIdx[nIter+1] = dbRows['id']
1064 nIter = nIter - 1
1065 nTemp = nTemp - 1
1066 else
1067 nTemp = nTemp - 1
1068 end
1069 end
1070 debe:close()
1071 debe = nil
1072 end
1073 posMove = 0
1074 end
1075 end
1076 rectfour:addEventListener('touch', rectfour)
1077
1078 function rectfive:touch(event)
1079 if event.phase == 'began' then
1080 posMove = event.y
1081 local nBase = event.y - (dsh - fontarial.height * 12)
1082 local nRect = fontarial.height * 1.5
1083 local nTemp = nBase / nRect
1084 local nIdx = 7 - math.floor(nTemp)
1085 if dbIdx[nIdx] == 0 then
1086 return
1087 elseif rectfive.color.r == 240 and rectfive.color.g == 230 and rectfive.color.b == 140 then
1088 rectfive.color = color.lightGrey
1089 dbMrk[nIdx] = 0
1090 else
1091 rectfive.color = color.khaki
1092 dbMrk[nIdx] = dbIdx[nIdx]
1093 end
1094 end
1095
1096 if event.phase == 'ended' then
1097 if math.abs(event.y - posMove) > fontarial.height*1.5 then
1098 -- Provide callback to count rows in table
1099 local nCount = 0
1100 function countrows(udata, cols, values, names)
1101 assert(udata == 'dingdong')
1102 nCount = tonumber(values[1])
1103 return 0
1104 end
1105
1106 -- Repopulate UI conditionally
1107 debe = sqlite3.open(pathStor .. 'amalog.sql')
1108 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1109 debe:close()
1110 debe = nil
1111
1112 if event.y - posMove > 0 then -- Gesture upward
1113 if nScroll + 7 < nCount then
1114 nScroll = nScroll + 7
1115 else
1116 return
1117 end
1118 else -- Gesture downward
1119 if nScroll - 7 >= 0 then
1120 nScroll = nScroll - 7
1121 else
1122 return
1123 end
1124 end
1125
1126 -- Kludge stucked event handlers
1127 rectoddy:removeEventListener('touch', rectoddy)
1128 recteven:removeEventListener('touch', recteven)
1129 recthree:removeEventListener('touch', recthree)
1130 rectfour:removeEventListener('touch', rectfour)
1131 rectfive:removeEventListener('touch', rectfive)
1132 rectseis:removeEventListener('touch', rectseis)
1133 rectsieb:removeEventListener('touch', rectsieb)
1134
1135 -- Clear viewport
1136 for nIter = 0, 6 do
1137 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1138
1139 function rectfresh:touch(event)
1140 if event.phase == 'began' then
1141 posMove = event.y
1142 local nBase = event.y - (dsh - fontarial.height * 12)
1143 local nRect = fontarial.height * 1.5
1144 local nTemp = nBase / nRect
1145 local nIdx = 7 - math.floor(nTemp)
1146 if dbIdx[nIdx] == 0 then
1147 return
1148 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1149 event.target.color = color.lightGrey
1150 dbMrk[nIdx] = 0
1151 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1152 event.target.color = {192, 192, 192}
1153 dbMrk[nIdx] = 0
1154 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1155 event.target.color = {220, 210, 120}
1156 dbMrk[nIdx] = dbIdx[nIdx]
1157 else
1158 event.target.color = color.khaki
1159 dbMrk[nIdx] = dbIdx[nIdx]
1160 end
1161 end
1162 if event.phase == 'ended' then
1163 if math.abs(event.y - posMove) > fontarial.height*1.5 then
1164 -- Provide callback to count rows in table
1165 local nCount = 0
1166 function countrows(udata, cols, values, names)
1167 assert(udata == 'dingdong')
1168 nCount = tonumber(values[1])
1169 return 0
1170 end
1171
1172 -- Repopulate UI conditionally
1173 debe = sqlite3.open(pathStor .. 'amalog.sql')
1174 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1175 debe:close()
1176 debe = nil
1177
1178 if event.y - posMove > 0 then -- Gesture upward
1179 if nScroll + 7 < nCount then
1180 nScroll = nScroll + 7
1181 else
1182 return
1183 end
1184 else -- Gesture downward
1185 if nScroll - 7 >= 0 then
1186 nScroll = nScroll - 7
1187 else
1188 return
1189 end
1190 end
1191
1192 -- Kludge stucked event handlers
1193 rectoddy:removeEventListener('touch', rectoddy)
1194 recteven:removeEventListener('touch', recteven)
1195 recthree:removeEventListener('touch', recthree)
1196 rectfour:removeEventListener('touch', rectfour)
1197 rectfive:removeEventListener('touch', rectfive)
1198 rectseis:removeEventListener('touch', rectseis)
1199 rectsieb:removeEventListener('touch', rectsieb)
1200
1201 -- Clear viewport
1202 for nIter = 0, 6 do
1203 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1204
1205 function rectfresh:touch(event)
1206 if event.phase == 'began' then
1207 posMove = event.y
1208 local nBase = event.y - (dsh - fontarial.height * 12)
1209 local nRect = fontarial.height * 1.5
1210 local nTemp = nBase / nRect
1211 local nIdx = 7 - math.floor(nTemp)
1212 if dbIdx[nIdx] == 0 then
1213 return
1214 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1215 event.target.color = color.lightGrey
1216 dbMrk[nIdx] = 0
1217 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1218 event.target.color = {192, 192, 192}
1219 dbMrk[nIdx] = 0
1220 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1221 event.target.color = {220, 210, 120}
1222 dbMrk[nIdx] = dbIdx[nIdx]
1223 else
1224 event.target.color = color.khaki
1225 dbMrk[nIdx] = dbIdx[nIdx]
1226 end
1227 end
1228 end
1229 rectfresh:addEventListener('touch', rectfresh)
1230
1231 if nIter % 2 == 0 then
1232 rectfresh.color = color.lightGrey
1233 else
1234 rectfresh.color = {192, 192, 192}
1235 end
1236
1237 -- Clear indexes
1238 dbIdx[nIter+1] = 0
1239 dbMrk[nIter+1] = 0
1240 end
1241
1242 -- Redraw labels
1243 local nIter = 6
1244 --for nIter = 0, 7 do
1245 local nTemp = nCount - nScroll
1246 if nTemp < 7 then
1247 nIter = nTemp - 1
1248 end
1249
1250 debe = sqlite3.open(pathStor .. 'amalog.sql')
1251 for dbRows in debe:nrows('SELECT * FROM qsos') do
1252 if nTemp < 8 then
1253 if nTemp < 0 then break end
1254 if nIter < 0 then break end
1255 local labrepop = director:createLabel({
1256 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1257 hAlignment='left', vAlignment='bottom',
1258 font=fontsegoe,
1259 text=dbRows['call']
1260 })
1261 dbIdx[nIter+1] = dbRows['id']
1262 nIter = nIter - 1
1263 nTemp = nTemp - 1
1264 else
1265 nTemp = nTemp - 1
1266 end
1267 end
1268 debe:close()
1269 debe = nil
1270 end
1271 posMove = 0
1272 end
1273 end
1274 rectfresh:addEventListener('touch', rectfresh)
1275
1276 if nIter % 2 == 0 then
1277 rectfresh.color = color.lightGrey
1278 else
1279 rectfresh.color = {192, 192, 192}
1280 end
1281
1282 -- Clear indexes
1283 dbIdx[nIter+1] = 0
1284 dbMrk[nIter+1] = 0
1285 end
1286
1287 -- Redraw labels
1288 local nIter = 6
1289 --for nIter = 0, 7 do
1290 local nTemp = nCount - nScroll
1291 if nTemp < 7 then
1292 nIter = nTemp - 1
1293 end
1294
1295 debe = sqlite3.open(pathStor .. 'amalog.sql')
1296 for dbRows in debe:nrows('SELECT * FROM qsos') do
1297 if nTemp < 8 then
1298 if nTemp < 0 then break end
1299 if nIter < 0 then break end
1300 local labrepop = director:createLabel({
1301 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1302 hAlignment='left', vAlignment='bottom',
1303 font=fontsegoe,
1304 text=dbRows['call']
1305 })
1306 dbIdx[nIter+1] = dbRows['id']
1307 nIter = nIter - 1
1308 nTemp = nTemp - 1
1309 else
1310 nTemp = nTemp - 1
1311 end
1312 end
1313 debe:close()
1314 debe = nil
1315 end
1316 posMove = 0
1317 end
1318 end
1319 rectfive:addEventListener('touch', rectfive)
1320
1321 function rectseis:touch(event)
1322 if event.phase == 'began' then
1323 posMove = event.y
1324 local nBase = event.y - (dsh - fontarial.height * 12)
1325 local nRect = fontarial.height * 1.5
1326 local nTemp = nBase / nRect
1327 local nIdx = 7 - math.floor(nTemp)
1328 if dbIdx[nIdx] == 0 then
1329 return
1330 elseif rectseis.color.r == 220 and rectseis.color.g == 210 and rectseis.color.b == 120 then
1331 rectseis.color = {192, 192, 192}
1332 dbMrk[nIdx] = 0
1333 else
1334 rectseis.color = {220, 210, 120}
1335 dbMrk[nIdx] = dbIdx[nIdx]
1336 end
1337 end
1338
1339 if event.phase == 'ended' then
1340 if math.abs(event.y - posMove) > fontarial.height*1.5 then
1341 -- Provide callback to count rows in table
1342 local nCount = 0
1343 function countrows(udata, cols, values, names)
1344 assert(udata == 'dingdong')
1345 nCount = tonumber(values[1])
1346 return 0
1347 end
1348
1349 -- Repopulate UI conditionally
1350 debe = sqlite3.open(pathStor .. 'amalog.sql')
1351 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1352 debe:close()
1353 debe = nil
1354
1355 if event.y - posMove > 0 then -- Gesture upward
1356 if nScroll + 7 < nCount then
1357 nScroll = nScroll + 7
1358 else
1359 return
1360 end
1361 else -- Gesture downward
1362 if nScroll - 7 >= 0 then
1363 nScroll = nScroll - 7
1364 else
1365 return
1366 end
1367 end
1368
1369 -- Kludge stucked event handlers
1370 rectoddy:removeEventListener('touch', rectoddy)
1371 recteven:removeEventListener('touch', recteven)
1372 recthree:removeEventListener('touch', recthree)
1373 rectfour:removeEventListener('touch', rectfour)
1374 rectfive:removeEventListener('touch', rectfive)
1375 rectseis:removeEventListener('touch', rectseis)
1376 rectsieb:removeEventListener('touch', rectsieb)
1377
1378 -- Clear viewport
1379 for nIter = 0, 6 do
1380 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1381
1382 function rectfresh:touch(event)
1383 if event.phase == 'began' then
1384 posMove = event.y
1385 local nBase = event.y - (dsh - fontarial.height * 12)
1386 local nRect = fontarial.height * 1.5
1387 local nTemp = nBase / nRect
1388 local nIdx = 7 - math.floor(nTemp)
1389 if dbIdx[nIdx] == 0 then
1390 return
1391 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1392 event.target.color = color.lightGrey
1393 dbMrk[nIdx] = 0
1394 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1395 event.target.color = {192, 192, 192}
1396 dbMrk[nIdx] = 0
1397 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1398 event.target.color = {220, 210, 120}
1399 dbMrk[nIdx] = dbIdx[nIdx]
1400 else
1401 event.target.color = color.khaki
1402 dbMrk[nIdx] = dbIdx[nIdx]
1403 end
1404 end
1405 if event.phase == 'ended' then
1406 if math.abs(event.y - posMove) > fontarial.height*1.5 then
1407 -- Provide callback to count rows in table
1408 local nCount = 0
1409 function countrows(udata, cols, values, names)
1410 assert(udata == 'dingdong')
1411 nCount = tonumber(values[1])
1412 return 0
1413 end
1414
1415 -- Repopulate UI conditionally
1416 debe = sqlite3.open(pathStor .. 'amalog.sql')
1417 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1418 debe:close()
1419 debe = nil
1420
1421 if event.y - posMove > 0 then -- Gesture upward
1422 if nScroll + 7 < nCount then
1423 nScroll = nScroll + 7
1424 else
1425 return
1426 end
1427 else -- Gesture downward
1428 if nScroll - 7 >= 0 then
1429 nScroll = nScroll - 7
1430 else
1431 return
1432 end
1433 end
1434
1435 -- Kludge stucked event handlers
1436 rectoddy:removeEventListener('touch', rectoddy)
1437 recteven:removeEventListener('touch', recteven)
1438 recthree:removeEventListener('touch', recthree)
1439 rectfour:removeEventListener('touch', rectfour)
1440 rectfive:removeEventListener('touch', rectfive)
1441 rectseis:removeEventListener('touch', rectseis)
1442 rectsieb:removeEventListener('touch', rectsieb)
1443
1444 -- Clear viewport
1445 for nIter = 0, 6 do
1446 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1447
1448 function rectfresh:touch(event)
1449 if event.phase == 'began' then
1450 posMove = event.y
1451 local nBase = event.y - (dsh - fontarial.height * 12)
1452 local nRect = fontarial.height * 1.5
1453 local nTemp = nBase / nRect
1454 local nIdx = 7 - math.floor(nTemp)
1455 if dbIdx[nIdx] == 0 then
1456 return
1457 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1458 event.target.color = color.lightGrey
1459 dbMrk[nIdx] = 0
1460 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1461 event.target.color = {192, 192, 192}
1462 dbMrk[nIdx] = 0
1463 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1464 event.target.color = {220, 210, 120}
1465 dbMrk[nIdx] = dbIdx[nIdx]
1466 else
1467 event.target.color = color.khaki
1468 dbMrk[nIdx] = dbIdx[nIdx]
1469 end
1470 end
1471 end
1472 rectfresh:addEventListener('touch', rectfresh)
1473
1474 if nIter % 2 == 0 then
1475 rectfresh.color = color.lightGrey
1476 else
1477 rectfresh.color = {192, 192, 192}
1478 end
1479
1480 -- Clear indexes
1481 dbIdx[nIter+1] = 0
1482 dbMrk[nIter+1] = 0
1483 end
1484
1485 -- Redraw labels
1486 local nIter = 6
1487 --for nIter = 0, 7 do
1488 local nTemp = nCount - nScroll
1489 if nTemp < 7 then
1490 nIter = nTemp - 1
1491 end
1492
1493 debe = sqlite3.open(pathStor .. 'amalog.sql')
1494 for dbRows in debe:nrows('SELECT * FROM qsos') do
1495 if nTemp < 8 then
1496 if nTemp < 0 then break end
1497 if nIter < 0 then break end
1498 local labrepop = director:createLabel({
1499 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1500 hAlignment='left', vAlignment='bottom',
1501 font=fontsegoe,
1502 text=dbRows['call']
1503 })
1504 dbIdx[nIter+1] = dbRows['id']
1505 nIter = nIter - 1
1506 nTemp = nTemp - 1
1507 else
1508 nTemp = nTemp - 1
1509 end
1510 end
1511 debe:close()
1512 debe = nil
1513 end
1514 posMove = 0
1515 end
1516 end
1517 rectfresh:addEventListener('touch', rectfresh)
1518
1519 if nIter % 2 == 0 then
1520 rectfresh.color = color.lightGrey
1521 else
1522 rectfresh.color = {192, 192, 192}
1523 end
1524
1525 -- Clear indexes
1526 dbIdx[nIter+1] = 0
1527 dbMrk[nIter+1] = 0
1528 end
1529
1530 -- Redraw labels
1531 local nIter = 6
1532 --for nIter = 0, 7 do
1533 local nTemp = nCount - nScroll
1534 if nTemp < 7 then
1535 nIter = nTemp - 1
1536 end
1537
1538 debe = sqlite3.open(pathStor .. 'amalog.sql')
1539 for dbRows in debe:nrows('SELECT * FROM qsos') do
1540 if nTemp < 8 then
1541 if nTemp < 0 then break end
1542 if nIter < 0 then break end
1543 local labrepop = director:createLabel({
1544 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1545 hAlignment='left', vAlignment='bottom',
1546 font=fontsegoe,
1547 text=dbRows['call']
1548 })
1549 dbIdx[nIter+1] = dbRows['id']
1550 nIter = nIter - 1
1551 nTemp = nTemp - 1
1552 else
1553 nTemp = nTemp - 1
1554 end
1555 end
1556 debe:close()
1557 debe = nil
1558 end
1559 posMove = 0
1560 end
1561 end
1562 rectseis:addEventListener('touch', rectseis)
1563
1564 function rectsieb:touch(event)
1565 if event.phase == 'began' then
1566 posMove = event.y
1567 local nBase = event.y - (dsh - fontarial.height * 12)
1568 local nRect = fontarial.height * 1.5
1569 local nTemp = nBase / nRect
1570 local nIdx = 7 - math.floor(nTemp)
1571 if dbIdx[nIdx] == 0 then
1572 return
1573 elseif rectsieb.color.r == 240 and rectsieb.color.g == 230 and rectsieb.color.b == 140 then
1574 rectsieb.color = color.lightGrey
1575 dbMrk[nIdx] = 0
1576 else
1577 rectsieb.color = color.khaki
1578 dbMrk[nIdx] = dbIdx[nIdx]
1579 end
1580 end
1581
1582 if event.phase == 'ended' then
1583 if math.abs(event.y - posMove) > fontarial.height*1.5 then
1584 -- Provide callback to count rows in table
1585 local nCount = 0
1586 function countrows(udata, cols, values, names)
1587 assert(udata == 'dingdong')
1588 nCount = tonumber(values[1])
1589 return 0
1590 end
1591
1592 -- Repopulate UI conditionally
1593 debe = sqlite3.open(pathStor .. 'amalog.sql')
1594 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1595 debe:close()
1596 debe = nil
1597
1598 if event.y - posMove > 0 then -- Gesture upward
1599 if nScroll + 7 < nCount then
1600 nScroll = nScroll + 7
1601 else
1602 return
1603 end
1604 else -- Gesture downward
1605 if nScroll - 7 >= 0 then
1606 nScroll = nScroll - 7
1607 else
1608 return
1609 end
1610 end
1611
1612 -- Kludge stucked event handlers
1613 rectoddy:removeEventListener('touch', rectoddy)
1614 recteven:removeEventListener('touch', recteven)
1615 recthree:removeEventListener('touch', recthree)
1616 rectfour:removeEventListener('touch', rectfour)
1617 rectfive:removeEventListener('touch', rectfive)
1618 rectseis:removeEventListener('touch', rectseis)
1619 rectsieb:removeEventListener('touch', rectsieb)
1620
1621 -- Clear viewport
1622 for nIter = 0, 6 do
1623 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1624
1625 function rectfresh:touch(event)
1626 if event.phase == 'began' then
1627 posMove = event.y
1628 local nBase = event.y - (dsh - fontarial.height * 12)
1629 local nRect = fontarial.height * 1.5
1630 local nTemp = nBase / nRect
1631 local nIdx = 7 - math.floor(nTemp)
1632 if dbIdx[nIdx] == 0 then
1633 return
1634 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1635 event.target.color = color.lightGrey
1636 dbMrk[nIdx] = 0
1637 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1638 event.target.color = {192, 192, 192}
1639 dbMrk[nIdx] = 0
1640 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1641 event.target.color = {220, 210, 120}
1642 dbMrk[nIdx] = dbIdx[nIdx]
1643 else
1644 event.target.color = color.khaki
1645 dbMrk[nIdx] = dbIdx[nIdx]
1646 end
1647 end
1648 if event.phase == 'ended' then
1649 if math.abs(event.y - posMove) > fontarial.height*1.5 then
1650 -- Provide callback to count rows in table
1651 local nCount = 0
1652 function countrows(udata, cols, values, names)
1653 assert(udata == 'dingdong')
1654 nCount = tonumber(values[1])
1655 return 0
1656 end
1657
1658 -- Repopulate UI conditionally
1659 debe = sqlite3.open(pathStor .. 'amalog.sql')
1660 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1661 debe:close()
1662 debe = nil
1663
1664 if event.y - posMove > 0 then -- Gesture upward
1665 if nScroll + 7 < nCount then
1666 nScroll = nScroll + 7
1667 else
1668 return
1669 end
1670 else -- Gesture downward
1671 if nScroll - 7 >= 0 then
1672 nScroll = nScroll - 7
1673 else
1674 return
1675 end
1676 end
1677
1678 -- Kludge stucked event handlers
1679 rectoddy:removeEventListener('touch', rectoddy)
1680 recteven:removeEventListener('touch', recteven)
1681 recthree:removeEventListener('touch', recthree)
1682 rectfour:removeEventListener('touch', rectfour)
1683 rectfive:removeEventListener('touch', rectfive)
1684 rectseis:removeEventListener('touch', rectseis)
1685 rectsieb:removeEventListener('touch', rectsieb)
1686
1687 -- Clear viewport
1688 for nIter = 0, 6 do
1689 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1690
1691 function rectfresh:touch(event)
1692 if event.phase == 'began' then
1693 posMove = event.y
1694 local nBase = event.y - (dsh - fontarial.height * 12)
1695 local nRect = fontarial.height * 1.5
1696 local nTemp = nBase / nRect
1697 local nIdx = 7 - math.floor(nTemp)
1698 if dbIdx[nIdx] == 0 then
1699 return
1700 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1701 event.target.color = color.lightGrey
1702 dbMrk[nIdx] = 0
1703 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1704 event.target.color = {192, 192, 192}
1705 dbMrk[nIdx] = 0
1706 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1707 event.target.color = {220, 210, 120}
1708 dbMrk[nIdx] = dbIdx[nIdx]
1709 else
1710 event.target.color = color.khaki
1711 dbMrk[nIdx] = dbIdx[nIdx]
1712 end
1713 end
1714 end
1715 rectfresh:addEventListener('touch', rectfresh)
1716
1717 if nIter % 2 == 0 then
1718 rectfresh.color = color.lightGrey
1719 else
1720 rectfresh.color = {192, 192, 192}
1721 end
1722
1723 -- Clear indexes
1724 dbIdx[nIter+1] = 0
1725 dbMrk[nIter+1] = 0
1726 end
1727
1728 -- Redraw labels
1729 local nIter = 6
1730 --for nIter = 0, 7 do
1731 local nTemp = nCount - nScroll
1732 if nTemp < 7 then
1733 nIter = nTemp - 1
1734 end
1735
1736 debe = sqlite3.open(pathStor .. 'amalog.sql')
1737 for dbRows in debe:nrows('SELECT * FROM qsos') do
1738 if nTemp < 8 then
1739 if nTemp < 0 then break end
1740 if nIter < 0 then break end
1741 local labrepop = director:createLabel({
1742 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1743 hAlignment='left', vAlignment='bottom',
1744 font=fontsegoe,
1745 text=dbRows['call']
1746 })
1747 dbIdx[nIter+1] = dbRows['id']
1748 nIter = nIter - 1
1749 nTemp = nTemp - 1
1750 else
1751 nTemp = nTemp - 1
1752 end
1753 end
1754 debe:close()
1755 debe = nil
1756 end
1757 posMove = 0
1758 end
1759 end
1760 rectfresh:addEventListener('touch', rectfresh)
1761
1762 if nIter % 2 == 0 then
1763 rectfresh.color = color.lightGrey
1764 else
1765 rectfresh.color = {192, 192, 192}
1766 end
1767
1768 -- Clear indexes
1769 dbIdx[nIter+1] = 0
1770 dbMrk[nIter+1] = 0
1771 end
1772
1773 -- Redraw labels
1774 local nIter = 6
1775 --for nIter = 0, 7 do
1776 local nTemp = nCount - nScroll
1777 if nTemp < 7 then
1778 nIter = nTemp - 1
1779 end
1780
1781 debe = sqlite3.open(pathStor .. 'amalog.sql')
1782 for dbRows in debe:nrows('SELECT * FROM qsos') do
1783 if nTemp < 8 then
1784 if nTemp < 0 then break end
1785 if nIter < 0 then break end
1786 local labrepop = director:createLabel({
1787 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1788 hAlignment='left', vAlignment='bottom',
1789 font=fontsegoe,
1790 text=dbRows['call']
1791 })
1792 dbIdx[nIter+1] = dbRows['id']
1793 nIter = nIter - 1
1794 nTemp = nTemp - 1
1795 else
1796 nTemp = nTemp - 1
1797 end
1798 end
1799 debe:close()
1800 debe = nil
1801 end
1802 posMove = 0
1803 end
1804 end
1805 rectsieb:addEventListener('touch', rectsieb)
1806
1807 -- Provide callback to count rows in table
1808 local nCount = 0
1809 function countrows(udata, cols, values, names)
1810 assert(udata == 'dingdong')
1811 nCount = tonumber(values[1])
1812 return 0
1813 end
1814
1815 -- Populate UI
1816 debe = sqlite3.open(pathStor .. 'amalog.sql')
1817 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1818 local nTemp = nCount
1819 local nIter = 6; --for nIter = 0, 7 do
1820 if nTemp < 7 then
1821 nIter = nTemp - 1
1822 end
1823
1824 for dbRows in debe:nrows('SELECT * FROM qsos') do
1825 if nTemp < 8 then
1826 if nIter < 0 then break end
1827 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1828
1829 function rectfresh:touch(event)
1830 if event.phase == 'began' then
1831 posMove = event.y
1832 if event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1833 event.target.color = color.lightGrey
1834 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1835 event.target.color = {192, 192, 192}
1836 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1837 event.target.color = {220, 210, 120}
1838 else
1839 event.target.color = color.khaki
1840 end
1841 end
1842 end
1843 rectfresh:addEventListener('touch', rectfresh)
1844
1845 if nIter % 2 == 0 then
1846 rectfresh.color = color.lightGrey
1847 else
1848 rectfresh.color = {192, 192, 192}
1849 end
1850
1851 local labpopo = director:createLabel({
1852 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1853 hAlignment='left', vAlignment='bottom',
1854 font=fontsegoe,
1855 text=dbRows['call']
1856 })
1857 dbIdx[nIter+1] = dbRows['id']
1858 nIter = nIter - 1
1859 nTemp = nTemp - 1
1860 else
1861 nTemp = nTemp - 1
1862 end
1863 end
1864 debe:close()
1865 debe = nil
1866
1867 local butdel = director:createSprite(0, 0, 'images/buttdel1.png')
1868 local butadd = director:createSprite(0, 0, 'images/buttadd.png')
1869
1870 butdel.color = color.white
1871 butdel.x = (dsw - butdel.w - butadd.w) / 3
1872 butdel.y = (dsh-fontarial.height*12)/2
1873 butdel.xAnchor = 0
1874 butdel.yAnchor = 0.5
1875 --butdel.xScale = 5
1876 --butdel.yScale = 1.25
1877
1878 butadd.color = color.white
1879 butadd.x = dsw-dsw/8
1880 butadd.x = dsw - (dsw - butdel.w - butadd.w) / 3
1881 butadd.y = (dsh-fontarial.height*12)/2
1882 butadd.xAnchor = 1
1883 butadd.yAnchor = 0.5
1884
1885 -- Good transitions: slideInL/R, shrinkGrow, crossFade, fadeTR/BL, pageTurn, progressVertical
1886 --local transoptl = {transitionType = 'progressHorizontal', transitionTime = 0.5}
1887 local transoptr = {transitionType = 'slideInR', transitionTime = 0.5}
1888
1889 function butabout:touch(event)
1890 if event.phase == 'began' then
1891 director:moveToScene(sceneAbout, transoptr)
1892 end
1893 end
1894 butabout:addEventListener('touch', butabout)
1895
1896 function buthelp:touch(event)
1897 if event.phase == 'began' then
1898 director:moveToScene(sceneHelp, transoptr)
1899 end
1900 end
1901 buthelp:addEventListener('touch', buthelp)
1902
1903 -- String reader events handler
1904 function gotString(event)
1905 if (event.type == 'error') then
1906 dbg.print('Error reading string: ' .. event.text)
1907 elseif (event.type == 'read') then
1908 dbg.print('String read: ' .. event.text)
1909 end
1910 end
1911
1912 function butadd:touch(event)
1913 if (event.phase == 'began') then
1914 -- Ensure that the string reading extension is available
1915 if nui:isReadStringAvailable() then
1916 -- Add a string reader event handler
1917 system:addEventListener('stringread', gotString)
1918
1919 -- Create the string reader
1920 widginput = nui:readString('New QSO Entry', '', 'Call Sign, QTH, Notes...')
1921 if widginput then
1922 debe = sqlite3.open(pathStor .. 'amalog.sql')
1923 debe:exec('INSERT INTO qsos VALUES(NULL, \'' .. widginput .. '\')')
1924 --debe:exec[=[
1925 -- INSERT INTO qsos VALUES(NULL, widginput);
1926 --]=]
1927 debe:close()
1928 debe = nil
1929
1930 -- Provide callback to count rows in table
1931 local nCount = 0
1932 function countrows(udata, cols, values, names)
1933 assert(udata == 'dingdong')
1934 nCount = tonumber(values[1])
1935 return 0
1936 end
1937
1938 -- Repopulate UI
1939 debe = sqlite3.open(pathStor .. 'amalog.sql')
1940 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
1941 local nIter = 6
1942 --for nIter = 0, 7 do
1943 local nTemp = nCount
1944 if nTemp < 7 then
1945 nIter = nTemp - 1
1946 end
1947
1948 for dbRows in debe:nrows('SELECT * FROM qsos') do
1949 if nTemp < 8 then
1950 if nIter < 0 then break end
1951 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
1952
1953 function rectfresh:touch(event)
1954 if event.phase == 'began' then
1955 if event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
1956 event.target.color = color.lightGrey
1957 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
1958 event.target.color = {192, 192, 192}
1959 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
1960 event.target.color = {220, 210, 120}
1961 else
1962 event.target.color = color.khaki
1963 end
1964 end
1965 end
1966 rectfresh:addEventListener('touch', rectfresh)
1967
1968 if nIter % 2 == 0 then
1969 rectfresh.color = color.lightGrey
1970 else
1971 rectfresh.color = {192, 192, 192}
1972 end
1973
1974 local labrepop = director:createLabel({
1975 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
1976 hAlignment='left', vAlignment='bottom',
1977 font=fontsegoe,
1978 text=dbRows['call']
1979 })
1980 dbIdx[nIter+1] = dbRows['id']
1981 nIter = nIter - 1
1982 nTemp = nTemp - 1
1983 else
1984 nTemp = nTemp - 1
1985 end
1986 end
1987 debe:close()
1988 debe = nil
1989 end
1990 else
1991 dbg.print('String reading is not supported on this platform')
1992 end
1993 end
1994
1995 if event.phase == 'ended' then
1996 if math.abs(event.y - posMove) > fontarial.height*1.5 then
1997 -- Provide callback to count rows in table
1998 local nCount = 0
1999 function countrows(udata, cols, values, names)
2000 assert(udata == 'dingdong')
2001 nCount = tonumber(values[1])
2002 return 0
2003 end
2004
2005 -- Repopulate UI conditionally
2006 debe = sqlite3.open(pathStor .. 'amalog.sql')
2007 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
2008 debe:close()
2009 debe = nil
2010
2011 if event.y - posMove > 0 then -- Gesture upward
2012 if nScroll + 7 < nCount then
2013 nScroll = nScroll + 7
2014 else
2015 return
2016 end
2017 else -- Gesture downward
2018 if nScroll - 7 >= 0 then
2019 nScroll = nScroll - 7
2020 else
2021 return
2022 end
2023 end
2024
2025 -- Kludge stucked event handlers
2026 rectoddy:removeEventListener('touch', rectoddy)
2027 recteven:removeEventListener('touch', recteven)
2028 recthree:removeEventListener('touch', recthree)
2029 rectfour:removeEventListener('touch', rectfour)
2030 rectfive:removeEventListener('touch', rectfive)
2031 rectseis:removeEventListener('touch', rectseis)
2032 rectsieb:removeEventListener('touch', rectsieb)
2033
2034 -- Clear viewport
2035 for nIter = 0, 6 do
2036 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
2037
2038 function rectfresh:touch(event)
2039 if event.phase == 'began' then
2040 posMove = event.y
2041 local nBase = event.y - (dsh - fontarial.height * 12)
2042 local nRect = fontarial.height * 1.5
2043 local nTemp = nBase / nRect
2044 local nIdx = 7 - math.floor(nTemp)
2045 if dbIdx[nIdx] == 0 then
2046 return
2047 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
2048 event.target.color = color.lightGrey
2049 dbMrk[nIdx] = 0
2050 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
2051 event.target.color = {192, 192, 192}
2052 dbMrk[nIdx] = 0
2053 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
2054 event.target.color = {220, 210, 120}
2055 dbMrk[nIdx] = dbIdx[nIdx]
2056 else
2057 event.target.color = color.khaki
2058 dbMrk[nIdx] = dbIdx[nIdx]
2059 end
2060 end
2061 if event.phase == 'ended' then
2062 if math.abs(event.y - posMove) > fontarial.height*1.5 then
2063 -- Provide callback to count rows in table
2064 local nCount = 0
2065 function countrows(udata, cols, values, names)
2066 assert(udata == 'dingdong')
2067 nCount = tonumber(values[1])
2068 return 0
2069 end
2070
2071 -- Repopulate UI conditionally
2072 debe = sqlite3.open(pathStor .. 'amalog.sql')
2073 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
2074 debe:close()
2075 debe = nil
2076
2077 if event.y - posMove > 0 then -- Gesture upward
2078 if nScroll + 7 < nCount then
2079 nScroll = nScroll + 7
2080 else
2081 return
2082 end
2083 else -- Gesture downward
2084 if nScroll - 7 >= 0 then
2085 nScroll = nScroll - 7
2086 else
2087 return
2088 end
2089 end
2090
2091 -- Kludge stucked event handlers
2092 rectoddy:removeEventListener('touch', rectoddy)
2093 recteven:removeEventListener('touch', recteven)
2094 recthree:removeEventListener('touch', recthree)
2095 rectfour:removeEventListener('touch', rectfour)
2096 rectfive:removeEventListener('touch', rectfive)
2097 rectseis:removeEventListener('touch', rectseis)
2098 rectsieb:removeEventListener('touch', rectsieb)
2099
2100 -- Clear viewport
2101 for nIter = 0, 6 do
2102 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
2103
2104 function rectfresh:touch(event)
2105 if event.phase == 'began' then
2106 posMove = event.y
2107 local nBase = event.y - (dsh - fontarial.height * 12)
2108 local nRect = fontarial.height * 1.5
2109 local nTemp = nBase / nRect
2110 local nIdx = 7 - math.floor(nTemp)
2111 if dbIdx[nIdx] == 0 then
2112 return
2113 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
2114 event.target.color = color.lightGrey
2115 dbMrk[nIdx] = 0
2116 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
2117 event.target.color = {192, 192, 192}
2118 dbMrk[nIdx] = 0
2119 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
2120 event.target.color = {220, 210, 120}
2121 dbMrk[nIdx] = dbIdx[nIdx]
2122 else
2123 event.target.color = color.khaki
2124 dbMrk[nIdx] = dbIdx[nIdx]
2125 end
2126 end
2127 end
2128 rectfresh:addEventListener('touch', rectfresh)
2129
2130 if nIter % 2 == 0 then
2131 rectfresh.color = color.lightGrey
2132 else
2133 rectfresh.color = {192, 192, 192}
2134 end
2135
2136 -- Clear indexes
2137 dbIdx[nIter+1] = 0
2138 dbMrk[nIter+1] = 0
2139 end
2140
2141 -- Redraw labels
2142 local nIter = 6
2143 --for nIter = 0, 7 do
2144 local nTemp = nCount - nScroll
2145 if nTemp < 7 then
2146 nIter = nTemp - 1
2147 end
2148
2149 debe = sqlite3.open(pathStor .. 'amalog.sql')
2150 for dbRows in debe:nrows('SELECT * FROM qsos') do
2151 if nTemp < 8 then
2152 if nTemp < 0 then break end
2153 if nIter < 0 then break end
2154 local labrepop = director:createLabel({
2155 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
2156 hAlignment='left', vAlignment='bottom',
2157 font=fontsegoe,
2158 text=dbRows['call']
2159 })
2160 dbIdx[nIter+1] = dbRows['id']
2161 nIter = nIter - 1
2162 nTemp = nTemp - 1
2163 else
2164 nTemp = nTemp - 1
2165 end
2166 end
2167 debe:close()
2168 debe = nil
2169 end
2170 posMove = 0
2171 end
2172 end
2173 rectfresh:addEventListener('touch', rectfresh)
2174
2175 if nIter % 2 == 0 then
2176 rectfresh.color = color.lightGrey
2177 else
2178 rectfresh.color = {192, 192, 192}
2179 end
2180
2181 -- Clear indexes
2182 dbIdx[nIter+1] = 0
2183 dbMrk[nIter+1] = 0
2184 end
2185
2186 -- Redraw labels
2187 local nIter = 6
2188 --for nIter = 0, 7 do
2189 local nTemp = nCount - nScroll
2190 if nTemp < 7 then
2191 nIter = nTemp - 1
2192 end
2193
2194 debe = sqlite3.open(pathStor .. 'amalog.sql')
2195 for dbRows in debe:nrows('SELECT * FROM qsos') do
2196 if nTemp < 8 then
2197 if nTemp < 0 then break end
2198 if nIter < 0 then break end
2199 local labrepop = director:createLabel({
2200 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
2201 hAlignment='left', vAlignment='bottom',
2202 font=fontsegoe,
2203 text=dbRows['call']
2204 })
2205 dbIdx[nIter+1] = dbRows['id']
2206 nIter = nIter - 1
2207 nTemp = nTemp - 1
2208 else
2209 nTemp = nTemp - 1
2210 end
2211 end
2212 debe:close()
2213 debe = nil
2214 end
2215 posMove = 0
2216 end
2217 end
2218 butadd:addEventListener('touch', butadd)
2219
2220 function butdel:touch(event)
2221 if (event.phase == 'began') then
2222 -- Provide callback to count rows in table
2223 local nCount = 0
2224 function countrows(udata, cols, values, names)
2225 assert(udata == 'dingdong')
2226 nCount = tonumber(values[1])
2227 return 0
2228 end
2229
2230 -- Iterate over visible rows, deleting
2231 debe = sqlite3.open(pathStor .. 'amalog.sql')
2232 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
2233 local nTemp = nCount
2234 local nIter = 0; --for nIter = 0, 7 do
2235
2236 for dbRows in debe:nrows('SELECT * FROM qsos') do
2237 if nTemp < 8 then
2238 if nIter > 6 then break end
2239 if dbMrk[nIter+1] ~= 0 then
2240 debe:exec('DELETE FROM qsos WHERE id = \'' .. dbRows['id'] .. '\'')
2241 end
2242 nIter = nIter + 1
2243 nTemp = nTemp - 1
2244 else
2245 nTemp = nTemp - 1
2246 end
2247 end
2248 debe:close()
2249 debe = nil
2250
2251 -- Kludge stucked event handlers
2252 rectoddy:removeEventListener('touch', rectoddy)
2253 recteven:removeEventListener('touch', recteven)
2254 recthree:removeEventListener('touch', recthree)
2255 rectfour:removeEventListener('touch', rectfour)
2256 rectfive:removeEventListener('touch', rectfive)
2257 rectseis:removeEventListener('touch', rectseis)
2258 rectsieb:removeEventListener('touch', rectsieb)
2259
2260 -- Clear viewport
2261 for nIter = 0, 6 do
2262 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
2263
2264 function rectfresh:touch(event)
2265 if event.phase == 'began' then
2266 local nBase = event.y - (dsh - fontarial.height * 12)
2267 local nRect = fontarial.height * 1.5
2268 local nTemp = nBase / nRect
2269 local nIdx = 7 - math.floor(nTemp)
2270 if dbIdx[nIdx] == 0 then
2271 return
2272 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
2273 event.target.color = color.lightGrey
2274 dbMrk[nIdx] = 0
2275 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
2276 event.target.color = {192, 192, 192}
2277 dbMrk[nIdx] = 0
2278 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
2279 event.target.color = {220, 210, 120}
2280 dbMrk[nIdx] = dbIdx[nIdx]
2281 else
2282 event.target.color = color.khaki
2283 dbMrk[nIdx] = dbIdx[nIdx]
2284 end
2285 end
2286 end
2287 rectfresh:addEventListener('touch', rectfresh)
2288
2289 if nIter % 2 == 0 then
2290 rectfresh.color = color.lightGrey
2291 else
2292 rectfresh.color = {192, 192, 192}
2293 end
2294
2295 -- Clear indexes
2296 dbIdx[nIter+1] = 0
2297 dbMrk[nIter+1] = 0
2298 end
2299
2300 -- Repopulate UI
2301 debe = sqlite3.open(pathStor .. 'amalog.sql')
2302 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
2303 local nIter = 6
2304 --for nIter = 0, 7 do
2305 local nTemp = nCount
2306 if nTemp < 7 then
2307 nIter = nTemp - 1
2308 end
2309
2310 for dbRows in debe:nrows('SELECT * FROM qsos') do
2311 if nTemp < 8 then
2312 if nIter < 0 then break end
2313 local labrepop = director:createLabel({
2314 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
2315 hAlignment='left', vAlignment='bottom',
2316 font=fontsegoe,
2317 text=dbRows['call']
2318 })
2319 dbIdx[nIter+1] = dbRows['id']
2320 nIter = nIter - 1
2321 nTemp = nTemp - 1
2322 else
2323 nTemp = nTemp - 1
2324 end
2325 end
2326 debe:close()
2327 debe = nil
2328 end
2329
2330 if event.phase == 'ended' then
2331 if math.abs(event.y - posMove) > fontarial.height*1.5 then
2332 -- Provide callback to count rows in table
2333 local nCount = 0
2334 function countrows(udata, cols, values, names)
2335 assert(udata == 'dingdong')
2336 nCount = tonumber(values[1])
2337 return 0
2338 end
2339
2340 -- Repopulate UI conditionally
2341 debe = sqlite3.open(pathStor .. 'amalog.sql')
2342 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
2343 debe:close()
2344 debe = nil
2345
2346 if event.y - posMove > 0 then -- Gesture upward
2347 if nScroll + 7 < nCount then
2348 nScroll = nScroll + 7
2349 else
2350 return
2351 end
2352 else -- Gesture downward
2353 if nScroll - 7 >= 0 then
2354 nScroll = nScroll - 7
2355 else
2356 return
2357 end
2358 end
2359
2360 -- Kludge stucked event handlers
2361 rectoddy:removeEventListener('touch', rectoddy)
2362 recteven:removeEventListener('touch', recteven)
2363 recthree:removeEventListener('touch', recthree)
2364 rectfour:removeEventListener('touch', rectfour)
2365 rectfive:removeEventListener('touch', rectfive)
2366 rectseis:removeEventListener('touch', rectseis)
2367 rectsieb:removeEventListener('touch', rectsieb)
2368
2369 -- Clear viewport
2370 for nIter = 0, 6 do
2371 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
2372
2373 function rectfresh:touch(event)
2374 if event.phase == 'began' then
2375 posMove = event.y
2376 local nBase = event.y - (dsh - fontarial.height * 12)
2377 local nRect = fontarial.height * 1.5
2378 local nTemp = nBase / nRect
2379 local nIdx = 7 - math.floor(nTemp)
2380 if dbIdx[nIdx] == 0 then
2381 return
2382 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
2383 event.target.color = color.lightGrey
2384 dbMrk[nIdx] = 0
2385 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
2386 event.target.color = {192, 192, 192}
2387 dbMrk[nIdx] = 0
2388 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
2389 event.target.color = {220, 210, 120}
2390 dbMrk[nIdx] = dbIdx[nIdx]
2391 else
2392 event.target.color = color.khaki
2393 dbMrk[nIdx] = dbIdx[nIdx]
2394 end
2395 end
2396 if event.phase == 'ended' then
2397 if math.abs(event.y - posMove) > fontarial.height*1.5 then
2398 -- Provide callback to count rows in table
2399 local nCount = 0
2400 function countrows(udata, cols, values, names)
2401 assert(udata == 'dingdong')
2402 nCount = tonumber(values[1])
2403 return 0
2404 end
2405
2406 -- Repopulate UI conditionally
2407 debe = sqlite3.open(pathStor .. 'amalog.sql')
2408 local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
2409 debe:close()
2410 debe = nil
2411
2412 if event.y - posMove > 0 then -- Gesture upward
2413 if nScroll + 7 < nCount then
2414 nScroll = nScroll + 7
2415 else
2416 return
2417 end
2418 else -- Gesture downward
2419 if nScroll - 7 >= 0 then
2420 nScroll = nScroll - 7
2421 else
2422 return
2423 end
2424 end
2425
2426 -- Kludge stucked event handlers
2427 rectoddy:removeEventListener('touch', rectoddy)
2428 recteven:removeEventListener('touch', recteven)
2429 recthree:removeEventListener('touch', recthree)
2430 rectfour:removeEventListener('touch', rectfour)
2431 rectfive:removeEventListener('touch', rectfive)
2432 rectseis:removeEventListener('touch', rectseis)
2433 rectsieb:removeEventListener('touch', rectsieb)
2434
2435 -- Clear viewport
2436 for nIter = 0, 6 do
2437 local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
2438
2439 function rectfresh:touch(event)
2440 if event.phase == 'began' then
2441 posMove = event.y
2442 local nBase = event.y - (dsh - fontarial.height * 12)
2443 local nRect = fontarial.height * 1.5
2444 local nTemp = nBase / nRect
2445 local nIdx = 7 - math.floor(nTemp)
2446 if dbIdx[nIdx] == 0 then
2447 return
2448 elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
2449 event.target.color = color.lightGrey
2450 dbMrk[nIdx] = 0
2451 elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
2452 event.target.color = {192, 192, 192}
2453 dbMrk[nIdx] = 0
2454 elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
2455 event.target.color = {220, 210, 120}
2456 dbMrk[nIdx] = dbIdx[nIdx]
2457 else
2458 event.target.color = color.khaki
2459 dbMrk[nIdx] = dbIdx[nIdx]
2460 end
2461 end
2462 end
2463 rectfresh:addEventListener('touch', rectfresh)
2464
2465 if nIter % 2 == 0 then
2466 rectfresh.color = color.lightGrey
2467 else
2468 rectfresh.color = {192, 192, 192}
2469 end
2470
2471 -- Clear indexes
2472 dbIdx[nIter+1] = 0
2473 dbMrk[nIter+1] = 0
2474 end
2475
2476 -- Redraw labels
2477 local nIter = 6
2478 --for nIter = 0, 7 do
2479 local nTemp = nCount - nScroll
2480 if nTemp < 7 then
2481 nIter = nTemp - 1
2482 end
2483
2484 debe = sqlite3.open(pathStor .. 'amalog.sql')
2485 for dbRows in debe:nrows('SELECT * FROM qsos') do
2486 if nTemp < 8 then
2487 if nTemp < 0 then break end
2488 if nIter < 0 then break end
2489 local labrepop = director:createLabel({
2490 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
2491 hAlignment='left', vAlignment='bottom',
2492 font=fontsegoe,
2493 text=dbRows['call']
2494 })
2495 dbIdx[nIter+1] = dbRows['id']
2496 nIter = nIter - 1
2497 nTemp = nTemp - 1
2498 else
2499 nTemp = nTemp - 1
2500 end
2501 end
2502 debe:close()
2503 debe = nil
2504 end
2505 posMove = 0
2506 end
2507 end
2508 rectfresh:addEventListener('touch', rectfresh)
2509
2510 if nIter % 2 == 0 then
2511 rectfresh.color = color.lightGrey
2512 else
2513 rectfresh.color = {192, 192, 192}
2514 end
2515
2516 -- Clear indexes
2517 dbIdx[nIter+1] = 0
2518 dbMrk[nIter+1] = 0
2519 end
2520
2521 -- Redraw labels
2522 local nIter = 6
2523 --for nIter = 0, 7 do
2524 local nTemp = nCount - nScroll
2525 if nTemp < 7 then
2526 nIter = nTemp - 1
2527 end
2528
2529 debe = sqlite3.open(pathStor .. 'amalog.sql')
2530 for dbRows in debe:nrows('SELECT * FROM qsos') do
2531 if nTemp < 8 then
2532 if nTemp < 0 then break end
2533 if nIter < 0 then break end
2534 local labrepop = director:createLabel({
2535 x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
2536 hAlignment='left', vAlignment='bottom',
2537 font=fontsegoe,
2538 text=dbRows['call']
2539 })
2540 dbIdx[nIter+1] = dbRows['id']
2541 nIter = nIter - 1
2542 nTemp = nTemp - 1
2543 else
2544 nTemp = nTemp - 1
2545 end
2546 end
2547 debe:close()
2548 debe = nil
2549 end
2550 posMove = 0
2551 end
2552 end
2553 butdel:addEventListener('touch', butdel)
2554 end
2555
2556 function sceneloc:tearDown(event)
2557 dbg.print('sceneloc:tearDown')
2558 --rectfresh:removeEventListener('touch', rectfresh)
2559 rectoddy:removeEventListener('touch', rectoddy)
2560 recteven:removeEventListener('touch', recteven)
2561 recthree:removeEventListener('touch', recthree)
2562 rectfour:removeEventListener('touch', rectfour)
2563 rectfive:removeEventListener('touch', rectfive)
2564 rectseis:removeEventListener('touch', rectseis)
2565 rectsieb:removeEventListener('touch', rectsieb)
2566 --self.obj0:removeFromParent()
2567 --self.obj1:removeFromParent()
2568 --self.obj0 = nil
2569 --self.obj1 = nil
2570 end
2571 function sceneloc:enterPreTransition(event)
2572 dbg.print('sceneloc:enterPreTransition')
2573 end
2574 function sceneloc:enterPostTransition(event)
2575 dbg.print('sceneloc:enterPostTransition')
2576 end
2577 function sceneloc:exitPreTransition(event)
2578 dbg.print('sceneloc:exitPreTransition')
2579 end
2580 function sceneloc:exitPostTransition(event)
2581 dbg.print('sceneloc:exitPostTransition')
2582 end
2583
2584 sceneloc:addEventListener({'setUp', 'tearDown', 'enterPreTransition',
2585 'enterPostTransition', 'exitPreTransition', 'exitPostTransition'}, sceneloc)
2586
2587 return sceneloc

mercurial