Subversion Repositories Kolibri OS

Rev

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

  1. format MS COFF
  2. public EXPORTS
  3. section '.flat' code readable align 16
  4.  
  5. include '../../../macros.inc'
  6. purge mov
  7. include 'strlen.inc'
  8.  
  9. MB_FIRST_BUT_ID equ 3 ;¨¤¥­â¨ä¨ª â®à 1-© ª­®¯ª¨ ­  á®®¡é¥­¨¨
  10. MB_MAX_BUT equ 8 ;¬ ªá¨¬ «ì­®¥ ç¨á«® ª­®¯®ª ¢ á®®¡é¥­¨¨
  11. MB_BUT_HEIGHT equ 20 ;¢ëá®â  ª­®¯ª¨ ­  á®®¡é¥­¨¨
  12. CHAR_WIDTH equ 6 ;è¨à¨­  1-© ¡ãª¢ë ⥪áâ 
  13. MB_BUT_OTY_1 equ  5 ;¢ëà⨪ «ì­ë©(¥) ®âáâã¯(ë) ¬¥¦¤ã: § £®«®¢ª®¬ ®ª­  ¨ ⥪á⮬, ⥪á⮬ ª­®¯ª ¬¨
  14. ;--- ®âáâã¯ë ­  ª­®¯ª å, 㪠§ ­­ë¥ ¢®¯à®á ¬¨: <-?->, ¡¥§ ãç¥â  ⥪áâ  ---
  15. MB_BUT_OTX_1 equ  5 ;[<-?->Caption.....]
  16. MB_BUT_OTX_2 equ 10 ;[<-?->Caption<-?->]
  17. MB_BUT_OTX_3 equ 15 ;[<-?->Caption<-?->]<-?->
  18. MB_TEXT_OFFSET equ 2 ;ᬥ饭¨¥, ¯® ª®â®à®¬ã ­ ç¨­ ¥âìáï ⥪áâ § £®«®¢ª  ®ª­ 
  19.  
  20. align 4
  21. start:
  22.   mov eax,48
  23.   mov ebx,3
  24.   mov ecx,sc
  25.   mov edx,sizeof.system_colors
  26.   mcall
  27.   mov eax,40
  28.   mov ebx,0x27
  29.   mcall
  30.  
  31.   ;-- clear id pressed button ---
  32.   mov ebx,[mb_text]
  33.   mov al,byte[ebx]
  34.   add al,MB_FIRST_BUT_ID
  35.   dec al
  36.   mov byte[mb_key_foc],al
  37.  
  38.   push [mb_text]
  39.   call MsgBoxReInit
  40.  
  41. align 4
  42. red_win:
  43.   mov eax,12
  44.   mov ebx,1
  45.   mcall
  46.  
  47.   xor eax,eax
  48.   mov bx,word[mb_left]
  49.   shl ebx,16
  50.   mov bx,word[mb_width]
  51.   mov cx,word[mb_top]
  52.   shl ecx,16
  53.   mov cx,word[mb_height]
  54.   mov edx,[sc.work]
  55.   or  edx,0x33000000
  56.   mov edi,[mb_text]
  57.   add edi,MB_TEXT_OFFSET ;Caption
  58.   mcall
  59.  
  60.   mcall 9,mb_procinfo,-1
  61.   mov eax,dword[mb_procinfo.client_box.width]
  62.  
  63.   sub eax,[but_width]
  64.   shr eax,1
  65.   add eax,MB_BUT_OTX_1
  66.   mov [ot_left],eax
  67.  
  68.   mov eax,4 ;à¨á®¢ ­¨¥ ⥪áâ 
  69.   mov bx,MB_BUT_OTX_1
  70.   shl ebx,16
  71.   mov bx,MB_BUT_OTY_1
  72.   mov ecx,[sc.work_text]
  73.   mov edx,[txtMsg]
  74.  
  75.   @@:
  76.     mov esi,edx
  77.     call strlen
  78.     call linlen
  79.  
  80.     cmp eax,0
  81.     je @f
  82.  
  83.     mov esi,eax
  84.     push eax
  85.       mov eax,4
  86.       int 0x40
  87.     pop eax
  88.  
  89.     add edx,eax
  90.     cmp byte[edx],0
  91.     je @f
  92.     inc edx
  93.  
  94.     add ebx,10 ; move <--y-->
  95.     jmp @b
  96.   @@:
  97.  
  98.   call MsgBoxDrawAllBut
  99.   mcall 12,2
  100.  
  101. align 4
  102. still:
  103.   mov eax,10
  104.   mcall
  105.  
  106.   cmp al,1 ;¨§¬. ¯®«®¦¥­¨¥ ®ª­ 
  107.   jz red_win
  108.   cmp al,2
  109.   jz key
  110.   cmp al,3
  111.   jz button
  112.  
  113.   jmp still
  114.  
  115. align 4
  116. key:
  117.   mcall 2
  118.   cmp ah,13
  119.   jne @f
  120.     mov ah,[mb_key_foc]
  121.     jmp close
  122.   @@:
  123.  
  124.   cmp ah,176 ;Left
  125.   jne .no_left
  126.   cmp [mb_key_foc],MB_FIRST_BUT_ID
  127.   jg @f
  128.     mov al,[mb_key_max]
  129.     add [mb_key_foc],al
  130.   @@:
  131.     dec [mb_key_foc]
  132.     call MsgBoxDrawAllBut
  133.   .no_left:
  134.  
  135.   cmp ah,9 ;Tab
  136.   je @f
  137.   cmp ah,179 ;Right
  138.   je @f
  139.         jmp .no_right
  140.   @@:
  141.   mov al,[mb_key_max]
  142.   add al,MB_FIRST_BUT_ID
  143.   cmp [mb_key_foc],al
  144.   je .no_right
  145.     inc [mb_key_foc]
  146.     cmp [mb_key_foc],al
  147.     jl @f
  148.       mov [mb_key_foc],MB_FIRST_BUT_ID
  149.     @@:
  150.     call MsgBoxDrawAllBut
  151.   .no_right:
  152.  
  153.   jmp still
  154.  
  155. align 4
  156. button:
  157.   mcall 17 ;¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨
  158.   cmp ah,MB_FIRST_BUT_ID
  159.   jge close
  160.   cmp ah,1
  161.   jne still
  162.  
  163. ;.exit:
  164.   mov ah,MB_FIRST_BUT_ID
  165.   dec ah
  166. close:
  167.   sub ah,MB_FIRST_BUT_ID
  168.   inc ah
  169.   mov ebx,[mb_text]
  170.   mov byte[ebx],ah
  171.  
  172.   ;*** call msgbox functions ***
  173.   cmp ah,0
  174.   je @f
  175.   cmp dword[mb_funct],0
  176.   je @f
  177.     xor ebx,ebx
  178.     mov bl,ah
  179.     dec bl
  180.     shl bx,2 ;bx=bx*4
  181.     add ebx,dword[mb_funct]
  182.     cmp dword[ebx],0
  183.     je @f
  184.       call dword[ebx]
  185.   @@:
  186.   mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
  187.  
  188. align 4
  189. MsgBoxDrawAllBut:
  190.   mov ebx,[ot_left]
  191.   shl ebx,16
  192.   mov bx,word[ot_top]
  193.   add bx,MB_BUT_OTY_1
  194.  
  195.   ; Buttons ...
  196.   push edi
  197.   mov edi,txtBut
  198.   mov edx,[edi]
  199.  
  200.   mov ecx,MB_FIRST_BUT_ID
  201.   @@:
  202.     ;eax = len button caption text
  203.     mov esi,edx
  204.     call strlen
  205.  
  206.     cmp eax,0
  207.     je @f
  208.  
  209.     call MsgBoxDrawButton
  210.     inc ecx
  211.  
  212.     add edi,4
  213.     cmp edi,endBut
  214.     jge @f
  215.     mov edx,[edi]
  216.  
  217.     push bx
  218.     ror ebx,16
  219.       imul esi,CHAR_WIDTH
  220.       add esi,MB_BUT_OTX_3
  221.       add ebx,esi ; ...
  222.     ror ebx,16
  223.     pop bx
  224.  
  225.     jmp @b
  226.   @@:
  227.   pop edi
  228.   ret
  229.  
  230. ;input:
  231. ; ecx = button id
  232. align 4
  233. MsgBoxDrawButton:
  234.   push ecx
  235.  
  236.   ;button
  237.   push eax ebx edx
  238.     mov edx,ecx
  239.     imul eax,CHAR_WIDTH
  240.     add eax,MB_BUT_OTX_2
  241.  
  242.     mov esi,[sc.work_button]
  243.     cmp cl,[mb_key_foc]
  244.     jne @f
  245.       mov esi,[sc.work_button_text]
  246.     @@:
  247.  
  248.     mov cx,bx
  249.     sub cx,MB_BUT_OTY_1
  250.     shl ecx,16
  251.     mov cx,MB_BUT_HEIGHT
  252.     ror ebx,16
  253.     sub bx,MB_BUT_OTX_1
  254.     ror ebx,16
  255.     mov bx,ax
  256.  
  257.     mov eax,8
  258.     int 0x40
  259.   pop edx ebx eax
  260.  
  261.   ;caption
  262.   mov ecx,[sc.work_button_text]
  263.   cmp esi,ecx
  264.   jne @f
  265.     mov ecx,[sc.work_button]
  266.   @@:
  267.   mov esi,eax
  268.   mov eax,4
  269.   int 0x40
  270.  
  271.   pop ecx
  272.   ret
  273.  
  274. align 4
  275. MsgBoxReInit:
  276.   push ebp
  277.   mov ebp,esp
  278.     m2m dword[mb_text],dword[ebp+8]
  279.   push eax ebx ecx edi esi
  280.  
  281.   mov esi,[mb_text]
  282.   add esi,MB_TEXT_OFFSET
  283.   call strlen
  284.   inc esi ;add terminated zero
  285.   add esi,eax ;add len of caption
  286.   mov [txtMsg],esi
  287.  
  288.   ;--- go to first button text --- buttons 1...MB_MAX_BUT
  289.   mov ebx,txtBut
  290.   mov cx,MB_MAX_BUT
  291.   @@:
  292.     call strlen
  293.     add esi,eax ;add len of caption
  294.     inc esi ;add terminated zero
  295.  
  296.     mov dword[ebx],esi
  297.     cmp byte[esi],0
  298.     je @f
  299.     add ebx,4
  300.   loop @b
  301.   @@:
  302.  
  303.   ;--- calc button top ---
  304.   mov eax,1
  305.   mov ebx,[txtMsg]
  306.   @@:
  307.     inc ebx
  308.     cmp byte[ebx],0
  309.     je @f
  310.     cmp byte[ebx],13
  311.     jne @b
  312.     inc eax
  313.     jmp @b
  314.   @@:
  315.   imul eax,10
  316.   add eax,2*MB_BUT_OTY_1
  317.   mov [ot_top],eax
  318.  
  319.   ;--- calc window height ---
  320.   add eax,MB_BUT_OTY_1
  321.   add eax,MB_BUT_HEIGHT
  322.   add ax,5 ;height of border
  323.   mov [mb_height],ax
  324.   mcall 48,4 ;skin height
  325.   add [mb_height],ax
  326.  
  327.   ;--- calc window top ---
  328.   mov eax,14
  329.   int 0x40
  330.   mov word[mb_top],ax
  331.   mov ax,word[mb_height]
  332.   sub word[mb_top],ax
  333.   shr word[mb_top],1
  334.   ;---
  335.   shr eax,16
  336.   mov word[mb_left],ax
  337.   mov ax,word[mb_width]
  338.   sub word[mb_left],ax
  339.   shr word[mb_left],1
  340.  
  341.   ;--- calc button width ---
  342.   xor ebx,ebx
  343.   xor ecx,ecx
  344.   mov esi,[txtBut]
  345.   mov byte[mb_key_max],0
  346.   @@:
  347.     cmp byte[esi],0
  348.     je @f
  349.     inc ecx
  350.     call strlen
  351.     add esi,eax
  352.     inc esi
  353.     inc byte[mb_key_max]
  354.     add ebx,eax
  355.     jmp @b
  356.   @@:
  357.  
  358.   imul ebx,CHAR_WIDTH
  359.   imul ecx,MB_BUT_OTX_3
  360.   add ebx,ecx
  361.   add ebx,MB_BUT_OTX_2
  362.   sub ebx,MB_BUT_OTX_3
  363.   mov [but_width],ebx
  364.  
  365.   pop esi edi ecx ebx eax
  366.   pop ebp
  367.   ret 4
  368.  
  369. ;input:
  370. ; [esp+8] = pointer to msgbox text
  371. align 4
  372. MsgBoxCreate:
  373.   push ebp
  374.   mov ebp,esp
  375.     m2m dword[mb_text],dword[ebp+8]
  376.     push eax ebx ecx edx
  377.  
  378.     mov eax,51
  379.     mov ebx,1
  380.     mov ecx,start
  381.     mov edx,dword[ebp+12];thread
  382.     int 0x40
  383.  
  384.     mov dword[mb_funct],0
  385.     pop edx ecx ebx eax
  386.   pop ebp
  387.   ret 8
  388.  
  389. ;input:
  390. ; [esp+8] = pointer to msgbox functions pointers
  391. align 4
  392. MsgBoxSetFunctions:
  393.   push ebp
  394.   mov ebp,esp
  395.     m2m dword[mb_funct],dword[ebp+8]
  396.   pop ebp
  397.   ret 4
  398.  
  399. ;--- data ---
  400.   txtMsg dd 0 ;㪠§ â¥«ì ­  ­ ç «® ⥪áâ  á®®¡é¥­¨ï
  401.   txtBut rd MB_MAX_BUT ;㪠§ â¥«ì ­  ­ ç «® ⥪áâ  ¯®¤¯¨á¥© ª­®¯®ª
  402.   endBut:
  403.   ot_left dd 0 ;®âáâ㯠᫥¢  (¤«ï à¨á®¢ ­¨ï ª­®¯®ª)
  404.   ot_top dd 0 ;®âáâ㯠ᢥàåã (¤«ï à¨á®¢ ­¨ï ª­®¯®ª)
  405.   but_width dd 0 ;è¨à¨­  ¢á¥å ª­®¯®ª + § §®àë ¬¥¦¤ã ­¨¬¨
  406.   ;--- à §¬¥àë ­  íªà ­¥ ®ª­  á®®¡é¥­¨ï ---
  407.   mb_left dw 0
  408.   mb_width dw 300
  409.   mb_top dw 0
  410.   mb_height dw 50
  411.   mb_key_foc db MB_FIRST_BUT_ID ;ª­®¯ª  ¢ 䮪ãᥠ(á ãç¥â®¬ MB_FIRST_BUT_ID)
  412.   mb_key_max db 1 ;ç¨á«® ¢á¥å ª­®¯®ª á®®¡é¥­¨ï
  413. ;--------------------------------------------------
  414.   sc system_colors
  415.   mb_procinfo process_information ;㪠§ â¥«ì ­  áâàãªâãàã process_information த¨â¥«ì᪮£® ®ª­ 
  416.   mb_text dd 0 ;msgbox_1 ;㪠§ â¥«ì ¤ ­­ë¥ ¤«ï á®®¡é¥­¨ï (ª®â®àë ¯¥à¥¤ îâìáï ®ª­ã)
  417.   mb_funct dd 0 ;pointer to functions
  418. ;--------------------------------------------------
  419. align 16
  420. EXPORTS:
  421.   dd sz_mb_create, MsgBoxCreate
  422.   dd sz_mb_reinit, MsgBoxReInit
  423.   dd sz_mb_setfunctions, MsgBoxSetFunctions
  424.   dd 0,0
  425.   sz_mb_create db 'mb_create',0
  426.   sz_mb_reinit db 'mb_reinit',0
  427.   sz_mb_setfunctions db 'mb_setfunctions',0