Subversion Repositories Kolibri OS

Rev

Rev 5905 | Rev 5907 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5394 eAndrew 1
DEBUG equ 0
2
 
3
    LIST_WIDTH equ 256
4
    WIN_WIDTH equ (LIST_WIDTH + 16 + 12)
5
    LIST_SIZE equ 12
6
    LINE_SIZE equ 40
7
    LIST_HEIGHT equ (LIST_SIZE * LINE_SIZE / 2)
8
    WIN_HEIGHT equ (LIST_HEIGHT + 80)
9
 
10
    use32
11
    org     0
12
    db	    'MENUET01'
13
    dd	    1, main, dataend, memory, memory, params, 0
14
 
15
    include "../../proc32.inc"
16
    include "../../macros.inc"
17
    include "../../dll.inc"
5903 eAndrew 18
    include "../../cmp.inc"
5394 eAndrew 19
    include "../../string.inc"
20
    include "../../develop/libraries/box_lib/trunk/box_lib.mac"
21
 
22
    include "lang.inc"
23
 
24
if DEBUG eq 1
25
    include "../../debug.inc"
26
end if
27
 
28
 ;===============================
29
 
30
if lang eq ru
31
 title db "Открыть с помощью", 0
32
 browse_txt db "Обзор...", 0
33
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
34
 checkbox_txt db "Использовать всегда", 0
35
else if lang eq et
36
 title db "Open with", 0
37
 browse_txt db "Browse...", 0
38
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
39
 checkbox_txt db "Always use selected program", 0
40
else if lang eq it
41
 title db "Open with", 0
42
 browse_txt db "Browse...", 0
43
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
44
 checkbox_txt db "Always use selected program", 0
45
else
46
 title db "Open with", 0
47
 browse_txt db "Browse...", 0
48
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
49
 checkbox_txt db "Always use selected program", 0
50
end if
51
 
52
 sys_dir db "/sys", 0
53
 slash db "/", 0
54
 open_dialog_path db "/sys/file managers/opendial", 0
55
 app_link db "$", 0
5426 yogev_ezra 56
 icons db "/sys/icons32.png", 0
5394 eAndrew 57
 communication_area_name db "FFFFFF_open_dialog", 0
58
 assoc_ini db "/sys/settings/assoc.ini", 0
59
  .sec db "Assoc", 0
60
  .exec db "exec", 0
61
  .icon db "icon", 0
62
 
63
 sb_apps scrollbar \
64
  13, WIN_WIDTH - 25, LIST_HEIGHT, 10 + 12, \  ;; w, x, h, y
65
  0, 0, LIST_SIZE / 2, 0, \		       ;; b.h, max, area, pos
66
  0, 0, 0, 2
67
 
68
 cb_always check_box2 \
5488 leency 69
  5 shl 16 + 16, (LIST_HEIGHT + 33) shl 16 + 16, 6, 0, 0, 0, checkbox_txt, ch_flag_middle
5394 eAndrew 70
 
71
 opendialog:
72
  .type dd 0
73
  .procinfo dd buffer3
74
  .com_area_name dd communication_area_name
75
  .com_area dd 0
76
  .opendir_path dd buffer4
77
  .dir_default_path dd sys_dir
78
  .start_path dd open_dialog_path
79
  .draw_window dd draw_window
80
  .status dd 0
81
  .openfile_pach dd buffer
82
  .filename_area dd buffer5
83
  .filter_area dd .filter
84
  .x:
85
  .x_size dw 420
86
  .x_start dw 200
87
  .y:
88
  .y_size dw 320
89
  .y_start dw 120
90
 
91
 .filter dd 0
92
 
93
 ps_addres:
94
  dd 0		;; type
95
  dw 7		;; y
96
  dw 4		;; x
97
  dw 6		;; font.w
98
  dw LIST_WIDTH ;; w
99
  dd 0		;; mono
100
  dd 0		;; without bg
101
  .color dd 0	;; text color
102
  dd 0		;; bg color
103
  .txt dd 0	;; text
104
  dd buffer2
105
  dd 0
106
 
107
 is_execute:
108
  dd 7, 0, 0, 0, 0
109
  db 0
110
  dd buffer
111
 
