← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2206: add a browser tab style

 

------------------------------------------------------------
revno: 2206
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Wed 2010-08-11 17:40:28 +0200
message:
  add a browser tab style
modified:
  dcpp/SettingsManager.cpp
  dcpp/SettingsManager.h
  dwt/include/dwt/widgets/TabView.h
  dwt/src/widgets/TabView.cpp
  help/settings_tabs.html
  win32/MainWindow.cpp
  win32/TabsPage.cpp
  win32/TabsPage.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp	2010-08-07 14:25:29 +0000
+++ dcpp/SettingsManager.cpp	2010-08-11 15:40:28 +0000
@@ -289,6 +289,7 @@
 	setDefault(SEARCH_MERGE, true);
 	setDefault(TOOLBAR_SIZE, 20);
 	setDefault(TAB_WIDTH, 150);
+	setDefault(TAB_STYLE, TAB_STYLE_OD);
 	setDefault(TRANSFERS_PANED_POS, .7);
 	setDefault(QUEUE_PANED_POS, .3);
 	setDefault(SEARCH_PANED_POS, .2);

=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h	2010-08-06 21:02:04 +0000
+++ dcpp/SettingsManager.h	2010-08-11 15:40:28 +0000
@@ -123,6 +123,12 @@
 		INCOMING_FIREWALL_PASSIVE };
 	enum {	OUTGOING_DIRECT, OUTGOING_SOCKS5 };
 
