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 » Splitter » add controls to splitter bar, how? [NEEDS MORE IMPLEMENTATION...]
add controls to splitter bar, how? [NEEDS MORE IMPLEMENTATION...] [message #1873] Fri, 24 March 2006 14:37 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
I want to add some controls to splitter bar. Let'say button. What is the easy way? Smile

#include <CtrlLib/CtrlLib.h>

GUI_APP_MAIN
{	TopWindow w;
      Button b;
	Splitter horz;
	LineEdit ed1,ed2;

		horz.Add(ed1);
		horz.Add(ed2);
		
		w.Add(horz.Horz().VSizePos(35,35));
	w.Run();
}

[Updated on: Sun, 09 April 2006 04:11]

Report message to a moderator

Re: add controls to splitter bar, how? [message #1874 is a reply to message #1873] Fri, 24 March 2006 14:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
What is wrong with reference/Splitter?

Mirek
Re: add controls to splitter bar, how? [message #1876 is a reply to message #1874] Fri, 24 March 2006 15:16 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Fri, 24 March 2006 13:57

What is wrong with reference/Splitter?

Mirek


The buttons are not on the bar!
Re: add controls to splitter bar, how? [message #1877 is a reply to message #1876] Fri, 24 March 2006 15:31 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
E.g.

#include <CtrlLib/CtrlLib.h>

class MySplitter : public Splitter {
//	int lrpos[3];
	Button btn;
public:
	typedef MySplitter CLASSNAME;
	void	Move();
	Callback WhenLeftDouble;
	void LeftDouble(Point, dword);
	MySplitter();

};

void MySplitter::LeftDouble(Point, dword){
	WhenLeftDouble();
}

void MySplitter::Move(){
//	PromptOK("test");
	SetPos(100);
}

MySplitter::MySplitter(){
	//btn.SizePos().TopPos(10);
	//Add(btn);
	WhenLeftDouble <<THISBACK(Move);

}

class App : public TopWindow {
	LineEdit ed1,ed2;
	MySplitter horz;
	StatusBar status;
public:
	typedef App CLASSNAME;
	void Show();
	App();
};


App::App(){
	
		horz.Add(ed1);
		horz.Add(ed2);
		
		Add(horz.Horz().VSizePos(35,35));
		AddFrame(status);

		Sizeable();
}


GUI_APP_MAIN
{	
	App().Run();
}



I want "move right" "move left" buttons on splitter bar...
Re: add controls to splitter bar, how? [message #1878 is a reply to message #1877] Fri, 24 March 2006 17:58 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
ok, in fact, semi-working example is this:
#include <CtrlLib/CtrlLib.h>

class App : public TopWindow {
	LineEdit ed1,ed2;
	Splitter horz;
	Option btn;
public:
	typedef App CLASSNAME;
	void Move();
	App();
};

void App::Move(){
	if (btn.Get())
		  horz.SetPos(1000);
	else  horz.SetPos(5000);
	btn.SetRectX(horz.GetPos()/13-10,10);
}

App::App(){
	horz.Add(ed1);
	horz.Add(ed2);
	Add(horz.Horz().VSizePos(35,35));

	btn.SetRectY(50,50);
	btn.SetRectX(horz.GetPos()/13-10,10);
	Add(btn);

	btn.WhenAction=THISBACK(Move);

	Sizeable().Zoomable();
}

GUI_APP_MAIN
{	
	App().Run();
}


First problem is that position returned from splitter is in different units than from other controls...
Second problem is that in this case I need to catch splitter bar events and update button position...

What I wanted was the same like for HeaderCtrl - public access Splitter Bar...
Re: add controls to splitter bar, how? [message #1887 is a reply to message #1876] Fri, 24 March 2006 22:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
fudadmin wrote on Fri, 24 March 2006 09:16

luzr wrote on Fri, 24 March 2006 13:57

What is wrong with reference/Splitter?

Mirek


The buttons are not on the bar!



Please define "on the bar".

If I undestand this well, maybe it should be frame ctrl? See

http://upp.sourceforge.net/srcdoc$CtrlCore$AboutFrames$en-us .html

if this is not enough, you will have to either suggest Splitter improvements or define your own Ctrl (not a very complicated task in fact).

Mirek
Re: add controls to splitter bar, how? [message #1889 is a reply to message #1878] Fri, 24 March 2006 23:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
fudadmin wrote on Fri, 24 March 2006 11:58

ok, in fact, semi-working example is this:
.....
First problem is that position returned from splitter is in different units than from other controls...
Second problem is that in this case I need to catch splitter bar events and update button position...

What I wanted was the same like for HeaderCtrl - public access Splitter Bar...


SOrry, missed this followup...

Well, I guess Frame could solve this:

If I undestand you well, you need the option at the top of view area. You can easily add one by adding FrameCtrl to it.

Something line

FrameTop<Option> top;
top.Height(Draw::GetStdFontCy());
ed1.AddFrame(top);

..I guess that you will need some more complicated composition than Option there (Option is not opaque to start with), but as the first step....

Mirek
Re: add controls to splitter bar, how? [message #1958 is a reply to message #1889] Tue, 28 March 2006 20:43 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
improved example which works if you make Splitter::PosToClient() public... or add that piece of code instead ...
#include <CtrlLib/CtrlLib.h>

class App : public TopWindow {
	LineEdit ed1,ed2;
	Splitter horz;
	Option btn;
public:
	typedef App CLASSNAME;
	void MoveSplitter();
	App();
};

void App::MoveSplitter(){
	if (btn.Get())
		  horz.SetPos(1000);
	else  horz.SetPos(5000);
	btn.SetRectX( horz.PosToClient(horz.GetPos(0))-7, 15 );
}

App::App(){
	horz.Add(ed1);
	horz.Add(ed2);
	Add(horz.Horz().VSizePos(35,35));
	
	Add(btn);
	SetRect(20,30,950,720); //can't leave without it because you will not get Pos's...
	
	btn.SetRectX( horz.PosToClient(horz.GetPos(0))-7, 15 );  //have to make Splitter::PosToClient() public... :(
	btn.SetRectY(50,50);
	
	btn.WhenAction=THISBACK(MoveSplitter);
	Sizeable().Zoomable();
}


GUI_APP_MAIN
{	
	App().Run();
}


Now the problem is how to keep the "switcher" in place when resizing parent Ctrl's...?

[Updated on: Tue, 28 March 2006 20:44]

Report message to a moderator

Re: add controls to splitter bar, how? [message #1960 is a reply to message #1958] Tue, 28 March 2006 21:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
I am afraid this will to satisfy your appetitte, but for illustration:

#include <CtrlLib/CtrlLib.h>

class App : public TopWindow {
	LineEdit   ed1,ed2;
	Splitter   horz;

	FrameRight<StaticRect> sr;
	Option                 btn;

public:
	typedef App CLASSNAME;
	void MoveSplitter();
	App();
};

void App::MoveSplitter()
{
	if(btn)
		horz.SetPos(1000);
	else
		horz.SetPos(5000);
}

App::App()
{
	horz.Add(ed1);
	horz.Add(ed2);

	Add(horz.Horz().VSizePos(35,35));
	ed1.SetFrame(0, sr);
	sr.Width(20);
	ed1.AddFrame(FieldFrame());
	sr.Add(btn.LeftPos(5, 20).TopPos(0, 20));
	
	btn.WhenAction=THISBACK(MoveSplitter);
	Sizeable().Zoomable();
}


GUI_APP_MAIN
{
	App().Run();
}


As for the right solution, I believe something close how "edit window split" is done in TheIDE should be OK for you.

In fact, this is not much about U++, but about UI design. I do not believe that that option over split area looks nice Wink

Mirek
Re: add controls to splitter bar, how? [message #1962 is a reply to message #1960] Tue, 28 March 2006 23:44 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Tue, 28 March 2006 20:44


I do not believe that that option over split area looks nice Wink

Mirek


Of course it's not. I want to put some images...
Re: add controls to splitter bar, how? [message #1964 is a reply to message #1960] Tue, 28 March 2006 23:59 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Tue, 28 March 2006 20:44

I am afraid this will to satisfy your appetitte, but for illustration:
...



The idea with the extra frame in this code is super! One more example where the iceberg Ultimate++ lies... And needs to be explored.
Previous Topic: how programatically change widths/heights of splitted controls? [SOLVED]
Next Topic: setters of Splitter should return Splitter& [ADDED]
Goto Forum:
  


Current Time: Fri Nov 01 00:23:03 CET 2024

Total time taken to generate the page: 0.01331 seconds