Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
;
51 mikedld 2
;    UNIFORM WINDOW COLOURS & SKIN
31 halyavin 3
;
4
;    Compile with FASM for Menuet
5
;
6
;    < russian edition by Ivan Poddubny >
51 mikedld 7
;    < skin selection by Mike Semenyako >
3435 mario79 8
;******************************************************************************
9
; last update:  01/04/2013
10
; written by:   Marat Zakiyanov aka Mario79, aka Mario
11
; changes:      select colors with ColorDialog
12
;               some redesign of the look of the program
13
;******************************************************************************
1611 mario79 14
; last update:  10/09/2010
15
; written by:   Marat Zakiyanov aka Mario79, aka Mario
16
; changes:      select path with OpenDialog
31 halyavin 17
;******************************************************************************
3271 mario79 18
	use32
19
	org 0
20
	db 'MENUET01'	; identifier
21
	dd 1		; header version
22
	dd START	; start address
3435 mario79 23
	dd IM_END	; file size
24
	dd I_END	; memory
3271 mario79 25
	dd stacktop	; stack pointer
26
	dd skin_info	; parameters
27
	dd cur_dir_path	; path to file
28
 
1611 mario79 29
include 'lang.inc'
1702 Lrz 30
include '../../../config.inc'		;for nightbuild
1611 mario79 31
include '../../../macros.inc'
32
include 'kglobals.inc'
33
include 'unpacker.inc'
34
include '../../../develop/libraries/box_lib/load_lib.mac'
35
	@use_library
31 halyavin 36
;******************************************************************************
3435 mario79 37
;--------------------------------------
51 mikedld 38
struct SKIN_HEADER
485 heavyiron 39
  ident   dd ?
40
  version dd ?
41
  params  dd ?
42
  buttons dd ?
43
  bitmaps dd ?
51 mikedld 44
ends
3435 mario79 45
;--------------------------------------
51 mikedld 46
struct SKIN_PARAMS
485 heavyiron 47
  skin_height    dd ?
48
  margin.right   dw ?
49
  margin.left    dw ?
50
  margin.bottom  dw ?
51
  margin.top     dw ?
52
  colors.inner   dd ?
53
  colors.outer   dd ?
54
  colors.frame   dd ?
55
  colors_1.inner dd ?
56
  colors_1.outer dd ?
57
  colors_1.frame dd ?
58
  dtp.size       dd ?
59
  dtp.data       db 40 dup (?)
51 mikedld 60
ends
3435 mario79 61
;--------------------------------------
51 mikedld 62
struct SKIN_BUTTONS
485 heavyiron 63
  type     dd ?
64
  pos:
65
    left   dw ?
66
    top    dw ?
67
  size:
68
    width  dw ?
69
    height dw ?
51 mikedld 70
ends
3435 mario79 71
;--------------------------------------
51 mikedld 72
struct SKIN_BITMAPS
485 heavyiron 73
  kind  dw ?
74
  type  dw ?
75
  _data  dd ?
51 mikedld 76
ends
3435 mario79 77
;--------------------------------------
78
frame_1:
79
  .x      = 5
80
  .y      = 220
81
  .width  = 420
82
  .height = 50
83
;--------------------------------------
84
frame_2:
85
  .x      = 5
86
  .y      = 280
87
  .width  = 420
88
  .height = 50
1611 mario79 89
;---------------------------------------------------------------------
3271 mario79 90
START:		; start of execution
91
;---------------------------------------------------------------------
1611 mario79 92
	mcall	68,11
93
 
94
	test	eax,eax
95
	jz	close
96
 
97
load_libraries l_libs_start,end_l_libs
98
 
99
;if return code =-1 then exit, else nornary work
100
	inc	eax
101
	test	eax,eax
102
	jz	close
103
;---------------------------------------------------------------------
104
	mov	edi,filename_area
105
	mov	esi,start_temp_file_name
106
	xor	eax,eax
107
	cld
108
@@:
109
	lodsb
110
	stosb
111
	test	eax,eax
112
	jnz	@b
113
 
114
 
115
	mov	edi,fname
116
	mov	esi,default_dtp
117
	xor	eax,eax
118
	cld
119
@@:
120
	lodsb
121
	stosb
122
	test	eax,eax
123
	jnz	@b
124
 
125
;---------------------------------------------------------------------
126
	mov	edi,skin_info
3271 mario79 127
	cmp	byte [edi], 0
1611 mario79 128
	jne	skin_path_ready
129
	mov	esi,default_skin
130
	xor	eax,eax
131
	cld
132
@@:
133
	lodsb
134
	stosb
135
	test	eax,eax
136
	jnz	@b
137
skin_path_ready:
138
;---------------------------------------------------------------------
139
;OpenDialog	initialisation
3271 mario79 140
	push	dword OpenDialog_data
141
	call	[OpenDialog_Init]
1611 mario79 142
 
3271 mario79 143
	push	dword OpenDialog_data2
144
	call	[OpenDialog_Init]
3435 mario79 145
;--------------------------------------------------------------------
146
;init_ColorDialog	ColorDialog_data
147
	push    dword ColorDialog_data
148
	call    [ColorDialog_Init]
149
;--------------------------------------------------------------------
1611 mario79 150
; prepare for PathShow
151
	push	dword PathShow_data_1
152
	call	[PathShow_prepare]
153
 
154
	push	dword PathShow_data_2
155
	call	[PathShow_prepare]
156
;---------------------------------------------------------------------
3271 mario79 157
	mcall	48,3,color_table,4*10	; get current colors
158
	call	load_skin_file.2
159
;---------------------------------------------------------------------
31 halyavin 160
red:
3271 mario79 161
	call	draw_window		; at first, draw the window
162
;---------------------------------------------------------------------
31 halyavin 163
still:
3435 mario79 164
	mcall	10	; wait here for event
31 halyavin 165
 
3271 mario79 166
	dec	eax	; redraw request ?
167
	jz	red
3435 mario79 168
 
3271 mario79 169
	dec	eax	; key in buffer ?
170
	jz	key
3435 mario79 171
 
3271 mario79 172
	dec	eax	; button in buffer ?
173
	jz	button
31 halyavin 174
 
3271 mario79 175
	jmp	still
176
;---------------------------------------------------------------------
177
key:		; key
178
	mcall	2	; just read it and ignore
179
	jmp	still
180
;---------------------------------------------------------------------
181
button:		; button
182
	mcall	17	; get id
31 halyavin 183
 
3271 mario79 184
 	cmp	ah,12	; load file
185
 	jne	no_load
31 halyavin 186
 
3271 mario79 187
	call	load_file
188
	call	draw_window
189
 	jmp	still
190
;--------------------------------------
191
no_load:
192
 	cmp	ah,13	; save file
193
 	jne	no_save
31 halyavin 194
 
3271 mario79 195
	call	save_file
196
 	jmp	still
197
;--------------------------------------
198
no_save:
199
 	cmp	ah,14	; set 3d buttons
200
 	jne	no_3d
31 halyavin 201
 
3271 mario79 202
	mcall	48,1,1
203
 	jmp	doapply
204
;--------------------------------------
205
no_3d:
206
 	cmp	ah,15	; set flat buttons
207
 	jne	no_flat
31 halyavin 208
 
3271 mario79 209
	mcall	48, 1, 0
210
;--------------------------------------
484 diamond 211
doapply:
3271 mario79 212
	mcall	48, 0, 0
213
 	jmp	still
214
;--------------------------------------
215
no_flat:
216
 	cmp	ah,16	; apply
217
 	jne	no_apply
218
;--------------------------------------
219
apply_direct:
220
	mcall	48,2,color_table,10*4
221
 	jmp	doapply
222
;--------------------------------------
223
 no_apply:
224
 	cmp	ah,17	; load skin file
225
 	jne	no_load_skin
31 halyavin 226
 
3271 mario79 227
	call	load_skin_file
228
	call	draw_window
229
 	jmp	still
230
;--------------------------------------
231
no_load_skin:
232
 	cmp	ah,18	; apply skin
233
 	jne	no_apply_skin
31 halyavin 234
 
3271 mario79 235
 	cmp	[skin_info],0
236
 	je	no_apply_skin
51 mikedld 237
 
3271 mario79 238
	mcall	48,8,skin_info
239
	call	draw_window
240
 	jmp	still
241
;--------------------------------------
242
no_apply_skin:
243
	cmp	ah,31
244
	jb	no_new_colour
51 mikedld 245
 
3271 mario79 246
	cmp	ah,41
247
	jg	no_new_colour
248
 
3435 mario79 249
;---------------------------------------------------------------------
250
.start_ColorDialog:
251
	push    dword ColorDialog_data
252
	call    [ColorDialog_Start]
253
; 2 - use another method/not found program
254
	cmp	[ColorDialog_data.status],2
255
	je	still
256
; 1 - OK, color selected
257
	cmp	[ColorDialog_data.status],1
