3 #include "pys_icon_png.h"
5 class TestList : public BC_ListBox
8 TestList(int x, int y, int w, int h,
9 ArrayList<BC_ListBoxItem*> *items);
11 int selection_changed();
14 TestList::TestList(int x, int y, int w, int h,
15 ArrayList<BC_ListBoxItem*> *items)
16 : BC_ListBox(x, y, w, h, LISTBOX_TEXT, items,
17 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0)
21 int TestList::handle_event()
23 printf("handle_event\n");
27 int TestList::selection_changed()
29 BC_ListBoxItem *item = get_selection(0, 0);
30 printf("selection_changed %s\n", !item ? "<nul>" : item->get_text());
34 class TestWindow : public BC_Window
37 TestWindow() : BC_Window("Test9", 0, 0, 320, 240) {};
38 void create_objects();
41 ArrayList<BC_ListBoxItem*> items;
44 void TestWindow::create_objects()
46 lock_window("AWindowRemovePluginGUI::create_objects");
50 draw_text(x, y, "Hello world");
52 BC_Button *ok_button = new BC_OKButton(this);
53 add_subwindow(ok_button);
54 BC_Button *cancel_button = new BC_CancelButton(this);
55 add_subwindow(cancel_button);
56 BC_ListBoxItem *thing;
57 ArrayList<BC_ListBoxItem*> *sublist;
58 items.append(thing = new BC_ListBoxItem("thing 1"));
59 VFrame *pys_icon = new VFramePng(pys_icon_png);
60 thing->set_icon_vframe(pys_icon);
61 int pw = pys_icon->get_w(), ph = pys_icon->get_h();
62 BC_Pixmap *pys_picon = new BC_Pixmap(this, pw, ph);
63 pys_picon->draw_vframe(pys_icon, 0, 0, pw, pw, 0, 0);
64 thing->set_icon(pys_picon);
65 sublist = thing->new_sublist(1);
66 BC_ListBoxItem *fish, *cat, *hat;
67 sublist->append(fish = new BC_ListBoxItem("fish"));
68 ArrayList<BC_ListBoxItem*> *fish_list = fish->new_sublist(1);
69 fish_list->append(new BC_ListBoxItem("green"));
70 fish_list->append(new BC_ListBoxItem("eggs"));
71 fish_list->append(new BC_ListBoxItem("ham"));
72 sublist->append(cat = new BC_ListBoxItem("cat"));
73 ArrayList<BC_ListBoxItem*> *cat_list = cat->new_sublist(1);
74 cat_list->append(new BC_ListBoxItem("videos"));
75 sublist->append(hat = new BC_ListBoxItem("hat"));
76 ArrayList<BC_ListBoxItem*> *hat_list = hat->new_sublist(1);
77 hat_list->append(new BC_ListBoxItem("bonnet"));
78 hat_list->append(new BC_ListBoxItem("cap"));
79 hat_list->append(new BC_ListBoxItem("sombrero"));
80 items.append(thing = new BC_ListBoxItem("thing 2"));
81 int lw = get_w()-x-10, lh = ok_button->get_y() - y - 5;
82 add_subwindow(list = new TestList(x, y, lw, lh, &items));
87 int TestWindow::keypress_event()
89 switch( get_keypress() ) {
91 switch( list->get_format() ) {
93 list->update_format(LISTBOX_ICONS, 1);
96 list->update_format(LISTBOX_ICONS_PACKED, 1);
98 case LISTBOX_ICONS_PACKED:
99 list->update_format(LISTBOX_ICON_LIST, 1);
101 case LISTBOX_ICON_LIST:
102 list->update_format(LISTBOX_TEXT, 1);
114 window.create_objects();