home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CPCreditNowDemo.cpp
-
-
- Modifications to support the CreditNOWDemo are surrounded by: //AET
- comment lines. Beginning of a block has a trailing <<, end has >>.
-
-
- There are 6 text input fields, two text output fields, and a button.
- The button is a real ToolBox control. The text fields are driven from
- Text Edit via TENew().
-
- The Tab key moves you from field to field. The Return and Enter keys
- cause the "Authorize" function to be called. When "tab key" is pressed a
- Validate function is called for the text field. Validate currently does
- nothing.
-
- CreateTextFields() sets the rectangles and creates the TextEdit records for
- the input and output fields. It is called by FacetAdded(). The RegisterIdle()
- is also done there.
-
- The text fields are created and accessed within CFocus blocks.
-
- CreateButton() creates the Button which is called from FacetAdded(),
- and drawn in the Draw method. MyUsedShapeHandleMouseDown calls Authorize()
- to construct and send the AppleEvent to the CreditNOW! server.
-
-
-
- Problems:
-
- •Before the TextEdit calls were surrounded with CFocus clicking on the
- button worked. Now the ODPoint comes back with a ridiculous value and "hit"
- in the MyHandleMouseDown method is zero. The real mouse location in the window
- is within the bounds of the button. So I ignore the OpenDoc hit testing and
- just do real QuickDraw control hit testing stuff.
-
- •Somebody changes the window title back to "untitled <date>" after I
- painstakingly set it to what I want!!!
-
- •I can't get rid of the "Dont Save, Cancel, Save" dialog even though I dont
- want to save any data!!
-
-
-
- Contains: CPCreditNowDemo OpenDoc part editor class implementation.
- Built using PartMaker, then modified.
- Written by: PartMaker
-
- Change History (most recent first):
-
- <3> 4/14/95 JS Updated for Developer Release 2
- <4> 3/8/95 JS Updated to b1c13/c14
- <3> 3/8/95 RA Add tokenized kODPresDefault param to RegisterWindow().
- <2> 2/21/95 RA Add kODFrameObject param to RegisterWindow().
- <1> 2/2/95 RA first checked in
- <0> PartMaker source by E. Soldan, T. Çelik, J. Alfke, R. Adkins, D. Nelson, J. Schalk
- */
-
- #ifndef _CREDITNOWDEMO_
- #include "CPCreditNowDemo.h"
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- //----------------------------------------------------------------------------------------
-
- CPCreditNowDemo::CPCreditNowDemo()
- {
- // CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Constructor
- EnteringMethod("\pCPCreditNowDemo::CPCreditNowDemo");
-
- fDirty = kODFalse;
- fWindowID = 0;
- fSession = kODNULL;
- fSelf = kODNULL;
- fStorageUnit = kODNULL;
- fMenuBar = kODNULL;
- fDraftKey = 0;
- fThumbnailPicture = kODNULL;
-
- // Note that fFrameList
- // and fTextFields
- // are static fields, and therefore
- // constructors are automatically called before
- // CPCreditNOWDemo constructor.
- //AET<<
- fAuthButton = kODNULL;
- fCurrentField = kODNULL;
- fAddressVerify = kODNULL;
- fAuthorization = kODNULL;
- fFacet = kODNULL;
- //AET>>
- }
-
- //----------------------------------------------------------------------------------------
-
- CPCreditNowDemo::~CPCreditNowDemo()
- {
- // CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Destructor
- EnteringMethod("\pCPCreditNowDemo::~CPCreditNowDemo");
- }
-
- //----------------------------------------------------------------------------------------
-
- void CPCreditNowDemo::Release(Environment* ev)
- {
- // CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Release
- EnteringMethod("\pCPCreditNowDemo::Release");
-
- if (fSelf->GetRefCount(ev) == 1) {
- // Here is where you would unregister idle time for the part if
- // have registered time. Note that if you unregister without
- // registering, OpenDoc will crash. It's not just a simple
- // look-up-and-if-there-remove kind of operation.
-
- // Note that if you unregister idle here, OpenDoc will need to
- // call Release (here) due to it. This means that when we call
- // to unregister the idle, we are nesting calls to Release.
- // Due to this, I return out of each case, just to make the
- // flow of control of the call(s) to Release more straightforward.
-
- // Note that if you are going to use idle registration, you will
- // need to include "Disptch.h"
-
- //AET<<
- ( fSession->GetDispatcher(ev) )->UnregisterIdle(ev, fSelf, kODNULL);
- //AET>>
- return;
- }
- }
-
- //----------------------------------------------------------------------------------------
-
- ODID CPCreditNowDemo::Open(Environment* ev, ODFrame* frame)
- {
- // CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Open
- EnteringMethod("\pCPCreditNowDemo::Open");
-
- ODID windowID;
- ODWindow* window = kODNULL;
-
- if (frame) // Doing a View As Window or Open Root
- {
- if (frame->IsRoot(ev))
- {
- windowID = this->PrivOpenSavedWindow(ev, frame);
- }
- else
- {
- //ClockFrame* clockFrame = (ClockFrame*) frame->GetPartInfo(ev);
- //if (clockFrame)
- // windowID = clockFrame->ViewInWindow(ev);
- }
- }
- else
- {
- windowID = this->PrivOpenInitialWindow(ev);
- }
- return windowID;
- }
-
- //----------------------------------------------------------------------------------------
-
- ODWindow* CPCreditNowDemo::PrivCreateWindow(Environment *ev,ODFrame* sourceFrame)
- {
- // get rectangle
- Rect windRect;
- //AET<<
- ::SetRect(&windRect, 4, GetMBarHeight() + 24,
- 320,
- 295); // rgacsun
- //AET>>
-
- // get title
- Str255 windowTitleStr = "\pCreditNow!™ Demo"; // rgac
-
- ODPlatformWindow platformWindow = ::NewCWindow(kODNULL,
- &windRect,
- windowTitleStr,
- false,
- rDocProc, //AET
- (WindowPtr)-1L,
- true,
- kODNULL);
-
- ODBoolean isRoot = ((sourceFrame == kODNULL) || sourceFrame->IsRoot(ev));
-
- ODWindow* window = fSession->GetWindowState(ev)->RegisterWindow(ev,
- platformWindow, // newWindow
- isRoot ? // Persistent
- kODFrameObject: // Non-Persistent
- kODNonPersistentFrameObject, // frameType
- isRoot, // isRootWindow
- this->PrivWantResizableWindow(), // isResizable
- kODFalse, // isFloating
- kODFalse, // shouldSave rgac
- fSelf, // rootPart
- fSession->Tokenize(ev, kODViewAsFrame), // viewType
- fSession->Tokenize(ev, kODPresDefault), // presentation
- sourceFrame); // sourceFrame
- return window;
- }
-
- //----------------------------------------------------------------------------------------
-
- ODID CPCreditNowDemo::PrivOpenInitialWindow(Environment* ev)
- {
- ODWindow* window = this->PrivCreateWindow(ev, kODNULL);
- ODID windowID = window->GetID(ev);
- window->Open(ev);
- window->Show(ev);
- window->Select(ev);
- return windowID;
- }
-
- //----------------------------------------------------------------------------------------
-
- ODID CPCreditNowDemo::PrivOpenSavedWindow(Environment* ev, ODFrame* frame)
- {
- ODWindow* window = kODNULL;
- WindowProperties props;
-
- if (BeginGetWindowProperties(ev, frame, &props))
- {
- ODPlatformWindow platformWindow = NewCWindow(kODNULL, &(props.boundsRect), props.title,
- kODFalse, props.procID, (WindowPtr)-1L, props.hasCloseBox, props.refCon);
-
- window = fSession->GetWindowState(ev)->RegisterWindowForFrame(ev,
- platformWindow,
- frame,
- props.isRootWindow, // Keeps draft open
- kODTrue, // Is resizable
- kODFalse, // Is floating
- kODFalse, // shouldSave rgac
- props.sourceFrame);
- EndGetWindowProperties(ev, &props); // Release source frame
-
- window->Open(ev);
- window->Show(ev);
- return window->GetID(ev);
- }
- else
- return 0;
- }
-
- //----------------------------------------------------------------------------------------
-
- ODBoolean CPCreditNowDemo::PrivWantResizableWindow()
- {
- return kODFalse;
- }
-
- //----------------------------------------------------------------------------------------
-
- void CPCreditNowDemo::ReleaseAll(Environment* ev)
- {
- // CodeWarrior: Cmd-Click or Search:Find Definition • Explain_ReleaseAll
- EnteringMethod("\pCPCreditNowDemo::ReleaseAll");
-
- if (fMenuBar != kODNULL)
- fMenuBar->Release(ev);
- }
-
- //----------------------------------------------------------------------------------------
-
- void CPCreditNowDemo::PrivInvalAllDisplayFrames(Environment* ev)
- {
- // This is just a CPCreditNowDemo utility method.
-
- for (FrameLink *fl = fDisplayFrames.First(); fl->Frame(); fl = fl->Next())
- fl->Frame()->Invalidate(ev, kODNULL, kODNULL);
- }
-
- //----------------------------------------------------------------------------------------
- // Storage protocol
- //----------------------------------------------------------------------------------------
-
- void CPCreditNowDemo::IncrementRefCount(Environment* ev)
- {
- // CodeWarrior: Cmd-Click or Search:Find Definition • Explain_IncrementRefCount
- EnteringMethod("\pCPCreditNowDemo::IncrementRefCount");
- }
-
- //----------------------------------------------------------------------------------------
-
- void CPCreditNowDemo::CloneInto(Environment* ev, ODDraftKey key,
- ODStorageUnit* destinationSU, ODFrame* initiatingFrame)
- {
- // CodeWarrior: Cmd-Click or Search:Find Definition • Explain_CloneInto
- EnteringMethod("\pCPCreditNowDemo::CloneInto");
-
- // We must first verify that we've never written to this storage unit.
- // If we have, we should do nothing, otherwise we need to write out
- // the current state of the part content.
-
- if ( destinationSU->Exists(ev, kODPropContents, kCreditNowDemoKind, 0) == kODFalse )
- {
- // Add the properties we need to successfully externalize
- // ourselves into the destination storage unit.
- this->PrivCheckAndAddProperties(ev, destinationSU);
-
- // Write out the part's state information.
- this->PrivExternalizeStateInfo(ev, destinationSU, key, initiatingFrame);
-
- // Write out the part's content.
- this->PrivExternalizeContent(ev, destinationSU);
- }
- }
-
- //----------------------------------------------------------------------------------------
-
- ODSize CPCreditNowDemo::Purge(Environment* ev, ODSize size)
- {
- //
- ODUnused(size);
- EnteringMethod("\pCPCreditNowDemo::Purge");
-
- // CPCreditNowDemo doesn't do anything here.
- return 0;
- }
-