home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-03-29 | 3.8 KB | 154 lines | [TEXT/CWIE] |
- // Release Version: $ ODF 1 $
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- //================================================================================
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- // ----- Framework Includes -----
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h" //::FW_About()
- #endif
-
- #include "SLMixOS.h" // FW_GetMainScreenBounds
-
- //--- SOM library ------------------------------------------------
- #ifndef SOM_DevUniv_SFinance_xih
- #include "SFinance.xih" // DevUniv_SFinance SOM library
- #endif
-
- //==============================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment Calc
- #endif
-
- FW_DEFINE_AUTO(CCalcPart)
-
- //==============================================================================
- CCalcPart::CCalcPart(ODPart* odPart)
- : FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fPresentation(NULL),
- fLoanAmount(0),
- fAnnualInterestPercent(0),
- fLoanYears(0),
- fMonthlyPayment(0),
- fSOMFinanceCalc(NULL)
- {
- }
-
- //--------------------------------------------------------------------------------
- CCalcPart::~CCalcPart()
- {
- delete fSOMFinanceCalc;
- }
-
- //--------------------------------------------------------------------------------
- void
- CCalcPart::Initialize(Environment* ev) // Override
- {
- FW_CPart::Initialize(ev);
- FW_CSelection* selection = NULL;
- const ODType kMainPresentation = "Apple:Presentation:Calc";
- fPresentation = this->RegisterPresentation(ev, kMainPresentation, true, selection);
- fSOMFinanceCalc = new DevUniv_SFinance;
- }
-
- //--------------------------------------------------------------------------------
- FW_CFrame*
- CCalcPart::NewFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, FW_Boolean fromStorage) // Override
- {
- FW_UNUSED(presentation);
- FW_UNUSED(fromStorage);
- return FW_NEW(CCalcFrame, (ev, odFrame, presentation, this));
- }
-
- //--------------------------------------------------------------------------------
- FW_CContent*
- CCalcPart::NewPartContent(Environment* ev)
- {
- return NULL;
- }
-
- //--------------------------------------------------------------------------------
- FW_Boolean
- CCalcPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Boolean menuHandled = true;
- switch (theMenuEvent.GetCommandID(ev))
- {
- case kODCommandAbout:
- ::FW_About(ev, this, kAbout);
- break;
-
- default:
- menuHandled = false;
- }
- return menuHandled;
- }
-
- //-------------------------------------------------------------------
- CalcFloat
- CCalcPart::MyComputePayment(Environment* ev)
- {
- fMonthlyPayment = fSOMFinanceCalc->Payment(ev, fLoanAmount,
- fAnnualInterestPercent,
- fLoanYears);
- return fMonthlyPayment;
- }
-
- //-------------------------------------------------------------------
- void
- CCalcPart::MySetLoanAmount(CalcFloat borrowed)
- {
- fLoanAmount = borrowed;
- }
-
- //-------------------------------------------------------------------
- void
- CCalcPart::MySetAnnualInterestPercent(CalcFloat interest)
- {
- fAnnualInterestPercent = interest;
- }
-
- //-------------------------------------------------------------------
- void
- CCalcPart::MySetLoanYears(CalcFloat years)
- {
- fLoanYears = years;
- }
-
- //----------------------------------------------------------------------------------------
- FW_CWindow*
- CCalcPart::NewDocumentWindow(Environment* ev)
- {
- FW_CRect screenBounds;
- ::FW_GetMainScreenBounds(screenBounds);
- screenBounds.Inset(FW_IntToFixed(3), FW_IntToFixed(3));
-
- return new FW_CWindow(ev,
- this,
- FW_CPart::gViewAsFrameToken,
- fPresentation,
- FW_CPoint(FW_IntToFixed(280), FW_IntToFixed(200)),
- screenBounds.TopLeft(),
- FW_kDocumentWindow);
- }
-