ScummVM API documentation
design.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * MIT License:
21 *
22 * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
23 *
24 * Permission is hereby granted, free of charge, to any person
25 * obtaining a copy of this software and associated documentation
26 * files (the "Software"), to deal in the Software without
27 * restriction, including without limitation the rights to use,
28 * copy, modify, merge, publish, distribute, sublicense, and/or sell
29 * copies of the Software, and to permit persons to whom the
30 * Software is furnished to do so, subject to the following
31 * conditions:
32 *
33 * The above copyright notice and this permission notice shall be
34 * included in all copies or substantial portions of the Software.
35 *
36 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
38 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
40 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
41 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
42 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43 * OTHER DEALINGS IN THE SOFTWARE.
44 *
45 */
46
47#ifndef WAGE_DESIGN_H
48#define WAGE_DESIGN_H
49
50#include "common/memstream.h"
51#include "common/rect.h"
52
53#include "graphics/nine_patch.h"
54#include "graphics/macgui/macwindowmanager.h"
55
56namespace Wage {
57
58using namespace Graphics::MacGUIConstants;
59
60// struct to hold design operation data
61struct DrawOp {
62 uint32 offset;
63 Common::String opcode;
64 int fillType;
65 int borderThickness;
66 int borderFillType;
67};
68
69class Design {
70public:
72 ~Design();
73
74 Common::Array<DrawOp> _drawOps;
75
76 void setBounds(Common::Rect *bounds) {
77 _bounds = bounds;
78 }
79
80 Common::Rect *getBounds() {
81 return _bounds;
82 }
83
84 void paint(Graphics::ManagedSurface *canvas, Graphics::MacPatterns &patterns, int x, int y, int steps = -1);
85 bool isInBounds(int x, int y);
86 static void drawRect(Graphics::ManagedSurface *surface, const Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
87 static void drawRect(Graphics::ManagedSurface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
88 static void drawFilledRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int color, Graphics::MacPatterns &patterns, byte fillType);
89 static void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color, Graphics::MacPatterns &patterns, byte fillType);
90 static void drawHLine(Graphics::ManagedSurface *surface, int x1, int x2, int y, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
91 static void drawVLine(Graphics::ManagedSurface *surface, int x, int y1, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
92
93 bool isBoundsCalculation() { return _boundsCalculationMode; }
94 void adjustBounds(int16 x, int16 y);
95
96private:
97 byte *_data;
98 int _len;
99 int _renderedSteps;
100 Common::String _lastOpString;
101 Common::Rect *_bounds;
102 Graphics::ManagedSurface *_surface;
103 bool _boundsCalculationMode;
104 Graphics::ManagedSurface *_maskImage;
105
106private:
107 void render(Graphics::MacPatterns &patterns, int steps = -1);
108 void drawRect(Graphics::ManagedSurface *surface, Common::ReadStream &in,
109 Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
110 void drawRoundRect(Graphics::ManagedSurface *surface, Common::ReadStream &in,
111 Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
112 void drawPolygon(Graphics::ManagedSurface *surface, Common::ReadStream &in,
113 Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
114 void drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in,
115 Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
116 void drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadStream &in);
117};
118
119} // End of namespace Wage
120
121#endif
Definition: array.h:52
Definition: stream.h:385
Definition: stream.h:745
Definition: str.h:59
Definition: managed_surface.h:51
Definition: design.h:69
Definition: rect.h:536
Definition: design.h:61