From 75c3c8f50d388b53df93ced41c79f976bc7fb9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 20 Feb 2004 21:33:08 +0000 Subject: [PATCH] Fixed SetTarget() - BTW is even correctly implemented in R5. Beautified SetBorderHighlighting(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6669 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ScrollView.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/ScrollView.cpp b/src/kits/interface/ScrollView.cpp index 39a5afdd00..3357887f87 100644 --- a/src/kits/interface/ScrollView.cpp +++ b/src/kits/interface/ScrollView.cpp @@ -291,13 +291,13 @@ BScrollView::Border() const status_t BScrollView::SetBorderHighlighted(bool state) { - if (fBorder != B_FANCY_BORDER) - return B_ERROR; - if (fHighlighted == state) - // no change return B_OK; + if (fBorder != B_FANCY_BORDER) + // highlighting only works for B_FANCY_BORDER + return B_ERROR; + fHighlighted = state; // ToDo: The BeBook describes something like this: @@ -329,21 +329,30 @@ BScrollView::IsBorderHighlighted() const void BScrollView::SetTarget(BView *target) { + if (fTarget == target) + return; + if (fTarget != NULL) { fTarget->TargetedByScrollView(NULL); RemoveChild(fTarget); - // ToDo: investigate if we are supposed to delete it - //delete fTarget; + // we are not supposed to delete the view } fTarget = target; + if (fHorizontalScrollBar != NULL) + fHorizontalScrollBar->SetTarget(target); + if (fVerticalScrollBar != NULL) + fVerticalScrollBar->SetTarget(target); + if (target != NULL) { + target->MoveTo(BorderSize(fBorder), BorderSize(fBorder)); + target->TargetedByScrollView(this); + AddChild(target, ChildAt(0)); // This way, we are making sure that the target will // be added top most in the list (which is important // for unarchiving) - target->TargetedByScrollView(this); } }