// This file is part of c-evo-evo. // // This software is governed by the CeCILL license under French law and // abiding by the rules of distribution of free software. You can use, // modify and/or redistribute the software under the terms of the CeCILL // license as circulated by CEA, CNRS and INRIA at the following URL // "http://www.cecill.info". // // As a counterpart to the access to the source code and rights to copy, // modify and redistribute granted by the license, users are provided only // with a limited warranty and the software's author, the holder of the // economic rights, and the successive licensors have only limited // liability. // // In this respect, the user's attention is drawn to the risks associated // with loading, using, modifying and/or developing or reproducing the // software by the user in light of its specific status of free software, // that may mean that it is complicated to manipulate, and that also // therefore means that it is reserved for developers and experienced // professionals having in-depth computer knowledge. Users are therefore // encouraged to load and test the software's suitability as regards their // requirements in conditions enabling the security of their systems and/or // data to be ensured and, more generally, to use and operate it in the // same conditions as regards security. // // The fact that you are presently reading this means that you have had // knowledge of the CeCILL license and that you accept its terms. #pragma once #include "Dpi/DpiGraphics.h" #include #include #include #include #include namespace Cevo { class Texture; class GraphicSet; class GraphicSetItem; // Delphi/VCL TColor ints are packed as $00BBGGRR (red in the low byte, the // reverse of Qt's QRgb/QColor byte order). Convert ported color literals // (e.g. ButtonA's $0000FF placeholder color) with this helper rather than // constructing QColor from the raw hex value directly. QColor colorFromDelphi(int value); enum class FontType { Normal, Small, Tiny, Caption, Button, Count }; // Fonts, the main background texture and the system sprite sheets are // populated by the application's asset-loading step (ScreenTools.pas's // UnitInit/LoadAssets in the original, not ported here); null/default until // the application assigns them. extern std::array(FontType::Count)> UniFont; extern Texture *MainTexture; extern GraphicSet *HGrSystem; extern GraphicSet *HGrSystem2; extern GraphicSet *Templates; extern Dpi::Bitmap *Colors; // palette lookup bitmap, indexed by clkAge0/cli* below // Colors palette row/column indices (Colors->image().pixelColor(col, row)). constexpr int clkAge0 = 1; constexpr int cliTexture = 0; constexpr int cliBevelLight = 1; constexpr int cliBevelShade = 2; constexpr int cliTextLight = 3; constexpr int cliTextShade = 4; constexpr int cliLitText = 5; constexpr int cliMark = 6; constexpr int cliDimmedText = 7; constexpr int cliRoad = 8; constexpr int cliHouse = 9; constexpr int cliImp = 10; constexpr int cliImpProject = 11; constexpr int cliPage = 13; constexpr int cliCover = 14; enum class RasterOp { Copy, And, Paint, Invert }; // Mirrors ScreenTools.pas's BitBltBitmap raster-op blit (classic AND-mask + // OR-data sprite compositing) and UnshareBitmap (a no-op here: QImage is // already copy-on-write safe, so there is no shared-handle cache to break). void bitBltBitmap(Dpi::Bitmap &dest, int x, int y, int width, int height, Dpi::Bitmap &src, int xSrc, int ySrc, RasterOp rop = RasterOp::Copy); void unshareBitmap(Dpi::Bitmap &bitmap); // Draws a masked sprite (AND then OR, via an internal scratch buffer since // Qt's QPainter has no raster-op compositing against the live canvas). void sprite(Dpi::Canvas &canvas, GraphicSet &graphicSet, int xDst, int yDst, int width, int height, int xGr, int yGr); void sprite(Dpi::Canvas &canvas, int xDst, int yDst, const GraphicSetItem &item); void frame(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1); void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1); void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture); void editFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture); // Unimplemented in the original ScreenTools.pas too (body is commented out there). void corner(Dpi::Canvas &canvas, int x, int y, int kind, const Texture &texture); void fill(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset = 0, int yOffset = 0); void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset = QPoint()); void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int height, int formWidth = 0, int formHeight = 0); void biColorTextOut(Dpi::Canvas &canvas, QColor mainColor, QColor backColor, int x, int y, const QString &text); int biColorTextWidth(Dpi::Canvas &canvas, const QString &text); void risedTextOut(Dpi::Canvas &canvas, int x, int y, const QString &text); // cl == -2: mixed bevel colors; cl < 0: texture's text shade/light pair; cl >= 0: explicit color. void loweredTextOut(Dpi::Canvas &canvas, int cl, const Texture &texture, int x, int y, const QString &text); // Template-based color blending (Src is a greyscale "template" bitmap whose // channels encode per-pixel blend amplitudes). color0/color1/color2 use the // Delphi $BBGGRR byte order, like colorFromDelphi's input. void imageOpB(Dpi::Bitmap &dst, Dpi::Bitmap &src, int xDst, int yDst, int xSrc, int ySrc, int width, int height); void imageOpBCC(Dpi::Bitmap &dst, Dpi::Bitmap &src, int xDst, int yDst, int xSrc, int ySrc, int width, int height, int color1, int color2); void imageOpCBC(Dpi::Bitmap &dst, Dpi::Bitmap &src, int xDst, int yDst, int xSrc, int ySrc, int width, int height, int color0, int color2); void imageOpCCC(Dpi::Bitmap &bmp, int x, int y, int width, int height, int color0, int color1, int color2); } // namespace Cevo