CMS 3D CMS Logo

IgQtAppContextService.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "Iguana/Studio/interface/IgQtAppContextService.h"
00004 #include <classlib/utils/DebugAids.h>
00005 #include <qwidget.h>
00006 #include <qtabwidget.h>
00007 
00008 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00009 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00010 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00011 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00012 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00013 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00014 
00015 IG_DEFINE_STATE_ELEMENT (IgQtAppContextService, "Services/Qt/App Context");
00016 
00017 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00018 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00019 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00020 
00021 IgQtAppContextService::IgQtAppContextService (IgState *state,
00022                                               QWidget *mainWindow)
00023     : m_state (state),
00024       m_mainWindow (mainWindow)
00025 {
00026     ASSERT (state);
00027     ASSERT (mainWindow);
00028     state->put (s_key, this);
00029 }
00030 
00031 IgQtAppContextService::~IgQtAppContextService (void)
00032 {
00033     ASSERT (m_state);
00034     ASSERT (m_mainWindow);
00035     m_state->detach (s_key);
00036 }
00037 
00038 void
00039 IgQtAppContextService::add (ConnectionCallback connection, 
00040                             void *data, bool enable /*=true*/)
00041 {
00042     lat::Callback focusIn;
00043     lat::Callback focusOut;
00044     focusIn = lat::CreateCallback (connection, data, enable);
00045     focusOut = lat::CreateCallback (connection, data, false);
00046 
00047     m_focusInCallbacks.push_back (focusIn);
00048     m_focusOutCallbacks.push_back (focusOut);    
00049 }
00050 
00051 
00052 void
00053 IgQtAppContextService::addOnFocusIn (lat::CallbackRep *callback)
00054 {
00055     m_focusInCallbacks.push_back (lat::Callback (callback));    
00056 }
00057 
00058 void
00059 IgQtAppContextService::addOnFocusOut (lat::CallbackRep *callback)
00060 {
00061     m_focusOutCallbacks.push_back (lat::Callback (callback));    
00062 }
00063                                      
00064 // FIXME: rather than doing focusIn focusOut we should have a
00065 // changeFocus which does both and does it up to the common state
00066 // level, rather than always up to the to of the state tree.
00067 
00068 void
00069 IgQtAppContextService::focusIn (void)
00070 {
00071     if (m_state->parent ())
00072     {
00073         IgQtAppContextService *service;
00074         service = IgQtAppContextService::get (m_state->parent ());      
00075         if (service)
00076             service->focusIn ();        
00077     }    
00078     
00079     //FIXME: use LOG macro for logging.
00080     //std::cerr << "Focusing in of state " << m_state << std::endl;    
00081     for (CallbackList::iterator i = m_focusInCallbacks.begin ();
00082          i != m_focusInCallbacks.end ();
00083          i++)
00084     {
00085         (*i) ();        
00086     }    
00087 }
00088 
00089 void
00090 IgQtAppContextService::focusOut (void)
00091 {
00092     //FIXME: use LOG macro for logging.
00093     //std::cerr << "Focusing out of state " << m_state << std::endl;    
00094     for (CallbackList::iterator i = m_focusOutCallbacks.begin ();
00095          i != m_focusOutCallbacks.end ();
00096          i++)
00097     {
00098         (*i) ();
00099     }    
00100     
00101     if (m_state->parent ())
00102     {
00103         IgQtAppContextService *service;
00104         service = IgQtAppContextService::get (m_state->parent ());      
00105         if (service)
00106             service->focusOut ();
00107     }    
00108 }

Generated on Tue Jun 9 17:38:49 2009 for CMSSW by  doxygen 1.5.4