.developing rainbow

git-svn-id: svn://ultimatepp.org/upp/trunk@3525 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-06-13 12:42:24 +00:00
parent becf4df6d6
commit af893ea2ce
16 changed files with 755 additions and 724 deletions

View file

@ -3,14 +3,22 @@
#include <RichText/RichText.h>
#include <guiplatform.h>
#ifndef GUIPLATFORM_INCLUDE
#ifdef PLATFORM_WIN32
#include "Win32Gui.h"
#define GUIPLATFORM_INCLUDE "Win32Gui.h"
#endif
#ifdef PLATFORM_X11
#include "X11Gui.h"
#define GUIPLATFORM_INCLUDE "X11Gui.h"
#endif
#endif
#include GUIPLATFORM_INCLUDE
NAMESPACE_UPP
#ifdef _MULTITHREADED
@ -1215,6 +1223,8 @@ public:
String GuiPlatformGetKeyDesc(dword key);
bool GuiPlatformHasSizeGrip();
void GuiPlatformGripResize(TopWindow *q);
Color GuiPlatformGetScreenPixel(int x, int y);
void GuiPlatformAfterMenuPopUp();
Font FontZ(int face, int height = 0);

View file

@ -85,6 +85,18 @@ void GuiPlatformGripResize(TopWindow *q)
}
}
Color GuiPlatformGetScreenPixel(int x, int y)
{
HDC sdc = GetWindowDC(0);
Color c = Color::FromCR(GetPixel(sdc, x, y));
ReleaseDC(0, sdc);
return c;
}
void GuiPlatformAfterMenuPopUp()
{
}
void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
GuiLock __;

View file

