VirtualGui: gui_sizeof

This commit is contained in:
Mirek Fidler 2022-05-19 15:00:23 +02:00
parent a86d032cc6
commit b6efea2bb8
6 changed files with 26 additions and 104 deletions

View file

@ -96,29 +96,20 @@ 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;
}
@ -126,8 +117,6 @@ String GetTextClip(const String& text, const String& fmt)
{
if(fmt == "text")
return text;
if(fmt == "wtext")
return Unicode__(text.ToWString());
return Null;
}

View file

@ -28,10 +28,6 @@ bool Ctrl::GuiPlatformSetFullRefreshSpecial()
return false;
}
void Ctrl::PaintCaret(SystemDraw& w)
{
}
String GuiPlatformGetKeyDesc(dword key)
{
return Null;
@ -71,7 +67,8 @@ String Ctrl::Name() const {
#else
String s = String(typeid(*this).name()) + " : " + Format("0x%x", (int) this);
#endif
if(IsChild())
Ctrl *parent = GetParent();
if(parent)
s << "(parent " << String(typeid(*parent).name()) << ")";
return s;
}

View file

@ -25,7 +25,7 @@ private:
void DestroyWnd();
void NewTop() { top = new Top; top->owner_window = NULL; }
void NewTop() { SetTop(new Top); GetTop()->owner_window = NULL; }
void PutForeground();
static void MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta);

View file

@ -96,44 +96,17 @@ bool Ctrl::DoKeyFB(dword key, int cnt)
return b;
}
void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
GuiLock __;
caretx = x;
carety = y;
caretcx = cx;
caretcy = cy;
fbCaretTm = msecs();
SyncCaret();
}
void Ctrl::SyncCaret()
{
CursorSync();
}
void Ctrl::CursorSync()
{
LLOG("@ CursorSync");
Point p = GetMousePos() - fbCursorImage.GetHotSpot();
Rect cr = Null;
if(focusCtrl && (((msecs() - fbCaretTm) / 500) & 1) == 0)
cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy)
+ focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView();
if(fbCursorPos != p) {
fbCursorPos = p;
if(!(VirtualGuiPtr->GetOptions() & GUI_SETMOUSECURSOR))
Invalidate();
}
if(cr != fbCaretRect) {
fbCaretRect = cr;
if(VirtualGuiPtr->GetOptions() & GUI_SETCARET)
VirtualGuiPtr->SetCaret(cr);
else
Invalidate();
}
}
bool Ctrl::ProcessEvent(bool *quit)
@ -159,6 +132,7 @@ bool Ctrl::ProcessEvents(bool *quit)
LLOG("TimerProc invoked at " << msecs());
TimerProc(msecs());
LLOG("TimerProc elapsed: " << tm);
AnimateCaret();
SweepMkImageCache();
DoPaint();
return ret;

View file

@ -35,6 +35,7 @@ bool Ctrl::invalid;
Point Ctrl::fbCursorPos = Null;
Image Ctrl::fbCursorImage;
Rect Ctrl::fbCaretRect;
int Ctrl::fbCaretTm;
bool Ctrl::fbEndSession;
@ -73,9 +74,9 @@ Ctrl *Ctrl::GetOwner()
{
GuiLock __;
int q = FindTopCtrl();
if(q > 0 && topctrl[q]->top) {
Ctrl *x = topctrl[q]->top->owner_window;
LDUMP(Upp::Name(x));
Top *top = topctrl[q]->GetTop();
if(q > 0 && top) {
Ctrl *x = top->owner_window;
return dynamic_cast<TopWindowFrame *>(x) ? x->GetOwner() : x;
}
return NULL;
@ -87,36 +88,13 @@ Ctrl *Ctrl::GetActiveCtrl()
return focusCtrl ? focusCtrl->GetTopCtrl() : NULL;
}
// Vector<Callback> Ctrl::hotkey;
int Ctrl::RegisterSystemHotKey(dword key, Function<void ()> 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();
}*/
}
bool Ctrl::IsWaitingEvent()
@ -135,30 +113,12 @@ void Ctrl::SyncTopWindows()
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;
@ -306,18 +266,18 @@ int Ctrl::GetKbdSpeed()
void Ctrl::DestroyWnd()
{
for(int i = 0; i < topctrl.GetCount(); i++)
if(topctrl[i]->top && topctrl[i]->top->owner_window == this)
for(int i = 0; i < topctrl.GetCount(); i++) {
Top *top = topctrl[i]->GetTop();
if(top && top->owner_window == this)
topctrl[i]->WndDestroy();
}
int q = FindTopCtrl();
if(q >= 0) {
Invalidate();
topctrl.Remove(q);
}
if(top) {
delete top;
top = NULL;
}
if(top)
DeleteTop();
isopen = false;
TopWindow *win = dynamic_cast<TopWindow *>(this);
if(win)
@ -341,8 +301,11 @@ void Ctrl::PutForeground()
}
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]);
if(topctrl[i]) {
Top *top = topctrl[i]->GetTop();
if(top && 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();
@ -355,8 +318,8 @@ void Ctrl::SetWndForeground()
if(IsWndForeground())
return;
Ctrl *to = this;
while(to->top && to->top->owner_window)
to = to->top->owner_window;
while(to->GetTop() && to->GetTop()->owner_window)
to = to->GetTop()->owner_window;
to->PutForeground();
if(this != focusCtrl)
ActivateWnd();
@ -445,7 +408,8 @@ void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, boo
ASSERT(owner_window->IsOpen());
if(owner_window != desktop) {
owner_window->SetForeground();
top->owner_window = owner_window;
if(GetTop())
GetTop()->owner_window = owner_window;
}
}
topctrl.Add(this);
@ -496,10 +460,8 @@ void Ctrl::SysEndLoop()
void Ctrl::DeleteDesktopTop()
{
if(desktop && desktop->top) {
delete desktop->top;
desktop->top = NULL;
}
if(desktop && desktop->GetTop())
desktop->DeleteTop();
}
void Ctrl::SetDesktop(Ctrl& q)

View file

@ -25,7 +25,7 @@ some font system to measure fonts (e.g. DrawGL and plugin/FT`_fontsys).&]
[s5;:Upp`:`:VirtualGui`:`:GetOptions`(`): [@(0.0.255) virtual] [_^Upp`:`:dword^ dword]_[* G
etOptions]()&]
[s2;%% Returns a set of flags describing some aspects of VirtualGui
behaviour. Available option flags are:-|&]
behaviour. Available option flags are:&]
[s2;%% &]
[s7;i1120;a17;:Ctrl`:`:CENTER:%% [%-*C@3 GUI`_SETMOUSECURSOR]-|Use the
SetMouseCursor() method instead of painting the cursor.&]