diff --git a/uppsrc/CtrlLib/Button.cpp b/uppsrc/CtrlLib/Button.cpp index aa45f50d8..b11012779 100644 --- a/uppsrc/CtrlLib/Button.cpp +++ b/uppsrc/CtrlLib/Button.cpp @@ -26,7 +26,7 @@ void Pusher::LostFocus() { } void Pusher::LeftDown(Point, dword) { - if(Ctrl::ClickFocus()) SetWantFocus(); + if(Ctrl::ClickFocus() || clickfocus) SetWantFocus(); if(IsReadOnly()) return; push = true; RefreshPush(); @@ -138,6 +138,12 @@ Pusher& Pusher::SetFont(Font fnt) { return *this; } +Pusher& Pusher::ClickFocus(bool cf) +{ + clickfocus = cf; + return *this; +} + String Pusher::GetDesc() { return label; @@ -162,7 +168,7 @@ int Pusher::GetVisualState() const } Pusher::Pusher() { - keypush = push = false; + keypush = push = clickfocus = false; accesskey = 0; font = Null; NoInitFocus(); diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index 6db967c77..16e3d8ec3 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -978,6 +978,7 @@ EditField& EditField::NullText(const char *text, Color ink) EditField::EditField() { + dropcaret = Rect(0, 0, 0, 0); Unicode(); Reset(); } diff --git a/uppsrc/CtrlLib/PushCtrl.h b/uppsrc/CtrlLib/PushCtrl.h index 2544c715c..b4ce27173 100644 --- a/uppsrc/CtrlLib/PushCtrl.h +++ b/uppsrc/CtrlLib/PushCtrl.h @@ -18,6 +18,7 @@ public: private: bool push:1; bool keypush:1; + bool clickfocus:1; void EndPush(); @@ -39,6 +40,8 @@ protected: public: Pusher& SetFont(Font fnt); Pusher& SetLabel(const char *text); + Pusher& ClickFocus(bool cf = true); + Pusher& NoClickFocus() { return ClickFocus(false); } Font GetFont() const { return font; } String GetLabel() const { return label; } diff --git a/uppsrc/CtrlLib/TreeCtrl.cpp b/uppsrc/CtrlLib/TreeCtrl.cpp index 25673ea9e..97d6e7e3b 100644 --- a/uppsrc/CtrlLib/TreeCtrl.cpp +++ b/uppsrc/CtrlLib/TreeCtrl.cpp @@ -257,6 +257,12 @@ void TreeCtrl::Set(int id, Value k, Value v) SetOption(id); } +void TreeCtrl::SetDisplay(int id, const Display& display) +{ + item[id].SetDisplay(display); + Dirty(id); +} + void TreeCtrl::SetNode(int id, const TreeCtrl::Node& n) { (TreeCtrl::Node&)item[id] = n; @@ -746,11 +752,15 @@ void TreeCtrl::LeftDrag(Point p, dword keyflags) void TreeCtrl::DoClick(Point p, dword flags, bool down) { Point org = sb; + itemclickpos = Null; if(p.y + org.y > sb.GetTotal().cy) return; int i = FindLine(p.y + org.y); const Line& l = line[i]; - int x = levelcx + l.level * levelcx - org.x - (levelcx >> 1); + int itemx = levelcx + l.level * levelcx - org.x; + int x = itemx - (levelcx >> 1); + itemclickpos.x = p.x - itemx; + itemclickpos.y = p.y + org.y - l.y; if(p.x > x - 6 && p.x < x + 6) { if(down) Open(l.itemi, !IsOpen(l.itemi)); @@ -758,6 +768,8 @@ void TreeCtrl::DoClick(Point p, dword flags, bool down) else { if(down && IsSel(l.itemi)) { selclick = true; + if(down) + WhenLeftClick(); return; } SetWantFocus(); @@ -780,6 +792,8 @@ void TreeCtrl::DoClick(Point p, dword flags, bool down) } if(cursor != q) WhenAction(); + if(down) + WhenLeftClick(); } } diff --git a/uppsrc/CtrlLib/TreeCtrl.h b/uppsrc/CtrlLib/TreeCtrl.h index ffcf759b6..ca59b98b8 100644 --- a/uppsrc/CtrlLib/TreeCtrl.h +++ b/uppsrc/CtrlLib/TreeCtrl.h @@ -105,6 +105,7 @@ private: Point repoint; int retime; Size treesize; + Point itemclickpos; ScrollBars sb; Scroller scroller; @@ -125,7 +126,7 @@ private: void Scroll(); int FindLine(int y) const; void RefreshLine(int i, int ex = 0); - void RefreshItem(int id, int ex = 0); + void RefreshItem(int id, int ex); void SetCursorLineSync(int i); void MoveCursorLine(int c, int incr); void SetCursorLine(int i, bool sc, bool sel, bool cb); @@ -158,6 +159,7 @@ protected: public: Callback1 WhenOpen; Callback1 WhenClose; + Callback WhenLeftClick; Callback WhenLeftDouble; Callback1 WhenBar; Callback WhenSel; @@ -201,6 +203,9 @@ public: Value operator[](int id) const { return Get(id); } void Set(int id, Value value); void Set(int id, Value key, Value value); + + void SetDisplay(int id, const Display& display); + void RefreshItem(int id) { RefreshItem(id, 0); } int GetLineCount(); int GetItemAtLine(int i); @@ -225,6 +230,8 @@ public: int GetCursor() const; bool IsCursor() const { return GetCursor() >= 0; } + Point GetItemClickPos() const { return itemclickpos; } + Point GetScroll() const; void ScrollTo(Point sc); diff --git a/uppsrc/Esc/Value.cpp b/uppsrc/Esc/Value.cpp index f3f27fd4a..986add934 100644 --- a/uppsrc/Esc/Value.cpp +++ b/uppsrc/Esc/Value.cpp @@ -11,6 +11,7 @@ EscValue EscFromStdValue(const Value& v) switch(v.GetType()) { case BOOL_V: case INT_V: + case INT64_V: case DOUBLE_V: r = (double)v; break; diff --git a/uppsrc/TCore/util.cpp b/uppsrc/TCore/util.cpp index 80155693a..e27691d3b 100644 --- a/uppsrc/TCore/util.cpp +++ b/uppsrc/TCore/util.cpp @@ -1153,6 +1153,21 @@ String GetFileOnSystemPath(const char *file) #endif } +String QuoteCmdArg(const char *arg) +{ + if(!strchr(arg, ' ') && !strchr(arg, '\"')) + return arg; + StringBuffer out; + out.Cat('\"'); + for(; *arg; arg++) { + out.Cat(*arg); + if(*arg == '\"') + out.Cat('\"'); + } + out.Cat('\"'); + return out; +} + const char *FetchCmdArg(const char *arg, int& i) { if(!*arg) { diff --git a/uppsrc/TCore/util.h b/uppsrc/TCore/util.h index 354bb26f3..84a53f5b5 100644 --- a/uppsrc/TCore/util.h +++ b/uppsrc/TCore/util.h @@ -161,6 +161,7 @@ VectorMap LoadKeyMap(const char *p); VectorMap LoadKeyMapFile(const char *filename); const char *FetchCmdArg(const char *arg, int& i); +String QuoteCmdArg(const char *arg); inline void GetIL(int *ip, int count, const byte *data) {