Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
4120 eAndrew 1
use32
2
    org     0x0
3
;-------------------------------------------------------------------------------
4
    db	    "MENUET01"
5
    dd	    1, main, __dataend, __memend, __stackend, 0, sys_path
6
;-------------------------------------------------------------------------------
7
    include "../../../macros.inc"
8
    include "../../../proc32.inc"
9
    include "../../../dll.inc"
10
    include "../../../develop/libraries/box_lib/load_lib.mac"
4157 eAndrew 11
    ;include "../../../debug.inc"
4120 eAndrew 12
 
4140 eAndrew 13
    include "DATA.INC"
14
    include "NAME.INC"
15
 
4120 eAndrew 16
    @use_library_mem	 \
17
	    mem.Alloc,	 \
18
	    mem.Free,	 \
19
	    mem.ReAlloc, \
20
	    dll.Load
21
;================================================================================
4140 eAndrew 22
main:
4120 eAndrew 23
; ==== Init ====
24
    mcall   18, 7
25
    mov     [win.psid], eax
26
 
27
    mcall   40, 100101b
28
 
29
; ==== Load libs ====
30
    load_libraries load_lib_start, load_lib_end
31
 
32
; ==== Config LibINI ====
33
    invoke  ini.get_int, ini_data.file_name, ini_data.settings_name, ini_data.location_name, -1
34
    mov     [dock_items.location], eax
35
 
4140 eAndrew 36
    mcall   48, 3, color
37
    or	    dword[color.bg],	0x10000000
38
    or	    dword[color.frame], 0x10000000
39
    or	    dword[color.text],	0x80000000
4120 eAndrew 40
 
41
    invoke  ini.sections, ini_data.file_name, sections_callback
42
 
43
; ==== Config LibIMG ====
4140 eAndrew 44
    mov     dword[fi.p00], 5
45
    mov     dword[fi.p16], buf_128
46
    mov     dword[fi.p21], img_data.file_name
47
 
48
    mcall   70, fi
49
 
50
    mov     edx, [buf_128 + 32]
51
    imul    edx, 10
52
 
53
    stdcall mem.Alloc, edx
4120 eAndrew 54
    mov     [img_data.rgb_object], eax
55
 
4140 eAndrew 56
    mov     dword[fi.p00], 0
57
    mov     dword[fi.p12], edx
58
    m2m     dword[fi.p16], dword[img_data.rgb_object]
59
    mov     dword[fi.p21], img_data.file_name
4120 eAndrew 60
 
4140 eAndrew 61
    mcall   70, fi
4120 eAndrew 62
 
63
    cmp     ebx, 0xFFFFFFFF
64
    je	    @f
65
 
66
    stdcall dword[img.decode], dword[img_data.rgb_object], ebx, 0
67
    mov     dword[img_data.object], eax
68
 
69
  ; === ALPHA ===
70
    mov     edi, 0
71
    add     eax, 24
72
    mov     eax, [eax]
73
 .setalpha:
74
    mov     ebx, [eax + edi]
75
    shr     ebx, 24
76
    cmp     ebx, 0
77
    jne     .nonalpha
4134 eAndrew 78
 
79
    mov     ecx, [color.bg]
4120 eAndrew 80
    mov     [eax + edi], ecx
81
 .nonalpha:
82
    add     edi, 4
4140 eAndrew 83
    cmp     edi, ICONS_SIZE_RGB
4120 eAndrew 84
    jne     .setalpha
85
 
86
  ; === CONVERTING TO BGR
87
    stdcall dword[img.toRGB], dword[img_data.object], dword[img_data.rgb_object]
88
    stdcall dword[img.destroy], dword[img_data.object]
89
 
90
; ==== Config window ====
91
    mov     eax, dword[dock_items.location]
92
    and     eax, 1b
93
    cmp     eax, 0
94
    je	    .vert
95
    jmp     .setshape
96
 
97
 .vert:
98
    mov     byte[win.isvert], 1
99
 
100
 .setshape:
101
    cmp     byte[win.isvert], 1
102
    je	    .vert_sp
103
 
104
 .horz_sp:
105
    call    .HORZ_WIDTH
106
    call    .HORZ_X
107
    call    .HORZ_HEIGHT
108
    cmp     dword[dock_items.location], 1
109
    je	    .settop
110
 
111
 .setbottom:
