From: <arn...@us...> - 2007-11-29 23:02:49
|
Revision: 914 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=914&view=rev Author: arnetheduck Date: 2007-11-29 15:02:47 -0800 (Thu, 29 Nov 2007) Log Message: ----------- patches Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/MainWindow.cpp dcplusplus/trunk/win32/MainWindow.h dcplusplus/trunk/win32/PublicHubsFrame.cpp dcplusplus/trunk/win32/PublicHubsFrame.h dcplusplus/trunk/win32/SearchFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/changelog.txt 2007-11-29 23:02:47 UTC (rev 914) @@ -14,6 +14,8 @@ * Fixed some msvc compile issues (thanks james ross) * Fixed key handling in file listings (poy) * Message always focused first in chats (poy) +* Fixed filter in public hubs (thanks poy) +* Fixed missing title changes on tab change (thanks poy) -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-11-29 23:02:47 UTC (rev 914) @@ -2,6 +2,7 @@ #define WIDGETTABVIEW_H_ #include "WidgetTabSheet.h" +#include "WidgetWindow.h" #include "../WindowClass.h" #include <list> #include <vector> @@ -30,24 +31,27 @@ /// Fills with default parameters Seed(); }; - - template<typename T> - void add(T* w, const IconPtr& icon) { + + void add(WidgetChildWindow* w, const IconPtr& icon) { addWidget(w, icon, w->getText(), w->getVisible()); w->onTextChanging(std::tr1::bind(&WidgetTabView::handleTextChanging, this, w, _1)); } - void mark(Widget* w); + void mark(WidgetChildWindow* w); - void remove(Widget* w); + void remove(WidgetChildWindow* w); void next(bool reverse = false); - Widget* getActive(); - void setActive(Widget* w) { setActive(findTab(w)); } - - void onTabContextMenu(Widget* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f); + WidgetChildWindow* getActive(); + void setActive(WidgetChildWindow* w) { setActive(findTab(w)); } + void onTitleChanged(const std::tr1::function<void (const SmartUtil::tstring&)>& f) { + titleChangedFunction = f; + } + + void onTabContextMenu(WidgetChildWindow* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f); + bool filter(const MSG& msg); WidgetTabSheet::ObjectType getTab(); @@ -68,8 +72,8 @@ private: enum { MAX_TITLE_LENGTH = 20 }; struct TabInfo { - TabInfo(Widget* w_) : w(w_) { } - Widget* w; + TabInfo(WidgetChildWindow* w_) : w(w_) { } + WidgetChildWindow* w; std::tr1::function<bool (const ScreenCoordinate& pt)> handleContextMenu; }; @@ -77,24 +81,26 @@ WidgetTabSheet::ObjectType tab; + std::tr1::function<void (const SmartUtil::tstring&)> titleChangedFunction; + bool inTab; - typedef std::list<Widget*> WindowList; + typedef std::list<WidgetChildWindow*> WindowList; typedef WindowList::iterator WindowIter; WindowList viewOrder; Rectangle clientSize; std::vector<IconPtr> icons; int active; - int findTab(Widget* w); + int findTab(WidgetChildWindow* w); void setActive(int i); - TabInfo* getTabInfo(Widget* w); + TabInfo* getTabInfo(WidgetChildWindow* w); TabInfo* getTabInfo(int i); - void setTop(Widget* w); + void setTop(WidgetChildWindow* w); - bool handleTextChanging(Widget* w, const SmartUtil::tstring& newText); + bool handleTextChanging(WidgetChildWindow* w, const SmartUtil::tstring& newText); bool handleSized(const WidgetSizedEventResult&); void handleTabSelected(); bool handleContextMenu(SmartWin::ScreenCoordinate pt); @@ -103,8 +109,8 @@ void layout(); int addIcon(const IconPtr& icon); - void addWidget(Widget* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible); - void swapWidgets(Widget* oldW, Widget* newW); + void addWidget(WidgetChildWindow* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible); + void swapWidgets(WidgetChildWindow* oldW, WidgetChildWindow* newW); }; inline WidgetTabSheet::ObjectType WidgetTabView::getTab() Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -33,7 +33,7 @@ tab->onContextMenu(std::tr1::bind(&WidgetTabView::handleContextMenu, this, _1)); } -void WidgetTabView::addWidget(Widget* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible) { +void WidgetTabView::addWidget(WidgetChildWindow* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible) { int image = addIcon(icon); size_t tabs = tab->size(); TabInfo* ti = new TabInfo(w); @@ -53,17 +53,17 @@ layout(); } -Widget* WidgetTabView::getActive() { +WidgetChildWindow* WidgetTabView::getActive() { TabInfo* ti = getTabInfo(tab->getSelectedIndex()); return ti ? ti->w : 0; } -void WidgetTabView::remove(Widget* w) { +void WidgetTabView::remove(WidgetChildWindow* w) { if(viewOrder.size() > 1 && viewOrder.back() == w) { setActive(*(--(--viewOrder.end()))); } - Widget* cur = getTabInfo(tab->getSelectedIndex())->w; + WidgetChildWindow* cur = getTabInfo(tab->getSelectedIndex())->w; viewOrder.remove(w); @@ -74,9 +74,13 @@ layout(); } active = findTab(cur); + + // when no tab is opened + if(titleChangedFunction && (active == -1)) + titleChangedFunction(SmartUtil::tstring()); } -void WidgetTabView::onTabContextMenu(Widget* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f) { +void WidgetTabView::onTabContextMenu(WidgetChildWindow* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f) { TabInfo* ti = getTabInfo(w); if(ti) { ti->handleContextMenu = f; @@ -91,7 +95,7 @@ handleTabSelected(); } -void WidgetTabView::swapWidgets(Widget* oldW, Widget* newW) { +void WidgetTabView::swapWidgets(WidgetChildWindow* oldW, WidgetChildWindow* newW) { sendMessage(WM_SETREDRAW, FALSE); if(oldW) { @@ -126,16 +130,19 @@ setTop(ti->w); active = i; tab->setHighlight(i, false); + + if(titleChangedFunction) + titleChangedFunction(ti->w->getText()); } -void WidgetTabView::mark(Widget* w) { +void WidgetTabView::mark(WidgetChildWindow* w) { int i = findTab(w); if(i != -1 && i != tab->getSelectedIndex()) { tab->setHighlight(i, true); } } -int WidgetTabView::findTab(Widget* w) { +int WidgetTabView::findTab(WidgetChildWindow* w) { for(size_t i = 0; i < tab->size(); ++i) { if(getTabInfo(i)->w == w) { return static_cast<int>(i); @@ -144,7 +151,7 @@ return -1; } -WidgetTabView::TabInfo* WidgetTabView::getTabInfo(Widget* w) { +WidgetTabView::TabInfo* WidgetTabView::getTabInfo(WidgetChildWindow* w) { return getTabInfo(findTab(w)); } @@ -152,11 +159,14 @@ return i == -1 ? 0 : reinterpret_cast<TabInfo*>(tab->getData(i)); } -bool WidgetTabView::handleTextChanging(Widget* w, const SmartUtil::tstring& newText) { +bool WidgetTabView::handleTextChanging(WidgetChildWindow* w, const SmartUtil::tstring& newText) { int i = findTab(w); if(i != -1) { tab->setHeader(i, cutTitle(newText)); layout(); + + if(titleChangedFunction) + titleChangedFunction(newText); } return true; } @@ -195,7 +205,7 @@ if(viewOrder.size() < 2) { return; } - Widget* wnd = getActive(); + WidgetChildWindow* wnd = getActive(); if(!wnd) { return; } @@ -230,7 +240,7 @@ return; } -void WidgetTabView::setTop(Widget* wnd) { +void WidgetTabView::setTop(WidgetChildWindow* wnd) { WindowIter i = std::find(viewOrder.begin(), viewOrder.end(), wnd); if(i != viewOrder.end() && i != --viewOrder.end()) { viewOrder.erase(i); Modified: dcplusplus/trunk/win32/MDIChildFrame.h =================================================================== --- dcplusplus/trunk/win32/MDIChildFrame.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/MDIChildFrame.h 2007-11-29 23:02:47 UTC (rev 914) @@ -66,6 +66,7 @@ onSized(std::tr1::bind(&ThisType::handleSized, this, _1)); onActivate(std::tr1::bind(&ThisType::handleActivate, this, _1)); onCommand(std::tr1::bind(&ThisType::close, this, true), IDC_CLOSE_WINDOW); + addDlgCodeMessage(this); } virtual ~MDIChildFrame() { @@ -90,7 +91,10 @@ template<typename W> void addWidget(W* widget, bool alwaysFocus = false) { + addDlgCodeMessage(widget); + addColor(widget); + if(alwaysFocus || (lastFocus == NULL)) { lastFocus = widget->handle(); ::SetFocus(lastFocus); @@ -122,7 +126,19 @@ bool alwaysSameFocus; // always focus the same widget bool reallyClose; - + + void addDlgCodeMessage(SmartWin::WidgetComboBox* widget) { + widget->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); + SmartWin::WidgetTextBox* text = widget->getTextBox(); + if(text) + text->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); + } + + template<typename W> + void addDlgCodeMessage(W* widget) { + widget->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); + } + void addColor(SmartWin::WidgetComboBox* widget) { widget->onBackgroundColor(std::tr1::bind(&ThisType::handleBackgroundColor, this, _1)); SmartWin::WidgetTextBox* text = widget->getTextBox(); @@ -156,7 +172,13 @@ lastFocus = focus; } } - + + LRESULT handleGetDlgCode(WPARAM wParam) { + if(wParam != VK_TAB) + return DLGC_WANTMESSAGE; + return 0; + } + SmartWin::BrushPtr handleBackgroundColor(SmartWin::Canvas& canvas) { canvas.setBkColor(WinUtil::bgColor); canvas.setTextColor(WinUtil::textColor); Modified: dcplusplus/trunk/win32/MainWindow.cpp =================================================================== --- dcplusplus/trunk/win32/MainWindow.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/MainWindow.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -309,6 +309,7 @@ WidgetTabView::Seed cs; cs.style = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE; tabs = createTabView(cs); + tabs->onTitleChanged(std::tr1::bind(&MainWindow::handleTabsTitleChanged, this, _1)); paned->setFirst(tabs); } @@ -327,7 +328,7 @@ return true; } - SmartWin::Widget* active = getMDIParent()->getActive(); + SmartWin::WidgetChildWindow* active = getMDIParent()->getActive(); if(active) { if(::IsDialogMessage( active->handle(), & msg )) { return true; @@ -337,6 +338,10 @@ return false; } +void MainWindow::handleTabsTitleChanged(const SmartUtil::tstring& title) { + setText(title.empty() ? _T(APPNAME) _T(" ") _T(VERSIONSTRING) : _T(APPNAME) _T(" ") _T(VERSIONSTRING) _T(" - [") + title + _T("]")); +} + void MainWindow::handleExit() { close(true); } @@ -788,7 +793,7 @@ void MainWindow::handleActivate(bool active) { // Forward to active tab window - Widget* w = tabs->getActive(); + WidgetChildWindow* w = tabs->getActive(); if(w) { w->sendMessage(WM_ACTIVATE, active ? WA_ACTIVE : WA_INACTIVE); } Modified: dcplusplus/trunk/win32/MainWindow.h =================================================================== --- dcplusplus/trunk/win32/MainWindow.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/MainWindow.h 2007-11-29 23:02:47 UTC (rev 914) @@ -169,6 +169,8 @@ LRESULT trayMessage(WPARAM wParam, LPARAM lParam); LRESULT handleCopyData(WPARAM wParam, LPARAM lParam); LRESULT handleWhereAreYou(WPARAM wParam, LPARAM lParam); + + void handleTabsTitleChanged(const SmartUtil::tstring& title); void layout(); bool eachSecond(); Modified: dcplusplus/trunk/win32/PublicHubsFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -153,6 +153,7 @@ pubLists->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::handleListSelChanged, this)); filterSel = createComboBox(WinUtil::Seeds::comboBoxStatic); + addWidget(filterSel); //populate the filter list with the column names for(int j=0; j<COLUMN_LAST; j++) { @@ -160,12 +161,14 @@ } filterSel->addValue(CTSTRING(ANY)); filterSel->setSelectedIndex(COLUMN_LAST); + filterSel->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::updateList, this)); } { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL; filter = createTextBox(cs); - filter->onChar(std::tr1::bind(&PublicHubsFrame::handleFilterChar, this, _1)); + addWidget(filter); + filter->onKeyDown(std::tr1::bind(&PublicHubsFrame::handleFilterKeyDown, this, _1)); } initStatus(); @@ -306,7 +309,7 @@ updateStatus(); } -HRESULT PublicHubsFrame::handleSpeaker(WPARAM wParam, LPARAM lParam) { +LRESULT PublicHubsFrame::handleSpeaker(WPARAM wParam, LPARAM lParam) { if((wParam == FINISHED) || (wParam == LOADED_FROM_CACHE)) { std::auto_ptr<tstring> x(reinterpret_cast<tstring*>(lParam)); entries = FavoriteManager::getInstance()->getPublicHubs(); @@ -516,13 +519,12 @@ } void PublicHubsFrame::handleListSelChanged() { - printf("x\n"); FavoriteManager::getInstance()->setHubList(pubLists->getSelectedIndex()); entries = FavoriteManager::getInstance()->getPublicHubs(); updateList(); } -bool PublicHubsFrame::handleFilterChar(int c) { +bool PublicHubsFrame::handleFilterKeyDown(int c) { if(c == VK_RETURN) { filterString = Text::fromT(filter->getText()); updateList(); Modified: dcplusplus/trunk/win32/PublicHubsFrame.h =================================================================== --- dcplusplus/trunk/win32/PublicHubsFrame.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/PublicHubsFrame.h 2007-11-29 23:02:47 UTC (rev 914) @@ -121,7 +121,7 @@ void layout(); bool preClosing(); void postClosing(); - HRESULT handleSpeaker(WPARAM wParam, LPARAM lParam); + LRESULT handleSpeaker(WPARAM wParam, LPARAM lParam); void handleConfigure(); void handleRefresh(); void handleConnect(); @@ -130,7 +130,7 @@ bool handleContextMenu(SmartWin::ScreenCoordinate pt); bool handleKeyDown(int c); void handleListSelChanged(); - bool handleFilterChar(int c); + bool handleFilterKeyDown(int c); bool checkNick(); void updateStatus(); Modified: dcplusplus/trunk/win32/SearchFrame.cpp =================================================================== --- dcplusplus/trunk/win32/SearchFrame.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/SearchFrame.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -71,12 +71,6 @@ (*i)->close(true); } -static HRESULT allKeys(WPARAM wParam, LPARAM) { - if(wParam != VK_TAB) - return DLGC_WANTMESSAGE; - return 0; -} - SearchFrame::SearchFrame(SmartWin::WidgetTabView* mdiParent, const tstring& initialString_, LONGLONG initialSize_, SearchManager::SizeModes initialMode_, SearchManager::TypeModes initialType_) : BaseType(mdiParent, TSTRING(SEARCH), SmartWin::IconPtr(new SmartWin::Icon(IDR_SEARCH))), searchLabel(0), @@ -132,7 +126,6 @@ for(TStringIter i = lastSearches.begin(); i != lastSearches.end(); ++i) { searchBox->insertValue(0, *i); } - searchBox->getTextBox()->onRaw(std::tr1::bind(&allKeys, _1, _2), SmartWin::Message(WM_GETDLGCODE)); searchBox->getTextBox()->onKeyDown(std::tr1::bind(&SearchFrame::handleSearchKeyDown, this, _1)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |