Accounting Software
Small Business Software Estimating Software
Project Management SoftwareProject Estimating SoftwareProject Tracking SoftwareInventory Tracking SoftwareCustomer Tracking SoftwareCustomer Management SoftwareBusiness Management Software

Scrollers (Source Code)

Link to: header | other interface directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

CTCS_Scroller

This class manages generic scrollers in the
Goldenseal small business accounting software,
project management software, construction accounting software
and construction software.

It's a Buffer class for LActiveScroller

If the scroller is on a gray background it is automatically drawn 'Sunken'
into the surrounding area. Note that in this case the scrolling view is
inset by 2 pixels in each direction to allow for an extra frame pixel on each side.

Superclasses: LActiveScroller

Constructor

/*********************************************************************************
default constructor
*********************************************************************************/
CTCS_Scroller::CTCS_Scroller(const SPaneInfo *inPaneInfo, const SViewInfo &inViewInfo,
SInt16 inHorizBarLeftIndent, SInt16 inHorizBarRightIndent,
SInt16 inVertBarTopIndent, SInt16 inVertBarBottomIndent,
LView *inScrollingView)
: LActiveScroller(*inPaneInfo, inViewInfo, inHorizBarLeftIndent,
inHorizBarRightIndent, inVertBarTopIndent,
inVertBarBottomIndent, inScrollingView)

{
}/*********************************************************************************
stream constructor
*********************************************************************************/
CTCS_Scroller::CTCS_Scroller(LStream *inStream) : LActiveScroller(inStream)
{
}

Source Code

/******************************************************************************

ScrollToTop TCS 5/24/00

scroll to the very top

*******************************************************************************/
void CTCS_Scroller::ScrollToTop(const Boolean refresh)
{
ScrollToPosition(0, 0, refresh);
}
/******************************************************************************

ScrollToPosition TCS 5/24/00

scroll to the given position

*******************************************************************************/
void CTCS_Scroller::ScrollToPosition(const SInt32 vertPosition, const SInt32 horizPosition,
const Boolean refresh)
{
if (mScrollingView)
mScrollingView->ScrollPinnedImageTo(horizPosition, vertPosition, refresh);
if (mVerticalBar)
mVerticalBar->SetValue(vertPosition);
if (mHorizontalBar)
mHorizontalBar->SetValue(horizPosition);
}
/******************************************************************************

GetVerticalScroll TCS 5/24/00

return the current vertical scroll bar position

*******************************************************************************/
SInt32 CTCS_Scroller::GetVerticalScroll()
{
if (mVerticalBar)
return mVerticalBar->GetValue();
else
return 0;
}
/******************************************************************************

GetHorizontalScroll TCS 5/24/00

return the current horizontal scroll bar position

*******************************************************************************/
SInt32 CTCS_Scroller::GetHorizontalScroll()
{
if (mHorizontalBar)
return mHorizontalBar->GetValue();
else
return 0;
}
#if CAN_USE_MARK
#pragma mark -
#endif
/******************************************************************************

FinishCreateSelf

Draws the scroller v1.01, 12-09-96, 12-17-96

*******************************************************************************/
void CTCS_Scroller::FinishCreateSelf()
{
// Let the superclass do its thing
LActiveScroller::FinishCreateSelf();
// If we're on a gray background we add some attachments
TStColorPenState penState;
CTCS_RGBColor backColor;
ApplyForeAndBackColors();
TCS_GetBackgroundColor(&backColor);
if (backColor != CTCS_RGBColor::GetWhiteColor())
{
// We need to shrink the scrolling view by 1 pixel on each side
// We also need to shrink the scrollbars appropriately
if (mScrollingView != nil)
{
mScrollingView->ResizeFrameBy(-2, -2, false);
mScrollingView->MoveBy(1, 1, true);
// Add an attachment to draw a white background for the scrolling view
TCS_PenState penState = TCS_GetNormalPenState();

mScrollingView->AddAttachment(NEW LColorEraseAttachment(&penState));
}
if (mHorizontalBar != nil)
{
mHorizontalBar->ResizeFrameBy(-2, 0, false);
mHorizontalBar->MoveBy(1, -1, true);
}
if (mVerticalBar != nil)
{
mVerticalBar->ResizeFrameBy(0, -2, false);
mVerticalBar->MoveBy(-1, 1, true);
}
mGrayscale = true;
}
else
{
mGrayscale = false;
}
}/******************************************************************************

ActivateSelf

Activate Scroller v1.0, 12-11-96

*******************************************************************************/
void CTCS_Scroller::ActivateSelf()
{
#if TCS_FOR_MAC
// mfs_sa 29may2k2,
// Window's control visibility/look doesn't change on WIN
// for active/deactive state

// Show ScrollBars that were hidden when Deactivated
if (mVerticalBar != nil)
mVerticalBar->Show();
if (mHorizontalBar != nil)
mHorizontalBar->Show();
// If we are in grayscale mode we redraw immediately
if (mGrayscale && FocusExposed())
{
TCS_Rect frame;
CalcLocalFrameRect(frame);
if (ExecuteAttachments(msg_DrawOrPrint, &frame))
{
DrawSelf();
}
}
#endif
}
/*********************************************************************************

SuperPrintPanel TCS 3/24/00

print the scroller. We print the contents, but not the scroll bars.
*********************************************************************************/
void CTCS_Scroller::SuperPrintPanel(const PanelSpec &inSuperPanel,
TCS_RgnHandle inSuperPrintRgnH)
{
// Print Panels of SubPanes
TArrayIterator<LPane*> iterator(mSubPanes);
LPane *theSub;
while (iterator.Next(theSub))
{
if (theSub != mVerticalBar && theSub != mHorizontalBar)
theSub->SuperPrintPanel(inSuperPanel, inSuperPrintRgnH);
}
}
/******************************************************************************

DrawSelf v1.01, 12-09-96, 12-11-96

Draws the scroller

*******************************************************************************/
void CTCS_Scroller::DrawSelf()
{
TStColorPenState penState;
TCS_Rect frame;
Boolean isNotched = ((mHorizontalBar != nil) && (mVerticalBar != nil));
CalcLocalFrameRect(frame);
penState.Normalize();
if (mGrayscale)
{
Boolean deep = true;

#if TCS_FOR_MAC
GDIterator iter;
while (iter.More(deep))
#endif
{
if (deep)
{
if (IsActive())
TCS_SetRGBForeColor(&gAGARamp [rB]); // TCS rev 9/18/02
else
#if TCS_FOR_MAC
TCS_SetRGBForeColor(&gAGARamp [r10]);
#elif TCS_FOR_WINDOWS
TCS_SetForegroundColor(WinRGBColor::GetSysDlgBackClr());
#endif
}
else
{
TCS_SetForegroundColor(CTCS_RGBColor::GetBlackColor());
}
TCS_InsetRect(&frame, 1, 1);
if (isNotched)
{
TCS_MoveTo(frame.right - 1, frame.top);
TCS_LineTo(frame.left, frame.top);
TCS_LineTo(frame.left, frame.bottom - 1);
TCS_LineTo(frame.right - 16, frame.bottom - 1);
TCS_Line(0, -15);
TCS_Line(15, 0);
TCS_LineTo(frame.right - 1, frame.top);
}
else
{
TCS_FrameRect(&frame);
}
TCS_InsetRect(&frame, -1, -1);

if (deep)
{
#if TCS_FOR_MAC
TCS_SetRGBForeColor(IsActive() ? &gAGARamp [r5] : &gAGARamp [r2]);
#elif TCS_FOR_WINDOWS
TCS_SetForegroundColor(WinRGBColor::GetSysDlgBackClr());
#endif
TCS_MoveTo(frame.left, frame.bottom - 2);
TCS_LineTo(frame.left, frame.top);
TCS_LineTo(frame.right - 2, frame.top);
if (IsActive())
TCS_SetForegroundColor(CTCS_RGBColor::GetWhiteColor());
TCS_MoveTo(frame.left + 1, frame.bottom - 1);
if (isNotched)
{
TCS_LineTo(frame.right - 16, frame.bottom - 1);
TCS_Line(0, -15);
TCS_Line(15, 0);
}
else
{
TCS_LineTo(frame.right - 1, frame.bottom - 1);
}
TCS_LineTo(frame.right - 1, frame.top + 1);
}
} // while

TCS_InsetRect(&frame, 1, 1);
TCS_SetForegroundColor(CTCS_RGBColor::GetBlackColor());
TCS_SetBackgroundColor(CTCS_RGBColor::GetWhiteColor());
}
else
{
TCS_SetForegroundColor(CTCS_RGBColor::GetBlackColor());
TCS_SetBackgroundColor(CTCS_RGBColor::GetWhiteColor());
TCS_FrameRect(&frame);
}#if TCS_FOR_MAC
if (mVerticalBar != nil)
{
TCS_MoveTo(frame.right - 16, frame.top);
TCS_LineTo(frame.right - 16, frame.bottom - 1);
}

if (mHorizontalBar != nil)
{
TCS_MoveTo(frame.left, frame.bottom - 16);
TCS_LineTo(frame.right - 1, frame.bottom - 16);
}

// When inactive, ScrollBars are hidden. Just outline
// the ScrollBar locations with one pixel borders.
if (!IsActive())
{
if (mVerticalBar != nil)
{
mVerticalBar->CalcPortFrameRect(frame);
PortToLocalRect(frame);
TCS_FrameRect(&frame);
TCS_InsetRect(&frame, 1, 1);
TCS_EraseRect(&frame);
}
if (mHorizontalBar != nil)
{
mHorizontalBar->CalcPortFrameRect(frame);
PortToLocalRect(frame);
TCS_FrameRect(&frame);
TCS_InsetRect(&frame, 1, 1);
TCS_EraseRect(&frame);
}
}
#elif TCS_FOR_WINDOWS
// mfs_sa 29may2k2,
// Window's Scrollbar draws itself and more over
// Window's control visibility/look doesn't change on WIN
// for active/deactive state, so we don't need to draw anything

// We just draw a small 15x15 rectangle in the right bottom
// corner if both horizontal and vertical bar is present
if (mHorizontalBar && mVerticalBar)
{
TCS_SetRGBForeColor(&WinRGBColor::GetSysDlgBackClr());
frame.left = frame.right - 15;
frame.top = frame.bottom - 15;
TCS_PaintRect(&frame);
}
#endif
}