home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-05 | 4.8 KB | 171 lines | [TEXT/CWIE] |
- // Copyright © 1995 Apple Computer, Inc. All rights reserved.
- // Release Version: $ 1.0 d11 $
-
- //=======================================================================
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- // ----- Framework Layer -----
- #ifndef FWUTIL_H
- #include "FWUtil.h" // FW_CFacetContext, FW_Beep()
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h" // FW_CViewContext
- #endif
-
- #ifndef FWPRHDLR_H
- #include "FWPrHdlr.h" // FW_CPrintHandler
- #endif
-
- // ----- Graphic Includes -----
- #ifndef FWRECT_H
- #include <FWRect.h> // FW_CRect
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h" // FW_CRectShape
- #endif
-
- #ifndef FWGXUTIL_H
- #include "FWGXUtil.h" // FW_CGraphicContextGX
- #endif
-
- // for QuickDraw GX
- #ifndef __GXGRAPHICS__
- #include <GXGraphics.h> // GXNewRectangle()
- #endif
-
- #ifndef __GXENVIRONMENT__
- #include <GXEnvironment.h> // GXNewWindowViewPort()
- #endif
-
- #include <GXFonts.h>
- #include <GXLayout.h>
-
-
- //========================================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment GraphicsGX
- #endif
-
- //========================================================================================
- FW_DEFINE_AUTO(CGraphicsGXFrame)
-
- //========================================================================================
- CGraphicsGXFrame::CGraphicsGXFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, CGraphicsGXPart* graphicsgxPart)
- : FW_CFrame(ev, odFrame, presentation, graphicsgxPart)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- CGraphicsGXFrame::~CGraphicsGXFrame()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- void
- CGraphicsGXFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape) // Override
- {
- this->MyDrawWithODF(ev, odFacet, invalidShape);
- {
- FW_CGraphicContextGX gxContext(ev, odFacet, invalidShape);
- this->MyDrawGXBoxes(ev, gxContext);
- this->MyDrawGXText(ev, gxContext);
- }
- }
-
- //----------------------------------------------------------------------------------------
- void
- CGraphicsGXFrame::MyDrawWithODF(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext context(ev, this, odFacet, invalidShape);
- FW_CRect rect(FW_IntToFixed(25), FW_IntToFixed(25), FW_IntToFixed(75), FW_IntToFixed(75) );
- FW_CRectShape rectShape(rect, FW_kFill);
- rectShape.GetInk().SetForeColor(FW_kRGBGreen);
- rectShape.Render(context);
- }
-
- //----------------------------------------------------------------------------------------
- void
- CGraphicsGXFrame::MyDrawGXBoxes(Environment *ev, FW_CGraphicContextGX& context)
- {
- gxRectangle rectData = {ff(100), ff(100), ff(200), ff(300)};
- Fixed rotateCenter = ff(150);
- gxShape shape = ::GXNewRectangle(&rectData);
- context.DrawShape(shape);
-
- ::GXRotateShape(shape, ff(-45), rotateCenter, rotateCenter);
- gxColor myColor;
- myColor.space = gxRGBSpace;
- myColor.profile = NULL;
- myColor.element.rgb.red = 0x8000;
- myColor.element.rgb.green = 0x1000;
- myColor.element.rgb.blue = 0xE000;
- ::GXSetShapeColor(shape, &myColor);
- context.DrawShape(shape);
-
- ::GXDisposeShape(shape);
- }
-
- //----------------------------------------------------------------------------------------
- void
- CGraphicsGXFrame::MyDrawGXText(Environment *ev, FW_CGraphicContextGX& context)
- {
- gxPoint position = {ff(50), ff(50)};
- gxShape textShape =
- ::GXNewText(20, (unsigned char*)" The ffish in GX", &position);
-
- gxStyle textStyle = ::GXNewStyle();
- gxRunFeature runFeature[1];
- // runFeature[0].featureType = ligaturesType;
- runFeature[0].featureSelector = gxNoLigatureSplits;
- ::GXSetStyleRunFeatures(textStyle, 1, runFeature);
- ::GXSetStyleTextSize(textStyle, ff(36));
- ::GXSetShapeStyle(textShape, textStyle);
-
- gxFont aFont;
- long numFonts = ::GXFindFonts(nil, gxFullFontName, gxMacintoshPlatform,
- gxRomanScript, gxEnglishLanguage, strlen("Apple Chancery"),
- (const unsigned char*)"Apple Chancery", 1, 1, &aFont);
- ::GXSetShapeFont(textShape, aFont);
- for (short i = 0; i <=3; i++)
- {
- ::GXRotateShape(textShape, ff(i*15), position.x, position.y);
- context.DrawShape(textShape);
- }
- ::GXDisposeShape(textShape);
- }
-
- //------------------------------------------------------------------------------
- FW_CPrintHandler*
- CGraphicsGXFrame::NewPrintHandler(Environment* ev)
- {
- FW_CPart* part = GetPart(ev);
- return new FW_CPrintHandler(part, this);
- }
-
- //------------------------------------------------------------------------------
- FW_Boolean
- CGraphicsGXFrame::IsCurrentlyPrintable(Environment* ev) const
- {
- return TRUE;
- }
-
- //------------------------------------------------------------------------------
- void
- CGraphicsGXFrame::GetPrintContentExtent(Environment *ev, FW_CPoint& extent) const
- {
- FW_CRect frameRect = this->GetBounds(ev);
- extent = frameRect.Size();
- }
-
-