Subversion Repositories Kolibri OS

Rev

Rev 6586 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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