Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2455 mario79 3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 2455 $
9
 
10
 
11
include "skindata.inc"
12
 
13
;skin_data = 0x00778000
2436 mario79 14
;------------------------------------------------------------------------------
15
align 4
2288 clevermous 16
read_skin_file:
17
        stdcall load_file, ebx
18
        test    eax, eax
19
        jz      .notfound
20
        cmp     dword [eax], 'SKIN'
21
        jnz     .noskin
22
        cmp     ebx, 32*1024
23
        jb      @f
24
        mov     ebx, 32*1024
2436 mario79 25
;--------------------------------------
26
align 4
2288 clevermous 27
@@:
28
        lea     ecx, [ebx+3]
29
        shr     ecx, 2
30
        mov     esi, eax
31
        mov     edi, skin_data
32
        rep movsd
33
        stdcall kernel_free, eax
34
 
35
        call    parse_skin_data
36
        xor     eax, eax
37
        ret
2436 mario79 38
;--------------------------------------
39
align 4
2288 clevermous 40
.notfound:
41
        xor     eax, eax
42
        inc     eax
43
        ret
2436 mario79 44
;--------------------------------------
45
align 4
2288 clevermous 46
.noskin:
47
        stdcall kernel_free, eax
48
        push    2
49
        pop     eax
50
        ret
2436 mario79 51
;------------------------------------------------------------------------------
2381 hidnplayr 52
struct  SKIN_HEADER
53
        ident           dd ?
54
        version         dd ?
55
        params          dd ?
56
        buttons         dd ?
57
        bitmaps         dd ?
2288 clevermous 58
ends
59
 
2381 hidnplayr 60
struct  SKIN_PARAMS
61
        skin_height     dd ?
62
        margin.right    dw ?
63
        margin.left     dw ?
64
        margin.bottom   dw ?
65
        margin.top      dw ?
66
        colors.inner    dd ?
67
        colors.outer    dd ?
68
        colors.frame    dd ?
69
        colors_1.inner  dd ?
70
        colors_1.outer  dd ?
71
        colors_1.frame  dd ?
72
        dtp.size        dd ?
73
        dtp.data        rb 40
2288 clevermous 74
ends
75
 
2381 hidnplayr 76
struct  SKIN_BUTTONS
77
        type    dd ?
78
; position
79
        left    dw ?
80
        top     dw ?
81
; size
82
        width   dw ?
83
        height  dw ?
2288 clevermous 84
ends
85
 
2381 hidnplayr 86
struct  SKIN_BITMAPS
87
        kind    dw ?
88
        type    dw ?
89
        data    dd ?
2288 clevermous 90
ends
2436 mario79 91
;------------------------------------------------------------------------------
92
align 4
2288 clevermous 93
load_default_skin:
94
        mov     [_skinh], 22
95
        mov     ebx, _skin_file_default
96
        call    read_skin_file
97
        ret
2436 mario79 98
;------------------------------------------------------------------------------
99
align 4
2288 clevermous 100
parse_skin_data:
101
        mov     ebp, skin_data
102
        cmp     [ebp+SKIN_HEADER.ident], 'SKIN'
103
        jne     .exit
104
 
105
        mov     edi, skin_udata
106
        mov     ecx, (skin_udata.end-skin_udata)/4
107
        xor     eax, eax
108
        cld
109
        rep stosd
110
 
111
        mov     ebx, [ebp+SKIN_HEADER.params]
112
        add     ebx, skin_data
113
        mov     eax, [ebx+SKIN_PARAMS.skin_height]
114
        mov     [_skinh], eax
115
        mov     eax, [ebx+SKIN_PARAMS.colors.inner]
116
        mov     [skin_active.colors.inner], eax
117
        mov     eax, [ebx+SKIN_PARAMS.colors.outer]
118
        mov     [skin_active.colors.outer], eax
119
        mov     eax, [ebx+SKIN_PARAMS.colors.frame]
120
        mov     [skin_active.colors.frame], eax
121
        mov     eax, [ebx+SKIN_PARAMS.colors_1.inner]