112
    call    .HORZ_Y_BOTTOM
113
    jmp     .SETDEF
114
 
115
 .settop:
116
    call    .HORZ_Y_TOP
117
    jmp     .SETDEF
118
 
119
 
120
 .vert_sp:
121
    call    .VERT_WIDTH
122
    call    .VERT_HEIGHT
123
    call    .VERT_Y
124
    cmp     dword[dock_items.location], 2
125
    je	    .setleft
126
 
127
 .setright:
128
    call    .VERT_X_RIGHT
129
    jmp     .SETDEF
130
 
131
 .setleft:
132
    call    .VERT_X_LEFT
133
    jmp     .SETDEF
134
 
135
 .HORZ_WIDTH:
4140 eAndrew 136
    mov     eax, BUTTON_SIZE
4120 eAndrew 137
    mov     ebx, [dock_items.count]
138
    imul    eax, ebx
4140 eAndrew 139
    add     eax, 24
4120 eAndrew 140
    dec     eax
141
    mov     [win.width_opn], eax
142
    mov     [win.width_hdn], eax
143
 
144
    ret
145
 
146
 .HORZ_X:
147
    mcall   14
148
    shr     eax, 16
149
    mov     ebx, 2
150
    mov     edx, 0
151
    div     ebx
152
    mov     edx, 0
153
    mov     ecx, eax
154
 
155
    mov     eax, [win.width_opn]
156
    div     ebx
157
    sub     ecx, eax
158
    mov     [win.x_opn], ecx
159
    mov     [win.x_hdn], ecx
160
 
161
    ret
162
 
163
 .HORZ_HEIGHT:
4140 eAndrew 164
    mov     dword[win.height_opn], BUTTON_SIZE
4157 eAndrew 165
    mov     dword[win.height_hdn], 3
4120 eAndrew 166
 
167
    ret
168
 
169
 .HORZ_Y_BOTTOM:
170
    mcall   14
171
    and     eax, 0xFFFF
172
    dec     eax
173
    mov     [win.y_hdn], eax
4157 eAndrew 174
    sub     eax, 43
4120 eAndrew 175
    mov     [win.y_opn], eax
176
 
177
    ret
178
 
179
 .HORZ_Y_TOP:
180
    mov     dword[win.y_opn], 0
181
    mov     dword[win.y_hdn], 0
182
 
183
    ret
184
 
185
 .VERT_WIDTH:
4140 eAndrew 186
    mov     dword[win.width_opn], BUTTON_SIZE
4157 eAndrew 187
    mov     dword[win.width_hdn], 3
4120 eAndrew 188
 
189
    ret
190
 
191
 .VERT_X_LEFT:
192
 
193
    mov     dword[win.x_opn], 0
194
    mov     dword[win.x_hdn], 0
195
 
196
    ret
197
 
198
 .VERT_X_RIGHT:
199
    mcall   14
200
    and     eax, 0xFFFF0000
201
    shr     eax, 16
202
    mov     [win.x_hdn], eax
4140 eAndrew 203
    sub     eax, BUTTON_SIZE
4120 eAndrew 204
    mov     [win.x_opn], eax
205
 
206
    ret
207
 
208
 .VERT_HEIGHT:
4140 eAndrew 209
    mov     eax, BUTTON_SIZE
4120 eAndrew 210
    mov     ebx, [dock_items.count]
211
    imul    eax, ebx
212
    dec     eax
213
    mov     [win.height_opn], eax
214
    mov     [win.height_hdn], eax
215
 
216
    ret
217
 
218
 .VERT_Y:
219
    mcall   14
220
    and     eax, 0xFFFF
221
    mov     edx, 0
222
    mov     ebx, 2
223
    div     ebx
224
    mov     esi, eax
225
 
226
    mov     eax, [win.height_opn]
227
    mov     edx, 0
228
    mov     ebx, 2
229
    div     ebx
230
    sub     esi, eax
231
 
232
    mov     [win.y_hdn], esi
233
    mov     [win.y_opn], esi
234
 
235
    ret
236
 
237
 .SETDEF:
238
    mov     eax, [win.width_hdn]
239
    mov     [win.width], eax
240
 
241
    mov     eax, [win.x_hdn]
242
    mov     [win.x], eax
243
 
244
    mov     eax, [win.height_hdn]
245
    mov     [win.height], eax
246
 
