Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
129 mikedld 1
include "skindata.inc"
2
 
384 mikedld 3
;skin_data = 0x00778000
129 mikedld 4
 
5
load_skin_file:
6
; eax = filename
7
; edx = destination
8
    mov   ebx,1
9
    or    ecx,-1
10
    mov   esi,12
11
    call  fileread
12
    ret
13
 
14
struct SKIN_HEADER
15
  .ident   dd ?
16
  .version dd ?
17
  .params  dd ?
18
  .buttons dd ?
19
  .bitmaps dd ?
20
ends
21
 
22
struct SKIN_PARAMS
23
  .skin_height    dd ?
24
  .margin.right   dw ?
25
  .margin.left    dw ?
26
  .margin.bottom  dw ?
27
  .margin.top     dw ?
28
  .colors.inner   dd ?
29
  .colors.outer   dd ?
30
  .colors.frame   dd ?
31
  .colors_1.inner dd ?
32
  .colors_1.outer dd ?
33
  .colors_1.frame dd ?
34
  .dtp.size       dd ?
35
  .dtp.data       db 40 dup (?)
36
ends
37
 
38
struct SKIN_BUTTONS
39
  .type     dd ?
40
  .pos:
41
    .left   dw ?
42
    .top    dw ?
43
  .size:
44
    .width  dw ?
45
    .height dw ?
46
ends
47
 
48
struct SKIN_BITMAPS
49
  .kind  dw ?
50
  .type  dw ?
51
  .data  dd ?
52
ends
53
 
54
load_skin:
55
        pushad
56
        mov     [_skinh],22
57
        mov     eax,_skin_file
58
        mov     edx,skin_data
59
        mov     [edx+SKIN_HEADER.ident],'????'
60
        call    load_skin_file
61
        cmp     eax,ERROR_SUCCESS
62
        je      @f
63
        cmp     eax,ERROR_END_OF_FILE
64
        jne     .exit
65
    @@: call    parse_skin_data
66
  .exit:
67
        popad
68
        ret
69
 
70
parse_skin_data:
71
        mov     ebp,skin_data
72
        cmp     [ebp+SKIN_HEADER.ident],'SKIN'
73
        jne     .exit
74
 
75
        mov     edi,skin_udata
76
        mov     ecx,(skin_udata.end-skin_udata)/4
77
        xor     eax,eax
78
        cld
79
        rep	stosd
80
 
81
        mov     ebx,[ebp+SKIN_HEADER.params]
82
        add     ebx,skin_data
83
        mov     eax,[ebx+SKIN_PARAMS.skin_height]
84
        mov     [_skinh],eax
85
        mov     eax,[ebx+SKIN_PARAMS.colors.inner]
86
        mov     [skin_active.colors.inner],eax
87
        mov     eax,[ebx+SKIN_PARAMS.colors.outer]
88
        mov     [skin_active.colors.outer],eax
89
        mov     eax,[ebx+SKIN_PARAMS.colors.frame]
90
        mov     [skin_active.colors.frame],eax
91
        mov     eax,[ebx+SKIN_PARAMS.colors_1.inner]
92
        mov     [skin_inactive.colors.inner],eax
93
        mov     eax,[ebx+SKIN_PARAMS.colors_1.outer]
94
        mov     [skin_inactive.colors.outer],eax
95
        mov     eax,[ebx+SKIN_PARAMS.colors_1.frame]
96
        mov     [skin_inactive.colors.frame],eax
97
        lea     esi,[ebx+SKIN_PARAMS.dtp.data]
98
        mov     edi,common_colours
99
        mov     ecx,[ebx+SKIN_PARAMS.dtp.size]
100
        and     ecx,127
101
        rep     movsb
102
        mov     eax,dword[ebx+SKIN_PARAMS.margin.right]
103
        mov     dword[_skinmargins+0],eax
104
        mov     eax,dword[ebx+SKIN_PARAMS.margin.bottom]
105
        mov     dword[_skinmargins+4],eax
106
 
107
        mov     ebx,[ebp+SKIN_HEADER.bitmaps]
108
        add     ebx,skin_data
109
  .lp1: cmp     dword[ebx],0
110
        je      .end_bitmaps
