Subversion Repositories Kolibri OS

Rev

Rev 5907 | Rev 5913 | 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.   @@:
  433.     cmpe    byte [ebx], 0, @f
  434.  
  435.     movzx   edx, byte [ebx]
  436.     stdcall downcase_char, edx
  437.     cmpne   ah, al, .next
  438.     stdcall set_index, ecx
  439.     stdcall draw_list
  440.     jmp     update
  441.  
  442.  .next:
  443.     inc     ecx
  444.     add     ebx, 32
  445.     jmp     @b
  446.   @@:
  447.     jmp     update
  448.  
  449.  .toggle_cb:
  450.     mov     eax, [cb_always.flags]
  451.     mov     ebx, eax
  452.     and     ebx, ch_flag_en
  453.     cmpe    ebx, 0, @f
  454.     sub     eax, ch_flag_en
  455.     jmp     .toggle_cb.redraw
  456.   @@:
  457.     add     eax, ch_flag_en
  458.  .toggle_cb.redraw:
  459.     mov     [cb_always.flags], eax
  460.     invoke  checkbox.draw, cb_always
  461.     jmp     update
  462.  
  463.  .go_right:
  464.     mov     esi, 1
  465.     jmp     .go_anyway
  466.  
  467.  .go_left:
  468.     mov     esi, -1
  469.     jmp     .go_anyway
  470.  
  471.  .go_up:
  472.     mov     esi, -2
  473.     jmp     .go_anyway
  474.  
  475.  .go_down:
  476.     mov     esi, 2
  477.  
  478.  .go_anyway:
  479. ;; HIDE OLD SELECTION
  480.     stdcall draw_item, [last_x], [last_y], 0
  481.  
  482. ;; [X, Y] -> INDEX
  483.     stdcall get_index
  484.  
  485. ;; CHANGE INDEX
  486.     add     eax, esi
  487.  
  488.     cmpl    eax, [list.size], @f
  489.     mov     eax, [list.size]
  490.     dec     eax
  491.   @@:
  492.  
  493.     cmpge   eax, 0, @f
  494.     mov     eax, 0
  495.   @@:
  496.  
  497. ;; INDEX -> [X, Y]
  498.     stdcall set_index, eax
  499.     cmpe    eax, 1, @f
  500.  
  501. ;; PARTLY REDRAW
  502.     stdcall draw_item, [last_x], [last_y], 1
  503.     jmp     update
  504.  
  505. ;; FULL REDRAW
  506.   @@:
  507.     stdcall draw_list
  508.     jmp     update
  509.  
  510.  ;----------------------
  511.  
  512.  event_button:
  513.     mcall   17
  514.     cmpe    ah, 1, exit
  515.     cmpe    ah, 2, .opendialog
  516.     jmp     list_item_activate
  517.  
  518.  .opendialog:
  519.     invoke  opendialog.start, opendialog
  520.     cmpne   [opendialog.status], 1, update
  521.     mcall   70, is_openas
  522.  
  523.     mov     edi, 0
  524.     jmp     save_assoc
  525.  
  526.  ;----------------------
  527.  
  528.  list_item_activate:
  529.     stdcall get_index
  530.     shl     eax, 5
  531.     add     eax, list
  532.     cmpe    byte [eax], 0, update
  533.     mov     [param_a], eax
  534.     invoke  libini.get_str, assoc_ini, eax, assoc_ini.exec, buffer, 256, undefined
  535.     cmpe    byte [buffer], 0, ini_error
  536.     mcall   70, is_openas
  537.  
  538.     mov     edi, 1
  539.     jmp     save_assoc
  540.  
  541.  ;----------------------
  542.  
  543.  save_assoc:
  544.     mov     eax, [cb_always.flags]
  545.     and     eax, ch_flag_en
  546.     cmpe    eax, 0, exit
  547.  
  548.     cmpe    edi, 0, @f
  549.     stdcall string.copy, app_link, buffer
  550.     stdcall string.concatenate, [param_a], buffer
  551.   @@:
  552.  
  553.     invoke  libini.set_str, assoc_ini, assoc_ini.sec, [param_e], buffer, 33
  554.     jmp     exit
  555.  
  556.  ;----------------------
  557.  
  558.  event_mouse:
  559.     invoke  checkbox.mouse, cb_always
  560.     mov     edi, [sb_apps.position]
  561.     invoke  scrollbar.mouse, sb_apps
  562.     sub     edi, [sb_apps.position]
  563.     jz      @f
  564.     call    draw_list
  565.   @@:
  566.  
  567.     mcall   37, 1
  568.     movzx   edi, ax
  569.     shr     eax, 16
  570.     mov     esi, eax
  571.     sub     esi, 4
  572.     sub     edi, 10 + 12
  573.     cmpl    esi, 0, .out
  574.     cmpge   esi, LIST_WIDTH, .out
  575.     cmpl    edi, 0, .out
  576.     cmpge   edi, LIST_HEIGHT, .out
  577.  
  578.     mcall   37, 7
  579.     and     eax, 0xFFFF
  580.     cmpe    eax, 65535, .scroll_up
  581.     cmpe    eax, 0, @f
  582.  
  583.  .scroll_down:
  584.     mov     eax, [sb_apps.position]
  585.     add     eax, LIST_SIZE / 2
  586.     shl     eax, 1
  587.     cmpge   eax, [list.size], @f
  588.     inc     [sb_apps.position]
  589.     stdcall draw_list
  590.     jmp     update
  591.  
  592.  .scroll_up:
  593.     cmpe    [sb_apps.position], 0, @f
  594.     dec     [sb_apps.position]
  595.     stdcall draw_list
  596.     jmp     update
  597.  
  598.   @@:
  599.  
  600.     mov     eax, esi
  601.     mov     ebx, LIST_WIDTH / 2
  602.     mov     edx, 0
  603.     div     ebx
  604.     mov     esi, eax
  605.  
  606.     mov     eax, edi
  607.     mov     ebx, LINE_SIZE
  608.     mov     edx, 0
  609.     div     ebx
  610.     mov     edi, eax
  611.  
  612.     cmpne   esi, [last_x], .redraw
  613.     cmpne   edi, [last_y], .redraw
  614.     jmp     @f
  615.  
  616.  .redraw:
  617.     stdcall draw_item, [last_x], [last_y], 0
  618.     mov     [last_x], esi
  619.     mov     [last_y], edi
  620.     stdcall draw_item, esi, edi, 1
  621.     jmp     @f
  622.  
  623.  .out:
  624.     cmpe    [last_x], -1, @f
  625.     stdcall draw_item, [last_x], [last_y], 0
  626.     mov     [last_x], -1
  627.     mov     [last_y], -1
  628.   @@:
  629.  
  630.     jmp     update
  631.  
  632.  ;----------------------
  633.  
  634.  exit:
  635.     mcall   -1
  636.  
  637.  ;----------------------
  638.  
  639.  proc draw_window
  640.     mcall   12, 1
  641.  
  642.     mov     edx, [skin.work]
  643.     or      edx, 0x34 shl 24
  644.     mcall   0, <[win.x], WIN_WIDTH>, <[win.y], WIN_HEIGHT>, , , win.title
  645.     stdcall draw_list
  646.     invoke  pathshow.draw, ps_addres
  647.     invoke  checkbox.draw, cb_always
  648.  
  649.     mcall   13, <207, 66>, <LIST_HEIGHT + 29, 22>, [skin.work_graph]
  650.     mcall   8, <208, 63>, <LIST_HEIGHT + 30, 19>, 2, [skin.work_button]
  651. ;
  652.     mov     ecx, [skin.work_button_text]
  653.     add     ecx, 0x80 shl 24
  654.     mcall   4, <214, LIST_HEIGHT + 37>, , browse_txt
  655.  
  656.  ;; buttons
  657.     mov     eax, 8
  658.     mov     ebx, 4 shl 16 + LIST_WIDTH / 2
  659.     mov     ecx, (10 + 12) shl 16 + LINE_SIZE - 1
  660.     mov     edx, 0x60 shl 24 + 10
  661.     mov     edi, LIST_SIZE
  662.     mov     esi, 0
  663.   @@:
  664.     cmpe    edi, 0, @f
  665.     mcall
  666.  
  667.     cmpe    esi, 0, .doA
  668.  .doB:
  669.     sub     ebx, LIST_WIDTH shl 16
  670.     add     ecx, LINE_SIZE shl 16
  671.  .doA:
  672.     add     ebx, (LIST_WIDTH / 2) shl 16
  673.     sub     ecx, LINE_SIZE shl 16
  674.  
  675.     not     esi
  676.     add     ecx, LINE_SIZE shl 16
  677.     inc     edx
  678.     dec     edi
  679.     jmp     @b
  680.   @@:
  681.  
  682.     mcall   12, 2
  683.     ret
  684.   endp
  685.  
  686.  ;----------------------
  687.  
  688.  proc draw_list
  689.     mcall   13, <3, LIST_WIDTH + 2 + 12>, <9 + 12, 1>, [skin.work_graph]
  690.     mcall     ,                         , <LIST_HEIGHT + 9 + 1 + 12, 1>
  691.     mcall     , <3, 1>, <9 + 12, LIST_HEIGHT + 1>
  692.     mcall     , <3 + LIST_WIDTH + 12 + 1, 1>
  693.     mcall     , <4, LIST_WIDTH>, <10 + 12, LIST_HEIGHT>, 0xFFFfff
  694.  
  695.     mov     esi, 1
  696.     mov     edi, LIST_SIZE / 2 - 1
  697.  .draw_loop:
  698.     mov     edx, 0
  699.     cmpne   [last_x], esi, @f
  700.     cmpne   [last_y], edi, @f
  701.     mov     edx, 1
  702.   @@:
  703.     stdcall draw_item, esi, edi, edx
  704.     dec     esi
  705.     cmpne   esi, -1, @f
  706.     mov     esi, 1
  707.     dec     edi
  708.   @@:
  709.     cmpne   edi, -1, .draw_loop
  710.  
  711.     invoke  scrollbar.draw, sb_apps
  712.  
  713.     ret
  714.  endp
  715.  
  716.  ;----------------------
  717.  
  718.  proc draw_item uses edx edi esi, _x, _y, _sel
  719.  ;; get index
  720.     stdcall get_index_cur, [_x], [_y]
  721.     mov     edi, eax
  722.  
  723.     cmpge   edi, [list.size], .break
  724.  
  725.  ;; background
  726.     mov     ebx, [_x]
  727.     shl     ebx, 7 + 16
  728.     add     ebx, 4 shl 16 + LIST_WIDTH / 2
  729.  
  730.     imul    ecx, [_y], LINE_SIZE
  731.     shl     ecx, 16
  732.     add     ecx, (10 + 12) shl 16 + LINE_SIZE
  733.  
  734.     mov     edx, 0xFFFfff
  735.     cmpe    [_sel], 0, @f
  736.     mov     edx, 0x94AECE
  737.   @@:
  738.     mcall   13
  739.  
  740.  ;; shadows
  741.     push    ecx
  742.     cmpe    [_sel], 1, .after_shadows
  743.     mov     edx, 0xCCCccc ;[skin.3d]
  744.  
  745.     cmpne   [_x], 0, @f
  746.     imul     ecx, [_y], LINE_SIZE
  747.     shl      ecx, 16
  748.     add      ecx, (10 + 12) shl 16 + LINE_SIZE
  749.     mcall     , <4, 1>
  750.   @@:
  751.  
  752.     cmpne   [_y], 0, @f
  753.     imul     ebx, [_x], LIST_WIDTH / 2
  754.     shl      ebx, 16
  755.     add      ebx, 4 shl 16 + LIST_WIDTH / 2
  756.     mcall     , , <10 + 12, 1>
  757.   @@:
  758.  
  759.  .after_shadows:
  760.     pop     ecx
  761.  
  762.  ;; icon
  763.     and     ebx, 0xFFFF shl 16
  764.     shr     ecx, 16
  765.     add     ecx, ebx
  766.     mov     edx, ecx
  767.     add     edx, 6 shl 16 + (LINE_SIZE - 32) / 2
  768.  
  769.     mov     ebx, edi
  770.     shl     ebx, 2
  771.     mov     ebx, [ebx + list.icon]
  772.     imul    ebx, 32 * 32 * 3
  773.     add     ebx, [img.rgb]
  774.     cmpe    [_sel], 0, .draw_icon
  775.  .selected:
  776.     mov     eax, img.sel
  777.     mov     ecx, 32 * 32
  778.     push    edx
  779.   @@:
  780.     mov     edx, [ebx]
  781.     and     edx, 0xFFFFFF
  782.     cmpne   edx, 0xFFFFFF, .not
  783.     mov     edx, 0x94AECE
  784.  .not:
  785.     mov     [eax], edx
  786.     add     eax, 3
  787.     add     ebx, 3
  788.     dec     ecx
  789.     jnz     @b
  790.     pop     edx
  791.     mov     ebx, img.sel
  792.  
  793.  .draw_icon:
  794.     mcall   7, , <32, 32>
  795.  
  796.  ;; text
  797.     mov     ebx, edx
  798.     add     ebx, (32 + 6) shl 16 + 32 / 2 - 9 / 2
  799.  
  800.     mov     ecx, 0x000000 ; inactive item text
  801.     cmpe    [_sel], 0, @f
  802.     mov     ecx, 0x000000 ; active item text
  803.   @@:
  804.     add     ecx, 0x80 shl 24
  805.  
  806.     mov     edx, edi
  807.     shl     edx, 5
  808.     add     edx, list
  809.  
  810.     mcall   4
  811.  
  812.   .break:
  813.     ret
  814.  endp
  815.  
  816.  ;----------------------
  817.  
  818.  proc downcase_char uses ebx, _ch
  819.     mov     ebx, [_ch]
  820.  
  821.     cmpl    bl, "A", @f
  822.     cmpg    bl, "Z", @f
  823.     sub     bl, "A" - "a"
  824.     jmp     .ret
  825.   @@:
  826.  
  827.     cmpl    bl, "€", @f
  828.     cmpg    bl, "Ÿ", @f
  829.     sub     bl, "€" - " "
  830.   @@:
  831.  
  832.  .ret:
  833.     mov     al, bl
  834.     ret
  835.  endp
  836.  
  837.  ;----------------------
  838.  
  839.  proc get_index_cur uses ebx, _x, _y
  840.     mov     eax, [_y]
  841.     shl     eax, 1
  842.     add     eax, [_x]
  843.     mov     ebx, [sb_apps.position]
  844.     shl     ebx, 1
  845.     add     eax, ebx
  846.  
  847.     ret
  848.  endp
  849.  
  850.  ;----------------------
  851.  
  852.  proc get_index
  853.     stdcall get_index_cur, [last_x], [last_y]
  854.     ret
  855.  endp
  856.  
  857.  ;----------------------
  858.  
  859.  proc set_index uses ebx,_index
  860.     mov     eax, [_index]
  861.     mov     ebx, [sb_apps.position]
  862.     shl     ebx, 1
  863.     sub     eax, ebx
  864.  
  865.     mov     ebx, eax
  866.     and     ebx, 1b
  867.     mov     [last_x], ebx
  868.     shr     eax, 1
  869.     mov     [last_y], eax
  870.  
  871.     mov     eax, 0
  872.  
  873.     cmpl    [last_y], 0xFFFF, @f
  874.     mov     [last_y], 0
  875.     dec     [sb_apps.position]
  876.     mov     eax, 1
  877.     jmp     .exit
  878.   @@:
  879.  
  880.     cmpl    [last_y], LIST_SIZE / 2, @f
  881.     mov     ebx, [last_y]
  882.     sub     ebx, LIST_SIZE / 2 - 1
  883.     mov     [last_y], LIST_SIZE / 2 - 1
  884.     add     [sb_apps.position], ebx
  885.     mov     eax, 1
  886.     jmp     .exit
  887.   @@:
  888.  
  889.  .exit:
  890.     cmpge   [sb_apps.position], 0, @f
  891.     mov     [sb_apps.position], 0
  892.   @@:
  893.  
  894.     ret
  895.  endp
  896.  
  897.  ;----------------------
  898.  
  899.  proc section_cb, _file, _sec
  900.  ;; CHECK IF EXISTS
  901.     invoke  libini.get_str, assoc_ini, [_sec], assoc_ini.exec, buffer, 2048, undefined
  902.     mcall   70, is_file_exists
  903.     cmpe    ebx, -1, .exit
  904.  
  905.     mov     ebx, [list.size]
  906.     shl     ebx, 5
  907.     add     ebx, list
  908.     stdcall string.compare, [_sec], assoc_ini.sec
  909.     cmpe    eax, 1, @f
  910.     stdcall string.copy, [_sec], ebx
  911.     invoke  libini.get_num, [_file], [_sec], assoc_ini.icon, 0
  912.     mov     ecx, [list.size]
  913.     shl     ecx, 2
  914.     mov     [ecx + list.icon], eax
  915.     inc     [list.size]
  916.     inc     [sb_apps.max_area]
  917.   @@:
  918.     mov     eax, 1
  919.   .exit:
  920.     ret
  921.  endp
  922.  
  923.  ;----------------------
  924.  
  925.  proc sort_list
  926.     mov     edi, 0
  927.     mov     ebx, list            ;; i = 0
  928.     imul    ecx, [list.size], 32 ;; i < n - 1
  929.     sub     ecx, 32
  930.     add     ecx, list
  931.  
  932.  .loop1:
  933.     mov     edx, list            ;; j = 0
  934.     mov     esi, [list.size]     ;; j < n - i - 1
  935.     sub     esi, edi
  936.     dec     esi
  937.     imul    esi, 32
  938.     add     esi, list
  939.  .loop2:
  940.     mov     eax, edx
  941.     add     eax, 32
  942.     stdcall string.cmp, edx, eax, 32
  943.     cmpne   eax, 1, .next2
  944. ;; swap names
  945.     mov     eax, edx
  946.     add     eax, 32
  947.     stdcall string.copy, edx, buffer7
  948.     stdcall string.copy, eax, edx
  949.     stdcall string.copy, buffer7, eax
  950. ;; swap icons
  951.     mov     eax, edx
  952.     sub     eax, list
  953.     shr     eax, 3
  954.     add     eax, list.icon
  955.     push    ebx ecx
  956.     mov     ebx, [eax]
  957.     mov     ecx, [eax + 4]
  958.     mov     [eax], ecx
  959.     mov     [eax + 4], ebx
  960.     pop     ecx ebx
  961.  .next2:
  962.     add     edx, 32
  963.     cmpne   edx, esi, .loop2
  964.  .next1:
  965.     inc     edi
  966.     add     ebx, 32
  967.     cmpne   ebx, ecx, .loop1
  968.  
  969.     ret
  970.  endp
  971.  
  972.  ;----------------------
  973.  
  974.  dataend:
  975.  
  976.  ;===============================
  977.  
  978.  skin system_colors
  979.  list rb 32 * 256
  980.   .icon rd 256
  981.   .size rd 1
  982.  img  rd 1
  983.   .rgb rd 1
  984.   .size rd 1
  985.   .buf rb 40
  986.   .sel rb 32 * 32 * 3
  987.  win:
  988.   .x rd 1
  989.   .y rd 1
  990.  win.title rb 256
  991.  param_s rd 1
  992.  param_e rd 1
  993.  param_a rd 1
  994.  undefined rb 1
  995.  buffer  rb 2048
  996.  buffer2 rb 2048 ;OD
  997.  buffer3 rb 2048 ;OD
  998.  buffer4 rb 2048 ;OD
  999.  buffer5 rb 2048 ;OD
  1000.  buffer6 rb 2048 ;check existance
  1001.  buffer7 rb 32   ;for sorting
  1002.  buffer8 rd 2048
  1003.  params rb 2048
  1004.  _stack rb 2048
  1005.  memory:
  1006.