Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;                                                       ;
3
;    DIALOGS1.INC                                       ;
4
;                                                       ;
5
;    COMPILE WITH FASM for MENUET                       ;
6
;                                                       ;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
9
 
10
menus     dd   3        ; number of menus
11
m_x       dd   0x5      ; x start
12
m_y       dd   20       ; y start
13
m_xs      dd   290      ; x size
14
m_ys      dd   14       ; y size
15
g_stack   dd   0xf000   ; thread stack - required
16
 
17
 
18
menu:; AB C           D            E            F            G
19
 
20
  db  '*D FILE        +Save File   +Load File   +-           +Quit        '
21
  db  '*B EDIT        +Copy        +Paste       '
22
  db  '*B HELP        +Setup       +About..     '
23
  db    '@' ; end mark
24
 
25
;  A   : Data type '*' -> New menu , '+' -> menu selection
26
;  B   : Number of selections in menu (A+)
27
;  C   : Menu header text
28
;  D-G : Menu selection text
29
 
30
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31
;
32
;  DATA BELOW IS FOR DIALOGS1.INC INTERNALS
33
 
34
menu_action dd '----'
35
 
36
window_on   db 0
37
 
38
g_n         dd -1
39
g_x         dd 0x0
40
g_t         dd 0x0
41
g_1         dd 0x0
42
g_l         dd 0x0
43
closet      db 0
44
 
45
table: times 1024 db 0
46
 
47
last_mouse  dd  0x0
48
 
49
mo_x       dd 0x0
50
mo_y       dd 0x0
51
 
52
 
53
check_mouse:
54
 
55
     pusha
56
 
57
     cmp  [window_on],1
58
     je   no_open
59
 
60
     mov  eax,37
61
     mov  ebx,2
485 heavyiron 62
     mcall
31 halyavin 63
 
64
     cmp  [window_on],0
65
     jne  openw2
66
 
67
     cmp  eax,0
68
     je   no_open
69
 
70
  openw2:
71
 
72
   waitformouse:
73
 
74
     mov  eax,23
75
     mov  ebx,2
485 heavyiron 76
     mcall
31 halyavin 77
 
78
     cmp  eax,0
79
     jne  no_open
80
 
81
     mov  eax,37
82
     mov  ebx,2
485 heavyiron 83
     mcall
31 halyavin 84
 
85
     cmp  eax,0
86
     jne  waitformouse
87
 
88
 
89
     mov  eax,37
90
     mov  ebx,1
485 heavyiron 91
     mcall
31 halyavin 92
 
93
     mov  esi,eax
94
 
95
     shr  eax,16
96
     xor  edx,edx
97
     mov  ebx,50
98
     div  ebx
99
     mov  edx,eax
100
     cmp  edx,[g_n]
101
     je   no_open
102
     cmp  edx,[menus]
103
     jge  no_open
104
     mov  eax,esi
105
 
106
     and  eax,0xffff
107
 
108
     mov  ebx,[m_y]
109
     cmp  eax,ebx
110
     jbe  no_open
111
     add  ebx,[m_ys]
112
     cmp  eax,ebx
113
     jge  no_open
114
 
115
     cmp  [window_on],0
116
     je   noww
117
 
118
     mov  [closet],1
119
     mov  ecx,100
120
   waitm:
121
     mov  eax,5
122
     mov  ebx,1
485 heavyiron 123
     mcall
31 halyavin 124
     dec  ecx
125
     jz   no_open
126
     cmp  [window_on],0
127
     jne  waitm
128
   noww:
129
 
130
     mov  eax,edx
131
     jmp  cll
132
 
133
   no_open:
134
 
135
     mov  [last_mouse],esi
136
 
137
     popa
138
 
139
     ret
140
 
141
   cll:
142
 
143
     mov  [window_on],2
144
 
145
     mov  [g_n],eax
146
     mov  [g_x],96
147
     mov  [g_t],0
148
     mov  [g_1],1
149
 
150
     mov  eax,9
151
     mov  ebx,table
152
     mov  ecx,-1
485 heavyiron 153
     mcall
31 halyavin 154
 
155
     mov  eax,[table+34]
156
     mov  [mo_x],eax
157
     mov  eax,[table+38]
158
     mov  [mo_y],eax
159
 
160
     mov  eax,51
161
     mov  ebx,1
162
     mov  ecx,alert_entry
163
     mov  edx,[g_stack]
485 heavyiron 164
     mcall
31 halyavin 165
 
