1 using System;
2 using MyGUI.Managed;
3 
4 namespace TestApp.Managed
5 {
6 
7     public class Test_ItemBox
8     {
Test()9         public static void Test()
10         {
11             ItemBox box = Gui.Instance.CreateWidget<ItemBox>("ItemBox", new IntCoord(20, 320, 100, 100), Align.Default, "Main");
12 
13             box.EventNotifyItem += new ItemBox.HandleNotifyItem(box_EventNotifyItem);
14             box.EventMouseItemActivate += new ItemBox.HandleMouseItemActivate(box_EventMouseItemActivate);
15             box.EventChangeItemPosition += new ItemBox.HandleChangeItemPosition(box_EventChangeItemPosition);
16             box.EventSelectItemAccept += new ItemBox.HandleSelectItemAccept(box_EventSelectItemAccept);
17             box.RequestDrawItem += new ItemBox.HandleDrawItem(box_RequestDrawItem);
18             box.RequestCoordItem += new ItemBox.HandleCoordItem(box_RequestCoordItem);
19             box.RequestCreateWidgetItem += new ItemBox.HandleCreateWidgetItem(box_RequestCreateWidgetItem);
20 
21             box.AddItem("cell0");
22 
23             box.ResetDrag();
24             Widget cell = box.GetWidgetByIndex(0);
25 			if (cell != null)
26 			{
27 				uint index = box.GetIndexByWidget(cell);
28 			}
29             Widget drag = box.WidgetDrag;
30             box.VerticalAlignment = !box.VerticalAlignment;
31             box.ClearItemDataAt(0);
32             box.SetItemDataAt(0, "new cell0");
33             box.ClearIndexSelected();
34             box.IndexSelected = 0;
35             box.RedrawAllItems();
36             box.RedrawItemAt(0);
37             box.RemoveItemAt(0);
38             box.RemoveAllItems();
39 
40             box.AddItem("cell0");
41             box.SetItemDataAt(0, "new cell0");
42             box.InsertItemAt(0, "insert cell0");
43             uint count = box.ItemCount;
44         }
45 
box_RequestCreateWidgetItem(ItemBox _sender, Widget _item)46         static void box_RequestCreateWidgetItem(ItemBox _sender, Widget _item)
47         {
48             EditBox cell = _item.CreateWidget<EditBox>("Edit", new IntCoord(0, 0, 50, 50), Align.Default);
49             _item.UserData = cell;
50         }
51 
box_RequestCoordItem(ItemBox _sender, ref IntCoord _coord, bool _drag)52         static void box_RequestCoordItem(ItemBox _sender, ref IntCoord _coord, bool _drag)
53         {
54             _coord.left = 0;
55             _coord.top = 0;
56             _coord.width = 70;
57             _coord.height = 70;
58         }
59 
box_RequestDrawItem(ItemBox _sender, Widget _item, IBDrawItemInfo _info)60         static void box_RequestDrawItem(ItemBox _sender, Widget _item, IBDrawItemInfo _info)
61         {
62             EditBox cell = _item.UserData as EditBox;
63             string str = _sender.GetItemDataAt(_info.index) as string;
64             if (str != null) cell.OnlyText = str;
65         }
66 
box_EventSelectItemAccept(ItemBox _sender, uint _index)67         static void box_EventSelectItemAccept(ItemBox _sender, uint _index)
68         {
69             Gui.Instance.Log("TestApp", LogLevel.Info, "EventSelectItemAccept  index=" + _index.ToString());
70         }
71 
box_EventChangeItemPosition(ItemBox _sender, uint _index)72         static void box_EventChangeItemPosition(ItemBox _sender, uint _index)
73         {
74             Gui.Instance.Log("TestApp", LogLevel.Info, "EventChangeItemPosition  index=" + _index.ToString());
75         }
76 
box_EventMouseItemActivate(ItemBox _sender, uint _index)77         static void box_EventMouseItemActivate(ItemBox _sender, uint _index)
78         {
79             Gui.Instance.Log("TestApp", LogLevel.Info, "EventMouseItemActivate  index=" + _index.ToString());
80         }
81 
box_EventNotifyItem(ItemBox _sender, IBNotifyItemData _info)82         static void box_EventNotifyItem(ItemBox _sender, IBNotifyItemData _info)
83         {
84             Gui.Instance.Log("TestApp", LogLevel.Info, "EventNotifyItem  notify=" + _info.notify.ToString());
85         }
86     }
87 
88 }
89