Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
431 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2465 Serge 3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
431 serge 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
593 mikedld 8
$Revision: 2465 $
9
 
10
 
7 me_root 11
include "skindata.inc"
1 ha 12
 
381 serge 13
;skin_data = 0x00778000
2439 Serge 14
;------------------------------------------------------------------------------
15
align 4
523 diamond 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
2439 Serge 25
;--------------------------------------
26
align 4
523 diamond 27
@@:
28
        lea     ecx, [ebx+3]
29
        shr     ecx, 2
30
        mov     esi, eax
31
        mov     edi, skin_data
2434 Serge 32
        rep movsd
523 diamond 33
        stdcall kernel_free, eax
488 spraid 34
 
523 diamond 35
        call    parse_skin_data
36
        xor     eax, eax
37
        ret
2439 Serge 38
;--------------------------------------
39
align 4
523 diamond 40
.notfound:
41
        xor     eax, eax
42
        inc     eax
43
        ret
2439 Serge 44
;--------------------------------------
45
align 4
523 diamond 46
.noskin:
47
        stdcall kernel_free, eax
48
        push    2
49
        pop     eax
50
        ret
2439 Serge 51
;------------------------------------------------------------------------------
2434 Serge 52
struct  SKIN_HEADER
53
        ident           dd ?
54
        version         dd ?
55
        params          dd ?
56
        buttons         dd ?
57
        bitmaps         dd ?
49 mikedld 58
ends
1 ha 59
 
2434 Serge 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
49 mikedld 74
ends
1 ha 75
 
2434 Serge 76
struct  SKIN_BUTTONS
77
        type    dd ?
78
; position
79
        left    dw ?
80
        top     dw ?
81
; size
82
        width   dw ?
83
        height  dw ?
49 mikedld 84
ends
1 ha 85
 
2434 Serge 86
struct  SKIN_BITMAPS
87
        kind    dw ?
88
        type    dw ?
89
        data    dd ?
49 mikedld 90
ends
2439 Serge 91
;------------------------------------------------------------------------------
92
align 4
523 diamond 93
load_default_skin:
2434 Serge 94
        mov     [_skinh], 22
95
        mov     ebx, _skin_file_default
523 diamond 96
        call    read_skin_file
49 mikedld 97
        ret
2439 Serge 98
;------------------------------------------------------------------------------
99
align 4
49 mikedld 100
parse_skin_data:
2434 Serge 101
        mov     ebp, skin_data
102
        cmp     [ebp+SKIN_HEADER.ident], 'SKIN'
49 mikedld 103
        jne     .exit
1 ha 104
 
2434 Serge 105
        mov     edi, skin_udata
106
        mov     ecx, (skin_udata.end-skin_udata)/4
107
        xor     eax, eax
54 mikedld 108
        cld
2434 Serge 109
        rep stosd
54 mikedld 110
 
2434 Serge 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
1 ha 136
 
2434 Serge 137
        mov     ebx, [ebp+SKIN_HEADER.bitmaps]
138
        add     ebx, skin_data
2439 Serge 139
;--------------------------------------
140
align 4
141
.lp1:
2434 Serge 142
        cmp     dword[ebx], 0
49 mikedld 143
        je      .end_bitmaps
2434 Serge 144
        movzx   eax, [ebx+SKIN_BITMAPS.kind]
145
        movzx   ecx, [ebx+SKIN_BITMAPS.type]
49 mikedld 146
        dec     eax
147
        jnz     .not_left
2434 Serge 148
        xor     eax, eax
149
        mov     edx, skin_active.left.data
150
        or      ecx, ecx
49 mikedld 151
        jnz     @f
2434 Serge 152
        mov     edx, skin_inactive.left.data
2439 Serge 153
;--------------------------------------
154
align 4
155
@@:
2434 Serge 156
        jmp     .next_bitmap
2439 Serge 157
;--------------------------------------
158
align 4
159
.not_left:
49 mikedld 160
        dec     eax
161
        jnz     .not_oper
2434 Serge 162
        mov     esi, [ebx+SKIN_BITMAPS.data]
163
        add     esi, skin_data
164
        mov     eax, [esi+0]
49 mikedld 165
        neg     eax
2434 Serge 166
        mov     edx, skin_active.oper.data
167
        or      ecx, ecx