258
	jne	still
259
;---------------------------------------------------------------------
260
 
3271 mario79 261
	shr	eax,8
262
	sub	eax,31
263
	shl	eax,2
3435 mario79 264
	mov	ebx,[ColorDialog_data.color]
265
	and	ebx,0xffffff	; temporary for ColorDialog!!!!!!!!!!
3271 mario79 266
	mov	[eax+color_table],ebx
267
 	cmp	dword[not_packed_area+SKIN_HEADER.ident],'SKIN'
268
 	jne	@f
31 halyavin 269
 
3271 mario79 270
	mov	edi,[not_packed_area+SKIN_HEADER.params]
271
	mov	dword[edi+not_packed_area+SKIN_PARAMS.dtp.data+eax],ebx
272
	call	draw_skin
273
;--------------------------------------
274
@@:
275
	call	draw_colours
276
 	jmp	still
277
;--------------------------------------
278
no_new_colour:
279
	cmp	ah,1	; terminate
280
	jnz	noid1
281
;--------------------------------------
1611 mario79 282
close:
3271 mario79 283
	or	eax,-1
284
	mcall
285
;--------------------------------------
286
noid1:
287
 	jmp	still
288
;---------------------------------------------------------------------
1611 mario79 289
load_file:
290
;---------------------------------------------------------------------
291
; invoke OpenDialog
292
	mov	[OpenDialog_data.type],dword 0
3271 mario79 293
	push	dword OpenDialog_data
294
	call	[OpenDialog_Start]
1611 mario79 295
	cmp	[OpenDialog_data.status],1
296
	je	.1
297
	ret
298
.1:
299
; prepare for PathShow
300
	push	dword PathShow_data_1
301
	call	[PathShow_prepare]
31 halyavin 302
 
1611 mario79 303
	call	draw_PathShow
304
;---------------------------------------------------------------------
3271 mario79 305
	xor	eax, eax
306
	mov	ebx, read_info
307
	mov	dword [ebx], eax	; subfunction: read
308
	mov	dword [ebx+4], eax	; offset (low dword)
309
	mov	dword [ebx+8], eax	; offset (high dword)
310
	mov	dword [ebx+12], 40     ; read colors file: 4*10 bytes
311
	mov	dword [ebx+16], color_table ; address
312
	mcall	70
313
	ret
1611 mario79 314
;---------------------------------------------------------------------
315
load_skin_file:
316
;---------------------------------------------------------------------
317
; invoke OpenDialog
3271 mario79 318
	push	dword OpenDialog_data2
319
	call	[OpenDialog_Start]
1611 mario79 320
	cmp	[OpenDialog_data2.status],1
321
	je	.1
322
	ret
323
.1:
324
; prepare for PathShow
325
	push	dword PathShow_data_2
326
	call	[PathShow_prepare]
31 halyavin 327
 
1611 mario79 328
	call	draw_PathShow
329
;---------------------------------------------------------------------
330
.2:
3271 mario79 331
	xor	eax,eax
332
	mov	ebx,read_info2
333
	mov	dword [ebx], eax	; subfunction: read
334
	mov	dword [ebx+4], eax	; offset (low dword)
335
	mov	dword [ebx+8], eax	; offset (high dword)
336
	mov	dword [ebx+12], 32*1024 ; read: max 32 KBytes
337
	mov	dword [ebx+16], file_load_area ; address
338
	mcall	70
31 halyavin 339
 
3271 mario79 340
	mov	esi, file_load_area
179 mikedld 341
 
3271 mario79 342
	cmp	dword [esi], 'KPCK'
343
	jnz	notpacked
31 halyavin 344
 
3271 mario79 345
	cmp	dword [esi+4], 32*1024 ; max 32 KBytes
346
	ja	doret
51 mikedld 347
 
3271 mario79 348
	push	unpack_area
349
	push	esi
350
	call	unpack
351
	mov	esi,unpack_area
352
;--------------------------------------
353
notpacked:
354
 	cmp	[esi+SKIN_HEADER.ident],dword 'SKIN'
355
 	jne	doret
51 mikedld 356
 
3271 mario79 357
	mov	edi,not_packed_area
358
	mov	ecx,0x8000/4
359
	rep	movsd
51 mikedld 360
 
3271 mario79 361
	mov	ebp,not_packed_area
362
	mov	esi,[ebp+SKIN_HEADER.params]
363
	add	esi,ebp
364
	lea	esi,[esi+SKIN_PARAMS.dtp.data]
365
	mov	edi,color_table
