Subversion Repositories Kolibri OS

Rev

Rev 824 | Rev 2065 | Go to most recent revision | 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
178 heavyiron 4
	mcall	37,1
5
	mov	ebx,eax
6
	and	ebx,0x0000FFFF
7
	shr	eax,16
297 mikedld 8
	mov	ecx,[cur_editor.Bounds.Top]
178 heavyiron 9
	inc	ecx
297 mikedld 10
	pushd	[cur_editor.Bounds.Left] ecx [cur_editor.Bounds.Right] ecx
178 heavyiron 11
	popd	[__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
12
	sub	[__rc+0x8],SCRLW+6
280 mikedld 13
	mov	ecx,[cur_editor.Gutter.Width]
14
	add	[__rc+0x0],ecx
178 heavyiron 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
617 mikedld 21
endp
178 heavyiron 22
 
617 mikedld 23
proc get_mouse_event
178 heavyiron 24
	mcall	37,2
25
	and	al,3
26
	mov	bl,[ecx]
27
	cmp	[ecx],al
28
	mov	[ecx],al
29
	jne	@f
617 mikedld 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
178 heavyiron 37
	ret
617 mikedld 38
  .mv:	mov	eax,MEV_MOVE
39
	ret
178 heavyiron 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
617 mikedld 56
endp
178 heavyiron 57
 
617 mikedld 58
mouse_ev dd mouse.l_down,mouse.l_up,mouse.r_down,mouse.r_up,mouse.wheel,mouse.move
178 heavyiron 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]
1480 mikedld 68
	jmp	still.skip_write
178 heavyiron 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
    @@:
297 mikedld 82
;!!!        cmp     [just_from_popup],0
83
;!!!        je      @f
84
;!!!        cmp     al,MEV_LUP
85
;!!!        jne     still.skip_write
178 heavyiron 86
    @@: mov	[mev],al
87
	jmp	[mouse_ev+eax*4-4]
88
 
617 mikedld 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
 
178 heavyiron 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
259 mikedld 149
	mov	[mm.Edit+POPUP.pos],eax
178 heavyiron 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
259 mikedld 157
	mov	dword[POPUP_STACK],mm.Edit
178 heavyiron 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:
297 mikedld 174
	sub	eax,[cur_editor.Bounds.Left]
175
	sub	ebx,[cur_editor.Bounds.Top]
280 mikedld 176
	sub	eax,[cur_editor.Gutter.Width]
177
	sub	eax,LCHGW
178
	sub	ebx,2
178 heavyiron 179
	push	eax
180
	mov	eax,ebx
297 mikedld 181
	cdq
178 heavyiron 182
	mov	ecx,LINEH
183
	idiv	ecx
297 mikedld 184
    @@: add	eax,[cur_editor.TopLeft.Y]
178 heavyiron 185
	mov	ebx,eax
186
	pop	eax
297 mikedld 187
	cdq
178 heavyiron 188
	mov	ecx,6
189
	idiv	ecx
297 mikedld 190
    @@: add	eax,[cur_editor.TopLeft.X]
178 heavyiron 191
 
297 mikedld 192
	cmp	eax,[cur_editor.Columns.Count]
178 heavyiron 193
	jl	@f
297 mikedld 194
	mov	eax,[cur_editor.Columns.Count]
195
    @@: cmp	ebx,[cur_editor.Lines.Count]
178 heavyiron 196
	jl	@f
297 mikedld 197
	mov	ebx,[cur_editor.Lines.Count]
178 heavyiron 198
	dec	ebx
199
    @@:
297 mikedld 200
	cmp	[cur_editor.Caret.X],eax
178 heavyiron 201
	jne	.change_cur_pos
297 mikedld 202
	cmp	[cur_editor.Caret.Y],ebx
203
	jne	.change_cur_pos
204
	call	editor_check_for_changes
205
	jmp	still.skip_write
178 heavyiron 206
 
207
  .change_cur_pos:
297 mikedld 208
	mov	[cur_editor.Caret.X],eax
209
	mov	[cur_editor.Caret.Y],ebx
210
	call	editor_check_for_changes
178 heavyiron 211
	jmp	still
212
 
213
  .check_vscroll:
280 mikedld 214
	mov	ecx,[cur_editor.Bounds.Right]
297 mikedld 215
	sub	ecx,SCRLW-1
216
	pushd	ecx [cur_editor.Bounds.Top] ecx [cur_editor.Bounds.Bottom]
