00001 //<<<<<< INCLUDES >>>>>> 00002 00003 #include "Iguana/Studio/interface/IgQtFocusManager.h" 00004 #include "Iguana/Studio/interface/IgView.h" 00005 #include "Iguana/Studio/interface/IgQtAppContextService.h" 00006 #include "Iguana/Framework/interface/IgState.h" 00007 #include <qwidget.h> 00008 #undef emit // zap qt macro 00009 #include <iomanip> 00010 #include <map> 00011 00012 //<<<<<< PRIVATE DEFINES >>>>>> 00013 //<<<<<< PRIVATE CONSTANTS >>>>>> 00014 //<<<<<< PRIVATE TYPES >>>>>> 00015 //<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> 00016 //<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> 00017 //<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> 00018 //<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> 00019 //<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> 00020 //<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> 00021 00022 IgQtFocusManager::IgQtFocusManager (IgState *state, std::map<QWidget *, IgView *> *views) 00023 : m_state (state), 00024 m_views (views), 00025 m_oldView (0) 00026 { 00027 } 00028 00029 void 00030 IgQtFocusManager::windowActivated (QWidget *widget) 00031 { 00032 IgView *selectedView = (*m_views)[widget]; 00033 IgState *newState = selectedView ? selectedView->state () : 0; 00034 IgState *oldState = m_oldView ? m_oldView->state () : 0; 00035 00036 00037 if (oldState) 00038 { 00039 IgQtAppContextService *contextService = IgQtAppContextService::get (oldState); 00040 contextService->focusOut (); 00041 } 00042 00043 if (newState) 00044 { 00045 IgQtAppContextService *contextService = IgQtAppContextService::get (newState); 00046 contextService->focusIn (); 00047 } 00048 00049 m_oldView = selectedView; 00050 }