Subversion Repositories Kolibri OS

Rev

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