Subversion Repositories Kolibri OS

Rev

Rev 5579 | 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
5838 pathoswith 15
	mov	ecx,[lines.scr]
16
	imul	ecx,[lineHeight]
178 heavyiron 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
178 heavyiron 25
	mcall	37,2
26
	and	al,3
27
	mov	bl,[ecx]
28
	cmp	[ecx],al
29
	mov	[ecx],al
30
	jne	@f
617 mikedld 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
178 heavyiron 38
	ret
617 mikedld 39
  .mv:	mov	eax,MEV_MOVE
40
	ret
178 heavyiron 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
 
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
 
178 heavyiron 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]
1480 mikedld 76
	jmp	still.skip_write
178 heavyiron 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
    @@:
297 mikedld 90
;!!!        cmp     [just_from_popup],0
91
;!!!        je      @f
92
;!!!        cmp     al,MEV_LUP
93
;!!!        jne     still.skip_write
178 heavyiron 94
    @@: mov	[mev],al
95
	jmp	[mouse_ev+eax*4-4]
96
 
617 mikedld 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
 
178 heavyiron 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
4665 gtament 143
 
144
	call draw_main_menu
178 heavyiron 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
259 mikedld 159
	mov	[mm.Edit+POPUP.pos],eax
178 heavyiron 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
259 mikedld 167
	mov	dword[POPUP_STACK],mm.Edit
178 heavyiron 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:
297 mikedld 184
	sub	eax,[cur_editor.Bounds.Left]
185
	sub	ebx,[cur_editor.Bounds.Top]
280 mikedld 186
	sub	eax,[cur_editor.Gutter.Width]
187
	sub	eax,LCHGW
188
	sub	ebx,2
178 heavyiron 189
	push	eax
190
	mov	eax,ebx
297 mikedld 191
	cdq
5838 pathoswith 192
	mov	ecx,[lineHeight]
178 heavyiron 193
	idiv	ecx
297 mikedld 194
    @@: add	eax,[cur_editor.TopLeft.Y]
178 heavyiron 195
	mov	ebx,eax
196
	pop	eax
297 mikedld 197
	cdq
5838 pathoswith 198
	mov	ecx,[charWidth]
178 heavyiron 199
	idiv	ecx
297 mikedld 200
    @@: add	eax,[cur_editor.TopLeft.X]
5579 Pathoswith 201
	mov	ecx, ebx
202
	call	get_line_offset
203
	cmp	eax,[esi]
178 heavyiron 204
	jl	@f
5579 Pathoswith 205
	mov	eax,[esi]
297 mikedld 206
    @@: cmp	ebx,[cur_editor.Lines.Count]
178 heavyiron 207
	jl	@f
297 mikedld 208
	mov	ebx,[cur_editor.Lines.Count]
178 heavyiron 209
	dec	ebx
210
    @@:
297 mikedld 211
	cmp	[cur_editor.Caret.X],eax
178 heavyiron 212
	jne	.change_cur_pos
297 mikedld 213
	cmp	[cur_editor.Caret.Y],ebx
214
	jne	.change_cur_pos
215
	call	editor_check_for_changes
216
	jmp	still.skip_write
178 heavyiron 217
 
218
  .change_cur_pos:
297 mikedld 219
	mov	[cur_editor.Caret.X],eax
220
	mov	[cur_editor.Caret.Y],ebx
221
	call	editor_check_for_changes
178 heavyiron 222
	jmp	still
223
 
224
  .check_vscroll:
280 mikedld 225
	mov	ecx,[cur_editor.Bounds.Right]
297 mikedld 226
	sub	ecx,SCRLW-1
227
	pushd	ecx [cur_editor.Bounds.Top] ecx [cur_editor.Bounds.Bottom]
