File: Test_ItemBox.cs

package info (click to toggle)
mygui 3.4.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 38,800 kB
  • sloc: cpp: 122,825; ansic: 30,231; xml: 15,792; cs: 12,601; tcl: 776; python: 397; makefile: 38
file content (86 lines) | stat: -rw-r--r-- 2,850 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using MyGUI.Sharp;

namespace TestApp.Sharp
{

	public class Test_ItemBox
	{
		public static void Test()
		{
			ItemBox box = Gui.Instance.CreateWidget<ItemBox>("ItemBox", new IntCoord(20, 320, 100, 100), Align.Default, "Main");
			box.EventNotifyItem += new ItemBox.HandleNotifyItem(box_EventNotifyItem);
			box.EventMouseItemActivate += new ItemBox.HandleMouseItemActivate(box_EventMouseItemActivate);
			box.EventChangeItemPosition += new ItemBox.HandleChangeItemPosition(box_EventChangeItemPosition);
			box.EventSelectItemAccept += new ItemBox.HandleSelectItemAccept(box_EventSelectItemAccept);
			box.RequestDrawItem += new ItemBox.HandleDrawItem(box_RequestDrawItem);
			box.RequestCoordItem += new ItemBox.HandleCoordItem(box_RequestCoordItem);
			box.RequestCreateWidgetItem += new ItemBox.HandleCreateWidgetItem(box_RequestCreateWidgetItem);

			box.AddItem();//"cell0");

			box.ResetDrag();
			Widget cell = box.GetWidgetByIndex(0);
			if (cell != null)
			{
				uint index = box.GetIndexByWidget(cell);
			}
			Widget drag = box.WidgetDrag;
			box.VerticalAlignment = !box.VerticalAlignment;
			//box.ClearItemDataAt(0);
			//box.SetItemDataAt(0, "new cell0");
			box.ClearIndexSelected();
			box.IndexSelected = 0;
			box.RedrawAllItems();
			box.RedrawItemAt(0);
			box.RemoveItemAt(0);
			box.RemoveAllItems();

			box.AddItem();//"cell0");
			//box.SetItemDataAt(0, "new cell0");
			box.InsertItemAt(0);//, "insert cell0");
			uint count = box.ItemCount;
		}

		static void box_RequestCreateWidgetItem(ItemBox _sender, Widget _item)
		{
			EditBox cell = _item.CreateWidget<EditBox>("Edit", new IntCoord(0, 0, 50, 50), Align.Default);
			_item.UserData = cell;
		}

		static void box_RequestCoordItem(ItemBox _sender, ref IntCoord _coord, bool _drag)
		{
			_coord.left = 0;
			_coord.top = 0;
			_coord.width = 70;
			_coord.height = 70;
		}

		static void box_RequestDrawItem(ItemBox _sender, Widget _item, ref IBDrawItemInfo _info)
		{
			EditBox cell = _item.UserData as EditBox;
			//string str = _sender.GetItemDataAt(_info.index) as string;
			//if (str != null) cell.OnlyText = str;
		}

		static void box_EventSelectItemAccept(ItemBox _sender, uint _index)
		{
			Gui.Instance.Log("TestApp", LogLevel.Info, "EventSelectItemAccept  index=" + _index.ToString());
		}

		static void box_EventChangeItemPosition(ItemBox _sender, uint _index)
		{
			Gui.Instance.Log("TestApp", LogLevel.Info, "EventChangeItemPosition  index=" + _index.ToString());
		}

		static void box_EventMouseItemActivate(ItemBox _sender, uint _index)
		{
			Gui.Instance.Log("TestApp", LogLevel.Info, "EventMouseItemActivate  index=" + _index.ToString());
		}

		static void box_EventNotifyItem(ItemBox _sender, ref IBNotifyItemData _info)
		{
			Gui.Instance.Log("TestApp", LogLevel.Info, "EventNotifyItem  notify=" + _info.notify.ToString());
		}
	}

}