Link to: header | other interface
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
TCS_GroupBox
This class manages group boxes in the
Goldenseal small business estimating software,
project management software, construction
estimating software
and construction software.
It's a class for creating a group box with a caption, for basic interface use.
SUPERCLASS = CTCS_Caption
Constructor
/*********************************************************************************
constructor from stream. This justs sets our RGB to a default value
*********************************************************************************/
CTCS_GroupBox::CTCS_GroupBox(LStream *inStream)
: CTCS_Caption(inStream)
{
mEdgeColor = CTCS_RGBColor::GetGrayColor();
}
Source Code
/*********************************************************************************
DrawSelf
draw the group box
*********************************************************************************/
void CTCS_GroupBox::DrawSelf()
{
TCS_Rect frameR;
CalcLocalFrameRect(frameR);
DrawGroupBox(mText, mTextInfo, frameR, mEdgeColor);
}
/*********************************************************************************
DrawGroupBox
draw a group box. This is a separate static function because it is
used by the layout editor group box class
*********************************************************************************/
void CTCS_GroupBox::DrawGroupBox(const CTextString &caption,
const CTCS_TextInfo &textInfo,
const TCS_Rect &frame,
const CTCS_RGBColor &edgeColor)
{
const SInt32 cStringIndent = 6;
TStTextState textSaver;
TStColorPenState penSaver;
CStringGraphic stringGraphic(caption);
SInt32 frameWidth;
// set up the text environment
penSaver.Normalize();
CTCS_TextInfo::SetPortTextInfo(textInfo);
// Get the size of the caption
SInt32 strWidth = stringGraphic.GetWidth(); // rev TCS 9/17/02
SInt32 strHeight = stringGraphic.GetHeight();
strWidth += cStringIndent;
frameWidth = frame.right - frame.left;
// calculate the box in which the text is to be drawn
TCS_Rect textRect;
textRect.top = frame.top;
textRect.bottom = frame.top + strHeight;
switch (textInfo.GetTextJust())
{
case just_right:
textRect.right = frame.right - cStringIndent;
textRect.left = textRect.right - strWidth;
break;
case just_center:
textRect.left = frame.left + ((frameWidth - strWidth) >> 2);
textRect.right = textRect.left + strWidth;
break;
default:
// default is left-justified
textRect.left = frame.left + cStringIndent;
textRect.right = textRect.left + strWidth;
break;
}
// Draw the box
// We put this in it's own scope because we fiddle the clip area
{
TStClipRgnState clipSaver;
CTCS_Region clipRgn;
TCS_Rect boxR = frame;
// Subtract the text rectangle from the current clip area
TCS_GetClipRegion(&clipRgn);
TCS_ClipToRegion(clipRgn - CTCS_Region(textRect));
// Push the top of the group box down to the middle of the text
boxR.top += (textRect.bottom - textRect.top) >> 1;
// set the edge color and draw the frame
TCS_SetForegroundColor(edgeColor);
TCS_FrameRect(&boxR);
// TStClipRgnState restores clip at end of this scope
}
// we have drawn the box, now draw the text
TCS_SetForeColorIndex(textInfo.GetTextColor());
stringGraphic.DrawInBox(textRect);
}
|