annotate window/menuitem.h @ 14:8da1d92ac8f8

Don't create fonts faces for size <= 0, and update objects when their font size is set
author thib
date Sat, 09 Aug 2008 12:04:08 +0000
parents 223b71206888
children 5ae5533b3a9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 #ifndef __MENUITEM_H__
223b71206888 Initial import
thib
parents:
diff changeset
2 #define __MENUITEM_H__
223b71206888 Initial import
thib
parents:
diff changeset
3
223b71206888 Initial import
thib
parents:
diff changeset
4 #include"widget.h"
223b71206888 Initial import
thib
parents:
diff changeset
5
223b71206888 Initial import
thib
parents:
diff changeset
6 #define MenuItem WidMenuItem
223b71206888 Initial import
thib
parents:
diff changeset
7 #define MenuRadioButton WidMenuRadioButton
223b71206888 Initial import
thib
parents:
diff changeset
8 #define MenuScale WidMenuScale
223b71206888 Initial import
thib
parents:
diff changeset
9
223b71206888 Initial import
thib
parents:
diff changeset
10 // 必要なもの:
223b71206888 Initial import
thib
parents:
diff changeset
11 //
223b71206888 Initial import
thib
parents:
diff changeset
12 // ラベル:surfaceも貼れた方がよいが、まあいいや
223b71206888 Initial import
thib
parents:
diff changeset
13 // ラベル位置:ボタンの上、もしくは右
223b71206888 Initial import
thib
parents:
diff changeset
14 // 右の場合:右中央へjustify するので、ラベル全体の幅と右マージンが必要
223b71206888 Initial import
thib
parents:
diff changeset
15 // 上の場合:左下へjustify するので、左マージンと下マージンが必要
223b71206888 Initial import
thib
parents:
diff changeset
16
223b71206888 Initial import
thib
parents:
diff changeset
17 // 内容:x,y個数を指定、その中で中央割り当て
223b71206888 Initial import
thib
parents:
diff changeset
18
223b71206888 Initial import
thib
parents:
diff changeset
19 // ラベル位置情報:上なら左下にjustify, 右なら右中央にjustify
223b71206888 Initial import
thib
parents:
diff changeset
20 // なので、下へのマージンと上へのマージン、
223b71206888 Initial import
thib
parents:
diff changeset
21 // ラベル+四角ボタン(チェックボックス)
223b71206888 Initial import
thib
parents:
diff changeset
22 // ボタンが押されるとdeactivateされる
223b71206888 Initial import
thib
parents:
diff changeset
23 //
223b71206888 Initial import
thib
parents:
diff changeset
24 // ラジオボタン
223b71206888 Initial import
thib
parents:
diff changeset
25 // テキストボタンの集合体。x,y の個数を指定
223b71206888 Initial import
thib
parents:
diff changeset
26 // スケール
223b71206888 Initial import
thib
parents:
diff changeset
27
223b71206888 Initial import
thib
parents:
diff changeset
28 struct MenuItem : PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
29 int x_size, y_size;
223b71206888 Initial import
thib
parents:
diff changeset
30 int menu_width, menu_height;
223b71206888 Initial import
thib
parents:
diff changeset
31 int lb_width, lb_right, lb_left, lb_bottom;
223b71206888 Initial import
thib
parents:
diff changeset
32 PicWidget* label;
223b71206888 Initial import
thib
parents:
diff changeset
33 int* value_ptr;
223b71206888 Initial import
thib
parents:
diff changeset
34 std::vector<PicWidget*> item;
223b71206888 Initial import
thib
parents:
diff changeset
35 typedef std::vector<PicWidget*>::iterator iterator;
223b71206888 Initial import
thib
parents:
diff changeset
36 MenuItem(PicContainer* parent, const Rect& r_orig, int x_size, int y_size, int* value_ptr);
223b71206888 Initial import
thib
parents:
diff changeset
37 void SetLabelLeft(PicWidget* lb, const Rect& min_rect, const Rect& min_margin);
223b71206888 Initial import
thib
parents:
diff changeset
38 void SetLabelTop(PicWidget* lb, const Rect& left_margin, const Rect& bottom_margin);
223b71206888 Initial import
thib
parents:
diff changeset
39 void pack(void);
223b71206888 Initial import
thib
parents:
diff changeset
40 void activate(void);
223b71206888 Initial import
thib
parents:
diff changeset
41 void deactivate(void);
223b71206888 Initial import
thib
parents:
diff changeset
42 // callback
223b71206888 Initial import
thib
parents:
diff changeset
43 typedef void (*SetFunc)(void* pointer, MenuItem* widget);
223b71206888 Initial import
thib
parents:
diff changeset
44 SetFunc set_func;
223b71206888 Initial import
thib
parents:
diff changeset
45 void* set_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
46 void SetValue(int new_value);
223b71206888 Initial import
thib
parents:
diff changeset
47 virtual void SetValueImpl(int new_value) {};
223b71206888 Initial import
thib
parents:
diff changeset
48 };
223b71206888 Initial import
thib
parents:
diff changeset
49
223b71206888 Initial import
thib
parents:
diff changeset
50 struct RadioButton : MenuItem {
223b71206888 Initial import
thib
parents:
diff changeset
51 Event::Container& container;
223b71206888 Initial import
thib
parents:
diff changeset
52 PicContainer* parent;
223b71206888 Initial import
thib
parents:
diff changeset
53 int text_size;
223b71206888 Initial import
thib
parents:
diff changeset
54 Rect button_rect;
223b71206888 Initial import
thib
parents:
diff changeset
55 int buttons;
223b71206888 Initial import
thib
parents:
diff changeset
56 Color fore_color, pressed_color, back_color;
223b71206888 Initial import
thib
parents:
diff changeset
57 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
58 void Add(const char* s, bool is_center = true);
223b71206888 Initial import
thib
parents:
diff changeset
59 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
60 static void PressCallback(void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
61 void SetValueImpl(int new_value);
223b71206888 Initial import
thib
parents:
diff changeset
62 };
223b71206888 Initial import
thib
parents:
diff changeset
63
223b71206888 Initial import
thib
parents:
diff changeset
64 #endif /* __MENUITEM_H__ */