Subversion Repositories Kolibri OS

Rev

Rev 928 | Details | Compare with Previous | Last modification | View Log | RSS feed

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