linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02924
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2387: Add an address bar in file lists
------------------------------------------------------------
revno: 2387
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2011-01-10 22:49:08 +0100
message:
Add an address bar in file lists
modified:
changelog.txt
dwt/include/dwt/widgets/Rebar.h
dwt/src/widgets/Rebar.cpp
dwt/src/widgets/ToolBar.cpp
help/window_file_list.html
win32/DirectoryListingFrame.cpp
win32/DirectoryListingFrame.h
win32/MainWindow.cpp
win32/stdafx.cpp
--
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 'changelog.txt'
--- changelog.txt 2011-01-09 22:09:24 +0000
+++ changelog.txt 2011-01-10 21:49:08 +0000
@@ -68,6 +68,7 @@
* Save and restore the selected tab when re-opening (poy)
* Process file lists only when they first come into view (poy)
* [L#700594] Prevent multiple password dialogs and give them the hub title (poy)
+* [L#700593] Add an address bar in file lists (poy)
-- 0.770 2010-07-05 --
* [L#550300] Catch more potential file corruptions (thanks bigmuscle)
=== modified file 'dwt/include/dwt/widgets/Rebar.h'
--- dwt/include/dwt/widgets/Rebar.h 2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/widgets/Rebar.h 2011-01-10 21:49:08 +0000
@@ -89,9 +89,11 @@
*/
void refresh();
- void add(Widget* w, const tstring& text = tstring());
+ /** @param style see the REBARBANDINFO doc for possible values (fStyle section) */
+ void add(Widget* w, unsigned style = 0, const tstring& text = tstring());
void remove(Widget* w);
+ bool empty() const;
unsigned size() const;
protected:
=== modified file 'dwt/src/widgets/Rebar.cpp'
--- dwt/src/widgets/Rebar.cpp 2011-01-03 20:11:13 +0000
+++ dwt/src/widgets/Rebar.cpp 2011-01-10 21:49:08 +0000
@@ -36,7 +36,7 @@
const TCHAR Rebar::windowClass[] = REBARCLASSNAME;
Rebar::Seed::Seed() :
-BaseType::Seed(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | RBS_AUTOSIZE | RBS_VARHEIGHT, WS_EX_TOOLWINDOW)
+BaseType::Seed(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | RBS_AUTOSIZE | RBS_VARHEIGHT, WS_EX_CONTROLPARENT | WS_EX_TOOLWINDOW)
{
}
@@ -54,13 +54,13 @@
::MoveWindow(handle(), 0, 0, 0, 0, TRUE);
}
-void Rebar::add(Widget* w, const tstring& text) {
+void Rebar::add(Widget* w, unsigned style, const tstring& text) {
if(size() == 0)
setVisible(true);
w->addRemoveStyle(CCS_NORESIZE, true);
- REBARBANDINFO info = { sizeof(REBARBANDINFO), RBBIM_CHILD | RBBIM_CHILDSIZE };
+ REBARBANDINFO info = { sizeof(REBARBANDINFO), RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE, style };
if(!text.empty()) {
info.fMask |= RBBIM_TEXT;
@@ -89,6 +89,10 @@
setVisible(false);
}
+bool Rebar::empty() const {
+ return size() == 0;
+}
+
unsigned Rebar::size() const {
return sendMessage(RB_GETBANDCOUNT);
}
=== modified file 'dwt/src/widgets/ToolBar.cpp'
--- dwt/src/widgets/ToolBar.cpp 2011-01-03 20:11:13 +0000
+++ dwt/src/widgets/ToolBar.cpp 2011-01-10 21:49:08 +0000
@@ -77,8 +77,10 @@
}
Point ToolBar::getPreferredSize() {
- // don't care about the width
- return Point(0, HIWORD(sendMessage(TB_GETBUTTONSIZE)) + HIWORD(sendMessage(TB_GETPADDING)));
+ // get the rect of the last item
+ RECT rect;
+ sendMessage(TB_GETITEMRECT, size() - 1, reinterpret_cast<LPARAM>(&rect));
+ return Point(rect.right, rect.bottom - rect.top);
}
void ToolBar::addButton(const std::string& id, const IconPtr& icon, const IconPtr& hotIcon, const tstring& text, unsigned helpId,
=== modified file 'help/window_file_list.html'
--- help/window_file_list.html 2011-01-03 20:11:13 +0000
+++ help/window_file_list.html 2011-01-10 21:49:08 +0000
@@ -10,11 +10,7 @@
<img src="Directory.ico" width="16" height="16" alt="File List"/>
File List
</h1>
-<h2>Folder list (left)</h2>
-<p cshelp="IDH_FILE_LIST_DIRS">
-Folders available in the current file list. Left-click on a folder to show the contents of that folder in the window on the right; right-click to open a menu that allows you to download the whole folder.
-</p>
-<h3>Toolbar</h3>
+<h2>Toolbar</h2>
<dl style="margin-left: 40px;">
<dt><img src="Left.ico" width="16" height="16" alt="Back"/> Back</dt>
<dd cshelp="IDH_FILE_LIST_BACK">Switch to the previously visited directory. This command can also be accessed via the Backspace key and the Ctrl+Left keyboard shortcut.</dd>
@@ -23,6 +19,10 @@
<dt><img src="Up.ico" width="16" height="16" alt="Up one level"/> Up one level</dt>
<dd cshelp="IDH_FILE_LIST_UP">Switch to the parent directory. This command can also be accessed via the Ctrl+Up keyboard shortcut.</dd>
</dl>
+<h2>Folder list (left)</h2>
+<p cshelp="IDH_FILE_LIST_DIRS">
+Folders available in the current file list. Left-click on a folder to show the contents of that folder in the window on the right; right-click to open a menu that allows you to download the whole folder.
+</p>
<h2>Contents (right)</h2>
<p cshelp="IDH_FILE_LIST_FILES">
Shows the contents of the folder selected in the folder list (window on the left). Right-click to get menu options.
=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp 2011-01-09 15:38:35 +0000
+++ win32/DirectoryListingFrame.cpp 2011-01-10 21:49:08 +0000
@@ -35,6 +35,7 @@
#include <dcpp/ShareManager.h>
#include <dcpp/WindowInfo.h>
+#include <dwt/widgets/Rebar.h>
#include <dwt/widgets/ToolBar.h>
const string DirectoryListingFrame::id = "DirectoryListing";
@@ -172,6 +173,8 @@
DirectoryListingFrame::DirectoryListingFrame(TabViewPtr parent, const HintedUser& aUser, int64_t aSpeed) :
BaseType(parent, _T(""), IDH_FILE_LIST, IDI_DIRECTORY),
+ rebar(0),
+ pathBox(0),
grid(0),
dirs(0),
files(0),
@@ -198,40 +201,13 @@
grid->row(1).mode = GridInfo::STATIC;
grid->setSpacing(0);
- VSplitterPtr paned = grid->addChild(VSplitter::Seed(0.3));
-
{
- // create a container that will hold both the toolbar and the dir tree.
- ContainerPtr container = grid->addChild(Container::Seed(0, WS_EX_CONTROLPARENT));
-
- auto seed = ToolBar::Seed();
- seed.style &= ~CCS_ADJUSTABLE;
- ToolBarPtr toolbar = container->addChild(seed);
-
- StringList ids;
- auto addButton = [toolbar, &ids](unsigned icon, const tstring& text, unsigned helpId, const dwt::Dispatchers::VoidVoid<>::F& f) {
- ids.push_back(string(1, '0' + ids.size()));
- toolbar->addButton(ids.back(), WinUtil::toolbarIcon(icon), 0, text, helpId, f);
- };
- addButton(IDI_LEFT, T_("Back"), IDH_FILE_LIST_BACK, [this] { back(); });
- addButton(IDI_RIGHT, T_("Forward"), IDH_FILE_LIST_FORWARD, [this] { this->forward(); }); // explicit ns (vs std::forward)
- ids.push_back(string());
- addButton(IDI_UP, T_("Up one level"), IDH_FILE_LIST_UP, [this] { up(); });
- toolbar->setLayout(ids);
-
- dirs = container->addChild(WidgetDirs::Seed());
+ VSplitterPtr paned = grid->addChild(VSplitter::Seed(0.3));
+
+ dirs = grid->addChild(WidgetDirs::Seed());
dirs->setHelpId(IDH_FILE_LIST_DIRS);
addWidget(dirs);
-
- container->onSized([this, toolbar](const dwt::SizedEvent& e) {
- dwt::Rectangle r(e.size);
- toolbar->refresh();
- dwt::Point pt = toolbar->getWindowSize();
- r.pos.y += pt.y;
- r.size.y -= pt.y;
- dirs->layout(r);
- });
- paned->setFirst(container);
+ paned->setFirst(dirs);
dirs->setNormalImageList(WinUtil::fileImages);
dirs->onSelectionChanged(std::bind(&DirectoryListingFrame::handleSelectionChanged, this));
@@ -239,9 +215,7 @@
dirs->onSysKeyDown(std::bind(&DirectoryListingFrame::handleKeyDownDirs, this, _1));
dirs->onContextMenu(std::bind(&DirectoryListingFrame::handleDirsContextMenu, this, _1));
dirs->onXMouseUp(std::bind(&DirectoryListingFrame::handleXMouseUp, this, _1));
- }
- {
files = grid->addChild(WidgetFiles::Seed());
files->setHelpId(IDH_FILE_LIST_FILES);
addWidget(files);
@@ -314,6 +288,37 @@
searchGrid->setEnabled(false);
searchGrid->setVisible(false);
+ // create the rebar after the rest to make sure it doesn't grab the default focus.
+ rebar = addChild(Rebar::Seed());
+
+ {
+ auto seed = ToolBar::Seed();
+ seed.style &= ~CCS_ADJUSTABLE;
+ ToolBarPtr toolbar = addChild(seed);
+
+ StringList ids;
+ auto addButton = [toolbar, &ids](unsigned icon, const tstring& text, unsigned helpId, const dwt::Dispatchers::VoidVoid<>::F& f) {
+ ids.push_back(string(1, '0' + ids.size()));
+ toolbar->addButton(ids.back(), WinUtil::toolbarIcon(icon), 0, text, helpId, f);
+ };
+ addButton(IDI_LEFT, T_("Back"), IDH_FILE_LIST_BACK, [this] { back(); });
+ addButton(IDI_RIGHT, T_("Forward"), IDH_FILE_LIST_FORWARD, [this] { this->forward(); }); // explicit ns (vs std::forward)
+ ids.push_back(string());
+ addButton(IDI_UP, T_("Up one level"), IDH_FILE_LIST_UP, [this] { up(); });
+ toolbar->setLayout(ids);
+
+ rebar->add(toolbar, RBBS_NOGRIPPER);
+ }
+
+ pathBox = addChild(WinUtil::Seeds::comboBoxEdit);
+ pathBox->getTextBox()->setReadOnly();
+ addWidget(pathBox);
+ pathBox->onSelectionChanged([this] { selectItem(Text::toT(history[pathBox->getSelected()])); });
+
+ rebar->add(pathBox, RBBS_NOGRIPPER);
+
+ rebar->sendMessage(RB_MINIMIZEBAND); // minimize the toolbar band and maximize the path box
+
initStatus();
status->setSize(STATUS_FILE_LIST_DIFF, listDiff->getPreferredSize().x);
@@ -366,6 +371,11 @@
void DirectoryListingFrame::layout() {
dwt::Rectangle r(getClientSize());
+ rebar->refresh();
+ dwt::Point pt = rebar->getWindowSize();
+ r.pos.y += pt.y;
+ r.size.y -= pt.y;
+
status->layout(r);
status->mapWidget(STATUS_FILE_LIST_DIFF, listDiff);
@@ -844,6 +854,9 @@
}
void DirectoryListingFrame::handleSelectionChanged() {
+ if(!loaded)
+ return;
+
ItemInfo* ii = dirs->getSelectedData();
if(!ii) {
return;
@@ -853,9 +866,16 @@
if(d == 0) {
return;
}
+
HoldRedraw hold(files);
changeDir(d);
+
addHistory(dl->getPath(d));
+
+ pathBox->clear();
+ for(auto i = history.cbegin(), iend = history.cend(); i != iend; ++i)
+ pathBox->addValue(i->empty() ? getText() : Text::toT(*i));
+ pathBox->setSelected(historyIndex - 1);
}
void DirectoryListingFrame::changeDir(DirectoryListing::Directory* d) {
@@ -915,7 +935,7 @@
void DirectoryListingFrame::back() {
if(history.size() > 1 && historyIndex > 1) {
size_t n = min(historyIndex, history.size()) - 1;
- deque<string> tmp = history;
+ auto tmp = history;
selectItem(Text::toT(history[n - 1]));
historyIndex = n;
history = tmp;
@@ -925,7 +945,7 @@
void DirectoryListingFrame::forward() {
if(history.size() > 1 && historyIndex < history.size()) {
size_t n = min(historyIndex, history.size() - 1);
- deque<string> tmp = history;
+ auto tmp = history;
selectItem(Text::toT(history[n]));
historyIndex = n + 1;
history = tmp;
=== modified file 'win32/DirectoryListingFrame.h'
--- win32/DirectoryListingFrame.h 2011-01-09 15:38:35 +0000
+++ win32/DirectoryListingFrame.h 2011-01-10 21:49:08 +0000
@@ -157,6 +157,9 @@
tstring columns[COLUMN_LAST];
};
+ RebarPtr rebar;
+ ComboBoxPtr pathBox;
+
GridPtr grid;
typedef TypedTree<ItemInfo> WidgetDirs;
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2011-01-09 22:09:24 +0000
+++ win32/MainWindow.cpp 2011-01-10 21:49:08 +0000
@@ -867,7 +867,7 @@
void MainWindow::layout() {
dwt::Rectangle r(getClientSize());
- if(rebar->size() > 0) {
+ if(!rebar->empty()) {
rebar->refresh();
dwt::Point pt = rebar->getWindowSize();
r.pos.y += pt.y;
=== modified file 'win32/stdafx.cpp'
--- win32/stdafx.cpp 2010-02-11 21:44:13 +0000
+++ win32/stdafx.cpp 2011-01-10 21:49:08 +0000
@@ -17,3 +17,18 @@
*/
#include "stdafx.h"
+
+#if defined(__GNUC__)
+#if __GNUC__ <= 4 && __GNUC_MINOR__ <= 5 && __GNUC_PATCHLEVEL__ < 1
+#error GCC 4.5.1 is required
+#endif
+
+#elif defined(_MSC_VER)
+#if _MSC_VER < 1600
+#error MSVC 10 (2010) is required
+#endif
+
+#else
+#error No supported compiler found
+
+#endif