Subversion Repositories Kolibri OS

Rev

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

  1. proc check_mouse_in_edit_area
  2.         mcall   37,1
  3.         mov     ebx,eax
  4.         and     ebx,0x0000FFFF
  5.         shr     eax,16
  6.         mov     ecx,[cur_editor.Bounds.Top]
  7.         inc     ecx
  8.         pushd   [cur_editor.Bounds.Left] ecx [cur_editor.Bounds.Right] ecx
  9.         popd    [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
  10.         sub     [__rc+0x8],SCRLW+6
  11.         mov     ecx,[cur_editor.Gutter.Width]
  12.         add     [__rc+0x0],ecx
  13.         imul    ecx,[lines.scr],LINEH
  14.         dec     ecx
  15.         add     [__rc+0xC],ecx
  16.         mov     ecx,__rc
  17.         call    pt_in_rect
  18.         ret
  19. endp
  20.  
  21. proc get_mouse_event
  22.         mcall   37,2
  23.         and     al,3
  24.         mov     bl,[ecx]
  25.         cmp     [ecx],al
  26.         mov     [ecx],al
  27.         jne     @f
  28.         mcall   37,7
  29.         or      eax,eax
  30.         jz      .mv
  31.         add     [ecx+6],ax
  32.         shr     eax,16
  33.         add     [ecx+4],ax
  34.         mov     eax,MEV_WHEEL
  35.         ret
  36.   .mv:  mov     eax,MEV_MOVE
  37.         ret
  38.     @@: mov     bh,al
  39.         and     ebx,0x0101
  40.         cmp     bl,bh
  41.         je      .rb
  42.         test    al,1
  43.         jz      @f
  44.         mov     eax,MEV_LDOWN
  45.         ret
  46.     @@: mov     eax,MEV_LUP
  47.         ret
  48.   .rb:  test    al,2
  49.         jz      @f
  50.         mov     eax,MEV_RDOWN
  51.         ret
  52.     @@: mov     eax,MEV_RUP
  53.         ret
  54. endp
  55.  
  56. mouse_ev dd mouse.l_down,mouse.l_up,mouse.r_down,mouse.r_up,mouse.wheel,mouse.move
  57.  
  58. mouse:
  59.         mov     ecx,mst
  60.         call    get_mouse_event
  61.         cmp     [bot_mode],0
  62.         je      @f
  63.         mov     ah,al
  64.         mov     al,4
  65.         call    [bot_dlg_handler]
  66.         jmp     still
  67.     @@: cmp     al,MEV_MOVE
  68.         jne     .no_move
  69.         cmp     [popup_active],1
  70.         je      @f
  71.   .no_move:
  72.         mov     [s_status],0
  73.  
  74.         push    eax
  75.         mcall   9,p_info,-1
  76.         cmp     ax,[p_info.window_stack_position]
  77.         pop     eax
  78.         jne     still.skip_write
  79.     @@:
  80. ;!!!        cmp     [just_from_popup],0
  81. ;!!!        je      @f
  82. ;!!!        cmp     al,MEV_LUP
  83. ;!!!        jne     still.skip_write
  84.     @@: mov     [mev],al
  85.         jmp     [mouse_ev+eax*4-4]
  86.  
  87.   .wheel:
  88.         movsx   eax,word[mst+4]
  89.         lea     eax,[eax*3]
  90.         add     [cur_editor.TopLeft.X],eax
  91.         movsx   eax,word[mst+6]
  92.         lea     eax,[eax*3]
  93.         add     [cur_editor.TopLeft.Y],eax
  94.         xor     eax,eax
  95.         mov     [mst+4],eax
  96.         call    check_bottom_right
  97.         call    draw_editor
  98.         jmp     still.skip_write
  99.  
  100.   .move:
  101.         mcall   37,1
  102.         movsx   ebx,ax
  103.         sar     eax,16
  104.         cmp     [body_capt],0
  105.         jge     .check_body.2
  106.         cmp     [vscrl_capt],0
  107.         jge     .check_vscroll.2
  108.         cmp     [hscrl_capt],0
  109.         jge     .check_hscroll.2
  110.  
  111.         cmp     [do_not_draw],0
  112.         jne     still.skip_write
  113.         mov     eax,[mi_cur]
  114.         call    get_active_menu_item
  115.         cmp     eax,[mi_cur]
  116.         je      still.skip_write
  117.         push    [mi_cur]
  118.         cmp     [popup_active],0
  119.         je      @f
  120.         mov     [mi_cur],eax
  121.     @@: call    draw_main_menu
  122.         pop     [mi_cur]
  123.         cmp     [popup_active],0
  124.         je      still.skip_write
  125.         mov     ecx,[mi_cur]
  126.         or      ecx,ecx
  127.         js      still.skip_write
  128.         mov     eax,[main_menu.popups+ecx*4-4]
  129.         mov     edx,main_menu
  130.         call    dword[main_menu.onshow+ecx*4-4]
  131.         call    setup_main_menu_popup
  132.         mcall   60,2,[h_popup],POPUP_STACK,4
  133.  
  134.         jmp     still.skip_write
  135.  
  136.  
  137.   .r_down:
  138.     @@: cmp     [popup_active],0
  139.         je      @f
  140.         mcall   5,1
  141.         jmp     @b
  142.     @@: cmp     [mouse_captured],0
  143.         jne     still.skip_write
  144.         call    check_mouse_in_edit_area
  145.         jnc     still.skip_write
  146.         mcall   37,0
  147.         mov     [mm.Edit+POPUP.pos],eax
  148.     @@: mcall   37,2
  149.         cmp     eax,ebx
  150.         jnz     @f
  151.         mcall   5,1
  152.         jmp     @b
  153.     @@: and     [mst],0xFD
  154.         call    onshow.edit
  155.         mov     dword[POPUP_STACK],mm.Edit
  156.         mcall   51,1,popup_thread_start,POPUP_STACK
  157.         mov     [h_popup],eax
  158.         jmp     still.skip_write
  159.  
  160.   .r_up:
  161.         jmp     still.skip_write
  162.  
  163.   .l_down:
  164.         call    check_mouse_in_edit_area
  165.         jnc     .check_vscroll
  166.         mov     [mouse_captured],1
  167.         mov     [body_capt],1
  168.  
  169.         call    clear_selection
  170.  
  171.   .check_body.2:
  172.         sub     eax,[cur_editor.Bounds.Left]
  173.         sub     ebx,[cur_editor.Bounds.Top]
  174.         sub     eax,[cur_editor.Gutter.Width]
  175.         sub     eax,LCHGW
  176.         sub     ebx,2
  177.         push    eax
  178.         mov     eax,ebx
  179.         cdq
  180.         mov     ecx,LINEH
  181.         idiv    ecx
  182.     @@: add     eax,[cur_editor.TopLeft.Y]
  183.         mov     ebx,eax
  184.         pop     eax
  185.         cdq
  186.         mov     ecx,6
  187.         idiv    ecx
  188.     @@: add     eax,[cur_editor.TopLeft.X]
  189.  
  190.         cmp     eax,[cur_editor.Columns.Count]
  191.         jl      @f
  192.         mov     eax,[cur_editor.Columns.Count]
  193.     @@: cmp     ebx,[cur_editor.Lines.Count]
  194.         jl      @f
  195.         mov     ebx,[cur_editor.Lines.Count]
  196.         dec     ebx
  197.     @@:
  198.         cmp     [cur_editor.Caret.X],eax
  199.         jne     .change_cur_pos
  200.         cmp     [cur_editor.Caret.Y],ebx
  201.         jne     .change_cur_pos
  202.         call    editor_check_for_changes
  203.         jmp     still.skip_write
  204.  
  205.   .change_cur_pos:
  206.         mov     [cur_editor.Caret.X],eax
  207.         mov     [cur_editor.Caret.Y],ebx
  208.         call    editor_check_for_changes
  209.         jmp     still
  210.  
  211.   .check_vscroll:
  212.         mov     ecx,[cur_editor.Bounds.Right]
  213.         sub     ecx,SCRLW-1
  214.         pushd   ecx [cur_editor.Bounds.Top] ecx [cur_editor.Bounds.Bottom]
  215.         popd    [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
  216.         add     [__rc+0x8],SCRLW-2
  217.         add     [__rc+0x4],SCRLW-1
  218.         sub     [__rc+0xC],SCRLW*2+1
  219.         mov     ecx,__rc
  220.         call    pt_in_rect
  221.         jnc     .check_hscroll
  222.  
  223.   .check_vscroll.2:
  224.         sub     ebx,[cur_editor.Bounds.Top]
  225.         sub     ebx,SCRLW
  226.         cmp     [vscrl_capt],0
  227.         jge     .vcaptured
  228.         mov     eax,[cur_editor.VScroll.Top]
  229.         cmp     ebx,eax
  230.         jb      .center_vcapture
  231.         add     eax,[cur_editor.VScroll.Size]
  232.         cmp     ebx,eax
  233.         jae     .center_vcapture
  234.         mov     eax,ebx
  235.         sub     eax,[cur_editor.VScroll.Top]
  236.         dec     eax
  237.         mov     [vscrl_capt],eax
  238.         dec     ebx
  239.         jmp     .vcaptured
  240.   .center_vcapture:
  241.         mov     eax,[cur_editor.VScroll.Size]
  242.         shr     eax,1
  243.         mov     [vscrl_capt],eax
  244.   .vcaptured:
  245.         sub     ebx,[vscrl_capt]
  246.         jns     @f
  247.         xor     ebx,ebx
  248.     @@: mov     [mouse_captured],1
  249.         mov     eax,[cur_editor.Bounds.Bottom]
  250.         sub     eax,[cur_editor.Bounds.Top]
  251.         sub     eax,[cur_editor.VScroll.Size]
  252.         sub     eax,SCRLW*3
  253.         cmp     eax,ebx
  254.         jge     @f
  255.         mov     ebx,eax
  256.     @@:
  257.         mov     [cur_editor.VScroll.Top],ebx
  258.         mov     eax,[cur_editor.Lines.Count]
  259.         sub     eax,[lines.scr]
  260.         imul    ebx
  261.         mov     ebx,[cur_editor.Bounds.Bottom]
  262.         sub     ebx,[cur_editor.Bounds.Top]
  263.         sub     ebx,SCRLW*3
  264.         sub     ebx,[cur_editor.VScroll.Size]
  265.         idiv    ebx
  266.         cmp     eax,[cur_editor.TopLeft.Y]
  267.         je      still.skip_write
  268.         mov     [cur_editor.TopLeft.Y],eax
  269.         call    check_bottom_right
  270.         call    draw_editor
  271.         jmp     still.skip_write
  272.  
  273.   .check_hscroll:
  274.         pushd   [cur_editor.Bounds.Left] [cur_editor.Bounds.Bottom] [cur_editor.Bounds.Right] [cur_editor.Bounds.Bottom]
  275.         popd    [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
  276.         add     [__rc+0x8],-SCRLW*2-1
  277.         add     [__rc+0x4],-SCRLW+1
  278.         add     [__rc+0xC],-1
  279.         add     [__rc+0x0],SCRLW+1
  280.         mov     ecx,__rc
  281.         call    pt_in_rect
  282.         jnc     .check_main_menu
  283.  
  284.   .check_hscroll.2:
  285.         mov     ebx,eax
  286.         sub     ebx,SCRLW+1
  287.         sub     ebx,[cur_editor.Bounds.Left]
  288.         cmp     [hscrl_capt],0
  289.         jge     .hcaptured
  290.         mov     eax,[cur_editor.HScroll.Top]
  291.         cmp     ebx,eax
  292.         jl      .center_hcapture
  293.         add     eax,[cur_editor.HScroll.Size]
  294.         cmp     ebx,eax
  295.         jge     .center_hcapture
  296.         mov     eax,ebx
  297.         sub     eax,[cur_editor.HScroll.Top]
  298.         dec     eax
  299.         mov     [hscrl_capt],eax
  300.         dec     ebx
  301.         jmp     .hcaptured
  302.   .center_hcapture:
  303.         mov     eax,[cur_editor.HScroll.Size]
  304.         shr     eax,1
  305.         mov     [hscrl_capt],eax
  306.   .hcaptured:
  307.         sub     ebx,[hscrl_capt]
  308.         jns     @f
  309.         xor     ebx,ebx
  310.     @@: mov     [mouse_captured],1
  311.         mov     eax,[cur_editor.Bounds.Right]
  312.         sub     eax,[cur_editor.HScroll.Size]
  313.         sub     eax,SCRLW*3+1
  314.         cmp     eax,ebx
  315.         jge     @f
  316.         mov     ebx,eax
  317.     @@:
  318.         mov     [cur_editor.HScroll.Top],ebx
  319.         mov     eax,[cur_editor.Columns.Count]
  320.         sub     eax,[columns.scr]
  321.         imul    ebx
  322.         mov     ebx,[cur_editor.Bounds.Right]
  323.         sub     ebx,SCRLW*3+1
  324.         sub     ebx,[cur_editor.HScroll.Size]
  325.         idiv    ebx
  326.         cmp     eax,[cur_editor.TopLeft.X]
  327.         je      still.skip_write
  328.         mov     [cur_editor.TopLeft.X],eax
  329.         call    check_bottom_right
  330.         call    draw_editor
  331.         jmp     still.skip_write
  332.  
  333.   .check_main_menu:
  334.         cmp     [do_not_draw],0
  335.         jne     .capture_off
  336.  
  337.     @@: mcall   37,2
  338.         test    eax,0x01
  339.         jz      @f
  340.         mcall   5,1
  341.         jmp     @b
  342.     @@: and     [mst],0xFE
  343.  
  344.         cmp     [mi_cur],0
  345.         jle     .capture_off
  346.         mov     ecx,[mi_cur]
  347.         mov     eax,[main_menu.popups+ecx*4-4]
  348.         mov     edx,main_menu
  349.         call    dword[main_menu.onshow+ecx*4-4]
  350.         call    setup_main_menu_popup
  351.         mcall   51,1,popup_thread_start,POPUP_STACK
  352.         mov     [h_popup],eax
  353.  
  354.   .l_up:
  355.   .capture_off:
  356.         or      eax,-1
  357.         mov     [vscrl_capt],eax
  358.         mov     [hscrl_capt],eax
  359.         mov     [body_capt],eax
  360.         mov     [mouse_captured],0
  361. ;!!!        mov     [just_from_popup],0
  362.         jmp     still.skip_write
  363.