Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1037 mario79 1
;**************************************************************
2
; ScrollBar Macro for Kolibri OS
3
; Copyright (c) 2009, Mario79
4
; All rights reserved.
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
8
;     * Redistributions of source code must retain the above copyright
9
;       notice, this list of conditions and the following disclaimer.
10
;     * Redistributions in binary form must reproduce the above copyright
11
;       notice, this list of conditions and the following disclaimer in the
12
;       documentation and/or other materials provided with the distribution.
13
;     * Neither the name of the  nor the
14
;       names of its contributors may be used to endorse or promote products
15
;       derived from this software without specific prior written permission.
16
;
17
; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY
18
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
21
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
;*****************************************************************************
28
macro scroll_bar_exit
29
{
30
popa
31
ret 4
32
}
33
;*****************************************************************************
34
macro draw_up_arrow_vertical
35
{
36
	push  ebx
37
 
38
	xor   eax,eax
39
	mov   ax,sb_size_x
40
	shr   eax,1
41
	shl   eax,16
42
	add   ebx,eax
43
 
44
	xor   eax,eax
45
	mov   ax,sb_btn_high
46
	shr   eax,1
47
	shl   eax,16
48
	add   ecx,eax
49
 
50
	mov   edx,sb_line_col
51
	sub   ebx,4 shl 16
52
	mov   bx,7
53
	mov   cx,1
54
	mov   eax,13
55
	int   0x40
56
	sub   ecx,1 shl 16
57
	add   ebx,1 shl 16
58
	mov   bx,5
59
	int   0x40
60
	sub   ecx,1 shl 16
61
	add   ebx,1 shl 16
62
	mov   bx,3
63
	int   0x40
64
	sub   ecx,1 shl 16
65
	add   ebx,1 shl 16
66
	mov   bx,1
67
	int   0x40
68
	pop   ebx
69
}
70
;*****************************************************************************
71
macro draw_down_arrow_vertical
72
{
73
	push  ebx
74
 
75
	xor   eax,eax
76
	mov   ax,sb_size_x
77
	shr   eax,1
78
	shl   eax,16
79
	add   ebx,eax
80
 
81
	xor   eax,eax
82
	mov   ax,sb_btn_high
83
	shr   eax,1
84
	shl   eax,16
85
	add   ecx,eax
86
 
87
	mov   edx,sb_line_col
88
	sub   ebx,4 shl 16
89
	mov   bx,7
90
    sub   ecx,2 shl 16
91
	mov   cx,1
92
	mov   eax,13
93
	int   0x40
94
	add   ecx,1 shl 16
95
	add   ebx,1 shl 16
96
	mov   bx,5
97
	int   0x40
98
	add   ecx,1 shl 16
99
	add   ebx,1 shl 16
100
	mov   bx,3
101
	int   0x40
102
	add   ecx,1 shl 16
103
	add   ebx,1 shl 16
104
	mov   bx,1
105
	int   0x40
106
	pop   ebx
107
}
108
;*****************************************************************************
109
macro draw_runner_center_vertical
110
{
111
	push  ebx
112
	push  ecx
113
 
114
	xor   eax,eax
115
	mov   ax,sb_size_x
116
	shr   eax,1
117
	shl   eax,16
118
	add   ebx,eax
119
 
120
	mov   edx,sb_run_size
121
	shr   edx,1
122
	shl   edx,16
123
	add   ecx,edx
124
	mov   edx,sb_line_col
125
	sub   ecx,8 shl 16
126
    sub   ebx,5 shl 16
127
	mov   bx,10
128
	add   ecx,4 shl 16
129
	mov   cx,1
130
	mov   eax,13
131
	int   0x40
132
	add   ecx,3 shl 16
133
	sub   ebx,1 shl 16
134
	mov   bx,12
135
	int   0x40
136
	add   ebx,1 shl 16
137
	mov   bx,10
138
	add   ecx,3 shl 16
139
	int   0x40
140
	pop   ecx
141
	pop   ebx
142
}
143
;*****************************************************************************
144
macro draw_up_arrow_horizontal
145
{
146
	push  ecx
147
 
148
	xor   eax,eax
149
	mov   ax,sb_btn_high
150
	shr   eax,1
151
	shl   eax,16
152
	add   ebx,eax
153
 
154
	xor   eax,eax
155
	mov   ax,sb_size_y
156
	shr   eax,1
157
	shl   eax,16
158
	add   ecx,eax
159
 
160
	mov   edx,sb_line_col
161
	sub   ecx,4 shl 16
162
	mov   cx,7
163
	mov   bx,1
164
 
165
	mov   eax,13
166
	int   0x40
167
	sub   ebx,1 shl 16
168
	add   ecx,1 shl 16
169
	mov   cx,5
170
	int   0x40
171
	sub   ebx,1 shl 16
172
	add   ecx,1 shl 16
173
	mov   cx,3
174
	int   0x40
175
	sub   ebx,1 shl 16
176
	add   ecx,1 shl 16
177
	mov   cx,1
178
	int   0x40
179
	pop   ecx
180
}
181
;*****************************************************************************
182
macro draw_down_arrow_horizontal
183
{
184
	push  ecx
185
 
186
	xor   eax,eax
187
	mov   ax,sb_btn_high
188
	shr   eax,1
189
	shl   eax,16
190
	add   ebx,eax
191
 
192
	xor   eax,eax
193
	mov   ax,sb_size_y
194
	shr   eax,1
195
	shl   eax,16
196
	add   ecx,eax
197
 
198
	mov   edx,sb_line_col
199
	sub   ecx,4 shl 16
200
	mov   cx,7
201
	sub   ebx,2 shl 16
202
	mov   bx,1
203
	mov   eax,13
204
	int   0x40
205
	add   ebx,1 shl 16
206
	add   ecx,1 shl 16
207
	mov   cx,5
208
	int   0x40
209
	add   ebx,1 shl 16
210
	add   ecx,1 shl 16
211
	mov   cx,3
212
	int   0x40
213
	add   ecx,1 shl 16
214
	add   ebx,1 shl 16
215
	mov   cx,1
216
	int   0x40
217
	pop   ecx
218
}
219
;*****************************************************************************
220
macro draw_runner_center_horizontal
221
{
222
	push  ebx
223
	push  ecx
224
 
225
	xor   eax,eax
226
	mov   ax,sb_size_y
227
	shr   eax,1
228
	shl   eax,16
229
	add   ecx,eax
230
 
231
	mov   edx,sb_run_size
232
	shr   edx,1
233
	shl   edx,16
234
	add   ebx,edx
235
	mov   edx,sb_line_col
236
	sub   ebx,8 shl 16
237
	sub   ecx,5 shl 16
238
	mov   cx,10
239
	add   ebx,4 shl 16
240
	mov   bx,1
241
	mov   eax,13
242
	int   0x40
243
	add   ebx,3 shl 16
244
	sub   ecx,1 shl 16
245
	mov   cx,12
246
	int   0x40
247
	add   ecx,1 shl 16
248
	mov   cx,10
249
	add   ebx,3 shl 16
250
	int   0x40
251
	pop   ecx
252
	pop   ebx
253
}
254
;*****************************************************************************
255
macro use_scroll_bar
256
{
257
scroll_bar:
258
sb_size_x	equ [edi]
259
sb_start_x	equ [edi+2]
260
sb_size_y	equ [edi+4]
261
sb_start_y	equ [edi+6]
262
sb_btn_high    equ [edi+8]
263
sb_type	  equ [edi+12]
264
sb_max_area    equ [edi+16]
265
sb_cur_area    equ [edi+20]
266
sb_position    equ [edi+24]
267
sb_bckg_col    equ [edi+28]
268
sb_frnt_col    equ [edi+32]
269
sb_line_col    equ [edi+36]
270
sb_redraw	equ [edi+40]
271
sb_delta	 equ [edi+44]
272
sb_delta2	equ [edi+46]
273
sb_r_size_x    equ [edi+48]
274
sb_r_start_x   equ [edi+50]
275
sb_r_size_y    equ [edi+52]
276
sb_r_start_y   equ [edi+54]
277
sb_m_pos	 equ [edi+56]
278
sb_m_pos_2	equ [edi+60]
279
sb_m_keys	equ [edi+64]
280
sb_run_size    equ [edi+68]
281
sb_position2   equ [edi+72]
282
sb_work_size   equ [edi+76]
283
sb_all_redraw  equ [edi+80]
284
}
285
;*****************************************************************************
286
;*****************************************************************************
287
; draw event
288
;*****************************************************************************
289
;*****************************************************************************
290
macro use_scroll_bar_vertical
291
{
292
scroll_bar_vertical:
293
.draw:
294
	pusha
295
	mov   edi,dword [esp+36]
296
	mov   sb_all_redraw,dword 1
297
	call  .draw_1
298
	mov   sb_all_redraw,dword 0
299
scroll_bar_exit
300
.draw_1:
301
	pusha
302
;*********************************
303
	xor   eax,eax
304
	mov   ax,sb_size_y
305
	mov   edx,sb_btn_high
306
	shl   edx,1
307
	sub   eax,edx
308
	mov   sb_work_size,eax
309
;*********************************
310
	mov   eax,sb_work_size   ;sb_max_area
311
	mov   ebx,sb_max_area
312
	cmp   ebx,sb_cur_area
313
	ja    @f
314
 
315
	jmp   .no_size
316
 
317
@@:
318
	imul  eax,sb_cur_area
319
	xor   edx,edx
320
	div   ebx
321
	cmp   eax,10
322
	jae   @f
323
	mov   eax,10
324
@@:
325
.no_size:
326
	mov   sb_run_size,eax
327
;*********************************
328
	cmp   sb_delta,word 1
329
	je    .@@_3
330
	mov   eax,sb_work_size
331
	sub   eax,sb_run_size
332
	mov   ebx,sb_max_area
333
	cmp   ebx,sb_cur_area
334
	ja    @f
335
	xor   eax,eax
336
	jmp   .@@_1
337
@@:
338
	sub   ebx,sb_cur_area
339
	imul  eax,sb_position
340
	xor   edx,edx
341
	div   ebx
342
.@@_1:
343
	mov   sb_position2,eax
344
	xor   edx,edx
345
	mov   dx,sb_size_y
346
	sub   edx,sb_btn_high
347
	sub   edx,sb_btn_high
348
	sub   edx,sb_run_size
349
	cmp   sb_position2,edx
350
	jbe   .@@_3
351
	mov   sb_position2,edx
352
.@@_3:
353
;*********************************
354
	mov   ebx,sb_start_x
355
	shl   ebx,16
356
	inc   ebx
357
	mov   ecx,sb_size_y
358
	mov   edx,sb_line_col
359
	mov   eax,13
360
	cmp  sb_all_redraw,dword 0
361
	je   @f
362
	int   0x40   ; left extreme line
363
@@:
364
	push  ebx
365
	ror   ebx,16
366
	add   bx,sb_size_x
367
	rol   ebx,16
368
	cmp  sb_all_redraw,dword 0
369
	je   @f
370
	int   0x40   ; right extreme line
371
@@:
372
	pop   ebx
373
 
374
	push  ecx
375
 
376
	add   ebx,1 shl 16
377
	mov   bx,sb_size_x
378
	dec   ebx
379
	mov   cx,1
380
	cmp  sb_all_redraw,dword 0
381
	je   @f
382
	int   0x40   ; top button - extreme line
383
@@:
384
	push  ecx
385
	add   ecx,1 shl 16
386
	add   ecx,sb_btn_high
387
	sub   ecx,2
388
	mov   edx,sb_frnt_col
389
	cmp  sb_all_redraw,dword 0
390
	je   @f
391
	int   0x40   ; top button filling
392
;*********************************
393
draw_up_arrow_vertical
394
;*********************************
395
@@:
396
	pop   ecx
397
 
398
	ror   ecx,16
399
	add   ecx,sb_btn_high  ;14 shl 16
400
	rol   ecx,16
401
	mov   edx,sb_line_col
402
	cmp  sb_all_redraw,dword 0
403
	je   @f
404
	int   0x40   ;  top button - bottom line
405
@@:
406
	pop   ecx
407
;*********************************
408
	ror   ecx,16
409
	add   ecx,sb_btn_high  ;15 shl 16
410
	inc   ecx
411
	rol   ecx,16
412
	sub   ecx,sb_btn_high  ;30
413
	sub   ecx,sb_btn_high
414
	push  ecx
415
	mov   cx,0
416
	add   ecx,sb_position2
417
	dec   cx
418
	mov   eax,13
419
	test  cx,0x8000
420
	jnz   @f
421
	mov   edx,sb_bckg_col
422
	int   0x40    ; top interval
423
@@:
424
;*********************************
425
	shr   ecx,16
426
	add   ecx,sb_position2
427
	dec   ecx
428
	shl   ecx,16
429
	inc   ecx
430
	mov   edx,sb_line_col
431
	int   0x40    ; runner - top extreme line
432
 
433
	add   ecx,1 shl 16
434
	mov   cx,0
435
	add   ecx,sb_run_size
436
	mov   sb_r_size_x,ebx
437
	mov   sb_r_size_y,ecx
438
	sub   ecx,2
439
	mov   edx,sb_frnt_col
440
	int   0x40   ; runner filling
441
;*********************************
442
draw_runner_center_vertical
443
;*********************************
444
	shr   ecx,16
445
	add   ecx,sb_run_size
446
	sub   ecx,2
447
	shl   ecx,16
448
	inc   ecx
449
	mov   edx,sb_line_col
450
	int   0x40   ; runner - bottom extreme line
451
 
452
	add   ecx,1 shl 16
453
	mov   cx,sb_start_y
454
	add   cx,sb_size_y
455
	sub   ecx,sb_btn_high
456
	dec   ecx
457
	mov   eax,ecx
458
	shr   eax,16
459
	sub   cx,ax
460
	test  cx,0x8000
461
	jnz	  @f
462
	mov   edx,sb_bckg_col
463
	mov   eax,13
464
	int   0x40   ; bottom interval
465
@@:
466
	pop   ecx
467
;*********************************
468
	mov   ax,cx
469
	shr   ecx,16
470
	add   cx,ax
471
	sub   ecx,2
472
	shl   ecx,16
473
	inc   ecx
474
	mov   edx,sb_line_col
475
	mov   eax,13
476
	cmp  sb_all_redraw,dword 0
477
	je   @f
478
	int   0x40   ; bottom button - top line
479
@@:
480
	push  ecx
481
	add   ecx,1 shl 16
482
	add   cx,sb_btn_high
483
	sub   ecx,2
484
	mov   edx,sb_frnt_col
485
	cmp  sb_all_redraw,dword 0
486
	je   @f
487
	int   0x40   ; bottom button filling
488
;*********************************
489
draw_down_arrow_vertical
490
;*********************************
491
@@:
492
	pop   ecx
493
 
494
	ror   ecx,16
495
	add   ecx,sb_btn_high  ;14 shl 16
496
	rol   ecx,16
497
 
498
	mov   edx,sb_line_col
499
	mov   cx,1
500
	cmp  sb_all_redraw,dword 0
501
	je   @f
502
	int   0x40   ; bottom button - extreme line
503
@@:
504
	popa
505
	ret
506
;*****************************************************************************
507
;*****************************************************************************
508
; mouse event
509
;*****************************************************************************
510
;*****************************************************************************
511
.mouse:
512
	pusha
513
	mov     edi,dword [esp+36]
514
	mcall 37,1
515
	mov   sb_m_pos,eax
516
	cmp   sb_m_pos_2,dword 0
517
	jne   @f
518
 
519
	mov   sb_m_pos_2,eax
520
@@:
521
	mcall 37,2
522
	mov   sb_m_keys,eax
523
 
524
	cmp   sb_m_keys,eax
525
	je	  @f
526
 
527
	mov   sb_m_keys,eax
528
 
529
	mov   sb_delta,dword 0
530
 
531
	mov   eax,sb_m_pos
532
	mov   sb_m_pos_2,eax
533
	jmp   .continue_2
534
 
535
@@:
536
	cmp   sb_m_keys,dword 0
537
	jne	 @f   ;.continue_2
538
	mov   eax,sb_m_pos
539
	mov   sb_m_pos_2,eax
540
	jmp   .correct_1    ;.exit_sb
541
@@:
542
	mov   sb_delta,word 1
543
 
544
.continue_2:
545
	mov   eax,sb_m_pos
546
	test  eax,0x80000000
547
	jnz   .exit_sb
548
 
549
	test  eax,0x8000
550
	jnz   .exit_sb
551
 
552
	mov   ebx,eax
553
	shr   ebx,16   ; x position
554
	shl   eax,16
555
	shr   eax,16   ; y position
556
 
557
	mov   cx,sb_start_y
558
	cmp   ax,cx
559
	jb    .exit_sb
560
 
561
	cmp   sb_delta2,word 0
562
	je    @f
563
	push  ecx
564
	add   cx,sb_btn_high
565
	cmp   ax,cx
566
	pop   ecx
567
	jb    .exit_sb
568
 
569
@@:
570
	add   cx,sb_size_y
571
	cmp   ax,cx
572
	ja    .exit_sb
573
 
574
	cmp   sb_delta2,word 0
575
	je    @f
576
	sub   cx,sb_btn_high
577
	cmp   ax,cx
578
	ja    .exit_sb
579
 
580
@@:
581
	cmp   sb_delta2,word 1
582
	je    @f
583
 
584
	cmp   sb_m_keys,dword 0
585
	je    .exit_sb
586
 
587
	mov   cx,sb_start_x
588
	cmp   bx,cx
589
	jb    .exit_sb
590
 
591
	add   cx,sb_size_x
592
	cmp   bx,cx
593
	ja    .exit_sb
594
 
595
	mov   cx,sb_r_start_y
596
	cmp   ax,cx
597
	jb    .no_runner
598
 
599
	add   cx,sb_r_size_y
600
	cmp   ax,cx
601
	ja    .no_runner
602
 
603
	mov   sb_delta2,word 1
604
@@:
605
	push  eax
606
	mov   ax,sb_m_pos
607
	cmp   ax,sb_m_pos_2
608
	je    .correct  ;.exit_sb
609
 
610
	shl   eax,16
611
	shr   eax,16
612
	mov   ebx,sb_m_pos_2
613
	shl   ebx,16
614
	shr   ebx,16
615
	cmp   eax,ebx
616
	jb   .sub
617
 
618
	sub   eax,ebx
619
	mov   ebx,eax
620
	add   sb_position2,ebx
621
	xor   eax,eax
622
	mov   ax,sb_size_y
623
	sub   eax,sb_btn_high
624
	sub   eax,sb_btn_high
625
	sub   eax,sb_run_size
626
	cmp   sb_position2,eax
627
	jbe   @f
628
 
629
	mov   sb_position2,eax
630
@@:
631
	mov   eax,sb_m_pos
632
	mov   sb_m_pos_2,eax
633
	pop   eax
634
	call  .draw_1
635
	jmp   .no_runner_1
636
 
637
.correct:
638
	pop   eax
639
	jmp   .exit_sb
640
.correct_1:
641
	mov   sb_delta,dword 0
642
	jmp   .exit_sb
643
 
644
.sub:
645
	sub   ebx,eax
646
	sub   sb_position2,ebx
647
	test  sb_position2,dword 0x80000000
648
	jz	  @f
649
 
650
	mov   sb_position2,dword 0
651
@@:
652
	mov   eax,sb_m_pos
653
	mov   sb_m_pos_2,eax
654
	pop   eax
655
	call  .draw_1
656
	jmp   .no_runner_1
657
 
658
;*****************************************************************************
659
.no_runner:
660
	mov   sb_delta,dword 0
661
.no_runner_1:
662
	xor   ecx,ecx
663
	mov   cx,sb_start_y
664
	add   cx,sb_btn_high   ;15
665
	cmp   sb_delta,word 1
666
	je    .scroll_sb
667
 
668
	cmp   ax,cx
669
	ja    .scroll_sb
670
 
671
	cmp   sb_m_keys,dword 0
672
	je   .exit_sb
673
 
674
	cmp   sb_position,dword 0
675
;	je    .exit_sb
676
	je   @f
677
 
678
	dec   dword sb_position
679
	jmp   .all_sb
680
@@:
681
	mov   sb_position2,dword 0
682
	jmp   .all_sb
683
;*****************************************************************************
684
.scroll_sb:
685
	add   cx,sb_size_y
686
	sub   cx,sb_btn_high
687
	sub   cx,sb_btn_high
688
	cmp   sb_delta,word 1
689
	je    @f
690
 
691
	cmp   ax,cx
692
	ja    .down_sb
693
 
694
@@:
695
	mov   ebx,sb_btn_high   ;16  ;15
696
;	inc   ebx
697
	add   bx,sb_start_y
698
	sub   cx,bx
699
	sub   ax,bx
700
 
701
.scroll_sb_1:
702
	mov   ebx,sb_run_size
703
;*****************************************************************************
704
	cmp   sb_delta,word 1
705
	je    .continue
706
 
707
@@:
708
	mov   edx,eax
709
;	sub   edx,sb_btn_high
710
	push  ebx
711
	shr   ebx,1
712
	sub   edx,ebx
713
	pop   ebx
714
	mov   sb_position2,edx
715
	test  sb_position2,dword 0x80000000
716
	jz	 .test_1
717
 
718
	mov   sb_position2,dword 0
719
	jmp   .continue
720
 
721
.test_1:
722
	xor   edx,edx
723
	mov   dx,sb_size_y
724
	sub   edx,sb_btn_high
725
	sub   edx,sb_btn_high
726
	sub   edx,sb_run_size
727
	cmp   sb_position2,edx
728
	jbe   .continue
729
 
730
	mov   sb_position2,edx
731
;	jmp   .continue_1
732
 
733
.continue:
734
	mov   eax,sb_position2
735
	sub   ecx,ebx
736
.continue_1:
737
;*****************************************************************************
738
	mov   ebx,eax
739
 
740
	mov   eax,sb_max_area
741
	cmp   eax,sb_cur_area
742
	ja    @f
743
 
744
	xor   eax,eax
745
	inc   eax
746
	mov   sb_position2,eax
747
	jmp   .all_sb   ;.store_position
748
@@:
749
	sub   eax,sb_cur_area
750
	inc   eax
751
	shl   eax,10
752
	xor   edx,edx
753
	div   ecx
754
	shl   edx,1
755
	cmp   edx,ecx
756
	jb    @f
757
 
758
	inc   eax
759
 
760
@@:
761
	imul  eax,ebx
762
	shr   eax,10
763
 
764
	cmp   sb_position,eax
765
	je    .exit_sb
766
 
767
	cmp   eax,0
768
	ja    @f
769
 
770
	xor   eax,eax
771
 
772
@@:
773
.store_position:
774
	mov   sb_position,eax
775
.all_sb:
776
	mov   sb_redraw,dword 1
777
	call  .draw_1
778
	mov   eax,sb_m_pos
779
	mov   sb_m_pos_2,eax
780
	jmp   .exit_sb
781
;*****************************************************************************
782
.down_sb:
783
	cmp   sb_m_keys,dword 0
784
	je   .exit_sb
785
 
786
	mov   eax,sb_max_area
787
	sub   eax,sb_cur_area
788
	cmp   sb_position,eax
789
;	jae   .exit_sb
790
	jae   @f
791
 
792
	inc   dword sb_position
793
	jmp   .all_sb
794
@@:
795
	xor   eax,eax
796
	mov   ax,sb_size_y
797
	sub   eax,sb_btn_high
798
	sub   eax,sb_btn_high
799
	sub   eax,sb_run_size
800
	mov   sb_position2,eax
801
	jmp   .all_sb
802
.exit_sb:
803
scroll_bar_exit
804
}
805
 
806
;*****************************************************************************
807
;*****************************************************************************
808
;*****************************************************************************
809
;*****************************************************************************
810
;*****************************************************************************
811
macro use_scroll_bar_horizontal
812
{
813
scroll_bar_horizontal:
814
.draw:
815
	pusha
816
	mov   edi,dword [esp+36]
817
	mov   sb_all_redraw,dword 1
818
	call  .draw_1
819
	mov   sb_all_redraw,dword 0
820
scroll_bar_exit
821
.draw_1:
822
	pusha
823
;*********************************
824
	xor   eax,eax
825
	mov   ax,sb_size_x	;sb_size_y
826
	mov   edx,sb_btn_high
827
	shl   edx,1
828
	sub   eax,edx
829
	mov   sb_work_size,eax
830
;*********************************
831
	mov   eax,sb_work_size   ;sb_max_area
832
	mov   ebx,sb_max_area
833
	cmp   ebx,sb_cur_area
834
	ja    @f
835
 
836
	jmp   .no_size
837
 
838
@@:
839
	imul  eax,sb_cur_area
840
	xor   edx,edx
841
	div   ebx
842
	cmp   eax,10
843
	jae   @f
844
	mov   eax,10
845
@@:
846
.no_size:
847
	mov   sb_run_size,eax
848
;*********************************
849
	cmp   sb_delta,word 1
850
	je    .@@_3
851
	mov   eax,sb_work_size
852
	sub   eax,sb_run_size
853
	mov   ebx,sb_max_area
854
	cmp   ebx,sb_cur_area
855
	ja    @f
856
	xor   eax,eax
857
	jmp   .@@_1
858
@@:
859
	sub   ebx,sb_cur_area
860
	imul  eax,sb_position
861
	xor   edx,edx
862
	div   ebx
863
.@@_1:
864
	mov   sb_position2,eax
865
	xor   edx,edx
866
	mov   dx,sb_size_x
867
	sub   edx,sb_btn_high
868
	sub   edx,sb_btn_high
869
	sub   edx,sb_run_size
870
	cmp   sb_position2,edx
871
	jbe   .@@_3
872
	mov   sb_position2,edx
873
.@@_3:
874
;*********************************
875
	mov   ebx,sb_size_x
876
	mov   ecx,sb_start_y
877
	shl   ecx,16
878
	inc   ecx
879
	mov   edx,sb_line_col
880
	mov   eax,13
881
	cmp  sb_all_redraw,dword 0
882
	je   @f
883
	int   0x40   ; top extreme line
884
@@:
885
	push  ecx
886
	ror   ecx,16
887
	add   cx,sb_size_y
888
	rol   ecx,16
889
	cmp  sb_all_redraw,dword 0
890
	je   @f
891
	int   0x40   ; bottom extreme line
892
@@:
893
	pop   ecx
894
 
895
	push  ebx
896
 
897
	add   ecx,1 shl 16
898
	mov   cx,sb_size_y
899
	dec   ecx
900
	mov   bx,1
901
	cmp  sb_all_redraw,dword 0
902
	je   @f
903
	int   0x40   ; left button - extreme line
904
@@:
905
	push  ebx
906
	add   ebx,1 shl 16
907
	add   ebx,sb_btn_high
908
	sub   ebx,2
909
	mov   edx,sb_frnt_col
910
	cmp  sb_all_redraw,dword 0
911
	je   @f
912
	int   0x40   ; left  button filling
913
;*********************************
914
draw_up_arrow_horizontal
915
;*********************************
916
@@:
917
	pop   ebx
918
 
919
	ror   ebx,16
920
	add   ebx,sb_btn_high  ;14 shl 16
921
	rol   ebx,16
922
	mov   edx,sb_line_col
923
	cmp  sb_all_redraw,dword 0
924
	je   @f
925
	int   0x40   ;  left  button - right line
926
@@:
927
	pop   ebx
928
;*********************************
929
	ror   ebx,16
930
	add   ebx,sb_btn_high  ;15 shl 16
931
	  inc   ebx
932
	rol   ebx,16
933
	sub   ebx,sb_btn_high  ;30
934
	sub   ebx,sb_btn_high
935
	push  ebx
936
	mov   bx,0
937
	add   ebx,sb_position2
938
	  dec   bx
939
	mov   eax,13
940
	test  bx,0x8000
941
	jnz   @f
942
	mov   edx,sb_bckg_col
943
	int   0x40    ; left interval
944
@@:
945
;*********************************
946
	shr   ebx,16
947
	add   ebx,sb_position2
948
	dec   ebx
949
	shl   ebx,16
950
	inc   ebx
951
	mov   edx,sb_line_col
952
	int   0x40    ; runner - left extreme line
953
 
954
	add   ebx,1 shl 16
955
	mov   bx,0
956
	add   ebx,sb_run_size
957
	mov   sb_r_size_x,ebx
958
	mov   sb_r_size_y,ecx
959
	sub   ebx,2
960
	mov   edx,sb_frnt_col
961
	int   0x40   ; runner filling
962
;*********************************
963
draw_runner_center_horizontal
964
;*********************************
965
	shr   ebx,16
966
	add   ebx,sb_run_size
967
	sub   ebx,2
968
	shl   ebx,16
969
	inc   ebx
970
	mov   edx,sb_line_col
971
	int   0x40   ; runner - bottom extreme line
972
 
973
	add   ebx,1 shl 16
974
	mov   bx,sb_start_x
975
	add   bx,sb_size_x
976
	sub   ebx,sb_btn_high
977
	dec   ebx
978
	mov   eax,ebx
979
	shr   eax,16
980
	sub   bx,ax
981
	test  bx,0x8000
982
	jnz   @f
983
	mov   edx,sb_bckg_col
984
	mov   eax,13
985
	int   0x40   ; bottom interval
986
@@:
987
	pop   ebx
988
;*********************************
989
	mov   ax,bx
990
	shr   ebx,16
991
	add   bx,ax
992
	sub   ebx,2
993
	shl   ebx,16
994
	inc   ebx
995
	mov   edx,sb_line_col
996
	mov   eax,13
997
	cmp  sb_all_redraw,dword 0
998
	je   @f
999
	int   0x40    ; bottom button - top line
1000
@@:
1001
	push  ebx
1002
	add   ebx,1 shl 16
1003
	add   bx,sb_btn_high
1004
	sub   ebx,2
1005
	mov   edx,sb_frnt_col
1006
	cmp  sb_all_redraw,dword 0
1007
	je   @f
1008
	int   0x40   ; bottom button filling
1009
;*********************************
1010
draw_down_arrow_horizontal
1011
;*********************************
1012
@@:
1013
	pop   ebx
1014
 
1015
	ror   ebx,16
1016
	add   ebx,sb_btn_high  ;14 shl 16
1017
	rol   ebx,16
1018
 
1019
	mov   edx,sb_line_col
1020
	mov   bx,1
1021
	cmp  sb_all_redraw,dword 0
1022
	je   @f
1023
	int   0x40   ; bottom button - extreme line
1024
@@:
1025
	popa
1026
	ret
1027
;*****************************************************************************
1028
; mouse event
1029
;*****************************************************************************
1030
.mouse:
1031
	pusha
1032
	mov     edi,dword [esp+36]
1033
	mcall 37,1
1034
	mov   sb_m_pos,eax
1035
	cmp   sb_m_pos_2,dword 0
1036
	jne   @f
1037
 
1038
	mov   sb_m_pos_2,eax
1039
@@:
1040
	mcall 37,2
1041
	mov   sb_m_keys,eax
1042
 
1043
	cmp   sb_m_keys,eax
1044
	je	  @f
1045
 
1046
	mov   sb_m_keys,eax
1047
 
1048
	mov   sb_delta,dword 0
1049
 
1050
	mov   eax,sb_m_pos
1051
	mov   sb_m_pos_2,eax
1052
	jmp   .continue_2
1053
 
1054
@@:
1055
	cmp   sb_m_keys,dword 0
1056
	jne	 @f   ;.continue_2
1057
	mov   eax,sb_m_pos
1058
	mov   sb_m_pos_2,eax
1059
	jmp   .correct_1    ;.exit_sb
1060
@@:
1061
	mov   sb_delta,word 1
1062
 
1063
.continue_2:
1064
	mov   eax,sb_m_pos
1065
	test  eax,0x80000000
1066
	jnz   .exit_sb
1067
 
1068
	test  eax,0x8000
1069
	jnz   .exit_sb
1070
 
1071
	mov   ebx,eax
1072
	shr   eax,16   ; x position
1073
	shl   ebx,16
1074
	shr   ebx,16   ; y position
1075
 
1076
	mov   cx,sb_start_x   ;y
1077
	cmp   ax,cx
1078
	jb    .exit_sb
1079
 
1080
	cmp   sb_delta2,word 0
1081
	je    @f
1082
	push  ecx
1083
	add   cx,sb_btn_high
1084
	cmp   ax,cx
1085
	pop   ecx
1086
	jb    .exit_sb
1087
 
1088
@@:
1089
	add   cx,sb_size_x    ;y
1090
	cmp   ax,cx
1091
	ja    .exit_sb
1092
 
1093
	cmp   sb_delta2,word 0
1094
	je    @f
1095
	sub   cx,sb_btn_high
1096
	cmp   ax,cx
1097
	ja    .exit_sb
1098
 
1099
@@:
1100
	cmp   sb_delta2,word 1
1101
	je    @f
1102
 
1103
	cmp   sb_m_keys,dword 0
1104
	je    .exit_sb
1105
 
1106
	mov   cx,sb_start_y   ;x
1107
	cmp   bx,cx
1108
	jb    .exit_sb
1109
 
1110
	add   cx,sb_size_y    ;x
1111
	cmp   bx,cx
1112
	ja    .exit_sb
1113
 
1114
	mov   cx,sb_r_start_x
1115
	cmp   ax,cx
1116
	jb    .no_runner
1117
 
1118
	add   cx,sb_r_size_x
1119
	cmp   ax,cx
1120
	ja    .no_runner
1121
 
1122
	mov   sb_delta2,word 1
1123
@@:
1124
	push  eax
1125
	mov   eax,sb_m_pos
1126
	mov   ebx,sb_m_pos_2
1127
	shr   eax,16
1128
	shr   ebx,16
1129
	cmp   eax,ebx
1130
	je    .correct  ;.exit_sb
1131
 
1132
;	shl   eax,16
1133
;	shr   eax,16
1134
;	mov   ebx,sb_m_pos_2
1135
;	shl   ebx,16
1136
;	shr   ebx,16
1137
;	cmp   eax,ebx
1138
	jb   .sub
1139
 
1140
	sub   eax,ebx
1141
	mov   ebx,eax
1142
	add   sb_position2,ebx
1143
	xor   eax,eax
1144
	mov   ax,sb_size_x    ;y
1145
	sub   eax,sb_btn_high
1146
	sub   eax,sb_btn_high
1147
	sub   eax,sb_run_size
1148
	cmp   sb_position2,eax
1149
	jbe   @f
1150
 
1151
	mov   sb_position2,eax
1152
@@:
1153
	mov   eax,sb_m_pos
1154
	mov   sb_m_pos_2,eax
1155
	pop   eax
1156
	call  .draw_1
1157
	jmp   .no_runner_1
1158
 
1159
.correct:
1160
	pop   eax
1161
	jmp   .exit_sb
1162
.correct_1:
1163
	mov   sb_delta,dword 0
1164
	jmp   .exit_sb
1165
 
1166
.sub:
1167
	sub   ebx,eax
1168
	sub   sb_position2,ebx
1169
	test  sb_position2,dword 0x80000000
1170
	jz	  @f
1171
 
1172
	mov   sb_position2,dword 0
1173
@@:
1174
	mov   eax,sb_m_pos
1175
	mov   sb_m_pos_2,eax
1176
	pop   eax
1177
	call  .draw_1
1178
	jmp   .no_runner_1
1179
 
1180
;*****************************************************************************
1181
.no_runner:
1182
	mov   sb_delta,dword 0
1183
.no_runner_1:
1184
	xor   ecx,ecx
1185
	mov   cx,sb_start_x   ;y
1186
	add   cx,sb_btn_high   ;15
1187
	cmp   sb_delta,word 1
1188
	je    .scroll_sb
1189
 
1190
	cmp   ax,cx
1191
	ja    .scroll_sb
1192
 
1193
	cmp   sb_m_keys,dword 0
1194
	je   .exit_sb
1195
 
1196
	cmp   sb_position,dword 0
1197
;	je    .exit_sb
1198
	je   @f
1199
 
1200
	dec   dword sb_position
1201
	jmp   .all_sb
1202
@@:
1203
	mov   sb_position2,dword 0
1204
	jmp   .all_sb
1205
;*****************************************************************************
1206
.scroll_sb:
1207
	add   cx,sb_size_x	;y
1208
	sub   cx,sb_btn_high
1209
	sub   cx,sb_btn_high
1210
	cmp   sb_delta,word 1
1211
	je    @f
1212
 
1213
	cmp   ax,cx
1214
	ja    .down_sb
1215
 
1216
@@:
1217
	mov   ebx,sb_btn_high   ;16  ;15
1218
;	inc   ebx
1219
	add   bx,sb_start_x	;y
1220
	sub   cx,bx
1221
	sub   ax,bx
1222
 
1223
.scroll_sb_1:
1224
	mov   ebx,sb_run_size
1225
;*****************************************************************************
1226
	cmp   sb_delta,word 1
1227
	je    .continue
1228
 
1229
@@:
1230
	mov   edx,eax
1231
;	sub   edx,sb_btn_high
1232
	push  ebx
1233
	shr   ebx,1
1234
	sub   edx,ebx
1235
	pop   ebx
1236
	mov   sb_position2,edx
1237
	test  sb_position2,dword 0x80000000
1238
	jz	 .test_1
1239
 
1240
	mov   sb_position2,dword 0
1241
	jmp   .continue
1242
 
1243
.test_1:
1244
	xor   edx,edx
1245
	mov   dx,sb_size_x	 ;y
1246
	sub   edx,sb_btn_high
1247
	sub   edx,sb_btn_high
1248
	sub   edx,sb_run_size
1249
	cmp   sb_position2,edx
1250
	jbe   .continue
1251
 
1252
	mov   sb_position2,edx
1253
;	jmp   .continue_1
1254
 
1255
.continue:
1256
	mov   eax,sb_position2
1257
	sub   ecx,ebx
1258
.continue_1:
1259
;*****************************************************************************
1260
	mov   ebx,eax
1261
 
1262
	mov   eax,sb_max_area
1263
	cmp   eax,sb_cur_area
1264
	ja    @f
1265
 
1266
	xor   eax,eax
1267
	inc   eax
1268
	mov   sb_position2,eax
1269
	jmp   .all_sb   ;.store_position
1270
@@:
1271
	sub   eax,sb_cur_area
1272
	inc   eax
1273
	shl   eax,10
1274
	xor   edx,edx
1275
	div   ecx
1276
	shl   edx,1
1277
	cmp   edx,ecx
1278
	jb    @f
1279
 
1280
	inc   eax
1281
 
1282
@@:
1283
	imul  eax,ebx
1284
	shr   eax,10
1285
 
1286
	cmp   sb_position,eax
1287
	je    .exit_sb
1288
 
1289
	cmp   eax,0
1290
	ja    @f
1291
 
1292
	xor   eax,eax
1293
 
1294
@@:
1295
.store_position:
1296
	mov   sb_position,eax
1297
.all_sb:
1298
	mov   sb_redraw,dword 1
1299
	call  .draw_1
1300
	mov   eax,sb_m_pos
1301
	mov   sb_m_pos_2,eax
1302
	jmp   .exit_sb
1303
;*****************************************************************************
1304
.down_sb:
1305
	cmp   sb_m_keys,dword 0
1306
	je   .exit_sb
1307
 
1308
	mov   eax,sb_max_area
1309
	sub   eax,sb_cur_area
1310
	cmp   sb_position,eax
1311
;	jae   .exit_sb
1312
	jae   @f
1313
 
1314
	inc   dword sb_position
1315
	jmp   .all_sb
1316
@@:
1317
	xor   eax,eax
1318
	mov   ax,sb_size_x
1319
	sub   eax,sb_btn_high
1320
	sub   eax,sb_btn_high
1321
	sub   eax,sb_run_size
1322
	mov   sb_position2,eax
1323
	jmp   .all_sb
1324
.exit_sb:
1325
scroll_bar_exit
1326
}