home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 3.9 KB | 138 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWTabber.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWTABBER_H
- #include "FWTabber.h"
- #endif
-
- #ifndef FWEVENTH_H
- #include "FWEventH.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWEVEDEF_H
- #include "FWEveDef.h"
- #endif
-
- #ifndef FWVIEW_H
- #include "FWSView.h"
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwevents
- #endif
-
- //========================================================================================
- // CLASS FW_CViewTabber
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(FW_CViewTabber, FW_MEventHandler)
-
- //----------------------------------------------------------------------------------------
- // FW_CViewTabber::FW_CViewTabber
- //----------------------------------------------------------------------------------------
-
- FW_CViewTabber::FW_CViewTabber(Environment* ev, FW_CSuperView* parent, short tabbingKey)
- : FW_MEventHandler(),
- fParentView(parent),
- fFirstView(NULL),
- fNextView(NULL),
- fFoundCurrent(FALSE),
- fTabbingKey(tabbingKey)
- {
- parent->AdoptEventHandler(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewTabber::~FW_CViewTabber
- //----------------------------------------------------------------------------------------
-
- FW_CViewTabber::~FW_CViewTabber()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewTabber::DispatchVirtualKey
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CViewTabber::DoVirtualKey(Environment* ev,
- const FW_CVirtualKeyEvent& keyEvent)
- {
- if (keyEvent.GetKeyCode(ev) == fTabbingKey) {
- Tab(ev, fParentView, keyEvent.IsExtendModifier(ev));
- return FW_kHandled;
- }
- else
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewTabber::Tab
- //----------------------------------------------------------------------------------------
-
- void FW_CViewTabber::Tab(Environment* ev, FW_CSuperView* parentView, FW_Boolean tabBackward)
- {
- Reset();
-
- FindTargets(ev, parentView, tabBackward);
-
- if (fNextView == NULL) {
- // Wrap-around to first target
- fNextView = fFirstView;
- }
-
- if (fNextView)
- {
- fNextView->BecomeTarget(ev, TRUE);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CViewTabber::FindTargets
- //----------------------------------------------------------------------------------------
-
- void FW_CViewTabber::FindTargets(Environment* ev, FW_CSuperView* parent, FW_Boolean tabBackward)
- {
- FW_CViewIterator ite(parent);
- FW_CView* subview = tabBackward ? ite.Last() : ite.First();
-
- for (; ite.IsNotComplete(); subview = tabBackward ? ite.Previous() : ite.Next())
- {
- FW_Boolean canBeTarget = subview->IsEnabled(ev) && subview->IsVisible(ev)
- && subview->WantsToBeTarget(ev);
-
- if ((fFirstView == NULL) && canBeTarget)
- fFirstView = subview; // found the first potential target
-
- if (subview->IsTarget(ev)) {
- fFoundCurrent = TRUE; // found the current target
- }
- else if (fFoundCurrent && (fNextView == NULL) && canBeTarget)
- {
- fNextView = subview;
- break; // found the next target
- }
-
- if (subview->HasSubViews(ev))
- FindTargets(ev, (FW_CSuperView*)subview, tabBackward); // try deeper
-
- if (fNextView) break; // found the next target
- }
- }
-
-