#ifndef __SCROLLPANE_H#define __SCROLLPANE_H/*	ScrollPane.h					JJS 12/04/97	This file defines a type of Pane which displays a scrolling view of another one.	Create it by following these steps:		1. Create a ScrollPane, passing a pointer to the window where it will			be used, and (optional) boolean flags indicating whether it should			have a horizontal and vertical scroll bar, respectively.		2. Set the pane's mFrame to position it where you want it (as with any			other Pane).				3. Create a content pane, and set its frame with coordinates relative			to the inside of the ScrollPane (just as you would for an Enclosure).				4. Attach the content pane to the scroll pane with SetContentPane().			(You can pass 'false' for a second parameter, if you don't want the			ScrollPane to automatically destroy the content pane when it's done.)		Then, whenever something changes that would affect the scroll bars (like	changing the mFrame of the scroll pane or content pane), call Adjust() on the	scroll pane to make sure the scroll bars are updated.		If you don't want a border drawn around the content area, then set mBorder	to false on the scroll pane.		Bonus: if you want to leave a little extra room to the left of the horizontal	scroll bar, or above the vertical one, just set mReserve.h and mReserve.v	to the number of pixels to reserve before calling SetContentPane() or Adjust().	This is handy for making windows with indicators at the bottom, as in the	CodeWarrior IDE and many other apps.*///	11/12/97	- initial release//	12/04/97	- fixed bug in DisownContentPane()//				- added SetTopLeft() method//				- added Get/Set H/V ScrollRate methods#include "Pane.h"#include "ScrollbarPane.h"class ScrollPane : public Pane{  public:	ScrollPane(WindowPtr pWindow, const Boolean hasHBar=true, const Boolean hasVBar=true);	virtual ~ScrollPane();		// set/get/disown content pane	virtual void SetContentPane( Pane *pane, const Boolean takeOwnership=true );	virtual Pane* GetContentPane() { return mContent; }	virtual void DisownContentPane() { mOwnsContent = false; }		// adjust to a frame change, content size change, etc.	virtual void Adjust();		// utility functions -- mostly used internally	virtual Rect CalcHBarRect();	virtual Rect CalcVBarRect();	virtual Rect CalcContentRect();		// draw the pane (assumes grafport coordinates are set up)	virtual void Draw();	// try to handle a click -- return 1 if handled	virtual Boolean Click(Point where, short modifiers);	// get/set the top-left corner of the scrolled region	virtual Point GetTopLeft() const;	virtual void SetTopLeft( const Point p );		// get/set the scroll rate (amount scrolled when using arrows)	virtual short GetHScrollRate() { return (mHBar ? mHBar->mArrowRate : 0); }	virtual short GetVScrollRate() { return (mVBar ? mVBar->mArrowRate : 0); }	virtual void SetHScrollRate(const short pixels) { if (mHBar) mHBar->mArrowRate = pixels; }	virtual void SetVScrollRate(const short pixels) { if (mVBar) mVBar->mArrowRate = pixels; }	// PUBLIC DATA:	Point	mSize;		// hor. & ver. size of the content area (set by Adjust)	Boolean	mBorder;	// if true, draw a border around content region	Point	mReserve;	// hor. & ver. space to reserve (left of hor. scroll bar,						// and above vertical scroll bar)	  protected:	virtual void DrawContent();		// prepare port, and draw content pane	ScrollbarPane	*mHBar;	ScrollbarPane	*mVBar;	Pane			*mContent;		// content pane (if any)	Boolean			mOwnsContent;	// whether it "owns" content pane									// (if yes, then destroy it before unlinking!)};#endif
