Subversion Repositories Kolibri OS

Rev

Rev 297 | Rev 824 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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