www.pudn.com > wcore.rar > WebCoreTextRenderer.h
/* * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. * Portions Copyright (c) 2005 Nokia Corporation, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __WebCoreTextRenderer_h__ #define __WebCoreTextRenderer_h__ // INCLUDES #include// CONSTANTS // MACROS // DATA TYPES // FUNCTION PROTOTYPES // FORWARD DECLARATIONS class TPoint; class CWebCoreGraphicsContext; class CFont; // CLASS DECLARATION /** * * @lib webcore.lib * @since 3.0 */ class TWebCoreTextStyle { public: TWebCoreTextStyle() : iLetterSpacing(0),iWordSpacing(0),iPadding(0),iFamilies(0), iSmallCaps(EFalse),iRtl(EFalse),iVisuallyOrdered(EFalse), iApplyRunRounding(EFalse),iApplyWordRounding(EFalse),iAttemptFontSubstitution(EFalse) { } public: TRgb iTextColor; TRgb iBackgroundColor; TInt iLetterSpacing; TInt iWordSpacing; TInt iPadding; TInt iTabWidth; TInt iXpos; // this is an array of TPtrC's terminated by KNullDesC TPtrC *iFamilies; TBool iSmallCaps; TBool iRtl; TBool iVisuallyOrdered; TBool iApplyRunRounding; TBool iApplyWordRounding; TBool iAttemptFontSubstitution; }; /** * * @lib webcore.lib * @since 3.0 */ class TWebCoreTextRun { public: TWebCoreTextRun(const TText *aCharacters, TUint aLength, TInt aFrom, TInt aTo) { iCharacters = aCharacters; iLength = aLength; iFrom = aFrom; iTo = aTo; } public: const TText *iCharacters; TUint iLength; TInt iFrom; TInt iTo; }; /** * * @lib webcore.lib * @since 3.0 */ class TWebCoreTextGeometry { public: TWebCoreTextGeometry() { iPoint = TPoint(0,0); iSelectionY = 0; iSelectionHeight = 0; iSelectionMinX = 0; iSelectionMaxX = 0; iUseFontMetricsForSelectionYAndHeight = 1; } public: TPoint iPoint; TReal iSelectionY; TReal iSelectionHeight; TReal iSelectionMinX; TReal iSelectionMaxX; TBool iUseFontMetricsForSelectionYAndHeight; }; /** * * @lib webcore.lib * @since 3.0 */ class MWebCoreTextRenderer { public: // vertical metrics virtual TInt Ascent() = 0; virtual TInt Descent() = 0; virtual TInt LineSpacing() = 0; virtual TInt XHeight() = 0; // horizontal metrics virtual TInt WidthForRun(const TWebCoreTextRun& aRun, const TWebCoreTextStyle& aStyle) = 0; // drawing virtual void DrawRun( CWebCoreGraphicsContext& aGc, const TWebCoreTextRun& aRun, const TWebCoreTextStyle& aStyle, const TWebCoreTextGeometry& aGeometry) = 0; virtual void DrawHighlightForRun( CWebCoreGraphicsContext& aGc, const TWebCoreTextRun& aRun, const TWebCoreTextStyle& aStyle, const TWebCoreTextGeometry& aGeometry) = 0; virtual void DrawLineForCharacters( CWebCoreGraphicsContext& aGc, TPoint &aPoint, TInt aYOffset, TInt aWidth, TRgb &aColor) = 0; // selection point check virtual TInt PointToOffset(const TWebCoreTextRun& aRun, const TWebCoreTextStyle& aStyle, TInt aPosition, TBool aReversed, TBool aIncludePartialGlyphs) = 0; virtual void Ref() = 0; virtual void Deref() = 0; virtual CFont* Font() = 0; virtual TBool IsFontFixedPitch() = 0; }; #endif // End of File