00001
00002
00003 #include "Iguana/Studio/interface/IgQtAppContextService.h"
00004 #include <classlib/utils/DebugAids.h>
00005 #include <qwidget.h>
00006 #include <qtabwidget.h>
00007
00008
00009
00010
00011
00012
00013
00014
00015 IG_DEFINE_STATE_ELEMENT (IgQtAppContextService, "Services/Qt/App Context");
00016
00017
00018
00019
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 )
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
00065
00066
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
00080
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
00093
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 }