From: Jerome St-Louis Date: Sat, 14 Mar 2015 05:56:55 +0000 (-0400) Subject: ecere/gui/controls/TabControl: Tweaks to remove and add tabs X-Git-Url: https://ecere.com/cgi-bin/gitweb.cgi?p=sdk;a=commitdiff_plain;h=f78fd2217835e07f38554a0e39ec97d8811c86c4 ecere/gui/controls/TabControl: Tweaks to remove and add tabs --- diff --git a/ecere/src/gui/controls/TabControl.ec b/ecere/src/gui/controls/TabControl.ec index e1e2e91..e39553f 100644 --- a/ecere/src/gui/controls/TabControl.ec +++ b/ecere/src/gui/controls/TabControl.ec @@ -572,18 +572,25 @@ public class TabControl : Window public void AddTab(Tab tab) { - tab.parent = this; + if(tab.parent != this) + { + tab.parent = this; + return; + } tab.autoCreate = false; tab.id = numTabs; - tab.button = TabButton + if(!tab.button) { - parent = tabButtons, - master = this, stayDown = true, - text = tab.text, id = (int64)(intptr)tab, NotifyClicked = NotifyClicked, - tab = tab, - background = background; - }; - incref tab.button; + tab.button = TabButton + { + parent = tabButtons, + master = this, stayDown = true, + text = tab.text, id = (int64)(intptr)tab, NotifyClicked = NotifyClicked, + tab = tab, + background = background; + }; + incref tab.button; + } if(created) { @@ -614,7 +621,7 @@ public class TabControl : Window { Window child; Tab fallbackTab = null; - tab.parent = null; + // tab.parent = null; for(child = tabButtons.children.first; child; child = child.next) { if(child._class == class(TabButton)) @@ -623,7 +630,10 @@ public class TabControl : Window if(button.id == (int64)(intptr)tab) { if(button.created) + { button.Destroy(0); + numTabs--; + } break; } else @@ -636,12 +646,13 @@ public class TabControl : Window fallbackTab = tabButtons.children.first ? ((TabButton)tabButtons.children.first).tab : null; if(fallbackTab) fallbackTab.SelectTab(); + else + curTab = null; /*curTab = fallbackTab; curButton = curTab.button; curButton.checked = true; curTab.autoCreate = true;*/ } - numTabs--; } ~TabControl()