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 
56 namespace Wage {
57 
58 using namespace Graphics::MacGUIConstants;
59 
60 // struct to hold design operation data
61 struct DrawOp {
62  uint32 offset;
63  Common::String opcode;
64  int fillType;
65  int borderThickness;
66  int borderFillType;
67  int lineSize;
68 };
69 
70 class Design {
71 public:
73  ~Design();
74 
75  Common::Array<DrawOp> _drawOps;
76 
77  void setBounds(Common::Rect *bounds) {
78  _bounds = bounds;
79  }
80 
81  Common::Rect *getBounds() {
82  return _bounds;
83  }
84 
85  void paint(Graphics::ManagedSurface *canvas, Graphics::MacPatterns &patterns, int x, int y, int steps = -1);
86  bool isInBounds(int x, int y);
87  static void drawRect(Graphics::ManagedSurface *surface, const Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
88  static void drawRect(Graphics::ManagedSurface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
89  static void drawFilledRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int color, Graphics::MacPatterns &patterns, byte fillType);
90  static void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color, Graphics::MacPatterns &patterns, byte fillType);
91  static void drawHLine(Graphics::ManagedSurface *surface, int x1, int x2, int y, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
92  static void drawVLine(Graphics::ManagedSurface *surface, int x, int y1, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
93 
94  bool isBoundsCalculation() { return _boundsCalculationMode; }
95  void adjustBounds(int16 x, int16 y);
96 
97 private:
98  byte *_data;
99  int _len;
100  int _renderedSteps;
101  Common::String _lastOpString;
102  Common::Rect *_bounds;
103  Graphics::ManagedSurface *_surface;
104  bool _boundsCalculationMode;
105  Graphics::ManagedSurface *_maskImage;
106 
107 private:
108  void render(Graphics::MacPatterns &patterns, int steps = -1);
109  void drawRect(Graphics::ManagedSurface *surface, Common::ReadStream &in,
110  Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
111  void drawRoundRect(Graphics::ManagedSurface *surface, Common::ReadStream &in,
112  Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
113  void drawPolygon(Graphics::ManagedSurface *surface, Common::ReadStream &in,
114  Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
115  void drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in,
116  Graphics::MacPatterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
117  void drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadStream &in);
118 };
119 
120 } // End of namespace Wage
121 
122 #endif
Definition: managed_surface.h:51
Definition: str.h:59
Definition: array.h:52
Definition: macwindowmanager.h:45
Definition: rect.h:524
Definition: stream.h:745
Definition: design.h:61
Definition: design.h:70
Definition: debugger.h:28
Definition: stream.h:385