/*
* Copyright (C) 2003-2005 Pr Bjrklund, per.bjorklund@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
#include "../client/DCPlusPlus.h"
#include "Resource.h"
#include "../client/SettingsManager.h"
#include "FulTabsPage.h"
#include "WinUtil.h"
PropPage::TextItem FulTabsPage::texts[] = {
{ IDC_CH_BLEND, ResourceManager::BLEND_TABS },
{ IDC_SB_TAB_COLORS, ResourceManager::SETTINGS_SB_TAB_COLORS },
{ IDC_TEXT_TAB_SIZE, ResourceManager::SETTINGS_SB_TAB_SIZE },
{ IDC_BTN_COLOR, ResourceManager::SETTINGS_SELECT_COLOR },
{ IDC_SB_TAB_DIRTY_BLEND, ResourceManager::SETTINGS_SB_DIRTY_BLEND },
{ IDC_McDC_TABS, ResourceManager::McDC_TABS },
{ IDC_SETTINGS_BOLD_CONTENTS, ResourceManager::SETTINGS_BOLD_OPTIONS },
{ IDC_TEXT_BLENDING, ResourceManager::TEXT_BLENDING },
{ 0, ResourceManager::SETTINGS_AUTO_AWAY }
};
PropPage::Item FulTabsPage::items[] = {
{ IDC_CH_BLEND, SettingsManager::BLEND_TABS, PropPage::T_BOOL },
{ IDC_TAB_SIZE, SettingsManager::TAB_SIZE, PropPage::T_INT },
{ IDC_TAB_DIRTY_BLEND, SettingsManager::TAB_DIRTY_BLEND, PropPage::T_INT },
{ 0, 0, PropPage::T_END }
};
PropPage::ListItem FulTabsPage::listItems[] = {
{ SettingsManager::FINISHED_DOWNLOAD_DIRTY, ResourceManager::SETTINGS_FINISHED_DOWNLOAD_DIRTY },
{ SettingsManager::FINISHED_UPLOAD_DIRTY, ResourceManager::SETTINGS_FINISHED_UPLOAD_DIRTY },
{ SettingsManager::QUEUE_DIRTY, ResourceManager::SETTINGS_QUEUE_DIRTY },
{ SettingsManager::UP_QUEUE_DIRTY, ResourceManager::SETTINGS_UP_QUEUE_DIRTY },
{ SettingsManager::TAB_HUB_DIRTY, ResourceManager::SETTINGS_TAB_HUB_DIRTY },
{ SettingsManager::TAB_SEARCH_DIRTY, ResourceManager::SETTINGS_TAB_SEARCH_DIRTY },
{ SettingsManager::TAB_PM_DIRTY, ResourceManager::SETTINGS_TAB_PM_DIRTY },
{ SettingsManager::DEBUG_DIRTY, ResourceManager::SETTINGS_DEBUG_DIRTY },
{ SettingsManager::SYSTEM_LOG_DIRTY, ResourceManager::SETTINGS_SYSTEM_LOG_DIRTY },
{ SettingsManager::HUB_BOLD_TABS, ResourceManager::HUB_BOLD_TABS },
{ SettingsManager::PM_BOLD_TABS, ResourceManager::PM_BOLD_TABS },
{ SettingsManager::TAB_SHOW_ICONS, ResourceManager::TAB_SHOW_ICONS },
{ 0, ResourceManager::SETTINGS_AUTO_AWAY }
};
FulTabsPage::clrs FulTabsPage::colors[] = {
{ ResourceManager::TAB_ACTIVE_BG, SettingsManager::TAB_ACTIVE_BG, 0 },
{ ResourceManager::TAB_ACTIVE_TEXT, SettingsManager::TAB_ACTIVE_TEXT, 0 },
{ ResourceManager::TAB_ACTIVE_BORDER, SettingsManager::TAB_ACTIVE_BORDER, 0 },
{ ResourceManager::TAB_INACTIVE_BG, SettingsManager::TAB_INACTIVE_BG, 0 },
{ ResourceManager::TAB_INACTIVE_TEXT, SettingsManager::TAB_INACTIVE_TEXT, 0 },
{ ResourceManager::TAB_INACTIVE_BORDER, SettingsManager::TAB_INACTIVE_BORDER, 0 },
{ ResourceManager::TAB_INACTIVE_BG_NOTIFY, SettingsManager::TAB_INACTIVE_BG_NOTIFY, 0 },
{ ResourceManager::TAB_INACTIVE_PM_NOTIFY, SettingsManager::TAB_INACTIVE_PM_NOTIFY, 0 },
{ ResourceManager::TAB_INACTIVE_HUB_NOTIFY, SettingsManager::TAB_INACTIVE_HUB_NOTIFY, 0 },
{ ResourceManager::TAB_INACTIVE_BG_DISCONNECTED, SettingsManager::TAB_INACTIVE_BG_DISCONNECTED, 0},
{ ResourceManager::TAB_INACTIVE_FL_BG, SettingsManager::TAB_INACTIVE_FL_BG, 0 },
};
LRESULT FulTabsPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
PropPage::read((HWND)*this, items, listItems, GetDlgItem(IDC_BOLD_BOOLEANS));
PropPage::translate((HWND)(*this), texts);
colorList.Attach(GetDlgItem(IDC_COLOR_COMBO));
ctrlTabPreview.Attach(GetDlgItem(IDC_SAMPLE_COLOR));
for(int i=0; i < sizeof(colors) / sizeof(clrs); i++){
colorList.AddString(Text::toT(ResourceManager::getInstance()->getString(colors[i].name)).c_str());
colors[i].value = SettingsManager::getInstance()->get((SettingsManager::IntSetting)colors[i].setting, true);
}
setForeColor(ctrlTabPreview, GetSysColor(COLOR_3DFACE));
colorList.SetCurSel(0);
BOOL bTmp;
onColorListChange(0, 0, 0, bTmp);
BOOL b;
onClickedBox(0, IDC_CH_BLEND, 0, b );
return TRUE;
}
void FulTabsPage::write() {
PropPage::write((HWND)*this, items, listItems, GetDlgItem(IDC_BOLD_BOOLEANS));
for(int i = 0; i < sizeof(colors) / sizeof(clrs); i++){
settings->set((SettingsManager::IntSetting)colors[i].setting, (int)colors[i].value);
}
}
LRESULT FulTabsPage::onColorButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
colorList.Attach(GetDlgItem(IDC_COLOR_COMBO));
int sel = colorList.GetCurSel();
COLORREF col;
CColorDialog dlg(colors[colorList.GetCurSel()].value, 0, *this);
if (dlg.DoModal() == IDOK) {
colors[colorList.GetCurSel()].value = dlg.GetColor();
switch(sel) {
case 0: col = dlg.GetColor(); break;
}
setForeColor(ctrlTabPreview, dlg.GetColor());
}
colorList.Detach();
return 0;
}
LRESULT FulTabsPage::onClickedBox(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
int button = 0;
//this seems utterly stupid now, but it's easier if i want/need to
//add more items in the future =)
switch(wID) {
case IDC_CH_BLEND: button = IDC_TAB_DIRTY_BLEND; break;
}
::EnableWindow( GetDlgItem(button), IsDlgButtonChecked(wID) == BST_CHECKED );
return TRUE;
}
LRESULT FulTabsPage::onHelp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_FULTABSPAGE);
return 0;
}
LRESULT FulTabsPage::onHelpInfo(LPNMHDR /*pnmh*/) {
HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_FULTABSPAGE);
return 0;
}
LRESULT FulTabsPage::onColorListChange(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
COLORREF color = colors[colorList.GetCurSel()].value;
setForeColor(ctrlTabPreview, color);
return S_OK;
}
/**
* @file
* $Id: FulTabsPage.cpp 63 2005-12-12 17:02:22Z crakter $
*/