annotate window/widget.h @ 64:045ca45f9610

Remove --displaysize, as it was not used.
author Thibaut GIRKA <thib@sitedethib.com>
date Sun, 07 Feb 2010 11:33:23 +0100
parents 15a18fbe6f21
children 4416cfac86ae
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 __WIDGET_H__
223b71206888 Initial import
thib
parents:
diff changeset
29 #define __WIDGET_H__
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 "font/font.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
33 #include "font/text.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
34 #include "event.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
35 #include "picture.h"
0
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 #define TimeCursor WidTimeCursor
223b71206888 Initial import
thib
parents:
diff changeset
38 #define MouseCursor WidMouseCursor
223b71206888 Initial import
thib
parents:
diff changeset
39 #define Button WidButton
223b71206888 Initial import
thib
parents:
diff changeset
40 #define Scale WidScale
223b71206888 Initial import
thib
parents:
diff changeset
41 #define Label WidLabel
223b71206888 Initial import
thib
parents:
diff changeset
42 #define Dialog WidDialog
223b71206888 Initial import
thib
parents:
diff changeset
43 #define TextButton WidTextButton
223b71206888 Initial import
thib
parents:
diff changeset
44 #define Text WidText
223b71206888 Initial import
thib
parents:
diff changeset
45 #define AnmTime WidAnmTime
223b71206888 Initial import
thib
parents:
diff changeset
46 #define AnmMove WidAnmMove
223b71206888 Initial import
thib
parents:
diff changeset
47 #define AnmAlpha WidAnmAlpha
223b71206888 Initial import
thib
parents:
diff changeset
48 #define AnmPtnSolid WidAnmPtnSolid
223b71206888 Initial import
thib
parents:
diff changeset
49 #define AnmPtnAlpha WidAnmPtnAlpha
223b71206888 Initial import
thib
parents:
diff changeset
50
223b71206888 Initial import
thib
parents:
diff changeset
51 // namespace Widget {
223b71206888 Initial import
thib
parents:
diff changeset
52
223b71206888 Initial import
thib
parents:
diff changeset
53 struct TimeCursor : public Event::Time, PicWidget {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
54 int x, y, dx, dy, nptn;
0
223b71206888 Initial import
thib
parents:
diff changeset
55 int old_time, count, interval;
223b71206888 Initial import
thib
parents:
diff changeset
56 TimeCursor(Event::Container& container, int _interval, PicContainer* parent, const char* fname, int sx, int sy, int sdx, int sdy, int nptn, const Rect& r);
223b71206888 Initial import
thib
parents:
diff changeset
57 void Elapsed(unsigned int current_time);
223b71206888 Initial import
thib
parents:
diff changeset
58 };
223b71206888 Initial import
thib
parents:
diff changeset
59
223b71206888 Initial import
thib
parents:
diff changeset
60 struct MouseCursor : public Event::Video, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
61 int x, y;
223b71206888 Initial import
thib
parents:
diff changeset
62 Event::Container& container;
223b71206888 Initial import
thib
parents:
diff changeset
63 MouseCursor(Event::Container& container, PicContainer* parent, const char* s, int x, int y, int w, int h);
223b71206888 Initial import
thib
parents:
diff changeset
64 MouseCursor(Event::Container& container, PicContainer* parent, Surface* s, int x, int y, int w, int h);
223b71206888 Initial import
thib
parents:
diff changeset
65 ~MouseCursor();
223b71206888 Initial import
thib
parents:
diff changeset
66 static bool Motionfunc(int x, int y, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
67 };
223b71206888 Initial import
thib
parents:
diff changeset
68
223b71206888 Initial import
thib
parents:
diff changeset
69 struct Button : public Event::Video, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
70 int sx, sy, sdx, sdy, nptn;
223b71206888 Initial import
thib
parents:
diff changeset
71 bool is_in;
223b71206888 Initial import
thib
parents:
diff changeset
72 bool is_toggled;
223b71206888 Initial import
thib
parents:
diff changeset
73 bool is_toggle_switch;
223b71206888 Initial import
thib
parents:
diff changeset
74 Button(Event::Container& container, PicContainer* parent, const char* s, int sx, int sy, int sdx, int sdy, int nptn, const Rect& r, int _z);
223b71206888 Initial import
thib
parents:
diff changeset
75 Button(Event::Container& container, PicContainer* parent, Surface* s, int sx, int sy, int sdx, int sdy, int nptn, const Rect& r, int _z);
223b71206888 Initial import
thib
parents:
diff changeset
76 ~Button();
223b71206888 Initial import
thib
parents:
diff changeset
77 void Press(void);
223b71206888 Initial import
thib
parents:
diff changeset
78 void Release(void);
223b71206888 Initial import
thib
parents:
diff changeset
79 void Drag(int x_from, int y_from, int x_to, int y_to);
223b71206888 Initial import
thib
parents:
diff changeset
80 void In(void);
223b71206888 Initial import
thib
parents:
diff changeset
81 void Out(void);
223b71206888 Initial import
thib
parents:
diff changeset
82 void Toggle(bool new_toggle);
223b71206888 Initial import
thib
parents:
diff changeset
83 typedef void (*PressFunc)(void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
84 typedef void (*DragFunc)(int x_from, int y_from, int x_to, int y_to, void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
85 PressFunc press_func;
223b71206888 Initial import
thib
parents:
diff changeset
86 void* press_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
87 DragFunc drag_func;
223b71206888 Initial import
thib
parents:
diff changeset
88 void* drag_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
89
223b71206888 Initial import
thib
parents:
diff changeset
90 /* ·ΡΎ΅ */
223b71206888 Initial import
thib
parents:
diff changeset
91 void activate(void) { Event::Video::activate();}
223b71206888 Initial import
thib
parents:
diff changeset
92 void deactivate(void) { Event::Video::deactivate();}
223b71206888 Initial import
thib
parents:
diff changeset
93 void SetRegion(const Rect& new_rect) { Event::Video::SetRegion(new_rect);}
223b71206888 Initial import
thib
parents:
diff changeset
94 };
223b71206888 Initial import
thib
parents:
diff changeset
95 struct Scale : Event::Video, PicWidget {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
96 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
97 Button* arrow_down, *arrow_up;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
98 Button* cursor;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
99 PicContainer* panel;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
100 Event::Container& container;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
101 PicContainer* parent;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
102 Color cursor_color;
0
223b71206888 Initial import
thib
parents:
diff changeset
103
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
104 int mouse_x, mouse_y;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
105 enum {scale_max = 65536};
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
106 int min, max;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
107 int value;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
108 int value_add;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
109 int value_dragstart;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
110 int cursor_width;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
111 bool is_vertical;
0
223b71206888 Initial import
thib
parents:
diff changeset
112
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
113 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
114 Scale(Event::Container& container, PicContainer* parent, const Rect& r_orig, const Color& cursor_color, bool _is_vertical);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
115 void InitCursor(int cursor_width_ratio); // 1024=max
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
116 void SetRange(int min, int max);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
117 void SetValue(int value);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
118 int GetValue(void) const;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
119 typedef void (*ChangeFunc)(void* pointer, Scale* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
120 ChangeFunc change_func;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
121 void* change_pointer;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
122
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
123 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
124 void Init(Rect r_orig);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
125 int CalcValue(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
126 void SetScaleValue(int value);
0
223b71206888 Initial import
thib
parents:
diff changeset
127
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
128 // callback
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
129 static void PressArrowDown(void* pointer, Button* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
130 static void PressArrowUp(void* pointer, Button* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
131 static void PressCursor(void* pointer, Button* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
132 static void DragCursor(int x_from, int y_from,int x, int y, void* pointer, Button* from);
0
223b71206888 Initial import
thib
parents:
diff changeset
133
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
134 // ·ΡΎ΅‘§Event::Video
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
135 void Press(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
136 void Motion(int x, int y);
0
223b71206888 Initial import
thib
parents:
diff changeset
137
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
138 /* ·ΡΎ΅ : PicWidget */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
139 void activate(void) { Event::Video::activate();}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
140 void deactivate(void) { Event::Video::deactivate();}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
141 void SetRegion(const Rect& new_rect) { Event::Video::SetRegion(new_rect);}
0
223b71206888 Initial import
thib
parents:
diff changeset
142 };
223b71206888 Initial import
thib
parents:
diff changeset
143
223b71206888 Initial import
thib
parents:
diff changeset
144 struct TextButton : public Button {
223b71206888 Initial import
thib
parents:
diff changeset
145 enum Attribute {CENTER=1, REVERSE=2, NOPADDING=4};
223b71206888 Initial import
thib
parents:
diff changeset
146 PicRoot& root;
223b71206888 Initial import
thib
parents:
diff changeset
147 Surface* surface;
223b71206888 Initial import
thib
parents:
diff changeset
148 Attribute attribute;
223b71206888 Initial import
thib
parents:
diff changeset
149 int text_size;
223b71206888 Initial import
thib
parents:
diff changeset
150 Color fore, pressed, back;
223b71206888 Initial import
thib
parents:
diff changeset
151 TextButton(Event::Container& container, PicContainer* parent, const char* s, int text_size, Attribute attr, const Rect& r, int _z, const Color& fore, const Color& pressed, const Color& back);
223b71206888 Initial import
thib
parents:
diff changeset
152 void SetText(const char* s, const Color& fore, const Color& pressed, const Color& back);
223b71206888 Initial import
thib
parents:
diff changeset
153 void SetText(const char* s) {
223b71206888 Initial import
thib
parents:
diff changeset
154 SetText(s, fore, pressed, back);
223b71206888 Initial import
thib
parents:
diff changeset
155 }
223b71206888 Initial import
thib
parents:
diff changeset
156 ~TextButton();
223b71206888 Initial import
thib
parents:
diff changeset
157 };
223b71206888 Initial import
thib
parents:
diff changeset
158
223b71206888 Initial import
thib
parents:
diff changeset
159 struct Text : public Event::Video, Event::Time, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
160 typedef TextGlyphStream::iterator iterator;
223b71206888 Initial import
thib
parents:
diff changeset
161
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
162 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
163 Event::Container& event;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
164 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
165 PicBase* pictext;
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 TimeCursor* cursor;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
168 Surface* surface;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
169 TextGlyphStream gstream;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
170 std::vector<int> bottom_pos; // ΉΤΉβ€΅(height)€ΞΞί·ΧΓΝ
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
171 XKFont::HorizLayout layout;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
172 int fontsize;
0
223b71206888 Initial import
thib
parents:
diff changeset
173
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
174 iterator cur_pos;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
175 int line_number;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
176 Rect srcrect;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
177 int press_count;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
178 int scrolled_count;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
179 int scroll_height;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
180 bool window_activated;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
181 bool cursor_activated;
0
223b71206888 Initial import
thib
parents:
diff changeset
182
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
183 int speed; // chars / sec or -1
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
184 int wait_delay; // msec
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
185 int old_time;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
186 int wait_starttime;
0
223b71206888 Initial import
thib
parents:
diff changeset
187
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
188 int CalcScrollHeight(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
189 void DrawText(int& nChar);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
190 void Scrollup(int& nChar);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
191
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
192 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
193 Text(Event::Container& container, PicContainer* parent, const Rect& r, const Rect& text_r, int fontsize);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
194 ~Text();
0
223b71206888 Initial import
thib
parents:
diff changeset
195
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
196 TextStream stream;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
197 enum {PREPARE, DRAW, WAIT, SCROLL, DRAW2, WAIT2} status;
0
223b71206888 Initial import
thib
parents:
diff changeset
198
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
199 void Clear(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
200 void Start(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
201 void Flush(void);
0
223b71206888 Initial import
thib
parents:
diff changeset
202
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
203 void Elapsed(unsigned int current_time);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
204 static bool Pressed(int x, int y, void* pointer);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
205 void activate(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
206 void deactivate(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
207 void SetSpeed(int new_speed);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
208 void SetWait(int new_wait);
0
223b71206888 Initial import
thib
parents:
diff changeset
209
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
210 void SetCursor(TimeCursor* cursor);
0
223b71206888 Initial import
thib
parents:
diff changeset
211 };
223b71206888 Initial import
thib
parents:
diff changeset
212
223b71206888 Initial import
thib
parents:
diff changeset
213 extern void SetFont(const char* fontname);
223b71206888 Initial import
thib
parents:
diff changeset
214
223b71206888 Initial import
thib
parents:
diff changeset
215 struct Label : PicWidget{
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
216 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
217 Surface* surface;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
218 bool is_center;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
219 PicRoot& root;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
220 int text_size;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
221 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
222 Label(PicContainer* parent, const Rect& r_orig, bool is_center=true, const char* text=0, int textsize = 26);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
223 ~Label();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
224 void SetText(const char* text);
0
223b71206888 Initial import
thib
parents:
diff changeset
225 };
223b71206888 Initial import
thib
parents:
diff changeset
226
223b71206888 Initial import
thib
parents:
diff changeset
227 class Dialog : public Event::Video, PicWidget {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
228 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
229 Surface* surface_btn;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
230 Surface* surface_diag;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
231
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
232 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
233 enum { WAIT, OK, CANCEL} status;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
234 Dialog(Event::Container& container, PicContainer* parent, const char* text, bool with_cancel);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
235 ~Dialog();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
236 static void press_ok(void* pointer, Button* btn);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
237 static void press_cancel(void* pointer, Button* btn);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
238 static void DrawBox(Surface* s, const Rect& r);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
239 typedef void (*SetFunc)(void* pointer, Dialog* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
240 SetFunc set_func;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
241 void* set_pointer;
0
223b71206888 Initial import
thib
parents:
diff changeset
242 };
223b71206888 Initial import
thib
parents:
diff changeset
243
223b71206888 Initial import
thib
parents:
diff changeset
244 struct AnmTime : public Event::Time, PicAnm {
223b71206888 Initial import
thib
parents:
diff changeset
245 enum { PLAYING=1, FINISHED=3 } status;
223b71206888 Initial import
thib
parents:
diff changeset
246 unsigned int start_time;
223b71206888 Initial import
thib
parents:
diff changeset
247 unsigned int total_time;
223b71206888 Initial import
thib
parents:
diff changeset
248 int all_count;
223b71206888 Initial import
thib
parents:
diff changeset
249
223b71206888 Initial import
thib
parents:
diff changeset
250 AnmTime(Event::Container& container, PicBase* _pic, int total_time, int all_count = 0);
223b71206888 Initial import
thib
parents:
diff changeset
251 AnmTime(Event::Container& container, std::vector<PicBase*> _pic, int total_time, int all_count = 0);
223b71206888 Initial import
thib
parents:
diff changeset
252 virtual ~AnmTime() {}
223b71206888 Initial import
thib
parents:
diff changeset
253 void SetAllCount(int new_all_count) { all_count = new_all_count; }
223b71206888 Initial import
thib
parents:
diff changeset
254 void SetTotalTime(int new_total) { total_time = new_total; }
223b71206888 Initial import
thib
parents:
diff changeset
255 void Elapsed(unsigned int current_time);
223b71206888 Initial import
thib
parents:
diff changeset
256 void Play(void) {
223b71206888 Initial import
thib
parents:
diff changeset
257 start_time = 0;
223b71206888 Initial import
thib
parents:
diff changeset
258 status = PLAYING;
223b71206888 Initial import
thib
parents:
diff changeset
259 }
223b71206888 Initial import
thib
parents:
diff changeset
260
223b71206888 Initial import
thib
parents:
diff changeset
261 virtual void Start(void) {};
223b71206888 Initial import
thib
parents:
diff changeset
262 virtual void Exec(int count) = 0;
223b71206888 Initial import
thib
parents:
diff changeset
263 virtual void Finish(void) {};
223b71206888 Initial import
thib
parents:
diff changeset
264 void Abort(void);
223b71206888 Initial import
thib
parents:
diff changeset
265 bool IsEnd(void);
223b71206888 Initial import
thib
parents:
diff changeset
266 };
223b71206888 Initial import
thib
parents:
diff changeset
267
223b71206888 Initial import
thib
parents:
diff changeset
268 struct AnmMove : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
269 Rect from, to;
223b71206888 Initial import
thib
parents:
diff changeset
270 AnmMove(Event::Container& container, PicBase* _pic, const Rect& to, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
271 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
272 };
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
273
0
223b71206888 Initial import
thib
parents:
diff changeset
274 #define ALPHA_MAX 255
223b71206888 Initial import
thib
parents:
diff changeset
275 struct AnmAlpha : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
276 int from, to;
223b71206888 Initial import
thib
parents:
diff changeset
277 unsigned char alpha; Rect alpha_r;
223b71206888 Initial import
thib
parents:
diff changeset
278 AnmAlpha(Event::Container& container, PicBase* _pic, int alpha_from, int alpha_to, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
279 AnmAlpha(Event::Container& container, std::vector<PicBase*> _pic, int alpha_from, int alpha_to, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
280 void Start(void);
223b71206888 Initial import
thib
parents:
diff changeset
281 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
282 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
283 };
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
284
0
223b71206888 Initial import
thib
parents:
diff changeset
285 struct AnmAlphaMove : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
286 struct Ptn {
223b71206888 Initial import
thib
parents:
diff changeset
287 Rect pos;
223b71206888 Initial import
thib
parents:
diff changeset
288 Rect surface_pos;
223b71206888 Initial import
thib
parents:
diff changeset
289 unsigned char alpha;
223b71206888 Initial import
thib
parents:
diff changeset
290 unsigned int next_tick;
223b71206888 Initial import
thib
parents:
diff changeset
291 Ptn(const Rect& _r, const Rect& _surface_r, unsigned char _a, unsigned int _n) :
223b71206888 Initial import
thib
parents:
diff changeset
292 pos(_r), surface_pos(_surface_r), alpha(_a), next_tick(_n) {}
223b71206888 Initial import
thib
parents:
diff changeset
293 };
223b71206888 Initial import
thib
parents:
diff changeset
294 std::vector<Ptn> ptns;
223b71206888 Initial import
thib
parents:
diff changeset
295 int cur_count;
223b71206888 Initial import
thib
parents:
diff changeset
296 AnmAlphaMove(Event::Container& container, PicBase* _pic);
223b71206888 Initial import
thib
parents:
diff changeset
297 void SetPtn(void);
223b71206888 Initial import
thib
parents:
diff changeset
298 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
299 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
300 };
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
301
0
223b71206888 Initial import
thib
parents:
diff changeset
302 struct AnmPtnSolid : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
303 AnmPtnSolid(Event::Container& container, PicBase* _pic, const unsigned char* ptn, const Rect& alpha_r, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
304 ~AnmPtnSolid() { delete[] alpha; }
223b71206888 Initial import
thib
parents:
diff changeset
305 const unsigned char* ptn;
223b71206888 Initial import
thib
parents:
diff changeset
306 int ptn_len;
223b71206888 Initial import
thib
parents:
diff changeset
307 unsigned char* alpha;
223b71206888 Initial import
thib
parents:
diff changeset
308 Rect alpha_r;
223b71206888 Initial import
thib
parents:
diff changeset
309
223b71206888 Initial import
thib
parents:
diff changeset
310 void Start(void);
223b71206888 Initial import
thib
parents:
diff changeset
311 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
312 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
313 };
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
314
0
223b71206888 Initial import
thib
parents:
diff changeset
315 struct AnmPtnAlpha : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
316 AnmPtnAlpha(Event::Container& container, PicBase* _pic, const unsigned char* ptn, const Rect& alpha_r, int alpha_bandwidth, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
317 ~AnmPtnAlpha() { delete[] alpha; }
223b71206888 Initial import
thib
parents:
diff changeset
318 const unsigned char* ptn;
223b71206888 Initial import
thib
parents:
diff changeset
319 int ptn_len;
223b71206888 Initial import
thib
parents:
diff changeset
320 int band;
223b71206888 Initial import
thib
parents:
diff changeset
321 unsigned char* alpha;
223b71206888 Initial import
thib
parents:
diff changeset
322 Rect alpha_r;
223b71206888 Initial import
thib
parents:
diff changeset
323 void Start(void);
223b71206888 Initial import
thib
parents:
diff changeset
324 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
325 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
326 };
223b71206888 Initial import
thib
parents:
diff changeset
327
223b71206888 Initial import
thib
parents:
diff changeset
328 // } /* end of namespace Widget */
223b71206888 Initial import
thib
parents:
diff changeset
329
223b71206888 Initial import
thib
parents:
diff changeset
330 #undef Text
223b71206888 Initial import
thib
parents:
diff changeset
331
223b71206888 Initial import
thib
parents:
diff changeset
332 #endif
223b71206888 Initial import
thib
parents:
diff changeset
333