+	enum {
+		TAB_STYLE_BUTTONS = 1 << 1,
+		TAB_STYLE_OD = 1 << 2,
+		TAB_STYLE_BROWSER = 1 << 3
+	};
+
 	enum {	MAGNET_AUTO_SEARCH, MAGNET_AUTO_DOWNLOAD };
 
 	const string& get(StrSetting key, bool useDefault = true) const {

=== modified file 'dwt/include/dwt/widgets/TabView.h'
--- dwt/include/dwt/widgets/TabView.h	2010-08-10 16:53:56 +0000
+++ dwt/include/dwt/widgets/TabView.h	2010-08-11 15:40:28 +0000
@@ -73,6 +73,12 @@
 	struct Seed : public BaseType::Seed {
 		typedef ThisType WidgetType;
 
+		enum {
+			WinDefault, /// use the default Windows style.
+
+			WinBrowser /// use the "Browser" Windows style, only available on Win >= Vista.
+		} tabStyle;
+
 		FontPtr font;
 
 		/** for owner-drawn tabs (that have the TCS_OWNERDRAWFIXED style), defines the width of

=== modified file 'dwt/src/widgets/TabView.cpp'
--- dwt/src/widgets/TabView.cpp	2010-08-10 18:00:17 +0000
+++ dwt/src/widgets/TabView.cpp	2010-08-11 15:40:28 +0000
@@ -35,6 +35,7 @@
 #include <dwt/widgets/ToolTip.h>
 #include <dwt/WidgetCreator.h>
 #include <dwt/util/StringUtils.h>
+#include <dwt/util/win32/Version.h>
 #include <dwt/DWTException.h>
 #include <dwt/resources/Brush.h>
 #include <dwt/dwt_vsstyle.h>
@@ -49,6 +50,7 @@
 TabView::Seed::Seed(unsigned widthConfig_, bool toggleActive_, bool ctrlTab_) :
 BaseType::Seed(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |
 	TCS_FOCUSNEVER | TCS_HOTTRACK | TCS_MULTILINE | TCS_OWNERDRAWFIXED | TCS_RAGGEDRIGHT | TCS_TOOLTIPS),
+tabStyle(WinDefault),
 font(new Font(DefaultGuiFont)),
 widthConfig(widthConfig_),
 toggleActive(toggleActive_),
@@ -99,7 +101,12 @@
 		lf.lfWeight = FW_BOLD;
 		boldFont = FontPtr(new Font(::CreateFontIndirect(&lf), true));
 
-		theme.load(VSCLASS_TAB, this);
+		if(cs.tabStyle == Seed::WinBrowser && util::win32::ensureVersion(util::win32::VISTA)) {
+			theme.load(L"BrowserTab::" VSCLASS_TAB, this);
+			if(!theme)
+				theme.load(VSCLASS_TAB, this, false);
+		} else
+			theme.load(VSCLASS_TAB, this);
 		windowTheme.load(VSCLASS_WINDOW, this);
 
 		if(!(cs.style & TCS_BUTTONS)) {

=== modified file 'help/settings_tabs.html'
--- help/settings_tabs.html	2010-08-07 14:25:29 +0000
+++ help/settings_tabs.html	2010-08-11 15:40:28 +0000
@@ -16,11 +16,12 @@
 customize them.<br/>
 <i>DC++ needs to be restarted for this setting to take effect.</i>
 </p>
-<h2>Second set of choices</h2>
+<h2>Second and third sets of choices</h2>
 <p cshelp="IDH_SETTINGS_TABS_STYLE">
-2 modes are exposed here with various differences; select the one you prefer.<br/>
+Several modes are exposed here with various differences; select the one you prefer.<br/>
 One particular difference is that in tab style mode, multiline tabs re-organize so that the
 selected tab is always at the bottom. That isn't the case in button style mode.<br/>
+The "Browser theme" mode is only available on Windows &gt;= Vista.<br/>
 <i>DC++ needs to be restarted for this setting to take effect.</i>
 </p>
 <h2>Tab width</h2>

=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp	2010-08-06 21:02:04 +0000
+++ win32/MainWindow.cpp	2010-08-11 15:40:28 +0000
@@ -449,14 +449,16 @@
 
 void MainWindow::initTabs() {
 	dcdebug("initTabs\n");
-	SettingsManager::getInstance()->setDefault(SettingsManager::TAB_STYLE, TCS_OWNERDRAWFIXED);
 	TabView::Seed seed = WinUtil::Seeds::tabs;
 	seed.widthConfig = SETTING(TAB_WIDTH);
-	if(!(SETTING(TAB_STYLE) & TCS_OWNERDRAWFIXED)) {
+	if(SETTING(TAB_STYLE) & SettingsManager::TAB_STYLE_OD) {
+		if(SETTING(TAB_STYLE) & SettingsManager::TAB_STYLE_BROWSER)
+			seed.tabStyle = TabView::Seed::WinBrowser;
+	} else {
 		seed.style &= ~TCS_OWNERDRAWFIXED;
 		seed.widthConfig -= 100; // max width to max chars
 	}
-	if(SETTING(TAB_STYLE) & TCS_BUTTONS)
+	if(SETTING(TAB_STYLE) & SettingsManager::TAB_STYLE_BUTTONS)
 		seed.style |= TCS_BUTTONS;
 	seed.toggleActive = BOOLSETTING(TOGGLE_ACTIVE_WINDOW);
 	seed.ctrlTab = true;

=== modified file 'win32/TabsPage.cpp'
--- win32/TabsPage.cpp	2010-08-07 14:25:29 +0000
+++ win32/TabsPage.cpp	2010-08-11 15:40:28 +0000
@@ -23,6 +23,7 @@
 #include "TabsPage.h"
 
 #include <dwt/widgets/Slider.h>
+#include <dwt/util/win32/Version.h>
 
 #include <dcpp/SettingsManager.h>
 #include "WinUtil.h"
@@ -46,6 +47,8 @@
 grid(0),
 dcppDraw(0),
 buttonStyle(0),
+themeGroup(0),
+browserTheme(0),
 tabWidth(0),
 previewGroup(0),
 options(0)
@@ -59,16 +62,18 @@
 	grid->setSpacing(10);
 
 	{
-		GridPtr cur = grid->addChild(Grid::Seed(1, 2));
+		GridPtr cur = grid->addChild(Grid::Seed(1, 3));
 
 		GroupBoxPtr group = cur->addChild(GroupBox::Seed());
 		group->setHelpId(IDH_SETTINGS_TABS_DRAW);
 		GridPtr cur2 = group->addChild(Grid::Seed(2, 1));
 		dcppDraw = cur2->addChild(RadioButton::Seed(T_("Let DC++ draw tabs")));
 		dcppDraw->onClicked(std::bind(&TabsPage::createPreview, this));
+		dcppDraw->onClicked([&themeGroup]() { themeGroup->setEnabled(true); });
 		RadioButtonPtr button = cur2->addChild(RadioButton::Seed(T_("Use standard Windows tabs")));
 		button->onClicked(std::bind(&TabsPage::createPreview, this));
-		if(SETTING(TAB_STYLE) & TCS_OWNERDRAWFIXED)
+		button->onClicked([&themeGroup]() { themeGroup->setEnabled(false); });
+		if(SETTING(TAB_STYLE) & SettingsManager::TAB_STYLE_OD)
 			dcppDraw->setChecked();
 		else
 			button->setChecked();
@@ -80,10 +85,27 @@
 		button->onClicked(std::bind(&TabsPage::createPreview, this));
 		buttonStyle = cur2->addChild(RadioButton::Seed(T_("Button style")));
 		buttonStyle->onClicked(std::bind(&TabsPage::createPreview, this));
-		if(SETTING(TAB_STYLE) & TCS_BUTTONS)
+		if(SETTING(TAB_STYLE) & SettingsManager::TAB_STYLE_BUTTONS)
 			buttonStyle->setChecked();
 		else
 			button->setChecked();
+
+		themeGroup = cur->addChild(GroupBox::Seed());
+		themeGroup->setHelpId(IDH_SETTINGS_TABS_STYLE);
+		cur2 = themeGroup->addChild(Grid::Seed(2, 1));
+		button = cur2->addChild(RadioButton::Seed(T_("Default theme")));
+		button->onClicked(std::bind(&TabsPage::createPreview, this));
+		browserTheme = cur2->addChild(RadioButton::Seed(T_("Browser theme")));
+		if(dwt::util::win32::ensureVersion(dwt::util::win32::VISTA))
+			browserTheme->onClicked(std::bind(&TabsPage::createPreview, this));
+		else
+			browserTheme->setEnabled(false);
+		if(browserTheme->getEnabled() && (SETTING(TAB_STYLE) & SettingsManager::TAB_STYLE_BROWSER))
+			browserTheme->setChecked();
+		else
+			button->setChecked();
+		if(!(SETTING(TAB_STYLE) & SettingsManager::TAB_STYLE_OD))
+			themeGroup->setEnabled(false);
 	}
 
 	{
@@ -124,9 +146,11 @@
 void TabsPage::write() {
 	int tabStyle = 0;
 	if(dcppDraw->getChecked())
-		tabStyle |= TCS_OWNERDRAWFIXED;
+		tabStyle |= SettingsManager::TAB_STYLE_OD;
 	if(buttonStyle->getChecked())
-		tabStyle |= TCS_BUTTONS;
+		tabStyle |= SettingsManager::TAB_STYLE_BUTTONS;
+	if(browserTheme->getChecked())
+		tabStyle |= SettingsManager::TAB_STYLE_BROWSER;
 	SettingsManager::getInstance()->set(SettingsManager::TAB_STYLE, tabStyle);
 
 	SettingsManager::getInstance()->set(SettingsManager::TAB_WIDTH, tabWidth->getPosition());
@@ -144,7 +168,10 @@
 	TabView::Seed seed = WinUtil::Seeds::tabs;
 	seed.widthConfig = tabWidth->getPosition();
 	seed.style |= WS_DISABLED;
-	if(!dcppDraw->getChecked()) {
+	if(dcppDraw->getChecked()) {
+		if(browserTheme->getChecked())
+			seed.tabStyle = TabView::Seed::WinBrowser;
+	} else {
 		seed.style &= ~TCS_OWNERDRAWFIXED;
 		seed.widthConfig -= 100; // max width to max chars
 	}

=== modified file 'win32/TabsPage.h'
--- win32/TabsPage.h	2010-08-06 21:02:04 +0000
+++ win32/TabsPage.h	2010-08-11 15:40:28 +0000
@@ -34,6 +34,8 @@
 	GridPtr grid;
 	RadioButtonPtr dcppDraw;
 	RadioButtonPtr buttonStyle;
+	GroupBoxPtr themeGroup;
+	RadioButtonPtr browserTheme;
 	SliderPtr tabWidth;
 	GroupBoxPtr previewGroup;