112
 is_openas:
113
  dd 7, 0, 0, 0, 0
114
  db 0
115
  dd buffer
116
 
117
 is_open:
118
  dd 7, 0, 0, 0, 0
119
  db 0
120
  dd buffer
121
 
122
 is_undefined:
123
  dd 7, 0, notify_txt, 0, 0
124
  db "/sys/@notify", 0
125
 
126
 is_openimg_info:
127
  dd 5, 0, 0, 0, img.buf
128
  db 0
129
  dd icons
130
 
131
 is_openimg:
132
  dd 0, 0, 0, 0, 0
133
  db 0
134
  dd icons
135
 
5903 eAndrew 136
 is_file_exists:
137
  dd 0, 0, 0, 0, buffer6
138
  db 0
139
  dd buffer
140
 
5394 eAndrew 141
  last_x dd -1
142
  last_y dd -1
143
 
144
if DEBUG eq 1
5903 eAndrew 145
    std_param db "~/sys/example.asm", 0
5394 eAndrew 146
end if
147
 
148
 imports:
149
    library libini, "libini.obj"
150
    import  libini, libini.get_str, "ini_get_str", \
151
		    libini.set_str, "ini_set_str", \
152
		    libini.get_num, "ini_get_int", \
153
		    libini.for_each_section, "ini_enum_sections"
154
 
155
 imports_add:
156
    library libimg, "libimg.obj", \
157
	    boxlib, "box_lib.obj", \
158
	    prclib, "proc_lib.obj"
159
    import  libimg, libimg.init, "lib_init", \
160
		    libimg.toRGB, "img_to_rgb2", \
161
		    libimg.decode, "img_decode", \
162
		    libimg.destroy, "img_destroy"
163
    import  boxlib, scrollbar.draw, "scrollbar_v_draw", \
164
		    scrollbar.mouse, "scrollbar_v_mouse", \
165
		    pathshow.init, "PathShow_prepare", \
166
		    pathshow.draw, "PathShow_draw", \
167
		    checkbox.init, "init_checkbox2", \
168
		    checkbox.draw, "check_box_draw2", \
169
		    checkbox.mouse, "check_box_mouse2"
170
    import  prclib, opendialog.lib_init, "lib_init", \
171
		    opendialog.init, "OpenDialog_init", \
172
		    opendialog.start, "OpenDialog_start"
173
 
174
 ;===============================
175
 
176
 main:
177
    mcall   68, 11
178
    stdcall dll.Load, imports
179
 
180
if DEBUG eq 1
181
    stdcall string.copy, std_param, params
182
end if
183
 
184
 ;; trim params
5516 leency 185
    stdcall string.to_lower_case, params
5394 eAndrew 186
    stdcall string.trim_last, params
187
    stdcall string.trim_first, params
188
    mov     [param_s], eax
189
 
190
 ;; if empty - exit
191
    cmpe    [eax], byte 0, exit
192
 
193
 ;; if folder
194
    stdcall string.length, [param_s]
195
    add     eax, [param_s]
196
    cmpe    [eax - 1], byte '/', open
197
 
198
 ;; if dialog
199
    mov     eax, [param_s]
200
    mov     [is_openas + 8], eax
201
    cmpne   [eax], byte '~', @f
202
    inc     [param_s]
203
    mov     eax, [param_s]
204
    mov     [is_openas + 8], eax
205
    jmp     start_dialog
206
  @@:
207
 
208
 ;; if without '.' - execute
209
    stdcall string.last_index_of, [param_s], '.', 1
210
    cmpe    eax, -1, execute
211
 
212
 ;; if '.' is part of path - execute
213
    mov     esi, eax
214
    stdcall string.last_index_of, [param_s], '/', 1
215
    cmpg    eax, esi, execute
216
 
217
 ;; if ext == "kex" - execute
218
    add     esi, [param_s]
219
    mov     [param_e], esi
220
    cmpe    [esi], dword "kex", execute
221
 
222
 open_as:
223
    invoke  libini.get_str, assoc_ini, assoc_ini.sec, esi, buffer, 2048, undefined
224
    cmpe    [buffer], byte 0, start_dialog_pre
225
    cmpne   [buffer], byte "$", @f
