From 1b0471487a3e284e8bb35d19837084ee0246657f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 10 Sep 2008 21:07:32 +0000 Subject: [PATCH] Added layout friendly constructor (untested). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27407 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/ScrollBar.h | 11 +++++++---- src/kits/interface/ScrollBar.cpp | 29 +++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/headers/os/interface/ScrollBar.h b/headers/os/interface/ScrollBar.h index 03617969f1..c6034d9366 100644 --- a/headers/os/interface/ScrollBar.h +++ b/headers/os/interface/ScrollBar.h @@ -27,12 +27,15 @@ class BScrollBar : public BView { - public: - BScrollBar(BRect frame, const char *name, BView *target, +public: + BScrollBar(BRect frame, const char* name, + BView* target, float min, float max, + orientation direction); + BScrollBar(const char* name, BView* target, float min, float max, orientation direction); - BScrollBar(BMessage *data); + BScrollBar(BMessage* data); virtual ~BScrollBar(); - static BArchivable *Instantiate(BMessage *data); + static BArchivable *Instantiate(BMessage* data); virtual status_t Archive(BMessage *data, bool deep = true) const; virtual void AttachedToWindow(); diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index 0c61541fe4..9d290d0a95 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -207,6 +207,31 @@ BScrollBar::BScrollBar(BRect frame, const char* name, BView *target, } +BScrollBar::BScrollBar(const char* name, BView *target, + float min, float max, orientation direction) + : BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS), + fMin(min), + fMax(max), + fSmallStep(1), + fLargeStep(10), + fValue(0), + fProportion(0.0), + fTarget(NULL), + fOrientation(direction), + fTargetName(NULL) +{ + SetViewColor(B_TRANSPARENT_COLOR); + + fPrivateData = new BScrollBar::Private(this); + + SetTarget(target); + SetEventMask(B_NO_POINTER_HISTORY); + + _UpdateThumbFrame(); + _UpdateArrowButtons(); +} + + BScrollBar::BScrollBar(BMessage* data) : BView(data), fTarget(NULL), @@ -1108,9 +1133,9 @@ BScrollBar::PreferredSize() { BSize preferredSize = _MinSize(); if (fOrientation == B_HORIZONTAL) - preferredSize.width = 2 * preferredSize.width; + preferredSize.width *= 2; else - preferredSize.height = 2 * preferredSize.height; + preferredSize.height *= 2; return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), preferredSize); }