Subversion Repositories Kolibri OS

Rev

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

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