Index: CtrlLib/Button.cpp
===================================================================
--- CtrlLib/Button.cpp	(wersja 7749)
+++ CtrlLib/Button.cpp	(kopia robocza)
@@ -4,28 +4,34 @@
 
 #define LLOG(x) // LOG(x)
 
-void Pusher::RefreshFocus() {
+void Pusher::RefreshFocus()
+{
 	Refresh();
 }
 
-void Pusher::RefreshPush() {
+void Pusher::RefreshPush()
+{
 	Refresh();
 }
 
-void Pusher::PerformAction() {
+void Pusher::PerformAction()
+{
 	WhenAction();
 }
 
-void Pusher::GotFocus() {
+void Pusher::GotFocus()
+{
 	RefreshFocus();
 }
 
-void Pusher::LostFocus() {
+void Pusher::LostFocus()
+{
 	if(keypush) EndPush();
 	RefreshFocus();
 }
 
-void Pusher::LeftDown(Point, dword) {
+void Pusher::LeftDown(Point, dword)
+{
 	if(Ctrl::ClickFocus() || clickfocus) SetWantFocus();
 	if(IsReadOnly()) return;
 	push = true;
@@ -34,7 +40,13 @@
 	SetCapture();
 }
 
-void Pusher::MouseMove(Point, dword style) {
+void Pusher::RightDown(Point, dword)
+{
+	WhenRightClick();
+}
+
+void Pusher::MouseMove(Point, dword style)
+{
 	LLOG("Mouse move !");
 	if(IsReadOnly() || !HasCapture()) return;
 	bool b = GetScreenView().Contains(GetMousePos());
@@ -44,16 +56,19 @@
 	}
 }
 
-void Pusher::MouseLeave() {
+void Pusher::MouseLeave()
+{
 	EndPush();
 }
 
-void Pusher::LeftRepeat(Point, dword) {
+void Pusher::LeftRepeat(Point, dword)
+{
 	if(IsReadOnly()) return;
 	WhenRepeat();
 }
 
-void Pusher::LeftUp(Point, dword) {
+void Pusher::LeftUp(Point, dword)
+{
 	FinishPush();
 }
 
@@ -62,7 +77,7 @@
 	return AccessKeyBit(accesskey);
 }
 
-void  Pusher::AssignAccessKeys(dword used)
+void Pusher::AssignAccessKeys(dword used)
 {
 	if(!accesskey) {
 		accesskey = ChooseAccessKey(label, used);
@@ -72,13 +87,14 @@
 	Ctrl::AssignAccessKeys(used);
 }
 
-void  Pusher::State(int)
+void Pusher::State(int)
 {
 	if(keypush && GetTopCtrl() && !GetTopCtrl()->HasFocusDeep())
 		EndPush();
 }
 
-void Pusher::KeyPush() {
+void Pusher::KeyPush()
+{
 	if(IsReadOnly()) return;
 	if(keypush) {
 		WhenRepeat();
@@ -100,7 +116,8 @@
 	return true;
 }
 
-bool Pusher::Key(dword key, int) {
+bool Pusher::Key(dword key, int)
+{
 	if(IsReadOnly()) return false;
 	if(key == K_SPACE) {
 		KeyPush();
@@ -111,7 +128,8 @@
 	return false;
 }
 
-bool Pusher::HotKey(dword key) {
+bool Pusher::HotKey(dword key)
+{
 	if(CompareAccessKey(accesskey, key)) {
 		PseudoPush();
 		return true;
@@ -119,7 +137,8 @@
 	return false;
 }
 
-void Pusher::PseudoPush() {
+void Pusher::PseudoPush()
+{
 	if(IsReadOnly() || !IsEnabled()) return;
 	KeyPush();
 	Sync();
@@ -127,13 +146,15 @@
 	FinishPush();
 }
 
-void Pusher::EndPush() {
+void Pusher::EndPush()
+{
 	if(push || keypush)
 		RefreshPush();
 	keypush = push = false;
 }
 
-Pusher&  Pusher::SetFont(Font fnt) {
+Pusher&  Pusher::SetFont(Font fnt)
+{
 	font = fnt;
 	Refresh();
 	return *this;
@@ -150,13 +171,15 @@
 	return label;
 }
 
-Pusher& Pusher::SetLabel(const char *atext) {
+Pusher& Pusher::SetLabel(const char *atext)
+{
 	accesskey = ExtractAccessKey(atext, label);
 	Refresh();
 	return *this;
 }
 
-void Pusher::CancelMode() {
+void Pusher::CancelMode()
+{
 	EndPush();
 }
 
@@ -168,7 +191,8 @@
 	       CTRL_NORMAL;
 }
 
-Pusher::Pusher() {
+Pusher::Pusher()
+{
 	keypush = push = clickfocus = false;
 	accesskey = 0;
 	font = StdFont();
@@ -370,7 +394,8 @@
 	Pusher::MouseLeave();
 }
 
-bool Button::Key(dword key, int w) {
+bool Button::Key(dword key, int w)
+{
 	if(Pusher::Key(key, w)) return true;
 	if(key == K_ENTER) {
 		KeyPush();
@@ -381,7 +406,8 @@
 	return false;
 }
 
-bool Button::HotKey(dword key) {
+bool Button::HotKey(dword key)
+{
 	if(Pusher::HotKey(key)) return true;
 	if(CompareAccessKey(accesskey, key)) {
 		PseudoPush();
@@ -432,7 +458,8 @@
 	return *this;
 }
 
-Button::Button() {
+Button::Button()
+{
 	style = NULL;
 	type = NORMAL;
 	monoimg = false;
@@ -509,7 +536,8 @@
 	return *this;
 }
 
-SpinButtons::SpinButtons() {
+SpinButtons::SpinButtons()
+{
 	visible = true;
 	onsides = false;
 	inc.NoWantFocus();
@@ -533,11 +561,13 @@
 	Pusher::MouseLeave();
 }
 
-void Option::RefreshFocus() {
+void Option::RefreshFocus()
+{
 	Refresh();
 }
 
-void Option::RefreshPush() {
+void Option::RefreshPush()
+{
 	if(showlabel)
 		Refresh(0, 0, CtrlsImg::O0().GetSize().cx, GetSize().cy);
 	else
@@ -544,13 +574,15 @@
 		Pusher::RefreshPush();
 }
 
-Size Option::GetMinSize() const {
+Size Option::GetMinSize() const
+{
 	Size isz = CtrlsImg::O0().GetSize();
 	return AddFrameSize(isz.cx + (GetSmartTextSize(label).cx + 4) * showlabel,
 		                max(isz.cy, StdFont().Info().GetHeight()) + 2);
 }
 
-void Option::Paint(Draw& w) {
+void Option::Paint(Draw& w)
+{
 	Size sz = GetSize();
 	
 	if(!IsTransparent())
@@ -588,17 +620,20 @@
 	}
 }
 
-void   Option::SetData(const Value& data) {
+void   Option::SetData(const Value& data)
+{
 	Set(IsString(data) ? String(data) == "1" ? 1
 	                                         : IsNull(data) ? (notnull ? 0 : int(Null)) : 0
 	                   : notnull ? Nvl((int)data, 0) : (int)data);
 }
 
-Value  Option::GetData() const {
+Value  Option::GetData() const
+{
 	return (int) option;
 }
 
-void  Option::PerformAction() {
+void  Option::PerformAction()
+{
 	if(option == 0)
 		option = threestate ? Null : 1;
 	else
@@ -620,7 +655,8 @@
 	return *this;
 }
 
-Option::Option() {
+Option::Option()
+{
 	option = 0;
 	notnull = true;
 	switchimage = threestate = false;
@@ -641,7 +677,8 @@
 	Transparent();
 }
 
-void ButtonOption::Serialize(Stream& s) {
+void ButtonOption::Serialize(Stream& s)
+{
 	int version = 0;
 	s / version;
 	bool b = Get();
@@ -651,7 +688,8 @@
 		Refresh();
 }
 
-void  ButtonOption::Paint(Draw& w) {
+void  ButtonOption::Paint(Draw& w)
+{
 	Size sz = GetSize();
 	bool ds = !IsShowEnabled();
 	DrawLabel dl;
@@ -698,7 +736,8 @@
 	drawfocus = false;
 }
 	
-void  ButtonOption::LeftDown(Point, dword) {
+void  ButtonOption::LeftDown(Point, dword)
+{
 	if(IsReadOnly())
 		return;
 	push = true;
@@ -705,7 +744,8 @@
 	Refresh();
 }
 
-void  ButtonOption::LeftUp(Point, dword) {
+void  ButtonOption::LeftUp(Point, dword)
+{
 	if(IsReadOnly())
 		return;
 	option = !option;
@@ -713,7 +753,8 @@
 	UpdateActionRefresh();
 }
 
-void  ButtonOption::MouseMove(Point, dword flags) {
+void  ButtonOption::MouseMove(Point, dword flags)
+{
 	if(IsReadOnly())
 		return;
 	bool p = !!(flags & K_MOUSELEFT);
@@ -723,11 +764,13 @@
 	}
 }
 
-void  ButtonOption::MouseEnter(Point, dword) {
+void  ButtonOption::MouseEnter(Point, dword)
+{
 	Refresh();
 }
 
-void  ButtonOption::MouseLeave() {
+void  ButtonOption::MouseLeave()
+{
 	if(IsReadOnly())
 		return;
 	if(push)
@@ -760,7 +803,8 @@
 	Ctrl::AssignAccessKeys(used);
 }
 
-ButtonOption& ButtonOption::SetLabel(const String& text) {
+ButtonOption& ButtonOption::SetLabel(const String& text)
+{
 	accesskey = ExtractAccessKey(text, label);
 	Refresh();
 	return *this;
Index: CtrlLib/PushCtrl.h
===================================================================
--- CtrlLib/PushCtrl.h	(wersja 7749)
+++ CtrlLib/PushCtrl.h	(kopia robocza)
@@ -2,6 +2,7 @@
 public:
 	virtual void   CancelMode();
 	virtual void   LeftDown(Point, dword);
+	virtual void   RightDown(Point, dword);
 	virtual void   MouseMove(Point, dword);
 	virtual void   MouseLeave();
 	virtual void   LeftRepeat(Point, dword);
@@ -53,6 +54,7 @@
 
 	Callback WhenPush;
 	Callback WhenRepeat;
+	Callback WhenRightClick;
 
 	Pusher();
 	virtual ~Pusher();
Index: CtrlLib/ScrollBar.cpp
===================================================================
--- CtrlLib/ScrollBar.cpp	(wersja 7749)
+++ CtrlLib/ScrollBar.cpp	(kopia robocza)
@@ -17,6 +17,7 @@
 	thumbmin = 16;
 	overthumb = 0;
 	through = false;
+	menu = true;
 	CtrlsImageLook(vupper, CtrlsImg::I_SBVU);
 	CtrlsImageLook(vthumb, CtrlsImg::I_SBVT, CtrlsImg::SBVI());
 	CtrlsImageLook(vlower, CtrlsImg::I_SBVL);
@@ -34,7 +35,8 @@
 	isup2 = isdown2 = isleft2 = isright2 = false;
 }
 
-ScrollBar::ScrollBar() {
+ScrollBar::ScrollBar()
+{
 	minthumb = 16;
 	pagepos = pagesize = totalsize = 0;
 	linesize = 1;
@@ -51,18 +53,25 @@
 	Add(next);
 	Add(next2);
 	NoWantFocus();
+	
 	prev.ScrollStyle().NoWantFocus().Transparent();
-	prev.WhenPush = prev.WhenRepeat = callback(this, &ScrollBar::PrevLine);
+	prev.WhenPush = prev.WhenRepeat = THISBACK(PrevLine);
 	prev.WhenPush << Proxy(WhenLeftClick);
+	prev.WhenRightClick = THISBACK2(Menu, MENU_CALLER_PREV, Point());
 	prev2.ScrollStyle().NoWantFocus().Transparent();
 	prev2.WhenRepeat = prev.WhenRepeat;
 	prev2.WhenPush = prev.WhenPush;
+	prev2.WhenRightClick = prev.WhenRightClick;
+	
 	next.ScrollStyle().NoWantFocus().Transparent();
-	next.WhenPush = next.WhenRepeat = callback(this, &ScrollBar::NextLine);
+	next.WhenPush = next.WhenRepeat = THISBACK(NextLine);
 	next.WhenPush << Proxy(WhenLeftClick);
+	next.WhenRightClick = THISBACK2(Menu, MENU_CALLER_NEXT, Point());
 	next2.ScrollStyle().NoWantFocus().Transparent();
 	next2.WhenRepeat = next.WhenRepeat;
 	next2.WhenPush = next.WhenPush;
+	next2.WhenRightClick = next.WhenRightClick;
+	
 	style = NULL;
 	SetStyle(StyleDefault());
 	BackPaint();
@@ -105,11 +114,13 @@
 	return IsHorz() ? h : v;
 }
 
-int ScrollBar::GetHV(int h, int v) const {
+int ScrollBar::GetHV(int h, int v) const
+{
 	return IsHorz() ? h : v;
 }
 
-Rect ScrollBar::GetPartRect(int p) const {
+Rect ScrollBar::GetPartRect(int p) const
+{
 	Rect h = Slider();
 	int sbo = style->overthumb;
 	int off = GetHV(h.left, h.top);
@@ -131,7 +142,8 @@
 	return h;
 }
 
-void ScrollBar::Paint(Draw& w) {
+void ScrollBar::Paint(Draw& w)
+{
 	w.DrawRect(GetSize(), SColorPaper());
 	int cc;
 	Size sz = style->through ? GetSize() : Slider(cc).GetSize();
@@ -174,7 +186,7 @@
 }
 
 
-int  ScrollBar::GetMousePart()
+int ScrollBar::GetMousePart()
 {
 	int q = -1;
 	for(int i = 2; i >= 0; i--)
@@ -185,12 +197,14 @@
 	return q;
 }
 
-int  ScrollBar::GetRange() const {
+int ScrollBar::GetRange() const
+{
 	Size sz = Slider().GetSize();
 	return GetHV(sz.cx, sz.cy);
 }
 
-void ScrollBar::Bounds() {
+void ScrollBar::Bounds()
+{
 	int maxsize = GetRange();
 	if(thumbsize > maxsize)
 		thumbsize = maxsize;
@@ -200,7 +214,8 @@
 		thumbpos = 0;
 }
 
-bool ScrollBar::SetThumb(int _thumbpos, int _thumbsize) {
+bool ScrollBar::SetThumb(int _thumbpos, int _thumbsize)
+{
 	int ts = thumbsize;
 	int tp = thumbpos;
 	thumbsize = _thumbsize;
@@ -213,12 +228,14 @@
 	return false;
 }
 
-void ScrollBar::Drag(Point p) {
+void ScrollBar::Drag(Point p)
+{
 	if(SetThumb(max(0, IsHorz() ? p.x - delta : p.y - delta), thumbsize) && track)
 		Position();
 }
 
-void ScrollBar::LeftDown(Point p, dword) {
+void ScrollBar::LeftDown(Point p, dword)
+{
 	push = GetMousePart();
 	LLOG("ScrollBar::LeftDown(" << p << ")");
 	LLOG("MousePos = " << GetMousePos() << ", ScreenView = " << GetScreenView()
@@ -249,7 +266,13 @@
 	WhenLeftClick();
 }
 
-void ScrollBar::MouseMove(Point p, dword) {
+void ScrollBar::RightDown(Point p, dword)
+{
+	Menu(MENU_CALLER_SCROLL_BAR, p);
+}
+
+void ScrollBar::MouseMove(Point p, dword)
+{
 	if(HasCapture() && push == 2)
 		Drag(p);
 	else
@@ -267,7 +290,8 @@
 	Refresh();
 }
 
-void ScrollBar::LeftUp(Point p, dword) {
+void ScrollBar::LeftUp(Point p, dword)
+{
 	ReleaseCapture();
 	if(!track)
 		Position();
@@ -275,7 +299,8 @@
 	push = -1;
 }
 
-void ScrollBar::LeftRepeat(Point p, dword) {
+void ScrollBar::LeftRepeat(Point p, dword)
+{
 	if(jump || push < 0 || push == 2) return;
 	if(push == 0)
 		PrevPage();
@@ -289,7 +314,8 @@
 	Wheel(zdelta);
 }
 
-void ScrollBar::CancelMode() {
+void ScrollBar::CancelMode()
+{
 	push = light = -1;
 }
 
@@ -329,7 +355,8 @@
 	return false;
 }
 
-void ScrollBar::Set(int _pagepos, int _pagesize, int _totalsize) {
+void ScrollBar::Set(int _pagepos, int _pagesize, int _totalsize)
+{
 	pagesize = _pagesize;
 	totalsize = _totalsize;
 	is_active = totalsize > pagesize && pagesize > 0;
@@ -348,15 +375,18 @@
 	Set(_pagepos);
 }
 
-void ScrollBar::SetPage(int _pagesize) {
+void ScrollBar::SetPage(int _pagesize)
+{
 	Set(pagepos, _pagesize, totalsize);
 }
 
-void ScrollBar::SetTotal(int _totalsize) {
+void ScrollBar::SetTotal(int _totalsize)
+{
 	Set(pagepos, pagesize, _totalsize);
 }
 
-void ScrollBar::Position() {
+void ScrollBar::Position()
+{
 	int slsize = GetRange();
 	int mint = max(minthumb, style->thumbmin);
 	if(slsize < mint || totalsize <= pagesize)
@@ -373,32 +403,135 @@
 	WhenScroll();
 }
 
-void ScrollBar::Uset(int a) {
+void ScrollBar::Uset(int a)
+{
 	if(Set(a))
 		Action();
 }
 
-void ScrollBar::PrevLine() {
+void ScrollBar::Menu(int menuCaller, Point p)
+{
+	if(style->menu && prev.IsShowEnabled()) {
+		if(IsHorz())
+			MenuBar::Execute(THISBACK2(HorzMenu, menuCaller, p));
+		else
+			MenuBar::Execute(THISBACK2(VertMenu, menuCaller, p));
+	}
+}
+
+void ScrollBar::HorzMenu(Bar& bar, int menuCaller, Point p)
+{
+	bar.Add(t_("Scroll here"), THISBACK2(ScrollHere, menuCaller, p));
+	bar.Separator();
+	bar.Add(t_("Left edge"), THISBACK(Begin));
+	bar.Add(t_("Right edge"), THISBACK(End));
+	bar.Separator();
+	bar.Add(t_("Page left"), THISBACK(PrevPage));
+	bar.Add(t_("Page right"), THISBACK(NextPage));
+	bar.Separator();
+	bar.Add(t_("Scroll left"), THISBACK(PrevLine));
+	bar.Add(t_("Scroll right"), THISBACK(NextLine));
+}
+
+void ScrollBar::VertMenu(Bar& bar, int menuCaller, Point p)
+{
+	bar.Add(t_("Scroll here"), THISBACK2(ScrollHere, menuCaller, p));
+	bar.Separator();
+	bar.Add(t_("Top"), THISBACK(Begin));
+	bar.Add(t_("Bottom"), THISBACK(End));
+	bar.Separator();
+	bar.Add(t_("Page up"), THISBACK(PrevPage));
+	bar.Add(t_("Page down"), THISBACK(NextPage));
+	bar.Separator();
+	bar.Add(t_("Scroll up"), THISBACK(PrevLine));
+	bar.Add(t_("Scroll down"), THISBACK(NextLine));
+}
+
+void ScrollBar::ScrollHere(int menuCaller, Point p)
+{
+	if(menuCaller == MENU_CALLER_NEXT)
+		End();
+	else
+	if(menuCaller == MENU_CALLER_PREV)
+		Begin();
+	else
+	if(menuCaller == MENU_CALLER_SCROLL_BAR) {
+		Size sz = GetSize();
+		Size nextButtonsSz = GetNextButtonsSize();
+		Size prevButtonsSz = GetPrevButtonsSize();
+		
+		if(IsHorz()) {
+			int fixedX = p.x - prevButtonsSz.cx - thumbsize / 2;
+			int areaWidth = sz.cx - prevButtonsSz.cx - nextButtonsSz.cx;
+			if(fixedX < 0)
+				fixedX = 0;
+			if(areaWidth == 0)
+				areaWidth = 1;
+			Uset(fixedX / (double)areaWidth * totalsize);
+		}
+		else {
+			int fixedY = p.y - prevButtonsSz.cy - thumbsize / 2;
+			int areaHeight = sz.cy - prevButtonsSz.cy - nextButtonsSz.cy;
+			if(fixedY < 0)
+				fixedY = 0;
+			if(areaHeight == 0)
+				areaHeight = 1;
+			Uset(fixedY / (double)areaHeight * totalsize);	
+		}
+	}
+}
+
+Size ScrollBar::GetNextButtonsSize() const
+{
+	Size sz;
+	
+	sz.cy =  next.IsVisible()  ? next.GetSize().cy  : 0;
+	sz.cy += next2.IsVisible() ? next2.GetSize().cy : 0;
+	sz.cx =  next.IsVisible()  ? next.GetSize().cx  : 0;
+	sz.cx += next2.IsVisible() ? next2.GetSize().cx : 0;
+	
+	return sz;
+}
+
+Size ScrollBar::GetPrevButtonsSize() const
+{
+	Size sz;
+	
+	sz.cy =  prev.IsVisible()  ? prev.GetSize().cy  : 0;
+	sz.cy += prev2.IsVisible() ? prev2.GetSize().cy : 0;
+	sz.cx =  prev.IsVisible()  ? prev.GetSize().cx  : 0;
+	sz.cx += prev2.IsVisible() ? prev2.GetSize().cx : 0;
+	
+	return sz;
+}
+
+void ScrollBar::PrevLine()
+{
 	Uset(pagepos - linesize);
 }
 
-void ScrollBar::NextLine() {
+void ScrollBar::NextLine()
+{
 	Uset(pagepos + linesize);
 }
 
-void ScrollBar::PrevPage() {
+void ScrollBar::PrevPage()
+{
 	Uset(pagepos - max(pagesize - linesize, 1));
 }
 
-void ScrollBar::NextPage() {
+void ScrollBar::NextPage()
+{
 	Uset(pagepos + max(pagesize - linesize, 1));
 }
 
-void ScrollBar::Wheel(int zdelta, int lines) {
+void ScrollBar::Wheel(int zdelta, int lines)
+{
 	Uset(pagepos - lines * linesize * zdelta / 120);
 }
 
-bool ScrollBar::VertKey(dword key, bool homeend) {
+bool ScrollBar::VertKey(dword key, bool homeend)
+{
 	if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty())
 		return false;
 	switch(key) {
@@ -442,7 +575,8 @@
 	Uset(max(0, totalsize - pagesize));
 }
 
-bool ScrollBar::HorzKey(dword key) {
+bool ScrollBar::HorzKey(dword key)
+{
 	if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty())
 		return false;
 	switch(key) {
@@ -470,7 +604,8 @@
 	return true;
 }
 
-void ScrollBar::Layout() {
+void ScrollBar::Layout()
+{
 	Size sz = GetSize();
 	if(IsHorz()) {
 		prev.SetStyle(style->left);
@@ -502,7 +637,8 @@
 	Refresh();
 }
 
-bool ScrollBar::ScrollInto(int pos, int _linesize) {
+bool ScrollBar::ScrollInto(int pos, int _linesize)
+{
 	int new_pos = pagepos;
 	if(pos > new_pos + pagesize - _linesize)
 		new_pos = pos - pagesize + _linesize;
@@ -511,7 +647,8 @@
 	return Set(new_pos);
 }
 
-Size ScrollBar::GetStdSize() const {
+Size ScrollBar::GetStdSize() const
+{
 	int a = HeaderCtrl::GetStdHeight();
 	return Size(a, a);
 }
@@ -526,7 +663,8 @@
 	(IsHorz() ? sz.cy : sz.cx) += ScrollBarSize();
 }
 
-Size ScrollBar::GetViewSize() const {
+Size ScrollBar::GetViewSize() const
+{
 	if(IsChild() && InFrame()) {
 		Size sz = GetParent()->GetSize();
 		if(IsShown())
@@ -536,7 +674,8 @@
 	return Size(0, 0);
 }
 
-Size ScrollBar::GetReducedViewSize() const {
+Size ScrollBar::GetReducedViewSize() const
+{
 	if(IsChild() && InFrame()) {
 		Size sz = GetParent()->GetSize();
 		if(!IsShown())
@@ -546,7 +685,8 @@
 	return Size(0, 0);
 }
 
-ScrollBar& ScrollBar::AutoHide(bool b) {
+ScrollBar& ScrollBar::AutoHide(bool b)
+{
 	autohide = b;
 	if(b)
 		SetTotal(totalsize);
@@ -556,7 +696,8 @@
 	return *this;
 }
 
-ScrollBar& ScrollBar::AutoDisable(bool b) {
+ScrollBar& ScrollBar::AutoDisable(bool b)
+{
 	autodisable = b;
 	if(!b) {
 		if(!prev.IsEnabled())
@@ -622,85 +763,102 @@
 		GuiPlatformGripResize(q);
 }
 
-void ScrollBars::Scroll() {
+void ScrollBars::Scroll()
+{
 	WhenScroll();
 }
 
-bool ScrollBars::Key(dword key) {
+bool ScrollBars::Key(dword key)
+{
 	return x.HorzKey(key) || y.VertKey(key);
 }
 
-void ScrollBars::Set(Point pos, Size page, Size total) {
+void ScrollBars::Set(Point pos, Size page, Size total)
+{
 	x.Set(pos.x, page.cx, total.cx);
 	y.Set(pos.y, page.cy, total.cy);
 }
 
-bool ScrollBars::Set(int _x, int _y) {
+bool ScrollBars::Set(int _x, int _y)
+{
 	bool b = x.Set(_x) | y.Set(_y);
 	return b;
 }
 
-bool ScrollBars::Set(Point pos) {
+bool ScrollBars::Set(Point pos)
+{
 	return Set(pos.x, pos.y);
 }
 
-void ScrollBars::SetPage(int cx, int cy) {
+void ScrollBars::SetPage(int cx, int cy)
+{
 	x.SetPage(cx);
 	y.SetPage(cy);
 }
 
-void ScrollBars::SetPage(Size page) {
+void ScrollBars::SetPage(Size page)
+{
 	SetPage(page.cx, page.cy);
 }
 
-void ScrollBars::SetTotal(int cx, int cy) {
+void ScrollBars::SetTotal(int cx, int cy)
+{
 	x.SetTotal(cx);
 	y.SetTotal(cy);
 }
 
-void ScrollBars::SetTotal(Size total) {
+void ScrollBars::SetTotal(Size total)
+{
 	SetTotal(total.cx, total.cy);
 }
 
-bool ScrollBars::ScrollInto(Point pos, Size linesize) {
+bool ScrollBars::ScrollInto(Point pos, Size linesize)
+{
 	return x.ScrollInto(pos.x, linesize.cx) | y.ScrollInto(pos.y, linesize.cy);
 }
 
-bool ScrollBars::ScrollInto(Point pos) {
+bool ScrollBars::ScrollInto(Point pos)
+{
 	return x.ScrollInto(pos.x) | y.ScrollInto(pos.y);
 }
 
-ScrollBars& ScrollBars::SetLine(int linex, int liney) {
+ScrollBars& ScrollBars::SetLine(int linex, int liney)
+{
 	x.SetLine(linex);
 	y.SetLine(liney);
 	return *this;
 }
 
-ScrollBars& ScrollBars::Track(bool b) {
+ScrollBars& ScrollBars::Track(bool b)
+{
 	x.Track(b);
 	y.Track(b);
 	return *this;
 }
 
-ScrollBars& ScrollBars::Jump(bool b) {
+ScrollBars& ScrollBars::Jump(bool b)
+{
 	x.Jump(b);
 	y.Jump(b);
 	return *this;
 }
 
-ScrollBars& ScrollBars::AutoHide(bool b) {
+ScrollBars& ScrollBars::AutoHide(bool b) 
+{
 	x.AutoHide(b);
 	y.AutoHide(b);
 	return *this;
 }
 
-ScrollBars& ScrollBars::AutoDisable(bool b) {
+ScrollBars& ScrollBars::AutoDisable(bool b)
+{
 	x.AutoDisable(b);
 	y.AutoDisable(b);
 	return *this;
 }
 
-ScrollBars& ScrollBars::Box(Ctrl& _box) {
+ScrollBars& ScrollBars::Box(Ctrl& _box)
+{
 	box->Remove();
 	box = &_box;
 	if(x.GetParent() && x.GetParent() != box->GetParent())
@@ -708,7 +866,8 @@
 	return *this;
 }
 
-void ScrollBars::FrameAdd(Ctrl& p) {
+void ScrollBars::FrameAdd(Ctrl& p)
+{
 	p.Add(x);
 	p.Add(y);
 	if(box->GetParent() != &p)
@@ -715,13 +874,15 @@
 		p.Add(*box);
 }
 
-void ScrollBars::FrameRemove() {
+void ScrollBars::FrameRemove()
+{
 	x.Remove();
 	y.Remove();
 	box->Remove();
 }
 
-void ScrollBars::FramePaint(Draw& w, const Rect& r) {
+void ScrollBars::FramePaint(Draw& w, const Rect& r)
+{
 	if(x.IsShown() && y.IsShown() && !box) {
 		int h = ScrollBarSize();
 		w.DrawRect(r.right - h, r.bottom - h, h, h, SColorFace);
@@ -728,7 +889,8 @@
 	}
 }
 
-void ScrollBars::FrameLayout(Rect& r) {
+void ScrollBars::FrameLayout(Rect& r)
+{
 	int h = ScrollBarSize();
 	int by = 0;
 	int bx = x.IsShown() && y.IsShown() ? h : 0;
@@ -746,17 +908,20 @@
 	r.bottom -= dx;
 }
 
-void ScrollBars::FrameAddSize(Size& sz) {
+void ScrollBars::FrameAddSize(Size& sz)
+{
 	int h = ScrollBarSize();
 	sz.cy += x.IsShown() * h;
 	sz.cx += y.IsShown() * h;
 }
 
-Size ScrollBars::GetViewSize() const {
+Size ScrollBars::GetViewSize() const
+{
 	return Size(y.GetViewSize().cx, x.GetViewSize().cy);
 }
 
-Size ScrollBars::GetReducedViewSize() const {
+Size ScrollBars::GetReducedViewSize() const 
+{
 	return Size(y.GetReducedViewSize().cx, x.GetReducedViewSize().cy);
 }
 
@@ -789,7 +954,8 @@
 	return *this;
 }
 
-ScrollBars::ScrollBars() {
+ScrollBars::ScrollBars()
+{
 	box = &the_box;
 //	the_box.NoTransparent();
 	x.WhenScroll = y.WhenScroll = callback(this, &ScrollBars::Scroll);
Index: CtrlLib/ScrollBar.h
===================================================================
--- CtrlLib/ScrollBar.h	(wersja 7749)
+++ CtrlLib/ScrollBar.h	(kopia robocza)
@@ -1,9 +1,12 @@
 class ScrollBar : public FrameCtrl<Ctrl> {
+	typedef ScrollBar CLASSNAME;
+	
 public:
 	virtual void Layout();
 	virtual Size GetStdSize() const;
 	virtual void Paint(Draw& draw);
 	virtual void LeftDown(Point p, dword);
+	virtual void RightDown(Point p, dword);
 	virtual void MouseMove(Point p, dword);
 	virtual void MouseEnter(Point p, dword);
 	virtual void MouseLeave();
@@ -19,6 +22,7 @@
 	struct Style : ChStyle<Style> {
 		int barsize, arrowsize, thumbmin, overthumb;
 		bool through;
+		bool menu;
 		Value vupper[4], vthumb[4], vlower[4];
 		Value hupper[4], hthumb[4], hlower[4];
 		Button::Style up, down, left, right;
@@ -27,6 +31,8 @@
 	};
 
 private:
+	enum { MENU_CALLER_PREV, MENU_CALLER_SCROLL_BAR, MENU_CALLER_NEXT };
+
 	int     thumbpos;
 	int     thumbsize;
 	bool    horz:1;
@@ -61,9 +67,17 @@
 
 	void    Position();
 	void    Uset(int a);
-
+	
+	void    Menu(int menuCaller, Point p);
+	void    HorzMenu(Bar& bar, int menuCaller, Point p);
+	void    VertMenu(Bar& bar, int menuCaller, Point p);
+	
+	void    ScrollHere(int menuCaller, Point p);
+	Size    GetNextButtonsSize() const;
+	Size    GetPrevButtonsSize() const;
+	
 	int     ScrollBarSize() const                 { return style->barsize; }
-
+	
 public:
 	Callback WhenScroll;
 	Callback WhenVisibility;