166
     mov  [esp+28],dword 0  ; clear button entry
167
 
168
     mov  [menu_action],'MD  '
169
 
170
   check_gr:
171
 
172
     popa
173
 
174
     ret
175
 
176
 
177
draw_menu:
178
 
179
     mov  eax,9
180
     mov  ebx,table
181
     mov  ecx,-1
485 heavyiron 182
     mcall
31 halyavin 183
 
184
     cmp  [table+46],dword 30
185
     jb   drmr
186
 
187
     mov  eax,13     ; white background
188
     mov  ebx,[m_x]
189
     shl  ebx,16
190
     add  ebx,[m_xs]
191
     inc  ebx
192
     mov  ecx,[m_y]
193
     shl  ecx,16
194
     add  ecx,[m_ys]
195
     mov  edx,0xf0f8ff
485 heavyiron 196
     mcall
31 halyavin 197
 
198
     mov  eax,38     ; egde lines
199
     mov  ebx,[m_x]
200
     shl  ebx,16
201
     add  ebx,[m_x]
202
     add  ebx,[m_xs]
203
     mov  ecx,[m_y]
204
     shl  ecx,16
205
     add  ecx,[m_y]
206
     mov  edx,0x000000
485 heavyiron 207
     mcall
31 halyavin 208
     mov  eax,38
209
     mov  ecx,[m_y]
210
     add  ecx,[m_ys]
211
     shl  ecx,16
212
     add  ecx,[m_y]
213
     add  ecx,[m_ys]
485 heavyiron 214
     mcall
31 halyavin 215
 
216
     mov  esi,menu-1
217
     mov  edi,[m_x]
218
     mov  ebp,1
219
    new_menu:
220
     inc  esi
221
 
222
     cmp  [esi],byte '*'
223
     jne  drmnl1
224
     push esi
225
     mov  eax,4
226
     mov  ebx,edi
227
     shl  ebx,16
228
     add  ebx,[m_y]
229
     add  ebx,0x00050004
230
     mov  ecx,0x000000
231
     mov  edx,esi
232
     add  edx,3
233
     mov  esi,12
485 heavyiron 234
     mcall    ; draw text
31 halyavin 235
     pop  esi
236
     add  esi,2
237
     add  edi,50
238
     inc  ebp
239
 
240
    drmnl1:
241
     cmp  [esi],byte '@'
242
     jne  new_menu
243
 
244
    drmr:
245
 
246
     ret
247
 
248
alert_box:
249
 
250
   ; eax : x size - min 200
251
   ; ebx : pointer to ASCIIZ - max 128 character text
252
   ; ecx : button 1 id          ( OK or YES )
253
   ; edx : button 2 id or zero  ( NO )
254
 
255
 
256
   cmp  [window_on],0
257
   jne  alert_box_return
258
 
259
   mov  [window_on],1
260
 
261
   cmp  eax,100
262
   jg   size_ok
263
   mov  eax,100
264
 size_ok:
265
 
266
   mov  [g_x],eax
267
   mov  [g_t],ebx
268
   mov  [g_1],ecx
269
 
270
   mov  ecx,0
271
 new_search:
272
   cmp  [ebx],byte 0
273
   je   found_len
274
   inc  ebx
275
   inc  ecx
276
   cmp  ecx,128
277
   jbe  new_search
278
 found_len:
279
   mov  [g_l],ecx
280
 
281
   mov  eax,51
282
   mov  ebx,1
283
   mov  ecx,alert_entry
284
   mov  edx,[g_stack]
485 heavyiron 285
   mcall
31 halyavin 286
 
287
   mov  [menu_action],'MA  '
288
 
289
 alert_box_return:
290
 
291
   ret
292
 
293
alert_entry:
294
 
295
     call alert_draw_window
296
 
297
alert_still:
298
 
299
    mov  eax,23                 ; wait here for event
300
    mov  ebx,1
485 heavyiron 301
    mcall
31 halyavin 302
 
303
    cmp  eax,1                  ; redraw request ?
304
    je   alert_red
305
    cmp  eax,2                  ; key in buffer ?
306
    je   alert_key
307
    cmp  eax,3                  ; button in buffer ?
308
    je   alert_button
309
 
310
    cmp  [closet],0
311
    jne  ccc
312
 
313
    mov  eax,9
314
    mov  ebx,table
315
    mov  ecx,-1
485 heavyiron 316
    mcall
31 halyavin 317
 
