ZDCRgn ZSubPane::HandleFramePostChange(ZPoint inWindowLocation) { ZRect newBounds(ZRect::sZero); if (this->GetVisible()) newBounds = ZRect(this->GetSize())+inWindowLocation; return this->DoFramePostChange(fPriorBounds, newBounds); }
void ZSubPane::HandleFramePreChange(ZPoint inWindowLocation) { this->DoFramePreChange(); fPriorBounds = ZRect::sZero; if (this->GetVisible()) fPriorBounds = ZRect(this->GetSize())+inWindowLocation; }
void ZWindow::WindowFrameChange() { if (fLastKnownWindowSize != fOSWindow->GetSize()) { for (vector<ZWindowPane*>::iterator i = fVector_WindowPanes.begin(); i != fVector_WindowPanes.end(); ++i) (*i)->FramePreChange(); // Figure out the difference between our old and new regions ZDCRgn invalidRgn = ZRect(fLastKnownWindowSize); fLastKnownWindowSize = fOSWindow->GetSize(); invalidRgn ^= ZRect(fLastKnownWindowSize); invalidRgn += this->GetWindowOrigin(); this->InvalidateWindowRegion(invalidRgn); for (vector<ZWindowPane*>::iterator i = fVector_WindowPanes.begin(); i != fVector_WindowPanes.end(); ++i) (*i)->FramePostChange(); } }
void ZUtil_Win::sPixmapsFromHICON(HICON iHICON, ZDCPixmap* oColorPixmap, ZDCPixmap* oMonoPixmap, ZDCPixmap* oMaskPixmap) { ZAssertStop(2, iHICON); ICONINFO theICONINFO; ::GetIconInfo(iHICON, &theICONINFO); HDC dummyHDC = ::GetDC(nullptr); ZDCPixmap monoPixmap(new ZDCPixmapRep_DIB(dummyHDC, theICONINFO.hbmMask)); if (theICONINFO.hbmColor) { if (oColorPixmap) *oColorPixmap = ZDCPixmap(new ZDCPixmapRep_DIB(dummyHDC, theICONINFO.hbmColor)); if (oMaskPixmap) *oMaskPixmap = monoPixmap; } else { // theICONINFO.hbmColor is nullptr, so theICONINFO.hbmMask (and thus monoPixmap) contains // the mono pixmap and the mask stacked on top of each other. ZPoint monoSize = monoPixmap.Size(); if (oMonoPixmap) *oMonoPixmap = ZDCPixmap(monoPixmap, ZRect(0, 0, monoSize.h, monoSize.v / 2)); if (oMaskPixmap) *oMaskPixmap = ZDCPixmap(monoPixmap, ZRect(0, monoSize.v / 2, monoSize.h, monoSize.v)); } if (oMaskPixmap) oMaskPixmap->Munge(spMungeProc_Invert, nullptr); if (theICONINFO.hbmMask) ::DeleteObject(theICONINFO.hbmMask); if (theICONINFO.hbmMask) ::DeleteObject(theICONINFO.hbmColor); ::ReleaseDC(nullptr, dummyHDC); }
void ZRect::cutBorders(const Rect& screen, std::list<ZRect>& rectList) { for(std::list<ZRect>::iterator i = rectList.begin(); i != rectList.end(); ) { Rect common_rect = i->getRect().commonRect(screen); if(common_rect != i->getRect()) { if(common_rect.getSize() != Size()) { rectList.push_front(ZRect(i->getId(), common_rect, i->getZ())); } i = rectList.erase(i); } else { i++; } } }
// remove overlapping rects void ZRect::eraseOverlappingRects(std::list<ZRect>& rect_list) { // compare all rects to each other //std::list<ZRect> new_rect_list; for(std::list<ZRect>::iterator i = rect_list.begin(); i != rect_list.end(); ) { std::list<ZRect>::iterator j = i; j++; while(j != rect_list.end()) { if(i->rect.isTouched(j->getRect())) { // remove the upper part from the lower part if(i->isInFrontOf(*j)) { std::list<Rect> without_rect_list = j->getRect().withoutRect(i->getRect()); for(std::list<Rect>::iterator s = without_rect_list.begin(); s != without_rect_list.end(); s++) { rect_list.push_back(ZRect(j->getId(), *s, j->getZ())); } j = rect_list.erase(j); } else if(j->isInFrontOf(*i)) { std::list<Rect> without_rect_list = i->rect.withoutRect(j->getRect()); for(std::list<Rect>::iterator s = without_rect_list.begin(); s != without_rect_list.end(); s++) { rect_list.push_back(ZRect(i->getId(), *s, i->getZ())); } i = rect_list.erase(i); break; } else { j++; } } else { j++; } } i++; } //rect_list.insert(rect_list, new_rect_list.begin(), new_rect_list.end()); }
ZRect ZFont::get_bounding_box() const { FT_BBox ft_box = _impl->face->bbox; // convert to pixels by dividing each value by 64 ft_box.xMax /= 64; ft_box.xMin /= 64; ft_box.yMax /= 64; ft_box.yMin /= 64; return ZRect( ZPoint2D{0.0, 0.0}, ZSize2D{float(ft_box.xMax - ft_box.xMin), float(ft_box.yMax - ft_box.yMin)} ); }
ZOSWindow* BMDisplayWindow::sCreateOSWindow(ZApp* inApp) { ZOSWindow::CreationAttributes attr; attr.fFrame = ZRect(0, 0, 200, 80); attr.fLook = ZOSWindow::lookDocument; attr.fLayer = ZOSWindow::layerDocument; attr.fResizable = false; attr.fHasSizeBox = false; attr.fHasCloseBox = true; attr.fHasZoomBox = false; attr.fHasMenuBar = false; attr.fHasTitleIcon = false; return inApp->CreateOSWindow( attr ); }
ZRect ZRect::Intersection(const ZRect &rect) const { float tempX=0,tempY=0,tempW=0,tempH=0; //can only grab the intersection if they intersect if(Intersects(rect)) { tempX = rX > rect.X() ? rX : rect.X(); tempY = rY > rect.Y() ? rY : rect.Y(); tempW = rX+rWidth < rect.Right() ? rX+rWidth : rect.Right(); tempH = rY+rHeight < rect.Bottom() ? rY+rHeight : rect.Bottom(); tempW -= tempX; //adjust width and height tempH -= tempY; } return ZRect(tempX,tempY,tempW,tempH); }
void ZRect::eraseOverlappingRects(std::list<ZRect>& old_rect_list, std::list<ZRect>& new_rect_list) { for(std::list<ZRect>::iterator i = new_rect_list.begin(); i != new_rect_list.end(); ) { for(std::list<ZRect>::iterator j = old_rect_list.begin(); j != old_rect_list.end(); ) { // remove part of oldrects that are covered by a new rect with larger z if((i->getId() == j->getId() || i->isInFrontOf(*j)) && i->rect.isTouched(j->getRect())) { std::list<Rect> without_rect_list = j->rect.withoutRect(i->getRect()); std::list<ZRect> new_without_rect_list; for(std::list<Rect>::iterator s = without_rect_list.begin(); s != without_rect_list.end(); s++) { new_without_rect_list.push_back(ZRect(i->getId(), *s, i->getZ())); } old_rect_list.insert(j, new_without_rect_list.begin(), new_without_rect_list.end()); j = old_rect_list.erase(j); } else { j++; } } i++; } }
PainterTest_App::PainterTest_App() { fAsset = sGetAssetRootFromExecutable("PainterTest_Assets_en").GetChild("en|PainterTest"); fAsset_NPainterStd = sGetAssetRootFromExecutable("NPainterStd_Assets_en").GetChild("en|NPainterStd"); // Grab the paint state's palette data // Monochrome patterns vector<ZDCPattern> monoPatterns; NPaintEngine::sExtractMonoPatterns(ZUtil_UI::sGetPixmap(fAsset_NPainterStd.GetChild("MonoPatterns")), monoPatterns); // The color table vector<ZRGBColor> colorTable; #if 1 NPaintEngine::sExtractColors(ZUtil_UI::sGetPixmap(fAsset_NPainterStd.GetChild("ColorTable256")), 16, 16, colorTable); #else // This builds a 6 x 6 x 6 color cube, which is not very intuitive when squashed onto a 2D grid ZRGBColor theRGBColor; theRGBColor.alpha = 0xFFFFU; for (size_t blue = 0; blue < 6; ++blue) { for (size_t green = 0; green < 6; ++green) { for (size_t red = 0; red < 6; ++red) { theRGBColor.red = red * 0x3333U; theRGBColor.green = green * 0x3333U; theRGBColor.blue = blue * 0x3333U; colorTable.push_back(theRGBColor); } } } #endif // Pixmap patterns vector<ZDCPixmap> pixmapPatterns; for (ZAssetIter theIter = fAsset.GetChild("Textures"); theIter; theIter.Advance()) pixmapPatterns.push_back(ZUtil_UI::sGetPixmap(theIter.Current())); // Pen Shapes vector<ZDCRgn> penShapes; penShapes.push_back(ZDCRgn::sEllipse(0, 0, 1, 1)); penShapes.push_back(ZDCRgn::sEllipse(-1, -1, 1, 1)); penShapes.push_back(ZDCRgn::sEllipse(-2, -2, 2, 2)); penShapes.push_back(ZDCRgn::sEllipse(-4, -4, 4, 4)); penShapes.push_back(ZDCRgn::sEllipse(-8, -8, 8, 8)); penShapes.push_back(ZDCRgn::sEllipse(-12, -12, 12, 12)); penShapes.push_back(ZRect(0, 0, 1, 1)); penShapes.push_back(ZRect(-1, -1, 1, 1)); penShapes.push_back(ZRect(-2, -2, 2, 2)); penShapes.push_back(ZRect(-4, -4, 4, 4)); penShapes.push_back(ZRect(-8, -8, 8, 8)); penShapes.push_back(ZRect(-12, -12, 12, 12)); // Also add in a complex shape, just for kicks // ZDCRgn theRgn = ZDCRgn::sEllipse(-12, -12, 0, 0) | ZDCRgn::sEllipse(0, 0, 12, 12); // penShapes.push_back(theRgn); // Instantiate our paint state fPaintState = new NPainterStd_UI::UIPaintState(fAsset_NPainterStd.GetChild("Cursors"), monoPatterns, colorTable, pixmapPatterns, penShapes); sPainterTest_App = this; }
ZDCRgn ZSubPane::CalcBoundsRgn() { // By making this method virtual, you can have panes with holes in them (useful for // measurement in motion and opendoc) return ZRect(this->GetSize()); }