mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
.Removing Turtle from rainbow
git-svn-id: svn://ultimatepp.org/upp/trunk@6919 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2b496c6177
commit
888f1b187a
56 changed files with 0 additions and 7679 deletions
|
|
@ -1,46 +0,0 @@
|
|||
class ViewDraw : public SystemDraw {
|
||||
public:
|
||||
ViewDraw(Ctrl *ctrl);
|
||||
~ViewDraw();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
class ViewDraw : public SystemDraw {
|
||||
Vector<Rect> dummy;
|
||||
public:
|
||||
ViewDraw(Ctrl *) : SystemDraw(Ctrl::framebuffer, dummy) { dummy.Add(Rect(10, 10, 100, 100)); }
|
||||
};
|
||||
*/
|
||||
class DHCtrl : Ctrl {};
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_(); \
|
||||
\
|
||||
extern "C" int main(int argc, const char **argv, const char **envptr) { \
|
||||
UPP::AppInitEnvironment__(); \
|
||||
UPP::Ctrl::InitTelpp(); \
|
||||
GuiMainFn_(); \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_(); \
|
||||
\
|
||||
extern "C" int main(int argc, const char **argv, const char **envptr) { \
|
||||
UPP::AppInit__(argc, argv, envptr); \
|
||||
UPP::Ctrl::InitTelpp(); \
|
||||
GuiMainFn_(); \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
#endif
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void ChSysInit()
|
||||
{
|
||||
CtrlImg::Reset();
|
||||
CtrlsImg::Reset();
|
||||
ChReset();
|
||||
}
|
||||
|
||||
void ChHostSkin()
|
||||
{
|
||||
ChSysInit();
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,238 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
|
||||
static VectorMap<String, ClipData> fbClipboard;
|
||||
|
||||
void ClearClipboard()
|
||||
{
|
||||
GuiLock __;
|
||||
fbClipboard.Clear();
|
||||
}
|
||||
|
||||
void AppendClipboard(const char *format, const Value& data, String (*render)(const Value&))
|
||||
{
|
||||
GuiLock __;
|
||||
ClipData& cd = fbClipboard.GetAdd(format);
|
||||
cd.data = data;
|
||||
cd.render = render;
|
||||
}
|
||||
|
||||
static String sRawRender(const Value& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
void AppendClipboard(const char *format, const String& data)
|
||||
{
|
||||
GuiLock __;
|
||||
AppendClipboard(format, data, sRawRender);
|
||||
}
|
||||
|
||||
void AppendClipboard(const char *format, const byte *data, int length)
|
||||
{
|
||||
GuiLock __;
|
||||
AppendClipboard(format, String(data, length));
|
||||
}
|
||||
|
||||
String ReadClipboard(const char *format)
|
||||
{
|
||||
GuiLock __;
|
||||
int q = fbClipboard.Find(format);
|
||||
return q >= 0 ? (*fbClipboard[q].render)(fbClipboard[q].data) : String();
|
||||
}
|
||||
|
||||
void AppendClipboardText(const String& s)
|
||||
{
|
||||
AppendClipboard("text", ToSystemCharset(s));
|
||||
}
|
||||
|
||||
void AppendClipboardUnicodeText(const WString& s)
|
||||
{
|
||||
AppendClipboard("wtext", (byte *)~s, 2 * s.GetLength());
|
||||
}
|
||||
|
||||
const char *ClipFmtsText()
|
||||
{
|
||||
return "wtext;text";
|
||||
}
|
||||
|
||||
String GetString(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
if(clip.Accept("wtext")) {
|
||||
String s = ~clip;
|
||||
return WString((const wchar *)~s, wstrlen((const wchar *)~s)).ToString();
|
||||
}
|
||||
if(clip.IsAvailable("text"))
|
||||
return ~clip;
|
||||
return Null;
|
||||
}
|
||||
|
||||
WString GetWString(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
if(clip.Accept("wtext")) {
|
||||
String s = ~clip;
|
||||
return WString((const wchar *)~s, wstrlen((const wchar *)~s));
|
||||
}
|
||||
if(clip.IsAvailable("text"))
|
||||
return (~clip).ToWString();
|
||||
return Null;
|
||||
}
|
||||
|
||||
|
||||
bool AcceptText(PasteClip& clip)
|
||||
{
|
||||
return clip.Accept(ClipFmtsText());
|
||||
}
|
||||
|
||||
static String sText(const Value& data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
static String sWText(const Value& data)
|
||||
{
|
||||
return Unicode__(WString(data));
|
||||
}
|
||||
|
||||
void Append(VectorMap<String, ClipData>& data, const String& text)
|
||||
{
|
||||
data.GetAdd("text", ClipData(text, sText));
|
||||
data.GetAdd("wtext", ClipData(text, sWText));
|
||||
}
|
||||
|
||||
void Append(VectorMap<String, ClipData>& data, const WString& text)
|
||||
{
|
||||
data.GetAdd("text", ClipData(text, sText));
|
||||
data.GetAdd("wtext", ClipData(text, sWText));
|
||||
}
|
||||
|
||||
String GetTextClip(const WString& text, const String& fmt)
|
||||
{
|
||||
if(fmt == "text")
|
||||
return text.ToString();
|
||||
if(fmt == "wtext")
|
||||
return Unicode__(text);
|
||||
return Null;
|
||||
}
|
||||
|
||||
String GetTextClip(const String& text, const String& fmt)
|
||||
{
|
||||
if(fmt == "text")
|
||||
return text;
|
||||
if(fmt == "wtext")
|
||||
return Unicode__(text.ToWString());
|
||||
return Null;
|
||||
}
|
||||
|
||||
String ReadClipboardText()
|
||||
{
|
||||
String w = ReadClipboard("text");
|
||||
return w.GetCount() ? w : ReadClipboardUnicodeText().ToString();
|
||||
}
|
||||
|
||||
WString ReadClipboardUnicodeText()
|
||||
{
|
||||
String w = ReadClipboard("wtext");
|
||||
if(w.GetCount())
|
||||
return WString((const wchar *)~w, w.GetLength() / 2);
|
||||
return ReadClipboard("text").ToWString();
|
||||
}
|
||||
|
||||
bool IsClipboardAvailable(const char *id)
|
||||
{
|
||||
return fbClipboard.Find(id) >= 0;
|
||||
}
|
||||
|
||||
bool IsClipboardAvailableText()
|
||||
{
|
||||
return IsClipboardAvailable("text") || IsClipboardAvailable("wtext");
|
||||
}
|
||||
|
||||
const char *ClipFmtsImage()
|
||||
{
|
||||
static const char *q;
|
||||
ONCELOCK {
|
||||
static String s = "dib;" + ClipFmt<Image>();
|
||||
q = s;
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
bool AcceptImage(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
return clip.Accept(ClipFmtsImage());
|
||||
}
|
||||
|
||||
Image GetImage(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
Image m;
|
||||
if(Accept<Image>(clip)) {
|
||||
LoadFromString(m, ~clip);
|
||||
if(!m.IsEmpty())
|
||||
return m;
|
||||
}
|
||||
return Null;
|
||||
}
|
||||
|
||||
Image ReadClipboardImage()
|
||||
{
|
||||
GuiLock __;
|
||||
PasteClip d = Ctrl::Clipboard();
|
||||
return GetImage(d);
|
||||
}
|
||||
|
||||
String sImage(const Value& image)
|
||||
{
|
||||
Image img = image;
|
||||
return StoreAsString(const_cast<Image&>(img));
|
||||
}
|
||||
|
||||
String GetImageClip(const Image& img, const String& fmt)
|
||||
{
|
||||
GuiLock __;
|
||||
if(img.IsEmpty()) return Null;
|
||||
if(fmt == ClipFmt<Image>())
|
||||
return sImage(img);
|
||||
return Null;
|
||||
}
|
||||
|
||||
void AppendClipboardImage(const Image& img)
|
||||
{
|
||||
GuiLock __;
|
||||
if(img.IsEmpty()) return;
|
||||
AppendClipboard(ClipFmt<Image>(), img, sImage);
|
||||
}
|
||||
|
||||
bool AcceptFiles(PasteClip& clip)
|
||||
{
|
||||
if(clip.Accept("files")) {
|
||||
clip.SetAction(DND_COPY);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsAvailableFiles(PasteClip& clip)
|
||||
{
|
||||
return clip.IsAvailable("files");
|
||||
}
|
||||
|
||||
Vector<String> GetFiles(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
Vector<String> f;
|
||||
return f;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
#define LLOG(x) // DLOG(x)
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void Ctrl::GuiPlatformConstruct()
|
||||
{
|
||||
}
|
||||
|
||||
void Ctrl::GuiPlatformRemove()
|
||||
{
|
||||
}
|
||||
|
||||
void Ctrl::GuiPlatformGetTopRect(Rect& r) const
|
||||
{
|
||||
}
|
||||
|
||||
bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect& r)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ctrl::GuiPlatformSetFullRefreshSpecial()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ctrl::PaintCaret(SystemDraw& w)
|
||||
{
|
||||
}
|
||||
|
||||
String GuiPlatformGetKeyDesc(dword key)
|
||||
{
|
||||
return Null;
|
||||
}
|
||||
|
||||
void Ctrl::GuiPlatformSelection(PasteClip&)
|
||||
{
|
||||
}
|
||||
|
||||
void GuiPlatformAdjustDragImage(ImageBuffer&)
|
||||
{
|
||||
}
|
||||
|
||||
bool GuiPlatformHasSizeGrip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiPlatformGripResize(TopWindow *q)
|
||||
{
|
||||
q->GripResize();
|
||||
}
|
||||
|
||||
Color GuiPlatformGetScreenPixel(int x, int y)
|
||||
{
|
||||
return Null;
|
||||
}
|
||||
|
||||
void GuiPlatformAfterMenuPopUp()
|
||||
{
|
||||
}
|
||||
|
||||
String Ctrl::Name() const {
|
||||
GuiLock __;
|
||||
#ifdef CPU_64
|
||||
String s = String(typeid(*this).name()) + " : 0x" + FormatIntHex(this);
|
||||
#else
|
||||
String s = String(typeid(*this).name()) + " : " + Format("0x%x", (int) this);
|
||||
#endif
|
||||
if(IsChild())
|
||||
s << "(parent " << String(typeid(*parent).name()) << ")";
|
||||
return s;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
//$ class Ctrl {
|
||||
private:
|
||||
static Ptr<Ctrl> desktop;
|
||||
static Vector<Ctrl *> topctrl;
|
||||
static bool invalid;
|
||||
|
||||
static Point fbCursorPos;
|
||||
static Image fbCursorImage;
|
||||
static bool sdlMouseIsIn;
|
||||
|
||||
static Rect fbCaretRect;
|
||||
static int fbCaretTm;
|
||||
|
||||
static bool fbEndSession;
|
||||
static int64 fbEventLoop;
|
||||
static int64 fbEndSessionLoop;
|
||||
|
||||
static void CursorSync();
|
||||
|
||||
int FindTopCtrl() const;
|
||||
static Rect GetClipBound(const Vector<Rect>& inv, const Rect& r);
|
||||
static void DoPaint();
|
||||
static void SyncTopWindows();
|
||||
|
||||
// static void AddInvalid(const Rect& rect);
|
||||
|
||||
void DestroyWnd();
|
||||
|
||||
void NewTop() { top = new Top; top->owner_window = NULL; }
|
||||
void PutForeground();
|
||||
static void MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta);
|
||||
|
||||
static void DrawLine(const Vector<Rect>& clip, int x, int y, int cx, int cy, bool horz,
|
||||
const byte *pattern, int animation);
|
||||
static void DragRectDraw0(const Vector<Rect>& clip, const Rect& rect, int n,
|
||||
const byte *pattern, int animation);
|
||||
|
||||
static void ReadKeyMods(CParser& p);
|
||||
static void DoMouseButton(int event, CParser& p);
|
||||
|
||||
static void DoMouseFB(int event, Point p, int zdelta, CParser& cp);
|
||||
|
||||
static void TimerAndPaint();
|
||||
|
||||
friend struct PaintProxy__;
|
||||
friend class TopWindowFrame;
|
||||
friend class SystemDraw;
|
||||
friend struct DnDLoop;
|
||||
|
||||
void SetOpen(bool b) { isopen = b; }
|
||||
|
||||
protected:
|
||||
static int PaintLock;
|
||||
|
||||
static void ProcessEvent(const String& event);
|
||||
|
||||
public:
|
||||
static bool DoKeyFB(dword key, int cnt);
|
||||
|
||||
static void InitTelpp(const String& hostname);
|
||||
|
||||
static void Connect();
|
||||
|
||||
static void Exit();
|
||||
|
||||
static void EndSession();
|
||||
|
||||
static void SetDesktop(Ctrl& q);
|
||||
static Ctrl *GetDesktop() { return desktop; }
|
||||
static void SetDesktopSize(Size sz);
|
||||
|
||||
static void Invalidate() { invalid = true; }
|
||||
|
||||
void DragRectDraw(const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, int type, int animation);
|
||||
|
||||
static Ctrl *FindMouseTopCtrl();
|
||||
|
||||
static void PaintScene(SystemDraw& draw);
|
||||
static void PaintCaretCursor(SystemDraw& draw);
|
||||
|
||||
static bool SystemCursor;
|
||||
|
||||
enum { DRAWDRAGRECT_SCREEN = 0x8000 };
|
||||
//$ };
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) LOG(x)
|
||||
#define LDUMP(x) //DDUMP(x)
|
||||
|
||||
void Ctrl::SetMouseCursor(const Image& image)
|
||||
{
|
||||
GuiLock __;
|
||||
if(image.GetSerialId() != fbCursorImage.GetSerialId()) {
|
||||
fbCursorImage = image;
|
||||
fbCursorPos = Null;
|
||||
_TODO_
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // DLOG(x)
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
Ptr<Ctrl> sDnDSource;
|
||||
|
||||
Ctrl * Ctrl::GetDragAndDropSource()
|
||||
{
|
||||
return sDnDSource;
|
||||
}
|
||||
|
||||
struct DnDLoop : LocalLoop {
|
||||
const VectorMap<String, ClipData> *data;
|
||||
Vector<String> fmts;
|
||||
|
||||
Image move, copy, reject;
|
||||
Ptr<Ctrl> target;
|
||||
int action;
|
||||
byte actions;
|
||||
|
||||
void Sync();
|
||||
String GetData(const String& f);
|
||||
void DnD(bool paste);
|
||||
|
||||
virtual void LeftUp(Point, dword);
|
||||
virtual bool Key(dword, int);
|
||||
virtual void MouseMove(Point p, dword);
|
||||
virtual Image CursorImage(Point, dword);
|
||||
};
|
||||
|
||||
Ptr<DnDLoop> dndloop;
|
||||
|
||||
bool PasteClip::IsAvailable(const char *fmt) const
|
||||
{
|
||||
GuiLock __;
|
||||
return dnd ? dndloop && FindIndex(dndloop->fmts, fmt) >= 0
|
||||
: IsClipboardAvailable(fmt);
|
||||
}
|
||||
|
||||
String DnDLoop::GetData(const String& f)
|
||||
{
|
||||
GuiLock __;
|
||||
int i = data->Find(f);
|
||||
String d;
|
||||
if(i >= 0)
|
||||
d = (*data)[i].Render();
|
||||
else
|
||||
if(sDnDSource)
|
||||
d = sDnDSource->GetDropData(f);
|
||||
return d;
|
||||
}
|
||||
|
||||
String PasteClip::Get(const char *fmt) const
|
||||
{
|
||||
return dnd ? dndloop ? dndloop->GetData(fmt) : String() : ReadClipboard(fmt);
|
||||
}
|
||||
|
||||
void PasteClip::GuiPlatformConstruct()
|
||||
{
|
||||
dnd = false;
|
||||
}
|
||||
|
||||
void DnDLoop::DnD(bool paste)
|
||||
{
|
||||
PasteClip d;
|
||||
d.paste = paste;
|
||||
d.accepted = false;
|
||||
d.allowed = (byte)actions;
|
||||
d.action = GetCtrl() ? DND_COPY : DND_MOVE;
|
||||
d.dnd = true;
|
||||
if(target)
|
||||
target->DnD(GetMousePos(), d);
|
||||
action = d.IsAccepted() ? d.GetAction() : DND_NONE;
|
||||
}
|
||||
|
||||
void DnDLoop::Sync()
|
||||
{
|
||||
GuiLock __;
|
||||
Ptr<Ctrl> t = FindMouseTopCtrl();
|
||||
if(t != target)
|
||||
if(target)
|
||||
target->DnDLeave();
|
||||
target = t;
|
||||
DnD(false);
|
||||
}
|
||||
|
||||
void DnDLoop::LeftUp(Point, dword)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("DnDLoop::LeftUp");
|
||||
DnD(true);
|
||||
EndLoop();
|
||||
}
|
||||
|
||||
void DnDLoop::MouseMove(Point p, dword)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("DnDLoop::MouseMove");
|
||||
Sync();
|
||||
}
|
||||
|
||||
bool DnDLoop::Key(dword, int)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("DnDLoop::Key");
|
||||
Sync();
|
||||
return false;
|
||||
}
|
||||
|
||||
Image DnDLoop::CursorImage(Point, dword)
|
||||
{
|
||||
GuiLock __;
|
||||
return action == DND_MOVE ? move : action == DND_COPY ? copy : reject;
|
||||
}
|
||||
|
||||
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
|
||||
const VectorMap<String, ClipData>& data)
|
||||
{
|
||||
GuiLock __;
|
||||
DnDLoop d;
|
||||
d.actions = (byte)actions;
|
||||
d.reject = actions & DND_EXACTIMAGE ? CtrlCoreImg::DndNone() : MakeDragImage(CtrlCoreImg::DndNone(), sample);
|
||||
if(actions & DND_COPY)
|
||||
d.copy = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndCopy(), sample);
|
||||
if(actions & DND_MOVE)
|
||||
d.move = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndMoveX11(), sample);
|
||||
d.SetMaster(*this);
|
||||
d.data = &data;
|
||||
d.action = DND_NONE;
|
||||
d.fmts = Split(fmts, ';');
|
||||
dndloop = &d;
|
||||
sDnDSource = this;
|
||||
d.Run();
|
||||
sDnDSource = NULL;
|
||||
SyncCaret();
|
||||
LLOG("DoDragAndDrop finished");
|
||||
return d.action;
|
||||
}
|
||||
|
||||
void Ctrl::SetSelectionSource(const char *fmts) {}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
struct DrawDragRectInfo {
|
||||
Rect rect1, rect2, clip;
|
||||
int n;
|
||||
int type;
|
||||
int animation;
|
||||
};
|
||||
|
||||
void DrawDragLine(SystemDraw& w, bool horz, int x, int y, int len, int n, const int *pattern, int animation)
|
||||
{
|
||||
if(len <= 0)
|
||||
return;
|
||||
if(horz)
|
||||
w.Clip(x, y, len, n);
|
||||
else
|
||||
w.Clip(x, y, n, len);
|
||||
|
||||
(horz ? x : y) -= animation;
|
||||
len += animation;
|
||||
bool ch = false;
|
||||
while(len > 0) {
|
||||
int segment = pattern[ch];
|
||||
int d = segment + pattern[2];
|
||||
if(horz) {
|
||||
w.DrawRect(x, y, segment, n, InvertColor());
|
||||
x += d;
|
||||
}
|
||||
else {
|
||||
w.DrawRect(x, y, n, segment, InvertColor());
|
||||
y += d;
|
||||
}
|
||||
len -= d;
|
||||
ch = !ch;
|
||||
}
|
||||
w.End();
|
||||
}
|
||||
|
||||
void DrawDragFrame(SystemDraw& w, const Rect& r, int n, const int *pattern, int animation)
|
||||
{
|
||||
DrawDragLine(w, true, r.left, r.top, r.GetWidth(), n, pattern, animation);
|
||||
DrawDragLine(w, false, r.left, r.top + n, r.GetHeight() - 2 * n, n, pattern, animation);
|
||||
DrawDragLine(w, false, r.right - n, r.top + n, r.GetHeight() - 2 * n, n, pattern, animation);
|
||||
DrawDragLine(w, true, r.left, r.bottom - n, r.GetWidth(), n, pattern, animation);
|
||||
}
|
||||
|
||||
void DrawDragRect(Ctrl& q, const DrawDragRectInfo& f)
|
||||
{
|
||||
_TODO_
|
||||
SystemDraw w;
|
||||
Ctrl::PaintScene(w);
|
||||
w.Clip(f.clip);
|
||||
static int dashes[3][3] = {
|
||||
{ 32, 32, 0 },
|
||||
{ 1, 1, 1 },
|
||||
{ 5, 1, 2 },
|
||||
};
|
||||
const int *dash = dashes[minmax(f.type, 0, 2)];
|
||||
DrawDragFrame(w, f.rect1, f.n, dash, f.animation);
|
||||
DrawDragFrame(w, f.rect2, f.n, dash, f.animation);
|
||||
// w.End();
|
||||
Ctrl::PaintCaretCursor(w);
|
||||
// SDL_GL_SwapWindow(screen.win);
|
||||
}
|
||||
|
||||
void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, int type, int animation)
|
||||
{
|
||||
Ctrl *top = q.GetTopCtrl();
|
||||
if(top) {
|
||||
Point off = q.GetScreenView().TopLeft();
|
||||
DrawDragRectInfo f;
|
||||
f.rect1 = rect1.Offseted(off);
|
||||
f.rect2 = rect2.Offseted(off);
|
||||
f.clip = (clip & q.GetSize()).Offseted(off);
|
||||
f.n = n;
|
||||
f.type = type;
|
||||
f.animation = animation;
|
||||
DrawDragRect(*top, f);
|
||||
}
|
||||
}
|
||||
|
||||
void FinishDragRect(Ctrl& q)
|
||||
{
|
||||
SystemDraw w;
|
||||
Ctrl::PaintScene(w);
|
||||
Ctrl::PaintCaretCursor(w);
|
||||
_TODO_
|
||||
//SDL_GL_SwapWindow(screen.win);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,478 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#include "Telpp.brc"
|
||||
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // DLOG(x)
|
||||
#define LDUMP(x) // DDUMP(x)
|
||||
#define LTIMING(x)
|
||||
|
||||
static Point MousePos;
|
||||
|
||||
TcpSocket server;
|
||||
TcpSocket socket;
|
||||
|
||||
Size DesktopSize = Size(1000, 1000);
|
||||
|
||||
StaticRect& Desktop()
|
||||
{
|
||||
static StaticRect x;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
void Ctrl::InitTelpp()
|
||||
{
|
||||
if(!server.Listen(8000, 10)) {
|
||||
LOG("Cannot open server port for listening\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Ctrl::GlobalBackBuffer();
|
||||
Ctrl::InitTimer();
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
SetStdFont(ScreenSans(12)); //FIXME general handling
|
||||
#endif
|
||||
ChStdSkin();
|
||||
|
||||
Desktop().Color(Cyan());
|
||||
Desktop().SetRect(0, 0, DesktopSize.cx, DesktopSize.cy);
|
||||
SetDesktop(Desktop());
|
||||
}
|
||||
|
||||
Point GetMousePos() {
|
||||
return MousePos;
|
||||
}
|
||||
|
||||
dword lastbdowntime[8] = {0};
|
||||
dword isdblclick[8] = {0};
|
||||
|
||||
void Ctrl::MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta)
|
||||
{
|
||||
if(!t->IsEnabled())
|
||||
return;
|
||||
Rect rr = t->GetRect();
|
||||
if((event & Ctrl::ACTION) == DOWN) {
|
||||
Ptr<Ctrl> q = t;
|
||||
TopWindowFrame *wf = dynamic_cast<TopWindowFrame *>(~t);
|
||||
if(wf)
|
||||
q = wf->window;
|
||||
if(q) q->ClickActivateWnd();
|
||||
if(q) q->SetForeground();
|
||||
if(ignoreclick)
|
||||
return;
|
||||
}
|
||||
if(t)
|
||||
t->DispatchMouse(event, p - rr.TopLeft(), zdelta);
|
||||
if(t)
|
||||
t->PostInput();
|
||||
}
|
||||
|
||||
Ctrl *Ctrl::FindMouseTopCtrl()
|
||||
{
|
||||
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
||||
Ctrl *t = topctrl[i];
|
||||
if(t->GetRect().Contains(MousePos))
|
||||
return t->IsEnabled() ? t : NULL;
|
||||
}
|
||||
return desktop->IsEnabled() ? desktop : NULL;
|
||||
}
|
||||
|
||||
void Ctrl::SetCaret(int x, int y, int cx, int cy)
|
||||
{
|
||||
GuiLock __;
|
||||
caretx = x;
|
||||
carety = y;
|
||||
caretcx = cx;
|
||||
caretcy = cy;
|
||||
fbCaretTm = GetTickCount();
|
||||
SyncCaret();
|
||||
}
|
||||
|
||||
void Ctrl::SyncCaret()
|
||||
{
|
||||
CursorSync();
|
||||
}
|
||||
|
||||
void Ctrl::CursorSync()
|
||||
{
|
||||
// LLOG("@ CursorSync");
|
||||
Point p = GetMousePos() - fbCursorImage.GetHotSpot();
|
||||
Rect cr = Null;
|
||||
if(focusCtrl && (((GetTickCount() - fbCaretTm) / 500) & 1) == 0)
|
||||
cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy)
|
||||
+ focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView();
|
||||
if(fbCursorPos != p && !SystemCursor || cr != fbCaretRect) {
|
||||
fbCaretRect = cr;
|
||||
fbCursorPos = p;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
String content;
|
||||
|
||||
void Ctrl::PaintScene(SystemDraw& draw)
|
||||
{
|
||||
if(!desktop)
|
||||
return;
|
||||
LLOG("@ DoPaint");
|
||||
LTIMING("DoPaint paint");
|
||||
draw.Init(DesktopSize);
|
||||
draw.Begin();
|
||||
Vector<Rect> invalid;
|
||||
invalid.Add(DesktopSize); _TODO_
|
||||
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
||||
Rect r = topctrl[i]->GetRect();
|
||||
Rect ri = GetClipBound(invalid, r);
|
||||
if(!IsNull(ri)) {
|
||||
draw.Clipoff(r);
|
||||
topctrl[i]->UpdateArea(draw, ri - r.TopLeft());
|
||||
draw.End();
|
||||
Subtract(invalid, r);
|
||||
draw.ExcludeClip(r);
|
||||
}
|
||||
}
|
||||
Rect ri = GetClipBound(invalid, desktop->GetRect().GetSize());
|
||||
if(!IsNull(ri))
|
||||
desktop->UpdateArea(draw, ri);
|
||||
draw.End();
|
||||
}
|
||||
|
||||
void Ctrl::PaintCaretCursor(SystemDraw& draw)
|
||||
{
|
||||
if(!IsNull(fbCaretRect))
|
||||
draw.DrawRect(fbCaretRect, InvertColor);
|
||||
int64 q = fbCursorImage.GetAuxData();
|
||||
if(q) {
|
||||
draw.Put8(SystemDraw::STD_CURSORIMAGE);
|
||||
draw.Put8(clamp((int)q, 1, 16));
|
||||
}
|
||||
else {
|
||||
String h;
|
||||
Point p = fbCursorImage.GetHotSpot();
|
||||
h << "url('data:image/png;base64,"
|
||||
<< Base64Encode(PNGEncoder().SaveString(fbCursorImage))
|
||||
<< "') " << p.x << ' ' << p.y << ", default";
|
||||
draw.Put8(SystemDraw::SETCURSORIMAGE);
|
||||
draw.Put16(0); // _TODO_ Cursor cache
|
||||
draw.Put(h);
|
||||
draw.Put8(SystemDraw::CURSORIMAGE);
|
||||
draw.Put16(0); // _TODO_ Cursor cache
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::DoPaint()
|
||||
{
|
||||
if(!PaintLock) {
|
||||
if(invalid && desktop) {
|
||||
invalid = false;
|
||||
SystemDraw draw;
|
||||
PaintScene(draw);
|
||||
PaintCaretCursor(draw);
|
||||
content << String(draw.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool keyShift;
|
||||
bool keyCtrl;
|
||||
bool keyAlt;
|
||||
|
||||
bool GetShift() { return keyShift; }
|
||||
bool GetCtrl() { return keyCtrl; }
|
||||
bool GetAlt() { return keyAlt; }
|
||||
bool GetCapsLock() { return false; } // Impossible to implement
|
||||
|
||||
dword fbKEYtoK(dword chr) {
|
||||
chr = chr + K_DELTA;
|
||||
if(chr == K_ALT_KEY || chr == K_CTRL_KEY || chr == K_SHIFT_KEY)
|
||||
return chr;
|
||||
if(GetCtrl()) chr |= K_CTRL;
|
||||
if(GetAlt()) chr |= K_ALT;
|
||||
if(GetShift()) chr |= K_SHIFT;
|
||||
return chr;
|
||||
/*
|
||||
if(chr == SDLK_TAB)
|
||||
chr = K_TAB;
|
||||
else
|
||||
if(chr == SDLK_SPACE)
|
||||
chr = K_SPACE;
|
||||
else
|
||||
if(chr == SDLK_RETURN)
|
||||
chr = K_RETURN;
|
||||
else
|
||||
chr = chr + K_DELTA;
|
||||
*/
|
||||
}
|
||||
|
||||
void Ctrl::ReadKeyMods(CParser& p)
|
||||
{
|
||||
const char *s = p.GetPtr();
|
||||
if(*s)
|
||||
keyShift = *s++ == '1';
|
||||
if(*s)
|
||||
keyCtrl = *s++ == '1';
|
||||
if(*s)
|
||||
keyAlt = *s++ == '1';
|
||||
}
|
||||
|
||||
bool Ctrl::DoKeyFB(dword key, int cnt)
|
||||
{
|
||||
LLOG("DoKeyFB [" << GetKeyDesc(key) << "] " << key << ", " << cnt);
|
||||
|
||||
bool b = DispatchKey(key, cnt);
|
||||
SyncCaret();
|
||||
Ctrl *desktop = GetDesktop();
|
||||
if(desktop)
|
||||
desktop->PostInput();
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
bool mouseLeft, mouseMiddle, mouseRight;
|
||||
Point mouseDownPos;
|
||||
int64 mouseDownTime;
|
||||
|
||||
bool GetMouseLeft() { return mouseLeft; }
|
||||
bool GetMouseRight() { return mouseRight; }
|
||||
bool GetMouseMiddle() { return mouseMiddle; }
|
||||
|
||||
void Ctrl::DoMouseFB(int event, Point p, int zdelta, CParser& cp)
|
||||
{
|
||||
ReadKeyMods(cp);
|
||||
MousePos = p;
|
||||
int a = event & ACTION;
|
||||
if(a == UP && Ctrl::ignoreclick) {
|
||||
EndIgnore();
|
||||
return;
|
||||
}
|
||||
else
|
||||
if(a == DOWN && ignoreclick)
|
||||
return;
|
||||
LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
|
||||
if(captureCtrl)
|
||||
MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
|
||||
else
|
||||
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
||||
Ptr<Ctrl> t = topctrl[i];
|
||||
Rect rr = t->GetRect();
|
||||
if(rr.Contains(p)) {
|
||||
MouseEventFB(t, event, p, zdelta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ctrl *desktop = GetDesktop();
|
||||
if(desktop) {
|
||||
desktop->DispatchMouse(event, p, zdelta);
|
||||
desktop->PostInput();
|
||||
}
|
||||
}
|
||||
|
||||
static int sDistMax(Point a, Point b)
|
||||
{
|
||||
return IsNull(a) ? INT_MAX : max(abs(a.x - b.x), abs(a.y - b.y));
|
||||
}
|
||||
|
||||
Point ReadPoint(CParser& p)
|
||||
{
|
||||
Point pt;
|
||||
pt.x = p.ReadInt();
|
||||
pt.y = p.ReadInt();
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Ctrl::DoMouseButton(int event, CParser& p)
|
||||
{
|
||||
int button = p.ReadInt();
|
||||
Point pt = ReadPoint(p);
|
||||
int64 tm = p.ReadInt64();
|
||||
(button == 0 ? mouseLeft : button == 2 ? mouseRight : mouseMiddle) = event == DOWN;
|
||||
if(event == DOWN)
|
||||
if(sDistMax(mouseDownPos, pt) < GUI_DragDistance() && tm - mouseDownTime < 800) {
|
||||
event = DOUBLE;
|
||||
mouseDownTime = 0;
|
||||
}
|
||||
else {
|
||||
mouseDownPos = pt;
|
||||
mouseDownTime = tm;
|
||||
}
|
||||
DoMouseFB(decode(button, 0, LEFT, 2, RIGHT, MIDDLE)|event, pt, 0, p);
|
||||
}
|
||||
|
||||
bool Ctrl::ProcessEventQueue(const String& event_queue)
|
||||
{
|
||||
StringStream ss(event_queue);
|
||||
while(!ss.IsEof()) {
|
||||
String s = ss.GetLine();
|
||||
CParser p(s);
|
||||
try {
|
||||
if(p.Id("I"))
|
||||
SystemDraw::ResetI();
|
||||
else
|
||||
if(p.Id("R")) {
|
||||
DesktopSize = ReadPoint(p);
|
||||
Desktop().SetRect(0, 0, DesktopSize.cx, DesktopSize.cy);
|
||||
}
|
||||
if(p.Id("M")) {
|
||||
Point pt = ReadPoint(p);
|
||||
int64 tm = p.ReadInt64();
|
||||
DoMouseFB(MOUSEMOVE, pt, 0, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("W")) {
|
||||
double w = p.ReadDouble();
|
||||
Point pt = ReadPoint(p);
|
||||
int64 tm = p.ReadInt64();
|
||||
DoMouseFB(MOUSEWHEEL, pt, w < 0 ? 120 : -120, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("O")) {
|
||||
mouseLeft = mouseMiddle = mouseRight = false;
|
||||
mouseDownTime = 0;
|
||||
}
|
||||
else
|
||||
if(p.Id("D")) {
|
||||
DoMouseButton(DOWN, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("U")) {
|
||||
DoMouseButton(UP, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("K")) {
|
||||
int code = p.ReadInt();
|
||||
int which = p.ReadInt();
|
||||
ReadKeyMods(p);
|
||||
DoKeyFB(fbKEYtoK(which), 1);
|
||||
}
|
||||
else
|
||||
if(p.Id("k")) {
|
||||
int code = p.ReadInt();
|
||||
int which = p.ReadInt();
|
||||
ReadKeyMods(p);
|
||||
DoKeyFB(K_KEYUP|fbKEYtoK(which), 1);
|
||||
}
|
||||
else
|
||||
if(p.Id("C")) {
|
||||
int code = p.ReadInt();
|
||||
int which = p.ReadInt();
|
||||
ReadKeyMods(p);
|
||||
if(which && !keyAlt && !keyCtrl)
|
||||
DoKeyFB(which, 1);
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HttpHeader http;
|
||||
|
||||
void Ctrl::Reply()
|
||||
{
|
||||
GuiLock __;
|
||||
if(socket.IsOpen()) {
|
||||
TimerProc(GetTickCount());
|
||||
DefferedFocusSync();
|
||||
SyncCaret();
|
||||
SyncTopWindows();
|
||||
SweepMkImageCache();
|
||||
DoPaint();
|
||||
if(http.GetURI().GetCount() < 2)
|
||||
HttpResponse(socket, http.scgi, 200, "OK", "text/html", String(telpp_html, telpp_html_length)); // This is weird place, but whatever
|
||||
else {
|
||||
String s = GZCompress(content);
|
||||
HttpResponse(socket, http.scgi, 200, "OK", "text/plain; charset=x-user-defined",
|
||||
s, "U++ Tel++ server", true);
|
||||
}
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
|
||||
bool Ctrl::IsWaitingEvent()
|
||||
{
|
||||
GuiLock __;
|
||||
Reply();
|
||||
return socket.Timeout(0).Accept(server);
|
||||
}
|
||||
|
||||
bool Ctrl::ProcessEvents(bool *quit)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("ProcessEvents");
|
||||
if(!IsWaitingEvent())
|
||||
return false;
|
||||
|
||||
TimeStop tm;
|
||||
LLOG("Trying to read socket");
|
||||
socket.Timeout(20000);
|
||||
if(!http.Read(socket)) {
|
||||
LLOG("Header failed to read");
|
||||
socket.Close();
|
||||
return false;
|
||||
}
|
||||
String event_queue = socket.Get((int)http.GetContentLength());
|
||||
LLOG("---- Process events");
|
||||
if(event_queue.GetCount())
|
||||
LOG(event_queue);
|
||||
content.Clear();
|
||||
bool r = ProcessEventQueue(event_queue);
|
||||
_TODO_ // Resolve eventloop exit issue
|
||||
Reply();
|
||||
return r;
|
||||
}
|
||||
|
||||
void Ctrl::EventLoop(Ctrl *ctrl)
|
||||
{
|
||||
GuiLock __;
|
||||
Reply();
|
||||
ASSERT(IsMainThread());
|
||||
ASSERT(LoopLevel == 0 || ctrl);
|
||||
LoopLevel++;
|
||||
LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN);
|
||||
Ptr<Ctrl> ploop;
|
||||
if(ctrl) {
|
||||
ploop = LoopCtrl;
|
||||
LoopCtrl = ctrl;
|
||||
ctrl->inloop = true;
|
||||
}
|
||||
|
||||
bool quit = false;
|
||||
int64 loopno = ++EventLoopNo;
|
||||
ProcessEvents(&quit);
|
||||
while(loopno > EndSessionLoopNo && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount()))
|
||||
{
|
||||
// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep");
|
||||
SyncCaret();
|
||||
GuiSleep(20);
|
||||
// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents");
|
||||
ProcessEvents(&quit);
|
||||
// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents");
|
||||
// LDUMP(loopno);
|
||||
}
|
||||
|
||||
if(ctrl)
|
||||
LoopCtrl = ploop;
|
||||
LoopLevel--;
|
||||
LLOG(LOG_END << "Leaving event loop ");
|
||||
}
|
||||
|
||||
void Ctrl::GuiSleep(int ms)
|
||||
{
|
||||
GuiLock __;
|
||||
Reply();
|
||||
ASSERT(IsMainThread());
|
||||
// LLOG("GuiSleep");
|
||||
int level = LeaveGuiMutexAll();
|
||||
Sleep(ms); _TODO_
|
||||
EnterGuiMutex(level);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
PREMULTIPLIED
|
||||
IMAGE_ID(Arrow)
|
||||
IMAGE_ID(IBeam)
|
||||
IMAGE_ID(Wait)
|
||||
IMAGE_ID(No)
|
||||
IMAGE_ID(SizeAll)
|
||||
IMAGE_ID(SizeHorz)
|
||||
IMAGE_ID(SizeRight)
|
||||
IMAGE_ID(SizeLeft)
|
||||
IMAGE_ID(SizeVert)
|
||||
IMAGE_ID(SizeTopLeft)
|
||||
IMAGE_ID(SizeTop)
|
||||
IMAGE_ID(SizeTopRight)
|
||||
IMAGE_ID(SizeBottomLeft)
|
||||
IMAGE_ID(SizeBottom)
|
||||
IMAGE_ID(SizeBottomRight)
|
||||
IMAGE_ID(overlap)
|
||||
IMAGE_ID(maximize)
|
||||
IMAGE_ID(close)
|
||||
IMAGE_ID(bgtitle)
|
||||
IMAGE_ID(title)
|
||||
IMAGE_ID(border)
|
||||
IMAGE_ID(Hand)
|
||||
|
||||
IMAGE_BEGIN_DATA
|
||||
IMAGE_DATA(120,156,237,90,61,104,20,65,20,30,77,162,9,92,144,248,135,160,133,117,42,177,18,21,4,171,84,65,76,22,4,149)
|
||||
IMAGE_DATA(136,17,37,49,66,4,13,40,72,34,4,145,128,120,133,196,20,49,30,24,11,207,104,33,105,196,4,114,133,34,66,68)
|
||||
IMAGE_DATA(52,129,67,20,65,4,145,52,218,217,61,103,214,157,117,118,110,126,222,91,247,240,135,157,229,177,55,51,223,247,230,205)
|
||||
IMAGE_DATA(247,222,206,94,244,88,129,109,98,162,173,97,171,196,13,184,5,12,223,128,200,129,114,153,196,129,239,223,183,195,244,244)
|
||||
IMAGE_DATA(22,44,7,190,125,219,13,95,191,238,131,169,169,29,24,14,172,172,28,128,47,95,186,225,243,231,195,48,62,190,223,199)
|
||||
IMAGE_DATA(129,79,159,122,225,227,199,83,240,225,195,25,120,255,254,28,20,139,7,93,28,120,247,238,60,188,125,123,1,170,213,97)
|
||||
IMAGE_DATA(88,90,186,2,175,95,95,131,177,177,99,54,14,44,47,143,194,155,55,87,225,213,171,235,240,242,229,4,188,120,113,7)
|
||||
IMAGE_DATA(158,63,159,134,209,209,126,19,135,99,138,176,184,120,131,227,38,225,217,179,123,176,176,176,16,217,3,24,30,30,208,57)
|
||||
IMAGE_DATA(220,215,4,199,77,194,211,167,119,160,82,121,24,98,75,165,146,196,169,22,226,43,149,91,220,74,48,63,127,23,230,230)
|
||||
IMAGE_DATA(238,195,227,199,143,156,251,125,242,228,54,92,188,120,58,246,51,52,52,232,196,15,13,245,169,243,194,96,112,112,64,141)
|
||||
IMAGE_DATA(33,129,55,105,208,223,127,210,170,167,97,44,92,163,183,247,152,109,13,83,131,158,158,35,148,186,13,215,8,130,110,210)
|
||||
IMAGE_DATA(26,93,93,7,41,248,128,16,143,185,53,177,117,108,53,91,27,26,211,18,47,76,54,237,115,28,176,214,255,231,199,44)
|
||||
IMAGE_DATA(251,173,209,133,21,184,112,77,92,180,166,164,112,88,11,51,183,245,222,184,211,20,44,147,248,109,101,179,41,248,120,83)
|
||||
IMAGE_DATA(155,175,93,50,114,196,152,152,211,240,65,203,174,157,176,254,236,137,4,71,124,22,99,98,142,25,158,36,149,227,193,38)
|
||||
IMAGE_DATA(56,98,125,97,30,108,204,209,180,115,98,9,254,41,241,83,245,161,234,79,201,47,181,126,104,245,217,198,175,230,232,178)
|
||||
IMAGE_DATA(9,103,33,163,143,70,132,89,147,230,193,81,230,93,241,186,252,164,225,215,36,80,233,99,215,183,125,166,196,111,138,139)
|
||||
IMAGE_DATA(194,151,205,231,195,199,247,249,192,240,77,62,108,251,196,232,100,251,236,203,117,205,97,237,136,203,23,131,105,140,194,255)
|
||||
IMAGE_DATA(157,231,129,82,79,212,231,22,227,203,204,69,28,72,63,189,242,38,94,217,226,142,8,194,200,47,151,203,130,15,209,157)
|
||||
IMAGE_DATA(228,71,229,243,110,42,63,81,252,9,97,162,109,185,14,139,68,12,160,180,200,101,220,92,177,168,92,137,83,125,216,48)
|
||||
IMAGE_DATA(166,253,171,241,234,62,212,125,170,250,232,250,233,205,54,166,250,49,233,135,53,25,119,22,113,100,161,71,86,121,201,170)
|
||||
IMAGE_DATA(62,212,102,210,153,82,167,186,62,204,160,95,26,63,105,248,170,31,148,6,109,252,107,127,51,107,8,77,39,251,4,176)
|
||||
IMAGE_DATA(9,109,43,22,155,15,234,195,99,106,236,15,60,60,152,56,178,208,35,147,188,228,137,206,19,157,39,250,127,74,244,90)
|
||||
IMAGE_DATA(158,234,134,40,213,186,67,87,2,93,137,241,9,174,196,155,16,72,235,199,65,203,57,211,134,254,230,57,215,254,92,186)
|
||||
IMAGE_DATA(184,244,116,229,65,205,83,77,254,90,249,181,38,186,106,235,19,87,61,166,96,41,28,204,151,17,149,211,222,222,142,230)
|
||||
IMAGE_DATA(72,49,132,117,118,118,122,121,74,18,2,41,40,134,167,182,44,121,152,167,88,231,97,79,15,201,19,122,178,72,91,44)
|
||||
IMAGE_DATA(135,41,249,195,228,91,47,106,12,199,88,139,249,201,84,191,57,215,254,92,186,212,253,100,114,53,107,165,120,56,212,138)
|
||||
IMAGE_DATA(76,83,249,212,39,140,250,36,83,79,12,204,201,164,36,27,125,2,74,61,169,39,173,212,132,114,162,51,150,254,205,193)
|
||||
IMAGE_DATA(8,111,40,106,77,229,5,155,23,172,147,195,254,182,130,205,95,165,245,155,115,237,207,165,75,221,95,165,105,42,69,110)
|
||||
IMAGE_DATA(66,15,150,194,201,191,228,219,121,174,19,208,198,251,175,191,228,23,248,149,81,3,143,153,240,46,95,105,241,152,56,116)
|
||||
IMAGE_DATA(188,111,205,172,240,24,125,234,165,139,58,70,201,19,190,101,80,76,190,224,40,98,153,48,57,62,123,60,37,95,248,246)
|
||||
IMAGE_DATA(187,197,180,177,177,49,216,219,218,10,226,142,153,19,253,61,220,244,113,137,149,115,182,113,209,55,141,153,214,13,231,11)
|
||||
IMAGE_DATA(133,208,108,216,4,71,96,35,156,248,108,195,82,241,148,120,168,251,77,171,39,54,95,164,214,200,47,217,186,186,38,224)
|
||||
IMAGE_DATA(80,223,12,28,189,60,3,199,111,206,0,181,31,59,107,8,255,111,102,4,90,218,203,176,33,88,134,109,195,226,37,76)
|
||||
IMAGE_DATA(236,139,50,111,226,87,244,183,44,246,121,74,188,249,125,77,252,166,90,197,255,250,77,182,217,70,70,70,114,124,157,240)
|
||||
IMAGE_DATA(178,239,179,52,181,16,22,147,227,31,70,228,175,156,212,187,11,7,197,98,49,113,183,112,226,249,106,181,154,184,91,56)
|
||||
IMAGE_DATA(53,56,121,87,214,97,234,198,108,120,101,157,56,142,142,142,14,52,94,244,165,97,240,179,179,179,9,142,201,20,124,32)
|
||||
IMAGE_DATA(98,17,49,33,241,94,142,88,95,195,199,28,19,94,140,219,114,230,139,229,7,18,241,124,50,0,0,0,0,0,0,0)
|
||||
IMAGE_END_DATA(1184, 22)
|
||||
|
|
@ -1,358 +0,0 @@
|
|||
#define GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class SystemDraw : public Draw {
|
||||
public:
|
||||
virtual dword GetInfo() const;
|
||||
virtual Size GetPageSize() const;
|
||||
|
||||
virtual void BeginOp();
|
||||
virtual void EndOp();
|
||||
virtual void OffsetOp(Point p);
|
||||
virtual bool ClipOp(const Rect& r);
|
||||
virtual bool ClipoffOp(const Rect& r);
|
||||
virtual bool ExcludeClipOp(const Rect& r);
|
||||
virtual bool IntersectClipOp(const Rect& r);
|
||||
virtual bool IsPaintingOp(const Rect& r) const;
|
||||
virtual Rect GetPaintRect() const;
|
||||
|
||||
virtual void DrawRectOp(int x, int y, int cx, int cy, Color color);
|
||||
virtual void DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color);
|
||||
virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color);
|
||||
|
||||
virtual void DrawPolyPolylineOp(const Point *vertices, int vertex_count,
|
||||
const int *counts, int count_count,
|
||||
int width, Color color, Color doxor);
|
||||
virtual void DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count,
|
||||
const int *subpolygon_counts, int scc,
|
||||
const int *disjunct_polygon_counts, int dpcc,
|
||||
Color color, int width, Color outline,
|
||||
uint64 pattern, Color doxor);
|
||||
virtual void DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color);
|
||||
|
||||
virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor);
|
||||
virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
|
||||
Color ink, int n, const int *dx);
|
||||
|
||||
virtual Size GetNativeDpi() const;
|
||||
virtual void BeginNative();
|
||||
virtual void EndNative();
|
||||
|
||||
virtual int GetCloffLevel() const;
|
||||
|
||||
private:
|
||||
Size pageSize;
|
||||
Size nativeSize;
|
||||
Size nativeDpi;
|
||||
bool palette:1;
|
||||
bool color16:1;
|
||||
bool is_mono:1;
|
||||
int native;
|
||||
|
||||
friend class ImageDraw;
|
||||
friend class FontInfo;
|
||||
friend class Font;
|
||||
|
||||
friend void StaticExitDraw_();
|
||||
|
||||
Point actual_offset_bak;
|
||||
|
||||
struct Cloff : Moveable<Cloff> {
|
||||
Point org;
|
||||
HRGN hrgn;
|
||||
Rect drawingclip;
|
||||
};
|
||||
|
||||
Array<Cloff> cloff;
|
||||
Rect drawingclip;
|
||||
|
||||
COLORREF lastTextColor;
|
||||
Color lastColor;
|
||||
HBRUSH orgBrush;
|
||||
HBRUSH actBrush;
|
||||
HPEN orgPen;
|
||||
HPEN actPen;
|
||||
int lastPen;
|
||||
Color lastPenColor;
|
||||
|
||||
void Unselect0();
|
||||
void Cinit();
|
||||
|
||||
void LoadCaps();
|
||||
void SetPrinterMode();
|
||||
void Reset();
|
||||
void SetOrg();
|
||||
friend HPALETTE GetQlibPalette();
|
||||
void DotsMode();
|
||||
|
||||
static void InitColors();
|
||||
|
||||
friend class BackDraw;
|
||||
friend class ScreenDraw;
|
||||
friend class PrintDraw;
|
||||
|
||||
protected:
|
||||
dword style;
|
||||
HDC handle;
|
||||
Point actual_offset;
|
||||
|
||||
SystemDraw();
|
||||
void Init();
|
||||
void InitClip(const Rect& clip);
|
||||
|
||||
public:
|
||||
static Rect GetVirtualScreenArea();
|
||||
|
||||
static void SetAutoPalette(bool ap);
|
||||
static bool AutoPalette();
|
||||
bool PaletteMode() { return palette; }
|
||||
|
||||
static void Flush() { GdiFlush(); }
|
||||
|
||||
COLORREF GetColor(Color color) const;
|
||||
|
||||
Point GetOffset() const { return actual_offset; }
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
Point LPtoDP(Point p) const;
|
||||
Point DPtoLP(Point p) const;
|
||||
Rect LPtoDP(const Rect& r) const;
|
||||
Rect DPtoLP(const Rect& r) const;
|
||||
#endif
|
||||
|
||||
void SetColor(Color color);
|
||||
void SetDrawPen(int width, Color color);
|
||||
|
||||
Size GetSizeCaps(int i, int j) const;
|
||||
HDC BeginGdi();
|
||||
void EndGdi();
|
||||
HDC GetHandle() { return handle; }
|
||||
operator HDC() const { return handle; }
|
||||
void Unselect();
|
||||
void Attach(HDC ahandle) { handle = ahandle; Init(); }
|
||||
HDC Detach() { Unselect(); HDC h = handle; handle = NULL; return h; }
|
||||
|
||||
SystemDraw(HDC hdc);
|
||||
virtual ~SystemDraw();
|
||||
|
||||
bool CanSetSurface() { return IsGui() && IsWinNT(); }
|
||||
};
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
class WinMetaFile {
|
||||
Size size;
|
||||
HENHMETAFILE hemf;
|
||||
|
||||
void Init();
|
||||
|
||||
public:
|
||||
void Attach(HENHMETAFILE emf);
|
||||
HENHMETAFILE Detach();
|
||||
|
||||
void Set(const void *data, dword len);
|
||||
void Set(const String& data) { Set(~data, data.GetCount()); }
|
||||
|
||||
String Get() const;
|
||||
|
||||
operator bool() const { return hemf; }
|
||||
void SetSize(const Size& sz) { size = sz; }
|
||||
Size GetSize() const { return hemf ? size : Size(0, 0); }
|
||||
|
||||
void Clear();
|
||||
|
||||
void Paint(Draw& w, const Rect& r) const;
|
||||
void Paint(Draw& w, int x, int y, int cx, int cy) const;
|
||||
|
||||
void Serialize(Stream& s);
|
||||
|
||||
void ReadClipboard();
|
||||
void WriteClipboard() const;
|
||||
void Load(const char *file) { Set(LoadFile(file)); }
|
||||
|
||||
WinMetaFile() { Init(); }
|
||||
WinMetaFile(HENHMETAFILE hemf);
|
||||
WinMetaFile(HENHMETAFILE hemf, Size sz);
|
||||
WinMetaFile(const char *file);
|
||||
WinMetaFile(void *data, int len);
|
||||
WinMetaFile(const String& data);
|
||||
|
||||
~WinMetaFile() { Clear(); }
|
||||
|
||||
HENHMETAFILE GetHEMF() const { return hemf; }
|
||||
};
|
||||
|
||||
class WinMetaFileDraw : public SystemDraw {
|
||||
Size size;
|
||||
|
||||
public:
|
||||
bool Create(HDC hdc, int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
bool Create(int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
WinMetaFile Close();
|
||||
|
||||
WinMetaFileDraw() {}
|
||||
WinMetaFileDraw(HDC hdc, int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
WinMetaFileDraw(int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
~WinMetaFileDraw();
|
||||
};
|
||||
|
||||
void DrawWMF(Draw& w, int x, int y, int cx, int cy, const String& wmf);
|
||||
void DrawWMF(Draw& w, int x, int y, const String& wmf);
|
||||
Drawing LoadWMF(const char *path, int cx, int cy);
|
||||
Drawing LoadWMF(const char *path);
|
||||
|
||||
String AsWMF(const Drawing& iw);
|
||||
|
||||
#endif
|
||||
|
||||
class ScreenDraw : public SystemDraw {
|
||||
public:
|
||||
ScreenDraw(bool ic = false);
|
||||
~ScreenDraw();
|
||||
};
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
class PrintDraw : public SystemDraw {
|
||||
public:
|
||||
virtual void StartPage();
|
||||
virtual void EndPage();
|
||||
|
||||
private:
|
||||
bool aborted;
|
||||
|
||||
void InitPrinter();
|
||||
public:
|
||||
PrintDraw(HDC hdc, const char *jobname);
|
||||
~PrintDraw();
|
||||
};
|
||||
#endif
|
||||
|
||||
inline bool BitBlt(HDC ddc, Point d, HDC sdc, const Rect& s, dword rop = SRCCOPY)
|
||||
{ return BitBlt(ddc, d.x, d.y, s.Width(), s.Height(), sdc, s.left, s.top, rop); }
|
||||
|
||||
inline bool StretchBlt(HDC ddc, const Rect& r, HDC sdc, const Rect& s, dword rop = SRCCOPY)
|
||||
{ return StretchBlt(ddc, r.left, r.top, r.Width(), r.Height(), sdc, s.left, s.top, s.Width(), s.Height(), rop); }
|
||||
|
||||
inline bool PatBlt(HDC dc, const Rect& r, dword rop = PATCOPY)
|
||||
{ return PatBlt(dc, r.left, r.top, r.Width(), r.Height(), rop); }
|
||||
|
||||
inline void MoveTo(HDC hdc, Point pt) { MoveToEx(hdc, pt.x, pt.y, 0); }
|
||||
inline void LineTo(HDC hdc, Point pt) { LineTo(hdc, pt.x, pt.y); }
|
||||
|
||||
inline void DrawLine(HDC hdc, Point p, Point q) { MoveTo(hdc, p); LineTo(hdc, q); }
|
||||
inline void DrawLine(HDC hdc, int px, int py, int qx, int qy) { MoveToEx(hdc, px, py, 0); LineTo(hdc, qx, qy); }
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
inline void DrawArc(HDC hdc, const Rect& rc, Point p, Point q){ Arc(hdc, rc.left, rc.top, rc.right, rc.bottom, p.x, p.y, q.x, q.y); }
|
||||
#endif
|
||||
inline void DrawCircle(HDC hdc, int x, int y, int radius) { Ellipse(hdc, x - radius, y - radius, x + radius + 1, y + radius + 1); }
|
||||
inline void DrawCircle(HDC hdc, Point centre, int radius) { DrawCircle(hdc, centre.x, centre.y, radius); }
|
||||
inline void DrawEllipse(HDC hdc, const Rect& rc) { Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom); }
|
||||
|
||||
inline void DrawRect(HDC hdc, const Rect& rc) { Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); }
|
||||
|
||||
HDC ScreenHDC();
|
||||
HPALETTE GetQlibPalette();
|
||||
|
||||
Image Win32Icon(LPCSTR id, int iconsize = 0);
|
||||
Image Win32Icon(int id, int iconsize = 0);
|
||||
Image Win32Cursor(LPCSTR id);
|
||||
Image Win32Cursor(int id);
|
||||
HICON IconWin32(const Image& img, bool cursor = false);
|
||||
Image Win32DllIcon(const char *dll, int ii, bool large);
|
||||
|
||||
class BackDraw : public SystemDraw {
|
||||
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();
|
||||
};
|
||||
|
||||
class ImageDraw : public SystemDraw {
|
||||
Size size;
|
||||
|
||||
struct Section {
|
||||
HDC dc;
|
||||
HBITMAP hbmp, hbmpOld;
|
||||
RGBA *pixels;
|
||||
|
||||
void Init(int cx, int cy);
|
||||
~Section();
|
||||
};
|
||||
|
||||
Section rgb;
|
||||
Section a;
|
||||
SystemDraw alpha;
|
||||
|
||||
|
||||
bool has_alpha;
|
||||
|
||||
void Init();
|
||||
Image Get(bool pm) const;
|
||||
|
||||
public:
|
||||
Draw& Alpha();
|
||||
|
||||
operator Image() const;
|
||||
|
||||
Image GetStraight() const;
|
||||
|
||||
ImageDraw(Size sz);
|
||||
ImageDraw(int cx, int cy);
|
||||
~ImageDraw();
|
||||
};
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#define GUIPLATFORM_KEYCODES_INCLUDE "Win32Keys.h"
|
||||
|
||||
|
||||
#define GUIPLATFORM_CTRL_TOP_DECLS \
|
||||
HWND hwnd; \
|
||||
UDropTarget *dndtgt; \
|
||||
|
||||
|
||||
#define GUIPLATFORM_CTRL_DECLS_INCLUDE "Win32Ctrl.h"
|
||||
|
||||
|
||||
#define GUIPLATFORM_PASTECLIP_DECLS \
|
||||
UDropTarget *dt; \
|
||||
|
||||
#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE "Win32Top.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
inline unsigned GetHashValue(const HWND& hwnd)
|
||||
{
|
||||
return (unsigned)(intptr_t)hwnd;
|
||||
}
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
#ifndef PLATFORM_WINCE
|
||||
|
||||
#include <ShellAPI.h>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GUIPLATFORM_INCLUDE_AFTER "Win32GuiA.h"
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#include <CtrlCore/CtrlCore.h>
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LTIMING(x) // RTIMING(x)
|
||||
|
||||
void SetSurface(SystemDraw& w, int x, int y, int cx, int cy, const RGBA *pixels)
|
||||
{
|
||||
GuiLock __;
|
||||
// Empty as CanSetSurface is false
|
||||
}
|
||||
|
||||
void SetSurface(SystemDraw& w, const Rect& dest, const RGBA *pixels, Size psz, Point poff)
|
||||
{
|
||||
GuiLock __;
|
||||
// Empty as CanSetSurface is false
|
||||
}
|
||||
|
||||
#define IMAGECLASS FBImg
|
||||
#define IMAGEFILE <Telpp/FB.iml>
|
||||
#include <Draw/iml_source.h>
|
||||
|
||||
#define STD_CURSOR(name, sdl) \
|
||||
Image Image::name() { static Image img; ONCELOCK { img = FBImg::name(); img.SetAuxData(sdl); } return img; }
|
||||
|
||||
STD_CURSOR(Arrow, 1)
|
||||
STD_CURSOR(Wait, 2)
|
||||
STD_CURSOR(IBeam, 3)
|
||||
STD_CURSOR(No, 4)
|
||||
STD_CURSOR(SizeAll, 5)
|
||||
STD_CURSOR(SizeHorz, 6)
|
||||
STD_CURSOR(SizeVert, 7)
|
||||
STD_CURSOR(SizeTopLeft, 8)
|
||||
STD_CURSOR(SizeTop, 9)
|
||||
STD_CURSOR(SizeTopRight, 10)
|
||||
STD_CURSOR(SizeLeft, 11)
|
||||
STD_CURSOR(SizeRight, 12)
|
||||
STD_CURSOR(SizeBottomLeft, 13)
|
||||
STD_CURSOR(SizeBottom, 14)
|
||||
STD_CURSOR(SizeBottomRight, 15)
|
||||
STD_CURSOR(Hand, 16)
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
#define WEBKEY(x) x
|
||||
|
||||
K_BACK = WEBKEY(8) + K_DELTA,
|
||||
K_BACKSPACE = WEBKEY(8) + K_DELTA,
|
||||
|
||||
//handled extra in fbKEYtoK
|
||||
K_TAB = 9, //SDLK_TAB,
|
||||
|
||||
K_SPACE = 32, //SDLK_SPACE,
|
||||
|
||||
K_RETURN = 13, //SDLK_RETURN,
|
||||
K_ENTER = K_RETURN,
|
||||
|
||||
K_SHIFT_KEY = WEBKEY(16) + K_DELTA,
|
||||
K_CTRL_KEY = WEBKEY(17) + K_DELTA,
|
||||
K_ALT_KEY = WEBKEY(18) + K_DELTA,
|
||||
|
||||
K_CAPSLOCK = WEBKEY(20) + K_DELTA,
|
||||
K_ESCAPE = WEBKEY(27) + K_DELTA,
|
||||
K_PRIOR = WEBKEY(33) + K_DELTA,
|
||||
K_PAGEUP = WEBKEY(33) + K_DELTA,
|
||||
K_NEXT = WEBKEY(34) + K_DELTA,
|
||||
K_PAGEDOWN = WEBKEY(34) + K_DELTA,
|
||||
K_END = WEBKEY(35) + K_DELTA,
|
||||
K_HOME = WEBKEY(36) + K_DELTA,
|
||||
K_LEFT = WEBKEY(37) + K_DELTA,
|
||||
K_UP = WEBKEY(38) + K_DELTA,
|
||||
K_RIGHT = WEBKEY(39) + K_DELTA,
|
||||
K_DOWN = WEBKEY(40) + K_DELTA,
|
||||
K_INSERT = WEBKEY(45) + K_DELTA,
|
||||
K_DELETE = WEBKEY(46) + K_DELTA,
|
||||
|
||||
K_NUMPAD0 = WEBKEY(96) + K_DELTA,
|
||||
K_NUMPAD1 = WEBKEY(97) + K_DELTA,
|
||||
K_NUMPAD2 = WEBKEY(98) + K_DELTA,
|
||||
K_NUMPAD3 = WEBKEY(99) + K_DELTA,
|
||||
K_NUMPAD4 = WEBKEY(100) + K_DELTA,
|
||||
K_NUMPAD5 = WEBKEY(101) + K_DELTA,
|
||||
K_NUMPAD6 = WEBKEY(102) + K_DELTA,
|
||||
K_NUMPAD7 = WEBKEY(103) + K_DELTA,
|
||||
K_NUMPAD8 = WEBKEY(104) + K_DELTA,
|
||||
K_NUMPAD9 = WEBKEY(105) + K_DELTA,
|
||||
K_MULTIPLY = WEBKEY(106) + K_DELTA,
|
||||
K_ADD = WEBKEY(107) + K_DELTA,
|
||||
K_SEPARATOR = WEBKEY(108) + K_DELTA,
|
||||
K_SUBTRACT = WEBKEY(109) + K_DELTA,
|
||||
K_DECIMAL = WEBKEY(110) + K_DELTA,
|
||||
K_DIVIDE = WEBKEY(111) + K_DELTA,
|
||||
K_SCROLL = WEBKEY(145) + K_DELTA,
|
||||
|
||||
K_F1 = WEBKEY(112) + K_DELTA,
|
||||
K_F2 = WEBKEY(113) + K_DELTA,
|
||||
K_F3 = WEBKEY(114) + K_DELTA,
|
||||
K_F4 = WEBKEY(115) + K_DELTA,
|
||||
K_F5 = WEBKEY(116) + K_DELTA,
|
||||
K_F6 = WEBKEY(117) + K_DELTA,
|
||||
K_F7 = WEBKEY(118) + K_DELTA,
|
||||
K_F8 = WEBKEY(119) + K_DELTA,
|
||||
K_F9 = WEBKEY(120) + K_DELTA,
|
||||
K_F10 = WEBKEY(121) + K_DELTA,
|
||||
K_F11 = WEBKEY(122) + K_DELTA,
|
||||
K_F12 = WEBKEY(123) + K_DELTA,
|
||||
|
||||
K_A = WEBKEY('A') + K_DELTA,
|
||||
K_B = WEBKEY('B') + K_DELTA,
|
||||
K_C = WEBKEY('C') + K_DELTA,
|
||||
K_D = WEBKEY('D') + K_DELTA,
|
||||
K_E = WEBKEY('E') + K_DELTA,
|
||||
K_F = WEBKEY('F') + K_DELTA,
|
||||
K_G = WEBKEY('G') + K_DELTA,
|
||||
K_H = WEBKEY('H') + K_DELTA,
|
||||
K_I = WEBKEY('I') + K_DELTA,
|
||||
K_J = WEBKEY('J') + K_DELTA,
|
||||
K_K = WEBKEY('K') + K_DELTA,
|
||||
K_L = WEBKEY('L') + K_DELTA,
|
||||
K_M = WEBKEY('M') + K_DELTA,
|
||||
K_N = WEBKEY('N') + K_DELTA,
|
||||
K_O = WEBKEY('O') + K_DELTA,
|
||||
K_P = WEBKEY('P') + K_DELTA,
|
||||
K_Q = WEBKEY('Q') + K_DELTA,
|
||||
K_R = WEBKEY('R') + K_DELTA,
|
||||
K_S = WEBKEY('S') + K_DELTA,
|
||||
K_T = WEBKEY('T') + K_DELTA,
|
||||
K_U = WEBKEY('U') + K_DELTA,
|
||||
K_V = WEBKEY('V') + K_DELTA,
|
||||
K_W = WEBKEY('W') + K_DELTA,
|
||||
K_X = WEBKEY('X') + K_DELTA,
|
||||
K_Y = WEBKEY('Y') + K_DELTA,
|
||||
K_Z = WEBKEY('Z') + K_DELTA,
|
||||
K_0 = WEBKEY('0') + K_DELTA,
|
||||
K_1 = WEBKEY('1') + K_DELTA,
|
||||
K_2 = WEBKEY('2') + K_DELTA,
|
||||
K_3 = WEBKEY('3') + K_DELTA,
|
||||
K_4 = WEBKEY('4') + K_DELTA,
|
||||
K_5 = WEBKEY('5') + K_DELTA,
|
||||
K_6 = WEBKEY('6') + K_DELTA,
|
||||
K_7 = WEBKEY('7') + K_DELTA,
|
||||
K_8 = WEBKEY('8') + K_DELTA,
|
||||
K_9 = WEBKEY('9') + K_DELTA,
|
||||
|
||||
K_CTRL_LBRACKET = K_CTRL|219|K_DELTA,
|
||||
K_CTRL_RBRACKET = K_CTRL|221|K_DELTA,
|
||||
K_CTRL_MINUS = K_CTRL|189|K_DELTA,
|
||||
K_CTRL_GRAVE = K_CTRL|192|K_DELTA,
|
||||
K_CTRL_SLASH = K_CTRL|191|K_DELTA,
|
||||
K_CTRL_BACKSLASH = K_CTRL|220|K_DELTA,
|
||||
K_CTRL_COMMA = K_CTRL|188|K_DELTA,
|
||||
K_CTRL_PERIOD = K_CTRL|190|K_DELTA,
|
||||
K_CTRL_SEMICOLON = K_CTRL|59|K_DELTA,
|
||||
K_CTRL_EQUAL = K_CTRL|61|K_DELTA,
|
||||
K_CTRL_APOSTROPHE= K_CTRL|222|K_DELTA,
|
||||
|
||||
K_BREAK = WEBKEY(3) + K_DELTA, // Is it really?
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class TopWindowFrame : public Ctrl {
|
||||
public:
|
||||
virtual void Layout();
|
||||
virtual void Paint(Draw& w);
|
||||
virtual Image CursorImage(Point p, dword keyflags);
|
||||
virtual void LeftDown(Point p, dword keyflags);
|
||||
virtual void LeftHold(Point p, dword keyflags);
|
||||
virtual void LeftDouble(Point p, dword keyflags);
|
||||
virtual void MouseMove(Point p, dword keyflags);
|
||||
virtual void CancelMode();
|
||||
virtual void LeftUp(Point p, dword keyflags);
|
||||
|
||||
private:
|
||||
Point dir;
|
||||
Point startpos;
|
||||
Rect startrect;
|
||||
|
||||
bool maximized;
|
||||
Rect overlapped;
|
||||
|
||||
bool holding;
|
||||
TimeCallback hold;
|
||||
|
||||
Point GetDragMode(Point p);
|
||||
Image GetDragImage(Point dragmode);
|
||||
void StartDrag();
|
||||
Rect Margins() const;
|
||||
Rect ComputeClient(Rect r);
|
||||
void Hold();
|
||||
|
||||
typedef TopWindowFrame CLASSNAME;
|
||||
|
||||
public:
|
||||
String title;
|
||||
Button close, maximize;
|
||||
Image icon;
|
||||
Size minsize;
|
||||
bool sizeable;
|
||||
TopWindow *window;
|
||||
|
||||
void SetTitle(const String& s) { title = s; Refresh(); }
|
||||
Rect GetClient() const;
|
||||
void SetClient(Rect r);
|
||||
void GripResize();
|
||||
|
||||
void Maximize();
|
||||
void Overlap();
|
||||
void ToggleMaximize();
|
||||
bool IsMaximized() const { return maximized; }
|
||||
void SyncRect();
|
||||
|
||||
TopWindowFrame();
|
||||
};
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#include "Telpp.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
#include <CtrlCore/CtrlCore.h>
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void SystemDraw::Put16(int x)
|
||||
{
|
||||
result.Cat(LOBYTE(x));
|
||||
result.Cat(HIBYTE(x));
|
||||
}
|
||||
|
||||
void SystemDraw::Put32(int x)
|
||||
{
|
||||
Put16(LOWORD(x));
|
||||
Put16(HIWORD(x));
|
||||
}
|
||||
|
||||
void SystemDraw::Put(Point p)
|
||||
{// TODO: Clamp?
|
||||
Put16(p.x);
|
||||
Put16(p.y);
|
||||
}
|
||||
|
||||
void SystemDraw::Put(Size sz)
|
||||
{
|
||||
Put((Point)sz);
|
||||
}
|
||||
|
||||
void SystemDraw::Put(const Rect& r)
|
||||
{
|
||||
Put(r.TopLeft());
|
||||
Put(r.GetSize());
|
||||
}
|
||||
|
||||
void SystemDraw::Put(const String& s)
|
||||
{
|
||||
Put32(s.GetLength());
|
||||
result.Cat(s);
|
||||
}
|
||||
|
||||
Index<int64> SystemDraw::img_index[3];
|
||||
|
||||
int SystemDraw::GetImageI(int from, Index<int64>& img_index, int maxcount, SystemDraw& w, const Image& img)
|
||||
{
|
||||
int64 id = img.GetSerialId();
|
||||
int q = img_index.Find(id);
|
||||
if(q < 0) {
|
||||
if(img_index.GetCount() < maxcount) {
|
||||
q = img_index.GetCount();
|
||||
img_index.Add(id);
|
||||
}
|
||||
else {
|
||||
q = Random(maxcount);
|
||||
img_index.Set(q, id);
|
||||
}
|
||||
w.Put8(SETIMAGE);
|
||||
w.Put16(q + from);
|
||||
w.Put(img.GetSize());
|
||||
const RGBA *end = ~img + img.GetLength();
|
||||
for(const RGBA *s = ~img; s < end; s++) {
|
||||
w.Put8(s->r);
|
||||
w.Put8(s->g);
|
||||
w.Put8(s->b);
|
||||
w.Put8(s->a);
|
||||
}
|
||||
}
|
||||
return q + from;
|
||||
}
|
||||
|
||||
int SystemDraw::GetImageI(SystemDraw& w, const Image& img)
|
||||
{
|
||||
int area = img.GetWidth() * img.GetHeight();
|
||||
return area <= 64*64 ? GetImageI(0, img_index[0], 2048, w, img) :
|
||||
area <= 512 * 512 ? GetImageI(2048, img_index[1], 64, w, img) :
|
||||
GetImageI(2048 + 64, img_index[2], 8, w, img);
|
||||
}
|
||||
|
||||
void SystemDraw::PutImage(Point p, const Image& img, const Rect& src)
|
||||
{
|
||||
int i = GetImageI(*this, img);
|
||||
Put8(IMAGE);
|
||||
Put16(i);
|
||||
Put(p);
|
||||
Put(src);
|
||||
}
|
||||
|
||||
void SystemDraw::PutRect(const Rect& r, Color color)
|
||||
{ // TODO: Support InvertColor
|
||||
if(color == InvertColor()) {
|
||||
Put8(INVERTRECT);
|
||||
Put(r);
|
||||
}
|
||||
else {
|
||||
Put8(RECT);
|
||||
Put(r);
|
||||
Put8(color.GetR());
|
||||
Put8(color.GetG());
|
||||
Put8(color.GetB());
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1 +0,0 @@
|
|||
BINARY(telpp_html, "Telpp.html")
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
#define GUI_TELPP
|
||||
|
||||
#define _TODO_ // _DBG_
|
||||
|
||||
#include <Draw/Draw.h>
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
#include <CtrlCore/stdids.h>
|
||||
#endif
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define IMAGECLASS FBImg
|
||||
#define IMAGEFILE <Telpp/FB.iml>
|
||||
#include <Draw/iml_header.h>
|
||||
|
||||
class SystemDraw : public SDraw {
|
||||
public:
|
||||
virtual void PutImage(Point p, const Image& img, const Rect& src);
|
||||
virtual void PutRect(const Rect& r, Color color);
|
||||
|
||||
public:
|
||||
enum Code {
|
||||
RECT = 0,
|
||||
IMAGE = 1,
|
||||
SETIMAGE = 2,
|
||||
INVERTRECT = 3,
|
||||
STD_CURSORIMAGE = 4,
|
||||
SETCURSORIMAGE = 5,
|
||||
CURSORIMAGE = 6,
|
||||
};
|
||||
|
||||
static Index<int64> img_index[3];
|
||||
|
||||
int GetImageI(int from, Index<int64>& img_index, int maxcount, const Image& img);
|
||||
int GetImageI(const Image& img);
|
||||
|
||||
static void ResetI() { for(int i = 0; i < 3; i++) img_index[i].Clear(); }
|
||||
|
||||
StringBuffer result;
|
||||
|
||||
void Put8(int x) { result.Cat(x); }
|
||||
void Put16(int x);
|
||||
void Put32(int x);
|
||||
void Put(Point p);
|
||||
void Put(Size sz);
|
||||
void Put(const Rect& r);
|
||||
void Put(const String& s);
|
||||
|
||||
bool CanSetSurface() { return false; }
|
||||
static void Flush() {}
|
||||
};
|
||||
|
||||
struct BackDraw__ : public SystemDraw {
|
||||
BackDraw__() : SystemDraw() {}
|
||||
};
|
||||
|
||||
class BackDraw : public BackDraw__ { // Dummy only, as we are running in GlobalBackBuffer mode
|
||||
Size size;
|
||||
Draw *painting;
|
||||
Point painting_offset;
|
||||
ImageBuffer ib;
|
||||
|
||||
public:
|
||||
virtual bool IsPaintingOp(const Rect& r) const;
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
class ImageDraw : public SImageDraw {
|
||||
public:
|
||||
ImageDraw(Size sz) : SImageDraw(sz) {}
|
||||
ImageDraw(int cx, int cy) : SImageDraw(cx, cy) {}
|
||||
};
|
||||
|
||||
void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, uint64 pattern);
|
||||
|
||||
class TopWindowFrame;
|
||||
|
||||
#define GUIPLATFORM_CTRL_TOP_DECLS Ctrl *owner_window;
|
||||
|
||||
#define GUIPLATFORM_CTRL_DECLS_INCLUDE <Telpp/Ctrl.h>
|
||||
|
||||
#define GUIPLATFORM_PASTECLIP_DECLS \
|
||||
bool dnd; \
|
||||
friend struct DnDLoop; \
|
||||
|
||||
#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE <Telpp/Top.h>
|
||||
|
||||
class PrinterJob { // Dummy only...
|
||||
NilDraw nil;
|
||||
Vector<int> pages;
|
||||
|
||||
public:
|
||||
Draw& GetDraw() { return nil; }
|
||||
operator Draw&() { return GetDraw(); }
|
||||
const Vector<int>& GetPages() const { return pages; }
|
||||
int operator[](int i) const { return 0; }
|
||||
int GetPageCount() const { return 0; }
|
||||
|
||||
bool Execute() { return false; }
|
||||
|
||||
PrinterJob& Landscape(bool b = true) { return *this; }
|
||||
PrinterJob& MinMaxPage(int minpage, int maxpage) { return *this; }
|
||||
PrinterJob& PageCount(int n) { return *this; }
|
||||
PrinterJob& CurrentPage(int currentpage) { return *this; }
|
||||
PrinterJob& Name(const char *_name) { return *this; }
|
||||
|
||||
PrinterJob(const char *name = NULL) {}
|
||||
~PrinterJob() {}
|
||||
};
|
||||
|
||||
void USDLSetup(dword flags);
|
||||
|
||||
|
||||
void InitTelpp();
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#define GUIPLATFORM_INCLUDE_AFTER <Telpp/After.h>
|
||||
|
|
@ -1,285 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<canvas id="myCanvas" width="1000" height="1000" style="border:0px" tabindex="1" oncontextmenu="return false;">
|
||||
Your browser does not support the HTML5 canvas tag.
|
||||
</canvas>
|
||||
|
||||
<script>
|
||||
function Log(msg)
|
||||
{
|
||||
// if (window.console && console.log)
|
||||
// console.log(msg); //for firebug
|
||||
}
|
||||
|
||||
function Char(p, ch)
|
||||
{
|
||||
if(p.pos < p.text.length && (255 & p.text.charCodeAt(p.pos)) == ch) {
|
||||
p.pos++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function Get8(p)
|
||||
{
|
||||
return p.pos < p.text.length ? (255 & p.text.charCodeAt(p.pos++)) : 0;
|
||||
}
|
||||
|
||||
function Get16(p)
|
||||
{
|
||||
var l = Get8(p);
|
||||
var h = Get8(p);
|
||||
return (h << 8) | l;
|
||||
}
|
||||
|
||||
function Get32(p)
|
||||
{
|
||||
var l = Get16(p);
|
||||
var h = Get16(p);
|
||||
return (h << 16) | l;
|
||||
}
|
||||
|
||||
function GetString(p)
|
||||
{
|
||||
var n = Get32(p);
|
||||
var s = "";
|
||||
for(var i = 0; i < n; i++)
|
||||
s += String.fromCharCode(Get8(p));
|
||||
return s;
|
||||
}
|
||||
|
||||
function ProcessDraw(s)
|
||||
{
|
||||
var x, y, cx, cy, r, g, b, imgData, i, n, px, py;
|
||||
var p = new Object;
|
||||
p.text = s;
|
||||
p.pos = 0;
|
||||
|
||||
var canvas = document.getElementById("myCanvas");
|
||||
var ctx = canvas.getContext("2d");
|
||||
|
||||
while(p.pos < p.text.length) {
|
||||
Log(p.pos + ": " + p.text.charCodeAt(p.pos));
|
||||
if(Char(p, 0)) {
|
||||
x = Get16(p);
|
||||
y = Get16(p);
|
||||
cx = Get16(p);
|
||||
cy = Get16(p);
|
||||
r = Get8(p);
|
||||
g = Get8(p);
|
||||
b = Get8(p);
|
||||
Log("rect: " + x + ", " + y + ", " + cx + ", " + cy);
|
||||
var c = "rgb(" + r + "," + g + "," + b + ")";
|
||||
ctx.fillStyle = c;
|
||||
Log("color: " + c);
|
||||
ctx.fillRect(x, y, cx, cy);
|
||||
}
|
||||
else
|
||||
if(Char(p, 3)) {
|
||||
x = Get16(p);
|
||||
y = Get16(p);
|
||||
cx = Get16(p);
|
||||
cy = Get16(p);
|
||||
Log("irect: " + x + ", " + y + ", " + cx + ", " + cy);
|
||||
var imageData = ctx.getImageData(x, y, cx, cy);
|
||||
var data = imageData.data;
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
data[i] = 255 - data[i];
|
||||
data[i + 1] = 255 - data[i + 1];
|
||||
data[i + 2] = 255 - data[i + 2];
|
||||
}
|
||||
ctx.putImageData(imageData, x, y);
|
||||
}
|
||||
else
|
||||
if(Char(p, 2)) {
|
||||
r = Get16(p);
|
||||
cx = Get16(p);
|
||||
cy = Get16(p);
|
||||
n = cx * cy * 4;
|
||||
imgData = ctx.createImageData(cx, cy);
|
||||
for(i = 0; i < n; i++)
|
||||
imgData.data[i] = Get8(p);
|
||||
var img = document.createElement('canvas');
|
||||
img.width = cx;
|
||||
img.height = cy;
|
||||
img.getContext("2d").putImageData(imgData, 0, 0);
|
||||
window.img_cache[r] = img;
|
||||
Log("Set image: " + r);
|
||||
}
|
||||
else
|
||||
if(Char(p, 1)) {
|
||||
n = Get16(p);
|
||||
|
||||
px = Get16(p);
|
||||
py = Get16(p);
|
||||
x = Get16(p);
|
||||
y = Get16(p);
|
||||
cx = Get16(p);
|
||||
cy = Get16(p);
|
||||
|
||||
Log("Draw image: " + n);
|
||||
ctx.drawImage(window.img_cache[n], x, y, cx, cy, px, py, cx, cy);
|
||||
}
|
||||
else
|
||||
if(Char(p, 4)) {
|
||||
canvas.style.cursor = [
|
||||
"default", // should not happen
|
||||
"default", // Arrow
|
||||
"wait", // Wait
|
||||
"text", // IBeam
|
||||
"not-allowed", // No
|
||||
"move", // SizeAll
|
||||
"ew-resize", // SizeHorz
|
||||
"ns-resize", // SizeVert
|
||||
"nw-resize", // SizeTopLeft
|
||||
"n-resize", // SizeTop
|
||||
"ne-resize", // SizeTopRight
|
||||
"w-resize", // SizeLeft
|
||||
"e-resize", // SizeRight
|
||||
"sw-resize", // SizeBottomLeft
|
||||
"s-resize", // SizeBottom
|
||||
"se-resize", // SizeBottomRight
|
||||
"pointer" // Hand
|
||||
][Get8(p)];
|
||||
}
|
||||
else
|
||||
if(Char(p, 5)) {
|
||||
i = Get16(p);
|
||||
cursor_cache[i] = GetString(p);
|
||||
}
|
||||
else
|
||||
if(Char(p, 6)) {
|
||||
i = Get16(p);
|
||||
canvas.style.cursor = cursor_cache[i];
|
||||
Log(cursor_cache[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.img_cache = {};
|
||||
window.event_queue = "I\n";
|
||||
window.cursor_cache = {};
|
||||
|
||||
var canvas = document.getElementById("myCanvas");
|
||||
|
||||
function key_flags(event)
|
||||
{
|
||||
return " " + 1*event.shiftKey + 1*event.ctrlKey + 1*event.altKey + "\n";
|
||||
}
|
||||
|
||||
function mouse_event(event)
|
||||
{
|
||||
return " " + event.clientX + " " + event.clientY + " " + (new Date).getTime() + key_flags(event);
|
||||
}
|
||||
|
||||
canvas.onmousemove = function(event)
|
||||
{
|
||||
event_queue += "M" + mouse_event(event);
|
||||
Ping();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onmousedown = function(event)
|
||||
{
|
||||
event_queue += "D " + event.button + mouse_event(event);
|
||||
Ping();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onmouseout = function(event)
|
||||
{
|
||||
event_queue += "O\n";
|
||||
Ping();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onmouseup = function(event)
|
||||
{
|
||||
event_queue += "U " + event.button + mouse_event(event);
|
||||
Ping();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onwheel = function(event)
|
||||
{
|
||||
event_queue += "W " + event.deltaY + mouse_event(event);
|
||||
}
|
||||
|
||||
document.onkeydown = function(event)
|
||||
{
|
||||
event_queue += "K " + event.keyCode + " " + event.which + key_flags(event);
|
||||
Ping();
|
||||
Ping();
|
||||
}
|
||||
|
||||
document.onkeypress = function(event)
|
||||
{
|
||||
event_queue += "C " + event.keyCode + " " + event.which + key_flags(event);
|
||||
event.preventDefault();
|
||||
Ping();
|
||||
}
|
||||
|
||||
document.onkeyup = function(event)
|
||||
{
|
||||
event_queue += "k " + event.keyCode + " " + event.which + key_flags(event);
|
||||
event.preventDefault();
|
||||
Ping();
|
||||
}
|
||||
|
||||
function ResizeCanvas()
|
||||
{
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
event_queue += "R " + canvas.width + ' ' + canvas.height + "\n";
|
||||
Ping();
|
||||
}
|
||||
|
||||
window.onresize = ResizeCanvas;
|
||||
|
||||
var Processing = false;
|
||||
var timerID;
|
||||
|
||||
function Ping()
|
||||
{
|
||||
if(!Processing) {
|
||||
Processing = true;
|
||||
var req = new XMLHttpRequest();
|
||||
req.open('POST', 'localhost', true);
|
||||
req.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
req.send(event_queue);
|
||||
event_queue = "";
|
||||
req.onreadystatechange = function() {
|
||||
Log("onreadystatechange");
|
||||
if(req.readyState == 4 && req.status == 200) {
|
||||
ProcessDraw(req.responseText);
|
||||
Processing = false; // TODO: Resolve timeout
|
||||
}
|
||||
}
|
||||
}
|
||||
if(timerID != undefined)
|
||||
clearTimeout(timerID);
|
||||
timerID = setTimeout(Ping, 20);
|
||||
// Log("Ping");
|
||||
}
|
||||
|
||||
ResizeCanvas();
|
||||
|
||||
Ping();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
description "SDL20 U++ backend\377";
|
||||
|
||||
uses
|
||||
Painter,
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
Telpp.h,
|
||||
Keys.h,
|
||||
After.h,
|
||||
Local.h,
|
||||
TelDraw.cpp,
|
||||
Image.cpp,
|
||||
FB.iml,
|
||||
Ctrl.h,
|
||||
DrawDragRect.cpp,
|
||||
Ctrl.cpp,
|
||||
Wnd.cpp,
|
||||
Cursor.cpp,
|
||||
Paint.cpp,
|
||||
Event.cpp,
|
||||
Top.h,
|
||||
TopFrame.cpp,
|
||||
Top.cpp,
|
||||
Clip.cpp,
|
||||
DnD.cpp,
|
||||
ChSysInit.cpp,
|
||||
Telpp.brc,
|
||||
Telpp.html;
|
||||
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
|
||||
void TopWindow::SyncFrameRect(const Rect& r)
|
||||
{
|
||||
frame->SetClient(r);
|
||||
}
|
||||
|
||||
void TopWindow::DestroyFrame()
|
||||
{
|
||||
if(frame->IsOpen())
|
||||
frame->DestroyWnd();
|
||||
}
|
||||
|
||||
void TopWindow::GripResize()
|
||||
{
|
||||
frame->GripResize();
|
||||
}
|
||||
|
||||
void TopWindow::SyncSizeHints()
|
||||
{
|
||||
SyncCaption();
|
||||
}
|
||||
|
||||
void TopWindow::SyncTitle()
|
||||
{
|
||||
SyncCaption();
|
||||
}
|
||||
|
||||
void TopWindow::SyncCaption()
|
||||
{
|
||||
GuiLock __;
|
||||
frame->title = title.ToString();
|
||||
#ifdef _DEBUG
|
||||
frame->title = "TELPP";
|
||||
#endif
|
||||
frame->minsize = minsize;
|
||||
frame->close.Show(!noclosebox);
|
||||
frame->maximize.Show(maximizebox);
|
||||
frame->sizeable = sizeable;
|
||||
frame->RefreshLayout();
|
||||
frame->Refresh();
|
||||
frame->close <<= Proxy(WhenClose);
|
||||
frame->icon = icon;
|
||||
frame->Enable(IsEnabled());
|
||||
}
|
||||
|
||||
void TopWindow::State(int reason)
|
||||
{
|
||||
SyncCaption();
|
||||
}
|
||||
|
||||
void TopWindow::SyncRect()
|
||||
{
|
||||
frame->SyncRect();
|
||||
Rect r = frame->GetClient();
|
||||
if(r != GetRect())
|
||||
SetRect(r);
|
||||
}
|
||||
|
||||
void TopWindow::Open(Ctrl *owner)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("Open " << Upp::Name(owner));
|
||||
Rect r = GetRect();
|
||||
if(r.IsEmpty())
|
||||
SetRect(GetDefaultWindowRect());
|
||||
else
|
||||
if(r.left == 0 && r.top == 0)
|
||||
if(owner && center == 1)
|
||||
SetRect(owner->GetRect().CenterRect(r.GetSize()));
|
||||
else
|
||||
if(center)
|
||||
SetRect(GetWorkArea().CenterRect(r.GetSize()));
|
||||
frame->SetClient(GetRect());
|
||||
frame->window = this;
|
||||
frame->PopUp(owner, false, true);
|
||||
PopUp(frame, false, true);
|
||||
popup = false;
|
||||
SetRect(frame->GetClient());
|
||||
SyncCaption();
|
||||
if(state == MAXIMIZED)
|
||||
frame->Maximize();
|
||||
}
|
||||
|
||||
void TopWindow::Open()
|
||||
{
|
||||
Open(GetActiveCtrl());
|
||||
}
|
||||
|
||||
void TopWindow::OpenMain()
|
||||
{
|
||||
Open(NULL);
|
||||
}
|
||||
|
||||
void TopWindow::Minimize(bool effect)
|
||||
{
|
||||
// state = MINIMIZED;
|
||||
}
|
||||
|
||||
TopWindow& TopWindow::FullScreen(bool b)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
void TopWindow::Maximize(bool effect)
|
||||
{
|
||||
state = MAXIMIZED;
|
||||
frame->Maximize();
|
||||
}
|
||||
|
||||
void TopWindow::Overlap(bool effect)
|
||||
{
|
||||
GuiLock __;
|
||||
state = OVERLAPPED;
|
||||
frame->Overlap();
|
||||
}
|
||||
|
||||
TopWindow& TopWindow::TopMost(bool b, bool stay_top)
|
||||
{
|
||||
GuiLock __;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool TopWindow::IsTopMost() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopWindow::GuiPlatformConstruct()
|
||||
{
|
||||
frame = new TopWindowFrame;
|
||||
}
|
||||
|
||||
void TopWindow::GuiPlatformDestruct()
|
||||
{
|
||||
delete frame;
|
||||
}
|
||||
|
||||
void TopWindow::SerializePlacement(Stream& s, bool reminimize)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
//$ class TopWindow {
|
||||
public:
|
||||
virtual void State(int reason);
|
||||
|
||||
private:
|
||||
TopWindowFrame *frame;
|
||||
|
||||
void SyncRect();
|
||||
void SyncFrameRect(const Rect& r);
|
||||
void DestroyFrame();
|
||||
|
||||
friend class Ctrl;
|
||||
|
||||
public:
|
||||
void GripResize();
|
||||
//$ };
|
||||
|
|
@ -1,236 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
#define LDUMP(x) //DDUMP(x)
|
||||
|
||||
TopWindowFrame::TopWindowFrame()
|
||||
{
|
||||
close.SetImage(FBImg::close());
|
||||
close.EdgeStyle();
|
||||
Add(close);
|
||||
maximize.SetImage(FBImg::maximize());
|
||||
maximize.EdgeStyle();
|
||||
Add(maximize);
|
||||
maximize <<= THISBACK(ToggleMaximize);
|
||||
maximized = false;
|
||||
sizeable = false;
|
||||
holding = false;
|
||||
}
|
||||
|
||||
void TopWindowFrame::SyncRect()
|
||||
{
|
||||
if(maximized) {
|
||||
Size sz = GetWorkArea().GetSize();
|
||||
if(GetRect().GetSize() != sz)
|
||||
SetRect(sz);
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::Maximize()
|
||||
{
|
||||
if(!maximized && maximize.IsShown()) {
|
||||
maximized = true;
|
||||
overlapped = GetRect();
|
||||
SetRect(GetWorkArea().GetSize());
|
||||
maximize.SetImage(FBImg::overlap());
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::Overlap()
|
||||
{
|
||||
if(maximized && maximize.IsShown()) {
|
||||
maximized = false;
|
||||
SetRect(overlapped);
|
||||
maximize.SetImage(FBImg::maximize());
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::ToggleMaximize()
|
||||
{
|
||||
if(maximized)
|
||||
Overlap();
|
||||
else
|
||||
Maximize();
|
||||
}
|
||||
|
||||
Rect TopWindowFrame::Margins() const
|
||||
{
|
||||
return maximized ? Rect(0, 0, 0, 0) : ChMargins(FBImg::border());
|
||||
}
|
||||
|
||||
void TopWindowFrame::Paint(Draw& w)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
Rect m = Margins();
|
||||
int c = GetStdFontCy() + 4;
|
||||
ChPaintEdge(w, sz, FBImg::border());
|
||||
ChPaint(w, m.left, m.top, sz.cx - m.left - m.right, GetStdFontCy() + 4,
|
||||
window->IsForeground() ? FBImg::title() : FBImg::bgtitle());
|
||||
int tx = m.left + 2;
|
||||
int tcx = sz.cx - m.left - m.right - 4 - c * (close.IsShown() + maximize.IsShown());
|
||||
if(!IsNull(icon)) {
|
||||
Image h = icon;
|
||||
if(h.GetWidth() > c || h.GetHeight() > c)
|
||||
h = Rescale(h, GetFitSize(h.GetSize(), Size(c)));
|
||||
w.DrawImage(tx, m.top + 2, h);
|
||||
tx += c;
|
||||
tcx -= c;
|
||||
}
|
||||
DrawTextEllipsis(w, tx, m.top + 2, tcx, title, "..", StdFont(), SColorHighlightText());
|
||||
}
|
||||
|
||||
void TopWindowFrame::Layout()
|
||||
{
|
||||
Size sz = GetSize();
|
||||
Rect m = Margins();
|
||||
int c = GetStdFontCy() + 4;
|
||||
int x = sz.cx - m.right;
|
||||
if(close.IsShown())
|
||||
close.SetRect(x -= c, m.top, c, c);
|
||||
if(maximize.IsShown())
|
||||
maximize.SetRect(x -= c, m.top, c, c);
|
||||
}
|
||||
|
||||
Rect TopWindowFrame::GetClient() const
|
||||
{
|
||||
Rect r = GetRect();
|
||||
Rect m = Margins();
|
||||
r.left += m.left;
|
||||
r.right -= m.right;
|
||||
r.top += m.top;
|
||||
r.bottom -= m.bottom;
|
||||
r.top += GetStdFontCy() + 4;
|
||||
return r;
|
||||
}
|
||||
|
||||
Rect TopWindowFrame::ComputeClient(Rect r)
|
||||
{
|
||||
Rect m = Margins();
|
||||
r.left -= m.left;
|
||||
r.right += m.right;
|
||||
r.top -= m.top;
|
||||
r.bottom += m.bottom;
|
||||
r.top -= GetStdFontCy() + 4;
|
||||
return r;
|
||||
}
|
||||
|
||||
void TopWindowFrame::SetClient(Rect r)
|
||||
{
|
||||
SetRect(ComputeClient(r));
|
||||
}
|
||||
|
||||
Point TopWindowFrame::GetDragMode(Point p)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
Rect m = ChMargins(FBImg::border());
|
||||
Point dir;
|
||||
dir.y = p.y < m.top ? -1 : p.y > sz.cy - m.top ? 1 : 0;
|
||||
dir.x = p.x < m.left ? -1 : p.x > sz.cx - m.right ? 1 : 0;
|
||||
return dir;
|
||||
}
|
||||
|
||||
void TopWindowFrame::StartDrag()
|
||||
{
|
||||
if(maximized)
|
||||
return;
|
||||
if(!sizeable && (dir.x || dir.y))
|
||||
return;
|
||||
SetCapture();
|
||||
startrect = GetRect();
|
||||
startpos = GetMousePos();
|
||||
LLOG("START DRAG ---------------");
|
||||
}
|
||||
|
||||
void TopWindowFrame::GripResize()
|
||||
{
|
||||
dir = Point(1, 1);
|
||||
StartDrag();
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftDown(Point p, dword keyflags)
|
||||
{
|
||||
dir = GetDragMode(p);
|
||||
StartDrag();
|
||||
}
|
||||
|
||||
void TopWindowFrame::CancelMode()
|
||||
{
|
||||
holding = false;
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftUp(Point p, dword keyflags)
|
||||
{
|
||||
holding = false;
|
||||
}
|
||||
|
||||
void TopWindowFrame::Hold()
|
||||
{
|
||||
if(HasCapture()) {
|
||||
if(HasMouse() && GetMouseLeft() && holding)
|
||||
StartDrag();
|
||||
ReleaseCapture();
|
||||
holding = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftHold(Point p, dword keyflags)
|
||||
{
|
||||
/* if(HasCapture() || FullWindowDrag)
|
||||
return;
|
||||
dir = GetDragMode(p);
|
||||
if(!dir.x && !dir.y)
|
||||
StartDrag();*/
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftDouble(Point p, dword keyflags)
|
||||
{
|
||||
ToggleMaximize();
|
||||
IgnoreMouseUp();
|
||||
}
|
||||
|
||||
void TopWindowFrame::MouseMove(Point, dword)
|
||||
{
|
||||
LDUMP(HasWndCapture());
|
||||
LDUMP(HasCapture());
|
||||
if(!HasCapture() || holding)
|
||||
return;
|
||||
Size msz = ComputeClient(minsize).GetSize();
|
||||
Point p = GetMousePos() - startpos;
|
||||
Rect r = startrect;
|
||||
if(dir.x == -1)
|
||||
r.left = min(r.left + p.x, startrect.right - msz.cx);
|
||||
if(dir.x == 1)
|
||||
r.right = max(r.right + p.x, startrect.left + msz.cx);
|
||||
if(dir.y == -1)
|
||||
r.top = min(r.top + p.y, startrect.bottom - msz.cy);
|
||||
if(dir.y == 1)
|
||||
r.bottom = max(r.bottom + p.y, startrect.top + msz.cy);
|
||||
if(dir.y == 0 && dir.x == 0)
|
||||
r.Offset(p);
|
||||
SetRect(r);
|
||||
}
|
||||
|
||||
Image TopWindowFrame::GetDragImage(Point dir)
|
||||
{
|
||||
static Image (*im[9])() = {
|
||||
Image::SizeTopLeft, Image::SizeLeft, Image::SizeBottomLeft,
|
||||
Image::SizeTop, Image::Arrow, Image::SizeBottom,
|
||||
Image::SizeTopRight, Image::SizeRight, Image::SizeBottomRight,
|
||||
};
|
||||
return (*im[(dir.x + 1) * 3 + (dir.y + 1)])();
|
||||
}
|
||||
|
||||
Image TopWindowFrame::CursorImage(Point p, dword)
|
||||
{
|
||||
if(!sizeable)
|
||||
return Image::Arrow();
|
||||
return GetDragImage(HasCapture() ? dir : GetDragMode(p));
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,459 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TELPP
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) LOG(x)
|
||||
#define LDUMP(x) //DDUMP(x)
|
||||
#define LDUMPC(x) //DDUMPC(x)
|
||||
#define LTIMING(x) RTIMING(x)
|
||||
|
||||
Ptr<Ctrl> Ctrl::desktop;
|
||||
Vector<Ctrl *> Ctrl::topctrl;
|
||||
|
||||
bool Ctrl::invalid;
|
||||
|
||||
bool Ctrl::sdlMouseIsIn;
|
||||
|
||||
Point Ctrl::fbCursorPos = Null;
|
||||
Image Ctrl::fbCursorImage;
|
||||
Rect Ctrl::fbCaretRect;
|
||||
int Ctrl::fbCaretTm;
|
||||
bool Ctrl::fbEndSession;
|
||||
int Ctrl::PaintLock;
|
||||
|
||||
bool Ctrl::SystemCursor;
|
||||
|
||||
void Ctrl::SetDesktop(Ctrl& q)
|
||||
{
|
||||
desktop = &q;
|
||||
desktop->SetOpen(true);
|
||||
desktop->NewTop();
|
||||
invalid = true;
|
||||
}
|
||||
|
||||
void Ctrl::EndSession()
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("Ctrl::EndSession");
|
||||
fbEndSession = true;
|
||||
EndSessionLoopNo = EventLoopNo;
|
||||
}
|
||||
|
||||
void Ctrl::Exit()
|
||||
{
|
||||
TopWindow::ShutdownWindows();
|
||||
Ctrl::CloseTopCtrls();
|
||||
_TODO_
|
||||
}
|
||||
|
||||
void Ctrl::SetDesktopSize(Size sz)
|
||||
{
|
||||
if(desktop)
|
||||
desktop->SetRect(sz);
|
||||
invalid = true;
|
||||
SyncTopWindows();
|
||||
}
|
||||
|
||||
int Ctrl::FindTopCtrl() const
|
||||
{
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(this == topctrl[i])
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Ctrl::IsAlphaSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ctrl::IsCompositedGui()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector<Ctrl *> Ctrl::GetTopCtrls()
|
||||
{
|
||||
Vector<Ctrl *> ctrl;
|
||||
if(desktop)
|
||||
ctrl.Add(desktop);
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(!dynamic_cast<TopWindowFrame *>(topctrl[i]))
|
||||
ctrl.Add(topctrl[i]);
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
Ctrl *Ctrl::GetOwner()
|
||||
{
|
||||
GuiLock __;
|
||||
int q = FindTopCtrl();
|
||||
if(q > 0 && topctrl[q]->top) {
|
||||
Ctrl *x = topctrl[q]->top->owner_window;
|
||||
LDUMP(Upp::Name(x));
|
||||
return dynamic_cast<TopWindowFrame *>(x) ? x->GetOwner() : x;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Ctrl *Ctrl::GetActiveCtrl()
|
||||
{
|
||||
GuiLock __;
|
||||
return focusCtrl ? focusCtrl->GetTopCtrl() : NULL;
|
||||
}
|
||||
|
||||
// Vector<Callback> Ctrl::hotkey;
|
||||
|
||||
int Ctrl::RegisterSystemHotKey(dword key, Callback cb)
|
||||
{
|
||||
/* ASSERT(key >= K_DELTA);
|
||||
int q = hotkey.GetCount();
|
||||
for(int i = 0; i < hotkey.GetCount(); i++)
|
||||
if(!hotkey[i]) {
|
||||
q = i;
|
||||
break;
|
||||
}
|
||||
hotkey.At(q) = cb;
|
||||
dword mod = 0;
|
||||
if(key & K_ALT)
|
||||
mod |= MOD_ALT;
|
||||
if(key & K_SHIFT)
|
||||
mod |= MOD_SHIFT;
|
||||
if(key & K_CTRL)
|
||||
mod |= MOD_CONTROL;
|
||||
|
||||
return RegisterHotKey(NULL, q, mod, key & 0xffff) ? q : -1;*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Ctrl::UnregisterSystemHotKey(int id)
|
||||
{
|
||||
/* if(id >= 0 && id < hotkey.GetCount()) {
|
||||
UnregisterHotKey(NULL, id);
|
||||
hotkey[id].Clear();
|
||||
}*/
|
||||
}
|
||||
|
||||
void Ctrl::SyncTopWindows()
|
||||
{
|
||||
for(int i = 0; i < topctrl.GetCount(); i++) {
|
||||
TopWindow *w = dynamic_cast<TopWindow *>(topctrl[i]);
|
||||
if(w)
|
||||
w->SyncRect();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ViewDraw::ViewDraw(Ctrl *ctrl)
|
||||
{
|
||||
if(Ctrl::invalid)
|
||||
Ctrl::DoPaint();
|
||||
Ctrl::invalid = false;
|
||||
Ctrl::RemoveCursor();
|
||||
Ctrl::RemoveCaret();
|
||||
Rect r = ctrl->GetScreenView();
|
||||
Ctrl::invalid.Add(r);
|
||||
Ctrl::AddUpdate(r);
|
||||
for(int i = max(ctrl->GetTopCtrl()->FindTopCtrl() + 1, 0); i < Ctrl::topctrl.GetCount(); i++) {
|
||||
Rect rr = Ctrl::topctrl[i]->GetScreenRect();
|
||||
ExcludeClip(rr);
|
||||
Subtract(Ctrl::invalid, rr);
|
||||
}
|
||||
Offset(r.TopLeft());
|
||||
}
|
||||
|
||||
ViewDraw::~ViewDraw()
|
||||
{
|
||||
Ctrl::DoUpdate();
|
||||
}
|
||||
*/
|
||||
|
||||
Rect Ctrl::GetClipBound(const Vector<Rect>& inv, const Rect& r)
|
||||
{
|
||||
Rect ri = Null;
|
||||
for(int j = 0; j < inv.GetCount(); j++) {
|
||||
Rect rr = inv[j] & r;
|
||||
if(!rr.IsEmpty())
|
||||
ri = IsNull(ri) ? rr : rr | ri;
|
||||
}
|
||||
return ri;
|
||||
}
|
||||
|
||||
void Ctrl::WndUpdate(const Rect&)
|
||||
{
|
||||
GuiLock __;
|
||||
Invalidate();
|
||||
DoPaint();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetWndScreenRect() const
|
||||
{
|
||||
GuiLock __;
|
||||
return GetRect();
|
||||
}
|
||||
|
||||
void Ctrl::WndShow(bool b)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
void Ctrl::WndUpdate()
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
bool Ctrl::IsWndOpen() const {
|
||||
GuiLock __;
|
||||
return FindTopCtrl() >= 0 || this == desktop;
|
||||
}
|
||||
|
||||
void Ctrl::SetAlpha(byte alpha)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
Rect Ctrl::GetWorkArea() const
|
||||
{
|
||||
GuiLock __;
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
void Ctrl::GetWorkArea(Array<Rect>& rc)
|
||||
{
|
||||
GuiLock __;
|
||||
Array<Rect> r;
|
||||
r.Add(GetVirtualScreenArea());
|
||||
}
|
||||
|
||||
Rect Ctrl::GetVirtualWorkArea()
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetWorkArea(Point pt)
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetVirtualScreenArea()
|
||||
{
|
||||
GuiLock __;
|
||||
return desktop ? desktop->GetRect() : Rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
Rect Ctrl::GetPrimaryWorkArea()
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetPrimaryScreenArea()
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
int Ctrl::GetKbdDelay()
|
||||
{
|
||||
GuiLock __;
|
||||
return 500;
|
||||
}
|
||||
|
||||
int Ctrl::GetKbdSpeed()
|
||||
{
|
||||
GuiLock __;
|
||||
return 1000 / 32;
|
||||
}
|
||||
|
||||
void Ctrl::DestroyWnd()
|
||||
{
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(topctrl[i]->top && topctrl[i]->top->owner_window == this)
|
||||
topctrl[i]->WndDestroy();
|
||||
int q = FindTopCtrl();
|
||||
if(q >= 0) {
|
||||
Invalidate();
|
||||
topctrl.Remove(q);
|
||||
}
|
||||
if(top) {
|
||||
delete top;
|
||||
top = NULL;
|
||||
}
|
||||
isopen = false;
|
||||
TopWindow *win = dynamic_cast<TopWindow *>(this);
|
||||
if(win)
|
||||
win->DestroyFrame();
|
||||
}
|
||||
|
||||
void Ctrl::WndDestroy()
|
||||
{
|
||||
DestroyWnd();
|
||||
if(topctrl.GetCount())
|
||||
topctrl.Top()->ActivateWnd();
|
||||
}
|
||||
|
||||
void Ctrl::PutForeground()
|
||||
{
|
||||
int q = FindTopCtrl();
|
||||
if(q >= 0) {
|
||||
Invalidate();
|
||||
topctrl.Remove(q);
|
||||
topctrl.Add(this);
|
||||
}
|
||||
Vector< Ptr<Ctrl> > fw;
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(topctrl[i] && topctrl[i]->top && topctrl[i]->top->owner_window == this && topctrl[i] != this)
|
||||
fw.Add(topctrl[i]);
|
||||
for(int i = 0; i < fw.GetCount(); i++)
|
||||
if(fw[i])
|
||||
fw[i]->PutForeground();
|
||||
}
|
||||
|
||||
void Ctrl::SetWndForeground()
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsOpen());
|
||||
if(IsWndForeground())
|
||||
return;
|
||||
Ctrl *to = this;
|
||||
while(to->top && to->top->owner_window)
|
||||
to = to->top->owner_window;
|
||||
to->PutForeground();
|
||||
if(this != focusCtrl)
|
||||
ActivateWnd();
|
||||
}
|
||||
|
||||
bool Ctrl::IsWndForeground() const
|
||||
{
|
||||
GuiLock __;
|
||||
bool b = false;
|
||||
for(int i = 0; i < topctrl.GetCount(); i++) {
|
||||
const TopWindow *tw = dynamic_cast<const TopWindow *>(topctrl[i]);
|
||||
if(tw)
|
||||
b = tw == this;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
void Ctrl::WndEnable(bool)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
bool Ctrl::SetWndFocus()
|
||||
{
|
||||
GuiLock __;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::HasWndFocus() const
|
||||
{
|
||||
GuiLock __;
|
||||
return focusCtrl && focusCtrl->GetTopCtrl() == this;
|
||||
}
|
||||
|
||||
bool Ctrl::SetWndCapture()
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsMainThread());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::ReleaseWndCapture()
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsMainThread());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::HasWndCapture() const
|
||||
{
|
||||
GuiLock __;
|
||||
return captureCtrl && captureCtrl->GetTopCtrl() == this;
|
||||
}
|
||||
|
||||
void Ctrl::WndInvalidateRect(const Rect&)
|
||||
{
|
||||
GuiLock __;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void Ctrl::WndSetPos(const Rect& rect)
|
||||
{
|
||||
GuiLock __;
|
||||
TopWindow *w = dynamic_cast<TopWindow *>(this);
|
||||
if(w)
|
||||
w->SyncFrameRect(rect);
|
||||
Invalidate();
|
||||
SetWndRect(rect);
|
||||
}
|
||||
|
||||
void Ctrl::WndScrollView(const Rect& r, int dx, int dy)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("ScrollView " << rect);
|
||||
WndInvalidateRect(r);
|
||||
}
|
||||
|
||||
void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, bool topmost)
|
||||
{
|
||||
ASSERT(!IsChild() && !IsOpen() && FindTopCtrl() < 0);
|
||||
NewTop();
|
||||
if(owner) {
|
||||
Ctrl *owner_window = owner->GetTopWindow();
|
||||
if(!owner_window)
|
||||
owner_window = owner->GetTopCtrl();
|
||||
ASSERT(owner_window->IsOpen());
|
||||
if(owner_window != desktop) {
|
||||
owner_window->SetForeground();
|
||||
top->owner_window = owner_window;
|
||||
}
|
||||
}
|
||||
topctrl.Add(this);
|
||||
popup = isopen = true;
|
||||
RefreshLayoutDeep();
|
||||
if(activate) SetFocusWnd();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetDefaultWindowRect() {
|
||||
GuiLock __;
|
||||
static int ii = 0;
|
||||
Rect rect = GetVirtualScreenArea();
|
||||
Size sz = rect.GetSize();
|
||||
rect.Deflate(sz / 10);
|
||||
rect.Offset(Size(GetStdFontCy(), 2 * GetStdFontCy()) * (++ii % 8));
|
||||
return rect;
|
||||
}
|
||||
|
||||
Vector<WString> SplitCmdLine__(const char *cmd)
|
||||
{
|
||||
Vector<WString> out;
|
||||
while(*cmd)
|
||||
if((byte)*cmd <= ' ')
|
||||
cmd++;
|
||||
else if(*cmd == '\"') {
|
||||
WString quoted;
|
||||
while(*++cmd && (*cmd != '\"' || *++cmd == '\"'))
|
||||
quoted.Cat(FromSystemCharset(String(cmd, 1)).ToWString());
|
||||
out.Add(quoted);
|
||||
}
|
||||
else {
|
||||
const char *begin = cmd;
|
||||
while((byte)*cmd > ' ')
|
||||
cmd++;
|
||||
out.Add(String(begin, cmd).ToWString());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void Ctrl::InstallPanicBox()
|
||||
{
|
||||
}
|
||||
|
||||
void Ctrl::SysEndLoop()
|
||||
{
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#ifndef _Telpp_icpp_init_stub
|
||||
#define _Telpp_icpp_init_stub
|
||||
#include "Painter/init"
|
||||
#include "CtrlLib/init"
|
||||
#endif
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
class ViewDraw : public SystemDraw {
|
||||
public:
|
||||
ViewDraw(Ctrl *ctrl);
|
||||
~ViewDraw();
|
||||
};
|
||||
|
||||
/*
|
||||
class ViewDraw : public SystemDraw {
|
||||
Vector<Rect> dummy;
|
||||
public:
|
||||
ViewDraw(Ctrl *) : SystemDraw(Ctrl::framebuffer, dummy) { dummy.Add(Rect(10, 10, 100, 100)); }
|
||||
};
|
||||
*/
|
||||
|
||||
class DHCtrl : Ctrl {};
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void ChSysInit()
|
||||
{
|
||||
CtrlImg::Reset();
|
||||
CtrlsImg::Reset();
|
||||
ChReset();
|
||||
}
|
||||
|
||||
void ChHostSkin()
|
||||
{
|
||||
ChSysInit();
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,238 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
|
||||
static VectorMap<String, ClipData> fbClipboard;
|
||||
|
||||
void ClearClipboard()
|
||||
{
|
||||
GuiLock __;
|
||||
fbClipboard.Clear();
|
||||
}
|
||||
|
||||
void AppendClipboard(const char *format, const Value& data, String (*render)(const Value&))
|
||||
{
|
||||
GuiLock __;
|
||||
ClipData& cd = fbClipboard.GetAdd(format);
|
||||
cd.data = data;
|
||||
cd.render = render;
|
||||
}
|
||||
|
||||
static String sRawRender(const Value& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
void AppendClipboard(const char *format, const String& data)
|
||||
{
|
||||
GuiLock __;
|
||||
AppendClipboard(format, data, sRawRender);
|
||||
}
|
||||
|
||||
void AppendClipboard(const char *format, const byte *data, int length)
|
||||
{
|
||||
GuiLock __;
|
||||
AppendClipboard(format, String(data, length));
|
||||
}
|
||||
|
||||
String ReadClipboard(const char *format)
|
||||
{
|
||||
GuiLock __;
|
||||
int q = fbClipboard.Find(format);
|
||||
return q >= 0 ? (*fbClipboard[q].render)(fbClipboard[q].data) : String();
|
||||
}
|
||||
|
||||
void AppendClipboardText(const String& s)
|
||||
{
|
||||
AppendClipboard("text", ToSystemCharset(s));
|
||||
}
|
||||
|
||||
void AppendClipboardUnicodeText(const WString& s)
|
||||
{
|
||||
AppendClipboard("wtext", (byte *)~s, 2 * s.GetLength());
|
||||
}
|
||||
|
||||
const char *ClipFmtsText()
|
||||
{
|
||||
return "wtext;text";
|
||||
}
|
||||
|
||||
String GetString(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
if(clip.Accept("wtext")) {
|
||||
String s = ~clip;
|
||||
return WString((const wchar *)~s, wstrlen((const wchar *)~s)).ToString();
|
||||
}
|
||||
if(clip.IsAvailable("text"))
|
||||
return ~clip;
|
||||
return Null;
|
||||
}
|
||||
|
||||
WString GetWString(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
if(clip.Accept("wtext")) {
|
||||
String s = ~clip;
|
||||
return WString((const wchar *)~s, wstrlen((const wchar *)~s));
|
||||
}
|
||||
if(clip.IsAvailable("text"))
|
||||
return (~clip).ToWString();
|
||||
return Null;
|
||||
}
|
||||
|
||||
|
||||
bool AcceptText(PasteClip& clip)
|
||||
{
|
||||
return clip.Accept(ClipFmtsText());
|
||||
}
|
||||
|
||||
static String sText(const Value& data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
static String sWText(const Value& data)
|
||||
{
|
||||
return Unicode__(WString(data));
|
||||
}
|
||||
|
||||
void Append(VectorMap<String, ClipData>& data, const String& text)
|
||||
{
|
||||
data.GetAdd("text", ClipData(text, sText));
|
||||
data.GetAdd("wtext", ClipData(text, sWText));
|
||||
}
|
||||
|
||||
void Append(VectorMap<String, ClipData>& data, const WString& text)
|
||||
{
|
||||
data.GetAdd("text", ClipData(text, sText));
|
||||
data.GetAdd("wtext", ClipData(text, sWText));
|
||||
}
|
||||
|
||||
String GetTextClip(const WString& text, const String& fmt)
|
||||
{
|
||||
if(fmt == "text")
|
||||
return text.ToString();
|
||||
if(fmt == "wtext")
|
||||
return Unicode__(text);
|
||||
return Null;
|
||||
}
|
||||
|
||||
String GetTextClip(const String& text, const String& fmt)
|
||||
{
|
||||
if(fmt == "text")
|
||||
return text;
|
||||
if(fmt == "wtext")
|
||||
return Unicode__(text.ToWString());
|
||||
return Null;
|
||||
}
|
||||
|
||||
String ReadClipboardText()
|
||||
{
|
||||
String w = ReadClipboard("text");
|
||||
return w.GetCount() ? w : ReadClipboardUnicodeText().ToString();
|
||||
}
|
||||
|
||||
WString ReadClipboardUnicodeText()
|
||||
{
|
||||
String w = ReadClipboard("wtext");
|
||||
if(w.GetCount())
|
||||
return WString((const wchar *)~w, w.GetLength() / 2);
|
||||
return ReadClipboard("text").ToWString();
|
||||
}
|
||||
|
||||
bool IsClipboardAvailable(const char *id)
|
||||
{
|
||||
return fbClipboard.Find(id) >= 0;
|
||||
}
|
||||
|
||||
bool IsClipboardAvailableText()
|
||||
{
|
||||
return IsClipboardAvailable("text") || IsClipboardAvailable("wtext");
|
||||
}
|
||||
|
||||
const char *ClipFmtsImage()
|
||||
{
|
||||
static const char *q;
|
||||
ONCELOCK {
|
||||
static String s = "dib;" + ClipFmt<Image>();
|
||||
q = s;
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
bool AcceptImage(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
return clip.Accept(ClipFmtsImage());
|
||||
}
|
||||
|
||||
Image GetImage(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
Image m;
|
||||
if(Accept<Image>(clip)) {
|
||||
LoadFromString(m, ~clip);
|
||||
if(!m.IsEmpty())
|
||||
return m;
|
||||
}
|
||||
return Null;
|
||||
}
|
||||
|
||||
Image ReadClipboardImage()
|
||||
{
|
||||
GuiLock __;
|
||||
PasteClip d = Ctrl::Clipboard();
|
||||
return GetImage(d);
|
||||
}
|
||||
|
||||
String sImage(const Value& image)
|
||||
{
|
||||
Image img = image;
|
||||
return StoreAsString(const_cast<Image&>(img));
|
||||
}
|
||||
|
||||
String GetImageClip(const Image& img, const String& fmt)
|
||||
{
|
||||
GuiLock __;
|
||||
if(img.IsEmpty()) return Null;
|
||||
if(fmt == ClipFmt<Image>())
|
||||
return sImage(img);
|
||||
return Null;
|
||||
}
|
||||
|
||||
void AppendClipboardImage(const Image& img)
|
||||
{
|
||||
GuiLock __;
|
||||
if(img.IsEmpty()) return;
|
||||
AppendClipboard(ClipFmt<Image>(), img, sImage);
|
||||
}
|
||||
|
||||
bool AcceptFiles(PasteClip& clip)
|
||||
{
|
||||
if(clip.Accept("files")) {
|
||||
clip.SetAction(DND_COPY);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsAvailableFiles(PasteClip& clip)
|
||||
{
|
||||
return clip.IsAvailable("files");
|
||||
}
|
||||
|
||||
Vector<String> GetFiles(PasteClip& clip)
|
||||
{
|
||||
GuiLock __;
|
||||
Vector<String> f;
|
||||
return f;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
#define LLOG(x) // DLOG(x)
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void Ctrl::GuiPlatformConstruct()
|
||||
{
|
||||
}
|
||||
|
||||
void Ctrl::GuiPlatformRemove()
|
||||
{
|
||||
}
|
||||
|
||||
void Ctrl::GuiPlatformGetTopRect(Rect& r) const
|
||||
{
|
||||
}
|
||||
|
||||
bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect& r)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ctrl::GuiPlatformSetFullRefreshSpecial()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ctrl::PaintCaret(SystemDraw& w)
|
||||
{
|
||||
}
|
||||
|
||||
String GuiPlatformGetKeyDesc(dword key)
|
||||
{
|
||||
return Null;
|
||||
}
|
||||
|
||||
void Ctrl::GuiPlatformSelection(PasteClip&)
|
||||
{
|
||||
}
|
||||
|
||||
void GuiPlatformAdjustDragImage(ImageBuffer&)
|
||||
{
|
||||
}
|
||||
|
||||
bool GuiPlatformHasSizeGrip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiPlatformGripResize(TopWindow *q)
|
||||
{
|
||||
q->GripResize();
|
||||
}
|
||||
|
||||
Color GuiPlatformGetScreenPixel(int x, int y)
|
||||
{
|
||||
return Null;
|
||||
}
|
||||
|
||||
void GuiPlatformAfterMenuPopUp()
|
||||
{
|
||||
}
|
||||
|
||||
String Ctrl::Name() const {
|
||||
GuiLock __;
|
||||
#ifdef CPU_64
|
||||
String s = String(typeid(*this).name()) + " : 0x" + FormatIntHex(this);
|
||||
#else
|
||||
String s = String(typeid(*this).name()) + " : " + Format("0x%x", (int) this);
|
||||
#endif
|
||||
if(IsChild())
|
||||
s << "(parent " << String(typeid(*parent).name()) << ")";
|
||||
return s;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
//$ class Ctrl {
|
||||
private:
|
||||
static Ptr<Ctrl> desktop;
|
||||
static Vector<Ctrl *> topctrl;
|
||||
|
||||
static Point fbCursorPos;
|
||||
static Image fbCursorImage;
|
||||
|
||||
static Rect fbCaretRect;
|
||||
static int fbCaretTm;
|
||||
|
||||
static bool fbEndSession;
|
||||
static int64 fbEventLoop;
|
||||
static int64 fbEndSessionLoop;
|
||||
|
||||
static Ctrl& Desktop();
|
||||
|
||||
static void TimerAndPaint();
|
||||
static bool ProcessEvent(const String& event);
|
||||
|
||||
static bool quit;
|
||||
static int main_pid;
|
||||
static Vector<int> pid;
|
||||
static TcpSocket socket;
|
||||
static WebSocket websocket;
|
||||
static int64 update_serial;
|
||||
static int64 recieved_update_serial;
|
||||
|
||||
static Vector<Rect> invalid;
|
||||
|
||||
static BiVector<String> event_queue;
|
||||
static Size DesktopSize;
|
||||
|
||||
static void AddInvalid(const Rect& r);
|
||||
void AddInvalid() { AddInvalid(GetScreenRect()); }
|
||||
|
||||
static void InvalidateDesktop();
|
||||
|
||||
int FindTopCtrl() const;
|
||||
static Rect GetClipBound(const Vector<Rect>& inv, const Rect& r);
|
||||
static void DoPaint();
|
||||
static void SyncTopWindows();
|
||||
|
||||
// static void AddInvalid(const Rect& rect);
|
||||
|
||||
void DestroyWnd();
|
||||
|
||||
void NewTop() { top = new Top; top->owner_window = NULL; }
|
||||
void PutForeground();
|
||||
static void MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta);
|
||||
|
||||
static void DrawLine(const Vector<Rect>& clip, int x, int y, int cx, int cy, bool horz,
|
||||
const byte *pattern, int animation);
|
||||
static void DragRectDraw0(const Vector<Rect>& clip, const Rect& rect, int n,
|
||||
const byte *pattern, int animation);
|
||||
|
||||
static void ReadKeyMods(CParser& p);
|
||||
static void DoMouseButton(int event, CParser& p);
|
||||
|
||||
static void DoMouseFB(int event, Point p, int zdelta, CParser& cp);
|
||||
|
||||
static void Output();
|
||||
|
||||
friend struct PaintProxy__;
|
||||
friend class TopWindowFrame;
|
||||
friend class SystemDraw;
|
||||
friend struct DnDLoop;
|
||||
|
||||
void SetOpen(bool b) { isopen = b; }
|
||||
|
||||
static void Signal(int signal);
|
||||
static void Broadcast(int signal);
|
||||
|
||||
static TurtleStream turtle_stream;
|
||||
static Stream& OutputStream() { turtle_stream.SetDataFlag(); return turtle_stream; }
|
||||
static void Put8(int x) { turtle_stream.SetDataFlag(); turtle_stream.Put(x); }
|
||||
static void Put16(int x);
|
||||
static void Put32(int x);
|
||||
static void Put(Point p);
|
||||
static void Put(Size sz);
|
||||
static void Put(const Rect& r);
|
||||
static void Put(const String& s);
|
||||
|
||||
friend void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& clip,
|
||||
int n, Color color, int type, int animation);
|
||||
friend void DrawDragLine(SystemDraw& w, bool horz, int x, int y, int len, int n, int animation);
|
||||
|
||||
static int serial_time0;
|
||||
static int64 serial_0;
|
||||
|
||||
friend struct ImageSysData;
|
||||
|
||||
public:
|
||||
static bool DoKeyFB(dword key, int cnt);
|
||||
|
||||
static void SyncClient();
|
||||
|
||||
static String host;
|
||||
static int port;
|
||||
static bool debugmode;
|
||||
static String ip;
|
||||
static int connection_limit;
|
||||
|
||||
static Time stat_started;
|
||||
static int64 stat_data_send;
|
||||
static int stat_putrect;
|
||||
static int stat_putimage;
|
||||
static int stat_setimage;
|
||||
static int64 stat_setimage_len;
|
||||
static int stat_roundtrip_ms;
|
||||
static int stat_client_ms;
|
||||
|
||||
static bool StartSession();
|
||||
static void EndSession();
|
||||
|
||||
static Callback2<int, String> WhenConnect;
|
||||
static Callback1<int> WhenTerminate;
|
||||
|
||||
static Callback WhenDisconnect;
|
||||
|
||||
|
||||
static void SetDesktop(Ctrl& q);
|
||||
static Ctrl *GetDesktop() { return desktop; }
|
||||
static void SetDesktopSize(Size sz);
|
||||
static Size GetDesktopSize() { return DesktopSize; }
|
||||
|
||||
void DragRectDraw(const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, int type, int animation);
|
||||
|
||||
static Ctrl *FindMouseTopCtrl();
|
||||
|
||||
static void PaintScene(SystemDraw& draw);
|
||||
|
||||
enum { DRAWDRAGRECT_SCREEN = 0x8000 };
|
||||
//$ };
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // DLOG(x)
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
Ptr<Ctrl> sDnDSource;
|
||||
|
||||
Ctrl * Ctrl::GetDragAndDropSource()
|
||||
{
|
||||
return sDnDSource;
|
||||
}
|
||||
|
||||
struct DnDLoop : LocalLoop {
|
||||
const VectorMap<String, ClipData> *data;
|
||||
Vector<String> fmts;
|
||||
|
||||
Image move, copy, reject;
|
||||
Ptr<Ctrl> target;
|
||||
int action;
|
||||
byte actions;
|
||||
|
||||
void Sync();
|
||||
String GetData(const String& f);
|
||||
void DnD(bool paste);
|
||||
|
||||
virtual void LeftUp(Point, dword);
|
||||
virtual bool Key(dword, int);
|
||||
virtual void MouseMove(Point p, dword);
|
||||
virtual Image CursorImage(Point, dword);
|
||||
};
|
||||
|
||||
Ptr<DnDLoop> dndloop;
|
||||
|
||||
bool PasteClip::IsAvailable(const char *fmt) const
|
||||
{
|
||||
GuiLock __;
|
||||
return dnd ? dndloop && FindIndex(dndloop->fmts, fmt) >= 0
|
||||
: IsClipboardAvailable(fmt);
|
||||
}
|
||||
|
||||
String DnDLoop::GetData(const String& f)
|
||||
{
|
||||
GuiLock __;
|
||||
int i = data->Find(f);
|
||||
String d;
|
||||
if(i >= 0)
|
||||
d = (*data)[i].Render();
|
||||
else
|
||||
if(sDnDSource)
|
||||
d = sDnDSource->GetDropData(f);
|
||||
return d;
|
||||
}
|
||||
|
||||
String PasteClip::Get(const char *fmt) const
|
||||
{
|
||||
return dnd ? dndloop ? dndloop->GetData(fmt) : String() : ReadClipboard(fmt);
|
||||
}
|
||||
|
||||
void PasteClip::GuiPlatformConstruct()
|
||||
{
|
||||
dnd = false;
|
||||
}
|
||||
|
||||
void DnDLoop::DnD(bool paste)
|
||||
{
|
||||
PasteClip d;
|
||||
d.paste = paste;
|
||||
d.accepted = false;
|
||||
d.allowed = (byte)actions;
|
||||
d.action = GetCtrl() ? DND_COPY : DND_MOVE;
|
||||
d.dnd = true;
|
||||
if(target)
|
||||
target->DnD(GetMousePos(), d);
|
||||
action = d.IsAccepted() ? d.GetAction() : DND_NONE;
|
||||
}
|
||||
|
||||
void DnDLoop::Sync()
|
||||
{
|
||||
GuiLock __;
|
||||
Ptr<Ctrl> t = FindMouseTopCtrl();
|
||||
if(t != target)
|
||||
if(target)
|
||||
target->DnDLeave();
|
||||
target = t;
|
||||
DnD(false);
|
||||
}
|
||||
|
||||
void DnDLoop::LeftUp(Point, dword)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("DnDLoop::LeftUp");
|
||||
DnD(true);
|
||||
EndLoop();
|
||||
}
|
||||
|
||||
void DnDLoop::MouseMove(Point p, dword)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("DnDLoop::MouseMove");
|
||||
Sync();
|
||||
}
|
||||
|
||||
bool DnDLoop::Key(dword, int)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("DnDLoop::Key");
|
||||
Sync();
|
||||
return false;
|
||||
}
|
||||
|
||||
Image DnDLoop::CursorImage(Point, dword)
|
||||
{
|
||||
GuiLock __;
|
||||
return action == DND_MOVE ? move : action == DND_COPY ? copy : reject;
|
||||
}
|
||||
|
||||
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
|
||||
const VectorMap<String, ClipData>& data)
|
||||
{
|
||||
GuiLock __;
|
||||
DnDLoop d;
|
||||
d.actions = (byte)actions;
|
||||
d.reject = actions & DND_EXACTIMAGE ? CtrlCoreImg::DndNone() : MakeDragImage(CtrlCoreImg::DndNone(), sample);
|
||||
if(actions & DND_COPY)
|
||||
d.copy = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndCopy(), sample);
|
||||
if(actions & DND_MOVE)
|
||||
d.move = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndMoveX11(), sample);
|
||||
d.SetMaster(*this);
|
||||
d.data = &data;
|
||||
d.action = DND_NONE;
|
||||
d.fmts = Split(fmts, ';');
|
||||
dndloop = &d;
|
||||
sDnDSource = this;
|
||||
d.Run();
|
||||
sDnDSource = NULL;
|
||||
SyncCaret();
|
||||
LLOG("DoDragAndDrop finished");
|
||||
return d.action;
|
||||
}
|
||||
|
||||
void Ctrl::SetSelectionSource(const char *fmts) {}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#include <CtrlCore/CtrlCore.h>
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void SystemDraw::PutRect(const Rect& r, Color color)
|
||||
{
|
||||
LLOG("Ctrl::PutRect " << r << ", color " << color);
|
||||
Ctrl::stat_putrect++;
|
||||
Point p = r.TopLeft();
|
||||
if(color == InvertColor()) {
|
||||
Ctrl::Put8(INVERTRECT);
|
||||
Ctrl::Put(r);
|
||||
}
|
||||
else {
|
||||
Size sz = r.GetSize();
|
||||
Point dp = p - pos;
|
||||
if(abs(dp.x) < 256 && abs(dp.y) < 256 && sz.cx < 256 && sz.cy < 256 && 0) {
|
||||
Ctrl::Put8(dp.x < 0 ? dp.y < 0 ? RECTNN : RECTNP : dp.y < 0 ? RECTPN : RECTPP);
|
||||
Ctrl::Put8(abs(dp.x));
|
||||
Ctrl::Put8(abs(dp.y));
|
||||
Ctrl::Put8(sz.cx);
|
||||
Ctrl::Put8(sz.cy);
|
||||
}
|
||||
else {
|
||||
Ctrl::Put8(RECT);
|
||||
Ctrl::Put(r);
|
||||
}
|
||||
Ctrl::Put8(color.GetR());
|
||||
Ctrl::Put8(color.GetG());
|
||||
Ctrl::Put8(color.GetB());
|
||||
}
|
||||
pos = p;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
struct DrawDragRectInfo {
|
||||
Rect rect1, rect2, clip;
|
||||
int n;
|
||||
int type;
|
||||
int animation;
|
||||
};
|
||||
|
||||
void DrawDragLine(SystemDraw& w, bool horz, int x, int y, int len, int n, int anim)
|
||||
{
|
||||
if(len <= 0)
|
||||
return;
|
||||
for(int i = 0; i < n; i++) {
|
||||
Ctrl::Put8(horz ? HORZDRAGLINE : VERTDRAGLINE);
|
||||
Ctrl::Put16(x + !horz * i);
|
||||
Ctrl::Put16(y + horz * i);
|
||||
Ctrl::Put16(len);
|
||||
Ctrl::Put16(anim);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawDragFrame(SystemDraw& w, const Rect& r, int n, int animation)
|
||||
{
|
||||
DrawDragLine(w, true, r.left, r.top, r.GetWidth(), n, animation);
|
||||
DrawDragLine(w, false, r.left, r.top + n, r.GetHeight() - 2 * n, n, animation);
|
||||
DrawDragLine(w, false, r.right - n, r.top + n, r.GetHeight() - 2 * n, n, animation);
|
||||
DrawDragLine(w, true, r.left, r.bottom - n, r.GetWidth(), n, animation);
|
||||
}
|
||||
|
||||
void DrawDragRect(Ctrl& q, const DrawDragRectInfo& f)
|
||||
{
|
||||
SystemDraw w;
|
||||
w.Init(Ctrl::GetDesktopSize());
|
||||
w.Clip(f.clip);
|
||||
/* TODO
|
||||
static int dashes[3][3] = {
|
||||
{ 32, 32, 0 },
|
||||
{ 1, 1, 1 },
|
||||
{ 5, 1, 2 },
|
||||
};
|
||||
*/
|
||||
DrawDragFrame(w, f.rect1, f.n, f.animation);
|
||||
DrawDragFrame(w, f.rect2, f.n, f.animation);
|
||||
w.End();
|
||||
}
|
||||
|
||||
void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, int type, int animation)
|
||||
{
|
||||
Ctrl *top = q.GetTopCtrl();
|
||||
if(top) {
|
||||
Point off = q.GetScreenView().TopLeft();
|
||||
DrawDragRectInfo f;
|
||||
f.rect1 = rect1.Offseted(off);
|
||||
f.rect2 = rect2.Offseted(off);
|
||||
f.clip = (clip & q.GetSize()).Offseted(off);
|
||||
f.n = n;
|
||||
f.type = type;
|
||||
f.animation = animation;
|
||||
DrawDragRect(*top, f);
|
||||
Ctrl::SyncClient();
|
||||
Ctrl::Output();
|
||||
}
|
||||
}
|
||||
|
||||
void FinishDragRect(Ctrl& q)
|
||||
{
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,429 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LLOG(x)
|
||||
#define LDUMP(x) // RDUMP(x)
|
||||
#define LTIMING(x)
|
||||
|
||||
int Ctrl::serial_time0 = Null;
|
||||
int64 Ctrl::serial_0;
|
||||
|
||||
Time Ctrl::stat_started;
|
||||
int64 Ctrl::stat_data_send;
|
||||
int Ctrl::stat_putrect;
|
||||
int Ctrl::stat_putimage;
|
||||
int Ctrl::stat_setimage;
|
||||
int64 Ctrl::stat_setimage_len;
|
||||
int Ctrl::stat_roundtrip_ms;
|
||||
int Ctrl::stat_client_ms;
|
||||
|
||||
static Point MousePos;
|
||||
|
||||
Size Ctrl::DesktopSize = Size(1000, 1000);
|
||||
|
||||
StaticRect& DesktopRect()
|
||||
{
|
||||
static StaticRect x;
|
||||
return x;
|
||||
}
|
||||
|
||||
Ctrl& Ctrl::Desktop()
|
||||
{
|
||||
return DesktopRect();
|
||||
}
|
||||
|
||||
BiVector<String> Ctrl::event_queue;
|
||||
|
||||
void Ctrl::EndSession()
|
||||
{
|
||||
GuiLock __;
|
||||
Ctrl::CloseTopCtrls();
|
||||
}
|
||||
|
||||
bool Ctrl::IsWaitingEvent()
|
||||
{
|
||||
GuiLock __;
|
||||
if(quit) {
|
||||
WhenDisconnect();
|
||||
EndSession();
|
||||
Exit(0);
|
||||
}
|
||||
while(socket.Timeout(0).WaitRead()) {
|
||||
socket.Timeout(20000);
|
||||
String s = websocket.Recieve();
|
||||
if(s.IsVoid()) { // No data returned -> means EOF was reached
|
||||
WhenDisconnect();
|
||||
EndSession();
|
||||
Exit(0);
|
||||
}
|
||||
LLOG("Recieved data " << s);
|
||||
StringStream ss(s);
|
||||
while(!ss.IsEof()) {
|
||||
String s = ss.GetLine();
|
||||
CParser p(s);
|
||||
try {
|
||||
if(p.Id("S")) {
|
||||
uint32 l = p.ReadNumber();
|
||||
uint32 h = p.ReadNumber();
|
||||
recieved_update_serial = MAKEQWORD(l, h);
|
||||
stat_client_ms = p.ReadNumber();
|
||||
}
|
||||
else
|
||||
event_queue.AddTail(s);
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
}
|
||||
if(recieved_update_serial == serial_0) {
|
||||
serial_0 = 0;
|
||||
stat_roundtrip_ms = msecs() - serial_time0;
|
||||
serial_time0 = Null;
|
||||
}
|
||||
}
|
||||
socket.Timeout(20000);
|
||||
if(socket.IsError())
|
||||
LLOG("ERROR: " << socket.GetErrorDesc());
|
||||
return event_queue.GetCount();
|
||||
}
|
||||
|
||||
void Ctrl::GuiSleep(int ms)
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsMainThread());
|
||||
// LLOG("GuiSleep");
|
||||
int level = LeaveGuiMutexAll();
|
||||
socket.Timeout(ms).WaitRead();
|
||||
socket.Timeout(20000);
|
||||
EnterGuiMutex(level);
|
||||
}
|
||||
|
||||
dword lastbdowntime[8] = {0};
|
||||
dword isdblclick[8] = {0};
|
||||
|
||||
void Ctrl::MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta)
|
||||
{
|
||||
if(!t->IsEnabled())
|
||||
return;
|
||||
Rect rr = t->GetRect();
|
||||
if((event & Ctrl::ACTION) == DOWN) {
|
||||
Ptr<Ctrl> q = t;
|
||||
TopWindowFrame *wf = dynamic_cast<TopWindowFrame *>(~t);
|
||||
if(wf)
|
||||
q = wf->window;
|
||||
if(q) q->ClickActivateWnd();
|
||||
if(q) q->SetForeground();
|
||||
if(ignoreclick)
|
||||
return;
|
||||
}
|
||||
if(t)
|
||||
t->DispatchMouse(event, p - rr.TopLeft(), zdelta);
|
||||
if(t)
|
||||
t->PostInput();
|
||||
}
|
||||
|
||||
Ctrl *Ctrl::FindMouseTopCtrl()
|
||||
{
|
||||
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
||||
Ctrl *t = topctrl[i];
|
||||
if(t->GetRect().Contains(MousePos))
|
||||
return t->IsEnabled() ? t : NULL;
|
||||
}
|
||||
return desktop->IsEnabled() ? desktop : NULL;
|
||||
}
|
||||
|
||||
void Ctrl::SetCaret(int x, int y, int cx, int cy)
|
||||
{
|
||||
GuiLock __;
|
||||
caretx = x;
|
||||
carety = y;
|
||||
caretcx = cx;
|
||||
caretcy = cy;
|
||||
fbCaretTm = GetTickCount();
|
||||
SyncCaret();
|
||||
}
|
||||
|
||||
bool keyShift;
|
||||
bool keyCtrl;
|
||||
bool keyAlt;
|
||||
|
||||
bool GetShift() { return keyShift; }
|
||||
bool GetCtrl() { return keyCtrl; }
|
||||
bool GetAlt() { return keyAlt; }
|
||||
bool GetCapsLock() { return false; } // Impossible to implement
|
||||
|
||||
dword fbKEYtoK(dword chr) {
|
||||
if(findarg(chr, 9, 0xd) < 0)
|
||||
chr = chr + K_DELTA;
|
||||
if(chr == K_ALT_KEY || chr == K_CTRL_KEY || chr == K_SHIFT_KEY)
|
||||
return chr;
|
||||
if(GetCtrl()) chr |= K_CTRL;
|
||||
if(GetAlt()) chr |= K_ALT;
|
||||
if(GetShift()) chr |= K_SHIFT;
|
||||
return chr;
|
||||
/*
|
||||
if(chr == SDLK_TAB)
|
||||
chr = K_TAB;
|
||||
else
|
||||
if(chr == SDLK_SPACE)
|
||||
chr = K_SPACE;
|
||||
else
|
||||
if(chr == SDLK_RETURN)
|
||||
chr = K_RETURN;
|
||||
else
|
||||
chr = chr + K_DELTA;
|
||||
*/
|
||||
}
|
||||
|
||||
void Ctrl::ReadKeyMods(CParser& p)
|
||||
{
|
||||
const char *s = p.GetPtr();
|
||||
if(*s)
|
||||
keyShift = *s++ == '1';
|
||||
if(*s)
|
||||
keyCtrl = *s++ == '1';
|
||||
if(*s)
|
||||
keyAlt = *s++ == '1';
|
||||
}
|
||||
|
||||
bool Ctrl::DoKeyFB(dword key, int cnt)
|
||||
{
|
||||
LLOG("DoKeyFB [" << GetKeyDesc(key) << "] " << key << ", " << cnt);
|
||||
|
||||
bool b = DispatchKey(key, cnt);
|
||||
SyncCaret();
|
||||
Ctrl *desktop = GetDesktop();
|
||||
if(desktop)
|
||||
desktop->PostInput();
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
bool mouseLeft, mouseMiddle, mouseRight;
|
||||
Point mouseDownPos;
|
||||
int64 mouseDownTime;
|
||||
|
||||
bool GetMouseLeft() { return mouseLeft; }
|
||||
bool GetMouseRight() { return mouseRight; }
|
||||
bool GetMouseMiddle() { return mouseMiddle; }
|
||||
|
||||
void Ctrl::DoMouseFB(int event, Point p, int zdelta, CParser& cp)
|
||||
{
|
||||
ReadKeyMods(cp);
|
||||
MousePos = p;
|
||||
int a = event & ACTION;
|
||||
if(a == UP && Ctrl::ignoreclick) {
|
||||
EndIgnore();
|
||||
return;
|
||||
}
|
||||
else
|
||||
if(a == DOWN && ignoreclick)
|
||||
return;
|
||||
LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
|
||||
if(captureCtrl)
|
||||
MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
|
||||
else
|
||||
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
||||
Ptr<Ctrl> t = topctrl[i];
|
||||
Rect rr = t->GetRect();
|
||||
if(rr.Contains(p)) {
|
||||
MouseEventFB(t, event, p, zdelta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ctrl *desktop = GetDesktop();
|
||||
if(desktop) {
|
||||
desktop->DispatchMouse(event, p, zdelta);
|
||||
desktop->PostInput();
|
||||
}
|
||||
}
|
||||
|
||||
static int sDistMax(Point a, Point b)
|
||||
{
|
||||
return IsNull(a) ? INT_MAX : max(abs(a.x - b.x), abs(a.y - b.y));
|
||||
}
|
||||
|
||||
Point ReadPoint(CParser& p)
|
||||
{
|
||||
Point pt;
|
||||
pt.x = p.ReadInt();
|
||||
pt.y = p.ReadInt();
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Ctrl::DoMouseButton(int event, CParser& p)
|
||||
{
|
||||
int button = p.ReadInt();
|
||||
Point pt = ReadPoint(p);
|
||||
int64 tm = p.ReadInt64();
|
||||
(button == 0 ? mouseLeft : button == 2 ? mouseRight : mouseMiddle) = event == DOWN;
|
||||
if(event == DOWN) {
|
||||
if(ignoremouseup) {
|
||||
KillRepeat();
|
||||
ignoreclick = false;
|
||||
ignoremouseup = false;
|
||||
}
|
||||
if(ignoreclick)
|
||||
return;
|
||||
}
|
||||
if(event == UP) {
|
||||
if(ignoreclick)
|
||||
EndIgnore();
|
||||
}
|
||||
if(event == DOWN)
|
||||
if(sDistMax(mouseDownPos, pt) < GUI_DragDistance() && tm - mouseDownTime < 800) {
|
||||
event = DOUBLE;
|
||||
mouseDownTime = 0;
|
||||
}
|
||||
else {
|
||||
mouseDownPos = pt;
|
||||
mouseDownTime = tm;
|
||||
}
|
||||
DoMouseFB(decode(button, 0, LEFT, 2, RIGHT, MIDDLE)|event, pt, 0, p);
|
||||
}
|
||||
|
||||
bool Ctrl::ProcessEvent(const String& event)
|
||||
{
|
||||
LLOG("Processing event " << event);
|
||||
CParser p(event);
|
||||
try {
|
||||
if(p.Id("I"))
|
||||
SystemDraw::ResetI();
|
||||
else
|
||||
if(p.Id("R")) {
|
||||
DesktopSize = ReadPoint(p);
|
||||
Desktop().SetRect(0, 0, DesktopSize.cx, DesktopSize.cy);
|
||||
}
|
||||
if(p.Id("M")) {
|
||||
Point pt = ReadPoint(p);
|
||||
int64 tm = p.ReadInt64();
|
||||
DoMouseFB(MOUSEMOVE, pt, 0, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("W")) {
|
||||
double w = p.ReadDouble();
|
||||
Point pt = ReadPoint(p);
|
||||
int64 tm = p.ReadInt64();
|
||||
DoMouseFB(MOUSEWHEEL, pt, w < 0 ? 120 : -120, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("O")) {
|
||||
mouseLeft = mouseMiddle = mouseRight = false;
|
||||
mouseDownTime = 0;
|
||||
}
|
||||
else
|
||||
if(p.Id("D")) {
|
||||
DoMouseButton(DOWN, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("U")) {
|
||||
DoMouseButton(UP, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("K")) {
|
||||
int code = p.ReadInt();
|
||||
int which = p.ReadInt();
|
||||
int count = 1;
|
||||
for(;;) {
|
||||
if(event_queue.GetCount() && event_queue[0] == event) { // Chrome autorepeat
|
||||
event_queue.DropHead();
|
||||
count++;
|
||||
}
|
||||
else
|
||||
if(event_queue.GetCount() >= 2 && *event_queue[0] == 'C' && event_queue[1] == event) { // Firefox autorepeat
|
||||
String h = event_queue[0];
|
||||
event_queue.DropHead();
|
||||
event_queue.DropHead();
|
||||
event_queue.AddHead(h);
|
||||
count++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
ReadKeyMods(p);
|
||||
DoKeyFB(fbKEYtoK(which), count);
|
||||
}
|
||||
else
|
||||
if(p.Id("k")) {
|
||||
int code = p.ReadInt();
|
||||
int which = p.ReadInt();
|
||||
ReadKeyMods(p);
|
||||
DoKeyFB(K_KEYUP|fbKEYtoK(which), 1);
|
||||
}
|
||||
else
|
||||
if(p.Id("C")) {
|
||||
int code = p.ReadInt();
|
||||
int which = p.ReadInt();
|
||||
ReadKeyMods(p);
|
||||
int count = 1;
|
||||
while(event_queue.GetCount() && event_queue[0] == event) { // 'K's are not there anymore
|
||||
event_queue.DropHead();
|
||||
count++;
|
||||
}
|
||||
if(which && !keyAlt && !keyCtrl && findarg(which, 9, 0xd) < 0)
|
||||
DoKeyFB(which, 1);
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::ProcessEvents(bool *quit)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("---- Process events");
|
||||
bool r = false;
|
||||
while(IsWaitingEvent()) {
|
||||
while(event_queue.GetCount() >= 2 && *event_queue[0] == 'M' && *event_queue[1] == 'M')
|
||||
event_queue.DropHead(); // MouseMove compression
|
||||
String ev = event_queue[0];
|
||||
event_queue.DropHead();
|
||||
ProcessEvent(ev);
|
||||
r = true;
|
||||
}
|
||||
TimerAndPaint();
|
||||
return r;
|
||||
}
|
||||
|
||||
Point GetMousePos() {
|
||||
return MousePos;
|
||||
}
|
||||
|
||||
void Ctrl::EventLoop(Ctrl *ctrl)
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsMainThread());
|
||||
ASSERT(LoopLevel == 0 || ctrl);
|
||||
LoopLevel++;
|
||||
LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN);
|
||||
Ptr<Ctrl> ploop;
|
||||
if(ctrl) {
|
||||
ploop = LoopCtrl;
|
||||
LoopCtrl = ctrl;
|
||||
ctrl->inloop = true;
|
||||
}
|
||||
|
||||
bool quit = false;
|
||||
int64 loopno = ++EventLoopNo;
|
||||
ProcessEvents(&quit);
|
||||
while(loopno > EndSessionLoopNo && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount()))
|
||||
{
|
||||
// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep");
|
||||
SyncCaret();
|
||||
GuiSleep(20);
|
||||
// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents");
|
||||
ProcessEvents(&quit);
|
||||
// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents");
|
||||
// LDUMP(loopno);
|
||||
}
|
||||
|
||||
if(ctrl)
|
||||
LoopCtrl = ploop;
|
||||
LoopLevel--;
|
||||
LLOG(LOG_END << "Leaving event loop ");
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
PREMULTIPLIED
|
||||
IMAGE_ID(Arrow)
|
||||
IMAGE_ID(IBeam)
|
||||
IMAGE_ID(Wait)
|
||||
IMAGE_ID(No)
|
||||
IMAGE_ID(SizeAll)
|
||||
IMAGE_ID(SizeHorz)
|
||||
IMAGE_ID(SizeRight)
|
||||
IMAGE_ID(SizeLeft)
|
||||
IMAGE_ID(SizeVert)
|
||||
IMAGE_ID(SizeTopLeft)
|
||||
IMAGE_ID(SizeTop)
|
||||
IMAGE_ID(SizeTopRight)
|
||||
IMAGE_ID(SizeBottomLeft)
|
||||
IMAGE_ID(SizeBottom)
|
||||
IMAGE_ID(SizeBottomRight)
|
||||
IMAGE_ID(overlap)
|
||||
IMAGE_ID(maximize)
|
||||
IMAGE_ID(close)
|
||||
IMAGE_ID(bgtitle)
|
||||
IMAGE_ID(title)
|
||||
IMAGE_ID(border)
|
||||
IMAGE_ID(Hand)
|
||||
|
||||
IMAGE_BEGIN_DATA
|
||||
IMAGE_DATA(120,156,237,90,77,72,85,65,20,158,82,203,224,73,24,21,65,45,90,191,85,180,138,10,130,86,174,36,210,187,144,2)
|
||||
IMAGE_DATA(5,163,200,10,12,74,72,8,93,72,132,32,189,69,72,130,153,144,45,122,81,139,112,35,22,232,66,145,160,136,126,224)
|
||||
IMAGE_DATA(17,69,32,66,68,155,218,185,59,205,220,238,220,230,206,155,159,115,238,187,143,76,238,185,28,230,222,153,239,59,115,230)
|
||||
IMAGE_DATA(156,51,115,47,143,199,10,108,15,19,178,141,109,17,13,112,13,24,94,128,200,129,114,153,196,129,245,245,131,48,51,179)
|
||||
IMAGE_DATA(15,203,129,95,191,142,194,207,159,39,96,106,234,16,134,3,63,126,156,130,239,223,59,225,219,183,51,48,62,126,210,199)
|
||||
IMAGE_DATA(129,181,181,94,88,93,189,0,95,191,94,129,47,95,174,65,169,116,218,197,129,207,159,175,195,167,79,55,160,82,25,130)
|
||||
IMAGE_DATA(15,31,110,193,187,119,99,48,58,218,99,227,192,199,143,35,240,254,253,109,120,251,246,14,188,121,115,15,94,189,122,8)
|
||||
IMAGE_DATA(43,43,51,48,50,210,103,226,112,76,9,94,191,190,203,113,147,176,188,252,24,22,22,22,34,125,10,67,67,151,117,14)
|
||||
IMAGE_DATA(183,117,143,227,38,97,105,233,33,44,46,62,11,177,211,211,211,18,167,106,136,95,92,188,207,117,26,94,190,124,4,47)
|
||||
IMAGE_DATA(94,60,129,185,185,231,206,245,206,207,63,128,193,193,75,177,157,129,129,126,39,126,96,224,162,58,46,20,250,251,47,171)
|
||||
IMAGE_DATA(62,36,240,166,24,244,245,157,183,198,211,208,23,206,209,219,219,99,155,195,36,208,221,125,150,82,183,225,28,65,208,73)
|
||||
IMAGE_DATA(154,163,163,227,52,5,31,16,252,49,75,19,219,201,182,178,237,161,50,45,241,66,165,104,247,177,195,218,243,127,223,103)
|
||||
IMAGE_DATA(89,111,85,92,88,129,7,174,137,7,173,41,25,56,172,134,153,219,255,120,220,169,10,150,73,252,129,178,89,21,124,188)
|
||||
IMAGE_DATA(168,189,99,55,141,28,209,39,198,52,124,176,227,200,97,216,117,245,92,130,35,238,69,159,24,99,134,157,164,114,60,216)
|
||||
IMAGE_DATA(4,71,204,47,212,131,141,57,90,236,156,88,130,125,138,255,212,248,80,227,79,201,47,181,126,104,245,217,202,175,230,232)
|
||||
IMAGE_DATA(178,5,206,66,70,31,141,8,181,38,205,131,163,140,187,252,117,217,73,195,175,74,160,242,140,157,223,118,79,241,223,228)
|
||||
IMAGE_DATA(23,133,47,197,103,195,199,247,217,192,240,77,54,108,235,196,196,201,118,239,203,117,213,97,237,240,203,231,131,169,143,194)
|
||||
IMAGE_DATA(175,101,63,80,234,137,186,111,49,182,204,92,196,129,244,199,42,23,241,202,22,45,194,9,35,191,92,46,11,62,68,45)
|
||||
IMAGE_DATA(201,142,202,231,143,169,236,68,254,39,2,19,45,203,117,88,36,124,0,69,34,147,177,184,124,81,185,18,167,218,176,97)
|
||||
IMAGE_DATA(76,235,87,253,213,109,168,235,84,227,163,199,79,23,91,159,106,199,20,63,172,74,191,179,240,35,139,120,100,149,151,172)
|
||||
IMAGE_DATA(234,67,21,83,156,41,117,170,199,135,25,226,151,198,78,26,190,106,7,21,131,86,254,217,223,204,26,66,213,201,190,0)
|
||||
IMAGE_DATA(216,2,109,43,22,155,13,234,230,49,9,251,7,155,7,227,71,22,241,200,36,47,121,162,243,68,231,137,222,76,137,222)
|
||||
IMAGE_DATA(206,83,221,16,165,90,55,232,74,160,43,49,190,128,43,254,38,2,164,61,199,78,203,49,211,130,54,242,152,107,125,174)
|
||||
IMAGE_DATA(184,184,226,233,202,131,154,167,170,252,181,240,107,91,116,85,215,39,174,122,76,206,82,56,152,143,17,149,83,44,22,209)
|
||||
IMAGE_DATA(28,25,12,161,237,237,237,94,158,146,132,64,6,20,195,83,37,75,30,102,23,235,60,236,233,33,121,34,158,44,138,45)
|
||||
IMAGE_DATA(150,195,148,252,97,242,173,23,53,134,99,172,197,252,100,170,223,152,107,125,174,184,212,253,100,114,137,181,82,60,28,106)
|
||||
IMAGE_DATA(69,166,169,124,234,14,163,238,100,234,137,129,57,153,148,100,163,79,64,25,79,234,73,43,99,66,57,209,25,75,255,230)
|
||||
IMAGE_DATA(96,132,55,20,181,166,242,130,205,11,214,201,97,27,173,96,243,87,105,253,198,92,235,115,197,165,238,175,210,52,149,34)
|
||||
IMAGE_DATA(23,161,59,75,225,228,31,249,118,158,235,4,180,241,54,245,71,126,129,95,89,72,80,228,197,234,80,19,222,101,171,6)
|
||||
IMAGE_DATA(252,159,141,83,180,254,142,100,194,219,236,103,138,71,198,199,149,72,235,156,68,188,75,211,75,6,197,228,115,78,119,18)
|
||||
IMAGE_DATA(227,112,142,175,47,158,146,47,188,212,90,76,187,27,27,131,227,45,45,32,90,204,152,120,62,198,85,239,151,88,57,102)
|
||||
IMAGE_DATA(235,23,207,166,62,211,188,225,120,161,16,170,13,155,224,8,108,132,19,247,54,44,21,79,241,135,186,222,180,241,196,230)
|
||||
IMAGE_DATA(139,36,141,252,146,50,49,49,1,181,104,108,172,129,95,71,134,86,160,22,13,203,188,137,95,226,139,177,171,171,11,168)
|
||||
IMAGE_DATA(138,17,241,159,106,21,255,247,63,217,102,29,30,30,206,241,117,194,203,103,159,166,169,133,176,152,28,63,140,200,127,57)
|
||||
IMAGE_DATA(169,173,11,7,165,82,41,209,90,56,241,120,165,82,73,180,22,78,21,78,182,202,60,76,225,91,241,202,60,177,31,109)
|
||||
IMAGE_DATA(109,109,104,188,120,150,138,193,207,206,206,38,56,38,85,240,129,240,69,248,132,196,123,57,98,126,13,31,115,76,120,209)
|
||||
IMAGE_DATA(111,203,153,207,151,223,126,19,195,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
|
||||
IMAGE_END_DATA(1184, 22)
|
||||
|
|
@ -1,358 +0,0 @@
|
|||
#define GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class SystemDraw : public Draw {
|
||||
public:
|
||||
virtual dword GetInfo() const;
|
||||
virtual Size GetPageSize() const;
|
||||
|
||||
virtual void BeginOp();
|
||||
virtual void EndOp();
|
||||
virtual void OffsetOp(Point p);
|
||||
virtual bool ClipOp(const Rect& r);
|
||||
virtual bool ClipoffOp(const Rect& r);
|
||||
virtual bool ExcludeClipOp(const Rect& r);
|
||||
virtual bool IntersectClipOp(const Rect& r);
|
||||
virtual bool IsPaintingOp(const Rect& r) const;
|
||||
virtual Rect GetPaintRect() const;
|
||||
|
||||
virtual void DrawRectOp(int x, int y, int cx, int cy, Color color);
|
||||
virtual void DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color);
|
||||
virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color);
|
||||
|
||||
virtual void DrawPolyPolylineOp(const Point *vertices, int vertex_count,
|
||||
const int *counts, int count_count,
|
||||
int width, Color color, Color doxor);
|
||||
virtual void DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count,
|
||||
const int *subpolygon_counts, int scc,
|
||||
const int *disjunct_polygon_counts, int dpcc,
|
||||
Color color, int width, Color outline,
|
||||
uint64 pattern, Color doxor);
|
||||
virtual void DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color);
|
||||
|
||||
virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor);
|
||||
virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
|
||||
Color ink, int n, const int *dx);
|
||||
|
||||
virtual Size GetNativeDpi() const;
|
||||
virtual void BeginNative();
|
||||
virtual void EndNative();
|
||||
|
||||
virtual int GetCloffLevel() const;
|
||||
|
||||
private:
|
||||
Size pageSize;
|
||||
Size nativeSize;
|
||||
Size nativeDpi;
|
||||
bool palette:1;
|
||||
bool color16:1;
|
||||
bool is_mono:1;
|
||||
int native;
|
||||
|
||||
friend class ImageDraw;
|
||||
friend class FontInfo;
|
||||
friend class Font;
|
||||
|
||||
friend void StaticExitDraw_();
|
||||
|
||||
Point actual_offset_bak;
|
||||
|
||||
struct Cloff : Moveable<Cloff> {
|
||||
Point org;
|
||||
HRGN hrgn;
|
||||
Rect drawingclip;
|
||||
};
|
||||
|
||||
Array<Cloff> cloff;
|
||||
Rect drawingclip;
|
||||
|
||||
COLORREF lastTextColor;
|
||||
Color lastColor;
|
||||
HBRUSH orgBrush;
|
||||
HBRUSH actBrush;
|
||||
HPEN orgPen;
|
||||
HPEN actPen;
|
||||
int lastPen;
|
||||
Color lastPenColor;
|
||||
|
||||
void Unselect0();
|
||||
void Cinit();
|
||||
|
||||
void LoadCaps();
|
||||
void SetPrinterMode();
|
||||
void Reset();
|
||||
void SetOrg();
|
||||
friend HPALETTE GetQlibPalette();
|
||||
void DotsMode();
|
||||
|
||||
static void InitColors();
|
||||
|
||||
friend class BackDraw;
|
||||
friend class ScreenDraw;
|
||||
friend class PrintDraw;
|
||||
|
||||
protected:
|
||||
dword style;
|
||||
HDC handle;
|
||||
Point actual_offset;
|
||||
|
||||
SystemDraw();
|
||||
void Init();
|
||||
void InitClip(const Rect& clip);
|
||||
|
||||
public:
|
||||
static Rect GetVirtualScreenArea();
|
||||
|
||||
static void SetAutoPalette(bool ap);
|
||||
static bool AutoPalette();
|
||||
bool PaletteMode() { return palette; }
|
||||
|
||||
static void Flush() { GdiFlush(); }
|
||||
|
||||
COLORREF GetColor(Color color) const;
|
||||
|
||||
Point GetOffset() const { return actual_offset; }
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
Point LPtoDP(Point p) const;
|
||||
Point DPtoLP(Point p) const;
|
||||
Rect LPtoDP(const Rect& r) const;
|
||||
Rect DPtoLP(const Rect& r) const;
|
||||
#endif
|
||||
|
||||
void SetColor(Color color);
|
||||
void SetDrawPen(int width, Color color);
|
||||
|
||||
Size GetSizeCaps(int i, int j) const;
|
||||
HDC BeginGdi();
|
||||
void EndGdi();
|
||||
HDC GetHandle() { return handle; }
|
||||
operator HDC() const { return handle; }
|
||||
void Unselect();
|
||||
void Attach(HDC ahandle) { handle = ahandle; Init(); }
|
||||
HDC Detach() { Unselect(); HDC h = handle; handle = NULL; return h; }
|
||||
|
||||
SystemDraw(HDC hdc);
|
||||
virtual ~SystemDraw();
|
||||
|
||||
bool CanSetSurface() { return IsGui() && IsWinNT(); }
|
||||
};
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
class WinMetaFile {
|
||||
Size size;
|
||||
HENHMETAFILE hemf;
|
||||
|
||||
void Init();
|
||||
|
||||
public:
|
||||
void Attach(HENHMETAFILE emf);
|
||||
HENHMETAFILE Detach();
|
||||
|
||||
void Set(const void *data, dword len);
|
||||
void Set(const String& data) { Set(~data, data.GetCount()); }
|
||||
|
||||
String Get() const;
|
||||
|
||||
operator bool() const { return hemf; }
|
||||
void SetSize(const Size& sz) { size = sz; }
|
||||
Size GetSize() const { return hemf ? size : Size(0, 0); }
|
||||
|
||||
void Clear();
|
||||
|
||||
void Paint(Draw& w, const Rect& r) const;
|
||||
void Paint(Draw& w, int x, int y, int cx, int cy) const;
|
||||
|
||||
void Serialize(Stream& s);
|
||||
|
||||
void ReadClipboard();
|
||||
void WriteClipboard() const;
|
||||
void Load(const char *file) { Set(LoadFile(file)); }
|
||||
|
||||
WinMetaFile() { Init(); }
|
||||
WinMetaFile(HENHMETAFILE hemf);
|
||||
WinMetaFile(HENHMETAFILE hemf, Size sz);
|
||||
WinMetaFile(const char *file);
|
||||
WinMetaFile(void *data, int len);
|
||||
WinMetaFile(const String& data);
|
||||
|
||||
~WinMetaFile() { Clear(); }
|
||||
|
||||
HENHMETAFILE GetHEMF() const { return hemf; }
|
||||
};
|
||||
|
||||
class WinMetaFileDraw : public SystemDraw {
|
||||
Size size;
|
||||
|
||||
public:
|
||||
bool Create(HDC hdc, int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
bool Create(int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
WinMetaFile Close();
|
||||
|
||||
WinMetaFileDraw() {}
|
||||
WinMetaFileDraw(HDC hdc, int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
WinMetaFileDraw(int cx, int cy, const char *app = NULL, const char *name = NULL, const char *file = NULL);
|
||||
~WinMetaFileDraw();
|
||||
};
|
||||
|
||||
void DrawWMF(Draw& w, int x, int y, int cx, int cy, const String& wmf);
|
||||
void DrawWMF(Draw& w, int x, int y, const String& wmf);
|
||||
Drawing LoadWMF(const char *path, int cx, int cy);
|
||||
Drawing LoadWMF(const char *path);
|
||||
|
||||
String AsWMF(const Drawing& iw);
|
||||
|
||||
#endif
|
||||
|
||||
class ScreenDraw : public SystemDraw {
|
||||
public:
|
||||
ScreenDraw(bool ic = false);
|
||||
~ScreenDraw();
|
||||
};
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
class PrintDraw : public SystemDraw {
|
||||
public:
|
||||
virtual void StartPage();
|
||||
virtual void EndPage();
|
||||
|
||||
private:
|
||||
bool aborted;
|
||||
|
||||
void InitPrinter();
|
||||
public:
|
||||
PrintDraw(HDC hdc, const char *jobname);
|
||||
~PrintDraw();
|
||||
};
|
||||
#endif
|
||||
|
||||
inline bool BitBlt(HDC ddc, Point d, HDC sdc, const Rect& s, dword rop = SRCCOPY)
|
||||
{ return BitBlt(ddc, d.x, d.y, s.Width(), s.Height(), sdc, s.left, s.top, rop); }
|
||||
|
||||
inline bool StretchBlt(HDC ddc, const Rect& r, HDC sdc, const Rect& s, dword rop = SRCCOPY)
|
||||
{ return StretchBlt(ddc, r.left, r.top, r.Width(), r.Height(), sdc, s.left, s.top, s.Width(), s.Height(), rop); }
|
||||
|
||||
inline bool PatBlt(HDC dc, const Rect& r, dword rop = PATCOPY)
|
||||
{ return PatBlt(dc, r.left, r.top, r.Width(), r.Height(), rop); }
|
||||
|
||||
inline void MoveTo(HDC hdc, Point pt) { MoveToEx(hdc, pt.x, pt.y, 0); }
|
||||
inline void LineTo(HDC hdc, Point pt) { LineTo(hdc, pt.x, pt.y); }
|
||||
|
||||
inline void DrawLine(HDC hdc, Point p, Point q) { MoveTo(hdc, p); LineTo(hdc, q); }
|
||||
inline void DrawLine(HDC hdc, int px, int py, int qx, int qy) { MoveToEx(hdc, px, py, 0); LineTo(hdc, qx, qy); }
|
||||
|
||||
#ifndef PLATFORM_WINCE
|
||||
inline void DrawArc(HDC hdc, const Rect& rc, Point p, Point q){ Arc(hdc, rc.left, rc.top, rc.right, rc.bottom, p.x, p.y, q.x, q.y); }
|
||||
#endif
|
||||
inline void DrawCircle(HDC hdc, int x, int y, int radius) { Ellipse(hdc, x - radius, y - radius, x + radius + 1, y + radius + 1); }
|
||||
inline void DrawCircle(HDC hdc, Point centre, int radius) { DrawCircle(hdc, centre.x, centre.y, radius); }
|
||||
inline void DrawEllipse(HDC hdc, const Rect& rc) { Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom); }
|
||||
|
||||
inline void DrawRect(HDC hdc, const Rect& rc) { Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); }
|
||||
|
||||
HDC ScreenHDC();
|
||||
HPALETTE GetQlibPalette();
|
||||
|
||||
Image Win32Icon(LPCSTR id, int iconsize = 0);
|
||||
Image Win32Icon(int id, int iconsize = 0);
|
||||
Image Win32Cursor(LPCSTR id);
|
||||
Image Win32Cursor(int id);
|
||||
HICON IconWin32(const Image& img, bool cursor = false);
|
||||
Image Win32DllIcon(const char *dll, int ii, bool large);
|
||||
|
||||
class BackDraw : public SystemDraw {
|
||||
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();
|
||||
};
|
||||
|
||||
class ImageDraw : public SystemDraw {
|
||||
Size size;
|
||||
|
||||
struct Section {
|
||||
HDC dc;
|
||||
HBITMAP hbmp, hbmpOld;
|
||||
RGBA *pixels;
|
||||
|
||||
void Init(int cx, int cy);
|
||||
~Section();
|
||||
};
|
||||
|
||||
Section rgb;
|
||||
Section a;
|
||||
SystemDraw alpha;
|
||||
|
||||
|
||||
bool has_alpha;
|
||||
|
||||
void Init();
|
||||
Image Get(bool pm) const;
|
||||
|
||||
public:
|
||||
Draw& Alpha();
|
||||
|
||||
operator Image() const;
|
||||
|
||||
Image GetStraight() const;
|
||||
|
||||
ImageDraw(Size sz);
|
||||
ImageDraw(int cx, int cy);
|
||||
~ImageDraw();
|
||||
};
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#define GUIPLATFORM_KEYCODES_INCLUDE "Win32Keys.h"
|
||||
|
||||
|
||||
#define GUIPLATFORM_CTRL_TOP_DECLS \
|
||||
HWND hwnd; \
|
||||
UDropTarget *dndtgt; \
|
||||
|
||||
|
||||
#define GUIPLATFORM_CTRL_DECLS_INCLUDE "Win32Ctrl.h"
|
||||
|
||||
|
||||
#define GUIPLATFORM_PASTECLIP_DECLS \
|
||||
UDropTarget *dt; \
|
||||
|
||||
#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE "Win32Top.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
inline unsigned GetHashValue(const HWND& hwnd)
|
||||
{
|
||||
return (unsigned)(intptr_t)hwnd;
|
||||
}
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
#ifndef PLATFORM_WINCE
|
||||
|
||||
#include <ShellAPI.h>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GUIPLATFORM_INCLUDE_AFTER "Win32GuiA.h"
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
#include <CtrlCore/CtrlCore.h>
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
#define LTIMING(x) // RTIMING(x)
|
||||
|
||||
Vector<int> SystemDraw::ImageSysData::free_handle;
|
||||
int SystemDraw::ImageSysData::handle_count;
|
||||
|
||||
int SystemDraw::ImageSysData::AllocImageHandle()
|
||||
{
|
||||
if(free_handle.GetCount())
|
||||
return free_handle.Pop();
|
||||
return handle_count++;
|
||||
}
|
||||
|
||||
void SystemDraw::ImageSysData::FreeImageHandle(int handle)
|
||||
{
|
||||
free_handle.Add(handle);
|
||||
}
|
||||
|
||||
void SystemDraw::ImageSysData::Init(const Image& m)
|
||||
{
|
||||
img = m;
|
||||
handle = AllocImageHandle();
|
||||
LLOG("SetImage " << handle << ", size: " << img.GetSize() << ", cache size: " << SystemDraw::cache.GetSize());
|
||||
Ctrl::Put8(SETIMAGE);
|
||||
Ctrl::Put16(handle);
|
||||
Ctrl::Put(img.GetSize());
|
||||
const RGBA *end = ~img + img.GetLength();
|
||||
for(const RGBA *s = ~img; s < end; s++) {
|
||||
Ctrl::Put8(s->r);
|
||||
Ctrl::Put8(s->g);
|
||||
Ctrl::Put8(s->b);
|
||||
Ctrl::Put8(s->a);
|
||||
}
|
||||
Ctrl::stat_setimage++;
|
||||
Ctrl::stat_setimage_len += img.GetLength() * sizeof(RGBA);
|
||||
SysImageRealized(img);
|
||||
}
|
||||
|
||||
SystemDraw::ImageSysData::~ImageSysData()
|
||||
{
|
||||
SysImageReleased(img);
|
||||
FreeImageHandle(handle);
|
||||
}
|
||||
|
||||
struct ImageSysDataMaker : LRUCache<SystemDraw::ImageSysData, int64>::Maker {
|
||||
Image img;
|
||||
|
||||
virtual int64 Key() const { return img.GetSerialId(); }
|
||||
virtual int Make(SystemDraw::ImageSysData& object) const { object.Init(img); return img.GetLength(); }
|
||||
};
|
||||
|
||||
LRUCache<SystemDraw::ImageSysData, int64> SystemDraw::cache;
|
||||
|
||||
void SystemDraw::PutImage(Point p, const Image& img, const Rect& src)
|
||||
{
|
||||
LLOG("Ctrl::PutImage " << p << ", size: " << img.GetSize() << ", src: " << src << ", id: " << img.GetSerialId());
|
||||
Ctrl::stat_putimage++;
|
||||
ImageSysDataMaker m;
|
||||
LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount());
|
||||
m.img = img;
|
||||
ImageSysData& sd = cache.Get(m);
|
||||
if(Rect(img.GetSize()) == src) {
|
||||
Point dp = p - pos;
|
||||
if(abs(dp.x) < 256 && abs(dp.y) < 256) {
|
||||
Ctrl::Put8(dp.x < 0 ? dp.y < 0 ? IMAGENN : IMAGENP : dp.y < 0 ? IMAGEPN : IMAGEPP);
|
||||
Ctrl::Put8(abs(dp.x));
|
||||
Ctrl::Put8(abs(dp.y));
|
||||
Ctrl::Put16(sd.handle);
|
||||
pos = p;
|
||||
cache.Shrink(25000000, 5000); // Cache must be after Paint because of PaintOnly!
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ctrl::Put8(IMAGE);
|
||||
Ctrl::Put16(sd.handle);
|
||||
Ctrl::Put(p);
|
||||
Ctrl::Put(src);
|
||||
pos = p;
|
||||
cache.Shrink(25000000, 5000); // Cache must be after Paint because of PaintOnly!
|
||||
}
|
||||
|
||||
void SystemDraw::ResetI()
|
||||
{
|
||||
cache.Clear();
|
||||
ImageSysData::free_handle.Clear();
|
||||
ImageSysData::handle_count = 0;
|
||||
}
|
||||
|
||||
void SetSurface(SystemDraw& w, int x, int y, int cx, int cy, const RGBA *pixels)
|
||||
{
|
||||
GuiLock __;
|
||||
// Empty as CanSetSurface is false
|
||||
}
|
||||
|
||||
void SetSurface(SystemDraw& w, const Rect& dest, const RGBA *pixels, Size psz, Point poff)
|
||||
{
|
||||
GuiLock __;
|
||||
// Empty as CanSetSurface is false
|
||||
}
|
||||
|
||||
#define IMAGECLASS FBImg
|
||||
#define IMAGEFILE <Turtle/FB.iml>
|
||||
#include <Draw/iml_source.h>
|
||||
|
||||
#define STD_CURSOR(name, sdl) \
|
||||
Image Image::name() { static Image img; ONCELOCK { img = FBImg::name(); img.SetAuxData(sdl); } return img; }
|
||||
|
||||
STD_CURSOR(Arrow, 1)
|
||||
STD_CURSOR(Wait, 2)
|
||||
STD_CURSOR(IBeam, 3)
|
||||
STD_CURSOR(No, 4)
|
||||
STD_CURSOR(SizeAll, 5)
|
||||
STD_CURSOR(SizeHorz, 6)
|
||||
STD_CURSOR(SizeVert, 7)
|
||||
STD_CURSOR(SizeTopLeft, 8)
|
||||
STD_CURSOR(SizeTop, 9)
|
||||
STD_CURSOR(SizeTopRight, 10)
|
||||
STD_CURSOR(SizeLeft, 11)
|
||||
STD_CURSOR(SizeRight, 12)
|
||||
STD_CURSOR(SizeBottomLeft, 13)
|
||||
STD_CURSOR(SizeBottom, 14)
|
||||
STD_CURSOR(SizeBottomRight, 15)
|
||||
STD_CURSOR(Hand, 16)
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
#define WEBKEY(x) x
|
||||
|
||||
K_BACK = WEBKEY(8) + K_DELTA,
|
||||
K_BACKSPACE = WEBKEY(8) + K_DELTA,
|
||||
|
||||
//handled extra in fbKEYtoK
|
||||
K_TAB = 9, //SDLK_TAB,
|
||||
|
||||
K_SPACE = 32, //SDLK_SPACE,
|
||||
|
||||
K_RETURN = 13, //SDLK_RETURN,
|
||||
K_ENTER = K_RETURN,
|
||||
|
||||
K_SHIFT_KEY = WEBKEY(16) + K_DELTA,
|
||||
K_CTRL_KEY = WEBKEY(17) + K_DELTA,
|
||||
K_ALT_KEY = WEBKEY(18) + K_DELTA,
|
||||
|
||||
K_CAPSLOCK = WEBKEY(20) + K_DELTA,
|
||||
K_ESCAPE = WEBKEY(27) + K_DELTA,
|
||||
K_PRIOR = WEBKEY(33) + K_DELTA,
|
||||
K_PAGEUP = WEBKEY(33) + K_DELTA,
|
||||
K_NEXT = WEBKEY(34) + K_DELTA,
|
||||
K_PAGEDOWN = WEBKEY(34) + K_DELTA,
|
||||
K_END = WEBKEY(35) + K_DELTA,
|
||||
K_HOME = WEBKEY(36) + K_DELTA,
|
||||
K_LEFT = WEBKEY(37) + K_DELTA,
|
||||
K_UP = WEBKEY(38) + K_DELTA,
|
||||
K_RIGHT = WEBKEY(39) + K_DELTA,
|
||||
K_DOWN = WEBKEY(40) + K_DELTA,
|
||||
K_INSERT = WEBKEY(45) + K_DELTA,
|
||||
K_DELETE = WEBKEY(46) + K_DELTA,
|
||||
|
||||
K_NUMPAD0 = WEBKEY(96) + K_DELTA,
|
||||
K_NUMPAD1 = WEBKEY(97) + K_DELTA,
|
||||
K_NUMPAD2 = WEBKEY(98) + K_DELTA,
|
||||
K_NUMPAD3 = WEBKEY(99) + K_DELTA,
|
||||
K_NUMPAD4 = WEBKEY(100) + K_DELTA,
|
||||
K_NUMPAD5 = WEBKEY(101) + K_DELTA,
|
||||
K_NUMPAD6 = WEBKEY(102) + K_DELTA,
|
||||
K_NUMPAD7 = WEBKEY(103) + K_DELTA,
|
||||
K_NUMPAD8 = WEBKEY(104) + K_DELTA,
|
||||
K_NUMPAD9 = WEBKEY(105) + K_DELTA,
|
||||
K_MULTIPLY = WEBKEY(106) + K_DELTA,
|
||||
K_ADD = WEBKEY(107) + K_DELTA,
|
||||
K_SEPARATOR = WEBKEY(108) + K_DELTA,
|
||||
K_SUBTRACT = WEBKEY(109) + K_DELTA,
|
||||
K_DECIMAL = WEBKEY(110) + K_DELTA,
|
||||
K_DIVIDE = WEBKEY(111) + K_DELTA,
|
||||
K_SCROLL = WEBKEY(145) + K_DELTA,
|
||||
|
||||
K_F1 = WEBKEY(112) + K_DELTA,
|
||||
K_F2 = WEBKEY(113) + K_DELTA,
|
||||
K_F3 = WEBKEY(114) + K_DELTA,
|
||||
K_F4 = WEBKEY(115) + K_DELTA,
|
||||
K_F5 = WEBKEY(116) + K_DELTA,
|
||||
K_F6 = WEBKEY(117) + K_DELTA,
|
||||
K_F7 = WEBKEY(118) + K_DELTA,
|
||||
K_F8 = WEBKEY(119) + K_DELTA,
|
||||
K_F9 = WEBKEY(120) + K_DELTA,
|
||||
K_F10 = WEBKEY(121) + K_DELTA,
|
||||
K_F11 = WEBKEY(122) + K_DELTA,
|
||||
K_F12 = WEBKEY(123) + K_DELTA,
|
||||
|
||||
K_A = WEBKEY('A') + K_DELTA,
|
||||
K_B = WEBKEY('B') + K_DELTA,
|
||||
K_C = WEBKEY('C') + K_DELTA,
|
||||
K_D = WEBKEY('D') + K_DELTA,
|
||||
K_E = WEBKEY('E') + K_DELTA,
|
||||
K_F = WEBKEY('F') + K_DELTA,
|
||||
K_G = WEBKEY('G') + K_DELTA,
|
||||
K_H = WEBKEY('H') + K_DELTA,
|
||||
K_I = WEBKEY('I') + K_DELTA,
|
||||
K_J = WEBKEY('J') + K_DELTA,
|
||||
K_K = WEBKEY('K') + K_DELTA,
|
||||
K_L = WEBKEY('L') + K_DELTA,
|
||||
K_M = WEBKEY('M') + K_DELTA,
|
||||
K_N = WEBKEY('N') + K_DELTA,
|
||||
K_O = WEBKEY('O') + K_DELTA,
|
||||
K_P = WEBKEY('P') + K_DELTA,
|
||||
K_Q = WEBKEY('Q') + K_DELTA,
|
||||
K_R = WEBKEY('R') + K_DELTA,
|
||||
K_S = WEBKEY('S') + K_DELTA,
|
||||
K_T = WEBKEY('T') + K_DELTA,
|
||||
K_U = WEBKEY('U') + K_DELTA,
|
||||
K_V = WEBKEY('V') + K_DELTA,
|
||||
K_W = WEBKEY('W') + K_DELTA,
|
||||
K_X = WEBKEY('X') + K_DELTA,
|
||||
K_Y = WEBKEY('Y') + K_DELTA,
|
||||
K_Z = WEBKEY('Z') + K_DELTA,
|
||||
K_0 = WEBKEY('0') + K_DELTA,
|
||||
K_1 = WEBKEY('1') + K_DELTA,
|
||||
K_2 = WEBKEY('2') + K_DELTA,
|
||||
K_3 = WEBKEY('3') + K_DELTA,
|
||||
K_4 = WEBKEY('4') + K_DELTA,
|
||||
K_5 = WEBKEY('5') + K_DELTA,
|
||||
K_6 = WEBKEY('6') + K_DELTA,
|
||||
K_7 = WEBKEY('7') + K_DELTA,
|
||||
K_8 = WEBKEY('8') + K_DELTA,
|
||||
K_9 = WEBKEY('9') + K_DELTA,
|
||||
|
||||
K_CTRL_LBRACKET = K_CTRL|219|K_DELTA,
|
||||
K_CTRL_RBRACKET = K_CTRL|221|K_DELTA,
|
||||
K_CTRL_MINUS = K_CTRL|189|K_DELTA,
|
||||
K_CTRL_GRAVE = K_CTRL|192|K_DELTA,
|
||||
K_CTRL_SLASH = K_CTRL|191|K_DELTA,
|
||||
K_CTRL_BACKSLASH = K_CTRL|220|K_DELTA,
|
||||
K_CTRL_COMMA = K_CTRL|188|K_DELTA,
|
||||
K_CTRL_PERIOD = K_CTRL|190|K_DELTA,
|
||||
K_CTRL_SEMICOLON = K_CTRL|59|K_DELTA,
|
||||
K_CTRL_EQUAL = K_CTRL|61|K_DELTA,
|
||||
K_CTRL_APOSTROPHE= K_CTRL|222|K_DELTA,
|
||||
|
||||
K_BREAK = WEBKEY(3) + K_DELTA, // Is it really?
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class TopWindowFrame : public Ctrl {
|
||||
public:
|
||||
virtual void Layout();
|
||||
virtual void Paint(Draw& w);
|
||||
virtual Image CursorImage(Point p, dword keyflags);
|
||||
virtual void LeftDown(Point p, dword keyflags);
|
||||
virtual void LeftHold(Point p, dword keyflags);
|
||||
virtual void LeftDouble(Point p, dword keyflags);
|
||||
virtual void MouseMove(Point p, dword keyflags);
|
||||
virtual void CancelMode();
|
||||
virtual void LeftUp(Point p, dword keyflags);
|
||||
|
||||
private:
|
||||
Point dir;
|
||||
Point startpos;
|
||||
Rect startrect;
|
||||
|
||||
bool maximized;
|
||||
Rect overlapped;
|
||||
|
||||
bool holding;
|
||||
TimeCallback hold;
|
||||
|
||||
Point GetDragMode(Point p);
|
||||
Image GetDragImage(Point dragmode);
|
||||
void StartDrag();
|
||||
Rect Margins() const;
|
||||
Rect ComputeClient(Rect r);
|
||||
void Hold();
|
||||
|
||||
typedef TopWindowFrame CLASSNAME;
|
||||
|
||||
public:
|
||||
String title;
|
||||
Button close, maximize;
|
||||
Image icon;
|
||||
Size minsize;
|
||||
bool sizeable;
|
||||
TopWindow *window;
|
||||
|
||||
void SetTitle(const String& s) { title = s; Refresh(); }
|
||||
Rect GetClient() const;
|
||||
void SetClient(Rect r);
|
||||
void GripResize();
|
||||
|
||||
void Maximize();
|
||||
void Overlap();
|
||||
void ToggleMaximize();
|
||||
bool IsMaximized() const { return maximized; }
|
||||
void SyncRect();
|
||||
|
||||
TopWindowFrame();
|
||||
};
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LLOG(x)
|
||||
#define LDUMP(x) // RDUMP(x)
|
||||
#define LTIMING(x)
|
||||
|
||||
TurtleStream Ctrl::turtle_stream;
|
||||
|
||||
void Ctrl::Put16(int x)
|
||||
{
|
||||
Put8(LOBYTE(x));
|
||||
Put8(HIBYTE(x));
|
||||
}
|
||||
|
||||
void Ctrl::Put32(int x)
|
||||
{
|
||||
Put16(LOWORD(x));
|
||||
Put16(HIWORD(x));
|
||||
}
|
||||
|
||||
void Ctrl::Put(Point p)
|
||||
{// TODO: Clamp?
|
||||
Put16(p.x);
|
||||
Put16(p.y);
|
||||
}
|
||||
|
||||
void Ctrl::Put(Size sz)
|
||||
{
|
||||
Put((Point)sz);
|
||||
}
|
||||
|
||||
void Ctrl::Put(const Rect& r)
|
||||
{
|
||||
Put(r.TopLeft());
|
||||
Put(r.GetSize());
|
||||
}
|
||||
|
||||
void Ctrl::Put(const String& s)
|
||||
{
|
||||
Put32(s.GetLength());
|
||||
turtle_stream.SetDataFlag();
|
||||
turtle_stream.Put(s);
|
||||
}
|
||||
|
||||
void Ctrl::Output()
|
||||
{
|
||||
socket.Timeout(20000);
|
||||
if(turtle_stream.HasData()) {
|
||||
websocket.SendBinary(ZCompress(String(DISABLESENDING, 1))); // Do not send events until data transfered and processed
|
||||
int64 x = ++update_serial;
|
||||
if(IsNull(serial_time0)) {
|
||||
serial_time0 = msecs();
|
||||
serial_0 = update_serial;
|
||||
}
|
||||
Put8(UPDATESERIAL);
|
||||
Put32(LODWORD(x));
|
||||
Put32(HIDWORD(x));
|
||||
String s = turtle_stream.FlushStream();
|
||||
stat_data_send += s.GetCount();
|
||||
LLOG("Sending " << s.GetLength());
|
||||
websocket.SendBinary(s);
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::TimerAndPaint()
|
||||
{
|
||||
LLOG("TimerAndPaint " << msecs());
|
||||
TimerProc(GetTickCount());
|
||||
DefferedFocusSync();
|
||||
SyncCaret();
|
||||
SyncTopWindows();
|
||||
SweepMkImageCache();
|
||||
DoPaint();
|
||||
Output();
|
||||
}
|
||||
|
||||
void Ctrl::SyncCaret()
|
||||
{
|
||||
Rect cr = Null;
|
||||
if(focusCtrl)
|
||||
cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy)
|
||||
+ focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView();
|
||||
if(cr != fbCaretRect) { // TODO: SetCaret should perhaps be called on Ctrl::SetCaret
|
||||
Put8(SETCARET);
|
||||
Put(cr);
|
||||
fbCaretRect = cr;
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::PaintScene(SystemDraw& draw)
|
||||
{
|
||||
if(!desktop)
|
||||
return;
|
||||
LLOG("@ DoPaint");
|
||||
LTIMING("DoPaint paint");
|
||||
draw.Init(invalid, DesktopSize.cy);
|
||||
// draw.Init(DesktopSize);
|
||||
draw.Begin();
|
||||
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
||||
Rect r = topctrl[i]->GetRect();
|
||||
Rect ri = GetClipBound(invalid, r);
|
||||
LLOG(i << " Window " << r << ", bound " << ri);
|
||||
if(!IsNull(ri)) {
|
||||
draw.Clipoff(r);
|
||||
topctrl[i]->UpdateArea(draw, ri - r.TopLeft());
|
||||
draw.End();
|
||||
draw.ExcludeClip(r);
|
||||
Subtract(invalid, r);
|
||||
}
|
||||
}
|
||||
Rect ri = GetClipBound(invalid, DesktopSize);
|
||||
if(!IsNull(ri))
|
||||
desktop->UpdateArea(draw, ri);
|
||||
invalid.Clear();
|
||||
draw.End();
|
||||
|
||||
// DDUMP(turtle_stream.FlushStream().GetCount()); abort();
|
||||
}
|
||||
|
||||
void Ctrl::SetMouseCursor(const Image& image)
|
||||
{
|
||||
GuiLock __;
|
||||
if(image.GetSerialId() != fbCursorImage.GetSerialId()) {
|
||||
fbCursorImage = image;
|
||||
fbCursorPos = Null;
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::SyncClient()
|
||||
{
|
||||
while(recieved_update_serial < update_serial) {
|
||||
GuiSleep(10);
|
||||
IsWaitingEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::DoPaint()
|
||||
{
|
||||
if(recieved_update_serial >= update_serial - 1) { // Prevent overloading of transfer
|
||||
if(invalid.GetCount() && desktop) {
|
||||
SystemDraw draw;
|
||||
PaintScene(draw);
|
||||
}
|
||||
static int64 prev_cursor_id = Null;
|
||||
int64 id = fbCursorImage.GetSerialId();
|
||||
if(id != prev_cursor_id) {
|
||||
prev_cursor_id = id;
|
||||
int64 q = fbCursorImage.GetAuxData();
|
||||
if(q) {
|
||||
Put8(STD_CURSORIMAGE);
|
||||
Put8(clamp((int)q, 1, 16));
|
||||
}
|
||||
else {
|
||||
String h;
|
||||
Point p = fbCursorImage.GetHotSpot();
|
||||
h << "url('data:image/png;base64,"
|
||||
<< Base64Encode(PNGEncoder().SaveString(fbCursorImage))
|
||||
<< "') " << p.x << ' ' << p.y << ", default";
|
||||
Put8(SETCURSORIMAGE);
|
||||
Put16(0); // _TODO_ Cursor cache
|
||||
Put(h);
|
||||
Put8(CURSORIMAGE);
|
||||
Put16(0); // _TODO_ Cursor cache
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#include "Turtle.brc"
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // DLOG(x)
|
||||
#define LDUMP(x) // DDUMP(x)
|
||||
#define LTIMING(x)
|
||||
|
||||
int Ctrl::main_pid;
|
||||
Vector<int> Ctrl::pid;
|
||||
bool Ctrl::quit;
|
||||
|
||||
|
||||
void Ctrl::Broadcast(int signal) {
|
||||
#ifdef PLATFORM_POSIX
|
||||
if(getpid() == main_pid)
|
||||
for(int i = 0; i < pid.GetCount(); i++)
|
||||
kill(pid[i], signal);
|
||||
#endif
|
||||
}
|
||||
|
||||
String Ctrl::host = "localhost";
|
||||
int Ctrl::port = 8088;
|
||||
bool Ctrl::debugmode;
|
||||
int Ctrl::connection_limit = INT_MAX;
|
||||
String Ctrl::ip = "0.0.0.0";
|
||||
TcpSocket Ctrl::socket;
|
||||
WebSocket Ctrl::websocket;
|
||||
int64 Ctrl::update_serial;
|
||||
int64 Ctrl::recieved_update_serial;
|
||||
|
||||
Callback2<int, String> Ctrl::WhenConnect;
|
||||
Callback1<int> Ctrl::WhenTerminate;
|
||||
|
||||
bool Ctrl::StartSession()
|
||||
{
|
||||
LLOG("Connect");
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
main_pid = getpid();
|
||||
#endif
|
||||
|
||||
IpAddrInfo ipinfo;
|
||||
ipinfo.Execute(ip, port, IpAddrInfo::FAMILY_IPV4);
|
||||
|
||||
TcpSocket server;
|
||||
|
||||
#ifdef _DEBUG
|
||||
int qq = 0;
|
||||
for(;;) {
|
||||
if(server.Listen(ipinfo, port, 5, false, true))
|
||||
break;
|
||||
Cout() << "Trying to start listening (other process using the same port?) " << ++qq << "\n";
|
||||
Sleep(1000);
|
||||
}
|
||||
#else
|
||||
if(!server.Listen(ipinfo, port, 5, false, true)) {
|
||||
RLOG("Cannot open server socket for listening!");
|
||||
Exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
RLOG("Starting to listen on 8088, pid: " << getpid());
|
||||
socket.Timeout(2000); // TODO: Not quite ideal way to make quit work..
|
||||
for(;;) {
|
||||
if(quit)
|
||||
return false;
|
||||
#ifdef PLATFORM_POSIX
|
||||
int i = 0;
|
||||
while(i < pid.GetCount())
|
||||
if(pid[i] && waitpid(pid[i], 0, WNOHANG | WUNTRACED) > 0) {
|
||||
WhenTerminate(pid[i]);
|
||||
pid.Remove(i);
|
||||
}
|
||||
else
|
||||
i++;
|
||||
#endif
|
||||
if(server.IsError())
|
||||
server.ClearError();
|
||||
if(socket.Accept(server)) {
|
||||
HttpHeader http;
|
||||
if(http.Read(socket)) {
|
||||
RLOG("Accepted, header read");
|
||||
if(websocket.WebAccept(socket, http)) { // TODO: Connection limit, info
|
||||
if(pid.GetCount() >= connection_limit) {
|
||||
socket.Close();
|
||||
continue;
|
||||
}
|
||||
#ifdef PLATFORM_POSIX
|
||||
if(debugmode)
|
||||
break;
|
||||
int newpid = fork();
|
||||
if(newpid == 0)
|
||||
break;
|
||||
else {
|
||||
pid.Add(newpid);
|
||||
WhenConnect(newpid, socket.GetPeerAddr());
|
||||
socket.Close();
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
RLOG("Sending HTML");
|
||||
String html = String(turtle_html, turtle_html_length);
|
||||
html.Replace("%%host%%", "ws://" + Nvl(GetIniKey("turtle_host"), Nvl(host, "localhost")) + ":" + AsString(port));
|
||||
HttpResponse(socket, http.scgi, 200, "OK", "text/html", html);
|
||||
}
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
RLOG("Connection established with " << socket.GetPeerAddr() << ", pid: " << getpid());
|
||||
server.Close();
|
||||
if(socket.IsError())
|
||||
RLOG("CONNECT ERROR: " << socket.GetErrorDesc());
|
||||
|
||||
Ctrl::GlobalBackBuffer();
|
||||
Ctrl::InitTimer();
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
SetStdFont(ScreenSans(12)); //FIXME general handling
|
||||
#endif
|
||||
ChStdSkin();
|
||||
|
||||
extern StaticRect& DesktopRect();
|
||||
|
||||
DesktopRect().Color(Cyan());
|
||||
DesktopRect().SetRect(0, 0, DesktopSize.cx, DesktopSize.cy);
|
||||
SetDesktop(Desktop());
|
||||
|
||||
stat_started = GetSysTime();
|
||||
|
||||
while(!IsWaitingEvent())
|
||||
GuiSleep(10);
|
||||
|
||||
ProcessEvents();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Callback Ctrl::WhenDisconnect;
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LLOG(x)
|
||||
#define LDUMP(x) // RDUMP(x)
|
||||
#define LTIMING(x)
|
||||
|
||||
void TurtleStream::Reset()
|
||||
{
|
||||
zlib.Clear();
|
||||
zlib.Compress();
|
||||
hasdata = false;
|
||||
}
|
||||
|
||||
void TurtleStream::Out(const void *data, dword size)
|
||||
{
|
||||
zlib.Put(data, (int)size);
|
||||
}
|
||||
|
||||
String TurtleStream::FlushStream()
|
||||
{
|
||||
Flush();
|
||||
zlib.End();
|
||||
String s = zlib.Get();
|
||||
Reset();
|
||||
return s;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
|
||||
void TopWindow::SyncFrameRect(const Rect& r)
|
||||
{
|
||||
frame->SetClient(r);
|
||||
}
|
||||
|
||||
void TopWindow::DestroyFrame()
|
||||
{
|
||||
if(frame->IsOpen())
|
||||
frame->DestroyWnd();
|
||||
}
|
||||
|
||||
void TopWindow::GripResize()
|
||||
{
|
||||
frame->GripResize();
|
||||
}
|
||||
|
||||
void TopWindow::SyncSizeHints()
|
||||
{
|
||||
SyncCaption();
|
||||
}
|
||||
|
||||
void TopWindow::SyncTitle()
|
||||
{
|
||||
SyncCaption();
|
||||
}
|
||||
|
||||
void TopWindow::SyncCaption()
|
||||
{
|
||||
GuiLock __;
|
||||
frame->title = title.ToString();
|
||||
#ifdef _DEBUG
|
||||
frame->title = "TELPP";
|
||||
#endif
|
||||
frame->minsize = minsize;
|
||||
frame->close.Show(!noclosebox);
|
||||
frame->maximize.Show(maximizebox);
|
||||
frame->sizeable = sizeable;
|
||||
frame->RefreshLayout();
|
||||
frame->Refresh();
|
||||
frame->close <<= Proxy(WhenClose);
|
||||
frame->icon = icon;
|
||||
frame->Enable(IsEnabled());
|
||||
}
|
||||
|
||||
void TopWindow::State(int reason)
|
||||
{
|
||||
SyncCaption();
|
||||
}
|
||||
|
||||
void TopWindow::SyncRect()
|
||||
{
|
||||
frame->SyncRect();
|
||||
Rect r = frame->GetClient();
|
||||
if(r != GetRect())
|
||||
SetRect(r);
|
||||
}
|
||||
|
||||
void TopWindow::Open(Ctrl *owner)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("Open " << Upp::Name(owner));
|
||||
Rect r = GetRect();
|
||||
if(r.IsEmpty())
|
||||
SetRect(GetDefaultWindowRect());
|
||||
else
|
||||
if(r.left == 0 && r.top == 0)
|
||||
if(owner && center == 1)
|
||||
SetRect(owner->GetRect().CenterRect(r.GetSize()));
|
||||
else
|
||||
if(center)
|
||||
SetRect(GetWorkArea().CenterRect(r.GetSize()));
|
||||
frame->SetClient(GetRect());
|
||||
frame->window = this;
|
||||
frame->PopUp(owner, false, true);
|
||||
PopUp(frame, false, true);
|
||||
popup = false;
|
||||
SetRect(frame->GetClient());
|
||||
SyncCaption();
|
||||
if(state == MAXIMIZED)
|
||||
frame->Maximize();
|
||||
}
|
||||
|
||||
void TopWindow::Open()
|
||||
{
|
||||
Open(GetActiveCtrl());
|
||||
}
|
||||
|
||||
void TopWindow::OpenMain()
|
||||
{
|
||||
Open(NULL);
|
||||
}
|
||||
|
||||
void TopWindow::Minimize(bool effect)
|
||||
{
|
||||
// state = MINIMIZED;
|
||||
}
|
||||
|
||||
TopWindow& TopWindow::FullScreen(bool b)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
void TopWindow::Maximize(bool effect)
|
||||
{
|
||||
state = MAXIMIZED;
|
||||
frame->Maximize();
|
||||
}
|
||||
|
||||
void TopWindow::Overlap(bool effect)
|
||||
{
|
||||
GuiLock __;
|
||||
state = OVERLAPPED;
|
||||
frame->Overlap();
|
||||
}
|
||||
|
||||
TopWindow& TopWindow::TopMost(bool b, bool stay_top)
|
||||
{
|
||||
GuiLock __;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool TopWindow::IsTopMost() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopWindow::GuiPlatformConstruct()
|
||||
{
|
||||
frame = new TopWindowFrame;
|
||||
}
|
||||
|
||||
void TopWindow::GuiPlatformDestruct()
|
||||
{
|
||||
delete frame;
|
||||
}
|
||||
|
||||
void TopWindow::SerializePlacement(Stream& s, bool reminimize)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
//$ class TopWindow {
|
||||
public:
|
||||
virtual void State(int reason);
|
||||
|
||||
private:
|
||||
TopWindowFrame *frame;
|
||||
|
||||
void SyncRect();
|
||||
void SyncFrameRect(const Rect& r);
|
||||
void DestroyFrame();
|
||||
|
||||
friend class Ctrl;
|
||||
|
||||
public:
|
||||
void GripResize();
|
||||
//$ };
|
||||
|
|
@ -1,236 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
#define LDUMP(x) //DDUMP(x)
|
||||
|
||||
TopWindowFrame::TopWindowFrame()
|
||||
{
|
||||
close.SetImage(FBImg::close());
|
||||
close.EdgeStyle();
|
||||
Add(close);
|
||||
maximize.SetImage(FBImg::maximize());
|
||||
maximize.EdgeStyle();
|
||||
Add(maximize);
|
||||
maximize <<= THISBACK(ToggleMaximize);
|
||||
maximized = false;
|
||||
sizeable = false;
|
||||
holding = false;
|
||||
}
|
||||
|
||||
void TopWindowFrame::SyncRect()
|
||||
{
|
||||
if(maximized) {
|
||||
Size sz = GetWorkArea().GetSize();
|
||||
if(GetRect().GetSize() != sz)
|
||||
SetRect(sz);
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::Maximize()
|
||||
{
|
||||
if(!maximized && maximize.IsShown()) {
|
||||
maximized = true;
|
||||
overlapped = GetRect();
|
||||
SetRect(GetWorkArea().GetSize());
|
||||
maximize.SetImage(FBImg::overlap());
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::Overlap()
|
||||
{
|
||||
if(maximized && maximize.IsShown()) {
|
||||
maximized = false;
|
||||
SetRect(overlapped);
|
||||
maximize.SetImage(FBImg::maximize());
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::ToggleMaximize()
|
||||
{
|
||||
if(maximized)
|
||||
Overlap();
|
||||
else
|
||||
Maximize();
|
||||
}
|
||||
|
||||
Rect TopWindowFrame::Margins() const
|
||||
{
|
||||
return maximized ? Rect(0, 0, 0, 0) : ChMargins(FBImg::border());
|
||||
}
|
||||
|
||||
void TopWindowFrame::Paint(Draw& w)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
Rect m = Margins();
|
||||
int c = GetStdFontCy() + 4;
|
||||
ChPaintEdge(w, sz, FBImg::border());
|
||||
ChPaint(w, m.left, m.top, sz.cx - m.left - m.right, GetStdFontCy() + 4,
|
||||
window->IsForeground() ? FBImg::title() : FBImg::bgtitle());
|
||||
int tx = m.left + 2;
|
||||
int tcx = sz.cx - m.left - m.right - 4 - c * (close.IsShown() + maximize.IsShown());
|
||||
if(!IsNull(icon)) {
|
||||
Image h = icon;
|
||||
if(h.GetWidth() > c || h.GetHeight() > c)
|
||||
h = Rescale(h, GetFitSize(h.GetSize(), Size(c)));
|
||||
w.DrawImage(tx, m.top + 2, h);
|
||||
tx += c;
|
||||
tcx -= c;
|
||||
}
|
||||
DrawTextEllipsis(w, tx, m.top + 2, tcx, title, "..", StdFont(), SColorText());
|
||||
}
|
||||
|
||||
void TopWindowFrame::Layout()
|
||||
{
|
||||
Size sz = GetSize();
|
||||
Rect m = Margins();
|
||||
int c = GetStdFontCy() + 4;
|
||||
int x = sz.cx - m.right;
|
||||
if(close.IsShown())
|
||||
close.SetRect(x -= c, m.top, c, c);
|
||||
if(maximize.IsShown())
|
||||
maximize.SetRect(x -= c, m.top, c, c);
|
||||
}
|
||||
|
||||
Rect TopWindowFrame::GetClient() const
|
||||
{
|
||||
Rect r = GetRect();
|
||||
Rect m = Margins();
|
||||
r.left += m.left;
|
||||
r.right -= m.right;
|
||||
r.top += m.top;
|
||||
r.bottom -= m.bottom;
|
||||
r.top += GetStdFontCy() + 4;
|
||||
return r;
|
||||
}
|
||||
|
||||
Rect TopWindowFrame::ComputeClient(Rect r)
|
||||
{
|
||||
Rect m = Margins();
|
||||
r.left -= m.left;
|
||||
r.right += m.right;
|
||||
r.top -= m.top;
|
||||
r.bottom += m.bottom;
|
||||
r.top -= GetStdFontCy() + 4;
|
||||
return r;
|
||||
}
|
||||
|
||||
void TopWindowFrame::SetClient(Rect r)
|
||||
{
|
||||
SetRect(ComputeClient(r));
|
||||
}
|
||||
|
||||
Point TopWindowFrame::GetDragMode(Point p)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
Rect m = ChMargins(FBImg::border());
|
||||
Point dir;
|
||||
dir.y = p.y < m.top ? -1 : p.y > sz.cy - m.top ? 1 : 0;
|
||||
dir.x = p.x < m.left ? -1 : p.x > sz.cx - m.right ? 1 : 0;
|
||||
return dir;
|
||||
}
|
||||
|
||||
void TopWindowFrame::StartDrag()
|
||||
{
|
||||
if(maximized)
|
||||
return;
|
||||
if(!sizeable && (dir.x || dir.y))
|
||||
return;
|
||||
SetCapture();
|
||||
startrect = GetRect();
|
||||
startpos = GetMousePos();
|
||||
LLOG("START DRAG ---------------");
|
||||
}
|
||||
|
||||
void TopWindowFrame::GripResize()
|
||||
{
|
||||
dir = Point(1, 1);
|
||||
StartDrag();
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftDown(Point p, dword keyflags)
|
||||
{
|
||||
dir = GetDragMode(p);
|
||||
StartDrag();
|
||||
}
|
||||
|
||||
void TopWindowFrame::CancelMode()
|
||||
{
|
||||
holding = false;
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftUp(Point p, dword keyflags)
|
||||
{
|
||||
holding = false;
|
||||
}
|
||||
|
||||
void TopWindowFrame::Hold()
|
||||
{
|
||||
if(HasCapture()) {
|
||||
if(HasMouse() && GetMouseLeft() && holding)
|
||||
StartDrag();
|
||||
ReleaseCapture();
|
||||
holding = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftHold(Point p, dword keyflags)
|
||||
{
|
||||
/* if(HasCapture() || FullWindowDrag)
|
||||
return;
|
||||
dir = GetDragMode(p);
|
||||
if(!dir.x && !dir.y)
|
||||
StartDrag();*/
|
||||
}
|
||||
|
||||
void TopWindowFrame::LeftDouble(Point p, dword keyflags)
|
||||
{
|
||||
ToggleMaximize();
|
||||
IgnoreMouseUp();
|
||||
}
|
||||
|
||||
void TopWindowFrame::MouseMove(Point, dword)
|
||||
{
|
||||
LDUMP(HasWndCapture());
|
||||
LDUMP(HasCapture());
|
||||
if(!HasCapture() || holding)
|
||||
return;
|
||||
Size msz = ComputeClient(minsize).GetSize();
|
||||
Point p = GetMousePos() - startpos;
|
||||
Rect r = startrect;
|
||||
if(dir.x == -1)
|
||||
r.left = min(r.left + p.x, startrect.right - msz.cx);
|
||||
if(dir.x == 1)
|
||||
r.right = max(r.right + p.x, startrect.left + msz.cx);
|
||||
if(dir.y == -1)
|
||||
r.top = min(r.top + p.y, startrect.bottom - msz.cy);
|
||||
if(dir.y == 1)
|
||||
r.bottom = max(r.bottom + p.y, startrect.top + msz.cy);
|
||||
if(dir.y == 0 && dir.x == 0)
|
||||
r.Offset(p);
|
||||
SetRect(r);
|
||||
}
|
||||
|
||||
Image TopWindowFrame::GetDragImage(Point dir)
|
||||
{
|
||||
static Image (*im[9])() = {
|
||||
Image::SizeTopLeft, Image::SizeLeft, Image::SizeBottomLeft,
|
||||
Image::SizeTop, Image::Arrow, Image::SizeBottom,
|
||||
Image::SizeTopRight, Image::SizeRight, Image::SizeBottomRight,
|
||||
};
|
||||
return (*im[(dir.x + 1) * 3 + (dir.y + 1)])();
|
||||
}
|
||||
|
||||
Image TopWindowFrame::CursorImage(Point p, dword)
|
||||
{
|
||||
if(!sizeable)
|
||||
return Image::Arrow();
|
||||
return GetDragImage(HasCapture() ? dir : GetDragMode(p));
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1 +0,0 @@
|
|||
BINARY(turtle_html, "Turtle.html")
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
#define GUI_TURTLE
|
||||
|
||||
#define _TODO_ // _DBG_
|
||||
|
||||
#include <Draw/Draw.h>
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
#include <CtrlCore/stdids.h>
|
||||
#endif
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define IMAGECLASS FBImg
|
||||
#define IMAGEFILE <Turtle/FB.iml>
|
||||
#include <Draw/iml_header.h>
|
||||
|
||||
class TurtleStream : public OutStream {
|
||||
public:
|
||||
virtual void Out(const void *data, dword size);
|
||||
|
||||
private:
|
||||
Zlib zlib;
|
||||
bool hasdata;
|
||||
|
||||
void Reset();
|
||||
|
||||
public:
|
||||
void SetDataFlag() { hasdata = true; }
|
||||
bool HasData() const { return hasdata; }
|
||||
String FlushStream();
|
||||
|
||||
TurtleStream() { Reset(); }
|
||||
};
|
||||
|
||||
enum Command {
|
||||
RECT = 0,
|
||||
IMAGE = 1,
|
||||
SETIMAGE = 2,
|
||||
INVERTRECT = 3,
|
||||
STD_CURSORIMAGE = 4,
|
||||
SETCURSORIMAGE = 5,
|
||||
CURSORIMAGE = 6,
|
||||
DISABLESENDING = 7,
|
||||
UPDATESERIAL = 8,
|
||||
|
||||
IMAGEPP = 9,
|
||||
IMAGENP = 10,
|
||||
IMAGEPN = 11,
|
||||
IMAGENN = 12,
|
||||
|
||||
RECTPP = 13,
|
||||
RECTNP = 14,
|
||||
RECTPN = 15,
|
||||
RECTNN = 16,
|
||||
|
||||
SETCARET = 17,
|
||||
|
||||
HORZDRAGLINE = 18,
|
||||
VERTDRAGLINE = 19,
|
||||
};
|
||||
|
||||
|
||||
class SystemDraw : public SDraw {
|
||||
public:
|
||||
virtual void PutImage(Point p, const Image& img, const Rect& src);
|
||||
virtual void PutRect(const Rect& r, Color color);
|
||||
|
||||
public:
|
||||
struct ImageSysData {
|
||||
Image img;
|
||||
int handle;
|
||||
|
||||
static Vector<int> free_handle;
|
||||
static int handle_count;
|
||||
|
||||
static int AllocImageHandle();
|
||||
static void FreeImageHandle(int handle);
|
||||
|
||||
void Init(const Image& img);
|
||||
~ImageSysData();
|
||||
};
|
||||
|
||||
static LRUCache<ImageSysData, int64> cache;
|
||||
|
||||
Point pos;
|
||||
|
||||
static void ResetI();
|
||||
|
||||
bool CanSetSurface() { return false; }
|
||||
static void Flush() {}
|
||||
|
||||
SystemDraw() { pos = Point(0, 0); }
|
||||
};
|
||||
|
||||
struct BackDraw__ : public SystemDraw {
|
||||
BackDraw__() : SystemDraw() {}
|
||||
};
|
||||
|
||||
class BackDraw : public BackDraw__ { // Dummy only, as we are running in GlobalBackBuffer mode
|
||||
Size size;
|
||||
Draw *painting;
|
||||
Point painting_offset;
|
||||
ImageBuffer ib;
|
||||
|
||||
public:
|
||||
virtual bool IsPaintingOp(const Rect& r) const;
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
class ImageDraw : public SImageDraw {
|
||||
public:
|
||||
ImageDraw(Size sz) : SImageDraw(sz) {}
|
||||
ImageDraw(int cx, int cy) : SImageDraw(cx, cy) {}
|
||||
};
|
||||
|
||||
void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, uint64 pattern);
|
||||
|
||||
class TopWindowFrame;
|
||||
|
||||
#define GUIPLATFORM_CTRL_TOP_DECLS Ctrl *owner_window;
|
||||
|
||||
#define GUIPLATFORM_CTRL_DECLS_INCLUDE <Turtle/Ctrl.h>
|
||||
|
||||
#define GUIPLATFORM_PASTECLIP_DECLS \
|
||||
bool dnd; \
|
||||
friend struct DnDLoop; \
|
||||
|
||||
#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE <Turtle/Top.h>
|
||||
|
||||
class PrinterJob { // _TODO_
|
||||
NilDraw nil;
|
||||
Vector<int> pages;
|
||||
|
||||
public:
|
||||
Draw& GetDraw() { return nil; }
|
||||
operator Draw&() { return GetDraw(); }
|
||||
const Vector<int>& GetPages() const { return pages; }
|
||||
int operator[](int i) const { return 0; }
|
||||
int GetPageCount() const { return 0; }
|
||||
|
||||
bool Execute() { return false; }
|
||||
|
||||
PrinterJob& Landscape(bool b = true) { return *this; }
|
||||
PrinterJob& MinMaxPage(int minpage, int maxpage) { return *this; }
|
||||
PrinterJob& PageCount(int n) { return *this; }
|
||||
PrinterJob& CurrentPage(int currentpage) { return *this; }
|
||||
PrinterJob& Name(const char *_name) { return *this; }
|
||||
|
||||
PrinterJob(const char *name = NULL) {}
|
||||
~PrinterJob() {}
|
||||
};
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#define GUIPLATFORM_INCLUDE_AFTER <Turtle/After.h>
|
||||
|
|
@ -1,551 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<canvas id="myCanvas" width="1000" height="1000" style="border:0px" tabindex="1" oncontextmenu="return false;">
|
||||
Your browser does not support the HTML5 canvas tag.
|
||||
</canvas>
|
||||
|
||||
<script>
|
||||
|
||||
// zlib.js for inflate
|
||||
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';function m(b){throw b;}var n=void 0,r=this;function s(b,d){var a=b.split("."),c=r;!(a[0]in c)&&c.execScript&&c.execScript("var "+a[0]);for(var f;a.length&&(f=a.shift());)!a.length&&d!==n?c[f]=d:c=c[f]?c[f]:c[f]={}};var u="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array;function v(b){var d=b.length,a=0,c=Number.POSITIVE_INFINITY,f,e,g,h,k,l,q,p,t;for(p=0;p<d;++p)b[p]>a&&(a=b[p]),b[p]<c&&(c=b[p]);f=1<<a;e=new (u?Uint32Array:Array)(f);g=1;h=0;for(k=2;g<=a;){for(p=0;p<d;++p)if(b[p]===g){l=0;q=h;for(t=0;t<g;++t)l=l<<1|q&1,q>>=1;for(t=l;t<f;t+=k)e[t]=g<<16|p;++h}++g;h<<=1;k<<=1}return[e,a,c]};function w(b,d){this.g=[];this.h=32768;this.d=this.f=this.a=this.l=0;this.input=u?new Uint8Array(b):b;this.m=!1;this.i=x;this.r=!1;if(d||!(d={}))d.index&&(this.a=d.index),d.bufferSize&&(this.h=d.bufferSize),d.bufferType&&(this.i=d.bufferType),d.resize&&(this.r=d.resize);switch(this.i){case y:this.b=32768;this.c=new (u?Uint8Array:Array)(32768+this.h+258);break;case x:this.b=0;this.c=new (u?Uint8Array:Array)(this.h);this.e=this.z;this.n=this.v;this.j=this.w;break;default:m(Error("invalid inflate mode"))}}
|
||||
var y=0,x=1,z={t:y,s:x};
|
||||
w.prototype.k=function(){for(;!this.m;){var b=A(this,3);b&1&&(this.m=!0);b>>>=1;switch(b){case 0:var d=this.input,a=this.a,c=this.c,f=this.b,e=n,g=n,h=n,k=c.length,l=n;this.d=this.f=0;e=d[a++];e===n&&m(Error("invalid uncompressed block header: LEN (first byte)"));g=e;e=d[a++];e===n&&m(Error("invalid uncompressed block header: LEN (second byte)"));g|=e<<8;e=d[a++];e===n&&m(Error("invalid uncompressed block header: NLEN (first byte)"));h=e;e=d[a++];e===n&&m(Error("invalid uncompressed block header: NLEN (second byte)"));h|=
|
||||
e<<8;g===~h&&m(Error("invalid uncompressed block header: length verify"));a+g>d.length&&m(Error("input buffer is broken"));switch(this.i){case y:for(;f+g>c.length;){l=k-f;g-=l;if(u)c.set(d.subarray(a,a+l),f),f+=l,a+=l;else for(;l--;)c[f++]=d[a++];this.b=f;c=this.e();f=this.b}break;case x:for(;f+g>c.length;)c=this.e({p:2});break;default:m(Error("invalid inflate mode"))}if(u)c.set(d.subarray(a,a+g),f),f+=g,a+=g;else for(;g--;)c[f++]=d[a++];this.a=a;this.b=f;this.c=c;break;case 1:this.j(B,C);break;case 2:aa(this);
|
||||
break;default:m(Error("unknown BTYPE: "+b))}}return this.n()};
|
||||
var D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],E=u?new Uint16Array(D):D,F=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],G=u?new Uint16Array(F):F,H=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],I=u?new Uint8Array(H):H,J=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],K=u?new Uint16Array(J):J,L=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,
|
||||
13],M=u?new Uint8Array(L):L,N=new (u?Uint8Array:Array)(288),O,P;O=0;for(P=N.length;O<P;++O)N[O]=143>=O?8:255>=O?9:279>=O?7:8;var B=v(N),Q=new (u?Uint8Array:Array)(30),R,S;R=0;for(S=Q.length;R<S;++R)Q[R]=5;var C=v(Q);function A(b,d){for(var a=b.f,c=b.d,f=b.input,e=b.a,g;c<d;)g=f[e++],g===n&&m(Error("input buffer is broken")),a|=g<<c,c+=8;g=a&(1<<d)-1;b.f=a>>>d;b.d=c-d;b.a=e;return g}
|
||||
function T(b,d){for(var a=b.f,c=b.d,f=b.input,e=b.a,g=d[0],h=d[1],k,l,q;c<h;){k=f[e++];if(k===n)break;a|=k<<c;c+=8}l=g[a&(1<<h)-1];q=l>>>16;b.f=a>>q;b.d=c-q;b.a=e;return l&65535}
|
||||
function aa(b){function d(a,b,c){var d,e,f,g;for(g=0;g<a;)switch(d=T(this,b),d){case 16:for(f=3+A(this,2);f--;)c[g++]=e;break;case 17:for(f=3+A(this,3);f--;)c[g++]=0;e=0;break;case 18:for(f=11+A(this,7);f--;)c[g++]=0;e=0;break;default:e=c[g++]=d}return c}var a=A(b,5)+257,c=A(b,5)+1,f=A(b,4)+4,e=new (u?Uint8Array:Array)(E.length),g,h,k,l;for(l=0;l<f;++l)e[E[l]]=A(b,3);g=v(e);h=new (u?Uint8Array:Array)(a);k=new (u?Uint8Array:Array)(c);b.j(v(d.call(b,a,g,h)),v(d.call(b,c,g,k)))}
|
||||
w.prototype.j=function(b,d){var a=this.c,c=this.b;this.o=b;for(var f=a.length-258,e,g,h,k;256!==(e=T(this,b));)if(256>e)c>=f&&(this.b=c,a=this.e(),c=this.b),a[c++]=e;else{g=e-257;k=G[g];0<I[g]&&(k+=A(this,I[g]));e=T(this,d);h=K[e];0<M[e]&&(h+=A(this,M[e]));c>=f&&(this.b=c,a=this.e(),c=this.b);for(;k--;)a[c]=a[c++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=c};
|
||||
w.prototype.w=function(b,d){var a=this.c,c=this.b;this.o=b;for(var f=a.length,e,g,h,k;256!==(e=T(this,b));)if(256>e)c>=f&&(a=this.e(),f=a.length),a[c++]=e;else{g=e-257;k=G[g];0<I[g]&&(k+=A(this,I[g]));e=T(this,d);h=K[e];0<M[e]&&(h+=A(this,M[e]));c+k>f&&(a=this.e(),f=a.length);for(;k--;)a[c]=a[c++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=c};
|
||||
w.prototype.e=function(){var b=new (u?Uint8Array:Array)(this.b-32768),d=this.b-32768,a,c,f=this.c;if(u)b.set(f.subarray(32768,b.length));else{a=0;for(c=b.length;a<c;++a)b[a]=f[a+32768]}this.g.push(b);this.l+=b.length;if(u)f.set(f.subarray(d,d+32768));else for(a=0;32768>a;++a)f[a]=f[d+a];this.b=32768;return f};
|
||||
w.prototype.z=function(b){var d,a=this.input.length/this.a+1|0,c,f,e,g=this.input,h=this.c;b&&("number"===typeof b.p&&(a=b.p),"number"===typeof b.u&&(a+=b.u));2>a?(c=(g.length-this.a)/this.o[2],e=258*(c/2)|0,f=e<h.length?h.length+e:h.length<<1):f=h.length*a;u?(d=new Uint8Array(f),d.set(h)):d=h;return this.c=d};
|
||||
w.prototype.n=function(){var b=0,d=this.c,a=this.g,c,f=new (u?Uint8Array:Array)(this.l+(this.b-32768)),e,g,h,k;if(0===a.length)return u?this.c.subarray(32768,this.b):this.c.slice(32768,this.b);e=0;for(g=a.length;e<g;++e){c=a[e];h=0;for(k=c.length;h<k;++h)f[b++]=c[h]}e=32768;for(g=this.b;e<g;++e)f[b++]=d[e];this.g=[];return this.buffer=f};
|
||||
w.prototype.v=function(){var b,d=this.b;u?this.r?(b=new Uint8Array(d),b.set(this.c.subarray(0,d))):b=this.c.subarray(0,d):(this.c.length>d&&(this.c.length=d),b=this.c);return this.buffer=b};function U(b,d){var a,c;this.input=b;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.A=d.verify);a=b[this.a++];c=b[this.a++];switch(a&15){case V:this.method=V;break;default:m(Error("unsupported compression method"))}0!==((a<<8)+c)%31&&m(Error("invalid fcheck flag:"+((a<<8)+c)%31));c&32&&m(Error("fdict flag is not supported"));this.q=new w(b,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})}
|
||||
U.prototype.k=function(){var b=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(b[this.a++]<<24|b[this.a++]<<16|b[this.a++]<<8|b[this.a++])>>>0;var c=d;if("string"===typeof c){var f=c.split(""),e,g;e=0;for(g=f.length;e<g;e++)f[e]=(f[e].charCodeAt(0)&255)>>>0;c=f}for(var h=1,k=0,l=c.length,q,p=0;0<l;){q=1024<l?1024:l;l-=q;do h+=c[p++],k+=h;while(--q);h%=65521;k%=65521}a!==(k<<16|h)>>>0&&m(Error("invalid adler-32 checksum"))}return d};var V=8;s("Zlib.Inflate",U);s("Zlib.Inflate.prototype.decompress",U.prototype.k);var W={ADAPTIVE:z.s,BLOCK:z.t},X,Y,Z,$;if(Object.keys)X=Object.keys(W);else for(Y in X=[],Z=0,W)X[Z++]=Y;Z=0;for($=X.length;Z<$;++Z)Y=X[Z],s("Zlib.Inflate.BufferType."+Y,W[Y]);}).call(this);
|
||||
|
||||
function Log(msg)
|
||||
{
|
||||
if (window.console && console.log)
|
||||
console.log(msg); //for firebug
|
||||
}
|
||||
|
||||
function Char(p, ch)
|
||||
{
|
||||
if(p.pos < p.data.length && (255 & p.data[p.pos]) == ch) {
|
||||
p.pos++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function Get8(p)
|
||||
{
|
||||
return p.pos < p.data.length ? (255 & p.data[p.pos++]) : 0;
|
||||
}
|
||||
|
||||
function Get16(p)
|
||||
{
|
||||
var l = Get8(p);
|
||||
var h = Get8(p);
|
||||
return (h << 8) | l;
|
||||
}
|
||||
|
||||
function Get32(p)
|
||||
{
|
||||
var l = Get16(p);
|
||||
var h = Get16(p);
|
||||
return (h << 16) | l;
|
||||
}
|
||||
|
||||
function GetString(p)
|
||||
{
|
||||
var n = Get32(p);
|
||||
var s = "";
|
||||
for(var i = 0; i < n; i++)
|
||||
s += String.fromCharCode(Get8(p));
|
||||
return s;
|
||||
}
|
||||
|
||||
var SendingEnabled = true;
|
||||
|
||||
var posx, posy;
|
||||
var ctx;
|
||||
|
||||
var caretx = 0, carety = 0, caretcx = 0, caretcy = 0, caretshown = false;
|
||||
var caretTimerID;
|
||||
|
||||
function InvertRect(x, y, cx, cy)
|
||||
{
|
||||
if(cx <= 0 || cy <= 0)
|
||||
return;
|
||||
var imageData = ctx.getImageData(x, y, cx, cy);
|
||||
var data = imageData.data;
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
data[i] = 255 - data[i];
|
||||
data[i + 1] = 255 - data[i + 1];
|
||||
data[i + 2] = 255 - data[i + 2];
|
||||
}
|
||||
ctx.putImageData(imageData, x, y);
|
||||
}
|
||||
|
||||
function DrawDragLine(x, y, cx, cy, anim)
|
||||
{
|
||||
if(cx <= 0 || cy <= 0)
|
||||
return;
|
||||
var imageData = ctx.getImageData(x, y, cx, cy);
|
||||
var data = imageData.data;
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
if(((i / 4 + anim) / 4) & 1) {
|
||||
data[i] = 255 - data[i];
|
||||
data[i + 1] = 255 - data[i + 1];
|
||||
data[i + 2] = 255 - data[i + 2];
|
||||
}
|
||||
}
|
||||
ctx.putImageData(imageData, x, y);
|
||||
}
|
||||
|
||||
function InvertCaret()
|
||||
{
|
||||
// Log("InvertCaret " + caretx + " " + carety + " " + caretcx + " " + caretcy);
|
||||
if(caretcx >= 0 || caretcy >= 0)
|
||||
InvertRect(caretx, carety, caretcx, caretcy);
|
||||
}
|
||||
|
||||
function ClearCaretTimer()
|
||||
{
|
||||
if(caretTimerID != undefined)
|
||||
clearTimeout(caretTimerID);
|
||||
}
|
||||
|
||||
function CaretTimer()
|
||||
{
|
||||
ClearCaretTimer();
|
||||
caretTimerID = setTimeout(DoCaret, 500);
|
||||
}
|
||||
|
||||
function DoCaret()
|
||||
{
|
||||
if(caretcx || caretcy) {
|
||||
InvertCaret();
|
||||
caretshown = !caretshown;
|
||||
CaretTimer();
|
||||
}
|
||||
}
|
||||
|
||||
function InvertShownCaret()
|
||||
{
|
||||
if(caretshown)
|
||||
InvertCaret();
|
||||
}
|
||||
|
||||
function HideCaret(x, y, cx, cy)
|
||||
{
|
||||
return;
|
||||
if(caretHidden)
|
||||
return;
|
||||
if(Math.max(x, caretx) < Math.min(x + cx, caretx + caretcx) &&
|
||||
Math.max(y, carety) < Math.min(y + cy, carety + caretcy)) {
|
||||
// Log("Hiding caret");
|
||||
InvertShownCaret();
|
||||
caretHidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function ProcessDraw(s)
|
||||
{
|
||||
// console.clear();
|
||||
|
||||
// Log("Painting started " + s.length);
|
||||
|
||||
// window.document.title = "Processing draw";
|
||||
|
||||
var time0 = (new Date).getTime();
|
||||
|
||||
var p = new Object;
|
||||
p.data = s;
|
||||
p.pos = 0;
|
||||
|
||||
var canvas = document.getElementById("myCanvas");
|
||||
|
||||
ctx = canvas.getContext("2d");
|
||||
|
||||
SendingEnabled = true;
|
||||
|
||||
posx = 0;
|
||||
posy = 0;
|
||||
|
||||
InvertShownCaret();
|
||||
|
||||
while(p.pos < p.data.length) {
|
||||
// Log(p.pos + ": " + p.data[p.pos]);
|
||||
if(Char(p, 0)) { // RECT
|
||||
var x = Get16(p);
|
||||
var y = Get16(p);
|
||||
var cx = Get16(p);
|
||||
var cy = Get16(p);
|
||||
var r = Get8(p);
|
||||
var g = Get8(p);
|
||||
var b = Get8(p);
|
||||
// Log("rect: " + x + ", " + y + ", " + cx + ", " + cy);
|
||||
var c = "rgb(" + r + "," + g + "," + b + ")";
|
||||
ctx.fillStyle = c;
|
||||
// Log("color: " + c);
|
||||
HideCaret(x, y, cx, cy);
|
||||
ctx.fillRect(x, y, cx, cy);
|
||||
posx = x;
|
||||
posy = y;
|
||||
}
|
||||
else
|
||||
if(Char(p, 3)) { // INVERTRECT
|
||||
var x = Get16(p);
|
||||
var y = Get16(p);
|
||||
var cx = Get16(p);
|
||||
var cy = Get16(p);
|
||||
// Log("irect: " + x + ", " + y + ", " + cx + ", " + cy);
|
||||
HideCaret(x, y, cx, cy);
|
||||
InvertRect(x, y, cx, cy);
|
||||
posx = x;
|
||||
posy = y;
|
||||
}
|
||||
else
|
||||
if(Char(p, 2)) { // SETIMAGE
|
||||
var r = Get16(p);
|
||||
var cx = Get16(p);
|
||||
var cy = Get16(p);
|
||||
var n = cx * cy * 4;
|
||||
var imgData = ctx.createImageData(cx, cy);
|
||||
for(i = 0; i < n; i++)
|
||||
imgData.data[i] = Get8(p);
|
||||
var img = document.createElement('canvas');
|
||||
img.width = cx;
|
||||
img.height = cy;
|
||||
img.getContext("2d").putImageData(imgData, 0, 0);
|
||||
window.img_cache[r] = img;
|
||||
// Log("Set image: " + r);
|
||||
if(img == undefined) // TODO: Remove after debugging this
|
||||
alert("Undefined in set: " + n);
|
||||
if(window.img_cache[r] == undefined)
|
||||
alert("Undefined 2: " + n);
|
||||
}
|
||||
else
|
||||
if(Char(p, 1)) { // IMAGE
|
||||
var n = Get16(p);
|
||||
|
||||
var px = Get16(p);
|
||||
var py = Get16(p);
|
||||
var x = Get16(p);
|
||||
var y = Get16(p);
|
||||
var cx = Get16(p);
|
||||
var cy = Get16(p);
|
||||
|
||||
// Log("Draw image: " + n);
|
||||
if(window.img_cache[n] == undefined)
|
||||
alert("Undefined image: " + n);
|
||||
HideCaret(x, y, cx, cy);
|
||||
ctx.drawImage(window.img_cache[n], x, y, cx, cy, px, py, cx, cy);
|
||||
|
||||
posx = px;
|
||||
posy = py;
|
||||
}
|
||||
else
|
||||
if(Char(p, 4)) { // STD_CURSORIMAGE
|
||||
canvas.style.cursor = [
|
||||
"default", // should not happen
|
||||
"default", // Arrow
|
||||
"wait", // Wait
|
||||
"text", // IBeam
|
||||
"not-allowed", // No
|
||||
"move", // SizeAll
|
||||
"ew-resize", // SizeHorz
|
||||
"ns-resize", // SizeVert
|
||||
"nw-resize", // SizeTopLeft
|
||||
"n-resize", // SizeTop
|
||||
"ne-resize", // SizeTopRight
|
||||
"w-resize", // SizeLeft
|
||||
"e-resize", // SizeRight
|
||||
"sw-resize", // SizeBottomLeft
|
||||
"s-resize", // SizeBottom
|
||||
"se-resize", // SizeBottomRight
|
||||
"pointer" // Hand
|
||||
][Get8(p)];
|
||||
}
|
||||
else
|
||||
if(Char(p, 5)) { // SETCURSORIMAGE
|
||||
i = Get16(p);
|
||||
window.cursor_cache[i] = GetString(p);
|
||||
}
|
||||
else
|
||||
if(Char(p, 6)) { // CURSORIMAGE
|
||||
i = Get16(p);
|
||||
canvas.style.cursor = window.cursor_cache[i];
|
||||
// Log(cursor_cache[i]);
|
||||
}
|
||||
else
|
||||
if(Char(p, 7)) { // DISABLESENDING
|
||||
SendingEnabled = true;
|
||||
}
|
||||
else
|
||||
if(Char(p, 8)) { // UPDATESERIAL
|
||||
update_serial_l = Get32(p);
|
||||
update_serial_h = Get32(p);
|
||||
ws.send("S " + update_serial_l + " " + update_serial_h + " " + ((new Date).getTime() - time0) + "\n");
|
||||
}
|
||||
else
|
||||
if(Char(p, 9)) // IMAGEPP
|
||||
SImage(p, 1, 1);
|
||||
else
|
||||
if(Char(p, 10)) // IMAGENP
|
||||
SImage(p, -1, 1);
|
||||
else
|
||||
if(Char(p, 11)) // IMAGEPN
|
||||
SImage(p, 1, -1);
|
||||
else
|
||||
if(Char(p, 12)) // IMAGENN
|
||||
SImage(p, -1, -1);
|
||||
else
|
||||
if(Char(p, 13)) // RECTPP
|
||||
SRect(p, 1, 1);
|
||||
else
|
||||
if(Char(p, 14)) // RECTNP
|
||||
SRect(p, -1, 1);
|
||||
else
|
||||
if(Char(p, 15)) // RECTPN
|
||||
SRect(p, 1, -1);
|
||||
else
|
||||
if(Char(p, 16)) // RECTNN
|
||||
SRect(p, -1, -1);
|
||||
else
|
||||
if(Char(p, 17)) { // SETCARET
|
||||
caretx = Get16(p);
|
||||
carety = Get16(p);
|
||||
caretcx = Get16(p);
|
||||
caretcy = Get16(p);
|
||||
caretshown = true;
|
||||
CaretTimer();
|
||||
// Log("SET CARET " + caretx + " " + carety + " " + caretcx + " " + caretcy);
|
||||
}
|
||||
else
|
||||
if(Char(p, 18)) { // HORZDRAGLINE,
|
||||
var x = Get16(p);
|
||||
var y = Get16(p);
|
||||
var l = Get16(p);
|
||||
var anim = Get16(p);
|
||||
DrawDragLine(x, y, l, 1, anim);
|
||||
}
|
||||
else
|
||||
if(Char(p, 19)) { // VERTDRAGLINE,
|
||||
var x = Get16(p);
|
||||
var y = Get16(p);
|
||||
var l = Get16(p);
|
||||
var anim = Get16(p);
|
||||
DrawDragLine(x, y, 1, l, anim);
|
||||
}
|
||||
}
|
||||
InvertShownCaret();
|
||||
// window.document.title = "OK";
|
||||
if(SendingEnabled && event_queue.length)
|
||||
ScheduleSend();
|
||||
// Log("Painting finished");
|
||||
}
|
||||
|
||||
function SImage(p, sx, sy)
|
||||
{
|
||||
var px = posx + sx * Get8(p);
|
||||
var py = posy + sy * Get8(p);
|
||||
var n = Get16(p);
|
||||
// Log("Draw opt image: " + px + " " + py + " " + n);
|
||||
var img = window.img_cache[n];
|
||||
if(img == undefined)
|
||||
alert("Undefined image: " + n);
|
||||
HideCaret(px, py, img.width, img.height);
|
||||
ctx.drawImage(window.img_cache[n], px, py);
|
||||
posx = px;
|
||||
posy = py;
|
||||
}
|
||||
|
||||
function SRect(p, sx, sy)
|
||||
{
|
||||
var px = posx + sx * Get8(p);
|
||||
var py = posy + sy * Get8(p);
|
||||
var cx = Get8(p);
|
||||
var cy = Get8(p);
|
||||
var r = Get8(p);
|
||||
var g = Get8(p);
|
||||
var b = Get8(p);
|
||||
// Log("rect: " + x + ", " + y + ", " + cx + ", " + cy);
|
||||
var c = "rgb(" + r + "," + g + "," + b + ")";
|
||||
ctx.fillStyle = c;
|
||||
// Log("color: " + c);
|
||||
HideCaret(x, y, cx, cy);
|
||||
ctx.fillRect(x, y, cx, cy);
|
||||
posx = px;
|
||||
posy = py;
|
||||
}
|
||||
|
||||
|
||||
window.img_cache = {};
|
||||
window.event_queue = "I\n";
|
||||
window.cursor_cache = {};
|
||||
window.update_serial_l = 0;
|
||||
window.update_serial_h = 0;
|
||||
|
||||
var canvas = document.getElementById("myCanvas");
|
||||
|
||||
function key_flags(event)
|
||||
{
|
||||
return " " + 1*event.shiftKey + 1*event.ctrlKey + 1*event.altKey + "\n";
|
||||
}
|
||||
|
||||
function mouse_event(event)
|
||||
{
|
||||
return " " + event.clientX + " " + event.clientY + " " + (new Date).getTime() + key_flags(event);
|
||||
}
|
||||
|
||||
canvas.onmousemove = function(event)
|
||||
{
|
||||
event_queue += "M" + mouse_event(event);
|
||||
ScheduleSend();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onmousedown = function(event)
|
||||
{
|
||||
event_queue += "D " + event.button + mouse_event(event);
|
||||
ScheduleSend();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onmouseout = function(event)
|
||||
{
|
||||
event_queue += "O\n";
|
||||
ScheduleSend();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onmouseup = function(event)
|
||||
{
|
||||
event_queue += "U " + event.button + mouse_event(event);
|
||||
ScheduleSend();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
canvas.onwheel = function(event)
|
||||
{
|
||||
event_queue += "W " + event.deltaY + mouse_event(event);
|
||||
}
|
||||
|
||||
document.onkeydown = function(event)
|
||||
{
|
||||
event_queue += "K " + event.keyCode + " " + event.which + key_flags(event);
|
||||
ScheduleSend();
|
||||
if(event.ctrlKey || event.altKey) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
document.onkeypress = function(event)
|
||||
{
|
||||
event_queue += "C " + event.keyCode + " " + event.which + key_flags(event);
|
||||
event.preventDefault();
|
||||
ScheduleSend();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
document.onkeyup = function(event)
|
||||
{
|
||||
event_queue += "k " + event.keyCode + " " + event.which + key_flags(event);
|
||||
event.preventDefault();
|
||||
ScheduleSend();
|
||||
if(event.ctrlKey || event.altKey) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function ResizeCanvas()
|
||||
{
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
event_queue += "R " + canvas.width + ' ' + canvas.height + "\n";
|
||||
ScheduleSend();
|
||||
}
|
||||
|
||||
window.onresize = ResizeCanvas;
|
||||
|
||||
var timerID;
|
||||
|
||||
function ConnectWebsocket()
|
||||
{
|
||||
return new WebSocket("%%host%%");
|
||||
}
|
||||
|
||||
var ws = ConnectWebsocket();
|
||||
|
||||
ws.binaryType = "arraybuffer";
|
||||
|
||||
function ScheduleSend()
|
||||
{
|
||||
if(SendingEnabled) {
|
||||
if(timerID != undefined)
|
||||
clearTimeout(timerID);
|
||||
timerID = setTimeout(SendEvents, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function SendEvents()
|
||||
{
|
||||
if(SendingEnabled) {
|
||||
if(event_queue.length) {
|
||||
// Log(event_queue);
|
||||
ws.send(event_queue);
|
||||
}
|
||||
else
|
||||
ws.send("PING");
|
||||
event_queue = "";
|
||||
if(timerID != undefined)
|
||||
clearTimeout(timerID);
|
||||
timerID = setTimeout(SendEvents, 20);
|
||||
}
|
||||
}
|
||||
|
||||
ws.onopen = function()
|
||||
{
|
||||
// Log("websocket connection opened");
|
||||
ResizeCanvas();
|
||||
};
|
||||
|
||||
ws.onmessage = function(event)
|
||||
{
|
||||
// Log("onmessage");
|
||||
if(event.data instanceof ArrayBuffer) {
|
||||
var inflate = new Zlib.Inflate(new Uint8Array(event.data));
|
||||
ProcessDraw(inflate.decompress());
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = function(ev)
|
||||
{
|
||||
ClearCaretTimer();
|
||||
alert("Connection closed.");
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
description "HTML5 backend\377";
|
||||
|
||||
uses
|
||||
Painter,
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
Turtle.h,
|
||||
Keys.h,
|
||||
After.h,
|
||||
Local.h,
|
||||
Draw.cpp,
|
||||
Image.cpp,
|
||||
FB.iml,
|
||||
Ctrl.h,
|
||||
DrawDragRect.cpp,
|
||||
Ctrl.cpp,
|
||||
Wnd.cpp,
|
||||
Stream.cpp,
|
||||
Server.cpp,
|
||||
Output.cpp,
|
||||
Event.cpp,
|
||||
Top.h,
|
||||
TopFrame.cpp,
|
||||
Top.cpp,
|
||||
Clip.cpp,
|
||||
DnD.cpp,
|
||||
ChSysInit.cpp,
|
||||
Turtle.brc,
|
||||
Turtle.html;
|
||||
|
||||
|
|
@ -1,459 +0,0 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) //LOG(x)
|
||||
#define LDUMP(x) //DDUMP(x)
|
||||
#define LDUMPC(x) //DDUMPC(x)
|
||||
#define LTIMING(x) //RTIMING(x)
|
||||
|
||||
Ptr<Ctrl> Ctrl::desktop;
|
||||
Vector<Ctrl *> Ctrl::topctrl;
|
||||
|
||||
Point Ctrl::fbCursorPos = Null;
|
||||
Image Ctrl::fbCursorImage;
|
||||
Rect Ctrl::fbCaretRect;
|
||||
int Ctrl::fbCaretTm;
|
||||
bool Ctrl::fbEndSession;
|
||||
|
||||
Vector<Rect> Ctrl::invalid;
|
||||
|
||||
void Ctrl::InvalidateDesktop()
|
||||
{
|
||||
AddInvalid(desktop->GetSize());
|
||||
}
|
||||
|
||||
void Ctrl::SetDesktop(Ctrl& q)
|
||||
{
|
||||
desktop = &q;
|
||||
desktop->SetOpen(true);
|
||||
desktop->NewTop();
|
||||
InvalidateDesktop();
|
||||
}
|
||||
|
||||
void Ctrl::SetDesktopSize(Size sz)
|
||||
{
|
||||
if(desktop)
|
||||
desktop->SetRect(sz);
|
||||
InvalidateDesktop();
|
||||
SyncTopWindows();
|
||||
}
|
||||
|
||||
int Ctrl::FindTopCtrl() const
|
||||
{
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(this == topctrl[i])
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Ctrl::IsAlphaSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ctrl::IsCompositedGui()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector<Ctrl *> Ctrl::GetTopCtrls()
|
||||
{
|
||||
Vector<Ctrl *> ctrl;
|
||||
if(desktop)
|
||||
ctrl.Add(desktop);
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(!dynamic_cast<TopWindowFrame *>(topctrl[i]))
|
||||
ctrl.Add(topctrl[i]);
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
Ctrl *Ctrl::GetOwner()
|
||||
{
|
||||
GuiLock __;
|
||||
int q = FindTopCtrl();
|
||||
if(q > 0 && topctrl[q]->top) {
|
||||
Ctrl *x = topctrl[q]->top->owner_window;
|
||||
LDUMP(Upp::Name(x));
|
||||
return dynamic_cast<TopWindowFrame *>(x) ? x->GetOwner() : x;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Ctrl *Ctrl::GetActiveCtrl()
|
||||
{
|
||||
GuiLock __;
|
||||
return focusCtrl ? focusCtrl->GetTopCtrl() : NULL;
|
||||
}
|
||||
|
||||
// Vector<Callback> Ctrl::hotkey;
|
||||
|
||||
int Ctrl::RegisterSystemHotKey(dword key, Callback cb)
|
||||
{
|
||||
/* ASSERT(key >= K_DELTA);
|
||||
int q = hotkey.GetCount();
|
||||
for(int i = 0; i < hotkey.GetCount(); i++)
|
||||
if(!hotkey[i]) {
|
||||
q = i;
|
||||
break;
|
||||
}
|
||||
hotkey.At(q) = cb;
|
||||
dword mod = 0;
|
||||
if(key & K_ALT)
|
||||
mod |= MOD_ALT;
|
||||
if(key & K_SHIFT)
|
||||
mod |= MOD_SHIFT;
|
||||
if(key & K_CTRL)
|
||||
mod |= MOD_CONTROL;
|
||||
|
||||
return RegisterHotKey(NULL, q, mod, key & 0xffff) ? q : -1;*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Ctrl::UnregisterSystemHotKey(int id)
|
||||
{
|
||||
/* if(id >= 0 && id < hotkey.GetCount()) {
|
||||
UnregisterHotKey(NULL, id);
|
||||
hotkey[id].Clear();
|
||||
}*/
|
||||
}
|
||||
|
||||
void Ctrl::SyncTopWindows()
|
||||
{
|
||||
for(int i = 0; i < topctrl.GetCount(); i++) {
|
||||
TopWindow *w = dynamic_cast<TopWindow *>(topctrl[i]);
|
||||
if(w)
|
||||
w->SyncRect();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ViewDraw::ViewDraw(Ctrl *ctrl)
|
||||
{
|
||||
if(Ctrl::invalid)
|
||||
Ctrl::DoPaint();
|
||||
Ctrl::invalid = false;
|
||||
Ctrl::RemoveCursor();
|
||||
Ctrl::RemoveCaret();
|
||||
Rect r = ctrl->GetScreenView();
|
||||
Ctrl::invalid.Add(r);
|
||||
Ctrl::AddUpdate(r);
|
||||
for(int i = max(ctrl->GetTopCtrl()->FindTopCtrl() + 1, 0); i < Ctrl::topctrl.GetCount(); i++) {
|
||||
Rect rr = Ctrl::topctrl[i]->GetScreenRect();
|
||||
ExcludeClip(rr);
|
||||
Subtract(Ctrl::invalid, rr);
|
||||
}
|
||||
Offset(r.TopLeft());
|
||||
}
|
||||
|
||||
ViewDraw::~ViewDraw()
|
||||
{
|
||||
Ctrl::DoUpdate();
|
||||
}
|
||||
*/
|
||||
|
||||
Rect Ctrl::GetClipBound(const Vector<Rect>& inv, const Rect& r)
|
||||
{
|
||||
Rect ri = Null;
|
||||
for(int j = 0; j < inv.GetCount(); j++) {
|
||||
Rect rr = inv[j] & r;
|
||||
if(!rr.IsEmpty())
|
||||
ri = IsNull(ri) ? rr : rr | ri;
|
||||
}
|
||||
return ri;
|
||||
}
|
||||
|
||||
void Ctrl::WndUpdate(const Rect& r)
|
||||
{
|
||||
GuiLock __;
|
||||
WndInvalidateRect(r);
|
||||
WndUpdate();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetWndScreenRect() const
|
||||
{
|
||||
GuiLock __;
|
||||
return GetRect();
|
||||
}
|
||||
|
||||
void Ctrl::WndShow(bool b)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
void Ctrl::WndUpdate()
|
||||
{
|
||||
GuiLock __;
|
||||
// SyncClient();
|
||||
// DoPaint();
|
||||
// Output();
|
||||
}
|
||||
|
||||
bool Ctrl::IsWndOpen() const {
|
||||
GuiLock __;
|
||||
return FindTopCtrl() >= 0 || this == desktop;
|
||||
}
|
||||
|
||||
void Ctrl::SetAlpha(byte alpha)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
Rect Ctrl::GetWorkArea() const
|
||||
{
|
||||
GuiLock __;
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
void Ctrl::GetWorkArea(Array<Rect>& rc)
|
||||
{
|
||||
GuiLock __;
|
||||
Array<Rect> r;
|
||||
r.Add(GetVirtualScreenArea());
|
||||
}
|
||||
|
||||
Rect Ctrl::GetVirtualWorkArea()
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetWorkArea(Point pt)
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetVirtualScreenArea()
|
||||
{
|
||||
GuiLock __;
|
||||
return desktop ? desktop->GetRect() : Rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
Rect Ctrl::GetPrimaryWorkArea()
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetPrimaryScreenArea()
|
||||
{
|
||||
return GetVirtualScreenArea();
|
||||
}
|
||||
|
||||
int Ctrl::GetKbdDelay()
|
||||
{
|
||||
GuiLock __;
|
||||
return 500;
|
||||
}
|
||||
|
||||
int Ctrl::GetKbdSpeed()
|
||||
{
|
||||
GuiLock __;
|
||||
return 1000 / 32;
|
||||
}
|
||||
|
||||
void Ctrl::DestroyWnd()
|
||||
{
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(topctrl[i]->top && topctrl[i]->top->owner_window == this)
|
||||
topctrl[i]->WndDestroy();
|
||||
int q = FindTopCtrl();
|
||||
if(q >= 0) {
|
||||
AddInvalid();
|
||||
topctrl.Remove(q);
|
||||
}
|
||||
if(top) {
|
||||
delete top;
|
||||
top = NULL;
|
||||
}
|
||||
isopen = false;
|
||||
TopWindow *win = dynamic_cast<TopWindow *>(this);
|
||||
if(win)
|
||||
win->DestroyFrame();
|
||||
}
|
||||
|
||||
void Ctrl::WndDestroy()
|
||||
{
|
||||
DestroyWnd();
|
||||
if(topctrl.GetCount())
|
||||
topctrl.Top()->ActivateWnd();
|
||||
}
|
||||
|
||||
void Ctrl::PutForeground()
|
||||
{
|
||||
int q = FindTopCtrl();
|
||||
if(q >= 0) {
|
||||
AddInvalid();
|
||||
topctrl.Remove(q);
|
||||
topctrl.Add(this);
|
||||
}
|
||||
Vector< Ptr<Ctrl> > fw;
|
||||
for(int i = 0; i < topctrl.GetCount(); i++)
|
||||
if(topctrl[i] && topctrl[i]->top && topctrl[i]->top->owner_window == this && topctrl[i] != this)
|
||||
fw.Add(topctrl[i]);
|
||||
for(int i = 0; i < fw.GetCount(); i++)
|
||||
if(fw[i])
|
||||
fw[i]->PutForeground();
|
||||
}
|
||||
|
||||
void Ctrl::SetWndForeground()
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsOpen());
|
||||
if(IsWndForeground())
|
||||
return;
|
||||
Ctrl *to = this;
|
||||
while(to->top && to->top->owner_window)
|
||||
to = to->top->owner_window;
|
||||
to->PutForeground();
|
||||
if(this != focusCtrl)
|
||||
ActivateWnd();
|
||||
}
|
||||
|
||||
bool Ctrl::IsWndForeground() const
|
||||
{
|
||||
GuiLock __;
|
||||
bool b = false;
|
||||
for(int i = 0; i < topctrl.GetCount(); i++) {
|
||||
const TopWindow *tw = dynamic_cast<const TopWindow *>(topctrl[i]);
|
||||
if(tw)
|
||||
b = tw == this;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
void Ctrl::WndEnable(bool)
|
||||
{
|
||||
GuiLock __;
|
||||
}
|
||||
|
||||
bool Ctrl::SetWndFocus()
|
||||
{
|
||||
GuiLock __;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::HasWndFocus() const
|
||||
{
|
||||
GuiLock __;
|
||||
return focusCtrl && focusCtrl->GetTopCtrl() == this;
|
||||
}
|
||||
|
||||
bool Ctrl::SetWndCapture()
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsMainThread());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::ReleaseWndCapture()
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(IsMainThread());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::HasWndCapture() const
|
||||
{
|
||||
GuiLock __;
|
||||
return captureCtrl && captureCtrl->GetTopCtrl() == this;
|
||||
}
|
||||
|
||||
void Ctrl::AddInvalid(const Rect& r_)
|
||||
{
|
||||
Rect r = r_ & Rect(DesktopSize);
|
||||
if(!IsNull(r))
|
||||
AddRefreshRect(invalid, r);
|
||||
}
|
||||
|
||||
void Ctrl::WndInvalidateRect(const Rect& r)
|
||||
{
|
||||
GuiLock __;
|
||||
int q = FindTopCtrl();
|
||||
if(q >= 0)
|
||||
AddInvalid(r + topctrl[q]->GetRect().TopLeft());
|
||||
else
|
||||
AddInvalid(r);
|
||||
}
|
||||
|
||||
void Ctrl::WndSetPos(const Rect& rect)
|
||||
{
|
||||
GuiLock __;
|
||||
TopWindow *w = dynamic_cast<TopWindow *>(this);
|
||||
if(w)
|
||||
w->SyncFrameRect(rect);
|
||||
AddInvalid();
|
||||
SetWndRect(rect);
|
||||
AddInvalid(rect);
|
||||
}
|
||||
|
||||
void Ctrl::WndScrollView(const Rect& r, int dx, int dy)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("ScrollView " << r << ", size " << GetSize());
|
||||
WndInvalidateRect(r);
|
||||
}
|
||||
|
||||
void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, bool topmost)
|
||||
{
|
||||
ASSERT(!IsChild() && !IsOpen() && FindTopCtrl() < 0);
|
||||
NewTop();
|
||||
if(owner) {
|
||||
Ctrl *owner_window = owner->GetTopWindow();
|
||||
if(!owner_window)
|
||||
owner_window = owner->GetTopCtrl();
|
||||
ASSERT(owner_window->IsOpen());
|
||||
if(owner_window != desktop) {
|
||||
owner_window->SetForeground();
|
||||
top->owner_window = owner_window;
|
||||
}
|
||||
}
|
||||
topctrl.Add(this);
|
||||
popup = isopen = true;
|
||||
RefreshLayoutDeep();
|
||||
if(activate) SetFocusWnd();
|
||||
AddInvalid();
|
||||
}
|
||||
|
||||
Rect Ctrl::GetDefaultWindowRect() {
|
||||
GuiLock __;
|
||||
static int ii = 0;
|
||||
Rect rect = GetVirtualScreenArea();
|
||||
Size sz = rect.GetSize();
|
||||
rect.Deflate(sz / 10);
|
||||
rect.Offset(Size(GetStdFontCy(), 2 * GetStdFontCy()) * (++ii % 8));
|
||||
return rect;
|
||||
}
|
||||
|
||||
Vector<WString> SplitCmdLine__(const char *cmd)
|
||||
{
|
||||
Vector<WString> out;
|
||||
while(*cmd)
|
||||
if((byte)*cmd <= ' ')
|
||||
cmd++;
|
||||
else if(*cmd == '\"') {
|
||||
WString quoted;
|
||||
while(*++cmd && (*cmd != '\"' || *++cmd == '\"'))
|
||||
quoted.Cat(FromSystemCharset(String(cmd, 1)).ToWString());
|
||||
out.Add(quoted);
|
||||
}
|
||||
else {
|
||||
const char *begin = cmd;
|
||||
while((byte)*cmd > ' ')
|
||||
cmd++;
|
||||
out.Add(String(begin, cmd).ToWString());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void Ctrl::InstallPanicBox()
|
||||
{
|
||||
}
|
||||
|
||||
void Ctrl::SysEndLoop()
|
||||
{
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#ifndef _Turtle_icpp_init_stub
|
||||
#define _Turtle_icpp_init_stub
|
||||
#include "Painter/init"
|
||||
#include "CtrlLib/init"
|
||||
#endif
|
||||
|
|
@ -1,343 +0,0 @@
|
|||
#include "WebWord.h"
|
||||
|
||||
#define IMAGECLASS UWordImg
|
||||
#define IMAGEFILE <UWord/UWord.iml>
|
||||
#include <Draw/iml.h>
|
||||
|
||||
FileSel& UWordFs()
|
||||
{
|
||||
static FileSel fs;
|
||||
return fs;
|
||||
}
|
||||
|
||||
FileSel& PdfFs()
|
||||
{
|
||||
static FileSel fs;
|
||||
return fs;
|
||||
}
|
||||
|
||||
void UWord::FileBar(Bar& bar)
|
||||
{
|
||||
/*
|
||||
bar.Add("New", CtrlImg::new_doc(), THISBACK(New))
|
||||
.Key(K_CTRL_N)
|
||||
.Help("Open new window");
|
||||
bar.Add("Open..", CtrlImg::open(), THISBACK(Open))
|
||||
.Key(K_CTRL_O)
|
||||
.Help("Open existing document");
|
||||
bar.Add(editor.IsModified(), "Save", CtrlImg::save(), THISBACK(Save))
|
||||
.Key(K_CTRL_S)
|
||||
.Help("Save current document");
|
||||
bar.Add("SaveAs", CtrlImg::save_as(), THISBACK(SaveAs))
|
||||
.Help("Save current document with a new name");
|
||||
bar.ToolGap();
|
||||
bar.MenuSeparator();
|
||||
bar.Add("Print..", CtrlImg::print(), THISBACK(Print))
|
||||
.Key(K_CTRL_P)
|
||||
.Help("Print document");
|
||||
bar.Add("Export to PDF..", UWordImg::pdf(), THISBACK(Pdf))
|
||||
.Help("Export document to PDF file");
|
||||
if(bar.IsMenuBar()) {
|
||||
if(lrufile().GetCount())
|
||||
lrufile()(bar, THISBACK(OpenFile));
|
||||
bar.Separator();
|
||||
bar.Add("Exit", THISBACK1(Destroy, false));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void UWord::AboutMenu(Bar& bar)
|
||||
{
|
||||
bar.Add("About..", THISBACK(About));
|
||||
}
|
||||
|
||||
String FormatSize(int64 n)
|
||||
{
|
||||
if(n < 10000)
|
||||
return Format("%d B", n);
|
||||
else
|
||||
if(n < 10000 * 1024)
|
||||
return Format("%d.%d KB", n >> 10, (n & 1023) / 103);
|
||||
else
|
||||
if(n < I64(10000000) * 1024)
|
||||
return Format("%d.%d MB", n >> 20, (n & 1023) / 103);
|
||||
else
|
||||
return Format("%d.%d GB", n >> 30, (n & 1023) / 103);
|
||||
}
|
||||
|
||||
|
||||
void UWord::ShowInfo()
|
||||
{
|
||||
String s;
|
||||
s << "Mem " << MemoryUsedKb() << " KB";
|
||||
int secs = GetSysTime() - Ctrl::stat_started;
|
||||
Time tm = Time(1, 1, 1, 0, 0, 0) + secs;
|
||||
s << ", uptime " << Format("%d:%0d:%02d:%02d", tm - Date(1, 1, 1), tm.hour, tm.minute, tm.second);
|
||||
s << ", data sent " << FormatSize(Ctrl::stat_data_send);
|
||||
if(secs)
|
||||
s << ", average bandwidth " << FormatSize(Ctrl::stat_data_send / secs) << "/s";
|
||||
s << ", actual bandwidth " << FormatSize(Ctrl::stat_data_send - sent_prev);
|
||||
s << ", putimage " << Ctrl::stat_putimage;
|
||||
s << ", putrect " << Ctrl::stat_putrect;
|
||||
s << ", setimage " << Ctrl::stat_setimage << " len " << FormatSize(Ctrl::stat_setimage_len);
|
||||
s << ", roundtrip " << Ctrl::stat_roundtrip_ms << " ms";
|
||||
s << ", client " << Ctrl::stat_client_ms << " ms";
|
||||
sent_prev = Ctrl::stat_data_send;
|
||||
statusbar.Set(s);
|
||||
}
|
||||
|
||||
void UWord::MainMenu(Bar& bar)
|
||||
{
|
||||
// bar.Add("File", THISBACK(FileBar));
|
||||
bar.Add("Window", callback(WindowsMenu));
|
||||
bar.Add("Help", THISBACK(AboutMenu));
|
||||
}
|
||||
|
||||
void UWord::New()
|
||||
{
|
||||
new UWord;
|
||||
}
|
||||
|
||||
void UWord::Load(const String& name)
|
||||
{
|
||||
lrufile().NewEntry(name);
|
||||
editor.SetQTF(LoadFile(name));
|
||||
filename = name;
|
||||
editor.ClearModify();
|
||||
Title(filename);
|
||||
}
|
||||
|
||||
void UWord::OpenFile(const String& fn)
|
||||
{
|
||||
if(filename.IsEmpty() && !editor.IsModified())
|
||||
Load(fn);
|
||||
else
|
||||
(new UWord)->Load(fn);
|
||||
}
|
||||
|
||||
void UWord::Open()
|
||||
{
|
||||
FileSel& fs = UWordFs();
|
||||
if(fs.ExecuteOpen())
|
||||
OpenFile(fs);
|
||||
else
|
||||
statusbar.Temporary("Loading aborted.");
|
||||
}
|
||||
|
||||
void UWord::DragAndDrop(Point, PasteClip& d)
|
||||
{
|
||||
if(AcceptFiles(d)) {
|
||||
Vector<String> fn = GetFiles(d);
|
||||
for(int i = 0; i < fn.GetCount(); i++)
|
||||
if(FileExists(fn[i]))
|
||||
OpenFile(fn[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void UWord::FrameDragAndDrop(Point p, PasteClip& d)
|
||||
{
|
||||
DragAndDrop(p, d);
|
||||
}
|
||||
|
||||
void UWord::Save0()
|
||||
{
|
||||
lrufile().NewEntry(filename);
|
||||
if(filename.IsEmpty())
|
||||
SaveAs();
|
||||
else
|
||||
if(SaveFile(filename, editor.GetQTF())) {
|
||||
statusbar.Temporary("File " + filename + " was saved.");
|
||||
ClearModify();
|
||||
}
|
||||
else
|
||||
Exclamation("Error saving the file [* " + DeQtf(filename) + "]!");
|
||||
}
|
||||
|
||||
void UWord::Save()
|
||||
{
|
||||
if(!editor.IsModified()) return;
|
||||
Save0();
|
||||
}
|
||||
|
||||
void UWord::SaveAs()
|
||||
{
|
||||
FileSel& fs = UWordFs();
|
||||
if(fs.ExecuteSaveAs()) {
|
||||
filename = fs;
|
||||
Title(filename);
|
||||
Save0();
|
||||
}
|
||||
}
|
||||
|
||||
void UWord::Print()
|
||||
{
|
||||
editor.Print();
|
||||
}
|
||||
|
||||
void UWord::Pdf()
|
||||
{
|
||||
FileSel& fs = PdfFs();
|
||||
if(!fs.ExecuteSaveAs("Output PDF file"))
|
||||
return;
|
||||
Size page = Size(3968, 6074);
|
||||
PdfDraw pdf;
|
||||
UPP::Print(pdf, editor.Get(), page);
|
||||
SaveFile(~fs, pdf.Finish());
|
||||
}
|
||||
|
||||
void UWord::About()
|
||||
{
|
||||
PromptOK("[A5 uWord]&Using [*^www://upp.sf.net^ Ultimate`+`+] technology.");
|
||||
}
|
||||
|
||||
void UWord::Destroy(bool shutdown)
|
||||
{
|
||||
if(editor.IsModified()) {
|
||||
switch((shutdown ? PromptYesNo : PromptYesNoCancel)("Do you want to save the changes to the document?")) {
|
||||
case 1:
|
||||
Save();
|
||||
break;
|
||||
case -1:
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
void UWord::ShutdownWindow()
|
||||
{
|
||||
Destroy(true);
|
||||
}
|
||||
|
||||
void UWord::MainBar(Bar& bar)
|
||||
{
|
||||
FileBar(bar);
|
||||
bar.Separator();
|
||||
editor.DefaultBar(bar);
|
||||
}
|
||||
|
||||
void UWord::SetBar()
|
||||
{
|
||||
toolbar.Set(THISBACK(MainBar));
|
||||
}
|
||||
|
||||
UWord::UWord()
|
||||
{
|
||||
AddFrame(menubar);
|
||||
AddFrame(TopSeparatorFrame());
|
||||
AddFrame(toolbar);
|
||||
AddFrame(statusbar);
|
||||
Add(editor.SizePos());
|
||||
menubar.Set(THISBACK(MainMenu));
|
||||
Sizeable().Zoomable();
|
||||
WhenClose = THISBACK1(Destroy, false);
|
||||
menubar.WhenHelp = toolbar.WhenHelp = statusbar;
|
||||
static int doc;
|
||||
Title(Format("Document%d", ++doc));
|
||||
Icon(CtrlImg::File());
|
||||
editor.ClearModify();
|
||||
SetBar();
|
||||
editor.WhenRefreshBar = THISBACK(SetBar);
|
||||
OpenMain();
|
||||
ActiveFocus(editor);
|
||||
|
||||
SetTimeCallback(-1000, THISBACK(ShowInfo));
|
||||
sent_prev = 0;
|
||||
}
|
||||
|
||||
void UWord::SerializeApp(Stream& s)
|
||||
{
|
||||
int version = 1;
|
||||
s / version;
|
||||
s % UWordFs()
|
||||
% PdfFs();
|
||||
if(version >= 1)
|
||||
s % lrufile();
|
||||
}
|
||||
|
||||
struct EventsWnd : TopWindow {
|
||||
Label l;
|
||||
String k;
|
||||
|
||||
|
||||
Image CursorImage(Point p, dword keyflags)
|
||||
{
|
||||
return UWordImg::pdf();
|
||||
}
|
||||
|
||||
void Do() {
|
||||
static int ii;
|
||||
String x;
|
||||
if(GetCtrl())
|
||||
x << "Ctrl ";
|
||||
if(GetAlt())
|
||||
x << "Alt ";
|
||||
if(GetShift())
|
||||
x << "Shift ";
|
||||
x << k << ' ' << GetMousePos();
|
||||
l = x;
|
||||
}
|
||||
|
||||
bool Key(dword key, int count) {
|
||||
k = GetKeyDesc(key) + ' ' + FormatIntHex(key);
|
||||
if(key < 256)
|
||||
k << '\"' << (char)key << '\"';
|
||||
Do();
|
||||
}
|
||||
|
||||
typedef EventsWnd CLASSNAME;
|
||||
|
||||
EventsWnd() {
|
||||
Add(l.SizePos());
|
||||
SetTimeCallback(-1000, THISBACK(Do));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void FinishApp()
|
||||
{
|
||||
LOG("Disconnected");
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
LOG("Session Started");
|
||||
|
||||
#ifdef _DEBUG
|
||||
MemoryLimitKb(5000000);
|
||||
Ctrl::debugmode = true;
|
||||
#endif
|
||||
|
||||
Ctrl::WhenDisconnect = callback(FinishApp);
|
||||
|
||||
#ifndef _DEBUG
|
||||
Ctrl::host = "eventcraft.eu";
|
||||
#endif
|
||||
|
||||
if(Ctrl::StartSession())
|
||||
{
|
||||
SetLanguage(LNG_ENGLISH);
|
||||
SetDefaultCharset(CHARSET_UTF8);
|
||||
|
||||
UWordFs().Type("QTF files", "*.qtf")
|
||||
.AllFilesType()
|
||||
.DefaultExt("qtf");
|
||||
PdfFs().Type("PDF files", "*.pdf")
|
||||
.AllFilesType()
|
||||
.DefaultExt("pdf");
|
||||
|
||||
LoadFromFile(callback(UWord::SerializeApp));
|
||||
#ifdef _DEBUG
|
||||
(new UWord)->editor.SetQTF(LoadFile(GetDataFile("test.qtf")));
|
||||
#else
|
||||
new UWord;
|
||||
#endif
|
||||
Ctrl::EventLoop();
|
||||
|
||||
Ctrl::EndSession();
|
||||
}
|
||||
|
||||
LOG("Session Finished");
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#ifndef _WebWord_WebWord_h_
|
||||
#define _WebWord_WebWord_h_
|
||||
|
||||
#include <RichEdit/RichEdit.h>
|
||||
#include <PdfDraw/PdfDraw.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct UWord : public TopWindow {
|
||||
public:
|
||||
virtual void DragAndDrop(Point, PasteClip& d);
|
||||
virtual void FrameDragAndDrop(Point, PasteClip& d);
|
||||
|
||||
virtual void ShutdownWindow();
|
||||
|
||||
RichEdit editor;
|
||||
MenuBar menubar;
|
||||
ToolBar toolbar;
|
||||
StatusBar statusbar;
|
||||
String filename;
|
||||
|
||||
int64 sent_prev;
|
||||
|
||||
static LRUList& lrufile() { static LRUList l; return l; }
|
||||
|
||||
void Load(const String& filename);
|
||||
void OpenFile(const String& fn);
|
||||
void New();
|
||||
void Open();
|
||||
void Save0();
|
||||
void Save();
|
||||
void SaveAs();
|
||||
void Print();
|
||||
void Pdf();
|
||||
void About();
|
||||
void Destroy(bool shutdown);
|
||||
void SetBar();
|
||||
void FileBar(Bar& bar);
|
||||
void AboutMenu(Bar& bar);
|
||||
void MainMenu(Bar& bar);
|
||||
void MainBar(Bar& bar);
|
||||
|
||||
void ShowInfo();
|
||||
|
||||
public:
|
||||
typedef UWord CLASSNAME;
|
||||
|
||||
static void SerializeApp(Stream& s);
|
||||
|
||||
UWord();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
uses
|
||||
Core,
|
||||
plugin/DroidFonts,
|
||||
RichEdit,
|
||||
Turtle,
|
||||
PdfDraw;
|
||||
|
||||
file
|
||||
test.qtf,
|
||||
WebWord.h,
|
||||
WebWord.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "SSE2 TURTLE RAINBOW";
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef _WebWord_icpp_init_stub
|
||||
#define _WebWord_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#include "plugin/DroidFonts/init"
|
||||
#include "RichEdit/init"
|
||||
#include "Turtle/init"
|
||||
#include "PdfDraw/init"
|
||||
#endif
|
||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue