|
From: <zou...@us...> - 2008-02-11 13:03:09
|
Revision: 1000
http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1000&view=rev
Author: zouzou123gen
Date: 2008-02-09 16:32:56 -0800 (Sat, 09 Feb 2008)
Log Message:
-----------
scroll fixes
Modified Paths:
--------------
dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h
dcplusplus/trunk/win32/HubFrame.cpp
dcplusplus/trunk/win32/PrivateFrame.cpp
dcplusplus/trunk/win32/SystemFrame.cpp
Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h 2008-02-09 22:14:47 UTC (rev 999)
+++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectScrollable.h 2008-02-10 00:32:56 UTC (rev 1000)
@@ -44,6 +44,8 @@
{
typedef Dispatchers::VoidVoid<> Dispatcher;
public:
+ bool scrollIsAtEnd();
+
/// \ingroup EventHandlersAspectScrollable
/// Setting the event handler for the "scrolling horizontally" event
/** A scrolling event occurs when for instance a WidgetSliders value is being
@@ -75,6 +77,18 @@
{}
};
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Implementation of class
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+template< class WidgetType >
+bool AspectScrollable< WidgetType >::scrollIsAtEnd()
+{
+ SCROLLINFO scrollInfo = { sizeof(SCROLLINFO), SIF_RANGE | SIF_PAGE | SIF_POS };
+ BOOL ret = ::GetScrollInfo(static_cast<WidgetType*>(this)->handle(), SB_VERT, &scrollInfo);
+ xAssert(ret != FALSE, _T("Can't get scroll info in scrollIsAtEnd"));
+ return (scrollInfo.nPos == static_cast<int>(scrollInfo.nMax - std::max(scrollInfo.nPage - 1, 0u)));
+}
+
// end namespace SmartWin
}
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h 2008-02-09 22:14:47 UTC (rev 999)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTextBox.h 2008-02-10 00:32:56 UTC (rev 1000)
@@ -34,6 +34,7 @@
#include "../aspects/AspectControl.h"
#include "../aspects/AspectFocus.h"
#include "../aspects/AspectFont.h"
+#include "../aspects/AspectScrollable.h"
#include "../aspects/AspectText.h"
#include "../aspects/AspectUpdate.h"
@@ -70,6 +71,7 @@
public AspectControl< WidgetTextBoxBase >,
public AspectFocus< WidgetTextBoxBase >,
public AspectFont< WidgetTextBoxBase >,
+ public AspectScrollable< WidgetTextBoxBase >,
public AspectText< WidgetTextBoxBase >,
public AspectUpdate< WidgetTextBoxBase >
{
Modified: dcplusplus/trunk/win32/HubFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/HubFrame.cpp 2008-02-09 22:14:47 UTC (rev 999)
+++ dcplusplus/trunk/win32/HubFrame.cpp 2008-02-10 00:32:56 UTC (rev 1000)
@@ -203,6 +203,8 @@
}
void HubFrame::layout() {
+ bool scroll = chat->scrollIsAtEnd();
+
const int border = 2;
SmartWin::Rectangle r(getClientAreaSize());
@@ -233,6 +235,9 @@
paned->setSecond(0);
}
paned->setRect(r);
+
+ if(scroll)
+ chat->sendMessage(WM_VSCROLL, SB_BOTTOM);
}
void HubFrame::updateStatus() {
@@ -415,11 +420,7 @@
}
line += Text::toDOS(aLine);
- SCROLLINFO scrollInfo = { sizeof(SCROLLINFO), SIF_RANGE | SIF_PAGE | SIF_POS };
- bool scroll = (
- (::GetScrollInfo(chat->handle(), SB_VERT, &scrollInfo) == 0) || // on error, let's keep scrolling...
- (scrollInfo.nPos == (scrollInfo.nMax - max(scrollInfo.nPage - 1, 0u))) // scroll only if the current scroll position is at the end
- );
+ bool scroll = chat->scrollIsAtEnd();
HoldRedraw hold(chat, !scroll);
size_t limit = chat->getTextLimit();
Modified: dcplusplus/trunk/win32/PrivateFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/PrivateFrame.cpp 2008-02-09 22:14:47 UTC (rev 999)
+++ dcplusplus/trunk/win32/PrivateFrame.cpp 2008-02-10 00:32:56 UTC (rev 1000)
@@ -144,11 +144,7 @@
}
line += aLine;
- SCROLLINFO scrollInfo = { sizeof(SCROLLINFO), SIF_RANGE | SIF_PAGE | SIF_POS };
- bool scroll = (
- (::GetScrollInfo(chat->handle(), SB_VERT, &scrollInfo) == 0) || // on error, let's keep scrolling...
- (scrollInfo.nPos == (scrollInfo.nMax - max(scrollInfo.nPage - 1, 0u))) // scroll only if the current scroll position is at the end
- );
+ bool scroll = chat->scrollIsAtEnd();
HoldRedraw hold(chat, !scroll);
size_t limit = chat->getTextLimit();
@@ -228,6 +224,8 @@
}
void PrivateFrame::layout() {
+ bool scroll = chat->scrollIsAtEnd();
+
const int border = 2;
SmartWin::Rectangle r(getClientAreaSize());
@@ -240,6 +238,9 @@
r.size.y -= rm.size.y + border;
chat->setBounds(r);
+
+ if(scroll)
+ chat->sendMessage(WM_VSCROLL, SB_BOTTOM);
}
void PrivateFrame::updateTitle() {
Modified: dcplusplus/trunk/win32/SystemFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/SystemFrame.cpp 2008-02-09 22:14:47 UTC (rev 999)
+++ dcplusplus/trunk/win32/SystemFrame.cpp 2008-02-10 00:32:56 UTC (rev 1000)
@@ -52,26 +52,34 @@
}
void SystemFrame::addLine(time_t t, const tstring& msg) {
- int limit = log->getTextLimit();
- if(log->length() + static_cast<int>(msg.size()) > limit) {
- HoldRedraw hold(log);
+ bool scroll = log->scrollIsAtEnd();
+ HoldRedraw hold(log, !scroll);
+
+ size_t limit = log->getTextLimit();
+ if(log->length() + msg.size() > limit) {
+ HoldRedraw hold2(log, scroll);
log->setSelection(0, log->lineIndex(log->lineFromChar(limit / 10)));
log->replaceSelection(_T(""));
}
log->addTextLines(Text::toT("\r\n[" + Util::getShortTimeString(t) + "] ") + msg);
- log->sendMessage(WM_VSCROLL, SB_BOTTOM);
+ if(scroll)
+ log->sendMessage(WM_VSCROLL, SB_BOTTOM);
+
setDirty(SettingsManager::BOLD_SYSTEM_LOG);
}
void SystemFrame::layout() {
- const int border = 2;
+ bool scroll = log->scrollIsAtEnd();
SmartWin::Rectangle r(this->getClientAreaSize());
layoutStatus(r);
log->setBounds(r);
+
+ if(scroll)
+ log->sendMessage(WM_VSCROLL, SB_BOTTOM);
}
HRESULT SystemFrame::handleSpeaker(WPARAM wp, LPARAM lp) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|