226
    invoke  libini.get_str, assoc_ini, buffer + 1, assoc_ini.exec, buffer, 2048, undefined
227
    cmpe    [buffer], byte 0, ini_error
228
  @@:
229
    mcall   70, is_openas
230
    jmp     exit
231
 
232
 execute:
233
    mov     eax, [param_s]
234
    mov     [is_execute + 21], eax
235
    mcall   70, is_execute
236
    jmp     exit
237
 
238
 open:
239
    invoke  libini.get_str, assoc_ini, assoc_ini.sec, slash, buffer, 2048, undefined
5903 eAndrew 240
    cmpne   [buffer], byte "$", @f
241
    invoke  libini.get_str, assoc_ini, buffer + 1, assoc_ini.exec, buffer, 2048, undefined
5394 eAndrew 242
    cmpe    [buffer], byte 0, ini_error
5903 eAndrew 243
  @@:
5394 eAndrew 244
    mov     eax, [param_s]
245
    mov     [is_open + 8], eax
246
    mcall   70, is_open
247
    jmp     exit
248
 
249
 ini_error:
250
    mcall   70, is_undefined
251
    jmp     exit
252
 
253
 ;----------------------
254
 
255
 start_dialog_pre:
256
    or	    [cb_always.flags], ch_flag_en
257
 
258
 start_dialog:
259
    stdcall dll.Load, imports_add
260
    invoke  opendialog.lib_init
261
 
262
    mcall   40, 100111b
263
 
264
 ;; get title
265
    stdcall string.copy, title, win.title
266
 
267
 ;; get positions
268
    mcall   14
269
    movzx   ebx, ax
270
    shr     ebx, 1
271
    shr     eax, 16 + 1
272
    sub     eax, WIN_WIDTH / 2 - 1
273
    sub     ebx, WIN_HEIGHT / 2 - 1
274
    mov     [win.x], eax
275
    mov     [win.y], ebx
276
 
277
 ;; get colors
5721 leency 278
    mcall   48, 3, skin, sizeof.system_colors
5394 eAndrew 279
 
280
 ;; get opendialog
281
    invoke  opendialog.init, opendialog
282
 
283
 ;; get pathshow
284
    mov     eax, [param_s]
5721 leency 285
    mov     ebx, [skin.work_text]
5394 eAndrew 286
    mov     [ps_addres.txt], eax
287
    mov     [ps_addres], ebx
288
    invoke  pathshow.init, ps_addres
289
 
290
 ;; get checkbox
5721 leency 291
    mov     eax, 0xFFFfff
292
    mov     ebx, [skin.work_graph]
293
    mov     ecx, [skin.work_text]
5394 eAndrew 294
    mov     [cb_always.color], eax
295
    mov     [cb_always.border_color], ebx
296
    mov     [cb_always.text_color], ecx
297
    invoke  checkbox.init, cb_always
298
 
299
 ;; get list
300
    invoke  libini.for_each_section, assoc_ini, section_cb
301
    mov     eax, [sb_apps.max_area]
302
    and     eax, 1b
303
    shr     [sb_apps.max_area], 1
304
    add     [sb_apps.max_area], eax
305
 
5721 leency 306
    mov     eax, 0xFFFfff
307
    mov     ebx, 0xCCCccc ;[skin.3d]
5394 eAndrew 308
    mov     [sb_apps.bg_color], eax
309
    mov     [sb_apps.front_color], ebx
310
    mov     [sb_apps.line_color], ebx
311
 
312
 ;; get icons
313
    mcall   70, is_openimg_info
314
    mov     edx, dword [img.buf + 32]
315
    shl     edx, 4
316
    stdcall mem.Alloc, edx
317
    mov     [img.rgb], eax
318
 
319
    mov     [is_openimg + 12], edx
320
    m2m     dword[is_openimg + 16], dword[img.rgb]
321
    mcall   70, is_openimg
322
 
323
    invoke  libimg.decode, dword[img.rgb], ebx, 0
324
    mov     [img], eax
325
 
326
  ;; alpha
327
    mov     edi, [eax + 8]
328
    shl     edi, 7
329
    sub     edi, 4
330
    mov     eax, [eax + 24]
331
 .setalpha:
332
    mov     ebx, [eax + edi]
333
    shr     ebx, 24
334
    cmpne   ebx, 0, @f
5721 leency 335
    mov     ecx, 0xFFFfff
5394 eAndrew 336
    mov     [eax + edi], ecx
337
 @@:
338
    cmpe    edi, 0, @f
339
    sub     edi, 4
340
    jmp     .setalpha
341
 @@:
342
 
343
    invoke  libimg.toRGB, [img], [img.rgb]
344
    invoke  libimg.destroy, [img]
345
 
346
 ;----------------------
347
 
348
 update:
349
    mcall   10
350
    cmpe    eax, EV_REDRAW, event_redraw
351
    cmpe    eax, EV_KEY, event_key
352
    cmpe    eax, EV_BUTTON, event_button
353
    cmpe    eax, EV_MOUSE, event_mouse
354
    jmp     update
355
 
356
 ;----------------------
357
 
358
 event_redraw:
359
    call    draw_window
360
    jmp     update
361
 
362
 ;----------------------
363
 
364
 event_key:
365
    mcall   2
366
    cmpe    ah, 27, exit
367
 
5905 eAndrew 368
    cmpe    ah,  13, list_item_activate
5906 eAndrew 369
    cmpe    ah,   9, event_button.opendialog
370
    cmpe    ah,  32, .toggle_cb
5905 eAndrew 371
    cmpe    ah, 179, .go_right
372
    cmpe    ah, 176, .go_left
373
    cmpe    ah, 178, .go_up
374
    cmpe    ah, 177, .go_down
5906 eAndrew 375
 
376
    cmpl    ah, "a", @f
377
    cmpg    ah, "z", @f
378
    jmp     .letter
379
  @@:
380
 
381
    cmpl    ah, "а", @f
382
    cmpg    ah, "я", @f
383
    jmp     .letter
384
  @@:
385
 
386
    cmpl    ah, "A", @f
387
    cmpg    ah, "Z", @f
388
    jmp     .letter_big
389
  @@:
390
 
391
    cmpl    ah, "А", @f
392
    cmpg    ah, "Я", @f
393
    jmp     .letter_big
394
  @@:
395
 
396
    cmpl    ah, "0", @f
397
    cmpg    ah, "9", @f
398
    jmp     .letter
399
  @@:
400
 
5394 eAndrew 401
    jmp     update
402
 
5906 eAndrew 403
 .letter_big:
404
    movzx   ebx, ah
405
    stdcall downcase_char, ebx
406
    mov     ah, al
407
 
408
 .letter:
409
    push    eax
410
 
411
    stdcall get_index
412
    inc     eax
413
 
414
    mov     ecx, eax
415
 
416
    imul    ebx, eax, 32
417
    add     ebx, list
418
 
419
    pop     eax
420
 
421
  @@:
422
    cmpe    byte [ebx], 0, @f
423
 
424
    movzx   edx, byte [ebx]
425
    stdcall downcase_char, edx
426
    cmpne   ah, al, .next
427
    stdcall set_index, ecx
428
    stdcall draw_list
429
    jmp     update
430
 
431
 .next:
432
    inc     ecx
433
    add     ebx, 32
434
    jmp     @b
435
  @@:
436
    jmp     update
437
 
438
 .toggle_cb:
439
    mov     eax, [cb_always.flags]
440
    mov     ebx, eax
441
    and     ebx, ch_flag_en
442
    cmpe    ebx, 0, @f
443
    sub     eax, ch_flag_en
444
    jmp     .toggle_cb.redraw
445
  @@:
446
    add     eax, ch_flag_en
447
 .toggle_cb.redraw:
448
    mov     [cb_always.flags], eax
449
    invoke  checkbox.draw, cb_always
450
    jmp     update
451
 
5905 eAndrew 452
 .go_right:
453
    mov     esi, 1
454
    jmp     .go_anyway
455
 
456
 .go_left:
457
    mov     esi, -1
458
    jmp     .go_anyway
459
 
460
 .go_up:
461
    mov     esi, -2
462
    jmp     .go_anyway
463
 
464
 .go_down:
465
    mov     esi, 2
466
 
467
 .go_anyway:
468
;; HIDE OLD SELECTION
469
    stdcall draw_item, [last_x], [last_y], 0
470
 
471
;; [X, Y] -> INDEX
5906 eAndrew 472
    stdcall get_index
5905 eAndrew 473
 
474
;; CHANGE INDEX
475
    add     eax, esi
476
 
477
    cmpl    eax, [list.size], @f
478
    mov     eax, [list.size]
479
    dec     eax
480
  @@:
481
 
482
    cmpge   eax, 0, @f
483
    mov     eax, 0
484
  @@:
485
 
486
;; INDEX -> [X, Y]
5906 eAndrew 487
    stdcall set_index, eax
488
    cmpe    eax, 1, @f
5905 eAndrew 489
 
5906 eAndrew 490
;; PARTLY REDRAW
5905 eAndrew 491
    stdcall draw_item, [last_x], [last_y], 1
492
    jmp     update
493
 
5906 eAndrew 494
;; FULL REDRAW
5905 eAndrew 495
  @@:
496
    stdcall draw_list
497
    jmp     update
498
 
5394 eAndrew 499
 ;----------------------
500
 
501
 event_button:
502
    mcall   17
503
    cmpe    ah, 1, exit
504
    cmpe    ah, 2, .opendialog
5905 eAndrew 505
    jmp     list_item_activate
5394 eAndrew 506
 
5905 eAndrew 507
 .opendialog:
508
    invoke  opendialog.start, opendialog
509
    cmpne   [opendialog.status], 1, update
5394 eAndrew 510
    mcall   70, is_openas
5905 eAndrew 511
 
512
    mov     edi, 0
513
    jmp     save_assoc
514
 
515
 ;----------------------
516
 
517
 list_item_activate:
5906 eAndrew 518
    stdcall get_index
5905 eAndrew 519
    shl     eax, 5
520
    add     eax, list
521
    cmpe    byte [eax], 0, update
522
    mov     [param_a], eax
523
    invoke  libini.get_str, assoc_ini, eax, assoc_ini.exec, buffer, 256, undefined
524
    cmpe    byte [buffer], 0, ini_error
525
    mcall   70, is_openas
526
 
5394 eAndrew 527
    mov     edi, 1
5905 eAndrew 528
    jmp     save_assoc
5394 eAndrew 529
 
5905 eAndrew 530
 ;----------------------
531
 
532
 save_assoc:
5394 eAndrew 533
    mov     eax, [cb_always.flags]
534
    and     eax, ch_flag_en
535
    cmpe    eax, 0, exit
536
 
537
    cmpe    edi, 0, @f
538
    stdcall string.copy, app_link, buffer
539
    stdcall string.concatenate, [param_a], buffer
540
  @@:
541
 
542
    invoke  libini.set_str, assoc_ini, assoc_ini.sec, [param_e], buffer, 33
543
    jmp     exit
544
 
545
 ;----------------------
546
 
547
 event_mouse:
548
    invoke  checkbox.mouse, cb_always
549
    mov     edi, [sb_apps.position]
550
    invoke  scrollbar.mouse, sb_apps
551
    sub     edi, [sb_apps.position]
552
    jz	    @f
553
    call    draw_list
554
  @@:
555
 
556
    mcall   37, 1
557
    movzx   edi, ax
558
    shr     eax, 16
559
    mov     esi, eax
560
    sub     esi, 4
561
    sub     edi, 10 + 12
562
    cmpl    esi, 0, .out
563
    cmpge   esi, LIST_WIDTH, .out
564
    cmpl    edi, 0, .out
565
    cmpge   edi, LIST_HEIGHT, .out
566
 
567
    mcall   37, 7
568
    and     eax, 0xFFFF
569
    cmpe    eax, 65535, .scroll_up
570
    cmpe    eax, 0, @f
571
 
572
 .scroll_down:
573
    mov     eax, [sb_apps.position]
574
    add     eax, LIST_SIZE / 2
575
    shl     eax, 1
576
    cmpge   eax, [list.size], @f
577
    inc     [sb_apps.position]
578
    stdcall draw_list
579
    jmp     update
580
 
581
 .scroll_up:
582
    cmpe    [sb_apps.position], 0, @f