111
        movzx   eax,[ebx+SKIN_BITMAPS.kind]
112
        movzx   ecx,[ebx+SKIN_BITMAPS.type]
113
        dec     eax
114
        jnz     .not_left
115
        xor     eax,eax
116
        mov     edx,skin_active.left.data
117
        or      ecx,ecx
118
        jnz     @f
119
        mov     edx,skin_inactive.left.data
120
    @@: jmp     .next_bitmap
121
  .not_left:
122
        dec     eax
123
        jnz     .not_oper
124
        mov     esi,[ebx+SKIN_BITMAPS.data]
125
        add     esi,skin_data
126
        mov     eax,[esi+0]
127
        neg     eax
128
        mov     edx,skin_active.oper.data
129
        or      ecx,ecx
130
        jnz     @f
131
        mov     edx,skin_inactive.oper.data
132
    @@: jmp     .next_bitmap
133
  .not_oper:
134
        dec     eax
135
        jnz     .not_base
136
        mov     eax,[skin_active.left.width]
137
        mov     edx,skin_active.base.data
138
        or      ecx,ecx
139
        jnz     @f
140
        mov     eax,[skin_inactive.left.width]
141
        mov     edx,skin_inactive.base.data
142
    @@: jmp     .next_bitmap
143
  .not_base:
144
        add     ebx,8
145
        jmp     .lp1
146
  .next_bitmap:
147
        mov     ecx,[ebx+SKIN_BITMAPS.data]
148
        add     ecx,skin_data
149
        mov     [edx+4],eax
150
        mov     eax,[ecx+0]
151
        mov     [edx+8],eax
152
        add     ecx,8
153
        mov     [edx+0],ecx
154
        add     ebx,8
155
        jmp     .lp1
156
  .end_bitmaps:
157
 
158
        mov     ebx,[ebp+SKIN_HEADER.buttons]
159
        add     ebx,skin_data
160
  .lp2: cmp     dword[ebx],0
161
        je      .end_buttons
162
        mov     eax,[ebx+SKIN_BUTTONS.type]
163
        dec     eax
164
        jnz     .not_close
165
        mov     edx,skin_btn_close
166
        jmp     .next_button
167
  .not_close:
168
        dec     eax
169
        jnz     .not_minimize
170
        mov     edx,skin_btn_minimize
171
        jmp     .next_button
172
  .not_minimize:
173
        add     ebx,12
174
        jmp     .lp2
175
  .next_button:
176
        movsx   eax,[ebx+SKIN_BUTTONS.left]
177
        mov     [edx+SKIN_BUTTON.left],eax
178
        movsx   eax,[ebx+SKIN_BUTTONS.top]
179
        mov     [edx+SKIN_BUTTON.top],eax
180
        movsx   eax,[ebx+SKIN_BUTTONS.width]
181
        mov     [edx+SKIN_BUTTON.width],eax
182
        movsx   eax,[ebx+SKIN_BUTTONS.height]
183
        mov     [edx+SKIN_BUTTON.height],eax
184
        add     ebx,12
185
        jmp     .lp2
186
  .end_buttons:
187
 
188
  .exit:
189
        ret
190
 
191
sys_putimage_with_check:
192
	or	ebx,ebx
193
	jz	@f
194
	call	[putimage]
195
    @@: ret
196
 
197
drawwindow_IV_caption:
198
 
199
        mov     ebp,skin_active
200
        or      al,al
201
        jnz     @f
202
        mov     ebp,skin_inactive
203
    @@:
204
 
205
        mov     esi,[esp+4]
206
        mov     eax,[esi+WDATA.box.width]    ; window width
207
        mov     edx,[ebp+SKIN_DATA.left.left]
208
        shl     edx,16
209
        mov     ecx,[ebp+SKIN_DATA.left.width]
210
        shl     ecx,16
211
        add     ecx,[_skinh]
212
 
213
        mov     ebx, [ebp+SKIN_DATA.left.data]
214
        call    sys_putimage_with_check
215
 
216
        mov     esi,[esp+4]
217
        mov     eax,[esi+WDATA.box.width]
218
        sub     eax,[ebp+SKIN_DATA.left.width]
219
        sub     eax,[ebp+SKIN_DATA.oper.width]
