home *** CD-ROM | disk | FTP | other *** search
- /****
- * CIntelligentScrollPane.c
- *
- * This class makes the ScrollPane a little more intelligent.
- *
- * Copyright © 1993 Quipus, by Mårten Sörliden. All rights reserved.
- *
- ****/
-
- #include <CScrollBar.h>
- #include <CIntelligentScrollPane.h>
- #include <CIntelligentPanorama.h>
- #include <CIntelligentWindow.h>
-
-
- /** Construction and destruction methods **/
-
- void CIntelligentScrollPane::IIntelligentScrollPane(CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight,
- short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing,
- Boolean hasHoriz, Boolean hasVert, Boolean hasSizeBox)
- {
- IScrollPane(anEnclosure, aSupervisor, aWidth, aHeight,
- aHEncl, aVEncl, aHSizing, aVSizing,
- hasHoriz, hasVert, hasSizeBox);
-
- }
-
- void CIntelligentScrollPane::Dispose(void)
- {
- if (itsPanorama)
- if (member(itsPanorama, CIntelligentPanorama))
- itsPanorama->SetScrollPane(NULL);
- inherited::Dispose();
- }
-
-
- /** Accessing methods **/
-
- void CIntelligentScrollPane::GetPreferedFrame(LongRect *theFrame)
- {
- LongRect theAperture;
- LongRect theBounds;
-
- GetFrame(theFrame);
- if (itsPanorama) {
- itsPanorama->GetAperture(&theAperture);
- itsPanorama->GetBounds(&theBounds);
- theFrame->right = theFrame->right + (theBounds.right - theBounds.left) - (theAperture.right - theAperture.left);
- theFrame->bottom = theFrame->bottom + (theBounds.bottom - theBounds.top) - (theAperture.bottom - theAperture.top);
- }
- }
-
-
- /** Scroll bar maintenance methods **/
-
- // Override
- void CIntelligentScrollPane::AdjustScrollMax()
- {
- register short newMax; /* New maximum scroll bar setting */
- long hPos;
- long vPos;
- short hFSpan;
- short vFSpan;
- short theValue;
-
- if (itsPanorama == NULL) /* Take a quick exit if no */
- return; /* Panorama is installed */
-
- itsPanorama->GetExtent(&hPos, &vPos);
- hExtent = hPos;
- vExtent = vPos;
-
- itsPanorama->GetFrameSpan(&hFSpan, &vFSpan);
- hSpan = hFSpan;
- vSpan = vFSpan;
-
- hUnit = hExtent / MAXINT + 1; /* Controls are limited to shorts */
- vUnit = vExtent / MAXINT + 1; /* Need to scale in case extent is */
- /* larger than a short */
- hStep = Max( hUnit, hStep);
- vStep = Max( vUnit, vStep);
-
- itsPanorama->GetFramePosition(&hPos, &vPos);
-
- if (itsHorizSBar != NULL) {
- theValue = Max((hExtent - hSpan), hPos) / hUnit;
- if (theValue >= 0)
- itsHorizSBar->SetMaxValue(theValue);
- else
- itsHorizSBar->SetMaxValue(0);
- }
-
- if (itsVertSBar != NULL) {
- theValue = Max((vExtent - vSpan), vPos) / vUnit;
- if (theValue >= 0)
- itsVertSBar->SetMaxValue(theValue);
- else
- itsVertSBar->SetMaxValue(0);
- }
-
- if (itsPanorama) {
- if (member(itsEnclosure, CIntelligentWindow))
- ((CIntelligentWindow *)itsEnclosure)->UpdateStdState();
- }
- }