583
    dec     [sb_apps.position]
584
    stdcall draw_list
585
    jmp     update
586
 
587
  @@:
588
 
589
    mov     eax, esi
590
    mov     ebx, LIST_WIDTH / 2
591
    mov     edx, 0
592
    div     ebx
593
    mov     esi, eax
594
 
595
    mov     eax, edi
596
    mov     ebx, LINE_SIZE
597
    mov     edx, 0
598
    div     ebx
599
    mov     edi, eax
600
 
601
    cmpne   esi, [last_x], .redraw
602
    cmpne   edi, [last_y], .redraw
603
    jmp     @f
604
 
605
 .redraw:
606
    stdcall draw_item, [last_x], [last_y], 0
607
    mov     [last_x], esi
608
    mov     [last_y], edi
609
    stdcall draw_item, esi, edi, 1
610
    jmp     @f
611
 
612
 .out:
613
    cmpe    [last_x], -1, @f
614
    stdcall draw_item, [last_x], [last_y], 0
615
    mov     [last_x], -1
616
    mov     [last_y], -1
617
  @@:
618
 
619
    jmp     update
620
 
621
 ;----------------------
622
 
623
 exit:
624
    mcall   -1
625
 
626
 ;----------------------
627
 
628
 proc draw_window
629
    mcall   12, 1
630
 
5721 leency 631
    mov     edx, [skin.work]
5394 eAndrew 632
    or	    edx, 0x34 shl 24
633
    mcall   0, <[win.x], WIN_WIDTH>, <[win.y], WIN_HEIGHT>, , , win.title
634
    stdcall draw_list
635
    invoke  pathshow.draw, ps_addres
636
    invoke  checkbox.draw, cb_always
637
 
5721 leency 638
    mcall   13, <207, 66>, , [skin.work_graph]
639
    mcall   8, <208, 63>, , 2, [skin.work_button]
5394 eAndrew 640
;
5721 leency 641
    mov     ecx, [skin.work_button_text]
5394 eAndrew 642
    add     ecx, 0x80 shl 24
643
    mcall   4, <214, LIST_HEIGHT + 37>, , browse_txt
644
 
645
 ;; buttons
646
    mov     eax, 8
647
    mov     ebx, 4 shl 16 + LIST_WIDTH / 2
648
    mov     ecx, (10 + 12) shl 16 + LINE_SIZE - 1
649
    mov     edx, 0x60 shl 24 + 10
650
    mov     edi, LIST_SIZE
651
    mov     esi, 0
652
  @@:
653
    cmpe    edi, 0, @f
654
    mcall
655
 
656
    cmpe    esi, 0, .doA
657
 .doB:
658
    sub     ebx, LIST_WIDTH shl 16
659
    add     ecx, LINE_SIZE shl 16
660
 .doA:
661
    add     ebx, (LIST_WIDTH / 2) shl 16
662
    sub     ecx, LINE_SIZE shl 16
663
 
664
    not     esi
665
    add     ecx, LINE_SIZE shl 16
666
    inc     edx
667
    dec     edi
668
    jmp     @b
669
  @@:
670
 
671
    mcall   12, 2
672
    ret
673
  endp
674
 
675
 ;----------------------
676
 
677
 proc draw_list
5721 leency 678
    mcall   13, <3, LIST_WIDTH + 2 + 12>, <9 + 12, 1>, [skin.work_graph]
5394 eAndrew 679
    mcall     , 			, 
680
    mcall     , <3, 1>, <9 + 12, LIST_HEIGHT + 1>
681
    mcall     , <3 + LIST_WIDTH + 12 + 1, 1>
5721 leency 682
    mcall     , <4, LIST_WIDTH>, <10 + 12, LIST_HEIGHT>, 0xFFFfff
5394 eAndrew 683
 
684
    mov     esi, 1
685
    mov     edi, LIST_SIZE / 2 - 1
686
 .draw_loop:
687
    mov     edx, 0
688
    cmpne   [last_x], esi, @f
689
    cmpne   [last_y], edi, @f
690
    mov     edx, 1
691
  @@:
692
    stdcall draw_item, esi, edi, edx
693
    dec     esi
694
    cmpne   esi, -1, @f
695
    mov     esi, 1