220
        cmp     eax,[ebp+SKIN_DATA.base.left]
221
        jng     .non_base
222
        xor     edx,edx
223
        mov     ecx,[ebp+SKIN_DATA.base.width]
224
        jecxz   .non_base
225
        div     ecx
226
 
227
        inc     eax
228
 
229
        mov     ebx,[ebp+SKIN_DATA.base.data]
230
        mov     ecx,[ebp+SKIN_DATA.base.width]
231
        shl     ecx,16
232
        add     ecx,[_skinh]
233
        mov     edx,[ebp+SKIN_DATA.base.left]
234
        sub     edx,[ebp+SKIN_DATA.base.width]
235
        shl     edx,16
236
  .baseskinloop:
237
        shr     edx,16
238
        add     edx,[ebp+SKIN_DATA.base.width]
239
        shl     edx,16
240
 
241
        push    eax ebx ecx edx
242
        call    sys_putimage_with_check
243
        pop     edx ecx ebx eax
244
 
245
        dec     eax
246
        jnz     .baseskinloop
247
  .non_base:
248
 
249
        mov     esi,[esp+4]
250
        mov     edx,[esi+WDATA.box.width]
251
        sub     edx,[ebp+SKIN_DATA.oper.width]
252
        inc     edx
253
        shl     edx,16
254
        mov     ebx,[ebp+SKIN_DATA.oper.data]
255
 
256
        mov     ecx,[ebp+SKIN_DATA.oper.width]
257
        shl     ecx,16
258
        add     ecx,[_skinh]
259
        call    sys_putimage_with_check
260
 
261
        ret
262
 
263
;//mike.dld, 2006-08-02 ]
264
 
265
 
266
drawwindow_IV:
267
;param1 - aw_yes
268
 
269
        pusha
270
 
271
        push  edx
272
 
384 mikedld 273
        mov   edi,edx
129 mikedld 274
 
275
        mov     ebp,skin_active
276
        cmp     byte [esp+32+4+4],0
277
        jne     @f
278
        mov     ebp,skin_inactive
279
     @@:
280
 
281
        mov   eax,[edi+WDATA.box.left]
282
        shl   eax,16
283
		mov   ax,word [edi+WDATA.box.left]
284
		add   ax,word [edi+WDATA.box.width]
285
        mov   ebx,[edi+WDATA.box.top]
286
        shl   ebx,16
287
		mov   bx,word [edi+WDATA.box.top]
288
		add   bx,word [edi+WDATA.box.height]
289
;        mov   esi,[edi+24]
290
;        shr   esi,1
291
;        and   esi,0x007f7f7f
292
        mov   esi,[ebp+SKIN_DATA.colors.outer]
384 mikedld 293
        or      [edi+WDATA.fl_wdrawn], 4
129 mikedld 294
        call  draw_rectangle
295
        mov   ecx,3
296
      _dw3l:
297
        add   eax,1*65536-1
298
        add   ebx,1*65536-1
299
        test  ax,ax
300
        js    no_skin_add_button
301
        test  bx,bx
302
        js    no_skin_add_button
303
        mov   esi,[ebp+SKIN_DATA.colors.frame] ;[edi+24]
304
        call  draw_rectangle
305
        dec   ecx
306
        jnz   _dw3l
307
        mov   esi,[ebp+SKIN_DATA.colors.inner]
308
        add   eax,1*65536-1
309
        add   ebx,1*65536-1
310
        test  ax,ax
311
        js    no_skin_add_button
312
        test  bx,bx
313
        js    no_skin_add_button
314
        call  draw_rectangle
315
 
316
        cmp   dword[skin_data],'SKIN'
317
        je    @f
318
        xor   eax,eax
319
        xor   ebx,ebx
320
        mov   esi,[esp]
321
        mov   ecx,[esi+WDATA.box.width]
322
        inc   ecx
323
        mov   edx,[_skinh]
324
        mov   edi,[common_colours+4] ; standard grab color
325
        call  [drawbar]
326
        jmp   draw_clientbar
327
    @@:
328
 
329
        mov     al,[esp+32+4+4]
330
        call    drawwindow_IV_caption
331
 
