Subversion Repositories Kolibri OS

Rev

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