.developing rainbow

git-svn-id: svn://ultimatepp.org/upp/trunk@3522 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-06-13 08:50:59 +00:00
parent 45acf92b2b
commit 1e424e1f78
7 changed files with 300 additions and 296 deletions

View file

@ -1213,6 +1213,8 @@ public:
};
String GuiPlatformGetKeyDesc(dword key);
bool GuiPlatformHasSizeGrip();
void GuiPlatformGripResize(TopWindow *q);
Font FontZ(int face, int height = 0);

View file

@ -1,130 +1,145 @@
#include "CtrlCore.h"
#ifdef GUI_WIN
#define LLOG(x) // DLOG(x)
NAMESPACE_UPP
void Ctrl::GuiPlatformConstruct()
{
activex = false;
isdhctrl = false;
}
void Ctrl::GuiPlatformDestruct()
{
}
void Ctrl::GuiPlatformRemove()
{
}
void Ctrl::GuiPlatformGetTopRect(Rect& r) const
{
if(activex)
r = GetWndScreenRect();
}
bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect& r)
{
if(isdhctrl) {
InvalidateRect(((DHCtrl *)this)->GetHWND(), r, false);
return true;
}
return false;
}
bool Ctrl::GuiPlatformSetFullRefreshSpecial()
{
return isdhctrl;
}
void Ctrl::PaintCaret(SystemDraw& w)
{
}
String GuiPlatformGetKeyDesc(dword key)
{
static struct {
dword key;
const char *name;
} nkey[] = {
{ 0x100c0, "[`]" }, { 0x100bd, "[-]" }, { 0x100bb, "[=]" }, { 0x100dc, "[\\]" },
{ 0x100db, "[[]" }, { 0x100dd, "[]]" },
{ 0x100ba, "[;]" }, { 0x100de, "[']" },
{ 0x100bc, "[,]" }, { 0x100be, "[.]" }, { 0x100bf, "[/]" },
{ 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&)
{
}
void GuiPlatformAdjustDragImage(ImageBuffer&)
{
}
void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
GuiLock __;
caretx = x;
carety = y;
caretcx = cx;
caretcy = cy;
SyncCaret();
}
void Ctrl::SyncCaret() {
GuiLock __;
Rect cr;
cr.Clear();
if(focusCtrl && focusCtrl->IsVisible()) {
bool inframe = focusCtrl->InFrame();
cr = focusCtrl->GetScreenView();
cr = RectC(focusCtrl->caretx + cr.left, focusCtrl->carety + cr.top,
focusCtrl->caretcx, focusCtrl->caretcy) & cr;
for(Ctrl *q = focusCtrl->GetParent(); q; q = q->GetParent()) {
cr &= inframe ? q->GetScreenRect() : q->GetScreenView();
inframe = q->InFrame();
}
}
if(focusCtrl != caretCtrl || cr != caretRect) {
LLOG("Do SyncCaret focusCtrl: " << UPP::Name(focusCtrl)
<< ", caretCtrl: " << UPP::Name(caretCtrl)
<< ", cr: " << cr);
WndDestroyCaret();
if(focusCtrl && !cr.IsEmpty())
focusCtrl->GetTopCtrl()->WndCreateCaret(cr);
caretCtrl = focusCtrl;
caretRect = cr;
}
}
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("(hwnd 0x%x)", (int)(intptr_t) GetHWND());
return s;
}
void Ctrl::WndCreateCaret(const Rect& cr)
{
ICall(THISBACK1(WndCreateCaret0, cr));
}
END_UPP_NAMESPACE
#endif
#include "CtrlCore.h"
#ifdef GUI_WIN
#define LLOG(x) // DLOG(x)
NAMESPACE_UPP
void Ctrl::GuiPlatformConstruct()
{
activex = false;
isdhctrl = false;
}
void Ctrl::GuiPlatformDestruct()
{
}
void Ctrl::GuiPlatformRemove()
{
}
void Ctrl::GuiPlatformGetTopRect(Rect& r) const
{
if(activex)
r = GetWndScreenRect();
}
bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect& r)
{
if(isdhctrl) {
InvalidateRect(((DHCtrl *)this)->GetHWND(), r, false);
return true;
}
return false;
}
bool Ctrl::GuiPlatformSetFullRefreshSpecial()
{
return isdhctrl;
}
void Ctrl::PaintCaret(SystemDraw& w)
{
}
String GuiPlatformGetKeyDesc(dword key)
{
static struct {
dword key;
const char *name;
} nkey[] = {
{ 0x100c0, "[`]" }, { 0x100bd, "[-]" }, { 0x100bb, "[=]" }, { 0x100dc, "[\\]" },
{ 0x100db, "[[]" }, { 0x100dd, "[]]" },
{ 0x100ba, "[;]" }, { 0x100de, "[']" },
{ 0x100bc, "[,]" }, { 0x100be, "[.]" }, { 0x100bf, "[/]" },
{ 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&)
{
}
void GuiPlatformAdjustDragImage(ImageBuffer&)
{
}
bool GuiPlatformHasSizeGrip()
{
return true;
}
void GuiPlatformGripResize(TopWindow *q)
{
HWND hwnd = q->GetHWND();
Point p = GetMousePos() - q->GetRect().TopLeft();
if(hwnd) {
::SendMessage(hwnd, WM_SYSCOMMAND, 0xf008, MAKELONG(p.x, p.y));
::SendMessage(hwnd, WM_LBUTTONUP, 0, MAKELONG(p.x, p.y));
}
}
void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
GuiLock __;
caretx = x;
carety = y;
caretcx = cx;
caretcy = cy;
SyncCaret();
}
void Ctrl::SyncCaret() {
GuiLock __;
Rect cr;
cr.Clear();
if(focusCtrl && focusCtrl->IsVisible()) {
bool inframe = focusCtrl->InFrame();
cr = focusCtrl->GetScreenView();
cr = RectC(focusCtrl->caretx + cr.left, focusCtrl->carety + cr.top,
focusCtrl->caretcx, focusCtrl->caretcy) & cr;
for(Ctrl *q = focusCtrl->GetParent(); q; q = q->GetParent()) {
cr &= inframe ? q->GetScreenRect() : q->GetScreenView();
inframe = q->InFrame();
}
}
if(focusCtrl != caretCtrl || cr != caretRect) {
LLOG("Do SyncCaret focusCtrl: " << UPP::Name(focusCtrl)
<< ", caretCtrl: " << UPP::Name(caretCtrl)
<< ", cr: " << cr);
WndDestroyCaret();
if(focusCtrl && !cr.IsEmpty())
focusCtrl->GetTopCtrl()->WndCreateCaret(cr);
caretCtrl = focusCtrl;
caretRect = cr;
}
}
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("(hwnd 0x%x)", (int)(intptr_t) GetHWND());
return s;
}
void Ctrl::WndCreateCaret(const Rect& cr)
{
ICall(THISBACK1(WndCreateCaret0, cr));
}
END_UPP_NAMESPACE
#endif

View file

@ -1,116 +1,143 @@
#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;
}
}
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);
}
}
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

@ -575,15 +575,11 @@ ScrollBar& ScrollBar::SetStyle(const Style& s)
Image SizeGrip::CursorImage(Point p, dword)
{
#ifdef PLATFORM_X11
if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0) {
#endif
if(GuiPlatformHasSizeGrip()) {
TopWindow *q = dynamic_cast<TopWindow *>(GetTopCtrl());
if(q && !q->IsMaximized() && q->IsSizeable())
return Image::SizeBottomRight();
#ifdef PLATFORM_X11
}
#endif
return Image::Arrow();
}
@ -591,21 +587,16 @@ CH_IMAGE(SizeGripImg, CtrlsImg::SizeGrip());
void SizeGrip::Paint(Draw& w)
{
Size sz = GetSize();
if(!IsTransparent())
w.DrawRect(sz, SColorFace);
#ifdef PLATFORM_X11
if(_NET_Supported().Find(XAtom("_NET_WM_MOVERESIZE")) >= 0)
{
#endif
Size sz = GetSize();
if(!IsTransparent())
w.DrawRect(sz, SColorFace);
if(GuiPlatformHasSizeGrip()) {
TopWindow *q = dynamic_cast<TopWindow *>(GetTopCtrl());
if(q && !q->IsMaximized() && q->IsSizeable()) {
Size isz = CtrlsImg::SizeGrip().GetSize();
w.DrawImage(sz.cx - isz.cx, sz.cy - isz.cy, CtrlsImg::SizeGrip());
}
#ifdef PLATFORM_X11
}
#endif
}
SizeGrip::SizeGrip()
@ -621,35 +612,8 @@ SizeGrip::~SizeGrip() {}
void SizeGrip::LeftDown(Point p, dword flags)
{
TopWindow *q = dynamic_cast<TopWindow *>(GetTopCtrl());
if(!q || q->IsMaximized() || !q->IsSizeable()) return;
#ifdef PLATFORM_WIN32
HWND hwnd = q->GetHWND();
p = GetMousePos() - q->GetRect().TopLeft();
if(hwnd) {
::SendMessage(hwnd, WM_SYSCOMMAND, 0xf008, MAKELONG(p.x, p.y));
::SendMessage(hwnd, WM_LBUTTONUP, 0, MAKELONG(p.x, p.y));
}
#endif
#ifdef PLATFORM_X11
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);
}
#endif
if(q && !q->IsMaximized() && q->IsSizeable())
GuiPlatformGripResize(q);
}
void ScrollBars::Scroll() {

View file

@ -650,11 +650,7 @@ void TextCtrl::StdBar(Bar& menu) {
t_("Copy"), CtrlImg::copy(), THISBACK(Copy))
.Key(K_CTRL_INSERT)
.Key(K_CTRL_C);
menu.Add(IsEditable()
#ifdef PLATFORM_WIN32
&& ::IsClipboardFormatAvailable(CF_TEXT)
#endif
,
menu.Add(IsEditable() && IsClipboardAvailableText(),
t_("Paste"), CtrlImg::paste(), THISBACK(DoPaste))
.Key(K_SHIFT_INSERT)
.Key(K_CTRL_V);

View file

@ -2,7 +2,7 @@
NAMESPACE_UPP
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE
#define LLOG(x)

View file

@ -1,6 +1,6 @@
#include "CtrlLib.h"
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE
#include <commdlg.h>
@ -12,7 +12,7 @@
NAMESPACE_UPP
#ifdef PLATFORM_WIN32
#ifdef GUI_WIN
#ifndef PLATFORM_WINCE