Subversion Repositories Kolibri OS

Rev

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