Subversion Repositories Kolibri OS

Rev

Rev 6159 | Rev 7217 | 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"
18
    include "../../string.inc"
19
    include "../../develop/libraries/box_lib/trunk/box_lib.mac"
20
 
21
    include "lang.inc"
22
 
23
if DEBUG eq 1
24
    include "../../debug.inc"
25
end if
26
 
27
 ;===============================
28
 
29
if lang eq ru
30
 title db "Открыть с помощью", 0
31
 browse_txt db "Обзор...", 0
32
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
33
 checkbox_txt db "Использовать всегда", 0
34
else if lang eq et
35
 title db "Open with", 0
36
 browse_txt db "Browse...", 0
37
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
38
 checkbox_txt db "Always use selected program", 0
39
else if lang eq it
40
 title db "Open with", 0
41
 browse_txt db "Browse...", 0
42
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
43
 checkbox_txt db "Always use selected program", 0
44
else
45
 title db "Open with", 0
46
 browse_txt db "Browse...", 0
47
 notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0
48
 checkbox_txt db "Always use selected program", 0
49
end if
50
 
51
 sys_dir db "/sys", 0
52
 slash db "/", 0
53
 open_dialog_path db "/sys/file managers/opendial", 0
54
 app_link db "$", 0
5426 yogev_ezra 55
 icons db "/sys/icons32.png", 0
5394 eAndrew 56
 communication_area_name db "FFFFFF_open_dialog", 0
57
 assoc_ini db "/sys/settings/assoc.ini", 0
58
  .sec db "Assoc", 0
59
  .exec db "exec", 0
5908 eAndrew 60
  .next db "next", 0
5394 eAndrew 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
5913 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
 ;; if '.' is part of path - execute
212
    mov     esi, eax
213
    stdcall string.last_index_of, [param_s], '/', 1
214
    cmpg    eax, esi, execute
215
 
216
 ;; if ext == "kex" - execute
217
    add     esi, [param_s]
218
    mov     [param_e], esi
219
    cmpe    [esi], dword "kex", execute
220
 
221
 open_as:
5908 eAndrew 222
    invoke  libini.get_str, assoc_ini, assoc_ini.sec, esi, buffer8, 2048, undefined
223
    cmpe    byte [buffer8], 0, start_dialog_pre
224
 .run:
225
    mov     edi, 0
226
    cmpne   byte [buffer8], "$", .pre_open
227
    mov     edi, 1
228
    invoke  libini.get_str, assoc_ini, buffer8 + 1, assoc_ini.exec, buffer, 2048, undefined
229
    cmpe    byte [buffer], 0, ini_error
230
    jmp     @f
231
 .pre_open:
232
    stdcall string.copy, buffer8, buffer
5394 eAndrew 233
  @@:
234
    mcall   70, is_openas
5908 eAndrew 235
    cmpge   eax, 0, exit
236
    cmpe    edi, 0, start_dialog
237
    invoke  libini.get_str, assoc_ini, buffer8 + 1, assoc_ini.next, buffer8, 2048, undefined
238
    cmpne   byte [buffer], 0, .run
239
    jmp     start_dialog
5394 eAndrew 240
 
241
 execute:
242
    mov     eax, [param_s]
243
    mov     [is_execute + 21], eax
244
    mcall   70, is_execute
245
    jmp     exit
246
 
247
 open:
248
    invoke  libini.get_str, assoc_ini, assoc_ini.sec, slash, buffer, 2048, undefined
5903 eAndrew 249
    cmpne   [buffer], byte "$", @f
250
    invoke  libini.get_str, assoc_ini, buffer + 1, assoc_ini.exec, buffer, 2048, undefined
5394 eAndrew 251
    cmpe    [buffer], byte 0, ini_error
5903 eAndrew 252
  @@:
5394 eAndrew 253
    mov     eax, [param_s]
254
    mov     [is_open + 8], eax
255
    mcall   70, is_open
256
    jmp     exit
257
 
258
 ini_error:
259
    mcall   70, is_undefined
260
    jmp     exit
261
 
262
 ;----------------------
