diff --git a/uppdev/ArrayCtrl/ArrayCtrl.upp b/uppdev/ArrayCtrl/ArrayCtrl.upp index 280951725..3c29d5874 100644 --- a/uppdev/ArrayCtrl/ArrayCtrl.upp +++ b/uppdev/ArrayCtrl/ArrayCtrl.upp @@ -4,11 +4,7 @@ uses CtrlLib; file - app.tpp, - ArrayCtrl.h, - main.cpp optimize_speed, - src.tpp, - srcimp.tpp; + main.cpp optimize_speed; mainconfig "" = "GUI"; diff --git a/uppdev/ArrayCtrl/main.cpp b/uppdev/ArrayCtrl/main.cpp index c7a96bc58..5254f27b6 100644 --- a/uppdev/ArrayCtrl/main.cpp +++ b/uppdev/ArrayCtrl/main.cpp @@ -3,78 +3,26 @@ using namespace Upp; struct App : TopWindow { - ArrayCtrl a, b; - Splitter s; - - StatusBar status; - - void DnD(PasteClip& d) - { - if(AcceptText(d)) - a.Add(GetString(d), GetString(d)); + ArrayCtrl a; + + bool Order(int i1, int i2) { + DDUMP(a.Get(i1, 0)); + DDUMP(a.Get(i2, 0)); + return a.Get(i1, 0) < a.Get(i2, 0); } - void DnDInsert(int line, PasteClip& d) - { - if(AcceptInternal(d, "array")) - a.InsertDrop(line, d); - if(AcceptText(d)) { - a.Insert(line); - a.Set(line, 0, GetString(d)); - a.SetCursor(line); - } - } - - void DnDInsertB(int line, PasteClip& d) - { - } - - void Drag() - { - } - - void DragB() - { - } - - void A() - { - Exclamation("LeftDouble"); - Exit(); - } - - void B() - { - Exclamation("LeftClick"); - } - typedef App CLASSNAME; App() { - a.AddColumn("\1Text alsdfjla fdlajd flajd falsjkd fla fals fj").HeaderTab().WhenLeftDouble = THISBACK(A); - a.AddColumn("asdf").HeaderTab().WhenLeftClick = THISBACK(B); - a.MultiSelect(); - a.NoGrid(); - a.WhenDropInsert = THISBACK(DnDInsert); - a.WhenDrop = THISBACK(DnD); - a.WhenDrag = THISBACK(Drag); - a.WhenLeftDouble = THISBACK(A); - a.Removing(); - - b.AddColumn("Text"); - b.MultiSelect(); - b.WhenDropInsert = THISBACK(DnDInsertB); - b.WhenDrag = THISBACK(DragB); + Add(a.SizePos()); + Sizeable().Zoomable(); - Add(s.Horz(a, b)); + a.AddColumn("Test"); for(int i = 0; i < 200; i++) { - a.Add(i); - b.Add(FormatIntRoman(i, true)); - if((i & 3) == 0) - a.AddSeparator(); + a.Add((int)Random(10000)); } - Sizeable(); - AddFrame(status); + // a.Sort(THISBACK(Order)); + a.Sort(); } }; @@ -83,20 +31,3 @@ GUI_APP_MAIN DUMP("Test"); App().Run(); } - - -String HttpResponse(int code, const char *phrase, const String& data, const char *content_type) -{ - String r; - r << - "HTTP/1.0 " << code << ' ' << phrase << "\r\n" - "Date: " << WwwFormat(GetUtcTime()) << "\r\n" - "Server: Centrum-Nos SaleCrm\r\n" - "Content-Length: " << data.GetCount() << "\r\n" - "Connection: close\r\n"; - if(content_type) - r << "Content-Type: text/xml\r\n"; - r << "\r\n" << data; - return r; -} - diff --git a/uppdev/ArrayCtrlSort/main.cpp b/uppdev/ArrayCtrlSort/main.cpp index 34b13736c..5d127e6e1 100644 --- a/uppdev/ArrayCtrlSort/main.cpp +++ b/uppdev/ArrayCtrlSort/main.cpp @@ -4,6 +4,11 @@ class ArrayCtrlSort : public TopWindow { ArrayCtrl a; EditDouble ed1, ed2; + bool SortTest(int i1, int i2) + { + return a.Get(i1, 0) > a.Get(i2, 0); + } + public: typedef ArrayCtrlSort CLASSNAME; ArrayCtrlSort(); @@ -27,7 +32,9 @@ ArrayCtrlSort::ArrayCtrlSort() for(int i = 0; i < 100; i++) a.Add(rand() % 20, rand() % 10); Add(a.SizePos()); - a.ColumnSort(3, StdValueOrder()); +// a.ColumnSort(3, StdValueOrder()); + + a.Sort(10, 40, THISBACK(SortTest)); } GUI_APP_MAIN diff --git a/uppdev/LocalProcess/LocalProcess.cpp b/uppdev/LocalProcess/LocalProcess.cpp index a5c6dc120..5416d4704 100644 --- a/uppdev/LocalProcess/LocalProcess.cpp +++ b/uppdev/LocalProcess/LocalProcess.cpp @@ -5,6 +5,6 @@ using namespace Upp; CONSOLE_APP_MAIN { String out; - Sys("ls /sdf", out); + Sys("c:/xxx/pdftoppm -r 100 \"C:/xxx/smlouva.pdf\" \"C:/xxx/out.ppm\""); DDUMP(out); } diff --git a/uppdev/RichEditTest/todo.txt b/uppdev/RichEditTest/todo.txt index ca2ad5f8a..fafcfd266 100644 --- a/uppdev/RichEditTest/todo.txt +++ b/uppdev/RichEditTest/todo.txt @@ -1,3 +1,4 @@ + - Velke hodnoty grid apod... (collapsed mode) - keep with next nechodi - Equalize columns diff --git a/uppdev/ValuePath/ValuePath.cpp b/uppdev/ValuePath/ValuePath.cpp new file mode 100644 index 000000000..3eb301d03 --- /dev/null +++ b/uppdev/ValuePath/ValuePath.cpp @@ -0,0 +1,97 @@ +#include + +using namespace Upp; + +class Path { + bool index; + Value key; + Value value; + Path *parent; + Value *target; + + Path() { target = NULL; } + +public: + Path operator()(const Value& key); + Path operator[](int i); + void Set(const Value& key, const Value& v, bool ndx); + void operator=(const Value& v) { value = v; parent->Set(key, v, index); } + + Path(Value& v) { target = &v; value = v; parent = NULL; index = false; } +}; + +Path Path::operator()(const Value& k) +{ + Path p; + ValueMap m; + if(IsValueMap(value)) + m = value; + p.parent = this; + p.key = k; +// DLOG("operator()(" << key << ": " << m[key]); + p.value = m.GetAndClear(k); // Optimize! + p.index = false; + return p; +} + +Path Path::operator[](int i) +{ + ASSERT(i >= 0); + Path p; + ValueArray va; + if(IsValueArray(value)) + va = value; + p.parent = this; + p.key = i; + p.index = true; + if(i < va.GetCount()) + p.value = va.GetAndClear(i); + p.index = true; + return p; +} + +void Path::Set(const Value& k, const Value& v, bool ndx) +{ +// DLOG("Set(" << k << ": " << v << "), current key: " << key << ", value: " << value); + if(ndx) { + ValueArray va; + if(IsValueArray(value)) + va = value; + va.Set((int)k, v); + value = va; + } + else { + ValueMap m; + if(IsValueMap(value)) + m = value; + m.Set(k, v); + value = m; + } + if(parent) + parent->Set(key, value, index); + if(target) + *target = value; +} + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_COUT|LOG_FILE); + + Value x; + + Path(x)("hello")("world") = 555; + DUMP(x); + LOG("-------------------"); + Path(x)("hello")("you") = "this"; + DUMP(x); + LOG("-------------------"); + Path(x)("hello")("x") = "y"; + DUMP(x); + LOG("-------------------"); + for(int i = 0; i < 20; i++) + Path(x)("hello")("array")[i] = i; + DUMP(x); +// Path p = Path(x)("hello")("array"); +// for(int i = 0; i < 20; i++) +// p[i] = "*" + AsString(i); +} diff --git a/uppdev/ValuePath/ValuePath.upp b/uppdev/ValuePath/ValuePath.upp new file mode 100644 index 000000000..5eaf675ab --- /dev/null +++ b/uppdev/ValuePath/ValuePath.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + ValuePath.cpp; + +mainconfig + "" = ""; + diff --git a/uppdev/ValuePath/init b/uppdev/ValuePath/init new file mode 100644 index 000000000..912084914 --- /dev/null +++ b/uppdev/ValuePath/init @@ -0,0 +1,4 @@ +#ifndef _ValuePath_icpp_init_stub +#define _ValuePath_icpp_init_stub +#include "Core/init" +#endif