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