CtrlLib: HeaderCtrl serialization fixed (thanks zsolt), DropTree fixes

git-svn-id: svn://ultimatepp.org/upp/trunk@1706 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-11-18 08:09:16 +00:00
commit 4c7db817db
5 changed files with 51 additions and 18 deletions

View file

@ -115,10 +115,9 @@ no extension, returns empty string.&]
[s4;%% &]
[s5;:GetFileName`(const char`*`): [_^String^ String]_[* GetFileName]([@(0.0.255) const]_[@(0.0.255) c
har]_`*[*@3 path])&]
[s2;%% Gets file extension, including `'.`' character. If there is
no extension, returns empty string.&]
[s2;%% Returns the name of file (without directory).&]
[s2;%% Example (POSIX): GetFileName([@3 `"/home/user/test.ext`"]) returns
[@3 `".ext`"].&]
[@3 `"test.ext`"].&]
[s3;%% &]
[s4; &]
[s5;:AppendFileName`(const String`&`,const char`*`): [_^String^ String]_[* AppendFileName

View file

@ -648,6 +648,34 @@ ctrl DropList {
}
}
ctrl DropTree {
group "Input fields";
GetMinSize() { sz = XMinSize(); sz.cy += 6; return sz; }
GetStdSize() { sz = GetMinSize(); sz.cx *= 8; return sz; }
Frame SetFrame = InsetFrame();
bool SetEditable = true @2 ? "Editable";
bool WantFocus = true;
bool DisplayAll = false;
bool AutoResize = false;
bool DropFocus = false;
bool AlwaysDrop = false @1;
Text Tip;
// Qtf SetInfo @1 ? "Info of control" ;
Paint(w) {
r = GetRect();
DrawCtrlFrame(w, r, .SetFrame);
w.DrawRect(r, :SWhite);
n = r.bottom - r.top;
DrawEdgeButton(w, RectC(r.right - n, r.top, n, n));
w.DrawImage((n - 7) / 2 + r.right - n, (n - 6) / 2 + r.top, "ClassicCtrlsImg::DA");
w.DrawText(3, (GetSize().cy - GetTextSize("", Arial(10)).cy) / 2,
(.SetEditable ? "" : "R/O ") + "DropTree", Arial(10), :SMagenta);
}
}
template WithDropChoice {
bool Dropping = true;
String Appending = ", ";

View file

@ -15,11 +15,10 @@ PopUpTree::PopUpTree() {
Accel();
MouseMoveCursor();
NoPopUpEx();
maxheight = INT_MAX;
SetDropLines(16);
open = autosize = false;
showpos = Null;
WhenOpen = WhenClose = THISBACK(OpenClose);
droplines = 16;
}
PopUpTree::~PopUpTree() {}
@ -82,7 +81,7 @@ void PopUpTree::PopUp(Ctrl *owner, int x, int top, int bottom, int width) {
}
open = false;
Ctrl popup;
int ht = AddFrameSize(width, min(mh, autosize ? GetTreeSize().cy : droplines * GetStdFontCy())).cy;
int ht = AddFrameSize(width, min(mh, autosize ? GetTreeSize().cy : INT_MAX)).cy;
Rect rt = RectC(showpos.x, showpos.y - (up ? ht : 0), showwidth, ht);
if(GUI_PopUpEffect()) {
if(up) {
@ -140,7 +139,7 @@ void DropTree::Sync() {
icon = tree.GetNode(tree.GetCursor()).image;
icond.Set(valuedisplay ? *valuedisplay : tree.GetDisplay(tree.GetCursor()), icon);
MultiButton::SetDisplay(icond);
Set(tree.Get());
Set(tree.GetValue());
}
bool DropTree::Key(dword k, int) {
@ -182,7 +181,6 @@ void DropTree::Clear() {
void DropTree::SetData(const Value& data)
{
tree <<= data;
if(tree.Get() != data) {
tree <<= data;
Update();

View file

@ -726,15 +726,23 @@ void HeaderCtrl::Serialize(Stream& s) {
}
else {
int t = 0;
for(int i = 0; i < col.GetCount(); i++) {
int ndx = col[i].index;
double r = col[i].ratio;
s % ndx;
s % r;
int q = FindIndex(ndx);
if(q >= 0) {
col[q].ratio = r;
col.Swap(t++, q);
for(int i = 0; i < n; i++) {
if(n == col.GetCount()) {
int ndx = col[i].index;
double r = col[i].ratio;
s % ndx;
s % r;
int q = FindIndex(ndx);
if(q >= 0) {
col[q].ratio = r;
col.Swap(t++, q);
}
}
else {
int dummy = 0;
double dummy2 = 1.0;
s % dummy;
s % dummy2;
}
}
}

View file

@ -390,7 +390,7 @@ public:
PopUpTree& MaxHeight(int maxheight_) { maxheight = maxheight_; return *this; }
int GetMaxHeight() const { return maxheight; }
PopUpTree& AutoResize(bool b = true) { autosize = b; return *this; }
PopUpTree& SetDropLines(int n) { droplines = n; return *this; }
PopUpTree& SetDropLines(int n) { MaxHeight(n * (GetStdFontCy() + 4)); return *this; }
};
class DropTree : public MultiButton {