PG_ListBoxBaseItem::~PG_ListBoxBaseItem() { if(GetParent() == NULL) { return; } if(GetParent()->GetSelectedItem() == this) { GetParent()->SelectItem(NULL); //GetParent()->RemoveWidget(this, true, true); } for (PG_Widget* w = next(); w != NULL; w = w->next()) { w->SetID(w->GetID() - 1); } }
int main( int argc, char **argv ) { PG_Application app; app.LoadTheme( "default" ); app.InitScreen( 640, 480, 0 ); app.SetEmergencyQuit(true); PG_Label l( NULL, PG_Rect(10,50,250,25), NULL ); l.Show(); PG_TabBar bar( NULL, PG_Rect(10, 10, 300, 33) ); bar.sigTabSelect.connect(slot(handleTab), &l); bar.Show(); bar.AddTab("Tab1"); bar.AddTab("Tab2"); bar.AddTab("Tab3"); bar.AddTab("MoreTab1"); bar.AddTab("MoreTab2"); bar.AddTab("MoreTab3"); bar.AddTab("EvenLongerTab1"); bar.AddTab("Tab4"); PG_NoteBook notebook(NULL, PG_Rect(50, 100, 300, 200)); notebook.sigPageSelect.connect(slot(handlePageSelect)); PG_Button b(NULL, 1, PG_Rect(0,0,10,10), "Big fat button"); b.sigButtonClick.connect(slot(handleBigFatButton)); notebook.AddPage("button", &b, slot(handlePageButton)); PG_Widget* custom = notebook.CreatePage("custom", slot(handlePageCustom)); custom->SetID(2); PG_Label label(custom, PG_Rect(5,5,100,25), "My Page"); PG_CheckButton check(custom, -1, PG_Rect(5,35,150,25), "Check me"); PG_ListBox listpage(NULL, PG_Rect(0,0,300,100)); listpage.AddItem(new PG_ListBoxItem(25, "Item1")); listpage.AddItem(new PG_ListBoxItem(25, "Item2")); listpage.AddItem(new PG_ListBoxItem(25, "Item3")); listpage.AddItem(new PG_ListBoxItem(25, "Item4")); listpage.AddItem(new PG_ListBoxItem(25, "Item5")); listpage.AddItem(new PG_ListBoxItem(25, "Item6")); listpage.AddItem(new PG_ListBoxItem(25, "Item7")); listpage.AddItem(new PG_ListBoxItem(25, "Item8")); listpage.AddItem(new PG_ListBoxItem(25, "Item9")); listpage.AddItem(new PG_ListBoxItem(25, "Item10")); listpage.SetID(3); notebook.AddPage("list", &listpage); PG_NoteBook subnotebook(NULL, PG_Rect(0,0,100,100)); PG_Widget* complex = subnotebook.CreatePage("custom2"); PG_Button b2(complex, -1, PG_Rect(10,10,100,25), "Button"); subnotebook.AddPage("button2", new PG_Button(NULL, -1, PG_Rect(0,0,10,10), "Not so big button")); notebook.AddPage("complex", &subnotebook); notebook.Show(); app.Run(); return 0; }