Subversion Repositories Kolibri OS

Rev

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