Subversion Repositories Kolibri OS

Rev

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