void ScrollBar::LeftDown(Point p, dword) { push = GetMousePart(); LLOG("ScrollBar::LeftDown(" << p << ")"); LLOG("MousePos = " << GetMousePos() << ", ScreenView = " << GetScreenView() << ", rel. pos = " << (GetMousePos() - GetScreenView().TopLeft())); LLOG("GetWorkArea = " << GetWorkArea()); LLOG("VisibleScreenView = " << GetVisibleScreenView()); LLOG("PartRect(0) = " << GetPartRect(0)); LLOG("PartRect(1) = " << GetPartRect(1)); LLOG("PartRect(2) = " << GetPartRect(2)); LLOG("ScrollBar::LeftDown: mousepart = " << (int)push << ", rect = " << GetPartRect(push) << ", overthumb = " << style->overthumb << ", slider = " << Slider()); LLOG("thumbpos = " << thumbpos << ", thumbsize = " << thumbsize); if(push == 2) delta = GetHV(p.x, p.y) - thumbpos; else { if(jump) { delta = thumbsize / 2; Drag(p); } else if(push == 0) PrevPage(); else NextPage(); } SetCapture(); Refresh(); WhenLeftClick(); }
void Ctrl::ScrollView(const Rect& _r, int dx, int dy) { GuiLock __; LLOG("ScrollView " << _r << " " << dx << " " << dy); if(IsFullRefresh() || !IsVisible()) return; Size vsz = GetSize(); dx = sgn(dx) * min(abs(dx), vsz.cx); dy = sgn(dy) * min(abs(dy), vsz.cy); Rect r = _r & vsz; LLOG("ScrollView2 " << r << " " << dx << " " << dy); Ctrl *w; for(w = this; w->parent; w = w->parent) if(w->InFrame()) { Refresh(); return; } if(!w || !w->top) return; Rect view = InFrame() ? GetView() : GetClippedView(); Rect sr = (r + view.TopLeft()) & view; sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft(); if(w->AddScroll(sr, dx, dy)) Refresh(); else { LTIMING("ScrollCtrls1"); Top *top = GetTopCtrl()->top; for(Ctrl *q = GetFirstChild(); q; q = q->GetNext()) if(q->InView()) ScrollCtrl(top, q, r, q->GetRect(), dx, dy); if(parent) for(Ctrl *q = parent->GetFirstChild(); q; q = q->GetNext()) if(q->InView() && q != this) ScrollCtrl(top, q, r, q->GetScreenRect() - GetScreenView().TopLeft(), dx, dy); } }
DockCont *DockWindow::FindDockTarget(DockCont &dc, int &dock) { Point p = GetMousePos(); Rect r = GetScreenView(); DockCont *target = NULL; int align = DOCK_NONE; dock = DOCK_NONE; if (r.Contains(p)) { dock = GetPointAlign(p, r, true, true, true); if (dock != DOCK_NONE && dockpane[dock].IsVisible()) dock = DOCK_NONE; } else { target = GetMouseDockTarget(); if (target) { r = target->GetScreenRect(); dock = GetDockAlign(*target); align = GetPointAlign(p, r, IsTabbing(), IsTB(dock), !IsTB(dock)); } else return NULL; } if (dock != DOCK_NONE && (!dc.IsDockAllowed(dock) || IsPaneAnimating(dock) || IsFrameAnimating(dock)) || (dock == DOCK_NONE && !target)) { dock = DOCK_NONE; return NULL; } // Prepare for highlight if (target) { GetHighlightCtrl().bounds = GetAlignBounds(align, r, IsTabbing(), IsTB(dock), !IsTB(dock)); if (align == DOCK_NONE) dock = DOCK_NONE; // Tabbing // The following code handles the case of an insertion between two docked controls. In this case we must set // the highlight bounds to be a union of the bounds from each control. Very ugly. if (dock != DOCK_NONE) { Ctrl *c = IsTL(align) ? target->GetPrev() : target->GetNext(); if (c) { int opal = align > 1 ? align-2 : align+2; GetHighlightCtrl().bounds.Union(GetAlignBounds(opal, c->GetScreenRect(), IsTabbing())); } target = IsTL(align) ? target : dynamic_cast<DockCont*>(target->GetNext()); } } else if (dock != DOCK_NONE) GetHighlightCtrl().bounds = GetAlignBounds(dock, r, true); return target; }
double RulerCtrl::GetRawDelta() const { if(IsNull(raw_delta)) { raw_delta = delta; if(InFrame()) { Point pt = GetScreenView().TopLeft(), par = GetParent() ? GetParent() -> GetScreenView().TopLeft() : pt; raw_delta -= (is_vert ? pt.y - par.y : pt.x - par.x); } } return raw_delta; }
Rect Ctrl::GetClippedView() { GuiLock __; Rect sv = GetScreenView(); Rect view = sv; Ctrl *q = parent; Ctrl *w = this; while(q) { view &= w->InFrame() ? q->GetScreenRect() : q->GetScreenView(); w = q; q = q->parent; } return view - GetScreenRect().TopLeft(); }
void RichEdit::OpenFindReplace() { NextUndo(); if(!findreplace.IsOpen()) { Size sz = findreplace.GetSize(); findreplace.SetRect(GetScreenView().CenterRect(sz)); int l, h; if(GetSelection(l, h)) { findreplace.amend.Hide(); findreplace.ok.SetLabel(t_("Replace")); findreplace.Title(t_("Replace in selection")); findreplace.cancel <<= findreplace.Breaker(IDCANCEL); findreplace.ok <<= findreplace.Breaker(IDOK); if(findreplace.Execute() == IDOK) { int len = findreplace.find.GetText().GetLength(); int rlen = findreplace.replace.GetText().GetLength(); RichText rtext = ReplaceText(); cursor = l; for(;;) { int pos = FindPos(); if(pos < 0 || pos + len >= h) break; Select(pos, len); Remove(pos, len); Insert(pos, ReplaceText(), false); cursor += pos + rlen; h += rlen - len; } CancelSelection(); Move(h, false); } FindReplaceAddHistory(); findreplace.amend.Show(); findreplace.ok.SetLabel(t_("Find")); findreplace.Title(t_("Find / Replace")); findreplace.cancel <<= THISBACK(CloseFindReplace); findreplace.ok <<= THISBACK(Find); } else { findreplace.Open(); findreplace.find.SetFocus(); } } }
Ctrl *Ctrl::FindBestOpaque(const Rect& clip) { GuiLock __; Ctrl *w = NULL; for(Ctrl *q = GetFirstChild(); q; q = q->GetNext()) { if(q->IsVisible() && GetScreenView().Contains(q->GetScreenRect())) { Rect sw = q->GetScreenView(); if((q->GetOpaqueRect() + sw.TopLeft()).Contains(clip)) { w = q; Ctrl *h = q->FindBestOpaque(clip); if(h) w = h; } else if(q->GetScreenView().Contains(clip)) w = q->FindBestOpaque(clip); else if(q->GetScreenRect().Intersects(clip)) w = NULL; } } return w; }
void Ctrl::DragRectDraw(const Rect& rect1, const Rect& rect2, const Rect& clip, int n, Color color, int type, int animation) { static byte solid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static byte normal[] = { 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00 }; static byte dashed[] = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }; Point p = GetScreenView().TopLeft(); Vector<Rect> pr; if(type & DRAWDRAGRECT_SCREEN) { pr.Add(Rect(framebuffer.GetSize())); type &= ~DRAWDRAGRECT_SCREEN; p = Point(0, 0); } else pr = Intersection(GetPaintRects(), clip.Offseted(p)); const byte *pattern = type == DRAWDRAGRECT_DASHED ? dashed : type == DRAWDRAGRECT_NORMAL ? normal : solid; RemoveCursor(); RemoveCaret(); DragRectDraw0(pr, rect1.Offseted(p), n, pattern, animation); DragRectDraw0(pr, rect2.Offseted(p), n, pattern, animation); }
void MultiButton::LeftDown(Point p, dword flags) { push = true; Refresh(); if(IsNull(hl)) pushrect = Null; else { if(hl == MAIN) pushrect = GetScreenRect(); else { int x, cx; int border = IsTrivial() ? style->trivialborder : style->border; GetPos(hl, x, cx); pushrect = RectC(x, border, cx, GetSize().cy - 2 * border) .Offseted(GetScreenView().TopLeft()); } Sync(); if(hl >= 0) button[hl].WhenPush(); else WhenPush(); } }
void RichEdit::Find() { CancelSelection(); FindReplaceAddHistory(); if(notfoundfw) Move(0, false); found = notfoundfw = false; int pos = FindPos(); if(pos >= 0) { anchor = pos; cursor = pos + findreplace.find.GetText().GetLength(); Finish(); found = true; Size sz = findreplace.GetSize(); Rect sw = GetScreenView(); Rect r = sw.CenterRect(sz); Rect cr = GetCaretRect(); if(cr.top < sz.cy + 2 * cr.Height()) { r.bottom = sw.bottom - 8; r.top = r.bottom - sz.cy; } else { r.top = sw.top + 24; r.bottom = r.top + sz.cy; } findreplace.SetRect(r); if(!findreplace.IsOpen()) { findreplace.Open(); } SetFocus(); } else { CancelSelection(); CloseFindReplace(); notfoundfw = true; } }
void DisplayPopup::MouseMove(Point p, dword flags) { p += GetScreenView().TopLeft(); if(!slim.Contains(p)) MouseLeave(); }
Point DisplayPopup::Op(Point p) { return p + GetScreenView().TopLeft() - ctrl->GetScreenView().TopLeft(); }
Rect LineEdit::GetLineScreenRect(int line) const { int fcy = GetFontSize().cy; Rect r = RectC(0, (line - sb.Get().y) * fcy, GetSize().cx, fcy); r.Offset(GetScreenView().TopLeft()); return r; }
void MenuBug::RightDown(Point pt, dword keyflags) { MenuBar menu; menu.Add("Pokus", Callback()); menu.Execute(pt + GetScreenView().TopLeft()); }