263
 
264
 start_dialog_pre:
265
    or	    [cb_always.flags], ch_flag_en
266
 
267
 start_dialog:
268
    stdcall dll.Load, imports_add
269
    invoke  opendialog.lib_init
270
 
271
    mcall   40, 100111b
272
 
273
 ;; get title
274
    stdcall string.copy, title, win.title
275
 
276
 ;; get positions
277
    mcall   14
278
    movzx   ebx, ax
279
    shr     ebx, 1
280
    shr     eax, 16 + 1
281
    sub     eax, WIN_WIDTH / 2 - 1
282
    sub     ebx, WIN_HEIGHT / 2 - 1
283
    mov     [win.x], eax
284
    mov     [win.y], ebx
285
 
286
 ;; get colors
5721 leency 287
    mcall   48, 3, skin, sizeof.system_colors
5394 eAndrew 288
 
289
 ;; get opendialog
290
    invoke  opendialog.init, opendialog
291
 
292
 ;; get pathshow
293
    mov     eax, [param_s]
5721 leency 294
    mov     ebx, [skin.work_text]
5394 eAndrew 295
    mov     [ps_addres.txt], eax
296
    mov     [ps_addres], ebx
297
    invoke  pathshow.init, ps_addres
298
 
299
 ;; get checkbox
5721 leency 300
    mov     eax, 0xFFFfff
301
    mov     ebx, [skin.work_graph]
302
    mov     ecx, [skin.work_text]
5394 eAndrew 303
    mov     [cb_always.color], eax
304
    mov     [cb_always.border_color], ebx
305
    mov     [cb_always.text_color], ecx
306
    invoke  checkbox.init, cb_always
307
 
308
 ;; get list
309
    invoke  libini.for_each_section, assoc_ini, section_cb
5907 eAndrew 310
    stdcall sort_list
5394 eAndrew 311
    mov     eax, [sb_apps.max_area]
312
    and     eax, 1b
313
    shr     [sb_apps.max_area], 1
314
    add     [sb_apps.max_area], eax
315
 
5721 leency 316
    mov     eax, 0xFFFfff
317
    mov     ebx, 0xCCCccc ;[skin.3d]
5394 eAndrew 318
    mov     [sb_apps.bg_color], eax
319
    mov     [sb_apps.front_color], ebx
320
    mov     [sb_apps.line_color], ebx
321
 
322
 ;; get icons
323
    mcall   70, is_openimg_info
324
    mov     edx, dword [img.buf + 32]
325
    shl     edx, 4
326
    stdcall mem.Alloc, edx
327
    mov     [img.rgb], eax
328
 
329
    mov     [is_openimg + 12], edx
330
    m2m     dword[is_openimg + 16], dword[img.rgb]
331
    mcall   70, is_openimg
332
 
333
    invoke  libimg.decode, dword[img.rgb], ebx, 0
334
    mov     [img], eax
335
 
336
  ;; alpha
337
    mov     edi, [eax + 8]
338
    shl     edi, 7
339
    sub     edi, 4
340
    mov     eax, [eax + 24]
341
 .setalpha:
342
    mov     ebx, [eax + edi]
343
    shr     ebx, 24
344
    cmpne   ebx, 0, @f
5721 leency 345
    mov     ecx, 0xFFFfff
5394 eAndrew 346
    mov     [eax + edi], ecx
347
 @@:
348
    cmpe    edi, 0, @f
349
    sub     edi, 4
350
    jmp     .setalpha
351
 @@:
352
 
353
    invoke  libimg.toRGB, [img], [img.rgb]
354
    invoke  libimg.destroy, [img]
355
 
356
 ;----------------------
357
 
358
 update:
359
    mcall   10
360
    cmpe    eax, EV_REDRAW, event_redraw
361
    cmpe    eax, EV_KEY, event_key
362
    cmpe    eax, EV_BUTTON, event_button
363
    cmpe    eax, EV_MOUSE, event_mouse
364
    jmp     update
365
 
366
 ;----------------------
367
 
368
 event_redraw:
369
    call    draw_window
