Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Alignment of two (or more) toolbars at the same "level"
Alignment of two (or more) toolbars at the same "level" [message #28334] Sun, 29 August 2010 11:56 Go to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Hi,

Is it possible to align more than one tool bar in the same application “row/level” (or column, if they are vertically oriented?; I am referring to the typical feature of many applications, through which some toolbars share the same “row” (very common when the toolbars in question are rather small).

A second query: is it possible to relocate a toolbar with drag and drop?

Cheers,

Javier
Re: Alignment of two (or more) toolbars at the same "level" [message #28384 is a reply to message #28334] Tue, 31 August 2010 13:54 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Is there anybody capable to solve the enigma?

Cheers,

Javier
Re: Alignment of two (or more) toolbars at the same "level" [message #28388 is a reply to message #28384] Tue, 31 August 2010 14:17 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I do not understand. You can align them anyway you want, there are no constrains. You can use them as a frame or in the middle of your window or add them to a Button if you wish.

There is no drag & drop support for toolbars, so that users can rearrange and dock them where they wish.
Re: Alignment of two (or more) toolbars at the same "level" [message #28390 is a reply to message #28388] Tue, 31 August 2010 14:55 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Roger! But.. an example would help me a lot, if it's not too much trouble. Please, just provide some hints about how to do it.

Thank you.

Javier
Re: Alignment of two (or more) toolbars at the same "level" [message #28391 is a reply to message #28390] Tue, 31 August 2010 15:10 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Don't have U++ here now, but you can look at TheIDE sources. It has an option to have the menubar and toolbar on the same line or not.
Re: Alignment of two (or more) toolbars at the same "level" [message #28392 is a reply to message #28391] Tue, 31 August 2010 15:19 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Thanks, but too complicated. Any other hint, please?

Cheers,

Javier.
Re: Alignment of two (or more) toolbars at the same "level" [message #28406 is a reply to message #28392] Tue, 31 August 2010 20:35 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Hi Javier,

There are many ways how to have multiple toolbars and after that only one. Here is one way.
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class ToolBars : public TopWindow {
public:
	typedef ToolBars CLASSNAME;
	ToolBars();
	ToolBar tb;
	Button btn;
	bool one;
	void Act() {}
	void TBar(Bar& bar)
	{
		bar.Add(CtrlImg::exclamation(), THISBACK(Act)).Label("Exclamation");
		if (!one)
			bar.Break();
		bar.Add(CtrlImg::information(), THISBACK(Act)).Label("Information");
	}
	void OneTB()
	{
		one = !one;
		tb.Set(THISBACK(TBar));
		if (one)
			btn.SetLabel("Two Toolbars");
		else
			btn.SetLabel("One Toolbar");
	}
};

ToolBars::ToolBars()
{
	one = false;
	Title("Window title");
	tb.Set(THISBACK(TBar));
	AddFrame(tb);
	Add(btn.LeftPos(10, 80).TopPos(10, 30));
	btn.SetLabel("One toolbar");
	btn.WhenAction = THISBACK(OneTB);
}

GUI_APP_MAIN
{
	ToolBars().Run();
}


Andrei
Re: Alignment of two (or more) toolbars at the same "level" [message #28407 is a reply to message #28406] Tue, 31 August 2010 21:37 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Andrei,

Very grateful. It will be very useful.

What about the drag and drop feature?

Cheers,

Javier
Re: Alignment of two (or more) toolbars at the same "level" [message #28418 is a reply to message #28407] Wed, 01 September 2010 14:54 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
281264 wrote on Tue, 31 August 2010 22:37

Andrei,

Very grateful. It will be very useful.

What about the drag and drop feature?

Cheers,

Javier



Hello Javier,

If you want drag and drop you may use Docking from Bazaar, which provide rich docking options. If you want something simple, you may do it by your self Wink

Here is my solution. Add an instance of BarHandler to a Bar (MenuBar, Toolbar) and see how it's working.
class BarHandler: public Ctrl {
public:
	Ctrl *parent;
	BarCtrl* bar;
	bool left_down;
	Point left_point;
	
	BarHandler() : bar(0), parent(0), left_down(false) {}
	
	void UpdateLayout()
	{
		if (bar) {
			int align = bar->GetAlign();
			if (align == BarCtrl::BAR_LEFT || align == BarCtrl::BAR_RIGHT)
				TopPos(1, 4).HSizePosZ(2, 2);
			else
				VSizePosZ(2, 2).LeftPos(1, 4);
		}
	}
	
	void ParentChange()
	{
		bar = 0;
		VSizePos(2, 2).LeftPos(1, 4);
	}
	
	void InitCtrl()
	{
		Ctrl* ctrl = GetParent();
		while (ctrl) {
			bar = dynamic_cast<BarCtrl*>(ctrl);
			if (bar && (bar->IsToolBar() || bar->IsMenuBar())) {
				parent = bar->GetParent();
				break;
			} else {
				bar = 0;
			}
			ctrl = ctrl->GetParent();
		}	
	}
	void MouseLeave()
	{
		if (left_down)
			SetCapture();
	}
	
	void LeftDown(Point p, dword keyflags)
	{
		left_down = true;
		left_point = p;
		if (!bar || !parent)
			InitCtrl();
		if (bar && !bar->IsPopUp()) {
			Rect r = bar->GetScreenView();
			parent->RemoveFrame((CtrlFrame&)*bar);
			bar->SetRect(r.left , r.top, r.Width(), r.Height());
			bar->PopUp(NULL, true, true, true, true);
		}
	}
	void MouseMove(Point p, dword keyflags)
	{
		if (bar && left_down) {
			Rect r = bar->GetScreenView();
			bar->SetRect(p.x - left_point.x + r.left, p.y - left_point.y + r.top , r.Width(), r.Height());
		}
	}
	
	void LeftUp(Point p, dword keyflags)
	{
		left_down = false;
		int left, right, top, bottom;
		left = right = top = bottom = 0;
		if (bar && bar->IsPopUp()) {
			Rect pr = parent->GetRect();
			Point pt = GetMousePos();
			if (pr.Contains(pt)) {
				bar->Close();
				parent->AddFrame(*bar);
				left = pt.x - pr.left;
				right = pr.right - pt.x;
				top = pt.y - pr.top;
				bottom = pr.bottom - pt.y;
				if (left < right && left < top && left < bottom)
					bar->Left();
				if (right < left && right < top && right < bottom)
					bar->Right();
				if (top < left && top < right && top < bottom)
					bar->Top();
				if (bottom < left && bottom < right && bottom < top)
					bar->Bottom();
			}
		}
		ReleaseCapture();
		UpdateLayout();
	}
	
	void Paint(Draw& w)
	{
		ChPaint(w, GetSize(), CtrlImg::SmallDot());
	}
};


Andrei
Re: Alignment of two (or more) toolbars at the same "level" [message #28422 is a reply to message #28418] Wed, 01 September 2010 16:06 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Andrei,

Here is a test. There must be something incorrect.
Please tell me what is wrong.

Thank you,

Javier
Re: Alignment of two (or more) toolbars at the same "level" [message #28426 is a reply to message #28422] Wed, 01 September 2010 16:26 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Hi,

It don't support frames (yet), when toolbar is popup-ed.
It's not that hard to add support for frames, you may do it Smile
So for now just comment line toolbar.AddFrame(FieldFrame()); from your code.

Andrei
Re: Alignment of two (or more) toolbars at the same "level" [message #28427 is a reply to message #28426] Wed, 01 September 2010 17:19 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Thanks. It works very well.

Are you planning continuing working on it? It’ll become popular, guaranteed!

Another question about DockWindow (in the Bazaar): I have tried to use it but, somehow, it does recognize DockableWindow. Is it included in U++?

Javier
Re: Alignment of two (or more) toolbars at the same "level" [message #28428 is a reply to message #28427] Wed, 01 September 2010 17:37 Go to previous message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Andrei,

DockableWindow spotted!

Thanks,

Javier
Previous Topic: Query regarding PopUpTable
Next Topic: Assorted queries regarding ArrayCtrl.
Goto Forum:
  


Current Time: Fri Mar 29 06:55:03 CET 2024

Total time taken to generate the page: 0.01530 seconds