Mercurial > otakunoraifu
annotate window/menuitem.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 |
rev | line source |
---|---|
31 | 1 /* |
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
0 | 28 #ifndef __MENUITEM_H__ |
29 #define __MENUITEM_H__ | |
30 | |
52 | 31 #include "widget.h" |
0 | 32 |
33 #define MenuItem WidMenuItem | |
34 #define MenuRadioButton WidMenuRadioButton | |
35 #define MenuScale WidMenuScale | |
36 | |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
37 // 必要なもの: |
0 | 38 // |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
39 // ラベル:surfaceも貼れた方がよいが、まあいいや |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
40 // ラベル位置:ボタンの上、もしくは右 |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
41 // 右の場合:右中央へjustify するので、ラベル全体の幅と右マージンが必要 |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
42 // 上の場合:左下へjustify するので、左マージンと下マージンが必要 |
0 | 43 |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
44 // 内容:x,y個数を指定、その中で中央割り当て |
0 | 45 |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
46 // ラベル位置情報:上なら左下にjustify, 右なら右中央にjustify |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
47 // なので、下へのマージンと上へのマージン、 |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
48 // ラベル+四角ボタン(チェックボックス) |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
49 // ボタンが押されるとdeactivateされる |
0 | 50 // |
65
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
51 // ラジオボタン |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
52 // テキストボタンの集合体。x,y の個数を指定 |
4416cfac86ae
Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents:
52
diff
changeset
|
53 // スケール |
0 | 54 |
55 struct MenuItem : PicWidget { | |
56 int x_size, y_size; | |
57 int menu_width, menu_height; | |
58 int lb_width, lb_right, lb_left, lb_bottom; | |
59 PicWidget* label; | |
60 int* value_ptr; | |
61 std::vector<PicWidget*> item; | |
62 typedef std::vector<PicWidget*>::iterator iterator; | |
63 MenuItem(PicContainer* parent, const Rect& r_orig, int x_size, int y_size, int* value_ptr); | |
64 void SetLabelLeft(PicWidget* lb, const Rect& min_rect, const Rect& min_margin); | |
65 void SetLabelTop(PicWidget* lb, const Rect& left_margin, const Rect& bottom_margin); | |
66 void pack(void); | |
67 void activate(void); | |
68 void deactivate(void); | |
69 // callback | |
70 typedef void (*SetFunc)(void* pointer, MenuItem* widget); | |
71 SetFunc set_func; | |
72 void* set_pointer; | |
73 void SetValue(int new_value); | |
74 virtual void SetValueImpl(int new_value) {}; | |
75 }; | |
76 | |
77 struct RadioButton : MenuItem { | |
78 Event::Container& container; | |
79 PicContainer* parent; | |
80 int text_size; | |
81 Rect button_rect; | |
82 int buttons; | |
83 Color fore_color, pressed_color, back_color; | |
84 RadioButton(Event::Container& container, PicContainer* parent, const Rect& r_orig, int x_size, int y_size, int* value_ptr, const Rect& button_r, int text_size, const Color& fore, const Color& pressed, const Color& back); | |
85 void Add(const char* s, bool is_center = true); | |
86 void Add(const char* s, const Color& fore, const Color& pressed, const Color& back, bool is_center = true); | |
87 static void PressCallback(void* pointer, Button* from); | |
88 void SetValueImpl(int new_value); | |
89 }; | |
90 | |
91 #endif /* __MENUITEM_H__ */ |