247
    mov     eax, [win.y_hdn]
248
    mov     [win.y], eax
249
 
250
; ==== START ====
251
    mcall   9, win.procinfo, -1
252
    mov     ecx, [win.procinfo + 30]
253
    mcall   18, 21
254
    and     eax, 0xFFFF
255
    mov     [win.sid], eax
256
 
257
    call    main_loop
4140 eAndrew 258
;-------------------------------------------------------------------------------
4120 eAndrew 259
exit:
260
    stdcall mem.Free, [img_data.rgb_object]
261
    mcall   18, 2, [nwin.sid]
262
    mcall   -1
263
;-------------------------------------------------------------------------------
264
proc main_loop
265
    mcall   10
266
 
267
    cmp     eax, EV_REDRAW
268
    je	    event_redraw
269
 
270
    cmp     eax, EV_BUTTON
271
    je	    event_button
272
 
273
    cmp     eax, EV_MOUSE
274
    je	    event_mouse
275
 
276
    jmp     main_loop
277
 
278
 .end:
279
    ret
280
endp
281
;-------------------------------------------------------------------------------
4140 eAndrew 282
event_redraw:
4120 eAndrew 283
    mcall   12, 1
284
 
4140 eAndrew 285
    mcall   0, <[win.x], [win.width]>, <[win.y], [win.height]>, [color.bg], [color.bg], [color.frame]
4120 eAndrew 286
 
287
    mov     edi, 0
288
  @@:
289
    cmp     edi, [dock_items.count]
290
    je	    @f
291
 
292
    push    edi
4124 eAndrew 293
    mov     eax, 8
294
    mov     edx, 0x60000002
295
    mov     esi, [color.bg]
4140 eAndrew 296
    imul    edi, BUTTON_SIZE
297
    add     edi, 12
4124 eAndrew 298
    shl     edi, 16
4140 eAndrew 299
    add     edi, BUTTON_SIZE
4120 eAndrew 300
    cmp     byte[win.isvert], 1
301
    je	    .vert_btn
4140 eAndrew 302
    mcall   , edi, <0, BUTTON_SIZE>
4120 eAndrew 303
    jmp     .endbtn
304
 .vert_btn:
4157 eAndrew 305
    sub     edi, 12 shl 16
4140 eAndrew 306
    mcall   , <0, BUTTON_SIZE>, edi
4120 eAndrew 307
 .endbtn:
308
    pop     edi
309
 
310
    cmp     byte[dock_items.separator + edi], 1
4134 eAndrew 311
    jne     .end_separator
4120 eAndrew 312
 
313
 .draw_separator:
314
    push    ebx
315
    push    ecx
4140 eAndrew 316
 
4124 eAndrew 317
    mov     eax, 13
4120 eAndrew 318
    mov     ebx, edi
4140 eAndrew 319
    imul    ebx, BUTTON_SIZE
320
    add     ebx, BUTTON_SIZE
321
    add     ebx, 12
322
    dec     ebx
4120 eAndrew 323
    shl     ebx, 16
324
    add     ebx, 1
4140 eAndrew 325
 
4120 eAndrew 326
    cmp     byte[win.isvert], 1
327
    je	    .vert_draw_sep
4140 eAndrew 328
    mcall   , , <4, 36>, [color.frame]
4120 eAndrew 329
    jmp     .end_inner_sep
330
 .vert_draw_sep:
4157 eAndrew 331
    sub     ebx, 12 shl 16
4120 eAndrew 332
    mov     ecx, ebx
4140 eAndrew 333
    mcall   , <4, 36>, , [color.frame]
4120 eAndrew 334
 .end_inner_sep:
335
    pop     ecx
336
    pop     ebx
337
 .end_separator:
338
 
339
    cmp     byte[win.isvert], 1
340
    je	    .vert_dig
341
    mov     edx, ebx
342
    and     edx, 0xFFFF0000
4140 eAndrew 343
    add     edx, 0x00060006
4120 eAndrew 344
    jmp     .digend
345
 .vert_dig:
346
    mov     edx, ecx
347
    and     edx, 0xFFFF0000
348
    shr     edx, 16
4140 eAndrew 349
    add     edx, 0x00060006
4120 eAndrew 350
 .digend:
351
 
352
    imul    ebx, edi, 4
353
    add     ebx, dock_items.icon
354
    mov     ebx, [ebx]
