ScummVM API documentation
castmember.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  */
21 
22 #ifndef DIRECTOR_CASTMEMBER_CASTMEMBER_H
23 #define DIRECTOR_CASTMEMBER_CASTMEMBER_H
24 
25 #include "director/archive.h"
26 #include "director/stxt.h"
27 
28 #include "director/lingo/lingo-object.h"
29 
30 namespace Graphics {
31 class MacWidget;
32 }
33 
34 namespace Common {
35 class SeekableReadStream;
36 class SeekableReadStreamEndian;
37 }
38 
39 namespace Director {
40 
41 struct CastMemberInfo;
42 class Channel;
43 struct Resource;
44 
45 class CastMember : public Object<CastMember> {
46 public:
47  CastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream);
48  CastMember(Cast *cast, uint16 castId);
49  virtual ~CastMember() {}
50 
51  Cast *getCast() { return _cast; }
52  uint16 getID() { return _castId; }
53  CastMemberInfo *getInfo();
54 
55  virtual void load();
56  virtual void unload();
57  bool isLoaded() { return _loaded; }
58 
59  virtual bool isEditable() { return false; }
60  virtual void setEditable(bool editable) {}
61  virtual bool isModified() { return _modified; }
62  void setModified(bool modified);
63  virtual Graphics::MacWidget *createWidget(Common::Rect &bbox, Channel *channel, SpriteType spriteType) { return nullptr; }
64  virtual void updateWidget(Graphics::MacWidget *widget, Channel *channel) {}
65  virtual void updateFromWidget(Graphics::MacWidget *widget) {}
66  virtual Common::Rect getInitialRect() { return _initialRect; }
67 
68  virtual void setColors(uint32 *fgcolor, uint32 *bgcolor) { return; }
69  virtual uint32 getForeColor() { return 0; }
70  virtual void setForeColor(uint32 fgCol) { return; }
71  virtual uint32 getBackColor() { return 0; }
72  virtual void setBackColor(uint32 bgCol) { return; }
73 
74  bool hasProp(const Common::String &propName) override;
75  Datum getProp(const Common::String &propName) override;
76  bool setProp(const Common::String &propName, const Datum &value, bool force = false) override;
77  bool hasField(int field) override;
78  Datum getField(int field) override;
79  bool setField(int field, const Datum &value) override;
80 
81  // release the control to widget, this happens when we are changing sprites. Because we are having the new cast member and the old one shall leave
82  void releaseWidget() { _widget = nullptr; }
83 
84  virtual Common::String formatInfo() { return Common::String(); };
85 
86  // Return the default bounding box of the cast member. The origin is at the registration offset.
87  virtual Common::Rect getBbox();
88  // Return the bounding box of the cast member, assuming a stretched width and height value.
89  // The origin is at the registration offset.
90  virtual Common::Rect getBbox(int16 currentWidth, int16 currentHeight);
91  // Return the default registration offset. Offset is relative to the top-left corner of the widget.
92  virtual Common::Point getRegistrationOffset() { return Common::Point(0, 0); }
93  // Return the registration offset, assuming a stretched width and height value.
94  // Offset is relative to the top-left corner of the widget.
95  virtual Common::Point getRegistrationOffset(int16 currentWidth, int16 currentHeight) { return Common::Point(0, 0); }
96 
97  CastType _type;
98  Common::Rect _initialRect;
99  Common::Rect _boundingRect;
100  Common::Array<Resource> _children;
101 
102  bool _hilite;
103  bool _erase;
104  int _purgePriority;
105  uint32 _size;
106  uint8 _flags1;
107 
108 protected:
109  Cast *_cast;
110  uint16 _castId;
111  // a link to the widget we created, we may use it later
112  Graphics::MacWidget *_widget;
113  bool _loaded;
114  bool _modified;
115  bool _isChanged;
116 };
117 
118 struct EditInfo {
119  Common::Rect rect;
120  int32 selStart;
121  int32 selEnd;
122  byte version;
123  byte rulerFlag;
124 };
125 
127  bool autoHilite;
128  uint32 scriptId;
129  Common::String script;
130  Common::String name;
131  Common::String directory;
132  Common::String fileName;
133  Common::String type;
134  EditInfo scriptEditInfo;
135  FontStyle scriptStyle;
136  EditInfo textEditInfo;
137  Common::String modifiedBy;
138  Common::String comments;
139 
140  CastMemberInfo() : autoHilite(false), scriptId(0) {}
141 };
142 
143 } // End of namespace Director
144 
145 #endif
Definition: cast.h:85
Definition: str.h:59
Definition: channel.h:40
Definition: rect.h:144
Definition: archive.h:35
Definition: lingo-object.h:71
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:45
Definition: macwidget.h:39
Definition: lingo.h:130
Definition: stream.h:944
Definition: stxt.h:33
Definition: castmember.h:118
Definition: castmember.h:45
Definition: castmember.h:126