370
    jmp     update
371
 
372
 ;----------------------
373
 
374
 event_key:
375
    mcall   2
376
    cmpe    ah, 27, exit
377
 
5905 eAndrew 378
    cmpe    ah,  13, list_item_activate
5906 eAndrew 379
    cmpe    ah,   9, event_button.opendialog
380
    cmpe    ah,  32, .toggle_cb
5905 eAndrew 381
    cmpe    ah, 179, .go_right
382
    cmpe    ah, 176, .go_left
383
    cmpe    ah, 178, .go_up
384
    cmpe    ah, 177, .go_down
5906 eAndrew 385
 
386
    cmpl    ah, "a", @f
387
    cmpg    ah, "z", @f
388
    jmp     .letter
389
  @@:
390
 
391
    cmpl    ah, "а", @f
392
    cmpg    ah, "я", @f
393
    jmp     .letter
394
  @@:
395
 
396
    cmpl    ah, "A", @f
397
    cmpg    ah, "Z", @f
398
    jmp     .letter_big
399
  @@:
400
 
401
    cmpl    ah, "А", @f
402
    cmpg    ah, "Я", @f
403
    jmp     .letter_big
404
  @@:
405
 
406
    cmpl    ah, "0", @f
407
    cmpg    ah, "9", @f
408
    jmp     .letter
409
  @@:
410
 
5394 eAndrew 411
    jmp     update
412
 
5906 eAndrew 413
 .letter_big:
414
    movzx   ebx, ah
415
    stdcall downcase_char, ebx
416
    mov     ah, al
417
 
418
 .letter:
419
    push    eax
420
 
421
    stdcall get_index
422
    inc     eax
423
 
424
    mov     ecx, eax
425
 
426
    imul    ebx, eax, 32
427
    add     ebx, list
428
 
429
    pop     eax
430
 
5913 eAndrew 431
    mov     edi, 0
432
    mov     esi, [list.size]
433
 .search:
434
    shl     esi, 5
435
    add     esi, list
436
 @@:
437
    cmpe    ebx, esi, @f
5906 eAndrew 438
 
439
    movzx   edx, byte [ebx]
440
    stdcall downcase_char, edx
441
    cmpne   ah, al, .next
442
    stdcall set_index, ecx
443
    stdcall draw_list
444
    jmp     update
445
 
446
 .next:
447
    inc     ecx
448
    add     ebx, 32
449
    jmp     @b
450
  @@:
5913 eAndrew 451
    cmpe    edi, 1, update
452
    mov     ebx, list
453
    mov     ecx, 0
454
    mov     edi, 1
455
    push    eax
456
    stdcall get_index
457
    mov     esi, eax
458
    pop     eax
459
    jmp     .search
5906 eAndrew 460
 
461
 .toggle_cb:
462
    mov     eax, [cb_always.flags]
463
    mov     ebx, eax
464
    and     ebx, ch_flag_en
465
    cmpe    ebx, 0, @f
466
    sub     eax, ch_flag_en
467
    jmp     .toggle_cb.redraw
468
  @@:
469
    add     eax, ch_flag_en
470
 .toggle_cb.redraw:
471
    mov     [cb_always.flags], eax
472
    invoke  checkbox.draw, cb_always
473
    jmp     update
474
 
5905 eAndrew 475
 .go_right:
476
    mov     esi, 1
477
    jmp     .go_anyway
478
 
479
 .go_left:
480
    mov     esi, -1
481
    jmp     .go_anyway
482
 
483
 .go_up:
484
    mov     esi, -2
485
    jmp     .go_anyway
486
 
487
 .go_down:
488
    mov     esi, 2
489
 
490
 .go_anyway:
491
;; HIDE OLD SELECTION
492
    stdcall draw_item, [last_x], [last_y], 0
493
 
494
;; [X, Y] -> INDEX
5906 eAndrew 495
    stdcall get_index
5905 eAndrew 496
 
497
;; CHANGE INDEX
5913 eAndrew 498
 .check_p2:
499
    cmpne   esi, 2, .check_m2
