void Componentality::Graphics::operator-=(ISurface& dst, ISurface& src) { for (size_t i = 0; i < ____min(dst.getWidth(), src.getWidth()); i++) for (size_t j = 0; j < ____min(dst.getHeight(), src.getHeight()); j++) { ColorRGB dst_color = dst.peek(i, j); ColorRGB src_color = src.peek(i, j); dst_color.red -= src_color.red; dst_color.green -= src_color.green; dst_color.blue -= src_color.blue; dst.plot(i, j, dst_color); } }
Margins EditBox::draw(ISurface& master) { if (isHidden()) return Margins(); CST::Common::scoped_lock lock(mLock); Margins margins = getMargins(); if (!mFrameColor.isUndefined()) { Drawer drawer(master); drawer.rectangle(Point(0, 0), Point(master.getWidth() - 1, master.getHeight() - 1), mFrameColor); margins += Margins(1, 1, 1, 1); } if (!mBackgroundColor.isUndefined()) { Drawer drawer(master); drawer.filled_rectangle(Point(1, 1), Point(master.getWidth() - 2, master.getHeight() - 2), mBackgroundColor); } ViewPort basic_surface(master, margins.getTopLeft(master), margins.getRightBottom(master)); if (mCursor) { if (mCursorColor.isUndefined()) { Color color = getColor(); Componentality::Graphics::Color cursor_color(255 - color.operator Componentality::Graphics::ColorRGB().red, 255 - color.operator Componentality::Graphics::ColorRGB().green, 255 - color.operator Componentality::Graphics::ColorRGB().blue); mCursor->setColor(cursor_color); } else mCursor->setColor(mCursorColor); std::pair<Point, std::pair<size_t, size_t> > cursor_defs = positionCursor(basic_surface); mCursor->setLocation(cursor_defs.first + margins.getTopLeft(master)); mCursor->setSize(cursor_defs.second.first, cursor_defs.second.second); mCursor->reset(); } Font* font = System::getSystemProperties().getFontSet().find(this->getFont()); MovingPort surface(basic_surface, -(int) mScrolling, 0); if (font) { std::list<int> text = getText(); font->setForeground(mColor); font->print(surface, Point(1, 0), text); } IElement::draw(surface); return margins; }
Margins Frame::draw(ISurface& surface) { Point topleft(mWidth / 2, mWidth / 2), bottomright(surface.getWidth() - mWidth / 2 - 1, surface.getHeight() - mWidth / 2 - 1); AdvancedSurface asurface(surface); SquareBrush brush(mWidth); asurface.setBrush(&brush); Drawer drawer(asurface); drawer.rectangle(topleft, bottomright, mColor); Margins result; result.mBottom = result.mLeft = result.mRight = result.mTop = mWidth; ViewPort port = getDrawArea(surface, result); IElement::draw(port); return result; }