Subversion Repositories Kolibri OS

Rev

Rev 5838 | Details | Compare with Previous | Last modification | View Log | RSS feed

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