500
    mov     ebx, [list.size]
501
    dec     ebx
502
    sub     ebx, eax
503
    cmpg    ebx, 1, .add
504
    jmp     .check
505
 
506
 .check_m2:
507
    cmpne   esi, -2, .add
508
    cmpg    eax, 1, .add
509
    jmp     .check
510
 
511
 .add:
5905 eAndrew 512
    add     eax, esi
513
 
5913 eAndrew 514
 .check:
5905 eAndrew 515
    cmpl    eax, [list.size], @f
516
    mov     eax, [list.size]
517
    dec     eax
518
  @@:
519
 
520
    cmpge   eax, 0, @f
521
    mov     eax, 0
522
  @@:
523
 
524
;; INDEX -> [X, Y]
5906 eAndrew 525
    stdcall set_index, eax
526
    cmpe    eax, 1, @f
5905 eAndrew 527
 
5906 eAndrew 528
;; PARTLY REDRAW
5905 eAndrew 529
    stdcall draw_item, [last_x], [last_y], 1
530
    jmp     update
531
 
5906 eAndrew 532
;; FULL REDRAW
5905 eAndrew 533
  @@:
534
    stdcall draw_list
535
    jmp     update
536
 
5394 eAndrew 537
 ;----------------------
538
 
539
 event_button:
540
    mcall   17
541
    cmpe    ah, 1, exit
542
    cmpe    ah, 2, .opendialog
5905 eAndrew 543
    jmp     list_item_activate
5394 eAndrew 544
 
5905 eAndrew 545
 .opendialog:
546
    invoke  opendialog.start, opendialog
547
    cmpne   [opendialog.status], 1, update
5394 eAndrew 548
    mcall   70, is_openas
5905 eAndrew 549
 
550
    mov     edi, 0
551
    jmp     save_assoc
552
 
553
 ;----------------------
554
 
555
 list_item_activate:
5906 eAndrew 556
    stdcall get_index
5905 eAndrew 557
    shl     eax, 5
558
    add     eax, list
559
    cmpe    byte [eax], 0, update
560
    mov     [param_a], eax
561
    invoke  libini.get_str, assoc_ini, eax, assoc_ini.exec, buffer, 256, undefined
562
    cmpe    byte [buffer], 0, ini_error
563
    mcall   70, is_openas
564
 
5394 eAndrew 565
    mov     edi, 1
5905 eAndrew 566
    jmp     save_assoc
5394 eAndrew 567
 
5905 eAndrew 568
 ;----------------------
569
 
570
 save_assoc:
5394 eAndrew 571
    mov     eax, [cb_always.flags]
572
    and     eax, ch_flag_en
573
    cmpe    eax, 0, exit
574
 
575
    cmpe    edi, 0, @f
576
    stdcall string.copy, app_link, buffer
577
    stdcall string.concatenate, [param_a], buffer
578
  @@:
579
 
580
    invoke  libini.set_str, assoc_ini, assoc_ini.sec, [param_e], buffer, 33
581
    jmp     exit
582
 
583
 ;----------------------
584
 
585
 event_mouse:
586
    invoke  checkbox.mouse, cb_always
587
    mov     edi, [sb_apps.position]
588
    invoke  scrollbar.mouse, sb_apps
589
    sub     edi, [sb_apps.position]
590
    jz	    @f
591
    call    draw_list
592
  @@:
593
 
594
    mcall   37, 1
595
    movzx   edi, ax
596
    shr     eax, 16
597
    mov     esi, eax
598
    sub     esi, 4
599
    sub     edi, 10 + 12
600
    cmpl    esi, 0, .out
601
    cmpge   esi, LIST_WIDTH, .out
602
    cmpl    edi, 0, .out
603
    cmpge   edi, LIST_HEIGHT, .out
604
 
605
    mcall   37, 7
606
    and     eax, 0xFFFF
607
    cmpe    eax, 65535, .scroll_up
608
    cmpe    eax, 0, @f
609
 
610
 .scroll_down:
611
    mov     eax, [sb_apps.position]
612
    add     eax, LIST_SIZE / 2
