=== modified file 'dcpp/SettingsManager.cpp' --- dcpp/SettingsManager.cpp 2011-02-01 20:32:13 +0000 +++ dcpp/SettingsManager.cpp 2011-02-05 12:12:18 +0000 @@ -90,7 +90,7 @@ "BandwidthLimitStart", "BandwidthLimitEnd", "TimeDependentThrottle", "MaxDownloadSpeedRealTime", "MaxUploadSpeedTime", "MaxDownloadSpeedPrimary", "MaxUploadSpeedPrimary", "SlotsAlternateLimiting", "SlotsPrimaryLimiting", - "AutoDetectIncomingConnection", "SettingsSaveInterval", + "AutoDetectIncomingConnection", "SettingsSaveInterval", "FavoriteColor", "OpColor", "NormalColor", "BotColor", "SENTRY", // Int64 "TotalUpload", "TotalDownload", @@ -320,6 +320,10 @@ setDefault(MAIN_WINDOW_POS_Y, CW_USEDEFAULT); setDefault(UPLOAD_BAR_COLOR, RGB(205, 60, 55)); setDefault(DOWNLOAD_BAR_COLOR, RGB(55, 170, 85)); + setDefault(FAVORITE_COLOR, RGB(255, 255, 0)); + setDefault(OP_COLOR, RGB(30, 144, 255)); + setDefault(NORMAL_COLOR, RGB(255, 0, 255)); + setDefault(BOT_COLOR, RGB(128, 128, 0)); #endif } === modified file 'dcpp/SettingsManager.h' --- dcpp/SettingsManager.h 2011-01-02 17:12:02 +0000 +++ dcpp/SettingsManager.h 2011-02-05 12:12:18 +0000 @@ -109,7 +109,7 @@ BANDWIDTH_LIMIT_START, BANDWIDTH_LIMIT_END, TIME_DEPENDENT_THROTTLE, MAX_DOWNLOAD_SPEED_ALTERNATE, MAX_UPLOAD_SPEED_ALTERNATE, MAX_DOWNLOAD_SPEED_MAIN, MAX_UPLOAD_SPEED_MAIN, SLOTS_ALTERNATE_LIMITING, SLOTS_PRIMARY, - AUTO_DETECT_CONNECTION, SETTINGS_SAVE_INTERVAL, + AUTO_DETECT_CONNECTION, SETTINGS_SAVE_INTERVAL, FAVORITE_COLOR, OP_COLOR, NORMAL_COLOR, BOT_COLOR, INT_LAST }; enum Int64Setting { INT64_FIRST = INT_LAST + 1, === added file 'win32/ColorsPage.cpp' --- win32/ColorsPage.cpp 1970-01-01 00:00:00 +0000 +++ win32/ColorsPage.cpp 2011-02-05 12:11:57 +0000 @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point 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 "resource.h" + +#include "ColorsPage.h" + +#include + +#include "WinUtil.h" + + +ColorsPage::ColorsPage(dwt::Widget* parent) : +PropPage(parent), +grid(0) +{ + + grid = addChild(Grid::Seed(4, 1)); + grid->column(0).mode = GridInfo::FILL; + grid->row(0).mode = GridInfo::AUTO; + grid->row(0).align = GridInfo::STRETCH; + + + { + GridPtr colors = grid->addChild(GroupBox::Seed(T_("Userlist Colors")))->addChild(Grid::Seed(2, 4)); + colors->column(0).mode = GridInfo::FILL; + colors->column(0).align = GridInfo::STRETCH; + colors->column(1).mode = GridInfo::FILL; + colors->column(1).align = GridInfo::STRETCH; + colors->column(2).mode = GridInfo::FILL; + colors->column(2).align = GridInfo::STRETCH; + colors->column(3).mode = GridInfo::FILL; + colors->column(3).align = GridInfo::STRETCH; + + ButtonPtr favUserCol = colors->addChild(Button::Seed(T_("Favorite Users"))); + favUserCol->onClicked(std::bind(&ColorsPage::handleFUClicked, this)); + + ButtonPtr opUserCol = colors->addChild(Button::Seed(T_("Operators"))); + opUserCol->onClicked(std::bind(&ColorsPage::handleOPClicked, this)); + + ButtonPtr nmUserCol = colors->addChild(Button::Seed(T_("Normal Users"))); + nmUserCol->onClicked(std::bind(&ColorsPage::handleNMClicked, this)); + + ButtonPtr botUserCol = colors->addChild(Button::Seed(T_("Bots"))); + botUserCol->onClicked(std::bind(&ColorsPage::handleBTClicked, this)); + } + + favCol = SETTING(FAVORITE_COLOR); + opCol = SETTING(OP_COLOR); + nmCol = SETTING(NORMAL_COLOR); + botCol = SETTING(BOT_COLOR); + +} + +ColorsPage::~ColorsPage() { +} + +void ColorsPage::layout(const dwt::Rectangle& rc) { + PropPage::layout(rc); + + dwt::Point clientSize = getClientSize(); + grid->layout(dwt::Rectangle(7, 4, clientSize.x - 14, clientSize.y - 21)); +} + +void ColorsPage::write() +{ + SettingsManager* settings = SettingsManager::getInstance(); + + settings->set(SettingsManager::FAVORITE_COLOR, (int)favCol); + settings->set(SettingsManager::OP_COLOR, (int)opCol); + settings->set(SettingsManager::NORMAL_COLOR, (int)nmCol); + settings->set(SettingsManager::BOT_COLOR, (int)botCol); +} + +void ColorsPage::handleFUClicked() { + ColorDialog::ColorParams colorParams(favCol); + if(ColorDialog(this).open(colorParams)) { + favCol = colorParams.getColor(); + } +} + +void ColorsPage::handleOPClicked() { + ColorDialog::ColorParams colorParams(opCol); + if(ColorDialog(this).open(colorParams)) { + opCol = colorParams.getColor(); + } +} + +void ColorsPage::handleNMClicked() { + ColorDialog::ColorParams colorParams(nmCol); + if(ColorDialog(this).open(colorParams)) { + nmCol = colorParams.getColor(); + } +} + +void ColorsPage::handleBTClicked() { + ColorDialog::ColorParams colorParams(botCol); + if(ColorDialog(this).open(colorParams)) { + botCol = colorParams.getColor(); + } +} === added file 'win32/ColorsPage.h' --- win32/ColorsPage.h 1970-01-01 00:00:00 +0000 +++ win32/ColorsPage.h 2011-02-05 12:11:57 +0000 @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point 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. + */ + +#ifndef DCPLUSPLUS_WIN32_COLORS_PAGE_H +#define DCPLUSPLUS_WIN32_COLORS_PAGE_H + +#include "PropPage.h" + +class ColorsPage : public PropPage +{ +public: + ColorsPage(dwt::Widget* parent); + virtual ~ColorsPage(); + + virtual void layout(const dwt::Rectangle& rect); + virtual void write(); + +private: + + GridPtr grid; + + COLORREF favCol, opCol, nmCol, botCol; + + void handleFUClicked(); + void handleOPClicked(); + void handleNMClicked(); + void handleBTClicked(); +}; + +#endif // !defined(DCPLUSPLUS_WIN32_COLORS_PAGE_H) === modified file 'win32/HubFrame.cpp' --- win32/HubFrame.cpp 2011-02-02 17:45:47 +0000 +++ win32/HubFrame.cpp 2011-02-05 12:11:58 +0000 @@ -166,6 +166,7 @@ users->onDblClicked(std::bind(&HubFrame::handleDoubleClickUsers, this)); users->onKeyDown(std::bind(&HubFrame::handleUsersKeyDown, this, _1)); users->onContextMenu(std::bind(&HubFrame::handleUsersContextMenu, this, _1)); + users->onRaw(std::bind(&HubFrame::handleCustomDraw, this, _1, _2), dwt::Message(WM_NOTIFY, NM_CUSTOMDRAW)); prepareUserList(users, true); @@ -1397,3 +1398,35 @@ HubFrame::UserInfoList HubFrame::selectedUsersImpl() const { return showUsers->getChecked() ? usersFromTable(users) : (currentUser ? UserInfoList(1, currentUser) : UserInfoList()); } + +LRESULT HubFrame::handleCustomDraw(WPARAM wParam, LPARAM lParam) { + LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam; + int item = (int)cd->nmcd.dwItemSpec; + + switch(cd->nmcd.dwDrawStage) { + case CDDS_PREPAINT: + return CDRF_NOTIFYITEMDRAW; + + case CDDS_ITEMPREPAINT: + + if(cd->nmcd.hdr.hwndFrom == users->handle() ) { + + RECT r; + ListView_GetItemRect( users->handle(), item, &r, LVIR_BOUNDS ); + + UserInfo* ui = reinterpret_cast(cd->nmcd.lItemlParam); + if (ui->getIdentity().isBot()) { + cd->clrText = SETTING(BOT_COLOR); + } else if (FavoriteManager::getInstance()->isFavoriteUser(ui->getUser())) { + cd->clrText = SETTING(FAVORITE_COLOR); + } else if (ui->getIdentity().isOp()) { + cd->clrText = SETTING(OP_COLOR); + } else { + cd->clrText = SETTING(NORMAL_COLOR); + } + return CDRF_NEWFONT; + } + default: + return CDRF_DODEFAULT; + } +} === modified file 'win32/HubFrame.h' --- win32/HubFrame.h 2011-02-02 17:45:47 +0000 +++ win32/HubFrame.h 2011-02-05 12:11:58 +0000 @@ -287,6 +287,8 @@ virtual void on(NickTaken, Client*) throw(); virtual void on(SearchFlood, Client*, const string&) throw(); void onStatusMessage(const string& line, int flags); + + LRESULT handleCustomDraw(WPARAM wParam, LPARAM lParam); }; #endif // !defined(HUB_FRAME_H) === modified file 'win32/MainWindow.cpp' --- win32/MainWindow.cpp 2011-02-02 17:45:47 +0000 +++ win32/MainWindow.cpp 2011-02-05 12:11:59 +0000 @@ -998,6 +998,8 @@ if(SETTING(SETTINGS_SAVE_INTERVAL) != lastSettingsSave) setSaveTimer(); + + HubFrame::resortUsers(); // Redraw the UserList on IDOK } } === modified file 'win32/SettingsDialog.cpp' --- win32/SettingsDialog.cpp 2011-01-02 17:12:02 +0000 +++ win32/SettingsDialog.cpp 2011-02-05 12:12:00 +0000 @@ -42,6 +42,7 @@ #include "BandwidthLimitPage.h" #include "SearchTypesPage.h" #include "ProxyPage.h" +#include "ColorsPage.h SettingsDialog::SettingsDialog(dwt::Widget* parent) : dwt::ModalDialog(parent), @@ -128,6 +129,7 @@ { HTREEITEM item = addPage(T_("Appearance"), new AppearancePage(cur)); addPage(T_("Colors and sounds"), new Appearance2Page(cur), item); + addPage(T_("Userlist coloring"), new ColorsPage(cur), item); addPage(T_("Tabs"), new TabsPage(cur), item); addPage(T_("Windows"), new WindowsPage(cur), item); }