4140 eAndrew 355
    imul    ebx, ICON_SIZE_BGR
4120 eAndrew 356
    add     ebx, [img_data.rgb_object]
357
 
358
    mcall   7, , <32, 32>
359
 
360
    inc     edi
361
    jmp     @b
362
  @@:
363
 
364
    mcall   12, 2
365
 
366
    jmp     main_loop
367
;-------------------------------------------------------------------------------
4140 eAndrew 368
event_button:
4120 eAndrew 369
    mcall   17
370
 
371
    cmp     ah, 1
372
    je	    .button_close
373
 
374
    cmp     ah, 2
375
    je	    .button_dock
376
 
377
    jmp     @f
378
 
379
 .button_close:
380
    jmp     exit
381
 
382
 .button_dock:
383
    mov     edi, [win.button_index]
384
    imul    edi, 256
385
 
4140 eAndrew 386
    mov     dword[fi.p00], 7
387
 
4120 eAndrew 388
    mov     esi, edi
389
    add     esi, dock_items.path
4140 eAndrew 390
    mov     dword[fi.p21], esi
4120 eAndrew 391
 
392
    mov     esi, edi
393
    add     esi, dock_items.param
4140 eAndrew 394
    mov     dword[fi.p08], esi
4120 eAndrew 395
 
4140 eAndrew 396
    mcall   70, fi
4120 eAndrew 397
 
4134 eAndrew 398
    mov     ecx, eax
399
    mcall   18, 21
400
    and     eax, 0xFFFF
401
    mov     [win.psid], eax
402
 
4140 eAndrew 403
    jmp     wnd_hide
404
 
4120 eAndrew 405
  @@:
406
    jmp     main_loop
407
;-------------------------------------------------------------------------------
4140 eAndrew 408
event_mouse:
4120 eAndrew 409
    mcall   37, 1
410
    mov     edi, eax
411
    mov     esi, eax
412
    shr     edi, 16
413
    and     esi, 0xFFFF
414
 
415
    cmp     edi, 0
4140 eAndrew 416
    jl	    wnd_hide
4120 eAndrew 417
    dec     edi
418
    cmp     edi, [win.width]
4140 eAndrew 419
    jg	    wnd_hide
4120 eAndrew 420
    cmp     esi, 0
4140 eAndrew 421
    jl	    wnd_hide
4120 eAndrew 422
    dec     esi
423
    cmp     esi, [win.height]
4140 eAndrew 424
    jg	    wnd_hide
4120 eAndrew 425
 
426
    mov     eax, [dock_items.location]
427
    and     eax, 1b
428
    cmp     eax, 1
429
    jne     .vert
430
    mov     eax, edi
431
    jmp     .nxt
432
 
433
 .vert:
434
    mov     eax, esi
4157 eAndrew 435
    add     eax, 12
4120 eAndrew 436
 
437
 .nxt:
4140 eAndrew 438
    sub     eax, 12
4120 eAndrew 439
    mov     edx, 0
4140 eAndrew 440
    mov     ebx, BUTTON_SIZE
4120 eAndrew 441
    div     ebx
442
 
443
    cmp     eax, [dock_items.count]
444
    jge     .set0
445
    jmp     .nxtcmp
446
 
447
 .set0:
448
    mov     eax, 100
449
 
450
 .nxtcmp:
451
    cmp     [win.button_index], eax
452
    je	    .nxt2
453
 
454
    mov     [win.button_index], eax
455
 
456
 .nxt2:
457
    mov     eax, [win.button_index]
4140 eAndrew 458
    imul    eax, BUTTON_SIZE
4120 eAndrew 459
    cmp     byte[win.isvert], 1
460
    je	    .vert_name
461
    add     eax, [win.x]
462
    mov     [nwin.x], eax
4157 eAndrew 463
    mov     byte[nwin.change_shape], 1
464
    mcall   13, <0, [win.width]>, <[win.height], 1>, [color.frame]
4120 eAndrew 465
    jmp     .vert_end
466
 .vert_name:
467
    add     eax, [win.y]
4157 eAndrew 468
    add     eax, 14
4120 eAndrew 469
    mov     [nwin.y], eax
4157 eAndrew 470
    mov     byte[nwin.change_shape], 1
471
    mcall   13, <[win.width], 1>, <0, [win.height]>, [color.frame]
4120 eAndrew 472
 .vert_end:
473
 
474
    cmp     byte[win.state], 1
4140 eAndrew 475
    je	    main_loop
4120 eAndrew 476
 
477
    mov     edx, esp
478
    add     edx, 512
479
    mcall   51, 1, n_main
480
 
4124 eAndrew 481
    mov     eax, 18
482
 
483
    mcall   , 7
4120 eAndrew 484
    mov     [win.psid], eax
485
 
4129 eAndrew 486
    mcall   18, 3, [win.sid]
4120 eAndrew 487
 
488
    mov     byte[win.state], 1
489
 
490
    mov     eax, [win.width_opn]
491
    mov     [win.width], eax
492
 
493
    mov     eax, [win.x_opn]
494
    mov     [win.x], eax
495
 
496
    mov     eax, [win.height_opn]
497
    mov     [win.height], eax
498
 
499
    mov     eax, [win.y_opn]
500
    mov     [win.y], eax
501
 
502
    mcall   67, [win.x], [win.y], [win.width], [win.height]
503
 
4140 eAndrew 504
    jmp     event_redraw
4120 eAndrew 505
 
4140 eAndrew 506
;-------------------------------------------------------------------------------
507
wnd_hide:
4120 eAndrew 508
    cmp     byte[win.state], 0
4140 eAndrew 509
    je	    main_loop
4120 eAndrew 510
 
511
    mov     byte[nwin.close], 1
512
 
513
    mcall   18, 3, [win.psid]
514
 
515
    mov     byte[win.state], 0
516
    mov     byte[win.button_index], -1
517
 
518
    mov     eax, [win.width_hdn]
519
    mov     [win.width], eax
520
 
521
    mov     eax, [win.x_hdn]
522
    mov     [win.x], eax
523
 
524
    mov     eax, [win.height_hdn]
525
    mov     [win.height], eax
526
 
527
    mov     eax, [win.y_hdn]
528
    mov     [win.y], eax
529
 
530
    mcall   67, [win.x], [win.y], [win.width], [win.height]
531
 
4140 eAndrew 532
    jmp     event_redraw
4120 eAndrew 533
;-------------------------------------------------------------------------------
534
proc sections_callback, _file_name, _section_name
535
    mov     eax, [_section_name]
536
    cmp     byte[eax], '@'
537
    jne     @f
538
 
539
    dec     dword[dock_items.count]
540
    jmp     .endproc
541
 
542
  @@:
543
    ; ==== GET NAME ====
544
    mov     ebx, [dock_items.count]
545
    imul    ebx, 16
546
    add     ebx, dock_items.name
547
 
548
    mov     eax, [_section_name]
549
 
550
    mov     edi, 0
551
  @@:
552
    mov     cl, byte[eax]
553
    mov     byte[ebx + edi], cl
554
 
555
    inc     eax
556
    inc     edi
557
    cmp     edi, 10
558
    jne     @b
559
 
560
  ; ==== GET PATH ====
561
    mov     ebx, [dock_items.count]
562
    imul    ebx, 256
563
    add     ebx, dock_items.path
564
 
565
    invoke  ini.get_str, [_file_name], [_section_name], ini_data.path_name, ebx, 256, 0
566
 
567
  ; === GET  PARAM ===
568
    mov     ebx, [dock_items.count]
569
    imul    ebx, 256
570
    add     ebx, dock_items.param
571
 
572
    invoke  ini.get_str, [_file_name], [_section_name], ini_data.param_name, ebx, 256, 0
573
 
574
  ; ==== GET ICON ====
575
    invoke  ini.get_int, [_file_name], [_section_name], ini_data.icon_name, 0
576
 
577
    mov     ebx, [dock_items.count]
578
    imul    ebx, 4
579
    mov     [dock_items.icon + ebx], eax
580
 
581
  ; ==== GET SEPARATOR ====
582
    invoke  ini.get_int, [_file_name], [_section_name], ini_data.separator_name, 0
583
 
584
    mov     ebx, [dock_items.count]
585
    mov     byte[dock_items.separator + ebx], al
586
 
587
  ; ====== END =======
588
 .endproc:
589
    mov     eax, 1
590
    inc     dword[dock_items.count]
591
    ret
592
endp
593
;-------------------------------------------------------------------------------
4140 eAndrew 594
    include "MEMORY.INC"