annotate window/menuitem.h @ 8:55b577e5f5b5

Some memory leaks fixed
author thib
date Tue, 05 Aug 2008 12:56:51 +0000 (2008-08-05)
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__ */