From 0de6e52a905a351e823697b712fc6eb710ee7a5a Mon Sep 17 00:00:00 2001 From: 0CodErr <0CodErr@kolibrios.org> Date: Mon, 10 Oct 2016 18:58:07 +0000 Subject: [PATCH] Added border styles(raised, sunken, etched, ridged), possibility to fill frame background. git-svn-id: svn://kolibrios.org@6586 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../libraries/box_lib/trunk/box_lib.mac | 34 ++- .../develop/libraries/box_lib/trunk/frame.mac | 280 +++++++++++------- 2 files changed, 205 insertions(+), 109 deletions(-) diff --git a/programs/develop/libraries/box_lib/trunk/box_lib.mac b/programs/develop/libraries/box_lib/trunk/box_lib.mac index 0c7f7d725e..d4b0a4f847 100644 --- a/programs/develop/libraries/box_lib/trunk/box_lib.mac +++ b/programs/develop/libraries/box_lib/trunk/box_lib.mac @@ -498,4 +498,36 @@ PB_MIN equ +24 PB_MAX equ +28 PB_BACK_COLOR equ +32 PB_PROGRESS_COLOR equ +36 -PB_FRAME_COLOR equ +40 \ No newline at end of file +PB_FRAME_COLOR equ +40 + +; *** Frame constants *** ; +FR_STYLE equ +0 ; Dword +FR_WIDTH equ +4 ; Word +FR_LEFT equ +6 ; Word +FR_HEIGHT equ +8 ; Word +FR_TOP equ +10 ; Word +FR_OUTER_COLOR equ +12 ; Dword +FR_INNER_COLOR equ +16 ; Dword +FR_FLAGS equ +20 ; Dword +FR_TEXT equ +24 ; Dword +FR_TEXT_POSITION equ +28 ; Dword +FR_FONT equ +32 ; Dword +FR_FONT_HEIGHT equ +36 ; Dword +FR_FORE_COLOR equ +40 ; Dword +FR_BACK_COLOR equ +44 ; Dword + +; FR_FLAGS = [x][yyy][z] +; z - Caption +; yyy - BorderStyle +; x - BackStyle +FR_CAPTION equ 00001b ; [z] +FR_DOUBLE equ 00000b ; [yyy] +FR_RAISED equ 00010b ; [yyy] +FR_SUNKEN equ 00100b ; [yyy] +FR_ETCHED equ 00110b ; [yyy] +FR_RIDGED equ 01000b ; [yyy] +FR_FILLED equ 10000b ; [x] + +; FR_TEXT_POSITION +FR_TEXT_POS_BOTTOM equ 1 +FR_TEXT_POS_TOP equ 0 \ No newline at end of file diff --git a/programs/develop/libraries/box_lib/trunk/frame.mac b/programs/develop/libraries/box_lib/trunk/frame.mac index aa502c534f..addee52a9b 100644 --- a/programs/develop/libraries/box_lib/trunk/frame.mac +++ b/programs/develop/libraries/box_lib/trunk/frame.mac @@ -1,4 +1,8 @@ ;************************************************************** +; 2016, 0CodErr +; Added border styles(raised, sunken, etched, ridged). +; Added possibility to fill frame background. +;************************************************************** ; Frame Macro for Kolibri OS ; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario ; All rights reserved. @@ -28,7 +32,6 @@ macro frame_start { pusha - mov edi,dword [esp+36] } ;***************************************************************************** macro frame_exit @@ -39,21 +42,22 @@ ret 4 ;***************************************************************************** macro use_frame { +fr equ [esp + 36] frame: -fr_type equ [edi] ;dword -fr_size_x equ [edi+4] ;word -fr_start_x equ [edi+6] ;word -fr_size_y equ [edi+8] ;word -fr_start_y equ [edi+10] ;word -fr_ext_fr_col equ [edi+12] ;dword -fr_int_fr_col equ [edi+16] ;dword -fr_draw_text_flag equ [edi+20] ;dword 0-not,1-yes -fr_text_pointer equ [edi+24] ;dword -fr_text_position equ [edi+28] ;dword 0-up,1-bottom -fr_font_number equ [edi+32] ;dword 0-monospace,1-variable -fr_font_size_y equ [edi+36] ;dword -fr_font_color equ [edi+40] ;dword -fr_font_backgr_color equ [edi+44] ;dword +fr_type equ [eax + FR_STYLE] ; dword +fr_size_x equ [eax + FR_WIDTH] ; word +fr_start_x equ [eax + FR_LEFT] ; word +fr_size_y equ [eax + FR_HEIGHT] ; word +fr_start_y equ [eax + FR_TOP] ; word +fr_ext_fr_col equ [eax + FR_OUTER_COLOR] ; dword +fr_int_fr_col equ [eax + FR_INNER_COLOR] ; dword +fr_flags equ [eax + FR_FLAGS] ; dword +fr_text_pointer equ [eax + FR_TEXT] ; dword +fr_text_position equ [eax + FR_TEXT_POSITION] ; dword +fr_font_number equ [eax + FR_FONT] ; dword +fr_font_size_y equ [eax + FR_FONT_HEIGHT] ; dword +fr_font_color equ [eax + FR_FORE_COLOR] ; dword +fr_font_backgr_color equ [eax + FR_BACK_COLOR] ; dword ;***************************************************************************** ;***************************************************************************** ; draw event @@ -62,97 +66,156 @@ fr_font_backgr_color equ [edi+44] ;dword align 4 .draw: frame_start -;------------------------------------- -; in -; ebx = [coordinate on axis x]*65536 + [size on axis x] -; ecx = [coordinate on axis y]*65536 + [size on axis y] -;-------------------------------------- -; top - mov bx,fr_start_x - shl ebx,16 - mov bx,fr_start_x - add bx,fr_size_x - dec bx - - mov cx,fr_start_y - shl ecx,16 - mov cx,fr_start_y - - mcall 38,,,fr_ext_fr_col - - add ecx,1 shl 16 +1 - add ebx,1 shl 16 - dec ebx - - mcall ,,,fr_int_fr_col -;-------------------------------------- -; bottom - mov bx,fr_start_x - shl ebx,16 - mov bx,fr_start_x - add bx,fr_size_x - dec bx - - mov cx,fr_start_y - add cx,fr_size_y - dec cx - shl ecx,16 - mov cx,fr_start_y - add cx,fr_size_y - dec cx - - mcall ,,,fr_ext_fr_col - - sub ecx,1 shl 16 +1 - add ebx,1 shl 16 - dec ebx - - mcall ,,,fr_int_fr_col -;-------------------------------------- -; left - mov bx,fr_start_x - shl ebx,16 - mov bx,fr_start_x - - mov cx,fr_start_y - shl ecx,16 - mov cx,fr_start_y - add cx,fr_size_y - dec cx - - mcall ,,,fr_ext_fr_col - - add ebx,1 shl 16 +1 - add ecx,1 shl 16 - dec ecx - - mcall ,,,fr_int_fr_col - -;-------------------------------------- -; right - mov bx,fr_start_x - add bx,fr_size_x - dec bx - shl ebx,16 - mov bx,fr_start_x - add bx,fr_size_x - dec bx - - mov cx,fr_start_y - shl ecx,16 - mov cx,fr_start_y - add cx,fr_size_y - dec cx - - mcall ,,,fr_ext_fr_col - - sub ebx,1 shl 16 +1 - add ecx,1 shl 16 - dec ecx - - mcall ,,,fr_int_fr_col + mov eax, fr + mov edx, fr_ext_fr_col + mov edi, fr_int_fr_col + mov esi, edx + mov ebp, edi + mov eax, fr_flags + and eax, 1110b +.raised: + cmp eax, FR_RAISED + je .border_style_selected +.sunken: + cmp eax, FR_SUNKEN + jne .etched + xchg edx, edi + xchg esi, ebp + jmp .border_style_selected +.etched: + cmp eax, FR_ETCHED + jne .ridged + xchg edx, edi + jmp .border_style_selected +.ridged: + cmp eax, FR_RIDGED + jne .double + xchg esi, ebp + jmp .border_style_selected +.double: + cmp eax, FR_DOUBLE + jne .border_style_selected + mov edi, edx + mov esi, ebp +.border_style_selected: +; Outer Top Line + mov eax, fr + mov bx, fr_start_x + mov cx, fr_start_y + shl ebx, 16 + shl ecx, 16 + mov bx, fr_size_x + add bx, fr_start_x + sub ebx, 1 + mov cx, fr_start_y + mov eax, 38 + int 64 +; Outer Left Line + mov eax, fr + mov bx, fr_start_x + add cx, fr_size_y + sub ecx, 1 + mov eax, 38 + int 64 +; Inner Top Line + mov eax, fr + mov bx, fr_start_x + mov cx, fr_start_y + add ebx, 1 + add ecx, 1 + shl ebx, 16 + shl ecx, 16 + mov bx, fr_size_x + mov cx, fr_start_y + add bx, fr_start_x + sub ebx, 2 + add ecx, 1 + mov edx, esi + mov eax, 38 + int 64 +; Inner Left Line + mov eax, fr + mov bx, fr_start_x + add cx, fr_size_y + add ebx, 1 + sub ecx, 3 + mov edx, esi + mov eax, 38 + int 64 +; Outer Bottom Line + mov eax, fr + mov bx, fr_size_x + mov cx, fr_size_y + add bx, fr_start_x + add cx, fr_start_y + sub ebx, 1 + sub ecx, 1 + shl ebx, 16 + shl ecx, 16 + mov bx, fr_start_x + mov cx, fr_size_y + add cx, fr_start_y + sub ecx, 1 + mov edx, edi + mov eax, 38 + int 64 +; Outer Right Line + mov eax, fr + add bx, fr_size_x + sub ebx, 1 + mov cx, fr_start_y + mov edx, edi + mov eax, 38 + int 64 +; Inner Bottom Line + mov eax, fr + mov bx, fr_size_x + mov cx, fr_size_y + add bx, fr_start_x + add cx, fr_start_y + sub ebx, 2 + sub ecx, 2 + shl ebx, 16 + shl ecx, 16 + mov bx, fr_start_x + mov cx, fr_size_y + add cx, fr_start_y + add ebx, 1 + sub ecx, 2 + mov edx, ebp + mov eax, 38 + int 64 +; Inner Right Line + mov eax, fr + mov cx, fr_start_y + add bx, fr_size_x + sub ebx, 3 + add ecx, 1 + mov edx, ebp + mov eax, 38 + int 64 ;---------------------------------------------------------------------- - cmp fr_draw_text_flag,dword 0 + mov eax, fr + test dword fr_flags, FR_FILLED + je .fill_exit + + mov bx, fr_start_x + mov cx, fr_start_y + add ebx, 2 + add ecx, 2 + shl ebx, 16 + shl ecx, 16 + mov bx, fr_size_x + mov cx, fr_size_y + sub ebx, 4 + sub ecx, 4 + mov edx, fr_font_backgr_color + mov eax, 13 + int 64 +.fill_exit: +;---------------------------------------------------------------------- + mov eax, fr + test dword fr_flags, FR_CAPTION je .exit mov ecx,0xC0000000 @@ -160,6 +223,7 @@ frame_start and eax,11b shl eax,28 add ecx,eax + mov eax, fr mov eax,fr_font_color and eax,0xffffff add ecx,eax @@ -171,6 +235,7 @@ frame_start xor esi,esi + mov eax, fr mov bx,fr_start_x add bx,10 shl ebx,16 @@ -194,10 +259,9 @@ align 4 ;-------------------------------------- align 4 .draw_1: - push edi - mov edi,eax + mov edx,fr_text_pointer + mov edi,fr_font_backgr_color mcall 4 - pop edi ;---------------------------------------------------------------------- align 4 .exit: