annotate window/picture.h @ 66:d112357a0ec1

Fix a bug with savegames introduced with changeset c7bcc0ec2267. Warning: savegames created since c7bcc0ec2267 are probably corrupted, you may have to start the game over. If you chose not to do so, you should replace all occurrences of 'TextWindow' by 'TextImplWindow', and 'Text Window' by 'TextImpl Window' in your save files.
author Thibaut Girka <thib@sitedethib.com>
date Sat, 11 Dec 2010 18:36:20 +0100
parents 4416cfac86ae
children 1fd20d231376
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
1 /*
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
3 * All rights reserved.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
4 *
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
5 * Redistribution and use in source and binary forms, with or without
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
6 * modification, are permitted provided that the following conditions
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
7 * are met:
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
9 * notice, this list of conditions and the following disclaimer.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
12 * documentation and/or other materials provided with the distribution.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
14 * derived from this software without specific prior written permission.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
15 *
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
26 */
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
27
0
223b71206888 Initial import
thib
parents:
diff changeset
28 #ifndef __PICTURE__
223b71206888 Initial import
thib
parents:
diff changeset
29 #define __PICTURE__
223b71206888 Initial import
thib
parents:
diff changeset
30
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
31 #include <vector>
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
32 #include <list>
0
223b71206888 Initial import
thib
parents:
diff changeset
33 #ifdef HAVE_CONFIG_H
223b71206888 Initial import
thib
parents:
diff changeset
34 # include "config.h"
223b71206888 Initial import
thib
parents:
diff changeset
35 #endif
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 class PicBase;
223b71206888 Initial import
thib
parents:
diff changeset
38 class PicContainer;
223b71206888 Initial import
thib
parents:
diff changeset
39 class PicRoot;
223b71206888 Initial import
thib
parents:
diff changeset
40
223b71206888 Initial import
thib
parents:
diff changeset
41 class Surface;
223b71206888 Initial import
thib
parents:
diff changeset
42
223b71206888 Initial import
thib
parents:
diff changeset
43 namespace Event {
223b71206888 Initial import
thib
parents:
diff changeset
44 class Video;
223b71206888 Initial import
thib
parents:
diff changeset
45 }
223b71206888 Initial import
thib
parents:
diff changeset
46
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
47 /* PicBase の内容をイベントと連動させるためのインターフェース */
0
223b71206888 Initial import
thib
parents:
diff changeset
48 class PicAnm {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
49 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
50 typedef std::vector<PicBase*>::iterator iterator;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
51 std::vector<PicBase*> pic;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
52 PicAnm(PicBase* pic);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
53 PicAnm(std::vector<PicBase*> pic);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
54 virtual ~PicAnm();
0
223b71206888 Initial import
thib
parents:
diff changeset
55 };
223b71206888 Initial import
thib
parents:
diff changeset
56
223b71206888 Initial import
thib
parents:
diff changeset
57 class PicBase {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
58 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
59 friend class PicContainer;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
60 friend class PicWidget;
0
223b71206888 Initial import
thib
parents:
diff changeset
61
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
62 typedef std::list<PicBase*> List;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
63 typedef std::list<PicBase*>::iterator iterator;
0
223b71206888 Initial import
thib
parents:
diff changeset
64
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
65 PicContainer* parent;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
66 class PicWidget* widget;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
67 Rect rel_pos; // relative position to the parent
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
68 Rect rel_solid_area; // solid area(not alpha-blended) to the parent
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
69 Rect clip_area; // clip area on the parent
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
70 bool is_hidden;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
71 bool is_hidden_now;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
72 bool is_cached;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
73 public:
60
e16e13d8cd68 Replaced SATURATE -> ADD, implemented objComposite, corrected minor things
Thibaut GIRKA <thib@sitedethib.com>
parents: 52
diff changeset
74 enum { /*MOBILE=1,*/ CACHE_BACK=2, /* CACHE_SELF=4,*/ NO_PICTURE=8, SOLID = 16, SURFACE_FREE = 32, FIT_SURFACE = 64, BLIT_ADD = 128, BLIT_MULTIPLY = 256, ALPHA_FREE=512};
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
75 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
76 int attribute;
0
223b71206888 Initial import
thib
parents:
diff changeset
77
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
78 PicRoot* root;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
79 iterator z_pos;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
80 int surface_x, surface_y, surface_w, surface_h;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
81 Surface* surface_back;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
82 Surface* surface_own;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
83 const unsigned char* surface_alpha;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
84 Rect surface_alpha_rect;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
85 int distance_root;
0
223b71206888 Initial import
thib
parents:
diff changeset
86
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
87 void Blit(const Rect& rpos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
88 void Blit(void) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
89 is_cached = true;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
90 Blit(Rect(0, 0, rel_pos.width(), rel_pos.height()));
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
91 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
92 /*
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
93 ** rpos : relative position to the widget
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
94 ** ppos : relative position to the parent
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
95 ** ppos = parent_pos(rpos)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
96 ** rpos = child_pos(ppos, parent->this_widget)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
97 ** cpos : relative position to a child widget
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
98 ** cpos = child_pos(rpos, a_child_widget)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
99 ** apos : absolute position in the screen
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
100 ** apos = QueryAbsPos(rpos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
101 ** or
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
102 ** Rect ppos = rel_pos;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
103 ** apos = parent->QueryAbsPos(ppos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
104 ** the latter form is used for 'rel_pos',
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
105 ** because rel_pos is defined as the relative position to the parent
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
106 */
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
107 Rect QueryAbsPos(Rect& ppos); // この picture 内の rel_pos を表示するのに実際に必要な絶対座標を得る
0
223b71206888 Initial import
thib
parents:
diff changeset
108
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
109 static Rect child_pos(Rect rpos, PicBase* child) { /* return 'cpos' */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
110 rpos.intersect(child->rel_pos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
111 rpos.rmove( -(child->rel_pos.lx), -(child->rel_pos.ty));
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
112 return rpos;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
113 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
114 Rect parent_pos(Rect rpos) { /* return 'ppos' */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
115 rpos.rmove(rel_pos.lx, rel_pos.ty);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
116 rpos.intersect(rel_pos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
117 return rpos;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
118 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
119 void SetEventWidget(class PicWidget* widget);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
120 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
121 PicBase(const Rect& rel_pos, PicContainer* parent, int attr);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
122 virtual ~PicBase();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
123 void InitRoot(PicRoot* r) { root = r;} // only called from PicRoot::PicRoot
0
223b71206888 Initial import
thib
parents:
diff changeset
124
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
125 void ReBlit(const Rect& rpos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
126 void ReBlit(void) { ReBlit(Rect(0, 0, rel_pos.width(), rel_pos.height()));}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
127 void ExecReBlit(const Rect& rpos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
128 void SimpleBlit(Surface* screen);
0
223b71206888 Initial import
thib
parents:
diff changeset
129
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
130 virtual void RMove(int add_x, int add_y);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
131 void Move(int new_rx, int new_ry);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
132 #define ZMOVE_TOP ((PicBase*)0xffff00ff) /* 最前面へ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
133 #define ZMOVE_BOTTOM ((PicBase*)0xffff0fff) /* 最背面へ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
134 void ZMove(PicBase* back); // back の前に移動(back と自分は同じ親を持つこと)
0
223b71206888 Initial import
thib
parents:
diff changeset
135
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
136 void SetSurface(Surface* new_surface, int x, int y, int attribute = 0);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
137 void SetSurface(const char* new_surface, int x, int y);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
138 void SetSurfacePos(int x, int y);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
139 int SurfacePosX(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
140 int SurfacePosY(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
141 void SetSurfaceRect(const Rect& r);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
142 void SetSurfaceAlpha(const unsigned char* alpha, const Rect& rect);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
143 void SetSurfaceAlphaFile(const char* file);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
144 void SetSurfaceColorKey(int r, int g, int b);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
145 void SetSurfaceAttribute(int attribute);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
146 void SetSurfaceFreeFlag(bool flag=true);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
147 void SetClipArea(const Rect& r);
0
223b71206888 Initial import
thib
parents:
diff changeset
148
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
149 void hide(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
150 void show_all(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
151 void show(void);
0
223b71206888 Initial import
thib
parents:
diff changeset
152
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
153 int PosX(void) const { return rel_pos.lx;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
154 int PosY(void) const { return rel_pos.ty;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
155 int Width(void) const { return rel_pos.width();}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
156 int Height(void) const { return rel_pos.height();}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
157 int DistanceRoot(void) const { return distance_root; }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
158 bool IsHidden(void) { return is_hidden_now;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
159 bool IsParent(PicBase* pic);
0
223b71206888 Initial import
thib
parents:
diff changeset
160
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
161 std::vector<PicAnm*> anm;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
162 void ClearAnm(void);
0
223b71206888 Initial import
thib
parents:
diff changeset
163 };
223b71206888 Initial import
thib
parents:
diff changeset
164
223b71206888 Initial import
thib
parents:
diff changeset
165 class PicContainer : public PicBase {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
166 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
167 friend class PicBase;
0
223b71206888 Initial import
thib
parents:
diff changeset
168
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
169 void BlitBack(iterator z, Rect rpos); // z より後ろの領域を描画
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
170 void BlitFront(iterator z, Rect rpos); // z を含め、zより前の領域を描画
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
171 void BlitChildren(Rect rpos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
172 void BlitSelf(Rect rpos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
173 void BlitSelf(void) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
174 is_cached = true;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
175 BlitSelf(Rect(0, 0, rel_pos.width(), rel_pos.height()));
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
176 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
177 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
178 List children;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
179 private:
0
223b71206888 Initial import
thib
parents:
diff changeset
180
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
181 void set_showflag(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
182 void set_nowhiddenflag(bool is_hide);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
183 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
184 PicContainer(const Rect& rel_pos, PicContainer* parent, int attr);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
185 ~PicContainer();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
186 PicBase* create_leaf(const Rect& rel_pos, int attr);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
187 PicContainer* create_node(const Rect& rel_pos, int attr);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
188 PicRoot& Root(void) { return *root;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
189 void RMove(int add_x, int add_y);
0
223b71206888 Initial import
thib
parents:
diff changeset
190 };
223b71206888 Initial import
thib
parents:
diff changeset
191
223b71206888 Initial import
thib
parents:
diff changeset
192 typedef enum { NO_MASK, ALPHA_MASK, COLOR_MASK} MaskType;
223b71206888 Initial import
thib
parents:
diff changeset
193 struct PicRoot {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
194 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
195 class PicContainer* root;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
196 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
197 class FileToSurface* ftosurface;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
198 struct UpdateItem {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
199 PicBase* pic;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
200 Rect rpos;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
201 Rect apos;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
202 static bool less(const UpdateItem&, const UpdateItem&);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
203 UpdateItem(PicBase* p, const Rect& _rpos, const Rect& _apos) : pic(p), rpos(_rpos), apos(_apos) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
204 };
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
205 std::vector<UpdateItem> update_rects;
0
223b71206888 Initial import
thib
parents:
diff changeset
206
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
207 friend class FileToSurface;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
208 void DeleteSurfaceImpl(Surface* s) const;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
209 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
210 void Update(PicBase* pic, const Rect& rpos, const Rect& apos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
211 void DeleteUpdatePic(PicBase* pic);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
212 void ExecUpdate(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
213 void SetWindowCaption(const char* caption);
0
223b71206888 Initial import
thib
parents:
diff changeset
214
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
215 // Surface 操作
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
216 Surface* NewSurfaceFromRGBAData(int w, int h, char* data, MaskType with_mask) const; // data は malloc されたものであること(SDLの内部仕様)
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
217 Surface* NewSurface(int w, int h, MaskType with_mask) const;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
218 Surface* NewSurface(const char* filename, MaskType with_mask = ALPHA_MASK);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
219 Surface* RotZoomSurface(Surface* from, double zoom, double rotate_angle);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
220 void DeleteSurface(Surface* s);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
221 void BlitSurface(Surface* src, const Rect& src_rpos, const unsigned char* alpha, const Rect& alpha_r, Surface* dest, const Rect& dest_rpos, int attribute) const;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
222 void BlitSurface(Surface* src, const Rect& src_rpos, Surface* dest, const Rect& dest_rpos) const {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
223 BlitSurface(src, src_rpos, 0, Rect(0,0), dest, dest_rpos, 0);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
224 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
225 static bool with_mask(Surface* src);
0
223b71206888 Initial import
thib
parents:
diff changeset
226
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
227 Surface* surface;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
228 Surface* hw_surface;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
229 int width, height;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
230 PicRoot(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
231 ~PicRoot();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
232 PicBase* create_leaf(const Rect& apos, int attr) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
233 return root->create_leaf(apos, attr);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
234 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
235 PicContainer* create_node(const Rect& apos, int attr) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
236 return root->create_node(apos, attr);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
237 }
0
223b71206888 Initial import
thib
parents:
diff changeset
238 };
223b71206888 Initial import
thib
parents:
diff changeset
239
223b71206888 Initial import
thib
parents:
diff changeset
240 class PicWidget {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
241 private:
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 60
diff changeset
242 PicBase* pic; /* 本来継承するべきだが、遅延初期化したいので instance */
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
243 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
244 PicWidget(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
245 virtual ~PicWidget();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
246 void SetPic(PicBase* new_pic);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
247 PicBase* Pic(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
248 PicContainer* PicNode(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
249 virtual void activate(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
250 virtual void deactivate(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
251 virtual void SetRegion(const Rect& apos);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
252 void show(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
253 void hide(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
254 void show_all(void);
0
223b71206888 Initial import
thib
parents:
diff changeset
255 };
223b71206888 Initial import
thib
parents:
diff changeset
256
223b71206888 Initial import
thib
parents:
diff changeset
257 #endif /* PICTURE */