ScrollBarContextMenu.diff

Zbigniew Rebacz, 10/12/2014 02:45 PM

Download (22.4 KB)

View differences:

CtrlLib/Button.cpp (kopia robocza)
4 4

  
5 5
#define LLOG(x) // LOG(x)
6 6

  
7
void Pusher::RefreshFocus() {
7
void Pusher::RefreshFocus()
8
{
8 9
	Refresh();
9 10
}
10 11

  
11
void Pusher::RefreshPush() {
12
void Pusher::RefreshPush()
13
{
12 14
	Refresh();
13 15
}
14 16

  
15
void Pusher::PerformAction() {
17
void Pusher::PerformAction()
18
{
16 19
	WhenAction();
17 20
}
18 21

  
19
void Pusher::GotFocus() {
22
void Pusher::GotFocus()
23
{
20 24
	RefreshFocus();
21 25
}
22 26

  
23
void Pusher::LostFocus() {
27
void Pusher::LostFocus()
28
{
24 29
	if(keypush) EndPush();
25 30
	RefreshFocus();
26 31
}
27 32

  
28
void Pusher::LeftDown(Point, dword) {
33
void Pusher::LeftDown(Point, dword)
34
{
29 35
	if(Ctrl::ClickFocus() || clickfocus) SetWantFocus();
30 36
	if(IsReadOnly()) return;
31 37
	push = true;
......
34 40
	SetCapture();
35 41
}
36 42

  
37
void Pusher::MouseMove(Point, dword style) {
43
void Pusher::RightDown(Point, dword)
44
{
45
	WhenRightClick();
46
}
47

  
48
void Pusher::MouseMove(Point, dword style)
49
{
38 50
	LLOG("Mouse move !");
39 51
	if(IsReadOnly() || !HasCapture()) return;
40 52
	bool b = GetScreenView().Contains(GetMousePos());
......
44 56
	}
45 57
}
46 58

  
47
void Pusher::MouseLeave() {
59
void Pusher::MouseLeave()
60
{
48 61
	EndPush();
49 62
}
50 63

  
51
void Pusher::LeftRepeat(Point, dword) {
64
void Pusher::LeftRepeat(Point, dword)
65
{
52 66
	if(IsReadOnly()) return;
53 67
	WhenRepeat();
54 68
}
55 69

  
56
void Pusher::LeftUp(Point, dword) {
70
void Pusher::LeftUp(Point, dword)
71
{
57 72
	FinishPush();
58 73
}
59 74

  
......
62 77
	return AccessKeyBit(accesskey);
63 78
}
64 79

  
65
void  Pusher::AssignAccessKeys(dword used)
80
void Pusher::AssignAccessKeys(dword used)
66 81
{
67 82
	if(!accesskey) {
68 83
		accesskey = ChooseAccessKey(label, used);
......
72 87
	Ctrl::AssignAccessKeys(used);
73 88
}
74 89

  
75
void  Pusher::State(int)
90
void Pusher::State(int)
76 91
{
77 92
	if(keypush && GetTopCtrl() && !GetTopCtrl()->HasFocusDeep())
78 93
		EndPush();
79 94
}
80 95

  
81
void Pusher::KeyPush() {
96
void Pusher::KeyPush()
97
{
82 98
	if(IsReadOnly()) return;
83 99
	if(keypush) {
84 100
		WhenRepeat();
......
100 116
	return true;
101 117
}
102 118

  
103
bool Pusher::Key(dword key, int) {
119
bool Pusher::Key(dword key, int)
120
{
104 121
	if(IsReadOnly()) return false;
105 122
	if(key == K_SPACE) {
106 123
		KeyPush();
......
111 128
	return false;
112 129
}
113 130

  
114
bool Pusher::HotKey(dword key) {
131
bool Pusher::HotKey(dword key)
132
{
115 133
	if(CompareAccessKey(accesskey, key)) {
116 134
		PseudoPush();
117 135
		return true;
......
119 137
	return false;
120 138
}
121 139

  
122
void Pusher::PseudoPush() {
140
void Pusher::PseudoPush()
141
{
123 142
	if(IsReadOnly() || !IsEnabled()) return;
124 143
	KeyPush();
125 144
	Sync();
......
127 146
	FinishPush();
128 147
}
129 148

  
130
void Pusher::EndPush() {
149
void Pusher::EndPush()
150
{
131 151
	if(push || keypush)
132 152
		RefreshPush();
133 153
	keypush = push = false;
134 154
}
135 155

  
136
Pusher&  Pusher::SetFont(Font fnt) {
156
Pusher&  Pusher::SetFont(Font fnt)
157
{
137 158
	font = fnt;
138 159
	Refresh();
139 160
	return *this;
......
150 171
	return label;
151 172
}
152 173

  
153
Pusher& Pusher::SetLabel(const char *atext) {
174
Pusher& Pusher::SetLabel(const char *atext)
175
{
154 176
	accesskey = ExtractAccessKey(atext, label);
155 177
	Refresh();
156 178
	return *this;
157 179
}
158 180

  
159
void Pusher::CancelMode() {
181
void Pusher::CancelMode()
182
{
160 183
	EndPush();
161 184
}
162 185

  
......
168 191
	       CTRL_NORMAL;
169 192
}
170 193

  
171
Pusher::Pusher() {
194
Pusher::Pusher()
195
{
172 196
	keypush = push = clickfocus = false;
173 197
	accesskey = 0;
174 198
	font = StdFont();
......
370 394
	Pusher::MouseLeave();
371 395
}
372 396

  
373
bool Button::Key(dword key, int w) {
397
bool Button::Key(dword key, int w)
398
{
374 399
	if(Pusher::Key(key, w)) return true;
375 400
	if(key == K_ENTER) {
376 401
		KeyPush();
......
381 406
	return false;
382 407
}
383 408

  
384
bool Button::HotKey(dword key) {
409
bool Button::HotKey(dword key)
410
{
385 411
	if(Pusher::HotKey(key)) return true;
386 412
	if(CompareAccessKey(accesskey, key)) {
387 413
		PseudoPush();
......
432 458
	return *this;
433 459
}
434 460

  
435
Button::Button() {
461
Button::Button()
462
{
436 463
	style = NULL;
437 464
	type = NORMAL;
438 465
	monoimg = false;
......
509 536
	return *this;
510 537
}
511 538

  
512
SpinButtons::SpinButtons() {
539
SpinButtons::SpinButtons()
540
{
513 541
	visible = true;
514 542
	onsides = false;
515 543
	inc.NoWantFocus();
......
533 561
	Pusher::MouseLeave();
534 562
}
535 563

  
536
void Option::RefreshFocus() {
564
void Option::RefreshFocus()
565
{
537 566
	Refresh();
538 567
}
539 568

  
540
void Option::RefreshPush() {
569
void Option::RefreshPush()
570
{
541 571
	if(showlabel)
542 572
		Refresh(0, 0, CtrlsImg::O0().GetSize().cx, GetSize().cy);
543 573
	else
544 574
		Pusher::RefreshPush();
545 575
}
546 576

  
547
Size Option::GetMinSize() const {
577
Size Option::GetMinSize() const
578
{
548 579
	Size isz = CtrlsImg::O0().GetSize();
549 580
	return AddFrameSize(isz.cx + (GetSmartTextSize(label).cx + 4) * showlabel,
550 581
		                max(isz.cy, StdFont().Info().GetHeight()) + 2);
551 582
}
552 583

  
553
void Option::Paint(Draw& w) {
584
void Option::Paint(Draw& w)
585
{
554 586
	Size sz = GetSize();
555 587
	
556 588
	if(!IsTransparent())
......
588 620
	}
589 621
}
590 622

  
591
void   Option::SetData(const Value& data) {
623
void   Option::SetData(const Value& data)
624
{
592 625
	Set(IsString(data) ? String(data) == "1" ? 1
593 626
	                                         : IsNull(data) ? (notnull ? 0 : int(Null)) : 0
594 627
	                   : notnull ? Nvl((int)data, 0) : (int)data);
595 628
}
596 629

  
597
Value  Option::GetData() const {
630
Value  Option::GetData() const
631
{
598 632
	return (int) option;
599 633
}
600 634

  
601
void  Option::PerformAction() {
635
void  Option::PerformAction()
636
{
602 637
	if(option == 0)
603 638
		option = threestate ? Null : 1;
604 639
	else
......
620 655
	return *this;
621 656
}
622 657

  
623
Option::Option() {
658
Option::Option()
659
{
624 660
	option = 0;
625 661
	notnull = true;
626 662
	switchimage = threestate = false;
......
641 677
	Transparent();
642 678
}
643 679

  
644
void ButtonOption::Serialize(Stream& s) {
680
void ButtonOption::Serialize(Stream& s)
681
{
645 682
	int version = 0;
646 683
	s / version;
647 684
	bool b = Get();
......
651 688
		Refresh();
652 689
}
653 690

  
654
void  ButtonOption::Paint(Draw& w) {
691
void  ButtonOption::Paint(Draw& w)
692
{
655 693
	Size sz = GetSize();
656 694
	bool ds = !IsShowEnabled();
657 695
	DrawLabel dl;
......
698 736
	drawfocus = false;
699 737
}
700 738
	
701
void  ButtonOption::LeftDown(Point, dword) {
739
void  ButtonOption::LeftDown(Point, dword)
740
{
702 741
	if(IsReadOnly())
703 742
		return;
704 743
	push = true;
705 744
	Refresh();
706 745
}
707 746

  
708
void  ButtonOption::LeftUp(Point, dword) {
747
void  ButtonOption::LeftUp(Point, dword)
748
{
709 749
	if(IsReadOnly())
710 750
		return;
711 751
	option = !option;
......
713 753
	UpdateActionRefresh();
714 754
}
715 755

  
716
void  ButtonOption::MouseMove(Point, dword flags) {
756
void  ButtonOption::MouseMove(Point, dword flags)
757
{
717 758
	if(IsReadOnly())
718 759
		return;
719 760
	bool p = !!(flags & K_MOUSELEFT);
......
723 764
	}
724 765
}
725 766

  
726
void  ButtonOption::MouseEnter(Point, dword) {
767
void  ButtonOption::MouseEnter(Point, dword)
768
{
727 769
	Refresh();
728 770
}
729 771

  
730
void  ButtonOption::MouseLeave() {
772
void  ButtonOption::MouseLeave()
773
{
731 774
	if(IsReadOnly())
732 775
		return;
733 776
	if(push)
......
760 803
	Ctrl::AssignAccessKeys(used);
761 804
}
762 805

  
763
ButtonOption& ButtonOption::SetLabel(const String& text) {
806
ButtonOption& ButtonOption::SetLabel(const String& text)
807
{
764 808
	accesskey = ExtractAccessKey(text, label);
765 809
	Refresh();
766 810
	return *this;
CtrlLib/PushCtrl.h (kopia robocza)
2 2
public:
3 3
	virtual void   CancelMode();
4 4
	virtual void   LeftDown(Point, dword);
5
	virtual void   RightDown(Point, dword);
5 6
	virtual void   MouseMove(Point, dword);
6 7
	virtual void   MouseLeave();
7 8
	virtual void   LeftRepeat(Point, dword);
......
53 54

  
54 55
	Callback WhenPush;
55 56
	Callback WhenRepeat;
57
	Callback WhenRightClick;
56 58

  
57 59
	Pusher();
58 60
	virtual ~Pusher();
CtrlLib/ScrollBar.cpp (kopia robocza)
17 17
	thumbmin = 16;
18 18
	overthumb = 0;
19 19
	through = false;
20
	menu = true;
20 21
	CtrlsImageLook(vupper, CtrlsImg::I_SBVU);
21 22
	CtrlsImageLook(vthumb, CtrlsImg::I_SBVT, CtrlsImg::SBVI());
22 23
	CtrlsImageLook(vlower, CtrlsImg::I_SBVL);
......
34 35
	isup2 = isdown2 = isleft2 = isright2 = false;
35 36
}
36 37

  
37
ScrollBar::ScrollBar() {
38
ScrollBar::ScrollBar()
39
{
38 40
	minthumb = 16;
39 41
	pagepos = pagesize = totalsize = 0;
40 42
	linesize = 1;
......
51 53
	Add(next);
52 54
	Add(next2);
53 55
	NoWantFocus();
56
	
54 57
	prev.ScrollStyle().NoWantFocus().Transparent();
55
	prev.WhenPush = prev.WhenRepeat = callback(this, &ScrollBar::PrevLine);
58
	prev.WhenPush = prev.WhenRepeat = THISBACK(PrevLine);
56 59
	prev.WhenPush << Proxy(WhenLeftClick);
60
	prev.WhenRightClick = THISBACK2(Menu, MENU_CALLER_PREV, Point());
57 61
	prev2.ScrollStyle().NoWantFocus().Transparent();
58 62
	prev2.WhenRepeat = prev.WhenRepeat;
59 63
	prev2.WhenPush = prev.WhenPush;
64
	prev2.WhenRightClick = prev.WhenRightClick;
65
	
60 66
	next.ScrollStyle().NoWantFocus().Transparent();
61
	next.WhenPush = next.WhenRepeat = callback(this, &ScrollBar::NextLine);
67
	next.WhenPush = next.WhenRepeat = THISBACK(NextLine);
62 68
	next.WhenPush << Proxy(WhenLeftClick);
69
	next.WhenRightClick = THISBACK2(Menu, MENU_CALLER_NEXT, Point());
63 70
	next2.ScrollStyle().NoWantFocus().Transparent();
64 71
	next2.WhenRepeat = next.WhenRepeat;
65 72
	next2.WhenPush = next.WhenPush;
73
	next2.WhenRightClick = next.WhenRightClick;
74
	
66 75
	style = NULL;
67 76
	SetStyle(StyleDefault());
68 77
	BackPaint();
......
105 114
	return IsHorz() ? h : v;
106 115
}
107 116

  
108
int ScrollBar::GetHV(int h, int v) const {
117
int ScrollBar::GetHV(int h, int v) const
118
{
109 119
	return IsHorz() ? h : v;
110 120
}
111 121

  
112
Rect ScrollBar::GetPartRect(int p) const {
122
Rect ScrollBar::GetPartRect(int p) const
123
{
113 124
	Rect h = Slider();
114 125
	int sbo = style->overthumb;
115 126
	int off = GetHV(h.left, h.top);
......
131 142
	return h;
132 143
}
133 144

  
134
void ScrollBar::Paint(Draw& w) {
145
void ScrollBar::Paint(Draw& w)
146
{
135 147
	w.DrawRect(GetSize(), SColorPaper());
136 148
	int cc;
137 149
	Size sz = style->through ? GetSize() : Slider(cc).GetSize();
......
174 186
}
175 187

  
176 188

  
177
int  ScrollBar::GetMousePart()
189
int ScrollBar::GetMousePart()
178 190
{
179 191
	int q = -1;
180 192
	for(int i = 2; i >= 0; i--)
......
185 197
	return q;
186 198
}
187 199

  
188
int  ScrollBar::GetRange() const {
200
int ScrollBar::GetRange() const
201
{
189 202
	Size sz = Slider().GetSize();
190 203
	return GetHV(sz.cx, sz.cy);
191 204
}
192 205

  
193
void ScrollBar::Bounds() {
206
void ScrollBar::Bounds()
207
{
194 208
	int maxsize = GetRange();
195 209
	if(thumbsize > maxsize)
196 210
		thumbsize = maxsize;
......
200 214
		thumbpos = 0;
201 215
}
202 216

  
203
bool ScrollBar::SetThumb(int _thumbpos, int _thumbsize) {
217
bool ScrollBar::SetThumb(int _thumbpos, int _thumbsize)
218
{
204 219
	int ts = thumbsize;
205 220
	int tp = thumbpos;
206 221
	thumbsize = _thumbsize;
......
213 228
	return false;
214 229
}
215 230

  
216
void ScrollBar::Drag(Point p) {
231
void ScrollBar::Drag(Point p)
232
{
217 233
	if(SetThumb(max(0, IsHorz() ? p.x - delta : p.y - delta), thumbsize) && track)
218 234
		Position();
219 235
}
220 236

  
221
void ScrollBar::LeftDown(Point p, dword) {
237
void ScrollBar::LeftDown(Point p, dword)
238
{
222 239
	push = GetMousePart();
223 240
	LLOG("ScrollBar::LeftDown(" << p << ")");
224 241
	LLOG("MousePos = " << GetMousePos() << ", ScreenView = " << GetScreenView()
......
249 266
	WhenLeftClick();
250 267
}
251 268

  
252
void ScrollBar::MouseMove(Point p, dword) {
269
void ScrollBar::RightDown(Point p, dword)
270
{
271
	Menu(MENU_CALLER_SCROLL_BAR, p);
272
}
273

  
274
void ScrollBar::MouseMove(Point p, dword)
275
{
253 276
	if(HasCapture() && push == 2)
254 277
		Drag(p);
255 278
	else
......
267 290
	Refresh();
268 291
}
269 292

  
270
void ScrollBar::LeftUp(Point p, dword) {
293
void ScrollBar::LeftUp(Point p, dword)
294
{
271 295
	ReleaseCapture();
272 296
	if(!track)
273 297
		Position();
......
275 299
	push = -1;
276 300
}
277 301

  
278
void ScrollBar::LeftRepeat(Point p, dword) {
302
void ScrollBar::LeftRepeat(Point p, dword)
303
{
279 304
	if(jump || push < 0 || push == 2) return;
280 305
	if(push == 0)
281 306
		PrevPage();
......
289 314
	Wheel(zdelta);
290 315
}
291 316

  
292
void ScrollBar::CancelMode() {
317
void ScrollBar::CancelMode()
318
{
293 319
	push = light = -1;
294 320
}
295 321

  
......
329 355
	return false;
330 356
}
331 357

  
332
void ScrollBar::Set(int _pagepos, int _pagesize, int _totalsize) {
358
void ScrollBar::Set(int _pagepos, int _pagesize, int _totalsize)
359
{
333 360
	pagesize = _pagesize;
334 361
	totalsize = _totalsize;
335 362
	is_active = totalsize > pagesize && pagesize > 0;
......
348 375
	Set(_pagepos);
349 376
}
350 377

  
351
void ScrollBar::SetPage(int _pagesize) {
378
void ScrollBar::SetPage(int _pagesize)
379
{
352 380
	Set(pagepos, _pagesize, totalsize);
353 381
}
354 382

  
355
void ScrollBar::SetTotal(int _totalsize) {
383
void ScrollBar::SetTotal(int _totalsize)
384
{
356 385
	Set(pagepos, pagesize, _totalsize);
357 386
}
358 387

  
359
void ScrollBar::Position() {
388
void ScrollBar::Position()
389
{
360 390
	int slsize = GetRange();
361 391
	int mint = max(minthumb, style->thumbmin);
362 392
	if(slsize < mint || totalsize <= pagesize)
......
373 403
	WhenScroll();
374 404
}
375 405

  
376
void ScrollBar::Uset(int a) {
406
void ScrollBar::Uset(int a)
407
{
377 408
	if(Set(a))
378 409
		Action();
379 410
}
380 411

  
381
void ScrollBar::PrevLine() {
412
void ScrollBar::Menu(int menuCaller, Point p)
413
{
414
	if(style->menu && prev.IsShowEnabled()) {
415
		if(IsHorz())
416
			MenuBar::Execute(THISBACK2(HorzMenu, menuCaller, p));
417
		else
418
			MenuBar::Execute(THISBACK2(VertMenu, menuCaller, p));
419
	}
420
}
421

  
422
void ScrollBar::HorzMenu(Bar& bar, int menuCaller, Point p)
423
{
424
	bar.Add(t_("Scroll here"), THISBACK2(ScrollHere, menuCaller, p));
425
	bar.Separator();
426
	bar.Add(t_("Left edge"), THISBACK(Begin));
427
	bar.Add(t_("Right edge"), THISBACK(End));
428
	bar.Separator();
429
	bar.Add(t_("Page left"), THISBACK(PrevPage));
430
	bar.Add(t_("Page right"), THISBACK(NextPage));
431
	bar.Separator();
432
	bar.Add(t_("Scroll left"), THISBACK(PrevLine));
433
	bar.Add(t_("Scroll right"), THISBACK(NextLine));
434
}
435

  
436
void ScrollBar::VertMenu(Bar& bar, int menuCaller, Point p)
437
{
438
	bar.Add(t_("Scroll here"), THISBACK2(ScrollHere, menuCaller, p));
439
	bar.Separator();
440
	bar.Add(t_("Top"), THISBACK(Begin));
441
	bar.Add(t_("Bottom"), THISBACK(End));
442
	bar.Separator();
443
	bar.Add(t_("Page up"), THISBACK(PrevPage));
444
	bar.Add(t_("Page down"), THISBACK(NextPage));
445
	bar.Separator();
446
	bar.Add(t_("Scroll up"), THISBACK(PrevLine));
447
	bar.Add(t_("Scroll down"), THISBACK(NextLine));
448
}
449

  
450
void ScrollBar::ScrollHere(int menuCaller, Point p)
451
{
452
	if(menuCaller == MENU_CALLER_NEXT)
453
		End();
454
	else
455
	if(menuCaller == MENU_CALLER_PREV)
456
		Begin();
457
	else
458
	if(menuCaller == MENU_CALLER_SCROLL_BAR) {
459
		Size sz = GetSize();
460
		Size nextButtonsSz = GetNextButtonsSize();
461
		Size prevButtonsSz = GetPrevButtonsSize();
462
		
463
		if(IsHorz()) {
464
			int fixedX = p.x - prevButtonsSz.cx - thumbsize / 2;
465
			int areaWidth = sz.cx - prevButtonsSz.cx - nextButtonsSz.cx;
466
			if(fixedX < 0)
467
				fixedX = 0;
468
			if(areaWidth == 0)
469
				areaWidth = 1;
470
			Uset(fixedX / (double)areaWidth * totalsize);
471
		}
472
		else {
473
			int fixedY = p.y - prevButtonsSz.cy - thumbsize / 2;
474
			int areaHeight = sz.cy - prevButtonsSz.cy - nextButtonsSz.cy;
475
			if(fixedY < 0)
476
				fixedY = 0;
477
			if(areaHeight == 0)
478
				areaHeight = 1;
479
			Uset(fixedY / (double)areaHeight * totalsize);	
480
		}
481
	}
482
}
483

  
484
Size ScrollBar::GetNextButtonsSize() const
485
{
486
	Size sz;
487
	
488
	sz.cy =  next.IsVisible()  ? next.GetSize().cy  : 0;
489
	sz.cy += next2.IsVisible() ? next2.GetSize().cy : 0;
490
	sz.cx =  next.IsVisible()  ? next.GetSize().cx  : 0;
491
	sz.cx += next2.IsVisible() ? next2.GetSize().cx : 0;
492
	
493
	return sz;
494
}
495

  
496
Size ScrollBar::GetPrevButtonsSize() const
497
{
498
	Size sz;
499
	
500
	sz.cy =  prev.IsVisible()  ? prev.GetSize().cy  : 0;
501
	sz.cy += prev2.IsVisible() ? prev2.GetSize().cy : 0;
502
	sz.cx =  prev.IsVisible()  ? prev.GetSize().cx  : 0;
503
	sz.cx += prev2.IsVisible() ? prev2.GetSize().cx : 0;
504
	
505
	return sz;
506
}
507

  
508
void ScrollBar::PrevLine()
509
{
382 510
	Uset(pagepos - linesize);
383 511
}
384 512

  
385
void ScrollBar::NextLine() {
513
void ScrollBar::NextLine()
514
{
386 515
	Uset(pagepos + linesize);
387 516
}
388 517

  
389
void ScrollBar::PrevPage() {
518
void ScrollBar::PrevPage()
519
{
390 520
	Uset(pagepos - max(pagesize - linesize, 1));
391 521
}
392 522

  
393
void ScrollBar::NextPage() {
523
void ScrollBar::NextPage()
524
{
394 525
	Uset(pagepos + max(pagesize - linesize, 1));
395 526
}
396 527

  
397
void ScrollBar::Wheel(int zdelta, int lines) {
528
void ScrollBar::Wheel(int zdelta, int lines)
529
{
398 530
	Uset(pagepos - lines * linesize * zdelta / 120);
399 531
}
400 532

  
401
bool ScrollBar::VertKey(dword key, bool homeend) {
533
bool ScrollBar::VertKey(dword key, bool homeend)
534
{
402 535
	if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty())
403 536
		return false;
404 537
	switch(key) {
......
442 575
	Uset(max(0, totalsize - pagesize));
443 576
}
444 577

  
445
bool ScrollBar::HorzKey(dword key) {
578
bool ScrollBar::HorzKey(dword key)
579
{
446 580
	if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty())
447 581
		return false;
448 582
	switch(key) {
......
470 604
	return true;
471 605
}
472 606

  
473
void ScrollBar::Layout() {
607
void ScrollBar::Layout()
608
{
474 609
	Size sz = GetSize();
475 610
	if(IsHorz()) {
476 611
		prev.SetStyle(style->left);
......
502 637
	Refresh();
503 638
}
504 639

  
505
bool ScrollBar::ScrollInto(int pos, int _linesize) {
640
bool ScrollBar::ScrollInto(int pos, int _linesize)
641
{
506 642
	int new_pos = pagepos;
507 643
	if(pos > new_pos + pagesize - _linesize)
508 644
		new_pos = pos - pagesize + _linesize;
......
511 647
	return Set(new_pos);
512 648
}
513 649

  
514
Size ScrollBar::GetStdSize() const {
650
Size ScrollBar::GetStdSize() const
651
{
515 652
	int a = HeaderCtrl::GetStdHeight();
516 653
	return Size(a, a);
517 654
}
......
526 663
	(IsHorz() ? sz.cy : sz.cx) += ScrollBarSize();
527 664
}
528 665

  
529
Size ScrollBar::GetViewSize() const {
666
Size ScrollBar::GetViewSize() const
667
{
530 668
	if(IsChild() && InFrame()) {
531 669
		Size sz = GetParent()->GetSize();
532 670
		if(IsShown())
......
536 674
	return Size(0, 0);
537 675
}
538 676

  
539
Size ScrollBar::GetReducedViewSize() const {
677
Size ScrollBar::GetReducedViewSize() const
678
{
540 679
	if(IsChild() && InFrame()) {
541 680
		Size sz = GetParent()->GetSize();
542 681
		if(!IsShown())
......
546 685
	return Size(0, 0);
547 686
}
548 687

  
549
ScrollBar& ScrollBar::AutoHide(bool b) {
688
ScrollBar& ScrollBar::AutoHide(bool b)
689
{
550 690
	autohide = b;
551 691
	if(b)
552 692
		SetTotal(totalsize);
......
556 696
	return *this;
557 697
}
558 698

  
559
ScrollBar& ScrollBar::AutoDisable(bool b) {
699
ScrollBar& ScrollBar::AutoDisable(bool b)
700
{
560 701
	autodisable = b;
561 702
	if(!b) {
562 703
		if(!prev.IsEnabled())
......
622 763
		GuiPlatformGripResize(q);
623 764
}
624 765

  
625
void ScrollBars::Scroll() {
766
void ScrollBars::Scroll()
767
{
626 768
	WhenScroll();
627 769
}
628 770

  
629
bool ScrollBars::Key(dword key) {
771
bool ScrollBars::Key(dword key)
772
{
630 773
	return x.HorzKey(key) || y.VertKey(key);
631 774
}
632 775

  
633
void ScrollBars::Set(Point pos, Size page, Size total) {
776
void ScrollBars::Set(Point pos, Size page, Size total)
777
{
634 778
	x.Set(pos.x, page.cx, total.cx);
635 779
	y.Set(pos.y, page.cy, total.cy);
636 780
}
637 781

  
638
bool ScrollBars::Set(int _x, int _y) {
782
bool ScrollBars::Set(int _x, int _y)
783
{
639 784
	bool b = x.Set(_x) | y.Set(_y);
640 785
	return b;
641 786
}
642 787

  
643
bool ScrollBars::Set(Point pos) {
788
bool ScrollBars::Set(Point pos)
789
{
644 790
	return Set(pos.x, pos.y);
645 791
}
646 792

  
647
void ScrollBars::SetPage(int cx, int cy) {
793
void ScrollBars::SetPage(int cx, int cy)
794
{
648 795
	x.SetPage(cx);
649 796
	y.SetPage(cy);
650 797
}
651 798

  
652
void ScrollBars::SetPage(Size page) {
799
void ScrollBars::SetPage(Size page)
800
{
653 801
	SetPage(page.cx, page.cy);
654 802
}
655 803

  
656
void ScrollBars::SetTotal(int cx, int cy) {
804
void ScrollBars::SetTotal(int cx, int cy)
805
{
657 806
	x.SetTotal(cx);
658 807
	y.SetTotal(cy);
659 808
}
660 809

  
661
void ScrollBars::SetTotal(Size total) {
810
void ScrollBars::SetTotal(Size total)
811
{
662 812
	SetTotal(total.cx, total.cy);
663 813
}
664 814

  
665
bool ScrollBars::ScrollInto(Point pos, Size linesize) {
815
bool ScrollBars::ScrollInto(Point pos, Size linesize)
816
{
666 817
	return x.ScrollInto(pos.x, linesize.cx) | y.ScrollInto(pos.y, linesize.cy);
667 818
}
668 819

  
669
bool ScrollBars::ScrollInto(Point pos) {
820
bool ScrollBars::ScrollInto(Point pos)
821
{
670 822
	return x.ScrollInto(pos.x) | y.ScrollInto(pos.y);
671 823
}
672 824

  
673
ScrollBars& ScrollBars::SetLine(int linex, int liney) {
825
ScrollBars& ScrollBars::SetLine(int linex, int liney)
826
{
674 827
	x.SetLine(linex);
675 828
	y.SetLine(liney);
676 829
	return *this;
677 830
}
678 831

  
679
ScrollBars& ScrollBars::Track(bool b) {
832
ScrollBars& ScrollBars::Track(bool b)
833
{
680 834
	x.Track(b);
681 835
	y.Track(b);
682 836
	return *this;
683 837
}
684 838

  
685
ScrollBars& ScrollBars::Jump(bool b) {
839
ScrollBars& ScrollBars::Jump(bool b)
840
{
686 841
	x.Jump(b);
687 842
	y.Jump(b);
688 843
	return *this;
689 844
}
690 845

  
691
ScrollBars& ScrollBars::AutoHide(bool b) {
846
ScrollBars& ScrollBars::AutoHide(bool b) 
847
{
692 848
	x.AutoHide(b);
693 849
	y.AutoHide(b);
694 850
	return *this;
695 851
}
696 852

  
697
ScrollBars& ScrollBars::AutoDisable(bool b) {
853
ScrollBars& ScrollBars::AutoDisable(bool b)
854
{
698 855
	x.AutoDisable(b);
699 856
	y.AutoDisable(b);
700 857
	return *this;
701 858
}
702 859

  
703
ScrollBars& ScrollBars::Box(Ctrl& _box) {
860
ScrollBars& ScrollBars::Box(Ctrl& _box)
861
{
704 862
	box->Remove();
705 863
	box = &_box;
706 864
	if(x.GetParent() && x.GetParent() != box->GetParent())
......
708 866
	return *this;
709 867
}
710 868

  
711
void ScrollBars::FrameAdd(Ctrl& p) {
869
void ScrollBars::FrameAdd(Ctrl& p)
870
{
712 871
	p.Add(x);
713 872
	p.Add(y);
714 873
	if(box->GetParent() != &p)
715 874
		p.Add(*box);
716 875
}
717 876

  
718
void ScrollBars::FrameRemove() {
877
void ScrollBars::FrameRemove()
878
{
719 879
	x.Remove();
720 880
	y.Remove();
721 881
	box->Remove();
722 882
}
723 883

  
724
void ScrollBars::FramePaint(Draw& w, const Rect& r) {
884
void ScrollBars::FramePaint(Draw& w, const Rect& r)
885
{
725 886
	if(x.IsShown() && y.IsShown() && !box) {
726 887
		int h = ScrollBarSize();
727 888
		w.DrawRect(r.right - h, r.bottom - h, h, h, SColorFace);
728 889
	}
729 890
}
730 891

  
731
void ScrollBars::FrameLayout(Rect& r) {
892
void ScrollBars::FrameLayout(Rect& r)
893
{
732 894
	int h = ScrollBarSize();
733 895
	int by = 0;
734 896
	int bx = x.IsShown() && y.IsShown() ? h : 0;
......
746 908
	r.bottom -= dx;
747 909
}
748 910

  
749
void ScrollBars::FrameAddSize(Size& sz) {
911
void ScrollBars::FrameAddSize(Size& sz)
912
{
750 913
	int h = ScrollBarSize();
751 914
	sz.cy += x.IsShown() * h;
752 915
	sz.cx += y.IsShown() * h;
753 916
}
754 917

  
755
Size ScrollBars::GetViewSize() const {
918
Size ScrollBars::GetViewSize() const
919
{
756 920
	return Size(y.GetViewSize().cx, x.GetViewSize().cy);
757 921
}
758 922

  
759
Size ScrollBars::GetReducedViewSize() const {
923
Size ScrollBars::GetReducedViewSize() const 
924
{
760 925
	return Size(y.GetReducedViewSize().cx, x.GetReducedViewSize().cy);
761 926
}
762 927

  
......
789 954
	return *this;
790 955
}
791 956

  
792
ScrollBars::ScrollBars() {
957
ScrollBars::ScrollBars()
958
{
793 959
	box = &the_box;
794 960
//	the_box.NoTransparent();
795 961
	x.WhenScroll = y.WhenScroll = callback(this, &ScrollBars::Scroll);
CtrlLib/ScrollBar.h (kopia robocza)
1 1
class ScrollBar : public FrameCtrl<Ctrl> {
2
	typedef ScrollBar CLASSNAME;
3
	
2 4
public:
3 5
	virtual void Layout();
4 6
	virtual Size GetStdSize() const;
5 7
	virtual void Paint(Draw& draw);
6 8
	virtual void LeftDown(Point p, dword);
9
	virtual void RightDown(Point p, dword);
7 10
	virtual void MouseMove(Point p, dword);
8 11
	virtual void MouseEnter(Point p, dword);
9 12
	virtual void MouseLeave();
......
19 22
	struct Style : ChStyle<Style> {
20 23
		int barsize, arrowsize, thumbmin, overthumb;
21 24
		bool through;
25
		bool menu;
22 26
		Value vupper[4], vthumb[4], vlower[4];
23 27
		Value hupper[4], hthumb[4], hlower[4];
24 28
		Button::Style up, down, left, right;
......
27 31
	};
28 32

  
29 33
private:
34
	enum { MENU_CALLER_PREV, MENU_CALLER_SCROLL_BAR, MENU_CALLER_NEXT };
35

  
30 36
	int     thumbpos;
31 37
	int     thumbsize;
32 38
	bool    horz:1;
......
61 67

  
62 68
	void    Position();
63 69
	void    Uset(int a);
64

  
70
	
71
	void    Menu(int menuCaller, Point p);
72
	void    HorzMenu(Bar& bar, int menuCaller, Point p);
73
	void    VertMenu(Bar& bar, int menuCaller, Point p);
74
	
75
	void    ScrollHere(int menuCaller, Point p);
76
	Size    GetNextButtonsSize() const;
77
	Size    GetPrevButtonsSize() const;
78
	
65 79
	int     ScrollBarSize() const                 { return style->barsize; }
66

  
80
	
67 81
public:
68 82
	Callback WhenScroll;
69 83
	Callback WhenVisibility;