613
    shl     eax, 1
614
    cmpge   eax, [list.size], @f
615
    inc     [sb_apps.position]
616
    stdcall draw_list
617
    jmp     update
618
 
619
 .scroll_up:
620
    cmpe    [sb_apps.position], 0, @f
621
    dec     [sb_apps.position]
622
    stdcall draw_list
623
    jmp     update
624
 
625
  @@:
626
 
627
    mov     eax, esi
628
    mov     ebx, LIST_WIDTH / 2
629
    mov     edx, 0
630
    div     ebx
631
    mov     esi, eax
632
 
633
    mov     eax, edi
634
    mov     ebx, LINE_SIZE
635
    mov     edx, 0
636
    div     ebx
637
    mov     edi, eax
638
 
639
    cmpne   esi, [last_x], .redraw
640
    cmpne   edi, [last_y], .redraw
641
    jmp     @f
642
 
643
 .redraw:
644
    stdcall draw_item, [last_x], [last_y], 0
645
    mov     [last_x], esi
646
    mov     [last_y], edi
647
    stdcall draw_item, esi, edi, 1
648
    jmp     @f
649
 
650
 .out:
651
    cmpe    [last_x], -1, @f
652
    stdcall draw_item, [last_x], [last_y], 0
653
    mov     [last_x], -1
654
    mov     [last_y], -1
655
  @@:
656
 
657
    jmp     update
658
 
659
 ;----------------------
660
 
661
 exit:
662
    mcall   -1
663
 
664
 ;----------------------
665
 
666
 proc draw_window
667
    mcall   12, 1
668
 
5721 leency 669
    mov     edx, [skin.work]
5394 eAndrew 670
    or	    edx, 0x34 shl 24
671
    mcall   0, <[win.x], WIN_WIDTH>, <[win.y], WIN_HEIGHT>, , , win.title
672
    stdcall draw_list
673
    invoke  pathshow.draw, ps_addres
674
    invoke  checkbox.draw, cb_always
675
 
6159 leency 676
    mcall   8, <208, 63>, , 2, [skin.work_button]
5394 eAndrew 677
;
5721 leency 678
    mov     ecx, [skin.work_button_text]
5394 eAndrew 679
    add     ecx, 0x80 shl 24
6159 leency 680
    mcall   4, <214, LIST_HEIGHT + 36>, , browse_txt
5394 eAndrew 681
 
682
 ;; buttons
683
    mov     eax, 8
684
    mov     ebx, 4 shl 16 + LIST_WIDTH / 2
685
    mov     ecx, (10 + 12) shl 16 + LINE_SIZE - 1
686
    mov     edx, 0x60 shl 24 + 10
687
    mov     edi, LIST_SIZE
688
    mov     esi, 0
689
  @@:
690
    cmpe    edi, 0, @f
691
    mcall
692
 
693
    cmpe    esi, 0, .doA
694
 .doB:
695
    sub     ebx, LIST_WIDTH shl 16
696
    add     ecx, LINE_SIZE shl 16
697
 .doA:
698
    add     ebx, (LIST_WIDTH / 2) shl 16
699
    sub     ecx, LINE_SIZE shl 16
700
 
701
    not     esi
702
    add     ecx, LINE_SIZE shl 16
703
    inc     edx
704
    dec     edi
705
    jmp     @b
706
  @@:
707
 
708
    mcall   12, 2
709
    ret
710
  endp
711
 
712
 ;----------------------
713
 
714
 proc draw_list
5721 leency 715
    mcall   13, <3, LIST_WIDTH + 2 + 12>, <9 + 12, 1>, [skin.work_graph]
5394 eAndrew 716
    mcall     , 			, 
717
    mcall     , <3, 1>, <9 + 12, LIST_HEIGHT + 1>
718
    mcall     , <3 + LIST_WIDTH + 12 + 1, 1>
5721 leency 719
    mcall     , <4, LIST_WIDTH>, <10 + 12, LIST_HEIGHT>, 0xFFFfff
5394 eAndrew 720
 
721
    mov     esi, 1
