Subversion Repositories Kolibri OS

Rev

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