home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.4 KB | 183 lines | [TEXT/CWIE] |
- //========================================================================================
- //
- // File: Frame.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef BEHAVIOR_H
- #include "Behavior.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- // ----- Framework -----
-
- #ifndef FWBUTTON_H
- #include "FWButton.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWDRCMD_H
- #include "FWDrCmd.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- // ----- OpenDoc -----
-
- #ifndef SOM_ODFocusSet_xh
- #include <FocusSet.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfbutton
- #endif
-
- //========================================================================================
- // class CButtonFrame
- //========================================================================================
-
- FW_DEFINE_AUTO(CButtonFrame)
- FW_DEFINE_CLASS_M2(CButtonFrame, FW_CFrame, FW_MReceiver)
-
- //----------------------------------------------------------------------------------------
- // CButtonFrame::CButtonFrame
- //----------------------------------------------------------------------------------------
-
- CButtonFrame::CButtonFrame(Environment* ev,
- ODFrame* frame,
- FW_CPresentation* presentation,
- FW_CPart* part,
- CButtonContent* content) :
- FW_CFrame(ev, frame, presentation, part),
- FW_MDroppableFrame(ev, this),
- fOptionBehavior(NULL),
- fCurrentFocusSet(NULL),
- fContent(content)
- {
- ChangeDroppableState(ev, FW_kFrameDroppable); // Only droppable in view as frame
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonFrame::~CButtonFrame
- //----------------------------------------------------------------------------------------
-
- CButtonFrame::~CButtonFrame()
- {
- FW_START_DESTRUCTOR
-
- delete fCurrentFocusSet;
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonFrame::PostCreateViewFromStream
- //----------------------------------------------------------------------------------------
- // PostCreateViewFromStream is called after subviews are created from resources.
- // Add code which cannot be handled by current resource types.
-
- void CButtonFrame::PostCreateViewFromStream(Environment* ev)
- {
- // ----- Add a behavior to our button
- FW_CView* view = FindViewByID(ev, 1);
- FW_CButton* button = FW_DYNAMIC_CAST(FW_CButton, view);
- FW_ASSERT(button != NULL);
-
- // Add the button as the notifier for the content object
- fContent->AddInterest(button, FW_kButtonPressedMsg);
-
- // The role of the COptionBehavior is to detect Option-Click (In this case change the focus
- // set of the frame). Having a behavior allows us to not have to subclass FW_CButton.
- fOptionBehavior = FW_NEW(COptionBehavior, (ev));
- button->AdoptEventHandler(ev, fOptionBehavior);
-
- fCurrentFocusSet = fOptionBehavior->GetDesiredFocusSet();
-
- // WARNING: Make sure that classes created from resources won't be dead-stripped
- FW_DO_NOT_DEAD_STRIP(FW_CGrowBox);
- FW_DO_NOT_DEAD_STRIP(FW_CButton);
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CButtonFrame::Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape)
- {
- FW_CViewContext fc(ev, NULL, facet, invalidShape);
-
- // Just erase before the button draws itself
- FW_CRect invalidRect;
- fc.GetClipRect(invalidRect);
- FW_CRectShape::RenderRect(fc, invalidRect, FW_kFill, FW_kWhiteEraseInk);
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonFrame::RequestFocusSet
- //----------------------------------------------------------------------------------------
- // Set the fCurrentFocusSet to DesiredFocusSet. FW_CFrame::RequestFocusSet will call our CButtonFrame::GetFocusSet
-
- FW_Boolean CButtonFrame::RequestFocusSet(Environment *ev)
- {
- fCurrentFocusSet = fOptionBehavior->GetDesiredFocusSet();
-
- return FW_CFrame::RequestFocusSet(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonFrame::GetFocusSet
- //----------------------------------------------------------------------------------------
- // Usually GetFocusSet simply returns the presentation's focusSet. But here we want to
- // have one focusSet per frame instead of one per presentation.
-
- ODFocusSet* CButtonFrame::GetFocusSet(Environment* ev) const
- {
- FW_UNUSED(ev);
-
- return fCurrentFocusSet;
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CButtonFrame::NewDropCommand(Environment *ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint)
- {
-
- return FW_NEW(FW_CDropCommand, (ev, frame, dropInfo, facet, dropPoint, FW_kCantUndo));
- }
-
-