366
	mov	ecx,10
367
	rep	movsd
368
;--------------------------------------
369
doret:
370
	ret
1611 mario79 371
;---------------------------------------------------------------------
372
save_file:
373
;---------------------------------------------------------------------
374
; invoke OpenDialog
375
	mov	[OpenDialog_data.type],dword 1
3271 mario79 376
	push	dword OpenDialog_data
377
	call	[OpenDialog_Start]
1611 mario79 378
	cmp	[OpenDialog_data.status],1
379
	je	.1
380
	ret
381
.1:
382
; prepare for PathShow
383
	push	dword PathShow_data_1
384
	call	[PathShow_prepare]
31 halyavin 385
 
1611 mario79 386
	call	draw_PathShow
387
;---------------------------------------------------------------------
3271 mario79 388
	xor	eax,eax
389
	mov	ebx,write_info
390
	mov	[ebx],dword 2			; subfunction: write
391
	and	[ebx+4],eax			; (reserved)
392
	and	[ebx+8],eax			; (reserved)
393
	mov	[ebx+12],dword 10*4		; bytes to write
394
	mov	[ebx+16],dword color_table	; address
395
	mcall	70
396
	ret
1611 mario79 397
;---------------------------------------------------------------------
3435 mario79 398
draw_button_row:
399
	mov	edx,0x60000000 + 31		; BUTTON ROW
400
	mov	ebx,220*65536+14
401
	mov	ecx,10*65536+14
402
	mov	eax,8
403
;-----------------------------------
404
.newb:
405
	mcall
406
	add	ecx,20*65536
407
	inc	edx
408
	cmp	edx,0x60000000 + 40
409
	jbe	.newb
3271 mario79 410
	ret
3435 mario79 411
;---------------------------------------------------------------------
412
draw_button_row_of_texts:
413
	mov	ebx,240*65536+13	; ROW OF TEXTS
414
	mov	ecx,[w_work_text]
415
	mov	edx,text
416
	mov	esi,32
417
	mov	eax,4
418
;-----------------------------------
419
.newline:
420
	mcall
421
	add	ebx,20
422
	add	edx,32
423
	cmp	[edx],byte 'x'
424
	jne	.newline
425
	ret
426
;---------------------------------------------------------------------
31 halyavin 427
draw_colours:
3271 mario79 428
	pusha
429
	mov	esi,color_table
3435 mario79 430
	mov	ebx,220*65536+14
431
	mov	ecx,10*65536+14
432
	mov	eax,13
3472 mario79 433
	mov	[frame_data.draw_text_flag],dword 0
3271 mario79 434
;--------------------------------------
435
newcol:
436
	mov	edx,[esi]
3435 mario79 437
	mcall
3472 mario79 438
 
439
	push	ebx ecx
440
 
441
	sub	ebx,2 shl 16
442
	add	bx,4
443
	sub	ecx,2 shl 16
444
	add	cx,4
445
 
446
	mov	[frame_data.x],ebx
447
	mov	[frame_data.y],ecx
448
 
449
	push	dword frame_data
450
	call	[Frame_draw]
451
 
452
	pop	ecx ebx
453
 
3435 mario79 454
	add	ecx,20*65536
3271 mario79 455
	add	esi,4
3435 mario79 456
	cmp	esi,color_table+4*9
3271 mario79 457
	jbe	newcol
31 halyavin 458
 
3271 mario79 459
	popa
460
	ret
2068 mario79 461
;----------------------------------------------------------------------
1611 mario79 462
draw_PathShow:
463
	pusha
3435 mario79 464
	mcall	13,,,0xffffff
465
	mcall	13,,,0xffffff
1611 mario79 466
; draw for PathShow
467
	push	dword PathShow_data_1
468
	call	[PathShow_draw]
469
 
470
	push	dword PathShow_data_2
471
	call	[PathShow_draw]
472
	popa
473
	ret
474
;---------------------------------------------------------------------
31 halyavin 475
;   *********************************************
476
;   *******  WINDOW DEFINITIONS AND DRAW ********
477
;   *********************************************
478
draw_window:
2068 mario79 479
	mcall	12,1
480
	mcall	48,3,app_colours,10*4
481
	mcall	14
3435 mario79 482
	mcall	48,4
483
	mov	[current_skin_high],eax
2068 mario79 484
; DRAW WINDOW
485
	xor	eax,eax		; function 0 : define and draw window
486
	xor	esi,esi
487
	mov	edx,[w_work]	; color of work area RRGGBB,8->color
