Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;
  3. ;   MENU / DIALOG EXAMPLE
  4. ;
  5. ;   Compile with FASM for Menuet
  6. ;
  7.  
  8. use32
  9.  
  10.                org    0x0
  11.  
  12.                db     'MENUET01'              ; 8 byte id
  13.                dd     0x01                    ; header version
  14.                dd     START                   ; start of code
  15.                dd     I_END                   ; size of image
  16.                dd     0x10000                  ; memory for app
  17.                dd     0x10000                  ; esp
  18.                dd     0x0 , 0x0               ; I_Param , I_Icon
  19.  
  20. include 'lang.inc'
  21. include '..\..\..\..\macros.inc'
  22. include 'dialogs1.inc'
  23.  
  24. menu_history dd 0x0
  25.  
  26. START:                          ; start of execution
  27.  
  28. red:
  29.      call draw_window_main
  30.  
  31. still:                          ; wait here for event
  32.  
  33.     mov  eax,10
  34.     mcall
  35.  
  36.     cmp  eax,1                  ; process events
  37.     je   red
  38.     cmp  eax,2
  39.     je   key
  40.     cmp  eax,3
  41.     je   button
  42.  
  43.     call check_mouse            ; DIALOG CHECK
  44.  
  45.     mov  eax,[menu_action]
  46.     cmp  eax,[menu_history]
  47.     je   nodisplay
  48.  
  49.     mov  [menu_history],eax
  50.  
  51.     mov  eax,13
  52.     mov  ebx,220*65536+6*4
  53.     mov  ecx,70*65536+8
  54.     mov  edx,0xffffff
  55.     mcall
  56.  
  57.     mov  eax,4                  ; show menu selections
  58.     mov  ebx,220*65536+70
  59.     mov  ecx,0x000000
  60.     mov  edx,menu_action
  61.     mov  esi,4
  62.     mcall
  63.  
  64.   nodisplay:
  65.  
  66.     cmp  word [menu_action],word 'AD' ; user requests close
  67.     jne  no_menu_close
  68.     mov  eax,-1
  69.     mcall
  70.   no_menu_close:
  71.  
  72.     jmp  still
  73.  
  74.   key:
  75.     mov  eax,2                  ; key in buffer
  76.     mcall
  77.     jmp  still
  78.  
  79.   button:                       ; button in buffer
  80.     mov  eax,17
  81.     mcall
  82.  
  83.     cmp  ah,1                   ; close application
  84.     jne  noclose
  85.     or  eax,-1
  86.     mcall
  87.   noclose:
  88.  
  89.     cmp  ah,2
  90.     jne  no_alert_box           ; ALERT BOX
  91.     mov  eax,170                ; window width
  92.     mov  ebx,alert_text         ; asciiz string
  93.     mov  ecx,1                  ; OK button
  94.     call alert_box              ; function call
  95.     jmp  still
  96.   no_alert_box:
  97.  
  98.     cmp  ah,3
  99.     jne  no_choose_box          ; CHOOSE BOX
  100.     mov  eax,220                ; window width
  101.     mov  ebx,choose_text        ; asciiz string
  102.     mov  ecx,2                  ; YES/NO buttons
  103.     call alert_box              ; function call
  104.     jmp  still
  105.   no_choose_box:
  106.  
  107.  
  108.     jmp  still
  109.  
  110.  
  111.  
  112.  
  113. ;   *********************************************
  114. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  115. ;   *********************************************
  116.  
  117. draw_window_main:
  118.  
  119.     mov  eax,12                    ; function 12:tell os about windowdraw
  120.     mov  ebx,1                     ; 1, start of draw
  121.     mcall
  122.  
  123.     mov  eax,0                     ; open window
  124.     mov  ebx,100*65536+300
  125.     mov  ecx,100*65536+120
  126.     mov  edx,0x02ffffff
  127.     mov  esi,0x805080d0
  128.     mov  edi,0x005080d0
  129.     mcall
  130.  
  131.     call draw_menu                 ; DRAW MENU
  132.  
  133.     mov  eax,4                     ; window label
  134.     mov  ebx,8*65536+8
  135.     mov  ecx,0x10ddeeff
  136.     mov  edx,labelt
  137.     mov  esi,labellen-labelt
  138.     mcall
  139.  
  140.     mov  eax,8                     ; close button
  141.     mov  ebx,(300-17)*65536+10
  142.     mov  ecx,5*65536+10
  143.     mov  edx,1
  144.     mov  esi,0x4466bb
  145.     mcall
  146.  
  147.     mov  eax,8                     ; button : OPEN ALERT BOX
  148.     mov  ebx,25*65536+150
  149.     mov  ecx,61*65536+14
  150.     mov  edx,2
  151.     mov  esi,0x4466aa
  152.     mcall
  153.  
  154.     mov  eax,8                     ; button : OPEN CHOOSE BOX
  155.     mov  ebx,25*65536+150
  156.     mov  ecx,81*65536+14
  157.     mov  edx,3
  158.     mov  esi,0x4466aa
  159.     mcall
  160.  
  161.     mov  ebx,20*65536+55           ; draw info text with function 4
  162.     mov  ecx,0xffffff
  163.     mov  edx,text
  164.     mov  esi,40
  165.   newline:
  166.     mov  eax,4
  167.     mcall
  168.     add  ebx,10
  169.     add  edx,40
  170.     cmp  [edx],byte 'x'
  171.     jne  newline
  172.  
  173.     mov  eax,12                    ; function 12:tell os about windowdraw
  174.     mov  ebx,2                     ; 2, end of draw
  175.     mcall
  176.  
  177.     ret
  178.  
  179.  
  180. ; DATA AREA
  181.  
  182. text:
  183.     db '                                        '
  184.     db '   OPEN ALERT BOX                       '
  185.     db '                                        '
  186.     db '   OPEN CHOOSE BOX                      '
  187.  
  188.     db 'x <- END MARKER, DONT DELETE            '
  189.  
  190. labelt:
  191.      db   'EXAMPLE APPLICATION'
  192. labellen:
  193.  
  194. alert_text   db  '    File not found !',0
  195. choose_text  db  '    Save file before exit ? ',0
  196.  
  197. I_END:
  198.