722
    mov     edi, LIST_SIZE / 2 - 1
723
 .draw_loop:
724
    mov     edx, 0
725
    cmpne   [last_x], esi, @f
726
    cmpne   [last_y], edi, @f
727
    mov     edx, 1
728
  @@:
729
    stdcall draw_item, esi, edi, edx
730
    dec     esi
731
    cmpne   esi, -1, @f
732
    mov     esi, 1
733
    dec     edi
734
  @@:
735
    cmpne   edi, -1, .draw_loop
736
 
5906 eAndrew 737
    invoke  scrollbar.draw, sb_apps
738
 
5394 eAndrew 739
    ret
740
 endp
741
 
742
 ;----------------------
743
 
744
 proc draw_item uses edx edi esi, _x, _y, _sel
745
 ;; get index
5906 eAndrew 746
    stdcall get_index_cur, [_x], [_y]
747
    mov     edi, eax
5394 eAndrew 748
 
749
    cmpge   edi, [list.size], .break
750
 
751
 ;; background
752
    mov     ebx, [_x]
753
    shl     ebx, 7 + 16
754
    add     ebx, 4 shl 16 + LIST_WIDTH / 2
755
 
756
    imul    ecx, [_y], LINE_SIZE
757
    shl     ecx, 16
758
    add     ecx, (10 + 12) shl 16 + LINE_SIZE
759
 
5721 leency 760
    mov     edx, 0xFFFfff
5394 eAndrew 761
    cmpe    [_sel], 0, @f
5721 leency 762
    mov     edx, 0x94AECE
5394 eAndrew 763
  @@:
764
    mcall   13
765
 
766
 ;; shadows
767
    push    ecx
768
    cmpe    [_sel], 1, .after_shadows
5721 leency 769
    mov     edx, 0xCCCccc ;[skin.3d]
5394 eAndrew 770
 
771
    cmpne   [_x], 0, @f
772
    imul     ecx, [_y], LINE_SIZE
773
    shl      ecx, 16
774
    add      ecx, (10 + 12) shl 16 + LINE_SIZE
775
    mcall     , <4, 1>
776
  @@:
777
 
778
    cmpne   [_y], 0, @f
779
    imul     ebx, [_x], LIST_WIDTH / 2
780
    shl      ebx, 16
781
    add      ebx, 4 shl 16 + LIST_WIDTH / 2
782
    mcall     , , <10 + 12, 1>
783
  @@:
784
 
785
 .after_shadows:
786
    pop     ecx
787
 
788
 ;; icon
789
    and     ebx, 0xFFFF shl 16
790
    shr     ecx, 16
791
    add     ecx, ebx
792
    mov     edx, ecx
793
    add     edx, 6 shl 16 + (LINE_SIZE - 32) / 2
794
 
795
    mov     ebx, edi
796
    shl     ebx, 2
797
    mov     ebx, [ebx + list.icon]
798
    imul    ebx, 32 * 32 * 3
799
    add     ebx, [img.rgb]
800
    cmpe    [_sel], 0, .draw_icon
801
 .selected:
802
    mov     eax, img.sel
803
    mov     ecx, 32 * 32
804
    push    edx
805
  @@:
806
    mov     edx, [ebx]
807
    and     edx, 0xFFFFFF
5721 leency 808
    cmpne   edx, 0xFFFFFF, .not
809
    mov     edx, 0x94AECE
5394 eAndrew 810
 .not:
811
    mov     [eax], edx
812
    add     eax, 3
813
    add     ebx, 3
814
    dec     ecx
815
    jnz     @b
816
    pop     edx
817
    mov     ebx, img.sel
818
 
819
 .draw_icon:
820
    mcall   7, , <32, 32>
821
 
822
 ;; text
823
    mov     ebx, edx
824
    add     ebx, (32 + 6) shl 16 + 32 / 2 - 9 / 2
825
 
5721 leency 826
    mov     ecx, 0x000000 ; inactive item text
5394 eAndrew 827
    cmpe    [_sel], 0, @f
5721 leency 828
    mov     ecx, 0x000000 ; active item text
