home *** CD-ROM | disk | FTP | other *** search
- /* ================
- * PedViewScroll.cc
- * ================
- */
-
- #include "PedestalDebugging.h"
-
- #include <MacWindows.h>
-
- #include "PedViewScroll.hh"
-
- #include "PedPane.hh"
- #include "PedViewScroller.hh"
-
- //UPedNullView gNullView;
-
- static const Point sPointZero = {0, 0};
-
- PedViewScroll::PedViewScroll(PedPaneSubView &inSuperPane)
- : PedViewSub(inSuperPane), mPane(NULL), mScrollPos(sPointZero), mScroller(NULL)
- {
- }
-
- PedViewScroll::~PedViewScroll()
- {
- if (mPane) mPane->release();
- if (mScroller) mScroller->release();
- }
-
- void
- PedViewScroll::Dispose()
- {
- if (mScroller) {
- mScroller->Dispose();
- mScroller->release();
- mScroller = NULL;
- }
- if (mPane) {
- mPane->Dispose();
- mPane->release();
- mPane = NULL;
- }
- }
-
-
- enum {kPedMsgNone, kPedMsgScroll, kPedMsgNotifyScrolledTo};
-
- long
- PedViewScroll::Message(long inMsgCode, void *inData)
- {
- switch (inMsgCode) {
- case kPedMsgScroll:
- // We need a block here
- if (1) {
- short dh = (long)inData & 0xFF;
- short dv = (long)inData >> 16;
- Scroll(dh, dv);
- }
- break;
- case kPedMsgNone:
- break;
- default:
- break;
- }
- return 0;
- }
-
-
- void
- PedViewScroll::GetScrollPos(Point &outPos)
- {
- outPos = mScrollPos;
- }
-
- void
- PedViewScroll::GetFrame(Rect &outFrame)
- {
- PedViewSub::GetFrame(outFrame);
- //::OffsetRect(&outFrame, -mScrollPos.h, -mScrollPos.v);
- }
-
- void
- PedViewScroll::DoScroll(short inH, short inV)
- {
- Scroll(inH, inV);
- // Notify scroller that scrolling has occurred, to update the scrollbars.
- if (mScroller) {
- mScroller->Message(kPedMsgNotifyScrolledTo, &mScrollPos);
- }
- }
-
- void
- PedViewScroll::Scroll(short inH, short inV, bool inUpdate)
- {
- if (mPane) {
- mScrollPos.h += inH;
- mScrollPos.v += inV;
- }
- //Refresh();
-
- Rect frame;
- GetFrame(frame);
- RgnHandle updateRegion;
- updateRegion = ::NewRgn(); // always initialize the update region
- ::ScrollRect(&frame, -inH, -inV, updateRegion);
- if (inUpdate) {
- // Update immediately
- ::SetClip(updateRegion);
- Rect box = (*updateRegion)->rgnBBox;
- ::EraseRect(&box);
- DrawContent();
- ::ClipRect(&qd.thePort->portRect);
- } else {
- ::InvalRgn(updateRegion);
- }
- ::DisposeRgn(updateRegion);
- }
-
- void
- PedViewScroll::GetWindowToLocalOffset(Point &outOffset)
- {
- GetWindowToFrameOffset(outOffset);
-
- Point pos;
- GetScrollPos(pos);
- outOffset.h -= pos.h;
- outOffset.v -= pos.v;
- }
-
- PedPane *
- PedViewScroll::Pane()
- {
- return mPane;
- }
-
- void
- PedViewScroll::SetPane(PedPane *inPane)
- {
- PedPane *oldPane = mPane;
- if (inPane) inPane->retain();
- mPane = inPane;
- if (oldPane) oldPane->release();
- }
-
- void
- PedViewScroll::SetScroller(PedViewScroller *inScroller)
- {
- PedViewScroller *oldScroller = mScroller;
- if (inScroller) inScroller->retain();
- mScroller = inScroller;
- if (oldScroller) oldScroller->release();
- }
-
-
- void
- PedViewScroll::Focus()
- {
- PedViewSub::Focus();
- Rect frame;
- GetFrame(frame);
- ::ClipRect(&frame);
- }
-
- void
- PedViewScroll::Open()
- {
- if (mPane) {
- mPane->Open();
- }
- }
-
- void
- PedViewScroll::Close()
- {
- if (mPane) {
- mPane->Close();
- }
- }
-
- void
- PedViewScroll::Activate()
- {
- if (mPane) {
- mPane->Activate();
- }
- }
-
- void
- PedViewScroll::Deactivate()
- {
- if (mPane) {
- mPane->Deactivate();
- }
- }
-
- void
- PedViewScroll::DrawContent()
- {
- if (mPane) {
- //Rect frame;
- //GetFrame(frame);
- //::ClipRect(&frame);
- //::EraseRect(&frame);
- mPane->DrawContent();
- //::ClipRect(&qd.thePort->portRect);
- }
- }
-
- void
- PedViewScroll::Resize(short inWidth, short inHeight)
- {
- PedViewSub::Resize(inWidth, inHeight);
- if (mPane) {
- //mPane->Resize(inWidth, inHeight);
- }
- }
-
- void
- PedViewScroll::DispatchNullEvent(EventRecord &inEvent)
- {
- //PedViewSub::DispatchNullEvent(inEvent);
- if (mPane) {
- mPane->DispatchNullEvent(inEvent);
- }
- }
-
- void
- PedViewScroll::DispatchClickEvent(EventRecord &inEvent)
- {
- //PedViewSub::DispatchClickEvent(inEvent);
- if (mPane) {
- mPane->DispatchClickEvent(inEvent);
- }
- }
-
- void
- PedViewScroll::DispatchKey(EventRecord &inEvent)
- {
- }
-