GAlert::GAlert( GViewI *parent, const char *Title, const char *Text, const char *Btn1, const char *Btn2, const char *Btn3) { GText *t = 0; Children.Insert(t = new GText(-1, 8, 8, -1, -1, (char*)Text)); if (t) { // Setup dialog SetParent(parent); Name((char*)Title); List<GButton> Btns; List<const char> Names; if (Btn1) Names.Insert(Btn1); if (Btn2) Names.Insert(Btn2); if (Btn3) Names.Insert(Btn3); int i = 1, Tx = 0; for (const char *n=Names.First(); n; n=Names.Next()) { GDisplayString ds(SysFont, (char*)n); int x = ds.X(); GButton *v; Btns.Insert(v = new GButton(CMD_BASE + i++, 0, 0, (int) ((30.0f + x) * BTN_SCALE), (int) (20.0f * BTN_SCALE), (char*)n)); Tx += v->X() + ((i>1) ? 10 : 0); } int x = LgiApp->GetMetric(LGI_MET_DECOR_X) + 16; int y = LgiApp->GetMetric(LGI_MET_DECOR_Y) + 20 + 8 + 16; GRect r; if (t) { x += max(Tx, t->X()); y += t->Y(); r.ZOff(x, y); } SetPos(r); MoveToCenter(); // Setup controls int Cx = X() / 2; int Bx = Cx - (Tx / 2); for (GButton *b=Btns.First(); b; b=Btns.Next()) { GRect r; r.ZOff(b->X()-1, b->Y()-1); r.Offset(Bx, t->GetPos().y2 + 8); b->SetPos(r); Children.Insert(b); Bx += b->X() + 10; } } }
GRect &GView::GetClient(bool ClientSpace) { int Edge = (Sunken() || Raised()) ? _BorderSize : 0; static GRect c; if (ClientSpace) { c.ZOff(Pos.X() - 1 - (Edge<<1), Pos.Y() - 1 - (Edge<<1)); } else { c.ZOff(Pos.X()-1, Pos.Y()-1); c.Size(Edge, Edge); } return c; }
GRect GRegion::Bound() { static GRect r; if (a && Size > 0) { r = a[0]; for (int i=1; i<Size; i++) { r.Union(a+i); } } else { r.ZOff(-1, -1); } return r; }
CallbackParams() { Menu.ZOff(-1, -1); Depth = 0; }
bool GView::Invalidate(GRect *r, bool Repaint, bool Frame) { if (IsAttached()) { if (InThread() && !d->InPaint) { GRect Client; if (Frame) Client.ZOff(Pos.X()-1, Pos.Y()-1); else Client = GView::GetClient(false); static bool Repainting = false; if (!Repainting) { Repainting = true; GdkWindow *hnd = gtk_widget_get_window(_View); if (hnd) { if (r) { GRect cr = *r; cr.Offset(Client.x1, Client.y1); Gtk::GdkRectangle r = cr; gdk_window_invalidate_rect(hnd, &r, FALSE); } else { Gtk::GdkRectangle r = {0, 0, Pos.X(), Pos.Y()}; gdk_window_invalidate_rect(hnd, &r, FALSE); } } Repainting = false; } } else { X11_INVALIDATE_PARAMS *p = new X11_INVALIDATE_PARAMS; if (p) { if (r) { p->Rgn = *r; } else { p->Rgn.ZOff(-1, -1); } p->Repaint = Repaint; p->View = this; PostEvent(M_X11_INVALIDATE, (GMessage::Param)p, 0); } } return true; } else { GRect Up; GViewI *p = this; if (r) { Up = *r; } else { Up.Set(0, 0, Pos.X()-1, Pos.Y()-1); } while (p && !p->IsAttached()) { GRect pos = p->GetPos(); Up.Offset(pos.x1, pos.y1); p = p->GetParent(); } if (p && p->IsAttached()) { return p->Invalidate(&Up, Repaint); } } return false; }