3435 mario79 488
	or	edx,0x34000000
489
	mov	ecx,50 shl 16 + 346
490
	add	ecx,[current_skin_high]
491
	mcall	,<110,440>,,,,title
31 halyavin 492
 
2068 mario79 493
	mcall	9,procinfo,-1
494
 
495
	mov	eax,[procinfo+70] ;status of window
496
	test	eax,100b
497
	jne	.end
3271 mario79 498
 
3435 mario79 499
;if lang eq ru
51 mikedld 500
  load_w  = (5*2+6*9)
501
  save_w  = (5*2+6*9)
502
  flat_w  = (5*2+6*7)
503
  apply_w = (5*2+6*9)
3435 mario79 504
;else
505
;  load_w  = (5*2+6*6)
506
;  save_w  = (5*2+6*8)
507
;  flat_w  = (5*2+6*4)
508
;  apply_w = (5*2+6*7)
509
;end if
510
;-----------------------------------
511
; select color DTP frame
512
; LOAD BUTTON	; button 12
6033 leency 513
	mcall	8,,,12,[w_work_button]
2068 mario79 514
; SAVE BUTTON
515
	add	ebx,(load_w+2)*65536-load_w+save_w
516
	inc	edx
3435 mario79 517
	mcall		; button 13
518
; APPLY BUTTON
519
	mov	ebx,(frame_1.x + frame_1.width - apply_w - 15)*65536+apply_w
520
	mcall	8,,,16	; button 17
521
; select color DTP button text
6033 leency 522
	mcall	4,,[w_work_button_text],t1,t1.size
3435 mario79 523
;-----------------------------------
524
; select skin frame
525
; LOAD SKIN BUTTON	; button 17
6033 leency 526
	mcall	8,,,17,[w_work_button]
2068 mario79 527
; 3D
3435 mario79 528
	mov	ebx,(frame_2.x+155)*65536+34
529
	mcall	,,,14	; button 14
2068 mario79 530
; FLAT
3435 mario79 531
	add	ebx,36*65536-34+flat_w
2068 mario79 532
	inc	edx
3435 mario79 533
	mcall		; button 15
2068 mario79 534
; APPLY SKIN BUTTON
3435 mario79 535
	mov	ebx,(frame_2.x + frame_2.width - apply_w -15)*65536+apply_w
536
	mcall	,,,18		; button 18
537
; select skin button text
6033 leency 538
	mcall	4,,[w_work_button_text],t2,t2.size
3435 mario79 539
;-----------------------------------
540
	call	draw_button_row
541
	call	draw_button_row_of_texts
542
	call	draw_colours
2068 mario79 543
;-----------------------------------
3472 mario79 544
	mov	[frame_data.x],dword frame_1.x shl 16+frame_1.width
545
	mov	[frame_data.y],dword frame_1.y shl 16+frame_1.height
546
	mov	[frame_data.text_pointer],dword select_dtp_text
547
	mov	eax,[w_work]
548
	mov	[frame_data.font_backgr_color],eax
549
	mov	eax,[w_work_text]
550
	mov	[frame_data.font_color],eax
551
	mov	[frame_data.draw_text_flag],dword 1
552
 
553
	push	dword frame_data
554
	call	[Frame_draw]
555
;-----------------------------------
556
	mov	[frame_data.x],dword frame_2.x shl 16+frame_2.width
557
	mov	[frame_data.y],dword frame_2.y shl 16+frame_2.height
558
	mov	[frame_data.text_pointer],dword select_skin_text
31 halyavin 559
 
3472 mario79 560
	push	dword frame_data
561
	call	[Frame_draw]
2068 mario79 562
;-----------------------------------
3435 mario79 563
	call	draw_PathShow
564
;-----------------------------------
2068 mario79 565
	cmp	dword[not_packed_area+SKIN_HEADER.ident],'SKIN'
566
	jne	@f
567
	call	draw_skin
568
@@:
569
.end:
570
	mcall	12,2
571
	ret
3435 mario79 572
;-----------------------------------------------------------------------------
573
include 'drawskin.inc'
574
;-----------------------------------------------------------------------------
31 halyavin 575
; DATA AREA
3435 mario79 576
;-----------------------------------------------------------------------------
577
include 'idata.inc'
578
;-----------------------------------------------------------------------------
579
IM_END:
580
;-----------------------------------------------------------------------------
581
include 'udata.inc'
582
;-----------------------------------------------------------------------------
31 halyavin 583
I_END:
3435 mario79 584
;-----------------------------------------------------------------------------