696
    dec     edi
697
  @@:
698
    cmpne   edi, -1, .draw_loop
699
 
5906 eAndrew 700
    invoke  scrollbar.draw, sb_apps
701
 
5394 eAndrew 702
    ret
703
 endp
704
 
705
 ;----------------------
706
 
707
 proc draw_item uses edx edi esi, _x, _y, _sel
708
 ;; get index
5906 eAndrew 709
    stdcall get_index_cur, [_x], [_y]
710
    mov     edi, eax
5394 eAndrew 711
 
712
    cmpge   edi, [list.size], .break
713
 
714
 ;; background
715
    mov     ebx, [_x]
716
    shl     ebx, 7 + 16
717
    add     ebx, 4 shl 16 + LIST_WIDTH / 2
718
 
719
    imul    ecx, [_y], LINE_SIZE
720
    shl     ecx, 16
721
    add     ecx, (10 + 12) shl 16 + LINE_SIZE
722
 
5721 leency 723
    mov     edx, 0xFFFfff
5394 eAndrew 724
    cmpe    [_sel], 0, @f
5721 leency 725
    mov     edx, 0x94AECE
5394 eAndrew 726
  @@:
727
    mcall   13
728
 
729
 ;; shadows
730
    push    ecx
731
    cmpe    [_sel], 1, .after_shadows
5721 leency 732
    mov     edx, 0xCCCccc ;[skin.3d]
5394 eAndrew 733
 
734
    cmpne   [_x], 0, @f
735
    imul     ecx, [_y], LINE_SIZE
736
    shl      ecx, 16
737
    add      ecx, (10 + 12) shl 16 + LINE_SIZE
738
    mcall     , <4, 1>
739
  @@:
740
 
741
    cmpne   [_y], 0, @f
742
    imul     ebx, [_x], LIST_WIDTH / 2
743
    shl      ebx, 16
744
    add      ebx, 4 shl 16 + LIST_WIDTH / 2
745
    mcall     , , <10 + 12, 1>
746
  @@:
747
 
748
 .after_shadows:
749
    pop     ecx
750
 
751
 ;; icon
752
    and     ebx, 0xFFFF shl 16
753
    shr     ecx, 16
754
    add     ecx, ebx
755
    mov     edx, ecx
756
    add     edx, 6 shl 16 + (LINE_SIZE - 32) / 2
757
 
758
    mov     ebx, edi
759
    shl     ebx, 2
760
    mov     ebx, [ebx + list.icon]
761
    imul    ebx, 32 * 32 * 3
762
    add     ebx, [img.rgb]
763
    cmpe    [_sel], 0, .draw_icon
764
 .selected:
765
    mov     eax, img.sel
766
    mov     ecx, 32 * 32
767
    push    edx
768
  @@:
769
    mov     edx, [ebx]
770
    and     edx, 0xFFFFFF
5721 leency 771
    cmpne   edx, 0xFFFFFF, .not
772
    mov     edx, 0x94AECE
5394 eAndrew 773
 .not:
774
    mov     [eax], edx
775
    add     eax, 3
776
    add     ebx, 3
777
    dec     ecx
778
    jnz     @b
779
    pop     edx
780
    mov     ebx, img.sel
781
 
782
 .draw_icon:
783
    mcall   7, , <32, 32>
784
 
785
 ;; text
786
    mov     ebx, edx
787
    add     ebx, (32 + 6) shl 16 + 32 / 2 - 9 / 2
788
 
5721 leency 789
    mov     ecx, 0x000000 ; inactive item text
5394 eAndrew 790
    cmpe    [_sel], 0, @f
5721 leency 791
    mov     ecx, 0x000000 ; active item text
5394 eAndrew 792
  @@:
793
    add     ecx, 0x80 shl 24
794
 
795
    mov     edx, edi
796
    shl     edx, 5
797
    add     edx, list
798
 
799
    mcall   4
800
 
801
  .break:
802
    ret
803
 endp
804
 
805
 ;----------------------
806
 
5906 eAndrew 807
 proc downcase_char uses ebx, _ch
808
    mov     ebx, [_ch]
809
 
810
    cmpl    bl, "A", @f
811
    cmpg    bl, "Z", @f
