resources/scenemain.lua

Wed, 31 Jul 2013 19:28:00 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Jul 2013 19:28:00 +0200
changeset 0
7ff85f7ce3a7
permissions
-rw-r--r--

Flush prograss with initial commit.

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

mercurial