diff --git a/programs/develop/libraries/box_lib/trunk/box_lib.asm b/programs/develop/libraries/box_lib/trunk/box_lib.asm index 015ee66474..d94b6b3e0e 100644 --- a/programs/develop/libraries/box_lib/trunk/box_lib.asm +++ b/programs/develop/libraries/box_lib/trunk/box_lib.asm @@ -1,7 +1,13 @@ -;Libray from Editbox -; SEE YOU File FAQ.txt and HISTORY. Good Like! -;Last Change 13/02/2009 -;;;;;;;;;;;;;;;;;; +;***************************************************************************** +; Box_Lib - library of graphical components +; +; Authors: +; Alexey Teplov aka +; Marat Zakiyanov aka Mario79, aka Mario +; Evtikhov Maxim aka Maxxxx32 +; Eugene Grechnikov aka Diamond +; hidnplayr +;***************************************************************************** format MS COFF @@ -9,40 +15,41 @@ public EXPORTS section '.flat' code readable align 16 include '../../../../macros.inc' -include 'editbox.mac' ;макрос который должен облегчить жизнь :) специально для editbox -include 'checkbox.mac' ;макрос содержит реализацию checkbox -include 'optionbox.mac' ;макрос содержит реализацию optionbox -include 'scrollbar.mac' ;макрос содержит реализацию scrollbar -include 'd_button.mac' ;макрос содержит реализацию dinamic button -include 'menubar.mac' ;макрос содержит реализацию menubar +include 'editbox.mac' ;macro which should make life easier :) specially for editbox +include 'checkbox.mac' ;macro implements checkbox +include 'optionbox.mac' ;macro implements optionbox +include 'scrollbar.mac' ;macro implements scrollbar +include 'd_button.mac' ;macro implements dinamic_button +include 'menubar.mac' ;macro implements menubar +include 'filebrowser.mac' ;macro implements filebrowser ;---------------------------------------------------- ;EditBox ;---------------------------------------------------- align 4 -use_editbox_draw ;макрос расскрывает функцию отображения бокса. +use_editbox_draw ;macro reveals the function of the display. align 4 -use_editbox_key ;макрос расскрывает функцию обработки клавишь. +use_editbox_key ;macro reveals processing function of the keypad. align 4 -use_editbox_mouse ;макрос расскрывает функцию обработки мыши. +use_editbox_mouse ;macro reveals processing function of the mouse. ;---------------------------------------------------- ;CheckBox ;---------------------------------------------------- align 4 -use_checkbox_draw ;макрос расскрывает функцию отображения бокса. +use_checkbox_draw ;macro reveals the function of the display. align 4 -use_checkbox_mouse ;макрос расскрывает функцию обработки мыши. +use_checkbox_mouse ;macro reveals processing function of the mouse. ;-------------------------------------------------- ;radiobutton Group ;-------------------------------------------------- align 4 -use_optionbox_driver ;макросы которые управляют работой бокса ) +use_optionbox_driver ;macro that control the operating modes align 4 -use_optionbox_draw ;макрос расскрывает функцию отображения бокса. +use_optionbox_draw ;macro reveals the function of the display. align 4 -use_optionbox_mouse ;макрос расскрывает функцию обработки мыши. +use_optionbox_mouse ;macro reveals processing function of the mouse. ;-------------------------------------------------- ;scrollbar Group @@ -66,7 +73,11 @@ use_dinamic_button align 4 use_menu_bar - +;-------------------------------------------------- +;filebrowser Group +;-------------------------------------------------- +align 4 +use_file_browser ;-------------------------------------------------- init: ret @@ -110,7 +121,13 @@ EXPORTS: dd sz_Menu_bar_draw, menu_bar.draw dd sz_Menu_bar_mouse, menu_bar.mouse - dd szVersion_menu_bar, 0x00010001 + dd sz_Menu_bar_activate, menu_bar.activate + dd szVersion_menu_bar, 0x00010002 + + dd sz_FileBrowser_draw, fb_draw_panel + dd sz_FileBrowser_mouse, fb_mouse + dd sz_FileBrowser_key, fb_key + dd szVersion_FileBrowser, 0x00010001 dd 0,0 @@ -142,5 +159,10 @@ szVersion_dbutton db 'version_dbutton',0 sz_Menu_bar_draw db 'menu_bar_draw',0 sz_Menu_bar_mouse db 'menu_bar_mouse',0 +sz_Menu_bar_activate db 'menu_bar_activate',0 szVersion_menu_bar db 'version_menu_bar',0 +sz_FileBrowser_draw db 'FileBrowser_draw',0 +sz_FileBrowser_mouse db 'FileBrowser_mouse',0 +sz_FileBrowser_key db 'FileBrowser_key',0 +szVersion_FileBrowser db 'version_FileBrowser',0 \ No newline at end of file diff --git a/programs/develop/libraries/box_lib/trunk/d_button.mac b/programs/develop/libraries/box_lib/trunk/d_button.mac index d946148930..566b18ed23 100644 --- a/programs/develop/libraries/box_lib/trunk/d_button.mac +++ b/programs/develop/libraries/box_lib/trunk/d_button.mac @@ -1,6 +1,6 @@ ;************************************************************** ; Dinamic Button Macro for Kolibri OS -; Copyright (c) 2009, Mario79 +; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ ; names of its contributors may be used to endorse or promote products ; derived from this software without specific prior written permission. ; -; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY +; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY @@ -67,10 +67,10 @@ dinamic_button_exit cmp db_select,dword 2 je .click_2 mov ebx,db_passive_raw - jmp .draw_2 ;@f + jmp .draw_2 .active_1: mov ebx,db_active_raw - jmp .draw_2 ;@f + jmp .draw_2 .click_2: mov ebx,db_click_raw @@: diff --git a/programs/develop/libraries/box_lib/trunk/filebrowser.mac b/programs/develop/libraries/box_lib/trunk/filebrowser.mac new file mode 100644 index 0000000000..5b0da8f16e --- /dev/null +++ b/programs/develop/libraries/box_lib/trunk/filebrowser.mac @@ -0,0 +1,1394 @@ +;***************************************************************************** +; File Browser control for Kolibri OS +; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions are met: +; * Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; * Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; * Neither the name of the nor the +; names of its contributors may be used to endorse or promote products +; derived from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY +; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;***************************************************************************** +;***************************************************************************** +macro file_browser_exit +{ +popa +ret 4 +} +;***************************************************************************** +macro use_file_browser +{ +file_browser: +fb_type equ dword [edi] ;dword +fb_size_x equ [edi+4] ;word +fb_start_x equ [edi+6] ;word +fb_size_y equ [edi+8] ;word +fb_start_y equ [edi+10] ;word +fb_icon_size_y equ word [edi+12] ;word +fb_icon_size_x equ word [edi+14] ;word +fb_line_size_x equ word [edi+16] ;word +fb_line_size_y equ word [edi+18] ;word +fb_type_size_x equ word [edi+20] ;word +fb_size_size_x equ word [edi+22] ;word +fb_date_size_x equ word [edi+24] ;word +fb_attributes_size_x equ word [edi+26] ;word +fb_icon_assoc_area equ dword [edi+28] ;dword +fb_icon_raw_area equ dword [edi+32] ;dword +fb_resolution_raw equ dword [edi+36] ;dword +fb_palette_raw equ dword [edi+40] ;dword +fb_directory_path_area equ dword [edi+44] ;dword +fb_file_name_area equ dword [edi+48] ;dword +fb_select_flag equ dword [edi+52] ;dword +fb_background_color equ dword [edi+56] ;dword +fb_select_color equ dword [edi+60] ;dword +fb_seclect_text_color equ dword [edi+64] ;dword +fb_text_color equ dword [edi+68] ;dword +fb_reduct_text_color equ dword [edi+72] ;dword +fb_marked_text_color equ dword [edi+76] ;dword +fb_max_panel_line equ dword [edi+80] ;dword +fb_select_panel_counter equ dword [edi+84] ;dword +fb_folder_block equ dword [edi+88] ;dword +fb_start_draw_line equ dword [edi+92] ;dword +fb_start_draw_cursor_line equ word [edi+96] ;word +fb_folder_data equ dword [edi+98] ;dword +fb_temp_counter equ dword [edi+102] ;dword +fb_file_name_length equ dword [edi+106] ;dword +fb_marked_file equ dword [edi+110] ;dword +fb_extension_size equ dword [edi+114] ;dword +fb_extension_start equ dword [edi+118] ;dword +fb_type_table equ dword [edi+122] ;dword +fb_ini_file_start equ dword [edi+126] ;dword +fb_ini_file_end equ dword [edi+130] ;dword +fb_draw_scroll_bar equ dword [edi+134] ;dword +fb_font_size_y equ word [edi+138] ;dword +fb_font_size_x equ word [edi+140] ;dword +fb_mouse_keys equ dword [edi+142] ;dword +fb_mouse_keys_old equ dword [edi+146] ;dword +fb_mouse_pos equ dword [edi+150] ;dword +fb_mouse_keys_delta equ dword [edi+154] ;dword +fb_mouse_key_delay equ dword [edi+158] ;dword +fb_mouse_keys_tick equ dword [edi+162] ;dword +fb_start_draw_cursor_line_2 equ word [edi+166] ;dword +fb_all_redraw equ dword [edi+168] ;dword +fb_selected_BDVK_adress equ dword [edi+172] ;dword +fb_key_action equ dword [edi+176] ;dword +fb_name_temp_area equ dword [edi+180] ;dword +fb_max_name_temp_size equ dword [edi+184] ;dword +fb_display_name_max_length equ dword [edi+188] ;dword +fb_draw_panel_selection_flag equ dword [edi+192] ;dword +fb_mouse_pos_old equ dword [edi+196] ;dword +fb_marked_counter equ dword [edi+200] ;dword +;--------------------------------------------------------------------- +fb_draw_panel: + pusha + mov edi,dword [esp+36] + call fb_clear_panel + call fb_calc_max_panel_line + call fb_calc_folder_sysdata + call fb_draw_panel_selection + call fb_draw_folder_data +file_browser_exit +;--------------------------------------------------------------------- +fb_draw_panel_1: + pusha + mov eax,fb_select_color + push eax + mov eax,fb_seclect_text_color + push eax + mov ax,fb_start_draw_cursor_line + push eax + mov eax,fb_background_color + mov fb_select_color,eax + mov eax,fb_text_color + mov fb_seclect_text_color,eax + mov ax,fb_start_draw_cursor_line_2 + mov fb_start_draw_cursor_line,ax + call fb_draw_panel_selection + pop eax + mov fb_start_draw_cursor_line,ax + pop eax + mov fb_seclect_text_color,eax + pop eax + mov fb_select_color,eax + call fb_draw_panel_selection + call fb_draw_folder_data + popa + ret +;--------------------------------------------------------------------- +fb_clear_panel: + cmp fb_all_redraw,dword 1 + jne @f + xor eax,eax + mov fb_max_name_temp_size,eax +@@: + ret +;--------------------------------------------------------------------- +fb_calc_folder_sysdata: + mov eax,fb_folder_data + mov eax,[eax+4] + mov fb_folder_block,eax + ret +;--------------------------------------------------------------------- +fb_calc_max_panel_line: + xor eax,eax + xor ebx,ebx + mov ax,fb_size_y + mov bx,fb_line_size_y + test ebx,ebx + jnz @f + inc ebx +@@: + xor edx,edx + div ebx + mov fb_max_panel_line,eax + ret +;--------------------------------------------------------------------- +fb_draw_panel_selection: + cmp fb_all_redraw,dword 2 + je .end + xor eax,eax + cmp fb_select_panel_counter,eax + je .end + mov eax,fb_folder_block + sub eax,fb_start_draw_line + mov cx,fb_start_draw_cursor_line + call fb_for_all_panel_selection + mov eax,fb_folder_block + dec eax + xor edx,edx + mov dx,fb_line_size_y + imul eax,edx + cmp ax,cx + jae @f + mov cx,ax +@@: + mov fb_start_draw_cursor_line,cx + mov ebx,fb_size_x + add cx,fb_start_y +.1: + shl ecx,16 + mov cx,fb_line_size_y + mov edx,fb_select_color + xor eax,eax + mov ax,fb_icon_size_x + add eax,2 + sub ebx,eax + shl eax,16 + push eax + add ebx,eax + mcall 13 + pop ebx + cmp fb_all_redraw,dword 0 + je .end + mov bx,fb_start_x + ror ebx,16 + mcall 13,,,fb_background_color +.end: + ret +;--------------------------------------------------------------------- +fb_for_all_panel_selection: +; dec eax + xor edx,edx + mov dx,fb_line_size_y + imul eax,edx + cmp ax,cx + jae @f + mov cx,ax +@@: + mov eax,fb_max_panel_line + dec eax + imul eax,edx + cmp ax,cx + jae @f + mov cx,ax +@@: + ret +;--------------------------------------------------------------------- +fb_draw_folder_data: + mov eax,fb_folder_block + sub eax,fb_max_panel_line + test eax,0x8000000 + jz .ok_left + mov fb_start_draw_line,0 + jmp @f +.ok_left: + cmp eax,fb_start_draw_line + jae @f + mov fb_start_draw_line,eax +@@: + mov bx,fb_start_x + add bx,3 + add bx,fb_icon_size_x + shl ebx,16 + mov bx,fb_start_y + mov edx,fb_start_draw_line + imul edx,304 + add edx,fb_folder_data + add edx,32+40 + xor eax,eax +.start: + pusha + mov eax,edx + sub eax,fb_folder_data + sub eax,32+40 + xor edx,edx + mov ebx,304 + div ebx + cmp eax,fb_folder_block + je .end_1 +;.continue_1: + popa + cmp eax,fb_max_panel_line + je .end_2 + mov fb_marked_file,0 + cmp [edx+299-40],byte 0 + je @f + mov fb_marked_file,1 +@@: + call fb_clear_line + call fb_draw_type_size_date + cmp fb_all_redraw,dword 2 + je .draw_icon + cmp fb_all_redraw,dword 0 + je @f +.draw_icon: + call fb_draw_icon +@@: + push eax + xor eax,eax + mov ax,fb_size_x + push ebx edx + xor ebx,ebx + mov bx,fb_font_size_x + xor edx,edx + div ebx + pop edx ebx + sub eax,23+2+2 + mov esi,fb_file_name_length + mov fb_temp_counter,0 + mov fb_display_name_max_length,eax + cmp esi,eax + jbe @f + mov esi,eax + mov fb_temp_counter,1 +@@: + cmp fb_max_name_temp_size,esi + jae @f + mov fb_max_name_temp_size,esi + inc fb_max_name_temp_size +@@: + mov ecx,fb_text_color + cmp fb_marked_file,0 + je @f + mov ecx,fb_reduct_text_color ;0xff0000 +@@: + mov ax,fb_line_size_y + sub ax,fb_font_size_y + + push ebx + mov bx,ax + shr ax,1 + test bx,1b + jz @f + inc ax +@@: + pop ebx + + push ebx + add bx,ax + call .draw_name_temp_area + xor eax,eax + mov ax,fb_font_size_x + imul eax,fb_display_name_max_length + shl eax,16 + push edx + add ebx,eax + mov esi,2 + mov ecx,fb_reduct_text_color ;0xff0000 + mov edx,dword fb_truncated_filename_char + cmp fb_temp_counter,0 + jne @f + mov edx,dword fb_truncated_filename_clear + mov ecx,fb_text_color +@@: + push edi + + and ecx,0x30ffffff + add ecx,0x40000000 + mov eax,fb_background_color + cmp fb_draw_panel_selection_flag,1 + jne @f + mov eax,fb_select_color +@@: + mov edi,eax + mcall 4 + pop edi + cmp fb_temp_counter,0 + je .continue_1 + push edi + + mov eax,fb_background_color + cmp fb_draw_panel_selection_flag,1 + jne @f + mov eax,fb_select_color +@@: + mov edi,eax + + add ebx,1 shl 16 + mcall 4 + pop edi +.continue_1: + pop edx +.continue: + pop ebx + add bx,fb_line_size_y + add edx,304 + pop eax + inc eax + jmp .start +;-------------------------------------- +.draw_name_temp_area: + pusha + mov ebx,esi + mov eax,dword ' ' + mov ecx,256/4 + cld + + push edi + mov edi,fb_name_temp_area + rep stosd + pop edi + + mov esi,edx + mov ecx,ebx + cld + mov edi,fb_name_temp_area + rep movsb + popa + + pusha + mov edx,fb_name_temp_area + + cmp fb_all_redraw,dword 2 + jne .draw_name_temp_area_1 + mov esi,fb_max_name_temp_size + and ecx,0xffffff + add ecx,0x40000000 + + mov eax,fb_background_color + cmp fb_draw_panel_selection_flag,1 + jne @f + mov eax,fb_select_color +@@: + mov edi,eax +.draw_name_temp_area_1: + mcall 4 + popa + + ret +;-------------------------------------- +.end_1: + popa +.end_2: + cmp fb_all_redraw,dword 1 + jne @f + + mov ax,fb_start_y + add ax,fb_size_y + mov cx,bx + dec cx + rol ecx,16 + mov cx,ax + mov eax,ecx + shr eax,16 + sub cx,ax + cmp cx,0 + jbe @f + mov bx,fb_size_x + ror ebx,16 + sub bx,fb_icon_size_x + sub bx,3 + rol ebx,16 + mov edx,fb_background_color ;0xffffff + mcall 13 +@@: + +.end: +; mov fb_draw_scroll_bar,dword 1 + ret +;--------------------------------------------------------------------- +fb_clear_line: + mov fb_draw_panel_selection_flag,0 + pusha + shl ebx,16 + shr ebx,16 +; dec ebx + cmp fb_select_panel_counter,0 + je .continue + mov ax,fb_start_draw_cursor_line + add ax,fb_start_y + cmp bx,ax + jne .continue + mov fb_draw_panel_selection_flag,1 + jmp .end +.continue: + cmp fb_all_redraw,dword 2 + je .end + cmp fb_all_redraw,dword 0 + je .end + mov ebx,[esp+16] + mov cx,bx +; dec cx + rol ecx,16 + mov cx,fb_line_size_y + mov bx,fb_size_x + ror ebx,16 + sub bx,fb_icon_size_x + sub bx,3 + rol ebx,16 + mov edx,fb_background_color + mcall 13 +.end: + popa + ret +;--------------------------------------------------------------------- +fb_draw_type_size_date: + pusha + mov eax,fb_type_table + test [edx-40],byte 0x10 + jz .copy_type + mov [eax],dword ' ' + mov fb_file_name_length,0 + mov fb_extension_size,0 + jmp .start +.copy_type: + mov [eax],dword ' ' + mov [eax+4],word ' ' +.start: + mov esi,edx + xor eax,eax +@@: + cld + lodsb + test eax,eax + jnz @b + mov fb_file_name_length,esi + sub fb_file_name_length,edx + mov fb_temp_counter,esi + test [edx-40],byte 0x10 + jnz .size +;@@: + dec esi + dec edx +@@: + std + lodsb + cmp esi,edx + je .extension_size_0 + cmp al,'.' + jnz @b + add esi,2 + mov fb_extension_start,esi + mov ecx,fb_temp_counter + sub ecx,esi + inc ecx + mov fb_extension_size,ecx + sub fb_file_name_length,ecx + cmp ecx,2 + ja @f + inc fb_file_name_length +@@: + sub ecx,2 + cmp ecx,4 + jbe @f + mov ecx,3 + mov eax,fb_type_table + mov [eax+3],word '..' +@@: + push edi + mov edi,fb_type_table + cld + rep movsb + pop edi + inc edx + jmp .size +.extension_size_0: + inc edx + mov fb_extension_size,0 +.size: + mov eax,fb_type_table + test [edx-40],byte 0x10 + jz .copy_size + mov [eax+6],dword '----' + mov [eax+6+4],word '- ' + jmp .date +;----------------------------------------- +.call_decimal_string: + mov ebx,fb_type_table + add ebx,6 + call fb_decimal_string_4 + mov [ebx],dl + jmp .size_convert_end +;----------------------------------------- +.copy_size: +;/0x40000000 - Gb +;/0x100000 - Mb +;/0x400 Kb + mov [eax+6],dword ' ' + mov [eax+6+4],word ' ' + push ebx + push edx + mov eax,[edx-40+32] + mov ebx,eax + shr eax,30 ; /(1024*1024*1024) + test eax,eax + jz @f + mov dl,byte 'G' + jmp .call_decimal_string +@@: + mov eax,ebx + shr eax,20 ; /(1024*1024) + test eax,eax + jz @f + mov dl,byte 'M' + jmp .call_decimal_string +@@: + mov eax,ebx + shr eax,10 ; /1024 + test eax,eax + jz @f + mov dl,byte 'K' + jmp .call_decimal_string +@@: + mov eax,ebx +;.size_convert: + mov ebx,fb_type_table + add ebx,6 + call fb_decimal_string_4 +.size_convert_end: + mov eax,fb_type_table + add eax,6 + push edi + cmp [eax],byte '0' + jne @f + mov [eax],byte ' ' +@@: + add eax,3 +@@: + cmp [eax+1],byte ' ' + jne @f + mov esi,eax + mov edi,esi + inc edi + mov ecx,5 + std + rep movsb + jmp @r +@@: + pop edi + pop edx + pop ebx +;----------------------------------------- +.date: + xor eax,eax + mov al,[edx-40+28] + push ebx + mov ebx,fb_type_table + add ebx,12 + call fb_decimal_string_2 ; day + mov al,[edx-40+29] + mov ebx,fb_type_table + add ebx,12+3 + call fb_decimal_string_2 ; month + mov ax,[edx-40+30] + mov ebx,fb_type_table + add ebx,12+15 + call fb_decimal_string_4 ; year + mov ebx,fb_type_table + mov ax,[ebx+12+15+2] + mov [ebx+12+6],ax + pop ebx +;----------------------------------------- + ror ebx,16 + add bx,fb_size_x + sub ebx,122+12+15 + rol ebx,16 + mov ecx,fb_text_color + cmp fb_marked_file,0 + je @f + mov ecx,fb_reduct_text_color ;0xff0000 +@@: + mov edx,fb_type_table + mov esi,20 + + mov ax,fb_line_size_y + sub ax,fb_font_size_y + + push ebx + mov bx,ax + shr ax,1 + test bx,1b + jz @f + inc ax +@@: + pop ebx + add bx,ax + cmp fb_all_redraw,dword 2 + jne .draw ;@f + and ecx,0xffffff + add ecx,0x40000000 + + mov eax,fb_background_color + cmp fb_draw_panel_selection_flag,1 + jne @f + mov eax,fb_select_color +@@: + mov edi,eax +.draw: + mcall 4 + popa + ret +;--------------------------------------------------------------------- +fb_draw_icon: + pusha + xor eax,eax + mov ax,fb_icon_size_y + mov ebx,fb_resolution_raw + imul eax,ebx + mov bx,fb_icon_size_x + imul eax,ebx + mov ebx,eax + shr eax,3 + test ebx,111b + jz @f + inc eax +@@: + test [edx-40],byte 0x10 + jnz .draw_dir_pic + + call fb_get_icon_number +; mov ebx,2 + imul ebx,eax ;16*16*3 + jmp .draw +.draw_dir_pic: + xor ebx,ebx + cmp [edx],word '..' + jne .draw + mov ebx,eax ;16*16*3 +.draw: + add ebx,fb_icon_raw_area + mov cx,fb_icon_size_x + shl ecx,16 + mov cx,fb_icon_size_y + + mov edx,[esp+16] + ror edx,16 + sub edx,2 + sub dx,fb_icon_size_x + rol edx,16 + + mov ax,fb_line_size_y + sub ax,fb_icon_size_y + shr ax,1 + add dx,ax + + mov esi,fb_resolution_raw + + xor ebp,ebp + + push edi + mov edi,fb_palette_raw + mcall 65 + pop edi + popa + ret +;--------------------------------------------------------------------- +; Convert of a binary number in decimal string form +; Input: +; AX - value +; EBX - address of string +; Output: +; string contains the number, marked the end of the code 0 +fb_decimal_string_2: + push eax ebx ecx edx + xor ecx,ecx + mov [ebx],byte '0' + inc ebx +.p3: + xor edx,edx + push ebx + mov ebx,10 + div ebx + pop ebx + add edx,48 + push edx + inc ecx + cmp ax,0 + jne .p3 + cmp ecx,1 + jbe .p4 + mov ecx,2 + dec ebx +.p4: + pop edx + mov [ebx],dl + inc ebx + loop .p4 + pop edx ecx ebx eax + ret +;--------------------------------------------------------------------- +fb_decimal_string_4: + push eax ecx edx + xor ecx,ecx + mov [ebx],byte '0' + inc ebx +.p3: + xor edx,edx + push ebx + mov ebx,10 + div ebx + pop ebx + add edx,48 + push edx + inc ecx + cmp eax,0 + jne .p3 + cmp ecx,3 + jbe .p4 + mov ecx,4 + dec ebx +.p4: + pop edx + mov [ebx],dl + inc ebx + loop .p4 + pop edx ecx eax + ret +;--------------------------------------------------------------------- +fb_get_icon_number: + push eax + mov ebp,fb_extension_size + test ebp,ebp + je .end + dec ebp + test ebp,ebp + je .end + dec ebp + test ebp,ebp + je .end +@@: + mov edx,fb_ini_file_end + sub edx,ebp + mov eax,fb_ini_file_start + dec eax +.search_association: + cmp edx,eax + jbe .end + mov esi,fb_extension_start + inc eax + mov ecx,eax + mov ebx,eax + cld +.check: + lodsb + test al,al + jz @f + call fb_char_toupper + shl ax,8 + mov al,[ebx] + inc ebx + call fb_char_toupper + cmp al,ah + je .check + mov eax,ecx + jmp .search_association +@@: + mov eax,ecx + mov esi,eax + add esi,ebp + cmp [esi],byte '=' + jne .search_association + inc esi + xor ebx,ebx + xor eax,eax + mov ecx,9 + call .calculate + cmp al,0x30 + jb .end + cmp al,0x39 + ja .end + sub eax,0x30 +@@: + call .calculate_1 + cmp al,0x30 + jb @f + cmp al,0x39 + ja @f + sub eax,0x30 + + lea ebx,[ebx+ebx*4] + shl ebx,1 + + dec ecx + jnz @b +@@: + pop eax + ret +.end: + mov ebx,2 + pop eax + ret +;--------------------------------------------------------------------- +.calculate_1: + add ebx,eax +.calculate: + xor eax,eax + cld + lodsb + ret +;--------------------------------------------------------------------- +fb_char_toupper: +; convert character to uppercase, using cp866 encoding +; in: al=symbol +; out: al=converted symbol + cmp al,'a' + jb .ret + cmp al, 'z' + jbe .az + cmp al, 'а' + jb .ret + cmp al, 'р' + jb .rus1 + cmp al, 'я' + ja .ret +; 0xE0-0xEF -> 0x90-0x9F + sub al, 'р'-'Р' +.ret: + ret +.rus1: +; 0xA0-0xAF -> 0x80-0x8F +.az: + and al, not 0x20 + ret +;--------------------------------------------------------------------- +fb_truncated_filename_char: + db '..' +fb_truncated_filename_clear: + db ' ' +;--------------------------------------------------------------------- +;***************************************************************************** +;***************************************************************************** +; mouse event +;***************************************************************************** +;***************************************************************************** +fb_mouse: + pusha + mov edi,dword [esp+36] +;------------------------------------------------------- + mcall 37,2 + mov ebx,fb_mouse_keys + mov fb_mouse_keys_old,ebx + mov fb_mouse_keys,eax + + mcall 37,1 + mov ebx,fb_mouse_pos + mov fb_mouse_pos_old,ebx + mov fb_mouse_pos,eax + + test eax,0x80000000 + jnz .exit_fb + test eax,0x8000 + jnz .exit_fb + + mov ebx,eax + shr ebx,16 ; x position + shl eax,16 + shr eax,16 ; y position + + mov cx,fb_start_x + cmp bx,cx + jb .exit_fb + + add cx,fb_size_x + cmp bx,cx + ja .exit_fb + + mov cx,fb_start_y + cmp ax,cx + jb .exit_fb + + add cx,fb_size_y + cmp ax,cx + ja .exit_fb +;------------------------------------------------------- + cmp fb_mouse_keys_delta,1 + je .enter_1 + + cmp fb_mouse_keys,0 + jz .exit_fb +.start: + sub ax,fb_start_y + xor ebx,ebx + mov bx,fb_line_size_y + xor edx,edx + push eax + div ebx + pop eax + sub eax,edx + xor edx,edx + cmp fb_select_panel_counter,edx + jne @f + mov fb_mouse_keys_delta,0 + jmp .continue +@@: + xor edx,edx + cmp fb_start_draw_cursor_line,ax + jne @f + cmp fb_mouse_keys,edx + jnz .continue +@@: + mov fb_mouse_keys_delta,edx +.continue: + xor ebx,ebx + mov bx,fb_line_size_y + imul ebx,fb_folder_block + cmp eax,ebx + jb @f + xor edx,edx + mov dx,fb_line_size_y + sub ebx,edx + cmp bx,fb_start_draw_cursor_line + je .enter + call .store_old_cursor_line + mov fb_start_draw_cursor_line,bx + jmp .continue_1 +@@: + cmp ax,fb_start_draw_cursor_line + je .enter + call .store_old_cursor_line + mov fb_start_draw_cursor_line,ax +.continue_1: + test fb_mouse_keys,10b + jne .mark_mouse + jmp .enter_1 +.continue_2: + mov ax,fb_start_draw_cursor_line + cmp ax,fb_start_draw_cursor_line_2 + je .exit_fb + + call fb_draw_panel_1 + jmp .exit_fb +.enter: + cmp fb_mouse_keys_delta,2 + je .enter_2 + cmp fb_mouse_keys_delta,1 + je .enter_1 + mov eax,fb_mouse_keys_old + cmp fb_mouse_keys,eax + jz .exit_fb + test fb_mouse_keys,10b + jne .mark_mouse + xor edx,edx + inc edx + mov fb_mouse_keys_delta,edx + jmp .exit_fb +.enter_1: + mov eax,fb_mouse_keys_old + cmp fb_mouse_keys,eax + jz .exit_fb + test fb_mouse_keys,10b + jne .mark_mouse + mov edx,2 + mov fb_mouse_keys_delta,edx + mcall 26,9 + add eax,fb_mouse_key_delay + mov fb_mouse_keys_tick,eax + jmp .continue_2 +.enter_2: + mcall 26,9 + cmp eax,fb_mouse_keys_tick + ja @f +; mov eax,fb_mouse_pos_old +; cmp eax,fb_mouse_pos +; jne @f + mov eax,fb_mouse_keys_old + cmp fb_mouse_keys,eax + jz @f + test fb_mouse_keys,10b + jne .mark_mouse + call .enter_3 + jmp .exit_fb +@@: + xor eax,eax + inc eax + mov fb_mouse_keys_delta,eax +;------------------------------------------------------- +.exit_fb: +file_browser_exit +;------------------------------------------------------- +.mark_mouse: + call fb_key.mark_1 + call fb_draw_panel_1 + xor eax,eax + mov fb_mouse_keys_delta,eax + jmp .exit_fb +;------------------------------------------------------- +.enter_3: + xor eax,eax + mov fb_mouse_keys,eax + mov fb_mouse_keys_old,eax + mov eax,3 + mov fb_mouse_keys_delta,eax + xor eax,eax + mov ax,fb_start_draw_cursor_line + xor ebx,ebx + mov bx,fb_line_size_y + xor edx,edx + div ebx + add eax,fb_start_draw_line + imul eax,304 + add eax,32 + add eax,fb_folder_data + mov fb_selected_BDVK_adress,eax + xor eax,eax + mov fb_max_name_temp_size,eax + ret +;------------------------------------------------------- +.store_old_cursor_line: + push eax + mov ax,fb_start_draw_cursor_line + mov fb_start_draw_cursor_line_2,ax + xor eax,eax +; mov fb_mouse_keys_delta,eax + pop eax + ret +;***************************************************************************** +;***************************************************************************** +; key event +; 1 - arrow down +; 2 - arrow up +; 3 - PageDown +; 4 - PageUp +; 5 - Home +; 6 - End +; 7 - Enter +; 8 - Insert (Mark) +; 9 - Mark All +; 10 - Unmark All +; 11 - Invert Mark +;***************************************************************************** +;***************************************************************************** +fb_key: + pusha + mov edi,dword [esp+36] +;------------------------------------------------------- + mov eax,fb_key_action + shl eax,2 + add eax,dword fb_key_table + cmp eax,fb_key_table.end + jae .exit_fb + cmp [eax],dword 0 + je .exit_fb + jmp dword [eax] +;------------------------------------------------------- +.arrow_down: + mov ax,fb_start_draw_cursor_line + add ax,fb_line_size_y + add ax,fb_line_size_y + cmp ax,word fb_size_y + jae @f +.add_1: + call fb_mouse.store_old_cursor_line + mov ax,fb_start_draw_cursor_line + add ax,fb_line_size_y + mov fb_start_draw_cursor_line,ax + call fb_draw_panel_1 + jmp .exit_fb +@@: + mov eax,fb_folder_block + sub eax,fb_max_panel_line + test eax,0x80000000 + jnz .page_down_2 + + call .prepare_data_down + ja @f + + cmp fb_start_draw_line,eax + je .exit_fb +@@: + inc fb_start_draw_line + call fb_draw_panel_3 + jmp .exit_fb +;------------------------------------------------------- +.arrow_up: + mov ax,fb_start_draw_cursor_line + add ax,fb_start_y + cmp fb_start_y,ax + je @f + call fb_mouse.store_old_cursor_line + mov ax,fb_start_draw_cursor_line + sub ax,fb_line_size_y + mov fb_start_draw_cursor_line,ax + call fb_draw_panel_1 + jmp .exit_fb +@@: + cmp fb_start_draw_line,0 + je .exit_fb + dec fb_start_draw_line + call fb_draw_panel_3 + jmp .exit_fb +;------------------------------------------------------- +.page_down: + mov eax,fb_max_panel_line + mov ebx,fb_folder_block + sub ebx,eax + test ebx,0x80000000 + jnz .page_down_2 + sub ebx,fb_start_draw_line + cmp ebx,eax + ja .page_down_3 + mov ebx,fb_folder_block + sub ebx,eax + call .prepare_data_down + ja @f + cmp ebx,fb_start_draw_line + je .exit_fb +@@: + mov fb_start_draw_line,ebx +.page_down_0: + dec eax + xor ebx,ebx + mov bx,fb_line_size_y + imul eax,ebx +.page_down_1: + call fb_mouse.store_old_cursor_line + mov fb_start_draw_cursor_line,ax + call fb_draw_panel_2 + jmp .exit_fb +.page_down_2: + mov eax,fb_folder_block + sub eax,fb_start_draw_line + dec eax + xor ebx,ebx + mov bx,fb_line_size_y + imul eax,ebx + cmp ax,fb_start_draw_cursor_line + jbe .exit_fb + jmp .page_down_1 +.page_down_3: + add fb_start_draw_line,eax + call fb_draw_panel_2 + jmp .exit_fb +;------------------------------------------------------- +.prepare_data_down: + mov ecx,fb_folder_block + sub ecx,fb_start_draw_line + dec ecx + xor edx,edx + mov dx,fb_line_size_y + imul ecx,edx + cmp cx,fb_start_draw_cursor_line + ret +;------------------------------------------------------- +.page_up: + mov eax,fb_max_panel_line + mov ebx,fb_start_draw_line + sub ebx,eax + test ebx,0x8000000 + jz @f + cmp fb_start_draw_line,0 + jne .page_up_1 + cmp fb_start_draw_cursor_line,0 + je .exit_fb + mov fb_start_draw_cursor_line,0 +.page_up_1: + mov fb_start_draw_line,0 + call fb_draw_panel_2 + jmp .exit_fb +@@: + sub fb_start_draw_line,eax + call fb_draw_panel_2 + jmp .exit_fb +;------------------------------------------------------- +.home: + cmp fb_start_draw_line,0 + jne @f + cmp fb_start_draw_cursor_line,0 + je .exit_fb +@@: + mov fb_start_draw_line,0 + mov fb_start_draw_cursor_line,0 + call fb_mouse.store_old_cursor_line + call fb_draw_panel_2 + jmp .exit_fb +;------------------------------------------------------- +.end: + mov eax,fb_folder_block + sub eax,fb_max_panel_line + test eax,0x80000000 + jnz .page_down_2 + call .prepare_data_down + ja @f + cmp eax,fb_start_draw_line + je .exit_fb +@@: + mov fb_start_draw_line,eax + mov eax,fb_max_panel_line + jmp .page_down_0 +;------------------------------------------------------- +.enter: + call fb_mouse.enter_3 + jmp .exit_fb +;------------------------------------------------------- +.mark: + call .mark_1 + jmp .arrow_down +;------------------------------------------------------- +.mark_1: + xor eax,eax + mov ax,fb_start_draw_cursor_line + xor edx,edx + xor ebx,ebx + mov bx,fb_line_size_y + div ebx + mov esi,fb_start_draw_line + add esi,eax + imul esi,304 + add esi,fb_folder_data + + add esi,32+299 + mov al,[esi] + and al,1 + + test al,al + jnz @f + inc fb_marked_counter + jmp .mark_2 +@@: + dec fb_marked_counter +.mark_2: + mov al,[esi] + inc al + and al,1 + mov [esi],al + ret +;------------------------------------------------------- +.mark_all: + mov fb_temp_counter,0 +.mark_all_1: + mov ebp,fb_folder_block +.mark_all_2: + mov ebx,ebp + dec ebx + imul ebx,304 + add ebx,fb_folder_data + add ebx,32+40 + cmp [ebx],word '..' + jne .mark_all_3 + cmp [ebx+2],byte 0 + je @f +.mark_all_3: + call .select_mark_action +@@: + dec ebp + jnz .mark_all_2 + + call fb_draw_panel_3 + cmp fb_temp_counter,0 + jne @f + mov eax,fb_folder_block + jmp .mark_all_4 +@@: + cmp fb_temp_counter,1 + jne @f + mov fb_marked_counter,0 + jmp .exit_fb +@@: + mov eax,fb_folder_block + sub eax,fb_marked_counter +.mark_all_4: + dec eax + mov fb_marked_counter,eax + jmp .exit_fb +;------------------------------------------------------- +.select_mark_action: + add ebx,299-40 + cmp fb_temp_counter,0 + jne @f + mov [ebx],byte 1 + jmp .select_mark_action_1 +@@: + cmp fb_temp_counter,1 + jne @f + mov [ebx],byte 0 + jmp .select_mark_action_1 +@@: + mov al,[ebx] + inc al + and al,1 + mov [ebx],al +.select_mark_action_1: + ret +;------------------------------------------------------- +.unmark_all: + mov fb_temp_counter,1 + jmp .mark_all_1 +;------------------------------------------------------- +.invert_mark: + mov fb_temp_counter,2 + jmp .mark_all_1 +;------------------------------------------------------- +.exit_fb: +file_browser_exit +;------------------------------------------------------- +fb_key_table: + dd 0 + dd fb_key.arrow_down ; 1 + dd fb_key.arrow_up ; 2 + dd fb_key.page_down ; 3 + dd fb_key.page_up ; 4 + dd fb_key.home ; 5 + dd fb_key.end ; 6 + dd fb_key.enter ; 7 + dd fb_key.mark ; 8 + dd fb_key.mark_all ; 9 + dd fb_key.unmark_all ; 10 + dd fb_key.invert_mark ; 11 +.end: + dd 0 +;------------------------------------------------------- +fb_draw_panel_3: + mov eax,2 + mov fb_all_redraw,eax + jmp @f +fb_draw_panel_2: + xor eax,eax + inc eax + mov fb_all_redraw,eax + call fb_draw_panel_selection +@@: + call fb_draw_folder_data + xor eax,eax + mov fb_all_redraw,eax + inc eax + mov fb_draw_scroll_bar,eax + ret + +} diff --git a/programs/develop/libraries/box_lib/trunk/menubar.mac b/programs/develop/libraries/box_lib/trunk/menubar.mac index ed9d68896a..2aaacaf947 100644 --- a/programs/develop/libraries/box_lib/trunk/menubar.mac +++ b/programs/develop/libraries/box_lib/trunk/menubar.mac @@ -1,6 +1,6 @@ ;************************************************************** ; MenuBar Macro for Kolibri OS -; Copyright (c) 2009, Mario79 +; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ ; names of its contributors may be used to endorse or promote products ; derived from this software without specific prior written permission. ; -; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY +; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY @@ -34,31 +34,31 @@ ret 4 macro use_menu_bar { menu_bar: -m_type equ [edi] -m_size_x equ [edi+4] -m_start_x equ [edi+6] -m_size_y equ [edi+8] -m_start_y equ [edi+10] +m_type equ [edi] +m_size_x equ [edi+4] +m_start_x equ [edi+6] +m_size_y equ [edi+8] +m_start_y equ [edi+10] m_text_pointer equ [edi+12] m_pos_pointer equ [edi+16] -m_text_end equ [edi+20] -m_mouse_pos equ [edi+24] +m_text_end equ [edi+20] +m_ret_key equ [edi+24] m_mouse_keys equ [edi+28] -m_size_x1 equ [edi+32] -m_start_x1 equ [edi+34] -m_size_y1 equ [edi+36] -m_start_y1 equ [edi+38] -m_bckg_col equ [edi+40] -m_frnt_col equ [edi+44] -m_menu_col equ [edi+48] -m_select equ [edi+52] +m_size_x1 equ [edi+32] +m_start_x1 equ [edi+34] +m_size_y1 equ [edi+36] +m_start_y1 equ [edi+38] +m_bckg_col equ [edi+40] +m_frnt_col equ [edi+44] +m_menu_col equ [edi+48] +m_select equ [edi+52] m_out_select equ [edi+56] m_buf_adress equ [edi+60] -m_procinfo equ [edi+64] -m_click equ [edi+68] -m_cursor equ [edi+72] +m_procinfo equ [edi+64] +m_click equ [edi+68] +m_cursor equ [edi+72] m_cursor_old equ [edi+76] -m_interval equ [edi+80] +m_interval equ [edi+80] m_cursor_max equ [edi+84] m_extended_key equ [edi+88] m_menu_sel_col equ [edi+92] @@ -74,499 +74,517 @@ m_get_mouse_flag equ [edi+116] ;***************************************************************************** ;***************************************************************************** .draw: - pusha - mov edi,dword [esp+36] - call .draw_1 -menu_bar_exit + pusha + mov edi,dword [esp+36] + call .draw_1 + menu_bar_exit .draw_1: - call .calc_m_cursor_max - dec dword m_cursor_max - mov eax,m_cursor_max - imul eax,m_interval - mov m_size_y1,ax + call .calc_m_cursor_max + dec dword m_cursor_max + mov eax,m_cursor_max + imul eax,m_interval + mov m_size_y1,ax - mov ebx,m_size_x - mov ecx,m_size_y - cmp m_select,dword 1 - je .active - mov edx,m_bckg_col - jmp @f + mov ebx,m_size_x + mov ecx,m_size_y + cmp m_select,dword 1 + je .active + mov edx,m_bckg_col + jmp @f .active: - mov edx,m_frnt_col + mov edx,m_frnt_col @@: - mcall 13 - shr ecx,16 - mov bx,cx - movzx eax,word m_size_y - call .calculate_font_offset - cmp m_select,dword 1 - je .active_1 - mov ecx,m_bckg_text_col - add ecx,0x80000000 - jmp @f + mcall 13 + shr ecx,16 + mov bx,cx + movzx eax,word m_size_y + call .calculate_font_offset + cmp m_select,dword 1 + je .active_1 + mov ecx,m_bckg_text_col + add ecx,0x80000000 + jmp @f .active_1: - mov ecx,m_frnt_text_col - add ecx,0x80000000 + mov ecx,m_frnt_text_col + add ecx,0x80000000 @@: - mov edx,m_text_pointer - mcall 4 - ret + mov edx,m_text_pointer + mcall 4 + ret .draw_2: - mov ebx,m_size_x1 - mov ecx,m_size_y1 - mov edx,m_menu_col - mcall 13 + mov ebx,m_size_x1 + mov ecx,m_size_y1 + mov edx,m_menu_col + mcall 13 ret .calculate_font_offset: - sub eax,m_font_height - shr eax,1 - add ebx,eax - add ebx,4 shl 16 - ret + sub eax,m_font_height + shr eax,1 + add ebx,eax + add ebx,4 shl 16 + ret .draw_3: - mov ebx,m_size_x1 - mov ecx,m_size_y1 + mov ebx,m_size_x1 + mov ecx,m_size_y1 - push ebx ecx - mov eax,m_cursor_old - imul eax,m_interval - shl eax,16 - add ecx,eax - mov cx,m_interval - mov edx,m_menu_col - mcall 13 - pop ecx ebx + push ebx ecx + mov eax,m_cursor_old + imul eax,m_interval + shl eax,16 + add ecx,eax + mov cx,m_interval + mov edx,m_menu_col + mcall 13 + pop ecx ebx - push ebx ecx - mov eax,m_cursor - imul eax,m_interval - shl eax,16 - add ecx,eax - mov cx,m_interval - mov edx,m_menu_sel_col - mcall 13 - pop ecx ebx + push ebx ecx + mov eax,m_cursor + imul eax,m_interval + shl eax,16 + add ecx,eax + mov cx,m_interval + mov edx,m_menu_sel_col + mcall 13 + pop ecx ebx - shr ecx,16 - mov bx,cx - mov eax,m_interval - call .calculate_font_offset - mov edx,m_pos_pointer - xor ebp,ebp + shr ecx,16 + mov bx,cx + mov eax,m_interval + call .calculate_font_offset + mov edx,m_pos_pointer + xor ebp,ebp @@: - cmp ebp,m_cursor - jne .no_active_text - mov ecx,m_frnt_text_col - jmp .active_text + cmp ebp,m_cursor + jne .no_active_text + mov ecx,m_frnt_text_col + jmp .active_text .no_active_text: - mov ecx,m_bckg_text_col + mov ecx,m_bckg_text_col .active_text: - add ecx,0x80000000 - mcall 4 - call .get_next_text - inc ebp - add ebx,m_interval - jmp @r + add ecx,0x80000000 + mcall 4 + call .get_next_text + inc ebp + add ebx,m_interval + jmp @r .draw_end: - ret + ret .calc_m_cursor_max: - mov edx,m_pos_pointer - mov m_cursor_max,dword 0 + mov edx,m_pos_pointer + mov m_cursor_max,dword 0 @@: - inc dword m_cursor_max - call .get_next_text - jmp @r + inc dword m_cursor_max + call .get_next_text + jmp @r ;***************************************************************************** .get_next_text: - mov esi,edx + mov esi,edx @@: - cmp esi,m_text_end - je .get_next_text_end + cmp esi,m_text_end + je .get_next_text_end cld lodsb - test al,al - jnz @r - mov edx,esi - ret + test al,al + jnz @r + mov edx,esi + ret .get_next_text_end: - add esp,4 + add esp,4 ret ;***************************************************************************** ;***************************************************************************** ; mouse event ;***************************************************************************** ;***************************************************************************** +.activate: + pusha + mov edi,dword [esp+36] + jmp .start_loop .mouse: pusha - mov edi,dword [esp+36] -;.mouse_1: -; mov eax,m_mouse_pos -; cmp m_get_mouse_flag,dword 0 -; je @f - call .processing_real_mouse -;@@: - test eax,0x80000000 - jnz .exit_menu - test eax,0x8000 - jnz .exit_menu + mov edi,dword [esp+36] - mov ebx,eax - shr ebx,16 ; x position - shl eax,16 - shr eax,16 ; y position + call .processing_real_mouse + + test eax,0x80000000 + jnz .exit_menu + test eax,0x8000 + jnz .exit_menu + + mov ebx,eax + shr ebx,16 ; x position + shl eax,16 + shr eax,16 ; y position - mov cx,m_start_x - cmp bx,cx - jb .exit_menu + mov cx,m_start_x + cmp bx,cx + jb .exit_menu - add cx,m_size_x - dec cx - cmp bx,cx - ja .exit_menu + add cx,m_size_x + dec cx + cmp bx,cx + ja .exit_menu - mov cx,m_start_y - cmp ax,cx - jb .exit_menu + mov cx,m_start_y + cmp ax,cx + jb .exit_menu - add cx,m_size_y - cmp ax,cx - ja .exit_menu + add cx,m_size_y + cmp ax,cx + ja .exit_menu - test m_mouse_keys,dword 1b - jnz @f - cmp m_select,dword 1 - je .exit_menu_1 - mov m_select,dword 1 - call .draw_1 - jmp .exit_menu_1 + test m_mouse_keys,dword 1b + jnz @f + cmp m_select,dword 1 + je .exit_menu_1 + mov m_select,dword 1 + call .draw_1 + jmp .exit_menu_1 @@: - cmp m_get_mouse_flag,dword 1 - mov m_get_mouse_flag,dword 0 - je @f + cmp m_get_mouse_flag,dword 1 + mov m_get_mouse_flag,dword 0 + je @f - mov eax,m_mouse_keys - cmp eax,m_mouse_keys_old - je .exit_menu_1 + mov eax,m_mouse_keys + cmp eax,m_mouse_keys_old + je .exit_menu_1 @@: - mov m_select,dword 1 - call .draw_1 - call .allocate_menu_area - call .get_menu_area +.start_loop: + mov m_select,dword 1 + call .draw_1 + call .allocate_menu_area + call .get_menu_area - call .draw_2 + call .draw_2 .red: - call .draw_3 + call .draw_3 .still: - mcall 10 - cmp eax,1 - je .exit_menu_3 ;red - cmp eax,2 - je .key_menu - cmp eax,3 - je .exit_menu_3 - cmp eax,6 - je .mouse_menu - jmp .still + mcall 10 + cmp eax,1 + je .exit_menu_3 + cmp eax,2 + je .key_menu + cmp eax,3 + je .exit_menu_3 + cmp eax,6 + je .mouse_menu + jmp .still .key_menu: - mcall 2 - cmp m_extended_key,dword 1 - je .extended_key - test al,al - jnz .key_menu_end - cmp ah, 0xE0 - jne @f - mov m_extended_key,dword 1 -.key_menu_end: - jmp .still -@@: - cmp ah,72 ;Arrow Up - je .menu_key_72_1 - cmp ah,80 ; Arrow Down - je .menu_key_80_1 - cmp ah,28 ; Enter - je .menu_key_28_1 - cmp ah,1 ; Esc - je .menu_key_1_1 -.key_menu_end_1: - cmp ah,208 ; Arrow Down - je .key_menu_end - cmp ah,200 ; Arrow Up - je .key_menu_end - cmp ah,156 ; Enter - je .key_menu_end - cmp ah,129 ; Esc - je .key_menu_end -; cmp ah,184 ;Alt to Up -; je .end_5 -; cmp ah,187 ; F1 to Up -; je .end_1 -; cmp ah,188 ; F2 to Up -; je .end_1 - cmp ah,199 ;Home - je .key_menu_end - cmp ah,207 ;End - je .key_menu_end - cmp ah,201 ;Page UP - je .key_menu_end - cmp ah,209 ;Page Down - je .key_menu_end - cmp ah,42 ; NumLock ON - je .key_menu_end - cmp ah,170 ; NumLock ON - je .key_menu_end - cmp ah,210 ; Insert - je .key_menu_end - cmp ah,211 ; Delete - je .key_menu_end -; cmp ah,56 ;Alt to Up -; je .end_4 -; cmp ah,59 ; F1 to Down -; je .end_2 -; cmp ah,60 ; F2 to Down -; je .end_3 + mcall 2 -;.for_all_key: -; mov [close_menu],1 -; ret - jmp .exit_menu_3 ;.still + cmp m_extended_key,dword 1 + je .extended_key + test al,al + jnz .key_menu_end + cmp ah, 0xE0 + jne @f + mov m_extended_key,dword 1 +.key_menu_end: + jmp .still +@@: + cmp ah,72 ;Arrow Up + je .menu_key_72_1 + cmp ah,80 ; Arrow Down + je .menu_key_80_1 + cmp ah,28 ; Enter + je .menu_key_28_1 + cmp ah,1 ; Esc + je .menu_key_1_1 + cmp ah,75 ; L-Arrow down + je .menu_key_75_1 + cmp ah,77 ; R-Arrow down + je .menu_key_77_1 + +.key_menu_end_1: + cmp ah,208 ; Arrow Down + je .key_menu_end + cmp ah,200 ; Arrow Up + je .key_menu_end + cmp ah,156 ; Enter + je .key_menu_end + cmp ah,129 ; Esc + je .key_menu_end + cmp ah,199 ;Home + je .key_menu_end + cmp ah,207 ;End + je .key_menu_end + cmp ah,201 ;Page UP + je .key_menu_end + cmp ah,209 ;Page Down + je .key_menu_end + cmp ah,42 ; NumLock ON + je .key_menu_end + cmp ah,170 ; NumLock ON + je .key_menu_end + cmp ah,210 ; Insert + je .key_menu_end + cmp ah,211 ; Delete + je .key_menu_end + cmp ah,157 ; Ctrl up + je .key_menu_end + cmp ah,184 ; Alt up + je .key_menu_end + cmp ah,170 ; L-Shift up + je .key_menu_end + cmp ah,182 ; R-Shift up + je .key_menu_end + cmp ah,203 ; L-Arrow up + je .key_menu_end + cmp ah,205 ; R-Arrow up + je .key_menu_end + + jmp .exit_menu_3 ;--------------------------------------------------------------------- .extended_key: - mov m_extended_key, dword 0 + mov m_extended_key, dword 0 .menu_key_80: - cmp ah,80 ; arrow down - jne .menu_key_72 + cmp ah,80 ; arrow down + jne .menu_key_72 .menu_key_80_1: - mov eax,m_cursor_max - dec eax - cmp eax,m_cursor - je .still ;@f - mov ebx,m_cursor - mov m_cursor_old,ebx - inc dword m_cursor + mov eax,m_cursor_max + dec eax + cmp eax,m_cursor + je .still ;@f + mov ebx,m_cursor + mov m_cursor_old,ebx + inc dword m_cursor ;@@: - jmp .red + jmp .red ;--------------------------------------------------------------------- .menu_key_72: - cmp ah,72 ;arrow up - jne .menu_key_71 + cmp ah,72 ;arrow up + jne .menu_key_71 .menu_key_72_1: - cmp m_cursor,dword 0 - je .still ;@f - mov ebx,m_cursor - mov m_cursor_old,ebx - dec dword m_cursor + cmp m_cursor,dword 0 + je .still ;@f + mov ebx,m_cursor + mov m_cursor_old,ebx + dec dword m_cursor ;@@: - jmp .red + jmp .red ;--------------------------------------------------------------------- .menu_key_71: - cmp ah,71 ;Home - je @f - cmp ah,73 ;PageUp - jne .menu_key_79 + cmp ah,71 ;Home + je @f + cmp ah,73 ;PageUp + jne .menu_key_79 @@: - cmp m_cursor,dword 0 - je .still - mov ebx,m_cursor - mov m_cursor_old,ebx - mov m_cursor,dword 0 - jmp .red + cmp m_cursor,dword 0 + je .still + mov ebx,m_cursor + mov m_cursor_old,ebx + mov m_cursor,dword 0 + jmp .red ;--------------------------------------------------------------------- .menu_key_79: - cmp ah,79 ; End - je @f - cmp ah,81 ; PageDown - jne .menu_key_1 + cmp ah,79 ; End + je @f + cmp ah,81 ; PageDown + jne .menu_key_1 @@: - mov ecx,m_cursor_max - dec ecx - cmp m_cursor,ecx - je .still - mov ebx,m_cursor - mov m_cursor_old,ebx - mov m_cursor,ecx - jmp .red + mov ecx,m_cursor_max + dec ecx + cmp m_cursor,ecx + je .still + mov ebx,m_cursor + mov m_cursor_old,ebx + mov m_cursor,ecx + jmp .red ;--------------------------------------------------------------------- .menu_key_1: - cmp ah,1 ; Esc - jne .menu_key_28 + cmp ah,1 ; Esc + jne .menu_key_28 .menu_key_1_1: - jmp .exit_menu_3 + jmp .exit_menu_3 ;--------------------------------------------------------------------- .menu_key_28: - cmp ah,28 ; Enter - jne .menu_key_end + cmp ah,28 ; Enter + jne .menu_key_75 .menu_key_28_1: -; mov [press_enter_menu],1 -; ret - jmp .exit_menu_2 -.menu_key_end: - jmp .key_menu_end_1 + xor eax,eax + mov m_mouse_keys_old,eax + inc eax + mov m_mouse_keys,eax + jmp .exit_menu_2 +;--------------------------------------------------------------------- +.menu_key_75: + cmp ah,75 ; L-Arrow down + jne .menu_key_77 +.menu_key_75_1: + mov m_ret_key,dword 1 + jmp .exit_menu_3 +;--------------------------------------------------------------------- +.menu_key_77: + cmp ah,77 ; R-Arrow down + jne .key_menu_end_1 +.menu_key_77_1: + mov m_ret_key,dword 2 + jmp .exit_menu_3 ;--------------------------------------------------------------------- .processing_real_mouse: - mcall 37,2 - mov ebx,m_mouse_keys - mov m_mouse_keys_old,ebx - mov m_mouse_keys,eax + mcall 37,2 + mov ebx,m_mouse_keys + mov m_mouse_keys_old,ebx + mov m_mouse_keys,eax - mcall 37,1 - mov m_mouse_pos,eax - ret + mcall 37,1 + ret ;--------------------------------------------------------------------- .allocate_menu_area: - cmp m_buf_adress,dword 0 - je @f - call .free_menu_area + cmp m_buf_adress,dword 0 + je @f + call .free_menu_area @@: - movzx ecx,word m_size_x1 - movzx eax,word m_size_y1 - imul ecx,eax - lea ecx,[ecx*3] - mcall 68, 12 - mov m_buf_adress,eax - ret + movzx ecx,word m_size_x1 + movzx eax,word m_size_y1 + imul ecx,eax + lea ecx,[ecx*3] + mcall 68, 12 + mov m_buf_adress,eax + ret ;--------------------------------------------------------------------- .free_menu_area: - mcall 68,13,m_buf_adress - xor eax,eax - mov m_buf_adress,eax - ret + mcall 68,13,m_buf_adress + xor eax,eax + mov m_buf_adress,eax + ret ;--------------------------------------------------------------------- .get_menu_area: - mcall 9, m_procinfo,-1 + mcall 9, m_procinfo,-1 - mov cx,m_size_x1 - shl ecx,16 - mov cx,m_size_y1 + mov cx,m_size_x1 + shl ecx,16 + mov cx,m_size_y1 - mov dx,m_start_x1 - mov eax,m_procinfo - add dx,[eax+34] - add dx,[eax+54] - shl edx,16 - mov dx,m_start_y1 - add dx,[eax+38] - add dx,[eax+58] + mov dx,m_start_x1 + mov eax,m_procinfo + add dx,[eax+34] + add dx,[eax+54] + shl edx,16 + mov dx,m_start_y1 + add dx,[eax+38] + add dx,[eax+58] - mcall 36, m_buf_adress - ret + mcall 36, m_buf_adress + ret ;--------------------------------------------------------------------- .put_menu_area: - mov cx,m_size_x1 - shl ecx,16 - mov cx,m_size_y1 + mov cx,m_size_x1 + shl ecx,16 + mov cx,m_size_y1 - mov dx,m_start_x1 - shl edx,16 - mov dx,m_start_y1 + mov dx,m_start_x1 + shl edx,16 + mov dx,m_start_y1 - mcall 7, m_buf_adress - ret + mcall 7, m_buf_adress + ret ;--------------------------------------------------------------------- .mouse_menu: - call .processing_real_mouse + call .processing_real_mouse - test eax,0x80000000 - jnz .still - test eax,0x8000 - jnz .still + test eax,0x80000000 + jnz .still + test eax,0x8000 + jnz .still - mov ebx,eax - shr ebx,16 - shl eax,16 - shr eax,16 + mov ebx,eax + shr ebx,16 + shl eax,16 + shr eax,16 - xor ecx,ecx - mov cx,m_start_y1 - cmp ax,cx - jbe .close - add cx,m_size_y1 - cmp ax,cx - jae .close - mov cx,m_start_x1 - cmp bx,cx - jbe .close - add cx,m_size_x1 - cmp bx,cx - jae .close - sub ax,m_start_y1 - mov ebx,m_interval - xor edx,edx - div ebx - mov ebx,m_cursor - cmp eax,ebx - je .no_red - mov m_cursor_old,ebx - cmp eax,m_cursor_max - jb @f - mov eax,m_cursor_max + xor ecx,ecx + mov cx,m_start_y1 + cmp ax,cx + jbe .close + add cx,m_size_y1 + cmp ax,cx + jae .close + mov cx,m_start_x1 + cmp bx,cx + jbe .close + add cx,m_size_x1 + cmp bx,cx + jae .close + sub ax,m_start_y1 + mov ebx,m_interval + xor edx,edx + div ebx + mov ebx,m_cursor + cmp eax,ebx + je .no_red + mov m_cursor_old,ebx + cmp eax,m_cursor_max + jb @f + mov eax,m_cursor_max @@: - mov m_cursor,eax - test m_mouse_keys,dword 1b - jz .red - jmp .exit_menu_2 + mov m_cursor,eax + test m_mouse_keys,dword 1b + jz .red + jmp .exit_menu_2 .no_red: - test m_mouse_keys,dword 1b - jz .still - jmp .exit_menu_2 + test m_mouse_keys,dword 1b + jz .still + jmp .exit_menu_2 .close: - test m_mouse_keys,dword 1b - jz .still - jmp .exit_menu_3 + test m_mouse_keys,dword 1b + jz .still + jmp .exit_menu_3 .exit_menu: - cmp m_select,dword 0 - je .exit_menu_1 - mov m_select,dword 0 + cmp m_select,dword 0 + je .exit_menu_1 + mov m_select,dword 0 - call .draw_1 -; jmp .exit_menu_1 - test m_mouse_keys,dword 1b - jz .exit_menu_1 + call .draw_1 + + test m_mouse_keys,dword 1b + jz .exit_menu_1 .exit_menu_3: - mov m_select,dword 0 - call .put_menu_area - xor eax,eax - mov m_cursor_out,eax - jmp .exit + mov m_select,dword 0 + call .put_menu_area + xor eax,eax + mov m_cursor_out,eax + jmp .exit .exit_menu_2: - mov m_select,dword 0 - call .put_menu_area - mov edx,m_pos_pointer + mov m_select,dword 0 + call .put_menu_area + mov edx,m_pos_pointer - mov ebx,m_cursor + mov ebx,m_cursor @@: - cmp ebx,0 - jz @f - dec ebx - call .get_next_text - jmp @r + cmp ebx,0 + jz @f + dec ebx + call .get_next_text + jmp @r @@: - mov m_out_select,edx - mov eax,m_cursor - inc eax - mov m_cursor_out,eax + mov m_out_select,edx + mov eax,m_cursor + inc eax + mov m_cursor_out,eax - mov eax,m_mouse_keys - cmp eax,m_mouse_keys_old - jne .exit - xor eax,eax - mov m_cursor_out,eax + mov eax,m_mouse_keys + cmp eax,m_mouse_keys_old + jne .exit + xor eax,eax + mov m_cursor_out,eax .exit: - call .draw_1 - mov m_click,dword 1 - jmp @f + call .draw_1 + mov m_click,dword 1 + jmp @f .exit_menu_1: - mov m_click,dword 0 + mov m_click,dword 0 @@: menu_bar_exit } diff --git a/programs/develop/libraries/box_lib/trunk/scrollbar.mac b/programs/develop/libraries/box_lib/trunk/scrollbar.mac index c92084f814..f16f8d80f9 100644 --- a/programs/develop/libraries/box_lib/trunk/scrollbar.mac +++ b/programs/develop/libraries/box_lib/trunk/scrollbar.mac @@ -1,6 +1,6 @@ ;************************************************************** ; ScrollBar Macro for Kolibri OS -; Copyright (c) 2009, Mario79 +; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ ; names of its contributors may be used to endorse or promote products ; derived from this software without specific prior written permission. ; -; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY +; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY @@ -294,7 +294,6 @@ scroll_bar_vertical: .draw: pusha mov edi,dword [esp+36] -; mov sb_all_redraw,dword 1 mov sb_delta,word 0 call .draw_1 mov sb_all_redraw,dword 0 @@ -309,7 +308,7 @@ scroll_bar_exit sub eax,edx mov sb_work_size,eax ;********************************* - mov eax,sb_work_size ;sb_max_area + mov eax,sb_work_size mov ebx,sb_max_area cmp ebx,sb_cur_area ja @f @@ -494,7 +493,7 @@ draw_down_arrow_vertical pop ecx ror ecx,16 - add ecx,sb_btn_high ;14 shl 16 + add ecx,sb_btn_high rol ecx,16 mov edx,sb_line_col @@ -536,7 +535,7 @@ draw_down_arrow_vertical @@: cmp sb_m_keys,dword 0 - jne @f ;.continue_2 + jne @f mov eax,sb_m_pos mov sb_m_pos_2,eax jmp .correct_1 ;.exit_sb @@ -607,7 +606,7 @@ draw_down_arrow_vertical push eax mov ax,sb_m_pos cmp ax,sb_m_pos_2 - je .correct ;.exit_sb + je .correct shl eax,16 shr eax,16 @@ -675,10 +674,8 @@ draw_down_arrow_vertical mov eax,sb_ar_offset cmp sb_position,eax ;dword 0 -; je .exit_sb jbe @f -; dec dword sb_position sub sb_position,eax jmp .all_sb @@: @@ -699,7 +696,6 @@ draw_down_arrow_vertical @@: mov ebx,sb_btn_high ;16 ;15 -; inc ebx add bx,sb_start_y sub cx,bx sub ax,bx @@ -712,7 +708,6 @@ draw_down_arrow_vertical @@: mov edx,eax -; sub edx,sb_btn_high push ebx shr ebx,1 sub edx,ebx @@ -734,8 +729,7 @@ draw_down_arrow_vertical jbe .continue mov sb_position2,edx -; jmp .continue_1 - + .continue: mov eax,sb_position2 sub ecx,ebx @@ -750,7 +744,7 @@ draw_down_arrow_vertical xor eax,eax inc eax mov sb_position2,eax - jmp .all_sb ;.store_position + jmp .all_sb @@: sub eax,sb_cur_area inc eax @@ -796,10 +790,8 @@ draw_down_arrow_vertical sub eax,ebx cmp sb_position,eax pop eax -; jae .exit_sb jae @f -; inc dword sb_position add sb_position,ebx jmp .all_sb @@: @@ -826,7 +818,6 @@ scroll_bar_horizontal: .draw: pusha mov edi,dword [esp+36] -; mov sb_all_redraw,dword 1 mov sb_delta,word 0 call .draw_1 mov sb_all_redraw,dword 0 @@ -1066,7 +1057,7 @@ draw_down_arrow_horizontal @@: cmp sb_m_keys,dword 0 - jne @f ;.continue_2 + jne @f mov eax,sb_m_pos mov sb_m_pos_2,eax jmp .correct_1 ;.exit_sb @@ -1140,7 +1131,7 @@ draw_down_arrow_horizontal shr eax,16 shr ebx,16 cmp eax,ebx - je .correct ;.exit_sb + je .correct ; shl eax,16 ; shr eax,16 @@ -1208,10 +1199,8 @@ draw_down_arrow_horizontal mov eax,sb_ar_offset cmp sb_position,eax ;dword 0 -; je .exit_sb jbe @f -; dec dword sb_position sub sb_position,eax jmp .all_sb @@: @@ -1232,7 +1221,6 @@ draw_down_arrow_horizontal @@: mov ebx,sb_btn_high ;16 ;15 -; inc ebx add bx,sb_start_x ;y sub cx,bx sub ax,bx @@ -1245,7 +1233,7 @@ draw_down_arrow_horizontal @@: mov edx,eax -; sub edx,sb_btn_high + push ebx shr ebx,1 sub edx,ebx @@ -1267,8 +1255,7 @@ draw_down_arrow_horizontal jbe .continue mov sb_position2,edx -; jmp .continue_1 - + .continue: mov eax,sb_position2 sub ecx,ebx @@ -1283,7 +1270,7 @@ draw_down_arrow_horizontal xor eax,eax inc eax mov sb_position2,eax - jmp .all_sb ;.store_position + jmp .all_sb @@: sub eax,sb_cur_area inc eax @@ -1329,10 +1316,8 @@ draw_down_arrow_horizontal sub eax,ebx cmp sb_position,eax pop eax -; jae .exit_sb jae @f -; inc dword sb_position add sb_position,ebx jmp .all_sb @@: