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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » ExpressPane
ExpressPane [message #1713] Tue, 14 March 2006 19:22
wilho is currently offline  wilho
Messages: 19
Registered: February 2006
Promising Member
Here's my little composite control, thanks to Miriek for help.

Can be used to create button/control -control similar to left pane of m$'s LookOut.

#include <CtrlLib/CtrlLib.h>

class DblClckBtn : public Button {
public:
	Callback WhenLeftDouble;
	virtual void DblClckBtn::LeftDouble(Point, dword);
};
class ExpressPane : public Ctrl {
	struct SlaveControl {
	    bool isInSplitter;
	    DblClckBtn button;
	    Ctrl* slave;
	};	
	Array<SlaveControl> slaves;
	Splitter splitter;
	static const int BTN_SPACE = 22;
	typedef ExpressPane CLASSNAME;	
	void Toggle(int);
	void OpenOne(int);
public:
	void Add(const char *text, Ctrl& slave);
	void Rearrange();
	ExpressPane();
};
void DblClckBtn::LeftDouble(Point p, dword) {
	if(IsReadOnly()) return;
	WhenLeftDouble();
}
ExpressPane::ExpressPane(){
	Ctrl::Add(splitter);
	splitter.Vert();
}
void ExpressPane::OpenOne(int indx){	
	for(int loopI=slaves.GetCount()-1; loopI>-1; loopI--){
		slaves[loopI].isInSplitter = false; 
	}
	slaves[indx].isInSplitter = true;
	Rearrange();
}
void ExpressPane::Toggle(int indx){
	slaves[indx].isInSplitter = !slaves[indx].isInSplitter; 
	Rearrange();
}
void ExpressPane::Rearrange(){
	for(int loopI=slaves.GetCount()-1; loopI>-1; loopI--){
		splitter.RemoveChild( slaves[loopI].slave );
		if (slaves[loopI].isInSplitter == true){
			splitter << *slaves[loopI].slave;
		}
	}
	splitter.RefreshLayout();
}
void ExpressPane::Add(const char *text, Ctrl& slave){	
	SlaveControl& slvCtrl = slaves.Add();
	int btnIndx = slaves.GetCount()-1;
	slvCtrl.button <<= THISBACK1(Toggle,btnIndx);
	slvCtrl.button.WhenLeftDouble << THISBACK1(OpenOne,btnIndx);
	slvCtrl.button.SetLabel(text);
	slvCtrl.button.HSizePosZ(0, 0).BottomPosZ(BTN_SPACE * btnIndx, BTN_SPACE );
	slvCtrl.isInSplitter = false;
	slvCtrl.slave = &slave;	
	splitter.HSizePosZ(0, 0).VSizePosZ(0, BTN_SPACE * (btnIndx+1));
	Ctrl::Add(slvCtrl.button);
}

class App : public TopWindow {
	DocEdit de1,de2,de3;
	ExpressPane ep;
	public:
	App() {
		ep.Add("de3", de3);
		ep.Add("de2", de2);
		ep.Add("de1", de1);
		Add(ep.HSizePosZ(0,0).VSizePosZ(0,0));
		Sizeable().Zoomable();
	}
};
GUI_APP_MAIN
{
	App().Title("ExpressPane").Run();
}
Previous Topic: how to embed a D/COM control in my U++ GUI ?
Next Topic: Slider and "Dynamic rectangle" example
Goto Forum:
  


Current Time: Sun Jun 23 16:02:09 CEST 2024

Total time taken to generate the page: 0.00915 seconds