diff --git a/uppdev/ArrayCtrlMT/ArrayCtrlMT.upp b/uppdev/ArrayCtrlMT/ArrayCtrlMT.upp new file mode 100644 index 000000000..78afc12a4 --- /dev/null +++ b/uppdev/ArrayCtrlMT/ArrayCtrlMT.upp @@ -0,0 +1,9 @@ +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI SSE2"; + diff --git a/uppdev/ArrayCtrlMT/main.cpp b/uppdev/ArrayCtrlMT/main.cpp new file mode 100644 index 000000000..c9aeb8664 --- /dev/null +++ b/uppdev/ArrayCtrlMT/main.cpp @@ -0,0 +1,52 @@ +#include + +using namespace Upp; + +struct App : TopWindow { + Thread work; + + void Work(); + + ArrayCtrl list; + + typedef App CLASSNAME; + + App(); + ~App(); +}; + +void App::Work() +{ + for(;;) { + Sleep(1); + GuiLock __; + if(IsShutdownThreads()) + break; + if(list.GetCount() > 10000) { + if(PromptYesNo("Quit?")) { + Break(); + return; + } + list.Clear(); + } + list.Add(AsString((int64)Random()) + String('x', 200)); + } +} + +App::App() +{ + list.AddColumn("Test"); + Add(list.SizePos()); + work.Run(THISBACK(Work)); +} + +App::~App() +{ + ShutdownThreads(); +} + +GUI_APP_MAIN +{ + App app; + app.Run(); +} diff --git a/uppdev/SDL20/SDL20.cpp b/uppdev/SDL20/SDL20.cpp index cba251664..728fd59ed 100644 --- a/uppdev/SDL20/SDL20.cpp +++ b/uppdev/SDL20/SDL20.cpp @@ -16,25 +16,35 @@ int main(int argc, char** argv){ SDLWindow win; win.Create(RectC(100, 100, 1024, 768), "First test"); - bool quit = false; - int i = 0; - while(!quit) { - SDLDraw w; + { + SystemDraw w; w.Set(win); Size sz = Size(1024, 768); w.Init(sz); w.DrawRect(sz, White); -// w.DrawText(10, 10, "Hello world!", Arial(40)); + w.DrawText(10, 10, "Hello world!", Arial(40)); + } + + bool quit = false; + int i = 0; + while(!quit) { + SystemDraw w; + w.Set(win); + Size sz = Size(1024, 768); + w.Init(sz); + w.DrawText(i++, i, "Hello world!", Arial(40)); + +/* // w.DrawImage(300, 300, TestImg::pinkie()); RichText txt = ParseQTF(LoadFile(GetDataFile("text.qtf"))); if(1) { - RTIMING("SDLDraw"); + RTIMING("SystemDraw"); txt.Paint(Zoom(2, 10), w, 0, 0, sz.cx); } - +*/ win.Present(); SDL_Event e; diff --git a/uppdev/SDL20/SDL20.h b/uppdev/SDL20/SDL20.h index eb938e082..f666b5fc7 100644 --- a/uppdev/SDL20/SDL20.h +++ b/uppdev/SDL20/SDL20.h @@ -7,6 +7,8 @@ using namespace Upp; +NAMESPACE_UPP + struct SDLWindow { SDL_Window *win; SDL_Renderer *ren; @@ -23,7 +25,7 @@ struct SDLWindow { ~SDLWindow(); }; -struct SDLDraw : SDraw { +struct SystemDraw : SDraw { SDLWindow *win; virtual void PutImage(Point p, const Image& m, const Rect& src); @@ -31,8 +33,38 @@ struct SDLDraw : SDraw { void Set(SDLWindow& win_); - SDLDraw(); - ~SDLDraw(); + SystemDraw(); + ~SystemDraw(); }; +END_UPP_NAMESPACE + +/* +class BackDraw : public SDLDraw { +public: + virtual bool IsPaintingOp(const Rect& r) const; + +protected: + HBITMAP hbmpold; + HBITMAP hbmp; + + Size size; + Draw *painting; + Point painting_offset; + +public: + void Put(SystemDraw& w, int x, int y); + void Put(SystemDraw& w, Point p) { Put(w, p.x, p.y); } + + void Create(SystemDraw& w, int cx, int cy); + void Create(SystemDraw& w, Size sz) { Create(w, sz.cx, sz.cy); } + void Destroy(); + + void SetPaintingDraw(Draw& w, Point off) { painting = &w; painting_offset = off; } + + BackDraw(); + ~BackDraw(); +}; +*/ + #endif diff --git a/uppdev/SDL20/SDLDraw.cpp b/uppdev/SDL20/SDLDraw.cpp index 1a095aea8..fb2a671e8 100644 --- a/uppdev/SDL20/SDLDraw.cpp +++ b/uppdev/SDL20/SDLDraw.cpp @@ -2,6 +2,8 @@ #define LLOG(x) // DLOG(x) +NAMESPACE_UPP + struct RectSDL { SDL_Rect sr; @@ -19,8 +21,6 @@ struct RectSDL { SDL_Texture *TextureFromImage(SDL_Renderer *renderer, const Image& m) { Size isz = m.GetSize(); - void *pixels; - int pitch; SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, isz.cx, isz.cy); if(texture) { @@ -60,7 +60,7 @@ struct ImageSysDataMaker : LRUCache::Maker { virtual int Make(ImageSysData& object) const { object.Init(renderer, img); return img.GetLength(); } }; -void SDLDraw::PutImage(Point p, const Image& img, const Rect& src) +void SystemDraw::PutImage(Point p, const Image& img, const Rect& src) { if(img.GetLength() == 0 || !win) return; @@ -73,13 +73,13 @@ void SDLDraw::PutImage(Point p, const Image& img, const Rect& src) m.wserial = win->serial; ImageSysData& sd = cache.Get(m); { - RTIMING("SDL_RenderCopy"); - SDL_RenderCopy(win->ren, sd.texture, RectSDL(src), RectSDL(Rect(p, src.GetSize()))); + RTIMING("SDL_RenderCopy"); + SDL_RenderCopy(win->ren, sd.texture, RectSDL(src), RectSDL(Rect(p, src.GetSize()))); } cache.Shrink(4 * 1024 * 768, 1000); // Cache shrink must be after Paint because of PaintOnly! } -void SDLDraw::PutRect(const Rect& r, Color color) +void SystemDraw::PutRect(const Rect& r, Color color) { if(win && !IsNull(color)) { SDL_SetRenderDrawColor(win->ren, color.GetR(), color.GetG(), color.GetB(), 255); // Optimize? @@ -87,16 +87,18 @@ void SDLDraw::PutRect(const Rect& r, Color color) } } -void SDLDraw::Set(SDLWindow& win_) +void SystemDraw::Set(SDLWindow& win_) { win = win_.ren ? &win_ : NULL; } -SDLDraw::SDLDraw() +SystemDraw::SystemDraw() { win = NULL; } -SDLDraw::~SDLDraw() +SystemDraw::~SystemDraw() { } + +END_UPP_NAMESPACE diff --git a/uppdev/SDL20/Window.cpp b/uppdev/SDL20/Window.cpp index 4663ebffc..fbf126374 100644 --- a/uppdev/SDL20/Window.cpp +++ b/uppdev/SDL20/Window.cpp @@ -1,5 +1,7 @@ #include "SDL20.h" +NAMESPACE_UPP + bool SDLWindow::Create(const Rect& rect, const char *title) { win = SDL_CreateWindow(title, rect.left, rect.top, rect.GetWidth(), rect.GetHeight(), @@ -48,3 +50,5 @@ SDLWindow::~SDLWindow() { Destroy(); } + +END_UPP_NAMESPACE \ No newline at end of file diff --git a/uppdev/TcpSocket/TcpSocket.cpp b/uppdev/TcpSocket/TcpSocket.cpp index 0e7de6897..95a35fa6e 100644 --- a/uppdev/TcpSocket/TcpSocket.cpp +++ b/uppdev/TcpSocket/TcpSocket.cpp @@ -2,8 +2,10 @@ using namespace Upp; -CONSOLE_APP_MAIN -{ - +CONSOLE_APP_MAIN { + TcpSocket s; + if(!s.Connect("www.idnessdfg.cz", 12314)) { + DDUMP(s.GetErrorDesc()); + } + DLOG("OK"); } - diff --git a/uppdev/ToolWin/ToolWin.cpp b/uppdev/ToolWin/ToolWin.cpp index 58445517a..00001df3b 100644 --- a/uppdev/ToolWin/ToolWin.cpp +++ b/uppdev/ToolWin/ToolWin.cpp @@ -39,7 +39,9 @@ void ToolWin::FrameLayout(Rect& r) return; } close.Show(); - close.SetFrameRect(r.right - 18, r.top, 16, 16); + int c = GetTitleCy(); + int b = GetBorder(); + close.SetFrameRect(r.right - c - b + 1, r.top + b, c - 1, c - 1); Rect m = GetMargins(); r.left += m.left; r.right -= m.right; @@ -107,12 +109,11 @@ void ToolWin::MouseMove(Point, dword) if(dragdir.x == 1) r.right = minmax(r.right + off.x, r.left + minsz.cx, r.left + maxsz.cx); if(dragdir.y == -1) - r.top = minmax(r.top + off.y, r.bottom - maxsz.cy, r.bottom - maxsz.cy); + r.top = minmax(r.top + off.y, r.bottom - maxsz.cy, r.bottom - minsz.cy); if(dragdir.y == 1) r.bottom = minmax(r.bottom + off.y, r.top + minsz.cy, r.top + maxsz.cy); } SetRect(r); - DDUMP(HasCapture()); } void ToolWin::LeftUp(Point, dword) @@ -182,18 +183,6 @@ Point ToolWin::GetDir(Point p) const return r; } -/* -Size ToolWin::GetMinSize() const -{ - return AddMargins(client ? client->GetMinSize() : Size(0, 0)); -} - -Size ToolWin::GetMaxSize() const -{ - return AddMargins(client ? client->GetMaxSize() : Size(99999, 99999)); -} -*/ - void ToolWin::SetClientRect(Rect r) { Rect m = GetMargins(); @@ -241,6 +230,7 @@ ToolWin::ToolWin() close.Image(CtrlImg::cross()); close <<= THISBACK(DoClose); AddFrame(*this); + Sizeable(); FrameLess(); }