← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2487: fix scrolling in settings

 

------------------------------------------------------------
revno: 2487
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2011-04-12 19:26:38 +0200
message:
  fix scrolling in settings
modified:
  dwt/include/dwt/aspects/AspectChild.h
  dwt/include/dwt/widgets/ScrolledContainer.h
  dwt/src/widgets/GroupBox.cpp
  dwt/src/widgets/ScrolledContainer.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 'dwt/include/dwt/aspects/AspectChild.h'
--- dwt/include/dwt/aspects/AspectChild.h	2008-12-04 19:24:59 +0000
+++ dwt/include/dwt/aspects/AspectChild.h	2011-04-12 17:26:38 +0000
@@ -8,7 +8,8 @@
 #ifndef DWT_ASPECTCHILD_H_
 #define DWT_ASPECTCHILD_H_
 
-#include "../Widget.h"
+#include <dwt/forward.h>
+#include <dwt/widgets/Control.h>
 
 namespace dwt {
 
@@ -19,15 +20,15 @@
 	template<typename SeedType>
 	typename SeedType::WidgetType::ObjectType addChild(const SeedType& seed) {
 		// Only allow a single child
-		Widget* child = getChild();
-		if(child != NULL) {
-			::DestroyWindow(child->handle());
+		auto child = getChild();
+		if(child) {
+			child->close();
 		}
 		return WidgetCreator<typename SeedType::WidgetType>::create(static_cast<WidgetType*>(this), seed);
 	}
 
-	Widget* getChild() {
-		return hwnd_cast<Widget*>(::GetWindow(static_cast<WidgetType*>(this)->handle(), GW_CHILD));
+	Control* getChild() {
+		return hwnd_cast<Control*>(::GetWindow(static_cast<WidgetType*>(this)->handle(), GW_CHILD));
 	}
 };
 

=== modified file 'dwt/include/dwt/widgets/ScrolledContainer.h'
--- dwt/include/dwt/widgets/ScrolledContainer.h	2011-04-11 20:39:22 +0000
+++ dwt/include/dwt/widgets/ScrolledContainer.h	2011-04-12 17:26:38 +0000
@@ -34,7 +34,7 @@
 
 #include "../aspects/AspectChild.h"
 
-#include "Container.h"
+#include "Control.h"
 
 namespace dwt {
 

=== modified file 'dwt/src/widgets/GroupBox.cpp'
--- dwt/src/widgets/GroupBox.cpp	2011-03-27 10:50:56 +0000
+++ dwt/src/widgets/GroupBox.cpp	2011-04-12 17:26:38 +0000
@@ -61,7 +61,7 @@
 
 Point GroupBox::getPreferredSize() {
 	Point ret(0, 0);
-	Widget* w = getChild();
+	auto w = getChild();
 
 	if(w) {
 		ret = w->getPreferredSize();
@@ -71,11 +71,11 @@
 }
 
 void GroupBox::layout() {
-	Widget* child = getChild();
+	auto child = getChild();
 	if(child) {
 		auto size = getClientSize();
 		auto rc = shrink(Rectangle(size));
-		::MoveWindow(child->handle(), rc.left(), rc.top(), rc.width(), rc.height(), TRUE);
+		child->resize(rc);
 	}
 
 	BaseType::layout();
@@ -119,7 +119,7 @@
 }
 
 void GroupBox::handleEnabled(bool enabled) {
-	Widget* child = getChild();
+	auto child = getChild();
 	if(child)
 		child->setEnabled(enabled);
 }

=== modified file 'dwt/src/widgets/ScrolledContainer.cpp'
--- dwt/src/widgets/ScrolledContainer.cpp	2011-03-28 19:37:33 +0000
+++ dwt/src/widgets/ScrolledContainer.cpp	2011-04-12 17:26:38 +0000
@@ -61,17 +61,11 @@
 		setScrollInfo(SB_VERT, clientSize.y, childSize.y);
 	}
 
-	::MoveWindow(child->handle(), 0, 0, clientSize.x, clientSize.y, TRUE);
+	child->resize(Rectangle(0, 0, std::max(childSize.x, clientSize.x), std::max(childSize.y, clientSize.y)));
 }
 
 void ScrolledContainer::setScrollInfo(int type, int page, int max, int pos) {
-	SCROLLINFO si = { sizeof(SCROLLINFO) };
-
-	si.fMask = SIF_ALL;
-	si.nMin = 0;
-	si.nMax = max - 1;
-	si.nPos = pos;
-	si.nPage = type == SB_HORZ ? getClientSize().x : getClientSize().y;
+	SCROLLINFO si = { sizeof(SCROLLINFO), SIF_ALL, 0, max - 1, page, pos };
 	::SetScrollInfo(handle(), type, &si, TRUE);
 }
 
@@ -101,10 +95,10 @@
     	si.nPos = si.nMax;
     	break;
     case SB_LINELEFT:
-        si.nPos -= 1;
+        si.nPos -= 10;
         break;
     case SB_LINERIGHT:
-        si.nPos += 1;
+        si.nPos += 10;
         break;
     case SB_PAGELEFT:
         si.nPos -= si.nPage;
@@ -117,7 +111,7 @@
         break;
     }
 
-    ::SetScrollInfo(handle(), type, &si, FALSE);
+    ::SetScrollInfo(handle(), type, &si, TRUE);
 
 	::GetScrollInfo(handle(), type, &si);
 	auto hDiff = type == SB_HORZ ? orig - si.nPos : 0;