Subversion Repositories Kolibri OS

Rev

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