122
        mov     [skin_inactive.colors.inner], eax
123
        mov     eax, [ebx+SKIN_PARAMS.colors_1.outer]
124
        mov     [skin_inactive.colors.outer], eax
125
        mov     eax, [ebx+SKIN_PARAMS.colors_1.frame]
126
        mov     [skin_inactive.colors.frame], eax
127
        lea     esi, [ebx+SKIN_PARAMS.dtp.data]
128
        mov     edi, common_colours
129
        mov     ecx, [ebx+SKIN_PARAMS.dtp.size]
130
        and     ecx, 127
131
        rep movsb
132
        mov     eax, dword[ebx+SKIN_PARAMS.margin.right]
133
        mov     dword[_skinmargins+0], eax
134
        mov     eax, dword[ebx+SKIN_PARAMS.margin.bottom]
135
        mov     dword[_skinmargins+4], eax
136
 
137
        mov     ebx, [ebp+SKIN_HEADER.bitmaps]
138
        add     ebx, skin_data
2436 mario79 139
;--------------------------------------
140
align 4
141
.lp1:
2288 clevermous 142
        cmp     dword[ebx], 0
143
        je      .end_bitmaps
144
        movzx   eax, [ebx+SKIN_BITMAPS.kind]
145
        movzx   ecx, [ebx+SKIN_BITMAPS.type]
146
        dec     eax
147
        jnz     .not_left
148
        xor     eax, eax
149
        mov     edx, skin_active.left.data
150
        or      ecx, ecx
151
        jnz     @f
152
        mov     edx, skin_inactive.left.data
2436 mario79 153
;--------------------------------------
154
align 4
155
@@:
2288 clevermous 156
        jmp     .next_bitmap
2436 mario79 157
;--------------------------------------
158
align 4
159
.not_left:
2288 clevermous 160
        dec     eax
161
        jnz     .not_oper
162
        mov     esi, [ebx+SKIN_BITMAPS.data]
163
        add     esi, skin_data
164
        mov     eax, [esi+0]
165
        neg     eax
166
        mov     edx, skin_active.oper.data
167
        or      ecx, ecx
168
        jnz     @f
169
        mov     edx, skin_inactive.oper.data
2436 mario79 170
;--------------------------------------
171
align 4
172
@@:
2288 clevermous 173
        jmp     .next_bitmap
2436 mario79 174
;--------------------------------------
175
align 4
176
.not_oper:
2288 clevermous 177
        dec     eax
178
        jnz     .not_base
179
        mov     eax, [skin_active.left.width]
180
        mov     edx, skin_active.base.data
181
        or      ecx, ecx
182
        jnz     @f
183
        mov     eax, [skin_inactive.left.width]
184
        mov     edx, skin_inactive.base.data
2436 mario79 185
;--------------------------------------
186
align 4
187
@@:
2288 clevermous 188
        jmp     .next_bitmap
2436 mario79 189
;--------------------------------------
190
align 4
191
.not_base:
2288 clevermous 192
        add     ebx, 8
193
        jmp     .lp1
2436 mario79 194
;--------------------------------------
195
align 4
196
.next_bitmap:
2288 clevermous 197
        mov     ecx, [ebx+SKIN_BITMAPS.data]
198
        add     ecx, skin_data
199
        mov     [edx+4], eax
200
        mov     eax, [ecx+0]
201
        mov     [edx+8], eax
202
        add     ecx, 8
203
        mov     [edx+0], ecx
204
        add     ebx, 8
205
        jmp     .lp1
2436 mario79 206
;--------------------------------------
207
align 4
208
.end_bitmaps:
2288 clevermous 209
        mov     ebx, [ebp+SKIN_HEADER.buttons]
210
        add     ebx, skin_data
2436 mario79 211
;--------------------------------------
212
align 4
213
.lp2:
2288 clevermous 214
        cmp     dword[ebx], 0
215
        je      .end_buttons
216
        mov     eax, [ebx+SKIN_BUTTONS.type]
217
        dec     eax
218
        jnz     .not_close
219
        mov     edx, skin_btn_close
220
        jmp     .next_button
2436 mario79 221
;--------------------------------------
222
align 4
223
.not_close:
2288 clevermous 224
        dec     eax
225
        jnz     .not_minimize
226
        mov     edx, skin_btn_minimize
227
        jmp     .next_button
2436 mario79 228
;--------------------------------------
229
align 4
230
.not_minimize:
2288 clevermous 231
        add     ebx, 12
232
        jmp     .lp2
2436 mario79 233
;--------------------------------------
234
align 4
235
.next_button:
2288 clevermous 236
        movsx   eax, [ebx+SKIN_BUTTONS.left]
237
        mov     [edx+SKIN_BUTTON.left], eax
238
        movsx   eax, [ebx+SKIN_BUTTONS.top]
239
        mov     [edx+SKIN_BUTTON.top], eax
240
        movsx   eax, [ebx+SKIN_BUTTONS.width]
241
        mov     [edx+SKIN_BUTTON.width], eax
242
        movsx   eax, [ebx+SKIN_BUTTONS.height]
243
        mov     [edx+SKIN_BUTTON.height], eax
244
        add     ebx, 12
245
        jmp     .lp2
2436 mario79 246
;--------------------------------------
247
align 4
248
.end_buttons:
249
.exit:
2288 clevermous 250
        ret
2436 mario79 251
;------------------------------------------------------------------------------
252
align 4
2288 clevermous 253
drawwindow_IV_caption:
254
 
255
        mov     ebp, skin_active
256
        or      al, al
257
        jnz     @f
258
        mov     ebp, skin_inactive
2436 mario79 259
;--------------------------------------
260
align 4
261
@@:
2288 clevermous 262
        mov     esi, [esp+4]
263
        mov     eax, [esi+WDATA.box.width]   ; window width
264
        mov     edx, [ebp+SKIN_DATA.left.left]
265
        shl     edx, 16
266
        mov     ecx, [ebp+SKIN_DATA.left.width]
267
        shl     ecx, 16
268
        add     ecx, [_skinh]
269
 
270
        mov     ebx, [ebp+SKIN_DATA.left.data]
2436 mario79 271
        or      ebx, ebx
272
        jz      @f
273
        call    sys_putimage.forced
274
;--------------------------------------
275
align 4
276
@@:
2288 clevermous 277
        mov     esi, [esp+4]
278
        mov     eax, [esi+WDATA.box.width]
279
        sub     eax, [ebp+SKIN_DATA.left.width]
280
        sub     eax, [ebp+SKIN_DATA.oper.width]
281
        cmp     eax, [ebp+SKIN_DATA.base.left]
282
        jng     .non_base
283
        xor     edx, edx
284
        mov     ecx, [ebp+SKIN_DATA.base.width]
285
        jecxz   .non_base
286
        div     ecx
287
 
288
        inc     eax
289
 
290
        mov     ebx, [ebp+SKIN_DATA.base.data]
291
        mov     ecx, [ebp+SKIN_DATA.base.width]
292
        shl     ecx, 16
293
        add     ecx, [_skinh]
294
        mov     edx, [ebp+SKIN_DATA.base.left]
295
        sub     edx, [ebp+SKIN_DATA.base.width]
296
        shl     edx, 16
2436 mario79 297
;--------------------------------------
298
align 4
299
.baseskinloop:
2288 clevermous 300
        shr     edx, 16
301
        add     edx, [ebp+SKIN_DATA.base.width]
302
        shl     edx, 16
303
 
304
        push    eax ebx ecx edx
2436 mario79 305
 
306
        or      ebx, ebx
307
        jz      @f
308
        call    sys_putimage.forced
309
;--------------------------------------
310
align 4
311
@@:
2288 clevermous 312
        pop     edx ecx ebx eax
313
 
314
        dec     eax
315
        jnz     .baseskinloop
2436 mario79 316
;--------------------------------------
317
align 4
318
.non_base:
2288 clevermous 319
 
320
        mov     esi, [esp+4]
321
        mov     edx, [esi+WDATA.box.width]
322
        sub     edx, [ebp+SKIN_DATA.oper.width]
323
        inc     edx
324
        shl     edx, 16
325
        mov     ebx, [ebp+SKIN_DATA.oper.data]
326
 
327
        mov     ecx, [ebp+SKIN_DATA.oper.width]
328
        shl     ecx, 16
329
        add     ecx, [_skinh]
330
 
2436 mario79 331
        or      ebx, ebx
332
        jz      @f
333
        call    sys_putimage.forced
334
;--------------------------------------
335
align 4
336
@@:
2288 clevermous 337
        ret
2436 mario79 338
;------------------------------------------------------------------------------
339
align 4
2288 clevermous 340
drawwindow_IV:
341
;param1 - aw_yes
342
        pusha
343
 
344
        push    edx
345
 
346
        mov     edi, edx
347
 
348
        mov     ebp, skin_active
349
        cmp     byte [esp+32+4+4], 0
350
        jne     @f
351
        mov     ebp, skin_inactive
2436 mario79 352
;--------------------------------------
353
align 4
354
@@:
2288 clevermous 355
        mov     eax, [edi+WDATA.box.left]
356
        shl     eax, 16
357
        mov     ax, word [edi+WDATA.box.left]
358
        add     ax, word [edi+WDATA.box.width]
359
        mov     ebx, [edi+WDATA.box.top]
360
        shl     ebx, 16
361
        mov     bx, word [edi+WDATA.box.top]
362
        add     bx, word [edi+WDATA.box.height]
363
        mov     esi, [ebp+SKIN_DATA.colors.outer]
2423 mario79 364
        or      esi, 1 shl 25 ; 0x02000000 used for draw_rectangle without top line
365
        ror     ebx, 16
366
        add     ebx, [_skinh]
367
        sub     bx, 1
368
        rol     ebx, 16
2288 clevermous 369
        call    draw_rectangle
370
        mov     ecx, 3
2436 mario79 371
;--------------------------------------
372
align 4
373
_dw3l:
2288 clevermous 374
        add     eax, 1*65536-1
2423 mario79 375
        add     ebx, 0*65536-1
2288 clevermous 376
        test    ax, ax
377
        js      no_skin_add_button
378
        test    bx, bx
379
        js      no_skin_add_button
380
        mov     esi, [ebp+SKIN_DATA.colors.frame];[edi+24]
2423 mario79 381
        or      esi, 1 shl 25; 0x02000000 used for draw_rectangle without top line
2288 clevermous 382
        call    draw_rectangle
383
        dec     ecx
384
        jnz     _dw3l
385
        mov     esi, [ebp+SKIN_DATA.colors.inner]
2423 mario79 386
        or      esi, 1 shl 25; 0x02000000 used for draw_rectangle without top line
2288 clevermous 387
        add     eax, 1*65536-1
2423 mario79 388
        add     ebx, 0*65536-1
2288 clevermous 389
        test    ax, ax
390
        js      no_skin_add_button
391
        test    bx, bx
392
        js      no_skin_add_button
393
        call    draw_rectangle
394
 
395
        cmp     dword[skin_data], 'SKIN'
396
        je      @f
397
        xor     eax, eax
398
        xor     ebx, ebx
399
        mov     esi, [esp]
400
        mov     ecx, [esi+WDATA.box.width]
401
        inc     ecx
402
        mov     edx, [_skinh]
403
        mov     edi, [common_colours+4]; standard grab color
2453 mario79 404
;        call    [drawbar]
405
        call    vesa20_drawbar
2288 clevermous 406
        jmp     draw_clientbar
2436 mario79 407
;--------------------------------------
408
align 4
409
@@:
2288 clevermous 410
        mov     al, [esp+32+4+4]
411
        call    drawwindow_IV_caption
2436 mario79 412
;--------------------------------------
413
align 4
414
draw_clientbar:
2288 clevermous 415
        mov     esi, [esp]
416
 
417
        mov     edx, [esi+WDATA.box.top]                    ; WORK AREA