318
    cmp  ax,[table+4]
319
    je   no_close
320
  ccc:
321
    mov  [closet],0
322
    mov  [g_n],-1
323
    mov  [menu_action],'----'
324
    mov  [window_on],0
325
    mov  eax,-1
485 heavyiron 326
    mcall
31 halyavin 327
  no_close:
328
 
329
    jmp  alert_still
330
 
331
  alert_red:                          ; redraw
332
    call alert_draw_window
333
    jmp  alert_still
334
 
335
  alert_key:                    ; key
336
    mov  eax,2                  ; just read it and ignore
485 heavyiron 337
    mcall
31 halyavin 338
    jmp  alert_still
339
 
340
  alert_button:                 ; button
341
    mov  eax,17                 ; get id
485 heavyiron 342
    mcall
31 halyavin 343
 
344
    shr  eax,8
345
    cmp  eax,3
346
    jg   no_action1
347
    dec  eax
348
    shl  eax,2
349
    mov  eax,dword [eax+rtext]
350
    mov  [menu_action],eax
351
    jmp  action_done
352
  no_action1:
353
    sub  eax,16
354
    add  eax,65
355
    shl  eax,8
356
    mov  ebx,[g_n]
357
    add  ebx,65
358
    add  eax,ebx
359
    mov  [menu_action],eax
360
 
361
  action_done:
362
 
363
    mov  [closet],0
364
    mov  [g_n],-1
365
    mov  [window_on],0
366
    mov  eax,-1                 ; close this program
485 heavyiron 367
    mcall
31 halyavin 368
 
369
  rtext db 'NO  YES OK  '
370
 
371
    jmp  alert_still
372
 
373
 
374
;   *********************************************
375
;   *******  WINDOW DEFINITIONS AND DRAW ********
376
;   *********************************************
377
 
378
 
379
alert_draw_window:
380
 
381
 
382
    mov  eax,12                    ; function 12:tell os about windowdraw
383
    mov  ebx,1                     ; 1, start of draw
485 heavyiron 384
    mcall
31 halyavin 385
 
386
    cmp  [window_on],2
387
    jne  no_win_type_2
388
 
389
    mov  edx,menu-1
390
    mov  ecx,[g_n]
391
    add  ecx,1
392
   find_menu:
393
    inc  edx
394
    cmp  [edx],byte '*'
395
    je   menu_loop
396
    jmp  find_menu
397
   menu_loop:
398
    loop find_menu
399
    movzx ebp,byte [edx+1]
400
    sub  ebp,64
401
    push edx
402
                                   ; DRAW WINDOW
403
    mov  eax,0                     ; function 0 : define and draw window
404
    mov  ebx,[g_n]
405
    imul ebx,50
406
    add  ebx,[mo_x]
407
    add  ebx,[m_x]
408
    shl  ebx,16
409
    add  ebx,[g_x]
410
    mov  ecx,[mo_y]
411
    add  ecx,[m_y]
412
    add  ecx,[m_ys]
413
    shl  ecx,16
414
    mov  edx,14
415
    imul edx,ebp
416
    add  edx,7
417
    add  ecx,edx
418
    mov  edx,0x00ffffff            ; color of work area RRGGBB,8->color gl
419
    mov  esi,0x00ffffff            ; color of grab bar  RRGGBB,8->color gl
420
    mov  edi,0x000000cc            ; color of frames    RRGGBB
485 heavyiron 421
    mcall
31 halyavin 422
 
423
    pop  edx
424
 
425
    mov  ebx,5*65536+7            ; draw info text with function 4
426
    mov  ecx,0x10000000
427
    mov  esi,12
428
    mov  ebp,16
429
  no_d_found:
430
    inc  edx
431
    cmp  [edx],byte '*'
432
    je   d_drawed
433
    cmp  [edx],byte '@'
434
    je   d_drawed
435
    cmp  [edx],byte '+'
436
    jne  no_d_found
437
    inc  edx
438
    pusha          ; draw button
439
    mov  eax,8
440
    mov  ecx,ebx
441
    mov  ebx,[g_x]
442
    add  ebx,0x0000fffe
443
    shl  ecx,16
444
    add  ecx,0xfffc0000+14
445
    mov  edx,0x40000000
446
    add  edx,ebp
447
    mov  esi,0
485 heavyiron 448
    mcall
31 halyavin 449
    popa
450
    mov  eax,4     ; draw text
485 heavyiron 451
    mcall
31 halyavin 452
    inc  ebp
