Subversion Repositories Kolibri OS

Rev

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

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