annotate window/menuitem.h @ 61:bdd8a5ff8f46

Revert an old change that disabled cursors...
author Thibaut GIRKA <thib@sitedethib.com>
date Fri, 18 Dec 2009 21:07:29 +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 __MENUITEM_H__
223b71206888 Initial import
thib
parents:
diff changeset
29 #define __MENUITEM_H__
223b71206888 Initial import
thib
parents:
diff changeset
30
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
31 #include "widget.h"
0
223b71206888 Initial import
thib
parents:
diff changeset
32
223b71206888 Initial import
thib
parents:
diff changeset
33 #define MenuItem WidMenuItem
223b71206888 Initial import
thib
parents:
diff changeset
34 #define MenuRadioButton WidMenuRadioButton
223b71206888 Initial import
thib
parents:
diff changeset
35 #define MenuScale WidMenuScale
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 // 必要なもの:
223b71206888 Initial import
thib
parents:
diff changeset
38 //
223b71206888 Initial import
thib
parents:
diff changeset
39 // ラベル:surfaceも貼れた方がよいが、まあいいや
223b71206888 Initial import
thib
parents:
diff changeset
40 // ラベル位置:ボタンの上、もしくは右
223b71206888 Initial import
thib
parents:
diff changeset
41 // 右の場合:右中央へjustify するので、ラベル全体の幅と右マージンが必要
223b71206888 Initial import
thib
parents:
diff changeset
42 // 上の場合:左下へjustify するので、左マージンと下マージンが必要
223b71206888 Initial import
thib
parents:
diff changeset
43
223b71206888 Initial import
thib
parents:
diff changeset
44 // 内容:x,y個数を指定、その中で中央割り当て
223b71206888 Initial import
thib
parents:
diff changeset
45
223b71206888 Initial import
thib
parents:
diff changeset
46 // ラベル位置情報:上なら左下にjustify, 右なら右中央にjustify
223b71206888 Initial import
thib
parents:
diff changeset
47 // なので、下へのマージンと上へのマージン、
223b71206888 Initial import
thib
parents:
diff changeset
48 // ラベル+四角ボタン(チェックボックス)
223b71206888 Initial import
thib
parents:
diff changeset
49 // ボタンが押されるとdeactivateされる
223b71206888 Initial import
thib
parents:
diff changeset
50 //
223b71206888 Initial import
thib
parents:
diff changeset
51 // ラジオボタン
223b71206888 Initial import
thib
parents:
diff changeset
52 // テキストボタンの集合体。x,y の個数を指定
223b71206888 Initial import
thib
parents:
diff changeset
53 // スケール
223b71206888 Initial import
thib
parents:
diff changeset
54
223b71206888 Initial import
thib
parents:
diff changeset
55 struct MenuItem : PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
56 int x_size, y_size;
223b71206888 Initial import
thib
parents:
diff changeset
57 int menu_width, menu_height;
223b71206888 Initial import
thib
parents:
diff changeset
58 int lb_width, lb_right, lb_left, lb_bottom;
223b71206888 Initial import
thib
parents:
diff changeset
59 PicWidget* label;
223b71206888 Initial import
thib
parents:
diff changeset
60 int* value_ptr;
223b71206888 Initial import
thib
parents:
diff changeset
61 std::vector<PicWidget*> item;
223b71206888 Initial import
thib
parents:
diff changeset
62 typedef std::vector<PicWidget*>::iterator iterator;
223b71206888 Initial import
thib
parents:
diff changeset
63 MenuItem(PicContainer* parent, const Rect& r_orig, int x_size, int y_size, int* value_ptr);
223b71206888 Initial import
thib
parents:
diff changeset
64 void SetLabelLeft(PicWidget* lb, const Rect& min_rect, const Rect& min_margin);
223b71206888 Initial import
thib
parents:
diff changeset
65 void SetLabelTop(PicWidget* lb, const Rect& left_margin, const Rect& bottom_margin);
223b71206888 Initial import
thib
parents:
diff changeset
66 void pack(void);
223b71206888 Initial import
thib
parents:
diff changeset
67 void activate(void);
223b71206888 Initial import
thib
parents:
diff changeset
68 void deactivate(void);
223b71206888 Initial import
thib
parents:
diff changeset
69 // callback
223b71206888 Initial import
thib
parents:
diff changeset
70 typedef void (*SetFunc)(void* pointer, MenuItem* widget);
223b71206888 Initial import
thib
parents:
diff changeset
71 SetFunc set_func;
223b71206888 Initial import
thib
parents:
diff changeset
72 void* set_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
73 void SetValue(int new_value);
223b71206888 Initial import
thib
parents:
diff changeset
74 virtual void SetValueImpl(int new_value) {};
223b71206888 Initial import
thib
parents:
diff changeset
75 };
223b71206888 Initial import
thib
parents:
diff changeset
76
223b71206888 Initial import
thib
parents:
diff changeset
77 struct RadioButton : MenuItem {
223b71206888 Initial import
thib
parents:
diff changeset
78 Event::Container& container;
223b71206888 Initial import
thib
parents:
diff changeset
79 PicContainer* parent;
223b71206888 Initial import
thib
parents:
diff changeset
80 int text_size;
223b71206888 Initial import
thib
parents:
diff changeset
81 Rect button_rect;
223b71206888 Initial import
thib
parents:
diff changeset
82 int buttons;
223b71206888 Initial import
thib
parents:
diff changeset
83 Color fore_color, pressed_color, back_color;
223b71206888 Initial import
thib
parents:
diff changeset
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);
223b71206888 Initial import
thib
parents:
diff changeset
85 void Add(const char* s, bool is_center = true);
223b71206888 Initial import
thib
parents:
diff changeset
86 void Add(const char* s, const Color& fore, const Color& pressed, const Color& back, bool is_center = true);
223b71206888 Initial import
thib
parents:
diff changeset
87 static void PressCallback(void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
88 void SetValueImpl(int new_value);
223b71206888 Initial import
thib
parents:
diff changeset
89 };
223b71206888 Initial import
thib
parents:
diff changeset
90
223b71206888 Initial import
thib
parents:
diff changeset
91 #endif /* __MENUITEM_H__ */