ultimatepp/rainbow/VirtualGui/VirtualGui.h
cxl 5f61c702e9 .rainbow
git-svn-id: svn://ultimatepp.org/upp/trunk@15878 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2021-03-28 13:35:50 +00:00

148 lines
4.3 KiB
C++

#define VIRTUALGUI
#ifdef PLATFORM_POSIX
#include <CtrlCore/stdids.h>
#endif
namespace Upp {
#define IMAGECLASS FBImg
#define IMAGEFILE <VirtualGui/FB.iml>
#include <Draw/iml_header.h>
class SystemDraw : public DrawProxy {
public:
bool CanSetSurface() { return false; }
static void Flush() {}
};
enum KM {
KM_NONE = 0x00,
KM_LSHIFT= 0x01,
KM_RSHIFT= 0x02,
KM_LCTRL = 0x04,
KM_RCTRL = 0x08,
KM_LALT = 0x10,
KM_RALT = 0x20,
KM_CAPS = 0x40,
KM_NUM = 0x80,
KM_CTRL = KM_LCTRL | KM_RCTRL,
KM_SHIFT = KM_LSHIFT | KM_RSHIFT,
KM_ALT = KM_LALT | KM_RALT,
};
struct VirtualGui {
virtual Size GetSize() = 0;
virtual dword GetMouseButtons() = 0;
virtual dword GetModKeys() = 0;
virtual bool IsMouseIn() = 0;
virtual bool ProcessEvent(bool *quit) = 0;
virtual void WaitEvent(int ms) = 0;
virtual void WakeUpGuiThread() = 0;
virtual void SetMouseCursor(const Image& image) = 0;
virtual void Quit() = 0;
virtual bool IsWaitingEvent() = 0;
virtual SystemDraw& BeginDraw() = 0;
virtual void CommitDraw() = 0;
};
extern VirtualGui *VirtualGuiPtr;
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; }
Point GetOffset() const { return Point(0, 0); }
BackDraw();
~BackDraw();
};
class ImageDraw : public SImageDraw { // using software renderer
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 <VirtualGui/Ctrl.h>
#define GUIPLATFORM_PASTECLIP_DECLS \
bool dnd; \
friend struct DnDLoop; \
#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE <VirtualGui/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() {}
};
struct NilGUI : VirtualGui {
virtual dword GetOptions();
virtual Size GetSize();
virtual dword GetMouseButtons();
virtual dword GetModKeys();
virtual bool IsMouseIn();
virtual bool ProcessEvent(bool *quit);
virtual void WaitEvent(int ms);
virtual bool IsWaitingEvent();
virtual void WakeUpGuiThread();
virtual void SetMouseCursor(const Image& image);
virtual SystemDraw& BeginDraw();
virtual void CommitDraw();
virtual void Quit();
NilDraw nildraw;
SystemDraw sysdraw;
};
}
#define GUIPLATFORM_INCLUDE_AFTER <VirtualGui/After.h>