178 heavyiron 217
	popd	[__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
297 mikedld 218
	add	[__rc+0x8],SCRLW-2
219
	add	[__rc+0x4],SCRLW-1
220
	sub	[__rc+0xC],SCRLW*2+1
178 heavyiron 221
	mov	ecx,__rc
222
	call	pt_in_rect
223
	jnc	.check_hscroll
224
 
225
  .check_vscroll.2:
297 mikedld 226
	sub	ebx,[cur_editor.Bounds.Top]
227
	sub	ebx,SCRLW
178 heavyiron 228
	cmp	[vscrl_capt],0
229
	jge	.vcaptured
297 mikedld 230
	mov	eax,[cur_editor.VScroll.Top]
178 heavyiron 231
	cmp	ebx,eax
232
	jb	.center_vcapture
297 mikedld 233
	add	eax,[cur_editor.VScroll.Size]
178 heavyiron 234
	cmp	ebx,eax
235
	jae	.center_vcapture
236
	mov	eax,ebx
297 mikedld 237
	sub	eax,[cur_editor.VScroll.Top]
178 heavyiron 238
	dec	eax
239
	mov	[vscrl_capt],eax
240
	dec	ebx
241
	jmp	.vcaptured
242
  .center_vcapture:
297 mikedld 243
	mov	eax,[cur_editor.VScroll.Size]
178 heavyiron 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
297 mikedld 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
178 heavyiron 255
	cmp	eax,ebx
256
	jge	@f
257
	mov	ebx,eax
258
    @@:
297 mikedld 259
	mov	[cur_editor.VScroll.Top],ebx
260
	mov	eax,[cur_editor.Lines.Count]
178 heavyiron 261
	sub	eax,[lines.scr]
262
	imul	ebx
297 mikedld 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]
178 heavyiron 267
	idiv	ebx
297 mikedld 268
	cmp	eax,[cur_editor.TopLeft.Y]
178 heavyiron 269
	je	still.skip_write
297 mikedld 270
	mov	[cur_editor.TopLeft.Y],eax
178 heavyiron 271
	call	check_bottom_right
297 mikedld 272
	call	draw_editor
178 heavyiron 273
	jmp	still.skip_write
274
 
275
  .check_hscroll:
297 mikedld 276
	pushd	[cur_editor.Bounds.Left] [cur_editor.Bounds.Bottom] [cur_editor.Bounds.Right] [cur_editor.Bounds.Bottom]
178 heavyiron 277
	popd	[__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
280 mikedld 278
	add	[__rc+0x8],-SCRLW*2-1
279
	add	[__rc+0x4],-SCRLW+1
280
	add	[__rc+0xC],-1
281
	add	[__rc+0x0],SCRLW+1
178 heavyiron 282
	mov	ecx,__rc
283
	call	pt_in_rect
284
	jnc	.check_main_menu
285
 
286
  .check_hscroll.2:
287
	mov	ebx,eax
280 mikedld 288
	sub	ebx,SCRLW+1
289
	sub	ebx,[cur_editor.Bounds.Left]
178 heavyiron 290
	cmp	[hscrl_capt],0
291
	jge	.hcaptured
297 mikedld 292
	mov	eax,[cur_editor.HScroll.Top]
178 heavyiron 293
	cmp	ebx,eax
294
	jl	.center_hcapture
297 mikedld 295
	add	eax,[cur_editor.HScroll.Size]
178 heavyiron 296
	cmp	ebx,eax
297
	jge	.center_hcapture
298
	mov	eax,ebx
297 mikedld 299
	sub	eax,[cur_editor.HScroll.Top]
178 heavyiron 300
	dec	eax
301
	mov	[hscrl_capt],eax
302
	dec	ebx
303
	jmp	.hcaptured
304
  .center_hcapture:
297 mikedld 305
	mov	eax,[cur_editor.HScroll.Size]
178 heavyiron 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
297 mikedld 313
	mov	eax,[cur_editor.Bounds.Right]
314
	sub	eax,[cur_editor.HScroll.Size]
315
	sub	eax,SCRLW*3+1
178 heavyiron 316
	cmp	eax,ebx
317
	jge	@f
318
	mov	ebx,eax
319
    @@:
297 mikedld 320
	mov	[cur_editor.HScroll.Top],ebx
321
	mov	eax,[cur_editor.Columns.Count]
178 heavyiron 322
	sub	eax,[columns.scr]
323
	imul	ebx
297 mikedld 324
	mov	ebx,[cur_editor.Bounds.Right]
325
	sub	ebx,SCRLW*3+1
326
	sub	ebx,[cur_editor.HScroll.Size]
178 heavyiron 327
	idiv	ebx
297 mikedld 328
	cmp	eax,[cur_editor.TopLeft.X]
178 heavyiron 329
	je	still.skip_write
297 mikedld 330
	mov	[cur_editor.TopLeft.X],eax
178 heavyiron 331
	call	check_bottom_right
297 mikedld 332
	call	draw_editor
178 heavyiron 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
297 mikedld 363
;!!!        mov     [just_from_popup],0
178 heavyiron 364
	jmp	still.skip_write