Home » U++ Library support » Splitter » Splitter and SetMin strange behavior
Splitter and SetMin strange behavior [message #11627] |
Wed, 19 September 2007 20:13 |
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 |
|
mirek
Messages: 14038 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 |
|
mirek
Messages: 14038 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
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 07:37:27 CEST 2024
Total time taken to generate the page: 0.02502 seconds
|