From 56262fb48397c67b776e601a6ffe25f3ba5aa3ce Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Thu, 11 Dec 2003 21:54:14 +0000 Subject: [PATCH] Implemented a few functions, added some documentation and some TODO reminders git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5652 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ScrollBar.cpp | 91 ++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 11 deletions(-) diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index daed75c713..5ef350b98c 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -32,9 +32,9 @@ #include #include #include -#include "ScrollBar.h" +#include -#define TEST_MODE +//#define TEST_MODE typedef enum { @@ -60,6 +60,8 @@ typedef enum #define ARROW4 3 #define NOARROW -1 +// Because the R5 version kept a lot of data on server-side, we need to kludge our way +// into binary compatibility class BScrollBarPrivateData { public: @@ -110,6 +112,8 @@ public: int8 buttondown; }; +// This thread is spawned when a button is initially pushed and repeatedly scrolls +// the scrollbar by a little bit after a short delay int32 BScrollBarPrivateData::ButtonRepeaterThread(void *data) { BScrollBar *sb=(BScrollBar *)data; @@ -184,7 +188,7 @@ BScrollBar::BScrollBar(BRect frame,const char *name,BView *target,float min, fTargetName=new char[strlen(fTarget->Name()+1)]; strcpy(fTargetName,target->Name()); - // theoretically, we should also set the target BView's scrollbar + // TODO: theoretically, we should also set the target BView's scrollbar // pointer here } else @@ -212,7 +216,8 @@ BScrollBar::BScrollBar(BRect frame,const char *name,BView *target,float min, else privatedata->thumbframe.OffsetBy(B_V_SCROLL_BAR_WIDTH+1,0); } - + + SetResizingMode( (direction==B_VERTICAL)? B_FOLLOW_TOP_BOTTOM | B_FOLLOW_RIGHT : B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM ); @@ -229,26 +234,46 @@ BScrollBar::~BScrollBar() delete privatedata; if(fTargetName) delete fTargetName; + + // TODO: Disconnect from target } BArchivable *BScrollBar::Instantiate(BMessage *data) { + // TODO: Implement return NULL; } status_t BScrollBar::Archive(BMessage *data, bool deep) const { - return B_ERROR; + BView::Archive(data,deep); + data->AddFloat("_range",fMin); + data->AddFloat("_range",fMax); + data->AddFloat("_steps",fSmallStep); + data->AddFloat("_steps",fLargeStep); + data->AddFloat("_val",fValue); + data->AddInt32("_orient",(int32)fOrientation); + data->AddInt32("_prop",fProportion); + + return B_OK; } void BScrollBar::AttachedToWindow() { - // if fValue!=0, BScrollbars tell the server its value + // R5's SB contacts the server if fValue!=0. I *think* we don't need to do anything here... } void BScrollBar::SetValue(float value) { + if(value>fMax) + value=fMax; + if(valueName())+1]; strcpy(fTargetName,target->Name()); - // theoretically, we should also set the target BView's scrollbar + // TODO: theoretically, we should also set the target BView's scrollbar // pointer here } else @@ -329,6 +389,15 @@ void BScrollBar::SetTarget(BView *target) void BScrollBar::SetTarget(const char *targetName) { + if(!targetName) + return; + + if(!Window()) + debugger("Method requires window and doesn't have one"); + + BView *tgt=Window()->FindView(targetName); + if(tgt) + SetTarget(tgt); } BView *BScrollBar::Target() const