Added border styles(raised, sunken, etched, ridged), possibility to fill frame background.

git-svn-id: svn://kolibrios.org@6586 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
0CodErr 2016-10-10 18:58:07 +00:00
parent e47ae79991
commit 0de6e52a90
2 changed files with 205 additions and 109 deletions

View File

@ -499,3 +499,35 @@ PB_MAX equ +28
PB_BACK_COLOR equ +32 PB_BACK_COLOR equ +32
PB_PROGRESS_COLOR equ +36 PB_PROGRESS_COLOR equ +36
PB_FRAME_COLOR equ +40 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

View File

@ -1,4 +1,8 @@
;************************************************************** ;**************************************************************
; 2016, 0CodErr
; Added border styles(raised, sunken, etched, ridged).
; Added possibility to fill frame background.
;**************************************************************
; Frame Macro for Kolibri OS ; Frame Macro for Kolibri OS
; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario ; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
; All rights reserved. ; All rights reserved.
@ -28,7 +32,6 @@
macro frame_start macro frame_start
{ {
pusha pusha
mov edi,dword [esp+36]
} }
;***************************************************************************** ;*****************************************************************************
macro frame_exit macro frame_exit
@ -39,21 +42,22 @@ ret 4
;***************************************************************************** ;*****************************************************************************
macro use_frame macro use_frame
{ {
fr equ [esp + 36]
frame: frame:
fr_type equ [edi] ;dword fr_type equ [eax + FR_STYLE] ; dword
fr_size_x equ [edi+4] ;word fr_size_x equ [eax + FR_WIDTH] ; word
fr_start_x equ [edi+6] ;word fr_start_x equ [eax + FR_LEFT] ; word
fr_size_y equ [edi+8] ;word fr_size_y equ [eax + FR_HEIGHT] ; word
fr_start_y equ [edi+10] ;word fr_start_y equ [eax + FR_TOP] ; word
fr_ext_fr_col equ [edi+12] ;dword fr_ext_fr_col equ [eax + FR_OUTER_COLOR] ; dword
fr_int_fr_col equ [edi+16] ;dword fr_int_fr_col equ [eax + FR_INNER_COLOR] ; dword
fr_draw_text_flag equ [edi+20] ;dword 0-not,1-yes fr_flags equ [eax + FR_FLAGS] ; dword
fr_text_pointer equ [edi+24] ;dword fr_text_pointer equ [eax + FR_TEXT] ; dword
fr_text_position equ [edi+28] ;dword 0-up,1-bottom fr_text_position equ [eax + FR_TEXT_POSITION] ; dword
fr_font_number equ [edi+32] ;dword 0-monospace,1-variable fr_font_number equ [eax + FR_FONT] ; dword
fr_font_size_y equ [edi+36] ;dword fr_font_size_y equ [eax + FR_FONT_HEIGHT] ; dword
fr_font_color equ [edi+40] ;dword fr_font_color equ [eax + FR_FORE_COLOR] ; dword
fr_font_backgr_color equ [edi+44] ;dword fr_font_backgr_color equ [eax + FR_BACK_COLOR] ; dword
;***************************************************************************** ;*****************************************************************************
;***************************************************************************** ;*****************************************************************************
; draw event ; draw event
@ -62,97 +66,156 @@ fr_font_backgr_color equ [edi+44] ;dword
align 4 align 4
.draw: .draw:
frame_start frame_start
;------------------------------------- mov eax, fr
; in mov edx, fr_ext_fr_col
; ebx = [coordinate on axis x]*65536 + [size on axis x] mov edi, fr_int_fr_col
; ecx = [coordinate on axis y]*65536 + [size on axis y] mov esi, edx
;-------------------------------------- mov ebp, edi
; top 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 bx, fr_start_x
mov cx, fr_start_y
shl ebx, 16 shl ebx, 16
mov bx,fr_start_x
add bx,fr_size_x
dec bx
mov cx,fr_start_y
shl ecx, 16 shl ecx, 16
mov bx, fr_size_x
add bx, fr_start_x
sub ebx, 1
mov cx, fr_start_y mov cx, fr_start_y
mov eax, 38
mcall 38,,,fr_ext_fr_col int 64
; Outer Left Line
add ecx,1 shl 16 +1 mov eax, fr
add ebx,1 shl 16
dec ebx
mcall ,,,fr_int_fr_col
;--------------------------------------
; bottom
mov bx, fr_start_x 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 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 shl ecx, 16
mov bx, fr_size_x
mov cx, fr_start_y mov cx, fr_start_y
add cx,fr_size_y add bx, fr_start_x
dec cx sub ebx, 2
add ecx, 1
mcall ,,,fr_ext_fr_col mov edx, esi
mov eax, 38
sub ecx,1 shl 16 +1 int 64
add ebx,1 shl 16 ; Inner Left Line
dec ebx mov eax, fr
mcall ,,,fr_int_fr_col
;--------------------------------------
; left
mov bx, fr_start_x 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 ebx, 16
mov bx,fr_start_x
mov cx,fr_start_y
shl ecx, 16 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 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 add bx, fr_size_x
dec bx 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 ebx, 16
mov bx,fr_start_x
add bx,fr_size_x
dec bx
mov cx,fr_start_y
shl ecx, 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 mov cx, fr_start_y
add cx,fr_size_y add bx, fr_size_x
dec cx sub ebx, 3
add ecx, 1
mcall ,,,fr_ext_fr_col mov edx, ebp
mov eax, 38
sub ebx,1 shl 16 +1 int 64
add ecx,1 shl 16
dec ecx
mcall ,,,fr_int_fr_col
;---------------------------------------------------------------------- ;----------------------------------------------------------------------
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 je .exit
mov ecx,0xC0000000 mov ecx,0xC0000000
@ -160,6 +223,7 @@ frame_start
and eax,11b and eax,11b
shl eax,28 shl eax,28
add ecx,eax add ecx,eax
mov eax, fr
mov eax,fr_font_color mov eax,fr_font_color
and eax,0xffffff and eax,0xffffff
add ecx,eax add ecx,eax
@ -171,6 +235,7 @@ frame_start
xor esi,esi xor esi,esi
mov eax, fr
mov bx,fr_start_x mov bx,fr_start_x
add bx,10 add bx,10
shl ebx,16 shl ebx,16
@ -194,10 +259,9 @@ align 4
;-------------------------------------- ;--------------------------------------
align 4 align 4
.draw_1: .draw_1:
push edi mov edx,fr_text_pointer
mov edi,eax mov edi,fr_font_backgr_color
mcall 4 mcall 4
pop edi
;---------------------------------------------------------------------- ;----------------------------------------------------------------------
align 4 align 4
.exit: .exit: