void TextBox::onPreferredSize(PreferredSizeEvent& ev) { int w = 0; int h = 0; // TODO is it necessary? //w = widget->border_width.l + widget->border_width.r; //h = widget->border_width.t + widget->border_width.b; drawTextBox(NULL, this, &w, &h, gfx::ColorNone, gfx::ColorNone); if (this->getAlign() & JI_WORDWRAP) { View* view = View::getView(this); int width, min = w; if (view) { width = view->getViewportBounds().w; } else { width = getBounds().w; } w = MAX(min, width); drawTextBox(NULL, this, &w, &h, gfx::ColorNone, gfx::ColorNone); w = min; } ev.setPreferredSize(gfx::Size(w, h)); }
reg_t GfxText32::createFontBitmap(const CelInfo32 &celInfo, const Common::Rect &rect, const Common::String &text, const int16 foreColor, const int16 backColor, const GuiResourceId fontId, const int16 skipColor, const int16 borderColor, const bool dimmed, const bool gc) { _borderColor = borderColor; _text = text; _textRect = rect; _foreColor = foreColor; _dimmed = dimmed; setFont(fontId); int16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth; int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight; mulinc(_textRect, Ratio(_xResolution, scriptWidth), Ratio(_yResolution, scriptHeight)); CelObjView view(celInfo.resourceId, celInfo.loopNo, celInfo.celNo); _skipColor = view._skipColor; _width = view._width * _xResolution / view._xResolution; _height = view._height * _yResolution / view._yResolution; Common::Rect bitmapRect(_width, _height); if (_textRect.intersects(bitmapRect)) { _textRect.clip(bitmapRect); } else { _textRect = Common::Rect(); } SciBitmap &bitmap = *_segMan->allocateBitmap(&_bitmap, _width, _height, _skipColor, 0, 0, _xResolution, _yResolution, 0, false, gc); // NOTE: The engine filled the bitmap pixels with 11 here, which is silly // because then it just erased the bitmap using the skip color. So we don't // fill the bitmap redundantly here. _backColor = _skipColor; erase(bitmapRect, false); _backColor = backColor; view.draw(bitmap.getBuffer(), bitmapRect, Common::Point(0, 0), false, Ratio(_xResolution, view._xResolution), Ratio(_yResolution, view._yResolution)); if (_backColor != skipColor && _foreColor != skipColor) { erase(_textRect, false); } if (text.size() > 0) { if (_foreColor == skipColor) { error("TODO: Implement transparent text"); } else { if (borderColor != -1) { drawFrame(bitmapRect, 1, _borderColor, false); } drawTextBox(); } } return _bitmap; }
reg_t GfxText32::createFontBitmap(int16 width, int16 height, const Common::Rect &rect, const Common::String &text, const uint8 foreColor, const uint8 backColor, const uint8 skipColor, const GuiResourceId fontId, const TextAlign alignment, const int16 borderColor, const bool dimmed, const bool doScaling, reg_t *outBitmapObject) { _field_22 = 0; _borderColor = borderColor; _text = text; _textRect = rect; _width = width; _height = height; _foreColor = foreColor; _backColor = backColor; _skipColor = skipColor; _alignment = alignment; _dimmed = dimmed; setFont(fontId); if (doScaling) { int16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth; int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight; Ratio scaleX(_scaledWidth, scriptWidth); Ratio scaleY(_scaledHeight, scriptHeight); _width = (_width * scaleX).toInt(); _height = (_height * scaleY).toInt(); mulinc(_textRect, scaleX, scaleY); } // _textRect represents where text is drawn inside the // bitmap; clipRect is the entire bitmap Common::Rect bitmapRect(_width, _height); if (_textRect.intersects(bitmapRect)) { _textRect.clip(bitmapRect); } else { _textRect = Common::Rect(); } _bitmap = _segMan->allocateHunkEntry("FontBitmap()", _width * _height + BITMAP_HEADER_SIZE); byte *bitmap = _segMan->getHunkPointer(_bitmap); buildBitmapHeader(bitmap, _width, _height, _skipColor, 0, 0, _scaledWidth, _scaledHeight, 0, false); erase(bitmapRect, false); if (_borderColor > -1) { drawFrame(bitmapRect, 1, _borderColor, false); } drawTextBox(); *outBitmapObject = _bitmap; return _bitmap; }
void GLHelper::drawTextSettings( const GUIVisualizationTextSettings& settings, const std::string& text, const Position& pos, const double scale, const double angle, const double layer) { drawTextBox(text, pos, layer, settings.scaledSize(scale), settings.color, settings.bgColor, RGBColor::INVISIBLE, angle, 0, 0.2); }
reg_t GfxText32::createFontBitmap(int16 width, int16 height, const Common::Rect &rect, const Common::String &text, const uint8 foreColor, const uint8 backColor, const uint8 skipColor, const GuiResourceId fontId, const TextAlign alignment, const int16 borderColor, const bool dimmed, const bool doScaling, const bool gc) { _borderColor = borderColor; _text = text; _textRect = rect; _width = width; _height = height; _foreColor = foreColor; _backColor = backColor; _skipColor = skipColor; _alignment = alignment; _dimmed = dimmed; setFont(fontId); if (doScaling) { int16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth; int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight; Ratio scaleX(_xResolution, scriptWidth); Ratio scaleY(_yResolution, scriptHeight); _width = (_width * scaleX).toInt(); _height = (_height * scaleY).toInt(); mulinc(_textRect, scaleX, scaleY); } // _textRect represents where text is drawn inside the // bitmap; clipRect is the entire bitmap Common::Rect bitmapRect(_width, _height); if (_textRect.intersects(bitmapRect)) { _textRect.clip(bitmapRect); } else { _textRect = Common::Rect(); } _segMan->allocateBitmap(&_bitmap, _width, _height, _skipColor, 0, 0, _xResolution, _yResolution, 0, false, gc); erase(bitmapRect, false); if (_borderColor > -1) { drawFrame(bitmapRect, 1, _borderColor, false); } drawTextBox(); return _bitmap; }
void KivioShapePainter::drawShape( KivioShape *pShape, float x, float y, float w, float h ) { KivioShapeData *pShapeData; m_x = x; m_y = y; m_w = w; m_h = h; m_pShape = pShape; pShapeData = pShape->shapeData(); switch( pShapeData->shapeType() ) { case KivioShapeData::kstArc: drawArc(); break; case KivioShapeData::kstPie: drawPie(); break; case KivioShapeData::kstLineArray: drawLineArray(); break; case KivioShapeData::kstPolyline: drawPolyline(); break; case KivioShapeData::kstPolygon: drawPolygon(); break; case KivioShapeData::kstBezier: drawBezier(); break; case KivioShapeData::kstRectangle: drawRectangle(); break; case KivioShapeData::kstRoundRectangle: drawRoundRectangle(); break; case KivioShapeData::kstEllipse: drawEllipse(); break; case KivioShapeData::kstOpenPath: drawOpenPath(); break; case KivioShapeData::kstClosedPath: drawClosedPath(); break; case KivioShapeData::kstTextBox: drawTextBox(); break; case KivioShapeData::kstNone: default: break; } }
void GfxText32::drawTextBox(const Common::String &text) { _text = text; drawTextBox(); }
reg_t GfxText32::createFontBitmap(const CelInfo32 &celInfo, const Common::Rect &rect, const Common::String &text, const int16 foreColor, const int16 backColor, const GuiResourceId fontId, const int16 skipColor, const int16 borderColor, const bool dimmed, reg_t *outBitmapObject) { _field_22 = 0; _borderColor = borderColor; _text = text; _textRect = rect; _foreColor = foreColor; _dimmed = dimmed; setFont(fontId); int16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth; int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight; int borderSize = 1; mulinc(_textRect, Ratio(_scaledWidth, scriptWidth), Ratio(_scaledHeight, scriptHeight)); CelObjView view(celInfo.resourceId, celInfo.loopNo, celInfo.celNo); _skipColor = view._transparentColor; _width = view._width * _scaledWidth / view._scaledWidth; _height = view._height * _scaledHeight / view._scaledHeight; Common::Rect bitmapRect(_width, _height); if (_textRect.intersects(bitmapRect)) { _textRect.clip(bitmapRect); } else { _textRect = Common::Rect(); } _bitmap = _segMan->allocateHunkEntry("FontBitmap()", _width * _height + CelObjMem::getBitmapHeaderSize()); byte *bitmap = _segMan->getHunkPointer(_bitmap); CelObjMem::buildBitmapHeader(bitmap, _width, _height, _skipColor, 0, 0, _scaledWidth, _scaledHeight, 0, false); Buffer buffer(_width, _height, bitmap + READ_SCI11ENDIAN_UINT32(bitmap + 28)); // NOTE: The engine filled the bitmap pixels with 11 here, which is silly // because then it just erased the bitmap using the skip color. So we don't // fill the bitmap redundantly here. _backColor = _skipColor; erase(bitmapRect, false); _backColor = backColor; view.draw(buffer, bitmapRect, Common::Point(0, 0), false, Ratio(_scaledWidth, view._scaledWidth), Ratio(_scaledHeight, view._scaledHeight)); if (_backColor != skipColor && _foreColor != skipColor) { erase(_textRect, false); } if (text.size() > 0) { if (_foreColor == skipColor) { error("TODO: Implement transparent text"); } else { if (borderColor != -1) { drawFrame(bitmapRect, borderSize, _borderColor, false); } drawTextBox(); } } *outBitmapObject = _bitmap; return _bitmap; }