Subversion Repositories Kolibri OS

Rev

Rev 3471 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3470 mario79 1
;**************************************************************
6586 0CodErr 2
; 2016, 0CodErr
3
;       Added border styles(raised, sunken, etched, ridged).
4
;       Added possibility to fill frame background.
5
;**************************************************************
3470 mario79 6
; Frame Macro for Kolibri OS
7
; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
8
; All rights reserved.
9
;
10
; Redistribution and use in source and binary forms, with or without
11
; modification, are permitted provided that the following conditions are met:
12
;     * Redistributions of source code must retain the above copyright
13
;       notice, this list of conditions and the following disclaimer.
14
;     * Redistributions in binary form must reproduce the above copyright
15
;       notice, this list of conditions and the following disclaimer in the
16
;       documentation and/or other materials provided with the distribution.
17
;     * Neither the name of the  nor the
18
;       names of its contributors may be used to endorse or promote products
19
;       derived from this software without specific prior written permission.
20
;
21
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
22
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
25
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
;*****************************************************************************
32
macro frame_start
33
{
34
	pusha
35
}
36
;*****************************************************************************
37
macro frame_exit
38
{
39
popa
40
ret 4
41
}
42
;*****************************************************************************
43
macro use_frame
44
{
6586 0CodErr 45
fr equ [esp + 36]
3470 mario79 46
frame:
6586 0CodErr 47
fr_type              equ [eax + FR_STYLE]         ; dword
48
fr_size_x            equ [eax + FR_WIDTH]         ;  word
49
fr_start_x           equ [eax + FR_LEFT]          ;  word
50
fr_size_y            equ [eax + FR_HEIGHT]        ;  word
51
fr_start_y           equ [eax + FR_TOP]           ;  word
52
fr_ext_fr_col        equ [eax + FR_OUTER_COLOR]   ; dword
53
fr_int_fr_col        equ [eax + FR_INNER_COLOR]   ; dword
54
fr_flags             equ [eax + FR_FLAGS]         ; dword
55
fr_text_pointer      equ [eax + FR_TEXT]          ; dword
56
fr_text_position     equ [eax + FR_TEXT_POSITION] ; dword
57
fr_font_number       equ [eax + FR_FONT]          ; dword
58
fr_font_size_y       equ [eax + FR_FONT_HEIGHT]   ; dword
59
fr_font_color        equ [eax + FR_FORE_COLOR]    ; dword
60
fr_font_backgr_color equ [eax + FR_BACK_COLOR]    ; dword
3470 mario79 61
;*****************************************************************************
62
;*****************************************************************************
63
; draw event
64
;*****************************************************************************
65
;*****************************************************************************
66
align 4
67
.draw:
68
frame_start
6586 0CodErr 69
        mov    eax, fr
70
        mov    edx, fr_ext_fr_col
71
        mov    edi, fr_int_fr_col
72
        mov    esi, edx
73
        mov    ebp, edi
74
        mov    eax, fr_flags
75
        and    eax, 1110b
76
.raised:
77
        cmp    eax, FR_RAISED
78
        je     .border_style_selected
79
.sunken:
80
        cmp    eax, FR_SUNKEN
81
        jne    .etched
82
        xchg   edx, edi
83
        xchg   esi, ebp
84
        jmp    .border_style_selected
85
.etched:
86
        cmp    eax, FR_ETCHED
87
        jne    .ridged
88
        xchg   edx, edi
89
        jmp    .border_style_selected
90
.ridged:
91
        cmp    eax, FR_RIDGED
92
        jne    .double
93
        xchg   esi, ebp
94
        jmp    .border_style_selected
95
.double:
96
        cmp    eax, FR_DOUBLE
97
        jne    .border_style_selected
98
        mov    edi, edx
99
        mov    esi, ebp
100
.border_style_selected:
101
; Outer Top Line
102
        mov    eax, fr
103
        mov    bx, fr_start_x
104
        mov    cx, fr_start_y
105
        shl    ebx, 16
106
        shl    ecx, 16
107
        mov    bx, fr_size_x
108
        add    bx, fr_start_x
109
        sub    ebx, 1
110
        mov    cx, fr_start_y
111
        mov    eax, 38
112
        int    64
113
; Outer Left Line
114
        mov    eax, fr
115
        mov    bx, fr_start_x
116
        add    cx, fr_size_y
117
        sub    ecx, 1
118
        mov    eax, 38
119
        int    64
120
; Inner Top Line
121
        mov    eax, fr
122
        mov    bx, fr_start_x
123
        mov    cx, fr_start_y
124
        add    ebx, 1
125
        add    ecx, 1
126
        shl    ebx, 16
127
        shl    ecx, 16
128
        mov    bx, fr_size_x
129
        mov    cx, fr_start_y
130
        add    bx, fr_start_x
131
        sub    ebx, 2
132
        add    ecx, 1
133
        mov    edx, esi
134
        mov    eax, 38
135
        int    64
136
; Inner Left Line
137
        mov    eax, fr
138
        mov    bx, fr_start_x
139
        add    cx, fr_size_y
140
        add    ebx, 1
141
        sub    ecx, 3
142
        mov    edx, esi
143
        mov    eax, 38
144
        int    64
145
; Outer Bottom Line
146
        mov    eax, fr
147
        mov    bx, fr_size_x
148
        mov    cx, fr_size_y
149
        add    bx, fr_start_x
150
        add    cx, fr_start_y
151
        sub    ebx, 1
152
        sub    ecx, 1
153
        shl    ebx, 16
154
        shl    ecx, 16
155
        mov    bx, fr_start_x
156
        mov    cx, fr_size_y
157
        add    cx, fr_start_y
158
        sub    ecx, 1
159
        mov    edx, edi
160
        mov    eax, 38
161
        int    64
162
; Outer Right Line
163
        mov    eax, fr
164
        add    bx, fr_size_x
165
        sub    ebx, 1
166
        mov    cx, fr_start_y
167
        mov    edx, edi
168
        mov    eax, 38
169
        int    64
170
; Inner Bottom Line
171
        mov    eax, fr
172
        mov    bx, fr_size_x
173
        mov    cx, fr_size_y
174
        add    bx, fr_start_x
175
        add    cx, fr_start_y
176
        sub    ebx, 2
177
        sub    ecx, 2
178
        shl    ebx, 16
179
        shl    ecx, 16
180
        mov    bx, fr_start_x
181
        mov    cx, fr_size_y
182
        add    cx, fr_start_y
183
        add    ebx, 1
184
        sub    ecx, 2
185
        mov    edx, ebp
186
        mov    eax, 38
187
        int    64
188
; Inner Right Line
189
        mov    eax, fr
190
        mov    cx, fr_start_y
191
        add    bx, fr_size_x
192
        sub    ebx, 3
193
        add    ecx, 1
194
        mov    edx, ebp
195
        mov    eax, 38
196
        int    64
3470 mario79 197
;----------------------------------------------------------------------
6586 0CodErr 198
        mov    eax, fr
199
        test   dword fr_flags, FR_FILLED
200
        je     .fill_exit
201
 
202
        mov    bx, fr_start_x
203
        mov    cx, fr_start_y
204
        add    ebx, 2
205
        add    ecx, 2
206
        shl    ebx, 16
207
        shl    ecx, 16
208
        mov    bx, fr_size_x
209
        mov    cx, fr_size_y
210
        sub    ebx, 4
211
        sub    ecx, 4
212
        mov    edx, fr_font_backgr_color
213
        mov    eax, 13
214
        int    64
215
.fill_exit:
216
;----------------------------------------------------------------------
217
        mov    eax, fr
218
        test    dword fr_flags, FR_CAPTION
3470 mario79 219
	je	.exit
220
 
221
	mov	ecx,0xC0000000
222
	mov	eax,fr_font_number
223
	and	eax,11b
224
	shl	eax,28
225
	add	ecx,eax
6586 0CodErr 226
        mov    eax, fr
3470 mario79 227
	mov	eax,fr_font_color
228
	and	eax,0xffffff
229
	add	ecx,eax
230
 
231
	mov	edx,fr_text_pointer
232
 
233
	mov	eax,fr_font_backgr_color
234
	and	eax,0xffffff
235
 
236
	xor	esi,esi
237
 
6586 0CodErr 238
        mov    eax, fr
3470 mario79 239
	mov	bx,fr_start_x
240
	add	bx,10
241
	shl	ebx,16
242
	mov	bx,fr_font_size_y
243
	shr	bx,1
244
 
245
	not	bx
246
	add	bx,fr_start_y
247
 
248
	test	fr_font_size_y,word 1b
249
	jz	@f
250
 
251
	inc	bx
252
;--------------------------------------
253
align 4
254
@@:
255
	cmp	fr_text_position,dword 0
256
	je	.draw_1
257
 
258
	add	bx,fr_size_y
259
;--------------------------------------
260
align 4
261
.draw_1:
6586 0CodErr 262
        mov     edx,fr_text_pointer
263
        mov     edi,fr_font_backgr_color
3470 mario79 264
	mcall	4
265
;----------------------------------------------------------------------
266
align 4
267
.exit:
268
frame_exit
269
}
270
;*****************************************************************************