49 mikedld 168
        jnz     @f
2434 Serge 169
        mov     edx, skin_inactive.oper.data
2439 Serge 170
;--------------------------------------
171
align 4
172
@@:
2434 Serge 173
        jmp     .next_bitmap
2439 Serge 174
;--------------------------------------
175
align 4
176
.not_oper:
49 mikedld 177
        dec     eax
178
        jnz     .not_base
2434 Serge 179
        mov     eax, [skin_active.left.width]
180
        mov     edx, skin_active.base.data
181
        or      ecx, ecx
49 mikedld 182
        jnz     @f
2434 Serge 183
        mov     eax, [skin_inactive.left.width]
184
        mov     edx, skin_inactive.base.data
2439 Serge 185
;--------------------------------------
186
align 4
187
@@:
2434 Serge 188
        jmp     .next_bitmap
2439 Serge 189
;--------------------------------------
190
align 4
191
.not_base:
2434 Serge 192
        add     ebx, 8
49 mikedld 193
        jmp     .lp1
2439 Serge 194
;--------------------------------------
195
align 4
196
.next_bitmap:
2434 Serge 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
49 mikedld 205
        jmp     .lp1
2439 Serge 206
;--------------------------------------
207
align 4
208
.end_bitmaps:
2434 Serge 209
        mov     ebx, [ebp+SKIN_HEADER.buttons]
210
        add     ebx, skin_data
2439 Serge 211
;--------------------------------------
212
align 4
213
.lp2:
2434 Serge 214
        cmp     dword[ebx], 0
49 mikedld 215
        je      .end_buttons
2434 Serge 216
        mov     eax, [ebx+SKIN_BUTTONS.type]
49 mikedld 217
        dec     eax
218
        jnz     .not_close
2434 Serge 219
        mov     edx, skin_btn_close
49 mikedld 220
        jmp     .next_button
2439 Serge 221
;--------------------------------------
222
align 4
223
.not_close:
49 mikedld 224
        dec     eax
225
        jnz     .not_minimize
2434 Serge 226
        mov     edx, skin_btn_minimize
49 mikedld 227
        jmp     .next_button
2439 Serge 228
;--------------------------------------
229
align 4
230
.not_minimize:
2434 Serge 231
        add     ebx, 12
49 mikedld 232
        jmp     .lp2
2439 Serge 233
;--------------------------------------
234
align 4
235
.next_button:
2434 Serge 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
49 mikedld 245
        jmp     .lp2
2439 Serge 246
;--------------------------------------
247
align 4
248
.end_buttons:
249
.exit:
49 mikedld 250
        ret
2439 Serge 251
;------------------------------------------------------------------------------
252
align 4
114 mikedld 253
drawwindow_IV_caption:
254
 
2434 Serge 255
        mov     ebp, skin_active
256
        or      al, al
114 mikedld 257
        jnz     @f
2434 Serge 258
        mov     ebp, skin_inactive
2439 Serge 259
;--------------------------------------
260
align 4
261
@@:
2434 Serge 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]
114 mikedld 269
 
270
        mov     ebx, [ebp+SKIN_DATA.left.data]
2439 Serge 271
        or      ebx, ebx
272
        jz      @f
273
        call    sys_putimage.forced
274
;--------------------------------------
275
align 4
276
@@:
2434 Serge 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]
114 mikedld 282
        jng     .non_base
2434 Serge 283
        xor     edx, edx
284
        mov     ecx, [ebp+SKIN_DATA.base.width]
114 mikedld 285
        jecxz   .non_base
286
        div     ecx
287
 
288
        inc     eax
289
 
2434 Serge 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
2439 Serge 297
;--------------------------------------
298
align 4
299
.baseskinloop:
2434 Serge 300
        shr     edx, 16
301
        add     edx, [ebp+SKIN_DATA.base.width]
302
        shl     edx, 16
114 mikedld 303
 
304
        push    eax ebx ecx edx
2439 Serge 305
 
306
        or      ebx, ebx
307
        jz      @f
308
        call    sys_putimage.forced
309
;--------------------------------------
310
align 4
311
@@:
114 mikedld 312
        pop     edx ecx ebx eax
313
 
314
        dec     eax
315
        jnz     .baseskinloop
2439 Serge 316
;--------------------------------------
317
align 4
318
.non_base:
114 mikedld 319
 
2434 Serge 320
        mov     esi, [esp+4]
321
        mov     edx, [esi+WDATA.box.width]
322
        sub     edx, [ebp+SKIN_DATA.oper.width]
114 mikedld 323
        inc     edx
2434 Serge 324
        shl     edx, 16
325
        mov     ebx, [ebp+SKIN_DATA.oper.data]
114 mikedld 326
 
2434 Serge 327
        mov     ecx, [ebp+SKIN_DATA.oper.width]
328
        shl     ecx, 16
329
        add     ecx, [_skinh]
114 mikedld 330
 
2439 Serge 331
        or      ebx, ebx
332
        jz      @f
333
        call    sys_putimage.forced
334
;--------------------------------------
335
align 4
336
@@:
114 mikedld 337
        ret
2439 Serge 338
;------------------------------------------------------------------------------
339
align 4
1 ha 340
drawwindow_IV:
35 halyavin 341
;param1 - aw_yes
1 ha 342
        pusha
343
 
2434 Serge 344
        push    edx
1 ha 345
 
2434 Serge 346
        mov     edi, edx
1 ha 347
 
2434 Serge 348
        mov     ebp, skin_active
349
        cmp     byte [esp+32+4+4], 0
49 mikedld 350
        jne     @f
2434 Serge 351
        mov     ebp, skin_inactive
2439 Serge 352
;--------------------------------------
353
align 4
354
@@:
2434 Serge 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]
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
369
        call    draw_rectangle
370
        mov     ecx, 3
2439 Serge 371
;--------------------------------------
372
align 4
373
_dw3l:
2434 Serge 374
        add     eax, 1*65536-1
375
        add     ebx, 0*65536-1
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]
381
        or      esi, 1 shl 25; 0x02000000 used for draw_rectangle without top line
382
        call    draw_rectangle
383
        dec     ecx
384
        jnz     _dw3l
385
        mov     esi, [ebp+SKIN_DATA.colors.inner]
386
        or      esi, 1 shl 25; 0x02000000 used for draw_rectangle without top line
387
        add     eax, 1*65536-1
388
        add     ebx, 0*65536-1
389
        test    ax, ax
390
        js      no_skin_add_button
391
        test    bx, bx
392
        js      no_skin_add_button
393
        call    draw_rectangle
1 ha 394
 
2434 Serge 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
2465 Serge 404
;        call    [drawbar]
405
        call    vesa20_drawbar
2434 Serge 406
        jmp     draw_clientbar
2439 Serge 407
;--------------------------------------
408
align 4
409
@@:
2434 Serge 410
        mov     al, [esp+32+4+4]
114 mikedld 411
        call    drawwindow_IV_caption
2439 Serge 412
;--------------------------------------
413
align 4
414
draw_clientbar:
2434 Serge 415
        mov     esi, [esp]
1 ha 416
 
2434 Serge 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
2465 Serge 432
;        call    [drawbar]
433
        call    vesa20_drawbar
2439 Serge 434
;--------------------------------------
435
align 4
436
_noinside2:
2434 Serge 437
        cmp     dword[skin_data], 'SKIN'
438
        jne     no_skin_add_button
49 mikedld 439
;* close button
2434 Serge 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
1 ha 446
 
2434 Serge 447
        shl     eax, 4
448
        add     eax, edi
1 ha 449
 
2434 Serge 450
        mov     bx, [CURRENT_TASK]
451
        mov     [eax], bx
1 ha 452
 
2434 Serge 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
2439 Serge 463
;--------------------------------------
464
align 4
465
_bCx_at_right:
2434 Serge 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
1 ha 479
;* minimize button
2434 Serge 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
1 ha 486
 
2434 Serge 487
        shl     eax, 4
488
        add     eax, edi
1 ha 489
 
2434 Serge 490
        mov     bx, [CURRENT_TASK]
491
        mov     [eax], bx
1 ha 492
 
2434 Serge 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
2439 Serge 503
;--------------------------------------
504
align 4
505
_bMx_at_right:
2434 Serge 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
2439 Serge 519
;--------------------------------------
520
align 4
521
no_skin_add_button:
186 diamond 522
        pop     edi
1 ha 523
        popa
2434 Serge 524
        ret     4
2439 Serge 525
;------------------------------------------------------------------------------