File: Test_ListBox.cs

package info (click to toggle)
mygui 3.2.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,224 kB
  • sloc: cpp: 118,031; ansic: 30,202; xml: 15,544; cs: 12,602; tcl: 776; python: 417; makefile: 34
file content (75 lines) | stat: -rw-r--r-- 3,104 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
using System;
using MyGUI.Managed;

namespace TestApp.Managed
{
    public class Test_ListBox
    {
        public static void Test()
        {
            ListBox box = Gui.Instance.CreateWidget<ListBox>("ListBox", new IntCoord(20, 420, 100, 100), Align.Default, "Main");

            box.EventListChangeScroll += new ListBox.HandleListChangeScroll(box_EventListChangeScroll);
            box.EventListMouseItemFocus += new ListBox.HandleListMouseItemFocus(box_EventListMouseItemFocus);
            box.EventListMouseItemActivate += new ListBox.HandleListMouseItemActivate(box_EventListMouseItemActivate);
            box.EventListChangePosition += new ListBox.HandleListChangePosition(box_EventListChangePosition);
            box.EventListSelectAccept += new ListBox.HandleListSelectAccept(box_EventListSelectAccept);

            box.AddItem("line0");
            box.AddItem("line1");
            box.AddItem("line2");
            box.AddItem("line3");
            box.InsertItemAt(0, "insert line0");

            int height = box.OptimalHeight;
            box.SetScrollVisible(true);
            bool visible = box.IsItemSelectedVisible(true);
            visible = box.IsItemVisibleAt(0, true);
            box.BeginToItemSelected();
            box.BeginToItemLast();
            box.BeginToItemFirst();
            box.BeginToItemAt(0);
            string name = box.GetItemNameAt(0);
            box.SetItemNameAt(0, "set line0");
            name = box.GetItemNameAt(0);
            box.SetItemDataAt(0, "0");
            string data = box.GetItemDataAt(0) as string;
            box.ClearItemDataAt(0);
            data = box.GetItemDataAt(0) as string;
            box.ClearIndexSelected();
            box.IndexSelected = 0;
            uint index = box.FindItemIndexWith("line3");
            index = box.FindItemIndexWith("line33");
            box.SwapItemsAt(0, 1);
            box.RemoveItemAt(2);
            uint count = box.ItemCount;
            //box.RemoveAllItems();
            //count = box.ItemCount;
        }

        static void box_EventListSelectAccept(ListBox _sender, uint _index)
        {
            Gui.Instance.Log("TestApp", LogLevel.Info, "EventListSelectAccept  index=" + _index.ToString());
        }

        static void box_EventListChangePosition(ListBox _sender, uint _index)
        {
            Gui.Instance.Log("TestApp", LogLevel.Info, "EventListChangePosition  index=" + _index.ToString());
        }

        static void box_EventListMouseItemActivate(ListBox _sender, uint _index)
        {
            Gui.Instance.Log("TestApp", LogLevel.Info, "EventListMouseItemActivate  index=" + _index.ToString());
        }

        static void box_EventListMouseItemFocus(ListBox _sender, uint _index)
        {
            Gui.Instance.Log("TestApp", LogLevel.Info, "EventListMouseItemFocus  index=" + _index.ToString());
        }

        static void box_EventListChangeScroll(ListBox _sender, uint _position)
        {
            Gui.Instance.Log("TestApp", LogLevel.Info, "EventListChangeScroll  index=" + _position.ToString());
        }
    }
}