From ca7e60660ff253166b2742893db1efd3df010134 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 28 Aug 2013 11:43:07 +0000 Subject: [PATCH] Draw: support for LinuxGL, Sql: operator*=(VectorMap, SqlSelect) git-svn-id: svn://ultimatepp.org/upp/trunk@6283 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/Win32Wnd.cpp | 18 +++++++++++++++++- uppsrc/Draw/Cham.cpp | 10 +++++++--- uppsrc/Draw/Draw.h | 2 +- uppsrc/Draw/DrawText.cpp | 10 +++++----- uppsrc/Draw/DrawUtil.cpp | 2 +- uppsrc/Draw/Font.cpp | 4 ---- uppsrc/Draw/FontWin32.cpp | 4 ++-- uppsrc/Sql/Sqls.h | 10 ++++++++++ 8 files changed, 43 insertions(+), 17 deletions(-) diff --git a/uppsrc/CtrlCore/Win32Wnd.cpp b/uppsrc/CtrlCore/Win32Wnd.cpp index 2066a9339..b1ae22092 100644 --- a/uppsrc/CtrlCore/Win32Wnd.cpp +++ b/uppsrc/CtrlCore/Win32Wnd.cpp @@ -8,7 +8,7 @@ NAMESPACE_UPP #define LOGTIMING 0 #ifdef _DEBUG -#define LOGMESSAGES 0 +// #define LOGMESSAGES 1 #endif #define ELOGW(x) // RLOG(GetSysTime() << ": " << x) // Only activate in MT! @@ -761,6 +761,22 @@ void Ctrl::sProcessMSG(MSG& msg) if(msg.message != WM_SYSKEYDOWN && msg.message != WM_SYSKEYUP || PassWindowsKey((dword)msg.wParam) || msg.wParam == VK_MENU) //17.11 Mirek - fix to get windows menu invoked on Alt+Space TranslateMessage(&msg); // 04/09/07: TRC fix to make barcode reader going better + +#if 0 + DDUMP(msg.hwnd); + for(WinMsg *m = sWinMsg; m->ID; m++) + if(m->ID == msg.message) { + RLOG(m->name << ' ' << + Sprintf(", wParam = %d (0x%x), lParam = %d (0x%x)", + msg.wParam, msg.wParam, msg.lParam, msg.lParam)); + break; + } + + char cls[200]; + GetClassName(msg.hwnd, cls, 200); + DDUMP(cls); +#endif + if(IsWindowUnicode(msg.hwnd)) DispatchMessageW(&msg); else diff --git a/uppsrc/Draw/Cham.cpp b/uppsrc/Draw/Cham.cpp index bc6023f6d..1a44ba62d 100644 --- a/uppsrc/Draw/Cham.cpp +++ b/uppsrc/Draw/Cham.cpp @@ -56,7 +56,7 @@ void ChDraw(Draw& w, int x, int y, int cx, int cy, const Image& img, const Rect { LTIMING("ChDraw"); if(cx > 0 && cy > 0) { - #ifdef flagWINGL + #if defined(flagWINGL) || defined(flagLINUXGL) w.DrawImage(x, y, cx, cy, img, src); #else ChImageMaker m; @@ -253,7 +253,11 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) } if(op == LOOK_PAINT || op == LOOK_PAINTEDGE) { LTIMING("ChPaint Image"); + #if defined(flagWINGL) || defined(flagLINUXGL) + w.Offset(r.TopLeft()); + #else w.Clipoff(r); + #endif Rect sr(p, p2); Size sz2(isz.cx - sr.right, isz.cy - sr.bottom); Rect r = RectC(p.x, p.y, sz.cx - sr.left - sz2.cx, sz.cy - sr.top - sz2.cy); @@ -274,7 +278,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) ChDraw(w, r.right, p.y, sz2.cx, r.Height(), img, RectC(sr.right, p.y, sz2.cx, sr.Height())); if(op == LOOK_PAINT) { - if(IsNull(r) || IsNull(sr)) { + if(IsNull(r) || IsNull(sr)) { w.End(); return 1; } @@ -284,7 +288,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) Size sz; sz.cx = (tile & 1 ? sr : r).GetWidth(); sz.cy = (tile & 2 ? sr : r).GetHeight(); - #ifdef flagWINGL + #if defined(flagWINGL) || defined(flagLINUXGL) DrawTiles(w, r, img, sz, sr); #else img = Rescale(img, sz, sr); diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index 092720a85..c60065f8d 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -818,7 +818,7 @@ void AddRefreshRect(Vector& invalid, const Rect& _r); void DrawRect(Draw& w, const Rect& rect, const Image& img, bool ralgn = false); //??? TODO void DrawRect(Draw& w, int x, int y, int cx, int cy, const Image& img, bool ra = false); -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img, const Size& isz, const Rect& src); void DrawTiles(Draw& w, const Rect& rect, const Image& img, const Size& isz, const Rect& src); #endif diff --git a/uppsrc/Draw/DrawText.cpp b/uppsrc/Draw/DrawText.cpp index 960d648f5..48ed80c30 100644 --- a/uppsrc/Draw/DrawText.cpp +++ b/uppsrc/Draw/DrawText.cpp @@ -2,9 +2,9 @@ NAMESPACE_UPP -#ifdef flagWINGL -#include -#include +#if defined(flagWINGL) || defined(flagLINUXGL) +#include +#include #endif #define LLOG(x) // LOG(x) @@ -31,7 +31,7 @@ WString TextUnicode(const char *s, int n, byte cs, Font font) void Draw::DrawText(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx) { -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) if(IsNull(ink)) return; DrawTextOp(x, y, angle, text, font, ink, n, dx); @@ -221,7 +221,7 @@ void Draw::DrawText(int x, int y, const String& text, Font font, Color ink, cons Size GetTextSize(const wchar *text, Font font, int n) { -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) return GetTextSize(text, resources.GetFont(font), n); #else FontInfo fi = font.Info(); diff --git a/uppsrc/Draw/DrawUtil.cpp b/uppsrc/Draw/DrawUtil.cpp index 5a3494e7a..971e6dcdc 100644 --- a/uppsrc/Draw/DrawUtil.cpp +++ b/uppsrc/Draw/DrawUtil.cpp @@ -329,7 +329,7 @@ void DrawRect(Draw& w, const Rect& rect, const Image& img, bool ralgn) DrawRect(w, rect.left, rect.top, rect.Width(), rect.Height(), img, ralgn); } -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img, const Size& isz, const Rect& src) { w.Clip(x, y, cx, cy); Size sz = isz; diff --git a/uppsrc/Draw/Font.cpp b/uppsrc/Draw/Font.cpp index b43016b0d..05242e14d 100644 --- a/uppsrc/Draw/Font.cpp +++ b/uppsrc/Draw/Font.cpp @@ -139,9 +139,6 @@ void Font::InitStdFont() int height = 0; GetStdFontSys(name, height); #ifdef PLATFORM_WIN32 -#ifdef flagWINGL - AStdFont = Font(FindFaceNameIndex("Tahoma"), 12); -#else int q = FindFaceNameIndex(name); if(q <= 0) q = FindFaceNameIndex("Tahoma"); @@ -151,7 +148,6 @@ void Font::InitStdFont() q = FindFaceNameIndex("MS Sans Serif"); if(q > 0) AStdFont = Font(q, max(height, 1)); -#endif SyncStdFont(); #endif } diff --git a/uppsrc/Draw/FontWin32.cpp b/uppsrc/Draw/FontWin32.cpp index 7b2849c2d..9ab7ef109 100644 --- a/uppsrc/Draw/FontWin32.cpp +++ b/uppsrc/Draw/FontWin32.cpp @@ -246,8 +246,8 @@ Vector GetAllFacesSys() #define GLYPHINFOCACHE 31 #ifdef flagWINGL -#include -#include +#include +#include GlyphInfo GetGlyphInfoSys(Font font, int chr) { static GlyphInfo gi; diff --git a/uppsrc/Sql/Sqls.h b/uppsrc/Sql/Sqls.h index 1b1829741..80a270540 100644 --- a/uppsrc/Sql/Sqls.h +++ b/uppsrc/Sql/Sqls.h @@ -499,6 +499,16 @@ void SqlLoadColumn(T& t, SqlId table, SqlId column, SqlId key = SqlId("ID")) t.Add(sql[key], sql[column]); } +template +void operator*=(VectorMap& map, SqlSelect select) +{ + map.Clear(); + Sql sql; + sql * select; + while(sql.Fetch()) + map.Add(sql[0], sql[1]); +} + // Deprecated, use SqlPerformScript instead struct StdStatementExecutor : StatementExecutor { StdStatementExecutor(SqlSession& session) : cursor(session) {}