From 31d9c4a476fffd281a765b3c6c44117d8471098e Mon Sep 17 00:00:00 2001 From: eAndrew Date: Wed, 11 Feb 2015 20:41:46 +0000 Subject: [PATCH] Add @open to svn git-svn-id: svn://kolibrios.org@5394 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/Tupfile.lua | 2 + data/common/settings/assoc.ini | 109 +++++ programs/string.inc | 210 +++++++++ programs/system/open/Tupfile.lua | 2 + programs/system/open/macros.inc | 47 ++ programs/system/open/open.asm | 756 +++++++++++++++++++++++++++++++ 6 files changed, 1126 insertions(+) create mode 100644 data/common/settings/assoc.ini create mode 100644 programs/string.inc create mode 100644 programs/system/open/Tupfile.lua create mode 100644 programs/system/open/macros.inc create mode 100644 programs/system/open/open.asm diff --git a/data/Tupfile.lua b/data/Tupfile.lua index 6afc1eec00..e40ed79c1f 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -40,6 +40,7 @@ img_files = { {"SETTINGS/KOLIBRI.LBL", build_type .. "/settings/kolibri.lbl"}, {"SETTINGS/PANEL.INI", build_type .. "/settings/panel.ini"}, {"SETTINGS/DOCKY.INI", "common/settings/docky.ini"}, + {"SETTINGS/ASSOC.INI", "common/settings/assoc.ini"}, {"NOTIFY3.PNG", "common/notify3.png"}, {"SETTINGS/SETUP.DAT", build_type .. "/settings/setup.dat"}, {"VMODE", "common/vmode"}, @@ -234,6 +235,7 @@ tup.append_table(img_files, { {"@MENU", PROGS .. "/system/menu/trunk/menu"}, {"@PANEL", PROGS .. "/system/panel/trunk/@PANEL"}, {"@DOCKY", PROGS .. "/system/docky/trunk/docky"}, + {"@OPEN", PROGS .. "/system/open/open"}, {"@NOTIFY", PROGS .. "/system/notify3/notify"}, {"@SS", PROGS .. "/system/ss/trunk/@ss"}, {"REFRSCRN", PROGS .. "/system/refrscrn/refrscrn"}, diff --git a/data/common/settings/assoc.ini b/data/common/settings/assoc.ini new file mode 100644 index 0000000000..c63d1f2bf3 --- /dev/null +++ b/data/common/settings/assoc.ini @@ -0,0 +1,109 @@ +[TinyPad] +exec=/sys/tinypad +icon=9 + +[WebView] +exec=/sys/network/webview +icon=31 + +[TextEditor] +exec=/sys/develop/t_edit + +[KIV] +exec=/sys/media/kiv + +[Animage] +exec=/sys/media/animage +icon=15 + +[AC97snd] +exec=/sys/media/ac97snd + +[ListPlay] +exec=/sys/media/listplay + +[MidAMP] +exec=/sys/media/midamp + +[RTFRead] +exec=/sys/rtfread + +[Graph] +exec=/sys/graph +icon=28 + +[HeEd] +exec=/sys/develop/heed +icon=22 + +[Shell] +exec=/sys/shell +icon=2 + +[KPack] +exec=/sys/kpack +icon=10 + +[cObj] +exec=/sys/develop/cObj + +[Assoc] +/=/sys/file managers/eolite + +txt=$TinyPad +asm=$TinyPad +inc=$TinyPad +ini=$TinyPad +log=$TinyPad +inf=$TinyPad +conf=$TinyPad + +htm=$WebView +html=$WebView +mht=$WebView +fb2=$WebView + +gif=$KIV +tga=$KIV +ico=$KIV +cur=$KIV +pcx=$KIV +xcf=$KIV +pbm=$KIV +pgm=$KIV +pnm=$KIV +png=$KIV +jpg=$KIV +jpeg=$KIV +tif=$KIV +tiff=$KIV +wbmp=$KIV +bmp=$KIV + +wav=$AC97snd +xm=$AC97snd +m3u=$AC97snd + +lap=$ListPlay +asf=$ListPlay + +mid=$MidAMP +midi=$MidAMP + +rtf=$RTFRead + +grf=$Graph + +obj=$cObj + +raw=$HeEd + +sh=$Shell +shell=$Shell +bat=$Shell +cmd=$Shell + +skn=/sys/desktop +3ds=/sys/3d/view3ds +lif=/sys/demos/life2 +kla=/sys/games/klavisha \ No newline at end of file diff --git a/programs/string.inc b/programs/string.inc new file mode 100644 index 0000000000..bc18263636 --- /dev/null +++ b/programs/string.inc @@ -0,0 +1,210 @@ + proc string.length uses ebx, _str + mov eax, 0 + mov ebx, [_str] + @@: + cmp [ebx], byte 0 + je @f + inc eax + inc ebx + jmp @b + @@: + ret + endp + + proc string.copy uses eax ebx ecx, _src, _dst + mov eax, [_src] + mov ebx, [_dst] + @@: + mov cl, [eax] + mov [ebx], cl + cmp cl, 0 + je @f + inc eax + inc ebx + jmp @b + @@: + ret + endp + + proc string.concatenate uses eax, _src, _dst + stdcall string.length, [_dst] + add eax, [_dst] + stdcall string.copy, [_src], eax + ret + endp + + proc string.compare uses ebx ecx edx, _str1, _str2 + mov eax, 0 + mov ebx, [_str1] + mov ecx, [_str2] + @@: + mov dl, [ebx] + cmp dl, [ecx] + jne .not_eq + cmp dl, 0 + je @f + cmp [ecx], byte 0 + je @f + inc ebx + inc ecx + jmp @b + .not_eq: + mov eax, -1 + @@: + inc eax + ret + endp + + proc string.to_lower_case uses eax, _str + mov eax, [_str] + @@: + cmp [eax], byte 0 + je @f + cmp [eax], byte 65 + jl .next + cmp [eax], byte 90 + jg .next + add [eax], byte 97 - 65 + .next: + inc eax + jmp @b + @@: + ret + endp + + proc string.to_upper_case uses eax, _str + mov eax, [_str] + @@: + cmp [eax], byte 0 + je @f + cmp [eax], byte 97 + jl .next + cmp [eax], byte 122 + jg .next + sub [eax], byte 97 - 65 + .next: + inc eax + jmp @b + @@: + ret + endp + + proc string.match uses ebx ecx edx, _str1, _str2 + mov ebx, [_str1] + mov ecx, [_str2] + @@: + cmp [ebx], byte 0 + je @f + cmp [ecx], byte 0 + je @f + + mov dl, [ebx] + cmp [ecx], byte '?' + je .next + cmp [ecx], byte '*' + je .next_ebx + cmp [ecx], dl + je .next + + cmp [ecx - 1], byte '*' + je .next_ecx + + jmp @f + + .next_ecx: + dec ecx + jmp .next + .next_ebx: + dec ebx + .next: + inc ebx + inc ecx + jmp @b + @@: + + @@: + cmp [ecx], byte 0 + je @f + cmp [ecx], byte '*' + jne @f + inc ecx + jmp @b + @@: + + cmp [ecx], byte 0 + je @f + mov eax, 0 + ret + @@: + mov eax, 1 + ret + endp + + proc string.trim_last uses eax, _str + stdcall string.length, [_str] + add eax, [_str] + dec eax + @@: + cmp [eax], byte ' ' + jne @f + mov [eax], byte 0 + dec eax + jmp @b + @@: + ret + endp + + proc string.trim_first, _str + mov eax, [_str] + @@: + cmp [eax], byte ' ' + jne @f + inc eax + jmp @b + @@: + ret + endp + + proc string.index_of uses ebx ecx, _str, _char, _num + mov ebx, [_char] + mov ecx, [_str] + mov eax, 0 + @@: + cmp [ecx], byte 0 + je @f + cmp [ecx], bl + jne .after_check + dec [_num] + jz .finded + .after_check: + inc ecx + inc eax + jmp @b + @@: + mov eax, -1 + .finded: + ret + endp + + proc string.last_index_of uses ebx ecx, _str, _char, _num + stdcall string.length, [_str] + mov ecx, [_str] + add ecx, eax + mov ebx, [_char] + @@: + cmp eax, 0 + je @f + cmp [ecx], bl + jne .after_check + dec [_num] + jz .finded + .after_check: + dec ecx + dec eax + jmp @b + @@: + mov eax, -2 + .finded: + inc eax + ret + endp \ No newline at end of file diff --git a/programs/system/open/Tupfile.lua b/programs/system/open/Tupfile.lua new file mode 100644 index 0000000000..6f66d69273 --- /dev/null +++ b/programs/system/open/Tupfile.lua @@ -0,0 +1,2 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +tup.rule("open.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "open") diff --git a/programs/system/open/macros.inc b/programs/system/open/macros.inc new file mode 100644 index 0000000000..a5ea74720e --- /dev/null +++ b/programs/system/open/macros.inc @@ -0,0 +1,47 @@ +macro cmpe a, b, c +{ + cmp a, b + je c +} + +macro cmpne a, b, c +{ + cmp a, b + jne c +} + +macro cmpg a, b, c +{ + cmp a, b + jg c +} + +macro cmpl a, b, c +{ + cmp a, b + jl c +} + +macro cmpnl a, b, c +{ + cmp a, b + jnl c +} + +macro cmpng a, b, c +{ + cmp a, b + jng c +} + +macro cmpge a, b, c +{ + cmp a, b + jge c +} + +macro cmple a, b, c +{ + cmp a, b + jle c +} \ No newline at end of file diff --git a/programs/system/open/open.asm b/programs/system/open/open.asm new file mode 100644 index 0000000000..69cdbd106e --- /dev/null +++ b/programs/system/open/open.asm @@ -0,0 +1,756 @@ + DEBUG equ 0 + + LIST_WIDTH equ 256 + WIN_WIDTH equ (LIST_WIDTH + 16 + 12) + LIST_SIZE equ 12 + LINE_SIZE equ 40 + LIST_HEIGHT equ (LIST_SIZE * LINE_SIZE / 2) + WIN_HEIGHT equ (LIST_HEIGHT + 80) + + use32 + org 0 + db 'MENUET01' + dd 1, main, dataend, memory, memory, params, 0 + + include "../../proc32.inc" + include "../../macros.inc" + include "../../dll.inc" + include "../../string.inc" + include "../../develop/libraries/box_lib/trunk/box_lib.mac" + + include "lang.inc" + +if DEBUG eq 1 + include "../../debug.inc" +end if + + include "macros.inc" + + ;=============================== + +if lang eq ru + title db "Открыть с помощью", 0 + browse_txt db "Обзор...", 0 + notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0 + checkbox_txt db "Использовать всегда", 0 +else if lang eq et + title db "Open with", 0 + browse_txt db "Browse...", 0 + notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0 + checkbox_txt db "Always use selected program", 0 +else if lang eq it + title db "Open with", 0 + browse_txt db "Browse...", 0 + notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0 + checkbox_txt db "Always use selected program", 0 +else + title db "Open with", 0 + browse_txt db "Browse...", 0 + notify_txt db "'Incorrect ", '"', "/sys/settings/assoc.ini", '"', " file' -tE", 0 + checkbox_txt db "Always use selected program", 0 +end if + + sys_dir db "/sys", 0 + slash db "/", 0 + open_dialog_path db "/sys/file managers/opendial", 0 + app_link db "$", 0 + icons db "/sys/iconstrp.png", 0 + communication_area_name db "FFFFFF_open_dialog", 0 + assoc_ini db "/sys/settings/assoc.ini", 0 + .sec db "Assoc", 0 + .exec db "exec", 0 + .icon db "icon", 0 + + sb_apps scrollbar \ + 13, WIN_WIDTH - 25, LIST_HEIGHT, 10 + 12, \ ;; w, x, h, y + 0, 0, LIST_SIZE / 2, 0, \ ;; b.h, max, area, pos + 0, 0, 0, 2 + + cb_always check_box2 \ + 3 shl 16 + 10, (LIST_HEIGHT + 35) shl 16 + 10, 6, 0, 0, 0, checkbox_txt, ch_flag_middle + + opendialog: + .type dd 0 + .procinfo dd buffer3 + .com_area_name dd communication_area_name + .com_area dd 0 + .opendir_path dd buffer4 + .dir_default_path dd sys_dir + .start_path dd open_dialog_path + .draw_window dd draw_window + .status dd 0 + .openfile_pach dd buffer + .filename_area dd buffer5 + .filter_area dd .filter + .x: + .x_size dw 420 + .x_start dw 200 + .y: + .y_size dw 320 + .y_start dw 120 + + .filter dd 0 + + ps_addres: + dd 0 ;; type + dw 7 ;; y + dw 4 ;; x + dw 6 ;; font.w + dw LIST_WIDTH ;; w + dd 0 ;; mono + dd 0 ;; without bg + .color dd 0 ;; text color + dd 0 ;; bg color + .txt dd 0 ;; text + dd buffer2 + dd 0 + + is_execute: + dd 7, 0, 0, 0, 0 + db 0 + dd buffer + + is_openas: + dd 7, 0, 0, 0, 0 + db 0 + dd buffer + + is_open: + dd 7, 0, 0, 0, 0 + db 0 + dd buffer + + is_undefined: + dd 7, 0, notify_txt, 0, 0 + db "/sys/@notify", 0 + + is_openimg_info: + dd 5, 0, 0, 0, img.buf + db 0 + dd icons + + is_openimg: + dd 0, 0, 0, 0, 0 + db 0 + dd icons + + last_x dd -1 + last_y dd -1 + +if DEBUG eq 1 + std_param db "~/sys/settings/assoc.ini", 0 +end if + + imports: + library libini, "libini.obj" + import libini, libini.get_str, "ini_get_str", \ + libini.set_str, "ini_set_str", \ + libini.get_num, "ini_get_int", \ + libini.for_each_section, "ini_enum_sections" + + imports_add: + library libimg, "libimg.obj", \ + boxlib, "box_lib.obj", \ + prclib, "proc_lib.obj" + import libimg, libimg.init, "lib_init", \ + libimg.toRGB, "img_to_rgb2", \ + libimg.decode, "img_decode", \ + libimg.destroy, "img_destroy" + import boxlib, scrollbar.draw, "scrollbar_v_draw", \ + scrollbar.mouse, "scrollbar_v_mouse", \ + pathshow.init, "PathShow_prepare", \ + pathshow.draw, "PathShow_draw", \ + checkbox.init, "init_checkbox2", \ + checkbox.draw, "check_box_draw2", \ + checkbox.mouse, "check_box_mouse2" + import prclib, opendialog.lib_init, "lib_init", \ + opendialog.init, "OpenDialog_init", \ + opendialog.start, "OpenDialog_start" + + ;=============================== + + main: + mcall 68, 11 + stdcall dll.Load, imports + +if DEBUG eq 1 + stdcall string.copy, std_param, params +end if + + ;; trim params + stdcall string.trim_last, params + stdcall string.trim_first, params + mov [param_s], eax + + ;; if empty - exit + cmpe [eax], byte 0, exit + + ;; if folder + stdcall string.length, [param_s] + add eax, [param_s] + cmpe [eax - 1], byte '/', open + + ;; if dialog + mov eax, [param_s] + mov [is_openas + 8], eax + cmpne [eax], byte '~', @f + inc [param_s] + mov eax, [param_s] + mov [is_openas + 8], eax + jmp start_dialog + @@: + + ;; if without '.' - execute + stdcall string.last_index_of, [param_s], '.', 1 + cmpe eax, -1, execute + + ;; if '.' is part of path - execute + mov esi, eax + stdcall string.last_index_of, [param_s], '/', 1 + cmpg eax, esi, execute + + ;; if ext == "kex" - execute + add esi, [param_s] + mov [param_e], esi + cmpe [esi], dword "kex", execute + + open_as: + invoke libini.get_str, assoc_ini, assoc_ini.sec, esi, buffer, 2048, undefined + cmpe [buffer], byte 0, start_dialog_pre + cmpne [buffer], byte "$", @f + invoke libini.get_str, assoc_ini, buffer + 1, assoc_ini.exec, buffer, 2048, undefined + cmpe [buffer], byte 0, ini_error + @@: + mcall 70, is_openas + jmp exit + + execute: + mov eax, [param_s] + mov [is_execute + 21], eax + mcall 70, is_execute + jmp exit + + open: + invoke libini.get_str, assoc_ini, assoc_ini.sec, slash, buffer, 2048, undefined + cmpe [buffer], byte 0, ini_error + mov eax, [param_s] + mov [is_open + 8], eax + mcall 70, is_open + jmp exit + + ini_error: + mcall 70, is_undefined + jmp exit + + ;---------------------- + + start_dialog_pre: + or [cb_always.flags], ch_flag_en + + start_dialog: + stdcall dll.Load, imports_add + invoke opendialog.lib_init + + mcall 40, 100111b + + ;; get title + stdcall string.copy, title, win.title + + ;; get positions + mcall 14 + movzx ebx, ax + shr ebx, 1 + shr eax, 16 + 1 + sub eax, WIN_WIDTH / 2 - 1 + sub ebx, WIN_HEIGHT / 2 - 1 + mov [win.x], eax + mov [win.y], ebx + + ;; get colors + mcall 48, 3, skin, 192 + + ;; get opendialog + invoke opendialog.init, opendialog + + ;; get pathshow + mov eax, [param_s] + mov ebx, [skin.win_text] + mov [ps_addres.txt], eax + mov [ps_addres], ebx + invoke pathshow.init, ps_addres + + ;; get checkbox + mov eax, [skin.gui_face] + mov ebx, [skin.gui_fcframe] + mov ecx, [skin.win_text] + mov [cb_always.color], eax + mov [cb_always.border_color], ebx + mov [cb_always.text_color], ecx + invoke checkbox.init, cb_always + + ;; get list + invoke libini.for_each_section, assoc_ini, section_cb + mov eax, [sb_apps.max_area] + and eax, 1b + shr [sb_apps.max_area], 1 + add [sb_apps.max_area], eax + + mov eax, [skin.gui_face] + mov ebx, [skin.3d_face] + mov [sb_apps.bg_color], eax + mov [sb_apps.front_color], ebx + mov [sb_apps.line_color], ebx + + ;; get icons + mcall 70, is_openimg_info + mov edx, dword [img.buf + 32] + shl edx, 4 + stdcall mem.Alloc, edx + mov [img.rgb], eax + + mov [is_openimg + 12], edx + m2m dword[is_openimg + 16], dword[img.rgb] + mcall 70, is_openimg + + invoke libimg.decode, dword[img.rgb], ebx, 0 + mov [img], eax + + ;; alpha + mov edi, [eax + 8] + shl edi, 7 + sub edi, 4 + mov eax, [eax + 24] + .setalpha: + mov ebx, [eax + edi] + shr ebx, 24 + cmpne ebx, 0, @f + mov ecx, [skin.gui_face] + mov [eax + edi], ecx + @@: + cmpe edi, 0, @f + sub edi, 4 + jmp .setalpha + @@: + + invoke libimg.toRGB, [img], [img.rgb] + invoke libimg.destroy, [img] + + ;---------------------- + + update: + mcall 10 + cmpe eax, EV_REDRAW, event_redraw + cmpe eax, EV_KEY, event_key + cmpe eax, EV_BUTTON, event_button + cmpe eax, EV_MOUSE, event_mouse + jmp update + + ;---------------------- + + event_redraw: + call draw_window + jmp update + + ;---------------------- + + event_key: + mcall 2 + cmpe ah, 27, exit + +; cmpe ah, 179, .go_right +; cmpe ah, 176, .go_left +; cmpe ah, 178, .go_up +; cmpe ah, 177, .go_down +; jmp update +; +; .go_right: +; jmp update +; +; .go_left: +; jmp update +; +; .go_up: +; jmp update +; +; .go_down: +; stdcall draw_item, [last_x], [last_y], 0 +; +; cmpne [last_x], -1, @f +; mov [last_x], 0 +; @@: +; +; cmpne [last_y], LIST_SIZE / 2 - 1, @f +; mov eax, [sb_apps.position] +; add eax, LIST_SIZE / 2 +; shl eax, 1 +; cmpge eax, [list.size], .pre +; inc [sb_apps.position] +; stdcall draw_list +; invoke scrollbar.draw, sb_apps +; jmp update +; .pre: +; dec [last_y] +; @@: +; +; inc [last_y] +; stdcall draw_item, [last_x], [last_y], 1 + jmp update + + ;---------------------- + + event_button: + mcall 17 + cmpe ah, 1, exit + cmpe ah, 2, .opendialog + + .fromlist: + movzx ebx, ah + sub ebx, 10 + mov ecx, [sb_apps.position] + shl ecx, 1 + add ebx, ecx + shl ebx, 5 + add ebx, list + cmpe [ebx], byte 0, update + mov [param_a], ebx + invoke libini.get_str, assoc_ini, ebx, assoc_ini.exec, buffer, 256, undefined + cmpe [buffer], byte 0, ini_error + mcall 70, is_openas + mov edi, 1 + + .save_assoc: + mov eax, [cb_always.flags] + and eax, ch_flag_en + cmpe eax, 0, exit + + cmpe edi, 0, @f + stdcall string.copy, app_link, buffer + stdcall string.concatenate, [param_a], buffer + @@: + + invoke libini.set_str, assoc_ini, assoc_ini.sec, [param_e], buffer, 33 + jmp exit + + .opendialog: + invoke opendialog.start, opendialog + cmpne [opendialog.status], 1, update + mcall 70, is_openas + mov edi, 0 + jmp .save_assoc + + ;---------------------- + + event_mouse: + invoke checkbox.mouse, cb_always + mov edi, [sb_apps.position] + invoke scrollbar.mouse, sb_apps + sub edi, [sb_apps.position] + jz @f + call draw_list + @@: + + mcall 37, 1 + movzx edi, ax + shr eax, 16 + mov esi, eax + sub esi, 4 + sub edi, 10 + 12 + cmpl esi, 0, .out + cmpge esi, LIST_WIDTH, .out + cmpl edi, 0, .out + cmpge edi, LIST_HEIGHT, .out + + mcall 37, 7 + and eax, 0xFFFF + cmpe eax, 65535, .scroll_up + cmpe eax, 0, @f + + .scroll_down: + mov eax, [sb_apps.position] + add eax, LIST_SIZE / 2 + shl eax, 1 + cmpge eax, [list.size], @f + inc [sb_apps.position] + stdcall draw_list + invoke scrollbar.draw, sb_apps + jmp update + + .scroll_up: + cmpe [sb_apps.position], 0, @f + dec [sb_apps.position] + stdcall draw_list + invoke scrollbar.draw, sb_apps + jmp update + + @@: + + mov eax, esi + mov ebx, LIST_WIDTH / 2 + mov edx, 0 + div ebx + mov esi, eax + + mov eax, edi + mov ebx, LINE_SIZE + mov edx, 0 + div ebx + mov edi, eax + + cmpne esi, [last_x], .redraw + cmpne edi, [last_y], .redraw + jmp @f + + .redraw: + stdcall draw_item, [last_x], [last_y], 0 + mov [last_x], esi + mov [last_y], edi + stdcall draw_item, esi, edi, 1 + jmp @f + + .out: + cmpe [last_x], -1, @f + stdcall draw_item, [last_x], [last_y], 0 + mov [last_x], -1 + mov [last_y], -1 + @@: + + jmp update + + ;---------------------- + + exit: + mcall -1 + + ;---------------------- + + proc draw_window + mcall 12, 1 + + mov edx, [skin.win_face] + or edx, 0x34 shl 24 + mcall 0, <[win.x], WIN_WIDTH>, <[win.y], WIN_HEIGHT>, , , win.title + stdcall draw_list + invoke scrollbar.draw, sb_apps + invoke pathshow.draw, ps_addres + invoke checkbox.draw, cb_always + + mcall 13, <207, 66>, , [skin.btn_frame] + mcall 8, <208, 63>, , 2, [skin.btn_face] +; + mov ecx, [skin.btn_text] + add ecx, 0x80 shl 24 + mcall 4, <214, LIST_HEIGHT + 37>, , browse_txt + + ;; buttons + mov eax, 8 + mov ebx, 4 shl 16 + LIST_WIDTH / 2 + mov ecx, (10 + 12) shl 16 + LINE_SIZE - 1 + mov edx, 0x60 shl 24 + 10 + mov edi, LIST_SIZE + mov esi, 0 + @@: + cmpe edi, 0, @f + mcall + + cmpe esi, 0, .doA + .doB: + sub ebx, LIST_WIDTH shl 16 + add ecx, LINE_SIZE shl 16 + .doA: + add ebx, (LIST_WIDTH / 2) shl 16 + sub ecx, LINE_SIZE shl 16 + + not esi + add ecx, LINE_SIZE shl 16 + inc edx + dec edi + jmp @b + @@: + + mcall 12, 2 + ret + endp + + ;---------------------- + + proc draw_list + mcall 13, <3, LIST_WIDTH + 2 + 12>, <9 + 12, 1>, [skin.gui_fcframe] + mcall , , + mcall , <3, 1>, <9 + 12, LIST_HEIGHT + 1> + mcall , <3 + LIST_WIDTH + 12 + 1, 1> + mcall , <4, LIST_WIDTH>, <10 + 12, LIST_HEIGHT>, [skin.gui_face] + + mov esi, 1 + mov edi, LIST_SIZE / 2 - 1 + .draw_loop: + mov edx, 0 + cmpne [last_x], esi, @f + cmpne [last_y], edi, @f + mov edx, 1 + @@: + stdcall draw_item, esi, edi, edx + dec esi + cmpne esi, -1, @f + mov esi, 1 + dec edi + @@: + cmpne edi, -1, .draw_loop + + ret + endp + + ;---------------------- + + proc draw_item uses edx edi esi, _x, _y, _sel + ;; get index + mov edi, [_y] + shl edi, 1 + add edi, [_x] + mov esi, [sb_apps.position] + shl esi, 1 + add edi, esi + + cmpge edi, [list.size], .break + + ;; background + mov ebx, [_x] + shl ebx, 7 + 16 + add ebx, 4 shl 16 + LIST_WIDTH / 2 + + imul ecx, [_y], LINE_SIZE + shl ecx, 16 + add ecx, (10 + 12) shl 16 + LINE_SIZE + + mov edx, [skin.gui_face] + cmpe [_sel], 0, @f + mov edx, [skin.gui_fcframe] + @@: + mcall 13 + + ;; shadows + push ecx + cmpe [_sel], 1, .after_shadows + mov edx, [skin.3d_face] + + cmpne [_x], 0, @f + imul ecx, [_y], LINE_SIZE + shl ecx, 16 + add ecx, (10 + 12) shl 16 + LINE_SIZE + mcall , <4, 1> + @@: + + cmpne [_y], 0, @f + imul ebx, [_x], LIST_WIDTH / 2 + shl ebx, 16 + add ebx, 4 shl 16 + LIST_WIDTH / 2 + mcall , , <10 + 12, 1> + @@: + + .after_shadows: + pop ecx + + ;; icon + and ebx, 0xFFFF shl 16 + shr ecx, 16 + add ecx, ebx + mov edx, ecx + add edx, 6 shl 16 + (LINE_SIZE - 32) / 2 + + mov ebx, edi + shl ebx, 2 + mov ebx, [ebx + list.icon] + imul ebx, 32 * 32 * 3 + add ebx, [img.rgb] + cmpe [_sel], 0, .draw_icon + .selected: + mov eax, img.sel + mov ecx, 32 * 32 + push edx + @@: + mov edx, [ebx] + and edx, 0xFFFFFF + cmpne edx, [skin.gui_face], .not + mov edx, [skin.gui_fcframe] + .not: + mov [eax], edx + add eax, 3 + add ebx, 3 + dec ecx + jnz @b + pop edx + mov ebx, img.sel + + .draw_icon: + mcall 7, , <32, 32> + + ;; text + mov ebx, edx + add ebx, (32 + 6) shl 16 + 32 / 2 - 9 / 2 + + mov ecx, [skin.gui_text] + cmpe [_sel], 0, @f + mov ecx, [skin.gui_fctext] + @@: + add ecx, 0x80 shl 24 + + mov edx, edi + shl edx, 5 + add edx, list + + mcall 4 + + .break: + ret + endp + + ;---------------------- + + proc section_cb, _file, _sec + mov ebx, [list.size] + shl ebx, 5 + add ebx, list + stdcall string.compare, [_sec], assoc_ini.sec + cmpe eax, 1, @f + stdcall string.copy, [_sec], ebx + invoke libini.get_num, [_file], [_sec], assoc_ini.icon, 0 + mov ecx, [list.size] + shl ecx, 2 + mov [ecx + list.icon], eax + inc [list.size] + inc [sb_apps.max_area] + @@: + mov eax, 1 + ret + endp + + ;---------------------- + + dataend: + + ;=============================== + + skin sys_colors_new + list rb 32 * 256 + .icon rd 256 + .size rd 1 + img rd 1 + .rgb rd 1 + .size rd 1 + .buf rb 40 + .sel rb 32 * 32 * 3 + win: + .x rd 1 + .y rd 1 + win.title rb 256 + param_s rd 1 + param_e rd 1 + param_a rd 1 + undefined rb 1 + buffer rb 2048 + buffer2 rb 2048 + buffer3 rb 2048 + buffer4 rb 4096 + buffer5 rb 4096 + params rb 2048 + _stack rb 2048 + memory: \ No newline at end of file