Subversion Repositories Kolibri OS

Rev

Rev 7217 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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