418
        add     edx, 21+5
419
        mov     ebx, [esi+WDATA.box.top]
420
        add     ebx, [esi+WDATA.box.height]
421
        cmp     edx, ebx
422
        jg      _noinside2
423
        mov     eax, 5
424
        mov     ebx, [_skinh]
425
        mov     ecx, [esi+WDATA.box.width]
426
        mov     edx, [esi+WDATA.box.height]
427
        sub     ecx, 4
428
        sub     edx, 4
429
        mov     edi, [esi+WDATA.cl_workarea]
430
        test    edi, 0x40000000
431
        jnz     _noinside2
2453 mario79 432
;        call    [drawbar]
433
        call    vesa20_drawbar
2436 mario79 434
;--------------------------------------
435
align 4
436
_noinside2:
2288 clevermous 437
        cmp     dword[skin_data], 'SKIN'
438
        jne     no_skin_add_button
439
;* close button
440
        mov     edi, [BTN_ADDR]
441
        movzx   eax, word [edi]
442
        cmp     eax, 1000
443
        jge     no_skin_add_button
444
        inc     eax
445
        mov     [edi], ax
446
 
447
        shl     eax, 4
448
        add     eax, edi
449
 
450
        mov     bx, [CURRENT_TASK]
451
        mov     [eax], bx
452
 
453
        add     eax, 2      ; save button id number
454
        mov     bx, 1
455
        mov     [eax], bx
456
        add     eax, 2      ; x start
457
        xor     ebx, ebx
458
        cmp     [skin_btn_close.left], 0
459
        jge     _bCx_at_right
460
        mov     ebx, [esp]
461
        mov     ebx, [ebx+WDATA.box.width]
462
        inc     ebx
2436 mario79 463
;--------------------------------------
464
align 4
465
_bCx_at_right:
2288 clevermous 466
        add     ebx, [skin_btn_close.left]
467
        mov     [eax], bx
468
        add     eax, 2      ; x size
469
        mov     ebx, [skin_btn_close.width]
470
        dec     ebx
471
        mov     [eax], bx
472
        add     eax, 2      ; y start
473
        mov     ebx, [skin_btn_close.top]
474
        mov     [eax], bx
475
        add     eax, 2      ; y size
476
        mov     ebx, [skin_btn_close.height]
477
        dec     ebx
478
        mov     [eax], bx
479
;* minimize button
480
        mov     edi, [BTN_ADDR]
481
        movzx   eax, word [edi]
482
        cmp     eax, 1000
483
        jge     no_skin_add_button
484
        inc     eax
485
        mov     [edi], ax
486
 
487
        shl     eax, 4
488
        add     eax, edi
489
 
490
        mov     bx, [CURRENT_TASK]
491
        mov     [eax], bx
492
 
493
        add     eax, 2      ; save button id number
494
        mov     bx, 65535;999
495
        mov     [eax], bx
496
        add     eax, 2      ; x start
497
        xor     ebx, ebx
498
        cmp     [skin_btn_minimize.left], 0
499
        jge     _bMx_at_right
500
        mov     ebx, [esp]
501
        mov     ebx, [ebx+WDATA.box.width]
502
        inc     ebx
2436 mario79 503
;--------------------------------------
504
align 4
505
_bMx_at_right:
2288 clevermous 506
        add     ebx, [skin_btn_minimize.left]
507
        mov     [eax], bx
508
        add     eax, 2      ; x size
509
        mov     ebx, [skin_btn_minimize.width]
510
        dec     ebx
511
        mov     [eax], bx
512
        add     eax, 2      ; y start
513
        mov     ebx, [skin_btn_minimize.top]
514
        mov     [eax], bx
515
        add     eax, 2      ; y size
516
        mov     ebx, [skin_btn_minimize.height]
517
        dec     ebx
518
        mov     [eax], bx
2436 mario79 519
;--------------------------------------
520
align 4
521
no_skin_add_button:
2288 clevermous 522
        pop     edi
523
        popa
524
        ret     4
2436 mario79 525
;------------------------------------------------------------------------------