332
    draw_clientbar:
333
 
334
        mov   esi,[esp]
335
 
336
        mov   edx,[esi+WDATA.box.top]                       ; WORK AREA
337
        add   edx,21+5
338
        mov   ebx,[esi+WDATA.box.top]
339
        add   ebx,[esi+WDATA.box.height]
340
        cmp   edx,ebx
341
        jg    _noinside2
342
        mov   eax,5
343
        mov   ebx,[_skinh]
344
        mov   ecx,[esi+WDATA.box.width]
345
        mov   edx,[esi+WDATA.box.height]
346
        sub   ecx,4
347
        sub   edx,4
348
        mov   edi,[esi+WDATA.cl_workarea]
384 mikedld 349
	test  edi,0x40000000
350
	jnz   _noinside2
129 mikedld 351
        call  [drawbar]
352
      _noinside2:
353
 
354
        cmp   dword[skin_data],'SKIN'
355
        jne   no_skin_add_button
356
 
357
;* close button
384 mikedld 358
        mov   edi,[BTN_ADDR]
129 mikedld 359
        movzx eax,word [edi]
360
        cmp   eax,1000
361
        jge   no_skin_add_button
362
        inc   eax
363
        mov   [edi],ax
364
 
365
        shl   eax,4
366
        add   eax,edi
367
 
384 mikedld 368
        mov   bx,[CURRENT_TASK]
129 mikedld 369
        mov   [eax],bx
370
 
371
        add   eax,2         ; save button id number
372
        mov   bx,1
373
        mov   [eax],bx
374
        add   eax,2         ; x start
375
        xor   ebx,ebx
376
        cmp   [skin_btn_close.left],0
377
        jge   _bCx_at_right
378
        mov   ebx,[esp]
379
        mov   ebx,[ebx+WDATA.box.width]
380
        inc   ebx
381
      _bCx_at_right:
382
        add   ebx,[skin_btn_close.left]
383
        mov   [eax],bx
384
        add   eax,2         ; x size
385
        mov   ebx,[skin_btn_close.width]
386
        dec   ebx
387
        mov   [eax],bx
388
        add   eax,2         ; y start
389
        mov   ebx,[skin_btn_close.top]
390
        mov   [eax],bx
391
        add   eax,2         ; y size
392
        mov   ebx,[skin_btn_close.height]
393
        dec   ebx
394
        mov   [eax],bx
395
 
396
;* minimize button
384 mikedld 397
        mov   edi,[BTN_ADDR]
129 mikedld 398
        movzx eax,word [edi]
399
        cmp   eax,1000
400
        jge   no_skin_add_button
401
        inc   eax
402
        mov   [edi],ax
403
 
404
        shl   eax,4
405
        add   eax,edi
406
 
384 mikedld 407
        mov   bx,[CURRENT_TASK]
129 mikedld 408
        mov   [eax],bx
409
 
410
        add   eax,2         ; save button id number
411
        mov   bx,65535 ;999
412
        mov   [eax],bx
413
        add   eax,2         ; x start
414
        xor   ebx,ebx
415
        cmp   [skin_btn_minimize.left],0
416
        jge   _bMx_at_right
417
        mov   ebx,[esp]
418
        mov   ebx,[ebx+WDATA.box.width]
419
        inc   ebx
420
      _bMx_at_right:
421
        add   ebx,[skin_btn_minimize.left]
422
        mov   [eax],bx
423
        add   eax,2         ; x size
424
        mov   ebx,[skin_btn_minimize.width]
425
        dec   ebx
426
        mov   [eax],bx
427
        add   eax,2         ; y start
428
        mov   ebx,[skin_btn_minimize.top]
429
        mov   [eax],bx
430
        add   eax,2         ; y size
431
        mov   ebx,[skin_btn_minimize.height]
432
        dec   ebx
433
        mov   [eax],bx
434
 
435
      no_skin_add_button:
384 mikedld 436
        pop     edi
437
        and     [edi+WDATA.fl_wdrawn], not 4
438
        test    [edi+WDATA.fl_wdrawn], 2
439
        jz      @f
440
        call    drawwindowframes
441
@@:
129 mikedld 442
 
443
        popa
444
 
445
        ret  4
446