void GWindow::Pour() { GRegion Client(GetClient()); GRegion Update; bool HasTools = false; GViewI *v; { GRegion Tools; for (v = Children.First(); v; v = Children.Next()) { GView *k = dynamic_cast<GView*>(v); if (k && k->_IsToolBar) { GRect OldPos = v->GetPos(); Update.Union(&OldPos); if (HasTools) { // 2nd and later toolbars if (v->Pour(Tools)) { if (!v->Visible()) { v->Visible(true); } if (OldPos != v->GetPos()) { // position has changed update... v->Invalidate(); } Tools.Subtract(&v->GetPos()); Update.Subtract(&v->GetPos()); } } else { // First toolbar if (v->Pour(Client)) { HasTools = true; if (!v->Visible()) { v->Visible(true); } if (OldPos != v->GetPos()) { v->Invalidate(); } GRect Bar(v->GetPos()); Bar.x2 = GetClient().x2; Tools = Bar; Tools.Subtract(&v->GetPos()); Client.Subtract(&Bar); Update.Subtract(&Bar); } } } } } for (v = Children.First(); v; v = Children.Next()) { GView *k = dynamic_cast<GView*>(v); if (!(k && k->_IsToolBar)) { GRect OldPos = v->GetPos(); Update.Union(&OldPos); if (v->Pour(Client)) { if (!v->Visible()) { v->Visible(true); } if (OldPos != v->GetPos()) { // position has changed update... v->Invalidate(); } Client.Subtract(&v->GetPos()); Update.Subtract(&v->GetPos()); } else { // make the view not visible // v->Visible(FALSE); } } } for (int i=0; i<Update.Length(); i++) { Invalidate(Update[i]); } }
void GWindow::Pour() { bool SafeToLock = false; if (Wnd->IsLocked()) { // I'm already locked... this could be bad if it's not me thread_id Thread = WindowHandle()->LockingThread(); if (Thread != -1) { if (Thread == find_thread(NULL)) { // it's all ok, I'm locking me SafeToLock = true; } else { // someone else is locking us // ok who is locking me? thread_info Info; if (get_thread_info(Thread, &Info) == B_OK) { printf("Evil locking thread: %i (%s)\n", Thread, Info.name); } else { printf("Couldn't get evil thread info\n"); } } } } else { SafeToLock = true; } if (!SafeToLock) { printf("%s:%i - Not safe to lock for ::Pour.\n", __FILE__, __LINE__); return; } bool Lock = Wnd->Lock(); Wnd->BeginViewTransaction(); GRect r(Handle()->Frame()); r.Offset(-r.x1, -r.y1); GRegion Client(r); GRegion Update; if (Menu) { GRect Mp = Menu->GetPos(); Mp.x2 = 10000; Client.Subtract(&Mp); } for (GViewI *w = Children.First(); w; w = Children.Next()) { GRect OldPos = w->GetPos(); Update.Union(&OldPos); if (w->Pour(Client)) { if (!w->Visible()) { w->Visible(true); } Client.Subtract(&w->GetPos()); Update.Subtract(&w->GetPos()); } else { // non-pourable } } Wnd->EndViewTransaction(); Wnd->Sync(); // Handle()->Invalidate(); if (Lock) Wnd->Unlock(); }