GME  13
AnnotatorEventSink.cpp
Go to the documentation of this file.
00001 //################################################################################################
00002 //
00003 // Annotator Event Sink implementation
00004 //      AnnotatorEventSink.cpp
00005 //
00006 //################################################################################################
00007 
00008 #include "StdAfx.h"
00009 #include "AnnotatorEventSink.h"
00010 #include "GMEView.h"
00011 
00012 
00013 //################################################################################################
00014 //
00015 // CLASS : CAnnotatorEventSink
00016 //
00017 //################################################################################################
00018 
00019 void CAnnotatorEventSink::SetView(CGMEView* view)
00020 {
00021         m_view = view;
00022 }
00023 
00024 void CAnnotatorEventSink::SetGuiAnnotator(CGuiAnnotator* guiAnnotator)
00025 {
00026         m_guiAnnotator = guiAnnotator;
00027 }
00028 
00029 CAnnotatorEventSink::CAnnotatorEventSink():
00030         m_view(NULL),
00031         m_guiAnnotator(NULL)
00032 {
00033 }
00034 
00035 CAnnotatorEventSink::~CAnnotatorEventSink()
00036 {
00037 }
00038 
00039 
00041 // IMgaElementDecoratorEvents
00042 
00043 STDMETHODIMP CAnnotatorEventSink::Refresh(refresh_mode_enum refreshMode)
00044 {
00045         if (refreshMode == RM_REDRAW_SELF)
00046                 m_view->Invalidate(true);
00047         else if (refreshMode != RM_NOREFRESH)
00048                 m_view->PostMessage(WM_USER_DECOR_VIEWREFRESH_REQ, 0, refreshMode);
00049 
00050         return S_OK;
00051 }
00052 
00053 STDMETHODIMP CAnnotatorEventSink::OperationCanceled()
00054 {
00055         m_view->CancelDecoratorOperation(false);
00056 
00057         return S_OK;
00058 }
00059 
00060 STDMETHODIMP CAnnotatorEventSink::CursorChanged(LONG newCursorID)
00061 {
00062         m_view->SetIsCursorChangedByDecorator(true);
00063 
00064         return S_OK;
00065 }
00066 
00067 STDMETHODIMP CAnnotatorEventSink::CursorRestored()
00068 {
00069         m_view->SetIsCursorChangedByDecorator(false);
00070 
00071         return S_OK;
00072 }
00073 
00074 STDMETHODIMP CAnnotatorEventSink::LabelEditingStarted(LONG left, LONG top, LONG right, LONG bottom)
00075 {
00076         m_view->SetInElementDecoratorOperation(true);
00077         m_view->SetDecoratorOrAnnotator(false);
00078         m_view->SetShouldCommitOperation(false);
00079         m_view->StartDecoratorOperation();
00080 
00081         return S_OK;
00082 }
00083 
00084 STDMETHODIMP CAnnotatorEventSink::LabelEditingFinished(LONG left, LONG top, LONG right, LONG bottom)
00085 {
00086         if (!m_view->IsInOpenedDecoratorTransaction()) {
00087                 m_view->SetShouldCommitOperation(false);
00088                 m_view->SetInElementDecoratorOperation(false);
00089                 m_view->SetObjectInDecoratorOperation(NULL);
00090                 m_view->SetAnnotatorInDecoratorOperation(NULL);
00091         }
00092 
00093         return S_OK;
00094 }
00095 
00096 STDMETHODIMP CAnnotatorEventSink::LabelChanged(BSTR newLabel)
00097 {
00098         m_view->BeginTransaction();
00099         m_view->SetInOpenedDecoratorTransaction(true);
00100         m_view->SetShouldCommitOperation(true);
00101         m_view->EndDecoratorOperation();
00102 
00103         return S_OK;
00104 }
00105 
00106 STDMETHODIMP CAnnotatorEventSink::LabelMovingStarted(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00107 {
00108         return S_OK;
00109 }
00110 
00111 STDMETHODIMP CAnnotatorEventSink::LabelMoving(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00112 {
00113         return S_OK;
00114 }
00115 
00116 STDMETHODIMP CAnnotatorEventSink::LabelMovingFinished(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00117 {
00118         return S_OK;
00119 }
00120 
00121 STDMETHODIMP CAnnotatorEventSink::LabelMoved(LONG nFlags, LONG x, LONG y)
00122 {
00123         return S_OK;
00124 }
00125 
00126 STDMETHODIMP CAnnotatorEventSink::LabelResizingStarted(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00127 {
00128         return S_OK;
00129 }
00130 
00131 STDMETHODIMP CAnnotatorEventSink::LabelResizing(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00132 {
00133         return S_OK;
00134 }
00135 
00136 STDMETHODIMP CAnnotatorEventSink::LabelResizingFinished(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00137 {
00138         return S_OK;
00139 }
00140 
00141 STDMETHODIMP CAnnotatorEventSink::LabelResized(LONG nFlags, LONG cx, LONG cy)
00142 {
00143         return S_OK;
00144 }
00145 
00146 STDMETHODIMP CAnnotatorEventSink::GeneralOperationStarted(ULONGLONG operationData)
00147 {
00148         m_operationData = (void*)operationData;
00149 
00150         m_view->BeginTransaction();
00151         m_view->SetInElementDecoratorOperation(true);
00152         m_view->SetDecoratorOrAnnotator(false);
00153         m_view->SetInOpenedDecoratorTransaction(true);
00154         m_view->SetShouldCommitOperation(false);
00155         m_view->StartDecoratorOperation();
00156 
00157         return S_OK;
00158 }
00159 
00160 STDMETHODIMP CAnnotatorEventSink::GeneralOperationFinished(ULONGLONG* operationData)
00161 {
00162         if (operationData != NULL)
00163                 *operationData = (ULONGLONG)m_operationData;
00164 
00165         m_view->SetInElementDecoratorOperation(false);
00166         m_view->SetShouldCommitOperation(true);
00167         m_view->EndDecoratorOperation();
00168 
00169         return S_OK;
00170 }
00171 
00172 STDMETHODIMP CAnnotatorEventSink::WindowMovingStarted(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00173 {
00174         return S_OK;
00175 }
00176 
00177 STDMETHODIMP CAnnotatorEventSink::WindowMoving(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00178 {
00179         return S_OK;
00180 }
00181 
00182 STDMETHODIMP CAnnotatorEventSink::WindowMovingFinished(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00183 {
00184         return S_OK;
00185 }
00186 
00187 STDMETHODIMP CAnnotatorEventSink::WindowMoved(LONG nFlags, LONG x, LONG y)
00188 {
00189         return S_OK;
00190 }
00191 
00192 STDMETHODIMP CAnnotatorEventSink::WindowResizingStarted(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00193 {
00194         m_view->SetInElementDecoratorOperation(true);
00195         m_view->SetDecoratorOrAnnotator(false);
00196         m_view->SetShouldCommitOperation(false);
00197         m_view->SetOriginalRect(CRect(left, top, right, bottom));
00198 
00199         return S_OK;
00200 }
00201 
00202 STDMETHODIMP CAnnotatorEventSink::WindowResizing(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00203 {
00204 //      TODO m_guiAnnotator->ResizeObject(CRect(left, top, right, bottom));
00205         m_view->Invalidate();
00206         m_view->SetShouldCommitOperation(false);
00207 
00208         return S_OK;
00209 }
00210 
00211 STDMETHODIMP CAnnotatorEventSink::WindowResizingFinished(LONG nFlags, LONG left, LONG top, LONG right, LONG bottom)
00212 {
00213 //      TODO m_guiAnnotator->ResizeObject(CRect(left, top, right, bottom));
00214         m_view->SetInElementDecoratorOperation(false);
00215         m_view->SetOriginalRectEmpty();
00216 
00217         return S_OK;
00218 }
00219 
00220 STDMETHODIMP CAnnotatorEventSink::WindowResized(LONG nFlags, LONG cx, LONG cy)
00221 {
00222         m_view->BeginTransaction();
00223         m_view->SetInOpenedDecoratorTransaction(true);
00224         m_view->SetShouldCommitOperation(true);
00225 
00226         return S_OK;
00227 }