Subversion Repositories Kolibri OS

Rev

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

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