5394 eAndrew 829
  @@:
830
    add     ecx, 0x80 shl 24
831
 
832
    mov     edx, edi
833
    shl     edx, 5
834
    add     edx, list
835
 
836
    mcall   4
837
 
838
  .break:
839
    ret
840
 endp
841
 
842
 ;----------------------
843
 
5906 eAndrew 844
 proc downcase_char uses ebx, _ch
845
    mov     ebx, [_ch]
846
 
847
    cmpl    bl, "A", @f
848
    cmpg    bl, "Z", @f
849
    sub     bl, "A" - "a"
850
    jmp     .ret
851
  @@:
852
 
853
    cmpl    bl, "А", @f
854
    cmpg    bl, "Я", @f
855
    sub     bl, "А" - "а"
856
  @@:
857
 
858
 .ret:
859
    mov     al, bl
860
    ret
861
 endp
862
 
863
 ;----------------------
864
 
865
 proc get_index_cur uses ebx, _x, _y
866
    mov     eax, [_y]
867
    shl     eax, 1
868
    add     eax, [_x]
869
    mov     ebx, [sb_apps.position]
870
    shl     ebx, 1
871
    add     eax, ebx
872
 
873
    ret
874
 endp
875
 
876
 ;----------------------
877
 
878
 proc get_index
879
    stdcall get_index_cur, [last_x], [last_y]
880
    ret
881
 endp
882
 
883
 ;----------------------
884
 
885
 proc set_index uses ebx,_index
886
    mov     eax, [_index]
887
    mov     ebx, [sb_apps.position]
888
    shl     ebx, 1
889
    sub     eax, ebx
890
 
891
    mov     ebx, eax
892
    and     ebx, 1b
893
    mov     [last_x], ebx
894
    shr     eax, 1
895
    mov     [last_y], eax
896
 
897
    mov     eax, 0
898
 
899
    cmpl    [last_y], 0xFFFF, @f
5913 eAndrew 900
    mov     ebx, 0xFFFFFFFF shr 1
901
    sub     ebx, [last_y]
902
    inc     ebx
5906 eAndrew 903
    mov     [last_y], 0
5913 eAndrew 904
    ;dec     [sb_apps.position]
905
    sub     [sb_apps.position], ebx
5906 eAndrew 906
    mov     eax, 1
907
    jmp     .exit
908
  @@:
909
 
910
    cmpl    [last_y], LIST_SIZE / 2, @f
911
    mov     ebx, [last_y]
912
    sub     ebx, LIST_SIZE / 2 - 1
913
    mov     [last_y], LIST_SIZE / 2 - 1
914
    add     [sb_apps.position], ebx
915
    mov     eax, 1
916
    jmp     .exit
917
  @@:
918
 
919
 .exit:
920
    cmpge   [sb_apps.position], 0, @f
921
    mov     [sb_apps.position], 0
922
  @@:
923
 
924
    ret
925
 endp
926
 
927
 ;----------------------
928
 
5394 eAndrew 929
 proc section_cb, _file, _sec
5903 eAndrew 930
 ;; CHECK IF EXISTS
931
    invoke  libini.get_str, assoc_ini, [_sec], assoc_ini.exec, buffer, 2048, undefined
932
    mcall   70, is_file_exists
933
    cmpe    ebx, -1, .exit
934
 
5394 eAndrew 935
    mov     ebx, [list.size]
936
    shl     ebx, 5
937
    add     ebx, list
5913 eAndrew 938
    stdcall string.cmp, [_sec], assoc_ini.sec
939
    cmpe    eax, 0, @f
5394 eAndrew 940
    stdcall string.copy, [_sec], ebx
941
    invoke  libini.get_num, [_file], [_sec], assoc_ini.icon, 0
942
    mov     ecx, [list.size]
943
    shl     ecx, 2
944
    mov     [ecx + list.icon], eax
945
    inc     [list.size]
946
    inc     [sb_apps.max_area]
947
  @@:
948
    mov     eax, 1
5903 eAndrew 949
  .exit:
5394 eAndrew 950
    ret
