Subversion Repositories Kolibri OS

Rev

Rev 5913 | Rev 6832 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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 "../../cmp.inc"
  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
  56.  icons db "/sys/icons32.png", 0
  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.   .next db "next", 0
  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 \
  70.   5 shl 16 + 16, (LIST_HEIGHT + 33) shl 16 + 16, 6, 0, 0, 0, checkbox_txt, ch_flag_middle
  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.  
  137.  is_file_exists:
  138.   dd 0, 0, 0, 0, buffer6
  139.   db 0
  140.   dd buffer
  141.  
  142.   last_x dd -1
  143.   last_y dd -1
  144.  
  145. if DEBUG eq 1
  146.     std_param db "~/sys/example.asm", 0
  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
  186.     stdcall string.to_lower_case, params
  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:
  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
  234.   @@:
  235.     mcall   70, is_openas
  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
  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
  250.     cmpne   [buffer], byte "$", @f
  251.     invoke  libini.get_str, assoc_ini, buffer + 1, assoc_ini.exec, buffer, 2048, undefined
  252.     cmpe    [buffer], byte 0, ini_error
  253.   @@:
  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
  288.     mcall   48, 3, skin, sizeof.system_colors
  289.  
  290.  ;; get opendialog
  291.     invoke  opendialog.init, opendialog
  292.  
  293.  ;; get pathshow
  294.     mov     eax, [param_s]
  295.     mov     ebx, [skin.work_text]
  296.     mov     [ps_addres.txt], eax
  297.     mov     [ps_addres], ebx
  298.     invoke  pathshow.init, ps_addres
  299.  
  300.  ;; get checkbox
  301.     mov     eax, 0xFFFfff
  302.     mov     ebx, [skin.work_graph]
  303.     mov     ecx, [skin.work_text]
  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
  311.     stdcall sort_list
  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.  
  317.     mov     eax, 0xFFFfff
  318.     mov     ebx, 0xCCCccc ;[skin.3d]
  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
  346.     mov     ecx, 0xFFFfff
  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.  
  379.     cmpe    ah,  13, list_item_activate
  380.     cmpe    ah,   9, event_button.opendialog
  381.     cmpe    ah,  32, .toggle_cb
  382.     cmpe    ah, 179, .go_right
  383.     cmpe    ah, 176, .go_left
  384.     cmpe    ah, 178, .go_up
  385.     cmpe    ah, 177, .go_down
  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.  
  412.     jmp     update
  413.  
  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.  
  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
  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.   @@:
  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
  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.  
  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
  496.     stdcall get_index
  497.  
  498. ;; CHANGE INDEX
  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:
  513.     add     eax, esi
  514.  
  515.  .check:
  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]
  526.     stdcall set_index, eax
  527.     cmpe    eax, 1, @f
  528.  
  529. ;; PARTLY REDRAW
  530.     stdcall draw_item, [last_x], [last_y], 1
  531.     jmp     update
  532.  
  533. ;; FULL REDRAW
  534.   @@:
  535.     stdcall draw_list
  536.     jmp     update
  537.  
  538.  ;----------------------
  539.  
  540.  event_button:
  541.     mcall   17
  542.     cmpe    ah, 1, exit
  543.     cmpe    ah, 2, .opendialog
  544.     jmp     list_item_activate
  545.  
  546.  .opendialog:
  547.     invoke  opendialog.start, opendialog
  548.     cmpne   [opendialog.status], 1, update
  549.     mcall   70, is_openas
  550.  
  551.     mov     edi, 0
  552.     jmp     save_assoc
  553.  
  554.  ;----------------------
  555.  
  556.  list_item_activate:
  557.     stdcall get_index
  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.  
  566.     mov     edi, 1
  567.     jmp     save_assoc
  568.  
  569.  ;----------------------
  570.  
  571.  save_assoc:
  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.  
  670.     mov     edx, [skin.work]
  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.  
  677.     mcall   8, <208, 63>, <LIST_HEIGHT + 28, 21>, 2, [skin.work_button]
  678. ;
  679.     mov     ecx, [skin.work_button_text]
  680.     add     ecx, 0x80 shl 24
  681.     mcall   4, <214, LIST_HEIGHT + 36>, , browse_txt
  682.  
  683.  ;; buttons
  684.     mov     eax, 8
  685.     mov     ebx, 4 shl 16 + LIST_WIDTH / 2
  686.     mov     ecx, (10 + 12) shl 16 + LINE_SIZE - 1
  687.     mov     edx, 0x60 shl 24 + 10
  688.     mov     edi, LIST_SIZE
  689.     mov     esi, 0
  690.   @@:
  691.     cmpe    edi, 0, @f
  692.     mcall
  693.  
  694.     cmpe    esi, 0, .doA
  695.  .doB:
  696.     sub     ebx, LIST_WIDTH shl 16
  697.     add     ecx, LINE_SIZE shl 16
  698.  .doA:
  699.     add     ebx, (LIST_WIDTH / 2) shl 16
  700.     sub     ecx, LINE_SIZE shl 16
  701.  
  702.     not     esi
  703.     add     ecx, LINE_SIZE shl 16
  704.     inc     edx
  705.     dec     edi
  706.     jmp     @b
  707.   @@:
  708.  
  709.     mcall   12, 2
  710.     ret
  711.   endp
  712.  
  713.  ;----------------------
  714.  
  715.  proc draw_list
  716.     mcall   13, <3, LIST_WIDTH + 2 + 12>, <9 + 12, 1>, [skin.work_graph]
  717.     mcall     ,                         , <LIST_HEIGHT + 9 + 1 + 12, 1>
  718.     mcall     , <3, 1>, <9 + 12, LIST_HEIGHT + 1>
  719.     mcall     , <3 + LIST_WIDTH + 12 + 1, 1>
  720.     mcall     , <4, LIST_WIDTH>, <10 + 12, LIST_HEIGHT>, 0xFFFfff
  721.  
  722.     mov     esi, 1
  723.     mov     edi, LIST_SIZE / 2 - 1
  724.  .draw_loop:
  725.     mov     edx, 0
  726.     cmpne   [last_x], esi, @f
  727.     cmpne   [last_y], edi, @f
  728.     mov     edx, 1
  729.   @@:
  730.     stdcall draw_item, esi, edi, edx
  731.     dec     esi
  732.     cmpne   esi, -1, @f
  733.     mov     esi, 1
  734.     dec     edi
  735.   @@:
  736.     cmpne   edi, -1, .draw_loop
  737.  
  738.     invoke  scrollbar.draw, sb_apps
  739.  
  740.     ret
  741.  endp
  742.  
  743.  ;----------------------
  744.  
  745.  proc draw_item uses edx edi esi, _x, _y, _sel
  746.  ;; get index
  747.     stdcall get_index_cur, [_x], [_y]
  748.     mov     edi, eax
  749.  
  750.     cmpge   edi, [list.size], .break
  751.  
  752.  ;; background
  753.     mov     ebx, [_x]
  754.     shl     ebx, 7 + 16
  755.     add     ebx, 4 shl 16 + LIST_WIDTH / 2
  756.  
  757.     imul    ecx, [_y], LINE_SIZE
  758.     shl     ecx, 16
  759.     add     ecx, (10 + 12) shl 16 + LINE_SIZE
  760.  
  761.     mov     edx, 0xFFFfff
  762.     cmpe    [_sel], 0, @f
  763.     mov     edx, 0x94AECE
  764.   @@:
  765.     mcall   13
  766.  
  767.  ;; shadows
  768.     push    ecx
  769.     cmpe    [_sel], 1, .after_shadows
  770.     mov     edx, 0xCCCccc ;[skin.3d]
  771.  
  772.     cmpne   [_x], 0, @f
  773.     imul     ecx, [_y], LINE_SIZE
  774.     shl      ecx, 16
  775.     add      ecx, (10 + 12) shl 16 + LINE_SIZE
  776.     mcall     , <4, 1>
  777.   @@:
  778.  
  779.     cmpne   [_y], 0, @f
  780.     imul     ebx, [_x], LIST_WIDTH / 2
  781.     shl      ebx, 16
  782.     add      ebx, 4 shl 16 + LIST_WIDTH / 2
  783.     mcall     , , <10 + 12, 1>
  784.   @@:
  785.  
  786.  .after_shadows:
  787.     pop     ecx
  788.  
  789.  ;; icon
  790.     and     ebx, 0xFFFF shl 16
  791.     shr     ecx, 16
  792.     add     ecx, ebx
  793.     mov     edx, ecx
  794.     add     edx, 6 shl 16 + (LINE_SIZE - 32) / 2
  795.  
  796.     mov     ebx, edi
  797.     shl     ebx, 2
  798.     mov     ebx, [ebx + list.icon]
  799.     imul    ebx, 32 * 32 * 3
  800.     add     ebx, [img.rgb]
  801.     cmpe    [_sel], 0, .draw_icon
  802.  .selected:
  803.     mov     eax, img.sel
  804.     mov     ecx, 32 * 32
  805.     push    edx
  806.   @@:
  807.     mov     edx, [ebx]
  808.     and     edx, 0xFFFFFF
  809.     cmpne   edx, 0xFFFFFF, .not
  810.     mov     edx, 0x94AECE
  811.  .not:
  812.     mov     [eax], edx
  813.     add     eax, 3
  814.     add     ebx, 3
  815.     dec     ecx
  816.     jnz     @b
  817.     pop     edx
  818.     mov     ebx, img.sel
  819.  
  820.  .draw_icon:
  821.     mcall   7, , <32, 32>
  822.  
  823.  ;; text
  824.     mov     ebx, edx
  825.     add     ebx, (32 + 6) shl 16 + 32 / 2 - 9 / 2
  826.  
  827.     mov     ecx, 0x000000 ; inactive item text
  828.     cmpe    [_sel], 0, @f
  829.     mov     ecx, 0x000000 ; active item text
  830.   @@:
  831.     add     ecx, 0x80 shl 24
  832.  
  833.     mov     edx, edi
  834.     shl     edx, 5
  835.     add     edx, list
  836.  
  837.     mcall   4
  838.  
  839.   .break:
  840.     ret
  841.  endp
  842.  
  843.  ;----------------------
  844.  
  845.  proc downcase_char uses ebx, _ch
  846.     mov     ebx, [_ch]
  847.  
  848.     cmpl    bl, "A", @f
  849.     cmpg    bl, "Z", @f
  850.     sub     bl, "A" - "a"
  851.     jmp     .ret
  852.   @@:
  853.  
  854.     cmpl    bl, "€", @f
  855.     cmpg    bl, "Ÿ", @f
  856.     sub     bl, "€" - " "
  857.   @@:
  858.  
  859.  .ret:
  860.     mov     al, bl
  861.     ret
  862.  endp
  863.  
  864.  ;----------------------
  865.  
  866.  proc get_index_cur uses ebx, _x, _y
  867.     mov     eax, [_y]
  868.     shl     eax, 1
  869.     add     eax, [_x]
  870.     mov     ebx, [sb_apps.position]
  871.     shl     ebx, 1
  872.     add     eax, ebx
  873.  
  874.     ret
  875.  endp
  876.  
  877.  ;----------------------
  878.  
  879.  proc get_index
  880.     stdcall get_index_cur, [last_x], [last_y]
  881.     ret
  882.  endp
  883.  
  884.  ;----------------------
  885.  
  886.  proc set_index uses ebx,_index
  887.     mov     eax, [_index]
  888.     mov     ebx, [sb_apps.position]
  889.     shl     ebx, 1
  890.     sub     eax, ebx
  891.  
  892.     mov     ebx, eax
  893.     and     ebx, 1b
  894.     mov     [last_x], ebx
  895.     shr     eax, 1
  896.     mov     [last_y], eax
  897.  
  898.     mov     eax, 0
  899.  
  900.     cmpl    [last_y], 0xFFFF, @f
  901.     mov     ebx, 0xFFFFFFFF shr 1
  902.     sub     ebx, [last_y]
  903.     inc     ebx
  904.     mov     [last_y], 0
  905.     ;dec     [sb_apps.position]
  906.     sub     [sb_apps.position], ebx
  907.     mov     eax, 1
  908.     jmp     .exit
  909.   @@:
  910.  
  911.     cmpl    [last_y], LIST_SIZE / 2, @f
  912.     mov     ebx, [last_y]
  913.     sub     ebx, LIST_SIZE / 2 - 1
  914.     mov     [last_y], LIST_SIZE / 2 - 1
  915.     add     [sb_apps.position], ebx
  916.     mov     eax, 1
  917.     jmp     .exit
  918.   @@:
  919.  
  920.  .exit:
  921.     cmpge   [sb_apps.position], 0, @f
  922.     mov     [sb_apps.position], 0
  923.   @@:
  924.  
  925.     ret
  926.  endp
  927.  
  928.  ;----------------------
  929.  
  930.  proc section_cb, _file, _sec
  931.  ;; CHECK IF EXISTS
  932.     invoke  libini.get_str, assoc_ini, [_sec], assoc_ini.exec, buffer, 2048, undefined
  933.     mcall   70, is_file_exists
  934.     cmpe    ebx, -1, .exit
  935.  
  936.     mov     ebx, [list.size]
  937.     shl     ebx, 5
  938.     add     ebx, list
  939.     stdcall string.cmp, [_sec], assoc_ini.sec
  940.     cmpe    eax, 0, @f
  941.     stdcall string.copy, [_sec], ebx
  942.     invoke  libini.get_num, [_file], [_sec], assoc_ini.icon, 0
  943.     mov     ecx, [list.size]
  944.     shl     ecx, 2
  945.     mov     [ecx + list.icon], eax
  946.     inc     [list.size]
  947.     inc     [sb_apps.max_area]
  948.   @@:
  949.     mov     eax, 1
  950.   .exit:
  951.     ret
  952.  endp
  953.  
  954.  ;----------------------
  955.  
  956.  proc sort_list
  957.     mov     eax, list
  958.     mov     ebx, list.lowercased
  959.   @@:
  960.     stdcall string.copy, eax, ebx
  961.     stdcall string.to_lower_case, ebx
  962.     add     eax, 32
  963.     add     ebx, 32
  964.     cmpne   byte [eax], 0, @b
  965.  
  966.     mov     edi, 0
  967.     mov     ebx, list.lowercased ;; i = 0
  968.     imul    ecx, [list.size], 32 ;; i < n - 1
  969.     sub     ecx, 32
  970.     add     ecx, list.lowercased
  971.  
  972.  .loop1:
  973.     mov     edx, list.lowercased ;; j = 0
  974.     mov     esi, [list.size]     ;; j < n - i - 1
  975.     sub     esi, edi
  976.     dec     esi
  977.     imul    esi, 32
  978.     add     esi, list.lowercased
  979.  .loop2:
  980.     mov     eax, edx
  981.     add     eax, 32
  982.     stdcall string.cmp, edx, eax, 32
  983.     cmpne   eax, 1, .next2
  984. ;; swap names lw
  985.     mov     eax, edx
  986.     add     eax, 32
  987.     stdcall string.copy, edx, buffer7
  988.     stdcall string.copy, eax, edx
  989.     stdcall string.copy, buffer7, eax
  990. ;; swap names
  991.     mov     eax, edx
  992.     sub     eax, 256 * 32 - 32
  993.     sub     edx, 256 * 32
  994.     stdcall string.copy, edx, buffer7
  995.     stdcall string.copy, eax, edx
  996.     stdcall string.copy, buffer7, eax
  997.     add     edx, 256 * 32
  998. ;; swap icons
  999.     mov     eax, edx
  1000.     sub     eax, list.lowercased
  1001.     shr     eax, 3
  1002.     add     eax, list.icon
  1003.     push    ebx ecx
  1004.     mov     ebx, [eax]
  1005.     mov     ecx, [eax + 4]
  1006.     mov     [eax], ecx
  1007.     mov     [eax + 4], ebx
  1008.     pop     ecx ebx
  1009.  .next2:
  1010.     add     edx, 32
  1011.     cmpne   edx, esi, .loop2
  1012.  .next1:
  1013.     inc     edi
  1014.     add     ebx, 32
  1015.     cmpne   ebx, ecx, .loop1
  1016.  
  1017.     ret
  1018.  endp
  1019.  
  1020.  ;----------------------
  1021.  
  1022.  dataend:
  1023.  
  1024.  ;===============================
  1025.  
  1026.  skin system_colors
  1027.  list rb 32 * 256
  1028.   .lowercased rd 32 * 256
  1029.   .icon rd 256
  1030.   .size rd 1
  1031.  img  rd 1
  1032.   .rgb rd 1
  1033.   .size rd 1
  1034.   .buf rb 40
  1035.   .sel rb 32 * 32 * 3
  1036.  win:
  1037.   .x rd 1
  1038.   .y rd 1
  1039.  win.title rb 256
  1040.  param_s rd 1
  1041.  param_e rd 1
  1042.  param_a rd 1
  1043.  undefined rb 1
  1044.  buffer  rb 2048
  1045.  buffer2 rb 2048 ;OD
  1046.  buffer3 rb 2048 ;OD
  1047.  buffer4 rb 2048 ;OD
  1048.  buffer5 rb 2048 ;OD
  1049.  buffer6 rb 2048 ;check existance
  1050.  buffer7 rb 32   ;for sorting
  1051.  buffer8 rd 2048
  1052.  params rb 2048
  1053.  _stack rb 2048
  1054.  memory:
  1055.