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 » U++ Library support » Menus&Toolbars » ToolBar Callback weirdness
Re: ToolBar Callback weirdness [message #35278 is a reply to message #35273] Sat, 28 January 2012 14:19 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
You have to 'refresh' toolbar explicitly by setting it again after making any changes to it:

struct BarTest: TopWindow {
	ToolBar toolbar;
	int tool;
	
	typedef BarTest CLASSNAME;
	
	void SetBar()
	{
		toolbar.Set(THISBACK(ToolBarContent));
	}
	
	BarTest()
	{
		tool = 1;
		AddFrame(toolbar.Left());
		SetBar();
	}
	
	virtual void Paint(Draw& w)
	{
		w.DrawRect(GetSize(), Gray());
		w.DrawText(200, 220, AsString(tool));
	}
	
	void SetTool(int t)
	{
		tool = t;
		Refresh();
		SetBar();
	}
	
	void ToolBarContent(Bar& bar)
	{
		bar.Add("Move", CtrlImg::reporticon(), THISBACK1(SetToool, 1))
		   .Check(tool == 1);
		bar.Add("Rotate", CtrlImg::reporticon(), THISBACK1(SetTool, 2))
		   .Check(tool == 2);
	}
};


 
Read Message
Read Message
Read Message
Previous Topic: How do I create vertical toolbars
Next Topic: Popup menu with check items
Goto Forum:
  


Current Time: Sun Apr 28 12:48:34 CEST 2024

Total time taken to generate the page: 0.06281 seconds