453
    add  ebx,14
454
    jmp  no_d_found
455
  d_drawed:
456
 
457
  no_win_type_2:
458
 
459
 
460
    cmp  [window_on],1
461
    jne  no_win_1
462
 
463
    mov  eax,14                    ; to middle of screen
485 heavyiron 464
    mcall
31 halyavin 465
    mov  ecx,eax
466
    and  ecx,0xffff
467
    shr  ecx,1
468
    shr  eax,1
469
    mov  ebx,[g_x]
470
    shr  ebx,1
471
    shl  ebx,16
472
    sub  eax,ebx
473
    mov  ebx,eax
474
 
475
    mov  eax,0                     ; function 0 : define and draw window
476
    mov  bx,word [g_x]
477
    sub  ecx,80
478
    shl  ecx,16
479
    mov  cx,110                    ; [y start] *65536 + [y size]
480
    mov  edx,0x02ffffff            ; color of work area RRGGBB,8->color gl
481
    mov  esi,0x80d05050            ; color of grab bar  RRGGBB,8->color gl
482
    mov  edi,0x00d05050            ; color of frames    RRGGBB
485 heavyiron 483
    mcall
31 halyavin 484
 
485
 
486
    mov  eax,4                       ; label
487
    mov  ebx,8*65536+8
488
    mov  ecx,0x10ddeeff
489
    mov  edx,alert_labelt1
490
    mov  esi,alert_label1len-alert_labelt1
485 heavyiron 491
    mcall
31 halyavin 492
 
493
    mov  eax,4
494
    mov  ebx,10*65536+43
495
    mov  ecx,0x10000000
496
    mov  edx,[g_t]
497
    mov  esi,[g_l]
485 heavyiron 498
    mcall
31 halyavin 499
 
500
    cmp  [g_1],1
501
    jne  gadgets_no_1
502
 
503
    mov  eax,8
504
    mov  ebx,[g_x]
505
    sub  ebx,100
506
    shr  ebx,1
507
    shl  ebx,16
508
    add  ebx,30*65536+40
509
    mov  ecx,75*65536+16
510
    mov  edx,3
511
    mov  esi,0x446688
485 heavyiron 512
    mcall
31 halyavin 513
 
514
    mov  eax,4
515
    mov  ebx,[g_x]
516
    sub  ebx,100
517
    shr  ebx,1
518
    shl  ebx,16
519
    add  ebx,31*65536+80
520
    mov  ecx,0x10ffffff
521
    mov  edx,alert_t2
522
    mov  esi,alert_t2len-alert_t2
485 heavyiron 523
    mcall
31 halyavin 524
 
525
  gadgets_no_1:
526
 
527
    cmp  [g_1],2
528
    jne  gadgets_no_2
529
 
530
    mov  eax,8
531
    mov  ebx,[g_x]
532
    sub  ebx,100
533
    shr  ebx,1
534
    shl  ebx,16
535
    add  ebx,0*65536+40
536
    mov  ecx,75*65536+16
537
    mov  edx,1
538
    mov  esi,0x446688
485 heavyiron 539
    mcall
31 halyavin 540
 
541
    mov  eax,8
542
    mov  ebx,[g_x]
543
    sub  ebx,100
544
    shr  ebx,1
545
    shl  ebx,16
546
    add  ebx,57*65536+40
547
    mov  ecx,75*65536+16
548
    mov  edx,2
549
    mov  esi,0x446688
485 heavyiron 550
    mcall
31 halyavin 551
 
552
    mov  eax,4
553
    mov  ebx,[g_x]
554
    sub  ebx,100
555
    shr  ebx,1
556
    shl  ebx,16
557
    add  ebx,1*65536+80
558
    mov  ecx,0x10ffffff
559
    mov  edx,alert_t1
560
    mov  esi,alert_t1len-alert_t1
485 heavyiron 561
    mcall
31 halyavin 562
 
563
  gadgets_no_2:
564
 
565
  no_win_1:
566
 
567
    mov  eax,12                    ; function 12:tell os about windowdraw
568
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 569
    mcall
31 halyavin 570
 
571
    ret
572
 
573
 
574
; DATA AREA
575
 
576
 
577
alert_t1:
578
    db '  No      Yes'
579
alert_t1len:
580
 
581
 
582
alert_t2:
583
    db '  OK'
584
alert_t2len:
585
 
586
 
587
alert_labelt1:
588
     db   'ALERT'
589
alert_label1len:
590