------------------------------------------------------------ revno: 3233 committer: poy <p...@123gen.com> branch nick: trunk timestamp: Fri 2013-03-22 17:30:58 +0100 message: add some icons in the transfer list modified: win32/TransferView.cpp win32/TransferView.h win32/WinUtil.cpp win32/WinUtil.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 'win32/TransferView.cpp' --- win32/TransferView.cpp 2013-03-22 15:34:41 +0000 +++ win32/TransferView.cpp 2013-03-22 16:30:58 +0000 @@ -59,17 +59,15 @@ TransferView::TransferView(dwt::Widget* parent, TabViewPtr mdi_) : dwt::Container(parent), transfers(0), - mdi(mdi_) + mdi(mdi_), + downloadIcon(WinUtil::createIcon(IDI_DOWNLOAD, 16)), + uploadIcon(WinUtil::createIcon(IDI_UPLOAD, 16)) { create(); setHelpId(IDH_TRANSFERS); transfers = addChild(WidgetTransfers::Seed(WinUtil::Seeds::table)); - /*arrows = new dwt::ImageList(dwt::Point(16, 16)); - arrows->add(*WinUtil::createIcon(IDI_DOWNLOAD, 16)); - arrows->add(*WinUtil::createIcon(IDI_UPLOAD, 16)); - transfers->setSmallImageList(arrows);*/ transfers->setSmallImageList(WinUtil::fileImages); WinUtil::makeColumns(transfers, columns, COLUMN_LAST, SETTING(TRANSFERS_ORDER), SETTING(TRANSFERS_WIDTHS)); @@ -151,7 +149,7 @@ } int64_t TransferView::ItemInfo::timeleft() const { - return speed == 0 ? 0 : (size - transferred) / speed; + return speed == 0 ? 0 : static_cast<double>(size - transferred) / speed; } TransferView::ConnectionInfo::ConnectionInfo(const HintedUser& u, TransferInfo& parent) : @@ -173,6 +171,10 @@ return other.parent.download == parent.download && other.getUser() == getUser(); } +int TransferView::ConnectionInfo::getImage(int col) const { + return col == COLUMN_FILE ? WinUtil::TRANSFER_ICON_USER : ItemInfo::getImage(col); +} + void TransferView::ConnectionInfo::update(const UpdateInfo& ui) { if(ui.updateMask & UpdateInfo::MASK_FILE) { if(ui.path != parent.path) { @@ -266,7 +268,7 @@ } int TransferView::TransferInfo::getImage(int col) const { - return col == COLUMN_FILE ? WinUtil::getFileIcon(path) : -1; + return col == COLUMN_FILE ? WinUtil::getFileIcon(path) : ItemInfo::getImage(col); } void TransferView::TransferInfo::update() { @@ -440,7 +442,9 @@ } } -namespace { void drawProgress(HDC hdc, const dwt::Rectangle& rcItem, int item, int column, const tstring& text, double pos, bool download) { +namespace { void drawProgress(HDC hdc, const dwt::Rectangle& rcItem, int item, int column, + const dwt::IconPtr& icon, const tstring& text, double pos, bool download) +{ // draw something nice... COLORREF barBase = download ? SETTING(DOWNLOAD_BG_COLOR) : SETTING(UPLOAD_BG_COLOR); COLORREF bgBase = WinUtil::bgColor; @@ -473,6 +477,19 @@ rc.size.x -= 2; rc.size.y -= 1; + { + // draw the icon then shift the rect. + const long iconSize = 16; + const long iconTextSpace = 2; + + dwt::Rectangle iconRect { rc.left(), rc.top() + std::max(rc.height() - iconSize, 0L) / 2, iconSize, iconSize }; + + canvas.drawIcon(icon, iconRect); + + rc.pos.x += iconSize + iconTextSpace; + rc.size.x -= iconSize + iconTextSpace; + } + dwt::Rectangle textRect; { @@ -549,8 +566,10 @@ auto connInfo = dynamic_cast<const ConnectionInfo*>(&info); if((!connInfo || connInfo->status == ConnectionInfo::STATUS_RUNNING) && info.size > 0 && info.transferred >= 0) { int item = static_cast<int>(data.nmcd.dwItemSpec); - drawProgress(data.nmcd.hdc, transfers->getRect(item, col, LVIR_BOUNDS), item, col, info.getText(col), - static_cast<double>(info.transferred) / static_cast<double>(info.size), info.transfer().download); + drawProgress(data.nmcd.hdc, transfers->getRect(item, col, LVIR_BOUNDS), item, col, + info.transfer().download ? downloadIcon : uploadIcon, info.getText(col), + static_cast<double>(info.transferred) / static_cast<double>(info.size), + info.transfer().download); return CDRF_SKIPDEFAULT; } } === modified file 'win32/TransferView.h' --- win32/TransferView.h 2013-03-22 14:59:39 +0000 +++ win32/TransferView.h 2013-03-22 16:30:58 +0000 @@ -79,11 +79,6 @@ REMOVE_CONNECTION }; - enum { - IMAGE_DOWNLOAD = 0, - IMAGE_UPLOAD - }; - struct TransferInfo; struct UpdateInfo; @@ -120,6 +115,8 @@ bool operator==(const ConnectionInfo& other) const; + int getImage(int col) const; + void update(const UpdateInfo& ui); TransferInfo& transfer(); @@ -209,7 +206,9 @@ objects stored by this container, hence the std::list. */ TabViewPtr mdi; - dwt::ImageListPtr arrows; + + const dwt::IconPtr downloadIcon; + const dwt::IconPtr uploadIcon; bool startup; === modified file 'win32/WinUtil.cpp' --- win32/WinUtil.cpp 2013-02-03 22:26:48 +0000 +++ win32/WinUtil.cpp 2013-03-22 16:30:58 +0000 @@ -106,14 +106,14 @@ dwt::FontPtr WinUtil::font; dwt::FontPtr WinUtil::uploadFont; dwt::FontPtr WinUtil::downloadFont; -unordered_map<string, dwt::FontPtr> WinUtil::userMatchFonts; +decltype(WinUtil::userMatchFonts) WinUtil::userMatchFonts; dwt::ImageListPtr WinUtil::fileImages; dwt::ImageListPtr WinUtil::userImages; +decltype(WinUtil::fileIndexes) WinUtil::fileIndexes; TStringList WinUtil::lastDirs; MainWindow* WinUtil::mainWindow = 0; bool WinUtil::urlDcADCRegistered = false; bool WinUtil::urlMagnetRegistered = false; -WinUtil::ImageMap WinUtil::fileIndexes; DWORD WinUtil::helpCookie = 0; tstring WinUtil::helpPath; StringList WinUtil::helpTexts; @@ -200,6 +200,9 @@ // add the generic file icon (FILE_ICON_GENERIC). fileImages->add(*createIcon(IDI_FILE, 16)); + // add icons used by the transfer list (TRANSFER_ICON_*). + fileImages->add(*createIcon(IDI_USER, 16)); + { const dwt::Point size(16, 16); userImages = dwt::ImageListPtr(new dwt::ImageList(size)); === modified file 'win32/WinUtil.h' --- win32/WinUtil.h 2013-01-21 18:43:48 +0000 +++ win32/WinUtil.h 2013-03-22 16:30:58 +0000 @@ -82,11 +82,14 @@ class WinUtil { public: // pre-defined icon indexes used by the "fileImages" image list - see also getFileIcon. + // also contains icons used by the transfer list. enum { DIR_ICON, DIR_ICON_INCOMPLETE, - FILE_ICON_GENERIC + FILE_ICON_GENERIC, + + TRANSFER_ICON_USER }; // icon indexes to use with the "userImages" image list. @@ -138,12 +141,10 @@ static tstring commands; static dwt::ImageListPtr fileImages; static dwt::ImageListPtr userImages; + static unordered_map<string, size_t> fileIndexes; static TStringList lastDirs; static MainWindow* mainWindow; - typedef unordered_map<string, size_t> ImageMap; - static ImageMap fileIndexes; - struct Seeds { static const Button::Seed button; static const ComboBox::Seed comboBox;
_______________________________________________ Mailing list: https://launchpad.net/~linuxdcpp-team Post to : linuxdcpp-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~linuxdcpp-team More help : https://help.launchpad.net/ListHelp