951
 endp
952
 
953
 ;----------------------
954
 
5907 eAndrew 955
 proc sort_list
5913 eAndrew 956
    mov     eax, list
957
    mov     ebx, list.lowercased
958
  @@:
959
    stdcall string.copy, eax, ebx
960
    stdcall string.to_lower_case, ebx
961
    add     eax, 32
962
    add     ebx, 32
963
    cmpne   byte [eax], 0, @b
964
 
5907 eAndrew 965
    mov     edi, 0
5913 eAndrew 966
    mov     ebx, list.lowercased ;; i = 0
5907 eAndrew 967
    imul    ecx, [list.size], 32 ;; i < n - 1
968
    sub     ecx, 32
5913 eAndrew 969
    add     ecx, list.lowercased
5907 eAndrew 970
 
971
 .loop1:
5913 eAndrew 972
    mov     edx, list.lowercased ;; j = 0
5907 eAndrew 973
    mov     esi, [list.size]	 ;; j < n - i - 1
974
    sub     esi, edi
975
    dec     esi
976
    imul    esi, 32
5913 eAndrew 977
    add     esi, list.lowercased
5907 eAndrew 978
 .loop2:
979
    mov     eax, edx
980
    add     eax, 32
981
    stdcall string.cmp, edx, eax, 32
982
    cmpne   eax, 1, .next2
5913 eAndrew 983
;; swap names lw
5907 eAndrew 984
    mov     eax, edx
985
    add     eax, 32
986
    stdcall string.copy, edx, buffer7
987
    stdcall string.copy, eax, edx
988
    stdcall string.copy, buffer7, eax
5913 eAndrew 989
;; swap names
990
    mov     eax, edx
991
    sub     eax, 256 * 32 - 32
992
    sub     edx, 256 * 32
993
    stdcall string.copy, edx, buffer7
994
    stdcall string.copy, eax, edx
995
    stdcall string.copy, buffer7, eax
996
    add     edx, 256 * 32
5907 eAndrew 997
;; swap icons
998
    mov     eax, edx
5913 eAndrew 999
    sub     eax, list.lowercased
5907 eAndrew 1000
    shr     eax, 3
1001
    add     eax, list.icon
1002
    push    ebx ecx
1003
    mov     ebx, [eax]
1004
    mov     ecx, [eax + 4]
1005
    mov     [eax], ecx
1006
    mov     [eax + 4], ebx
1007
    pop     ecx ebx
1008
 .next2:
1009
    add     edx, 32
1010
    cmpne   edx, esi, .loop2
1011
 .next1:
1012
    inc     edi
1013
    add     ebx, 32
1014
    cmpne   ebx, ecx, .loop1
1015
 
1016
    ret
1017
 endp
1018
 
1019
 ;----------------------
1020
 
5394 eAndrew 1021
 dataend:
1022
 
1023
 ;===============================
1024
 
5721 leency 1025
 skin system_colors
5394 eAndrew 1026
 list rb 32 * 256
5913 eAndrew 1027
  .lowercased rd 32 * 256
5394 eAndrew 1028
  .icon rd 256
1029
  .size rd 1
1030
 img  rd 1
1031
  .rgb rd 1
1032
  .size rd 1
1033
  .buf rb 40
1034
  .sel rb 32 * 32 * 3
1035
 win:
1036
  .x rd 1
1037
  .y rd 1
1038
 win.title rb 256
1039
 param_s rd 1
1040
 param_e rd 1
1041
 param_a rd 1
1042
 undefined rb 1
5907 eAndrew 1043
 buffer  rb 2048
1044
 buffer2 rb 2048 ;OD
1045
 buffer3 rb 2048 ;OD
1046
 buffer4 rb 2048 ;OD
1047
 buffer5 rb 2048 ;OD
1048
 buffer6 rb 2048 ;check existance
1049
 buffer7 rb 32	 ;for sorting
5908 eAndrew 1050
 buffer8 rd 2048
5394 eAndrew 1051
 params rb 2048
1052
 _stack rb 2048
5903 eAndrew 1053
 memory: