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

Dialog Boxes (Source Code)

Link to: header | other interface directory

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

Comments

CTCS_DialogBox

This class manages dialog boxes for the
Goldenseal small business estimating software,
project management software, construction estimating software
and construction software.

This is a buffer class for dialog boxes. Grayscale is supported on the Mac through
code from The Gray Council.

Superclass: LDialogBox

Constructor

/******************************************************************************
stream constructor v1.0.1, 11-20-96, 09-03-97
*******************************************************************************/
CTCS_DialogBox::CTCS_DialogBox(LStream *inStream)
: THE_SUPERCLASS(inStream)
{
Boolean grayscale;
// Read grayscale flag from stream
inStream->ReadData(&grayscale, sizeof(Boolean));
#if TCS_FOR_MAC
// Set the background type
if (grayscale)
{
mBackgrounTCSind = kFlatWindowBackground;

// We need to determine the window proc ID in order to really
// decide what kind of background to do. So, let's find out
// the same way that PowerPlant does. The SWindowInfo back
// there in the stream contains a WINDid field, which is the
// id of a 'WIND' resource. The 'WIND' resource has the proc ID.
SInt32 originalMarker = inStream->GetMarker();

// Undo our stream read
inStream->SetMarker(-sizeof(Boolean), streamFrom_Marker);
// Undo the LDialogBox stream read.
inStream->SetMarker(-sizeof(PaneIDT), streamFrom_Marker);
inStream->SetMarker(-sizeof(PaneIDT), streamFrom_Marker);

// Undo the LWindow stream read.
inStream->SetMarker(-sizeof(SWindowInfo), streamFrom_Marker);

// Re-read the SWindowInfo.
SWindowInfo windowInfo;
inStream->ReadData(&windowInfo, sizeof(SWindowInfo));

// Peek into the 'WIND' resource, as done by LWindow::MakeMacWindow
SWINDResourceH theWIND = (SWINDResourceH) TCS_GetResource(cWindResType, windowInfo.WINDid, false);
TCS_FailNILMsg(theWIND, TCS_GetErrString(errID_BadWindow)); // TCS 5/25/99

SInt16 procID = (**theWIND).procID;
TCS_ForgetResource((TCS_Handle) theWIND); // wrapped TCS 12/27/01, rev TCS 7/10/02

// Restore the stream marker.
inStream->SetMarker(originalMarker, streamFrom_Start);

// Now determine the background kind based on the procID.
if ((procID == dBoxProc) || (procID == movableDBoxProc))
mBackgrounTCSind = kFlatWindowBackground;
else if (HasAttribute(windAttr_Modal))
mBackgrounTCSind = kRaisedModalBackground;
else
mBackgrounTCSind = kRaisedModelessBackground;
}
else
{
mBackgrounTCSind = kNoBackgroundPaint;
}
#endif
}

Source Code

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

FinishCreate

Finishes creation of the object v1.0.1, 11-20-96, 09-03-97

*******************************************************************************/
void CTCS_DialogBox::FinishCreate()
{
#if TCS_FOR_MAC
// Set the gray background color first (if we're grayscale)
if (mBackgrounTCSind != kNoBackgroundPaint)
SetForeAndBackColors(nil, &gAGARamp [r2]);
#endif
// Let the superclass do its normal stuff
THE_SUPERCLASS::FinishCreate();
}/******************************************************************************

FinishCreateSelf

Custom creation finishes v1.0.1, 11-20-96, 09-03-97

*******************************************************************************/
void CTCS_DialogBox::FinishCreateSelf()
{
// Let the superclass do its normal stuff first.
THE_SUPERCLASS::FinishCreateSelf();

#if TCS_FOR_MAC
// Either modify the WCTB background color, or
// just set QD background color.
if (mBackgrounTCSind == kFlatWindowBackground)
TCS_FailOSErr(AGAInstallGrayWCTB(mMacWindowP));
else if (mBackgrounTCSind != kNoBackgroundPaint)
SetForeAndBackColors(nil, &gAGARamp [r2]);
#endif
// Set the default button the gray way
SetDefaultButton(mDefaultButtonID);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/******************************************************************************

SetDefaultButton

Sets the default button for the dialog v1.0.3, 11-20-96, 09-03-97

*******************************************************************************/
void CTCS_DialogBox::SetDefaultButton(PaneIDT inButtonID)
{
#if TCS_FOR_MAC
LPane *thePane = FindPaneByID(inButtonID);
LControl *theButton = TCS_SAFE_CAST(thePane, LControl);
// Remove old default outline
#if TCS_FOR_OSX // TCS 12/26/03
#else
if (mDefaultOutline != nil)
{
mDefaultOutline->Refresh();
TCS_Forget(mDefaultOutline);
}
#endif

// Set up new default button
if (theButton != nil)
{
mDefaultButtonID = inButtonID;
theButton->AddListener(this);
// Create new default outline
#if TCS_FOR_OSX // TCS 12/26/03
#else
mDefaultOutline = NEW CTCS_DefaultOutline(theButton, thePane,
(mBackgrounTCSind != kNoBackgroundPaint));
mDefaultOutline->Refresh();
#endif
}
#elif TCS_FOR_WINDOWS
// Let the superclass do its normal stuff first.
THE_SUPERCLASS::SetDefaultButton(inButtonID);
#endif
}/******************************************************************************

DrawSelf

Draws the dialog box v1.0.1, 11-20-96, 09-03-97

*******************************************************************************/
void CTCS_DialogBox::DrawSelf()
{
#if TCS_FOR_OSX // TCS 1/25/04
THE_SUPERCLASS::DrawSelf(); // TCS rev 2/21/04
//TCS_Rect frameR;
//CalcLocalFrameRect(frameR);

//AGABackgroundPaint(&frameR, true, kRaisedModelessBackground, true, false);

#elif TCS_FOR_MAC
if (mBackgrounTCSind == kNoBackgroundPaint)
{
THE_SUPERCLASS::DrawSelf();
}
else
{
// Draw the background & size box // TCS rev 12/26/03
if (HasAttribute(windAttr_EraseOnUpdate))
DrawBackground(TCS_GetWindowRect(mMacWindowP), true, mActive == triState_On);
DrawSizeBox();
}
#else
THE_SUPERCLASS::DrawSelf();
#endif
}
/******************************************************************************

ResizeFrameBy

Resizes the window v1.0, 11-20-96

*******************************************************************************/
void CTCS_DialogBox::ResizeFrameBy(SInt16 inWidthDelta, SInt16 inHeightDelta,
Boolean inRefresh)
{
// For raised backgrounds,
// if the window size is changing in either direction, we need
// to invalidate the right/bottom edge pixels that will
// need to turn gray when the window is expanded, either before
// or after the resize.

InvalidateEdges(true, inWidthDelta, inHeightDelta);
THE_SUPERCLASS::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
InvalidateEdges(false, inWidthDelta, inHeightDelta);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/******************************************************************************

ActivateSelf

Redraws the window in the active state v1.1, 11-20-96, 09-04-97

*******************************************************************************/
void CTCS_DialogBox::ActivateSelf()
{
#if TCS_FOR_MAC
// Redraw the edge pixels that change based on active state
FocusDraw();
DrawBackground(TCS_GetWindowRect(mMacWindowP), false, true); // TCS rev 12/26/03
#endif

// mf_sa 26apr2k2, moved this out of TCS_FOR_MAC
THE_SUPERCLASS::ActivateSelf();
}/******************************************************************************

DeactivateSelf

Redraws the window in the inactive state v1.1, 11-20-96, 09-04-97

*******************************************************************************/
void CTCS_DialogBox::DeactivateSelf()
{
#if TCS_FOR_MAC
// Redraw the edge pixels that change based on active state
FocusDraw();
DrawBackground(TCS_GetWindowRect(mMacWindowP), false, false); // TCS rev 12/26/03
#endif

// mf_sa 26apr2k2, moved this out of TCS_FOR_MAC
THE_SUPERCLASS::DeactivateSelf();
}
/******************************************************************************

DrawBackground

Draw the window background v1.0, 11-20-96

*******************************************************************************/
void CTCS_DialogBox::DrawBackground(const TCS_Rect & area, Boolean fill, Boolean active)
{
#if TCS_FOR_MAC
if (mBackgrounTCSind != kNoBackgroundPaint)
{
AGABackgroundPaint(&area, fill, mBackgrounTCSind, active,
HasAttribute(windAttr_SizeBox));
}
#else
// Not necessary for Windows
// Suppress unused variable warnings(CodeWarrior only)
#if CAN_USE_MARK
#pragma unused(area, fill, active)
#endif
#endif
}/******************************************************************************

InvalidateEdges

Mark the edge pixels for update v1.0, 11-20-96

*******************************************************************************/
void CTCS_DialogBox::InvalidateEdges(Boolean before, SInt16 inWidthDelta,
SInt16 inHeightDelta)
{
#if TCS_FOR_MAC
if ((mBackgrounTCSind == kRaisedModelessBackground) ||
(mBackgrounTCSind == kRaisedModalBackground))
{
// Invalidate the extra "edge" pixels that need
// to be redrawn when the window is resized
TCS_Rect bounds,
rectToInvalidate;

CalcPortFrameRect(bounds);
if (((inWidthDelta > 0) && before) ||
((inWidthDelta < 0) && !before))
{
rectToInvalidate = bounds;
rectToInvalidate.left = rectToInvalidate.right - 1;
InvalPortRect(&rectToInvalidate);
}
if (((inHeightDelta > 0) && before) ||
((inHeightDelta < 0) && !before))
{
rectToInvalidate = bounds;
rectToInvalidate.top = rectToInvalidate.bottom - 1;
InvalPortRect(&rectToInvalidate);
}
if (HasAttribute(windAttr_EraseOnUpdate))
{
rectToInvalidate = bounds;
rectToInvalidate.left = rectToInvalidate.right - 16;
rectToInvalidate.top = rectToInvalidate.bottom - 16;
InvalPortRect(&rectToInvalidate);
}
}
#else
// Not necessary for Windows
// Suppress unused variable warnings(CodeWarrior only)
#if CAN_USE_MARK
#pragma unused(before, inWidthDelta, inHeightDelta)
#endif
#endif
}