@ -1,143 +1,155 @@
#include "CtrlCore.h"
#ifdef GUI_X11
NAMESPACE_UPP
void Ctrl::GuiPlatformConstruct()
{
}
void Ctrl::GuiPlatformDestruct()
{
}
void Ctrl::GuiPlatformRemove()
{
if(popupgrab) {
EndPopupGrab();
popupgrab = false;
}
}
void Ctrl::GuiPlatformGetTopRect(Rect& r) const
{
}
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()) << ")";
else
s << Format("(window 0x%x)", (int)(intptr_t) GetWindow());
return s;
}
bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect&)
{
return false;
}
bool Ctrl::GuiPlatformSetFullRefreshSpecial()
{
return false;
}
String GuiPlatformGetKeyDesc(dword key)
{
static struct {
dword key;
const char *name;
} nkey[] = {
{ 0x10060, "[`]" }, { 0x1002d, "[-]" }, { 0x1003d, "[=]" }, { 0x1005c, "[\\]" },
{ 0x1005b, "[[]" }, { 0x1005d, "[]]" },
{ 0x1003b, "[;]" }, { 0x10027, "[']" },
{ 0x1002c, "[,]" }, { 0x1002e, "[.]" }, { 0x1005f, "[/]" },
{ 0, NULL }
};
for(int i = 0; nkey[i].key; i++)
if(nkey[i].key == key)
return nkey[i].name;
return Null;
}
void Ctrl::GuiPlatformSelection(PasteClip& d)
{
d.fmt.Clear();
d.type = 2;
}
void GuiPlatformAdjustDragImage(ImageBuffer& b)
{
if(Ctrl::IsCompositedGui()) {
Image h = Rescale(b, 64, 64);
b = h;
}
}
bool GuiPlatformHasSizeGrip()
{
return _NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0;
}
void GuiPlatformGripResize(TopWindow *q)
{
if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0) {
XUngrabPointer(Xdisplay, CurrentTime); // 2008-02-25 cxl/mdelfe... compiz fix... who has grabbed it anyway?...
XClientMessageEvent m;
m.type = ClientMessage;
m.serial = 0;
m.send_event = XTrue;
m.window = q->GetWindow();
m.message_type = XAtom("_NET_WM_MOVERESIZE");
m.format = 32;
Point p = GetMousePos();
m.data.l[0] = p.x;
m.data.l[1] = p.y;
m.data.l[2] = 4;
m.data.l[3] = 0;
m.data.l[4] = 0;
XSendEvent(Xdisplay, Xroot, 0, SubstructureNotifyMask|SubstructureRedirectMask,
(XEvent*)&m);
}
}
void Ctrl::PaintCaret(SystemDraw& w)
{
GuiLock __;
if(this == caretCtrl && WndCaretVisible)
w.DrawRect(caretx, carety, caretcx, caretcy, InvertColor);
}
void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
GuiLock __;
if(this == caretCtrl)
RefreshCaret();
caretx = x;
carety = y;
caretcx = cx;
caretcy = cy;
WndCaretTime = GetTickCount();
if(this == caretCtrl)
RefreshCaret();
}
void Ctrl::SyncCaret() {
GuiLock __;
if(focusCtrl != caretCtrl) {
RefreshCaret();
caretCtrl = focusCtrl;
RefreshCaret();
}
}
END_UPP_NAMESPACE
#include "CtrlCore.h"
#ifdef GUI_X11
NAMESPACE_UPP
void Ctrl::GuiPlatformConstruct()
{
}
void Ctrl::GuiPlatformDestruct()
{
}
void Ctrl::GuiPlatformRemove()
{
if(popupgrab) {
EndPopupGrab();
popupgrab = false;
}
}
void Ctrl::GuiPlatformGetTopRect(Rect& r) const
{
}
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()) << ")";
else
s << Format("(window 0x%x)", (int)(intptr_t) GetWindow());
return s;
}
bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect&)
{
return false;
}
bool Ctrl::GuiPlatformSetFullRefreshSpecial()
{
return false;
}
String GuiPlatformGetKeyDesc(dword key)
{
static struct {
dword key;
const char *name;
} nkey[] = {
{ 0x10060, "[`]" }, { 0x1002d, "[-]" }, { 0x1003d, "[=]" }, { 0x1005c, "[\\]" },
{ 0x1005b, "[[]" }, { 0x1005d, "[]]" },
{ 0x1003b, "[;]" }, { 0x10027, "[']" },
{ 0x1002c, "[,]" }, { 0x1002e, "[.]" }, { 0x1005f, "[/]" },
{ 0, NULL }
};
for(int i = 0; nkey[i].key; i++)
if(nkey[i].key == key)
return nkey[i].name;
return Null;
}
void Ctrl::GuiPlatformSelection(PasteClip& d)
{
d.fmt.Clear();
d.type = 2;
}
void GuiPlatformAdjustDragImage(ImageBuffer& b)
{
if(Ctrl::IsCompositedGui()) {
Image h = Rescale(b, 64, 64);
b = h;
}
}
bool GuiPlatformHasSizeGrip()
{
return _NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0;
}
void GuiPlatformGripResize(TopWindow *q)
{
if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0) {
XUngrabPointer(Xdisplay, CurrentTime); // 2008-02-25 cxl/mdelfe... compiz fix... who has grabbed it anyway?...
XClientMessageEvent m;
m.type = ClientMessage;
m.serial = 0;
m.send_event = XTrue;
m.window = q->GetWindow();
m.message_type = XAtom("_NET_WM_MOVERESIZE");
m.format = 32;
p = GetMousePos();
m.data.l[0] = p.x;
m.data.l[1] = p.y;
m.data.l[2] = 4;
m.data.l[3] = 0;
m.data.l[4] = 0;
XSendEvent(Xdisplay, Xroot, 0, SubstructureNotifyMask|SubstructureRedirectMask,
(XEvent*)&m);
}
}
Color GuiPlatformGetScreenPixel(int x, int y)
{
// TODO
return Black;
}
void GuiPlatformAfterMenuPopUp()
{
XSync(Xdisplay, false);
ProcessEvents();
}
void Ctrl::PaintCaret(SystemDraw& w)
{
GuiLock __;
if(this == caretCtrl && WndCaretVisible)
w.DrawRect(caretx, carety, caretcx, caretcy, InvertColor);
}
void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
GuiLock __;
if(this == caretCtrl)
RefreshCaret();
caretx = x;
carety = y;
caretcx = cx;
caretcy = cy;
WndCaretTime = GetTickCount();
if(this == caretCtrl)
RefreshCaret();
}
void Ctrl::SyncCaret() {
GuiLock __;
if(focusCtrl != caretCtrl) {
RefreshCaret();
caretCtrl = focusCtrl;
RefreshCaret();
}
}
END_UPP_NAMESPACE
#endif

View file

@ -1,6 +1,5 @@
#include "CtrlLib.h"
NAMESPACE_UPP
#define LLOG(x) // RLOG(x)
@ -77,7 +76,7 @@ void ChClassicSkin()
LabelBoxTextColor_Write(SColorText());
}
#ifdef PLATFORM_X11
#ifdef GUI_X11
void ChSysInit()
{

View file

@ -1,7 +1,7 @@
#include "CtrlLib.h"
#include "ChGtk.h"
#ifdef PLATFORM_X11
#ifdef GUI_X11
#ifndef flagNOGTK
NAMESPACE_UPP

View file

@ -1,4 +1,4 @@
#ifdef PLATFORM_X11
#ifdef GUI_X11
#define Time XTime
#define Font XFont

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@ NAMESPACE_UPP
void ChSysInit();
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifdef PLATFORM_WINCE

View file

@ -7,8 +7,14 @@ NAMESPACE_UPP
void CtrlSetDefaultSkin(void (*fn1)(), void (*fn2)());
#if defined(GUI_WIN) || defined(GUI_X11)
INITBLOCK {
CtrlSetDefaultSkin(ChStdSkin, ChHostSkin);
};
#else
INITBLOCK {
CtrlSetDefaultSkin(ChStdSkin, ChStdSkin);
};
#endif
END_UPP_NAMESPACE

View file

@ -37,17 +37,17 @@ public:
~DelayCallback() { KillTimeCallback(this); }
};
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
struct Win32PrintDlg_;
#endif
#ifndef PLATFORM_WINCE
class PrinterJob {
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
One<Win32PrintDlg_> pdlg;
#endif
#ifdef PLATFORM_X11
#ifdef GUI_X11
Size pgsz;
#endif
One<Draw> draw;
@ -79,7 +79,7 @@ public:
#endif
#ifdef PLATFORM_X11
#ifdef GUI_X11
class TrayIcon : Ctrl {
virtual bool HookProc(XEvent *event);
@ -138,7 +138,7 @@ public:
#endif
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE
class TrayIcon : private Ctrl {
@ -276,7 +276,7 @@ public:
#endif
#endif
#ifdef PLATFORM_X11
#ifdef GUI_X11
typedef FileSel FileSelector;
#endif

View file

@ -55,15 +55,7 @@ void FetchColorCtrl::MouseMove(Point pt, dword keyflags)
else
{
pt += GetScreenView().TopLeft();
#ifdef PLATFORM_WIN32
HDC sdc = GetWindowDC(0);
user_color = Color::FromCR(GetPixel(sdc, pt.x, pt.y));
ReleaseDC(0, sdc);
#endif
#ifdef PLATFORM_X11
// todo: is it possible to screenshot a single screen pixel?
user_color = Black;
#endif
user_color = GuiPlatformGetScreenPixel(pt.x, pt.y);
Action();
}
}

View file

@ -2,7 +2,7 @@
NAMESPACE_UPP
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
void AvoidPaintingCheck__();
struct FileIconMaker : ImageMaker {
@ -72,28 +72,12 @@ Image GetFileIcon(const char *path, bool dir, bool force, bool large, bool quick
return MakeImage(m);
}
#define GETFILEICON_DEFINED
#endif
#ifdef PLATFORM_X11
#if defined(PLATFORM_X11) && !defined(flagNOGTK)
#ifdef flagNOGTK
Image PosixGetDriveImage(String dir, bool)
{
if(dir.GetCount() == 0 || dir == "/")
return CtrlImg::Computer();
if(dir.Find("cdrom") == 0 || dir.Find("cdrecorder") == 0)
return CtrlImg::CdRom();
if(dir.Find("floppy") == 0 || dir.Find("zip") == 0)
return CtrlImg::Diskette();
return CtrlImg::Hd();
}
Image GetFileIcon(const String& folder, const String& filename, bool isdir, bool isexe, bool)
{
return Null;
}
#else
Image GtkThemeIcon(const char *name, bool large);
Image GnomeImage(const char *s, bool large = false)
@ -237,7 +221,26 @@ Image GetFileIcon(const String& folder, const String& filename, bool isdir, bool
return IsNull(img) ? isexe ? (large ? lexe : exe) : (large ? lfile : file) : img;
}
#define GETFILEICON_DEFINED
#endif
#ifndef GETFILEICON_DEFINED
Image PosixGetDriveImage(String dir, bool)
{
if(dir.GetCount() == 0 || dir == "/")
return CtrlImg::Computer();
if(dir.Find("cdrom") == 0 || dir.Find("cdrecorder") == 0)
return CtrlImg::CdRom();
if(dir.Find("floppy") == 0 || dir.Find("zip") == 0)
return CtrlImg::Diskette();
return CtrlImg::Hd();
}
Image GetFileIcon(const String& folder, const String& filename, bool isdir, bool isexe, bool)
{
return Null;
}
#endif
Image NativePathIcon0(const char *path, bool folder, bool large)

View file

@ -544,10 +544,7 @@ void MenuBar::PopUp(Ctrl *owner, Point p, Size rsz)
#endif
doeffect = true;
Ctrl::PopUp(owner, true, true, GUI_DropShadows(), !owner);
#ifdef PLATFORM_X11
XSync(Xdisplay, false);
ProcessEvents();
#endif
GuiPlatformAfterMenuPopUp();
if(eff)
Animate(*this, p.x, p.y, sz.cx, sz.cy);
}

View file

@ -1,6 +1,6 @@
#include "CtrlLib.h"
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE
#include <commdlg.h>
@ -15,7 +15,7 @@
NAMESPACE_UPP
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE
@ -140,7 +140,7 @@ PrinterJob& PrinterJob::CurrentPage(int i)
#endif
#ifdef PLATFORM_POSIX
#ifdef GUI_X11
String System(const char *cmd, const String& in)
{

View file

@ -1,6 +1,6 @@
#include "CtrlLib.h"
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE
#include <commdlg.h>
@ -13,7 +13,7 @@
NAMESPACE_UPP
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE
#define LLOG(x)

View file

@ -2,7 +2,7 @@
#define LLOG(x) // LOG(x)
#ifdef PLATFORM_X11
#ifdef GUI_X11
#if !defined(flagNOGTK)
#include <glib.h>