Subversion Repositories Kolibri OS

Rev

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