diff options
author | David Corrales | 2007-06-23 18:51:33 +0000 |
---|---|---|
committer | David Corrales | 2007-06-23 18:51:33 +0000 |
commit | cacd7a28fd51d960947de88abbf30c487e66529d (patch) | |
tree | f3baa59853bfb307e452b86b9d93c4737b1fa6ab /gui/TabWidget.cpp | |
parent | 0ac96302fe9c04df79cb01a77d19535b45fe2db0 (diff) | |
parent | 90c2210dae8c91fa8babc6b05564e15c9d445d18 (diff) | |
download | scummvm-rg350-cacd7a28fd51d960947de88abbf30c487e66529d.tar.gz scummvm-rg350-cacd7a28fd51d960947de88abbf30c487e66529d.tar.bz2 scummvm-rg350-cacd7a28fd51d960947de88abbf30c487e66529d.zip |
Merged the FSNode branch with trunk r27031:27680
svn-id: r27681
Diffstat (limited to 'gui/TabWidget.cpp')
-rw-r--r-- | gui/TabWidget.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gui/TabWidget.cpp b/gui/TabWidget.cpp index 8159147c83..38ea6229ec 100644 --- a/gui/TabWidget.cpp +++ b/gui/TabWidget.cpp @@ -114,6 +114,38 @@ int TabWidget::addTab(const String &title) { return _activeTab; } +void TabWidget::removeTab(int tabID) { + assert(0 <= tabID && tabID < (int)_tabs.size()); + + // Deactive the tab if it's currently the active one + if (tabID == _activeTab) { + _tabs[tabID].firstWidget = _firstWidget; + releaseFocus(); + _firstWidget = 0; + } + + // Dispose the widgets in that tab and then the tab itself + delete _tabs[tabID].firstWidget; + _tabs.remove_at(tabID); + + // Adjust _firstVisibleTab if necessary + if (_firstVisibleTab >= (int)_tabs.size()) { + _firstVisibleTab = MAX(0, (int)_tabs.size() - 1); + } + + // The active tab was removed, so select a new active one (if any remains) + if (tabID == _activeTab) { + _activeTab = -1; + if (tabID >= (int)_tabs.size()) + tabID = _tabs.size() - 1; + if (tabID >= 0) + setActiveTab(tabID); + } + + // Finally trigger a redraw + _boss->draw(); +} + void TabWidget::setActiveTab(int tabID) { assert(0 <= tabID && tabID < (int)_tabs.size()); if (_activeTab != tabID) { |