178 heavyiron 228
	popd	[__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
297 mikedld 229
	add	[__rc+0x8],SCRLW-2
230
	add	[__rc+0x4],SCRLW-1
231
	sub	[__rc+0xC],SCRLW*2+1
178 heavyiron 232
	mov	ecx,__rc
233
	call	pt_in_rect
234
	jnc	.check_hscroll
235
 
236
  .check_vscroll.2:
297 mikedld 237
	sub	ebx,[cur_editor.Bounds.Top]
238
	sub	ebx,SCRLW
178 heavyiron 239
	cmp	[vscrl_capt],0
240
	jge	.vcaptured
297 mikedld 241
	mov	eax,[cur_editor.VScroll.Top]
178 heavyiron 242
	cmp	ebx,eax
243
	jb	.center_vcapture
297 mikedld 244
	add	eax,[cur_editor.VScroll.Size]
178 heavyiron 245
	cmp	ebx,eax
246
	jae	.center_vcapture
247
	mov	eax,ebx
297 mikedld 248
	sub	eax,[cur_editor.VScroll.Top]
178 heavyiron 249
	dec	eax
250
	mov	[vscrl_capt],eax
251
	dec	ebx
252
	jmp	.vcaptured
253
  .center_vcapture:
297 mikedld 254
	mov	eax,[cur_editor.VScroll.Size]
178 heavyiron 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
297 mikedld 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
178 heavyiron 266
	cmp	eax,ebx
267
	jge	@f
268
	mov	ebx,eax
269
    @@:
297 mikedld 270
	mov	[cur_editor.VScroll.Top],ebx
271
	mov	eax,[cur_editor.Lines.Count]
178 heavyiron 272
	sub	eax,[lines.scr]
273
	imul	ebx
297 mikedld 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]
178 heavyiron 278
	idiv	ebx
297 mikedld 279
	cmp	eax,[cur_editor.TopLeft.Y]
178 heavyiron 280
	je	still.skip_write
297 mikedld 281
	mov	[cur_editor.TopLeft.Y],eax
178 heavyiron 282
	call	check_bottom_right
297 mikedld 283
	call	draw_editor
178 heavyiron 284
	jmp	still.skip_write
285
 
286
  .check_hscroll:
297 mikedld 287
	pushd	[cur_editor.Bounds.Left] [cur_editor.Bounds.Bottom] [cur_editor.Bounds.Right] [cur_editor.Bounds.Bottom]
178 heavyiron 288
	popd	[__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
280 mikedld 289
	add	[__rc+0x8],-SCRLW*2-1
290
	add	[__rc+0x4],-SCRLW+1
291
	add	[__rc+0xC],-1
292
	add	[__rc+0x0],SCRLW+1
178 heavyiron 293
	mov	ecx,__rc
294
	call	pt_in_rect
295
	jnc	.check_main_menu
296
 
297
  .check_hscroll.2:
298
	mov	ebx,eax
280 mikedld 299
	sub	ebx,SCRLW+1
300
	sub	ebx,[cur_editor.Bounds.Left]
178 heavyiron 301
	cmp	[hscrl_capt],0
302
	jge	.hcaptured
297 mikedld 303
	mov	eax,[cur_editor.HScroll.Top]
178 heavyiron 304
	cmp	ebx,eax
305
	jl	.center_hcapture
297 mikedld 306
	add	eax,[cur_editor.HScroll.Size]
178 heavyiron 307
	cmp	ebx,eax
308
	jge	.center_hcapture
309
	mov	eax,ebx
297 mikedld 310
	sub	eax,[cur_editor.HScroll.Top]
178 heavyiron 311
	dec	eax
312
	mov	[hscrl_capt],eax
313
	dec	ebx
314
	jmp	.hcaptured
315
  .center_hcapture:
297 mikedld 316
	mov	eax,[cur_editor.HScroll.Size]
178 heavyiron 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
297 mikedld 324
	mov	eax,[cur_editor.Bounds.Right]
325
	sub	eax,[cur_editor.HScroll.Size]
326
	sub	eax,SCRLW*3+1
178 heavyiron 327
	cmp	eax,ebx
328
	jge	@f
329
	mov	ebx,eax
330
    @@:
297 mikedld 331
	mov	[cur_editor.HScroll.Top],ebx
332
	mov	eax,[cur_editor.Columns.Count]
178 heavyiron 333
	sub	eax,[columns.scr]
334
	imul	ebx
297 mikedld 335
	mov	ebx,[cur_editor.Bounds.Right]
336
	sub	ebx,SCRLW*3+1
337
	sub	ebx,[cur_editor.HScroll.Size]
178 heavyiron 338
	idiv	ebx
297 mikedld 339
	cmp	eax,[cur_editor.TopLeft.X]
178 heavyiron 340
	je	still.skip_write
297 mikedld 341
	mov	[cur_editor.TopLeft.X],eax
178 heavyiron 342
	call	check_bottom_right
297 mikedld 343
	call	draw_editor
178 heavyiron 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
297 mikedld 374
;!!!        mov     [just_from_popup],0
178 heavyiron 375
	jmp	still.skip_write