812
    sub     bl, "A" - "a"
813
    jmp     .ret
814
  @@:
815
 
816
    cmpl    bl, "А", @f
817
    cmpg    bl, "Я", @f
818
    sub     bl, "А" - "а"
819
  @@:
820
 
821
 .ret:
822
    mov     al, bl
823
    ret
824
 endp
825
 
826
 ;----------------------
827
 
828
 proc get_index_cur uses ebx, _x, _y
829
    mov     eax, [_y]
830
    shl     eax, 1
831
    add     eax, [_x]
832
    mov     ebx, [sb_apps.position]
833
    shl     ebx, 1
834
    add     eax, ebx
835
 
836
    ret
837
 endp
838
 
839
 ;----------------------
840
 
841
 proc get_index
842
    stdcall get_index_cur, [last_x], [last_y]
843
    ret
844
 endp
845
 
846
 ;----------------------
847
 
848
 proc set_index uses ebx,_index
849
    mov     eax, [_index]
850
    mov     ebx, [sb_apps.position]
851
    shl     ebx, 1
852
    sub     eax, ebx
853
 
854
    mov     ebx, eax
855
    and     ebx, 1b
856
    mov     [last_x], ebx
857
    shr     eax, 1
858
    mov     [last_y], eax
859
 
860
    mov     eax, 0
861
 
862
    cmpl    [last_y], 0xFFFF, @f
863
    mov     [last_y], 0
864
    dec     [sb_apps.position]
865
    mov     eax, 1
866
    jmp     .exit
867
  @@:
868
 
869
    cmpl    [last_y], LIST_SIZE / 2, @f
870
    mov     ebx, [last_y]
871
    sub     ebx, LIST_SIZE / 2 - 1
872
    mov     [last_y], LIST_SIZE / 2 - 1
873
    add     [sb_apps.position], ebx
874
    mov     eax, 1
875
    jmp     .exit
876
  @@:
877
 
878
 .exit:
879
    cmpge   [sb_apps.position], 0, @f
880
    mov     [sb_apps.position], 0
881
  @@:
882
 
883
    ret
884
 endp
885
 
886
 ;----------------------
887
 
5394 eAndrew 888
 proc section_cb, _file, _sec
5903 eAndrew 889
 ;; CHECK IF EXISTS
890
    invoke  libini.get_str, assoc_ini, [_sec], assoc_ini.exec, buffer, 2048, undefined
891
    mcall   70, is_file_exists
892
    cmpe    ebx, -1, .exit
893
 
5394 eAndrew 894
    mov     ebx, [list.size]
895
    shl     ebx, 5
896
    add     ebx, list
897
    stdcall string.compare, [_sec], assoc_ini.sec
898
    cmpe    eax, 1, @f
899
    stdcall string.copy, [_sec], ebx
900
    invoke  libini.get_num, [_file], [_sec], assoc_ini.icon, 0
901
    mov     ecx, [list.size]
902
    shl     ecx, 2
903
    mov     [ecx + list.icon], eax
904
    inc     [list.size]
905
    inc     [sb_apps.max_area]
906
  @@:
907
    mov     eax, 1
5903 eAndrew 908
  .exit:
5394 eAndrew 909
    ret
910
 endp
911
 
912
 ;----------------------
913
 
914
 dataend:
915
 
916
 ;===============================
917
 
5721 leency 918
 skin system_colors
5394 eAndrew 919
 list rb 32 * 256
920
  .icon rd 256
921
  .size rd 1
922
 img  rd 1
923
  .rgb rd 1
924
  .size rd 1
925
  .buf rb 40
926
  .sel rb 32 * 32 * 3
927
 win:
928
  .x rd 1
929
  .y rd 1
930
 win.title rb 256
931
 param_s rd 1
932
 param_e rd 1
933
 param_a rd 1
934
 undefined rb 1
935
 buffer rb 2048
936
 buffer2 rb 2048
937
 buffer3 rb 2048
938
 buffer4 rb 4096
939
 buffer5 rb 4096
5903 eAndrew 940
 buffer6 rb 2048
5394 eAndrew 941
 params rb 2048
942
 _stack rb 2048
5903 eAndrew 943
 memory: