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 » Splitter and SetMin strange behavior
Splitter and SetMin strange behavior [message #11627] Wed, 19 September 2007 20:13 Go to next message
mapo is currently offline  mapo
Messages: 5
Registered: September 2007
Promising Member
Hi,

i`m looking for using splitter, but have some strange problems with SetMin method.
if I want splitter to be ~380px wide, i have to cal S1.SetMin(0, 5000);, but documentation states, that second parameter is in pixels.

Am I doing something wrong?

I attached example project.

mapo.
Re: Splitter and SetMin strange behavior [message #11638 is a reply to message #11627] Wed, 19 September 2007 23:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mapo wrote on Wed, 19 September 2007 14:13

Hi,

i`m looking for using splitter, but have some strange problems with SetMin method.
if I want splitter to be ~380px wide, i have to cal S1.SetMin(0, 5000);, but documentation states, that second parameter is in pixels.

Am I doing something wrong?

I attached example project.

mapo.


I have just checked, unfortunately, Min seems to be in 1/10000 of width (which is, if nothing else, quite impractical).

Will look into the issue tomorrow (perhaps adding SetMinPixels).

Thanks for testcase.

Mirek

[Updated on: Wed, 19 September 2007 23:09]

Report message to a moderator

Re: Splitter and SetMin strange behavior [message #11661 is a reply to message #11638] Thu, 20 September 2007 22:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I hope it is fixed now (with SetMinPixels).

Quick fix:

class Splitter : public Ctrl {
public:
	virtual void   Layout();
	virtual void   Paint(Draw& draw);
	virtual void   MouseMove(Point p, dword keyflags);
	virtual void   LeftDown(Point p, dword keyflags);
	virtual void   LeftUp(Point p, dword keyflags);
	virtual Image  CursorImage(Point p, dword keyflags);
	virtual void   Serialize(Stream& s);

protected:
	Vector<int> pos;
	Vector<int> mins;
	Vector<int> minpx;
	int         width;
	int         style;
	int         mouseindex;
	bool        vert;
	int         inset;

	int       ClientToPos(Point client) const;
	int       PosToClient(int pos) const;
	int       FindIndex(Point client) const;
	int       GetChildCount() const;
	int       GetMins(int i) const;

public:
	void      Set(Ctrl& l, Ctrl& r);

	Splitter& SetPos(int newpos, int index = 0);
	int       GetPos(int index = 0) const          { return index < pos.GetCount() ? pos[index] : 10000; }

	int       GetCount() const                     { return GetChildCount(); }

	void      Zoom(int i);
	void      NoZoom()                             { Zoom(-1); }
	int       GetZoom() const                      { return style; }

	void      SetMin(int i, int w)                 { mins.At(i, 0) = w; }
	void      SetMinPixels(int i, int w)           { minpx.At(i, 0) = w; }

	void      Add(Ctrl& pane);
	Splitter& operator<<(Ctrl& pane)               { Add(pane); return *this; }

	Splitter& Vert(Ctrl& top, Ctrl& bottom);
	Splitter& Horz(Ctrl& left, Ctrl& right);
	Splitter& Vert()                               { vert = true; Layout(); return *this; }
	Splitter& Horz()                               { vert = false; Layout(); return *this; }
	Splitter& BarWidth(int w);
	bool      IsHorz() const                       { return !vert; }
	bool      IsVert() const                       { return vert; }

	void      Clear();
	void      Reset();

	Splitter();
	virtual ~Splitter();
};


int Splitter::GetMins(int i) const
{
	int min1 = (i < mins.GetCount() ? mins[i] : 0);
	int min2 = 0;
	int cx = GetSize().cx;
	if(cx)
		min2 = (i < minpx.GetCount() ? minpx[i] : 0) * 10000 / cx;
	return max(min1, min2);
}

Splitter& Splitter::SetPos(int p, int i) {
	int l = (i > 0 && i - 1 < pos.GetCount() ? pos[i - 1] : 0) + GetMins(i);
	int h = (i + 1 < pos.GetCount() ? pos[i + 1] : 10000) - GetMins(i + 1);
	pos.At(i) = minmax(p, l, h);
	Layout();
	return *this;
}


Mirek
Re: Splitter and SetMin strange behavior [message #11679 is a reply to message #11661] Fri, 21 September 2007 09:27 Go to previous message
mapo is currently offline  mapo
Messages: 5
Registered: September 2007
Promising Member
thanx! Smile


7edcd8e6f33ea538d7d44a5487ef4566
Previous Topic: splitter and WhenAction
Next Topic: Patch request for SplitterFrame
Goto Forum:
  


Current Time: Thu Mar 28 15:45:14 CET 2024

Total time taken to generate the page: 0.01318 seconds