Subversion Repositories Kolibri OS

Rev

Rev 2455 | Rev 3588 | 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: 2463 $
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
2463 mario79 393
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
394
        jnz     @f
2288 clevermous 395
        call    draw_rectangle
2463 mario79 396
;--------------------------------------
397
align 4
398
@@:
2288 clevermous 399
        cmp     dword[skin_data], 'SKIN'
400
        je      @f
401
        xor     eax, eax
402
        xor     ebx, ebx
403
        mov     esi, [esp]
404
        mov     ecx, [esi+WDATA.box.width]
405
        inc     ecx
406
        mov     edx, [_skinh]
407
        mov     edi, [common_colours+4]; standard grab color
2453 mario79 408
;        call    [drawbar]
409
        call    vesa20_drawbar
2288 clevermous 410
        jmp     draw_clientbar
2436 mario79 411
;--------------------------------------
412
align 4
413
@@:
2288 clevermous 414
        mov     al, [esp+32+4+4]
415
        call    drawwindow_IV_caption
2436 mario79 416
;--------------------------------------
417
align 4
418
draw_clientbar:
2288 clevermous 419
        mov     esi, [esp]
420
 
421
        mov     edx, [esi+WDATA.box.top]                    ; WORK AREA
422
        add     edx, 21+5
423
        mov     ebx, [esi+WDATA.box.top]
424
        add     ebx, [esi+WDATA.box.height]
425
        cmp     edx, ebx
426
        jg      _noinside2
427
        mov     eax, 5
428
        mov     ebx, [_skinh]
429
        mov     ecx, [esi+WDATA.box.width]
430
        mov     edx, [esi+WDATA.box.height]
431
        sub     ecx, 4
432
        sub     edx, 4
433
        mov     edi, [esi+WDATA.cl_workarea]
434
        test    edi, 0x40000000
435
        jnz     _noinside2
2453 mario79 436
;        call    [drawbar]
437
        call    vesa20_drawbar
2436 mario79 438
;--------------------------------------
439
align 4
440
_noinside2:
2288 clevermous 441
        cmp     dword[skin_data], 'SKIN'
442
        jne     no_skin_add_button
443
;* close button
444
        mov     edi, [BTN_ADDR]
445
        movzx   eax, word [edi]
446
        cmp     eax, 1000
447
        jge     no_skin_add_button
448
        inc     eax
449
        mov     [edi], ax
450
 
451
        shl     eax, 4
452
        add     eax, edi
453
 
454
        mov     bx, [CURRENT_TASK]
455
        mov     [eax], bx
456
 
457
        add     eax, 2      ; save button id number
458
        mov     bx, 1
459
        mov     [eax], bx
460
        add     eax, 2      ; x start
461
        xor     ebx, ebx
462
        cmp     [skin_btn_close.left], 0
463
        jge     _bCx_at_right
464
        mov     ebx, [esp]
465
        mov     ebx, [ebx+WDATA.box.width]
466
        inc     ebx
2436 mario79 467
;--------------------------------------
468
align 4
469
_bCx_at_right:
2288 clevermous 470
        add     ebx, [skin_btn_close.left]
471
        mov     [eax], bx
472
        add     eax, 2      ; x size
473
        mov     ebx, [skin_btn_close.width]
474
        dec     ebx
475
        mov     [eax], bx
476
        add     eax, 2      ; y start
477
        mov     ebx, [skin_btn_close.top]
478
        mov     [eax], bx
479
        add     eax, 2      ; y size
480
        mov     ebx, [skin_btn_close.height]
481
        dec     ebx
482
        mov     [eax], bx
483
;* minimize button
484
        mov     edi, [BTN_ADDR]
485
        movzx   eax, word [edi]
486
        cmp     eax, 1000
487
        jge     no_skin_add_button
488
        inc     eax
489
        mov     [edi], ax
490
 
491
        shl     eax, 4
492
        add     eax, edi
493
 
494
        mov     bx, [CURRENT_TASK]
495
        mov     [eax], bx
496
 
497
        add     eax, 2      ; save button id number
498
        mov     bx, 65535;999
499
        mov     [eax], bx
500
        add     eax, 2      ; x start
501
        xor     ebx, ebx
502
        cmp     [skin_btn_minimize.left], 0
503
        jge     _bMx_at_right
504
        mov     ebx, [esp]
505
        mov     ebx, [ebx+WDATA.box.width]
506
        inc     ebx
2436 mario79 507
;--------------------------------------
508
align 4
509
_bMx_at_right:
2288 clevermous 510
        add     ebx, [skin_btn_minimize.left]
511
        mov     [eax], bx
512
        add     eax, 2      ; x size
513
        mov     ebx, [skin_btn_minimize.width]
514
        dec     ebx
515
        mov     [eax], bx
516
        add     eax, 2      ; y start
517
        mov     ebx, [skin_btn_minimize.top]
518
        mov     [eax], bx
519
        add     eax, 2      ; y size
520
        mov     ebx, [skin_btn_minimize.height]
521
        dec     ebx
522
        mov     [eax], bx
2436 mario79 523
;--------------------------------------
524
align 4
525
no_skin_add_button:
2288 clevermous 526
        pop     edi
527
        popa
528
        ret     4
2436 mario79 529
;------------------------------------------------------------------------------