michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: michael@0: michael@0: #ifndef nsComposerCommandsUpdater_h__ michael@0: #define nsComposerCommandsUpdater_h__ michael@0: michael@0: #include "nsCOMPtr.h" // for already_AddRefed, nsCOMPtr michael@0: #include "nsIDocumentStateListener.h" michael@0: #include "nsISelectionListener.h" michael@0: #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS michael@0: #include "nsITimer.h" // for NS_DECL_NSITIMERCALLBACK, etc michael@0: #include "nsITransactionListener.h" // for nsITransactionListener michael@0: #include "nsIWeakReferenceUtils.h" // for nsWeakPtr michael@0: #include "nscore.h" // for NS_IMETHOD, nsresult, etc michael@0: michael@0: class nsIDOMWindow; michael@0: class nsITransaction; michael@0: class nsITransactionManager; michael@0: class nsPICommandUpdater; michael@0: michael@0: class nsComposerCommandsUpdater : public nsISelectionListener, michael@0: public nsIDocumentStateListener, michael@0: public nsITransactionListener, michael@0: public nsITimerCallback michael@0: { michael@0: public: michael@0: michael@0: nsComposerCommandsUpdater(); michael@0: virtual ~nsComposerCommandsUpdater(); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsISelectionListener michael@0: NS_DECL_NSISELECTIONLISTENER michael@0: michael@0: // nsIDocumentStateListener michael@0: NS_DECL_NSIDOCUMENTSTATELISTENER michael@0: michael@0: // nsITimerCallback interfaces michael@0: NS_DECL_NSITIMERCALLBACK michael@0: michael@0: /** nsITransactionListener interfaces michael@0: */ michael@0: NS_IMETHOD WillDo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt); michael@0: NS_IMETHOD DidDo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aDoResult); michael@0: NS_IMETHOD WillUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt); michael@0: NS_IMETHOD DidUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aUndoResult); michael@0: NS_IMETHOD WillRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt); michael@0: NS_IMETHOD DidRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aRedoResult); michael@0: NS_IMETHOD WillBeginBatch(nsITransactionManager *aManager, bool *aInterrupt); michael@0: NS_IMETHOD DidBeginBatch(nsITransactionManager *aManager, nsresult aResult); michael@0: NS_IMETHOD WillEndBatch(nsITransactionManager *aManager, bool *aInterrupt); michael@0: NS_IMETHOD DidEndBatch(nsITransactionManager *aManager, nsresult aResult); michael@0: NS_IMETHOD WillMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction, michael@0: nsITransaction *aTransactionToMerge, bool *aInterrupt); michael@0: NS_IMETHOD DidMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction, michael@0: nsITransaction *aTransactionToMerge, michael@0: bool aDidMerge, nsresult aMergeResult); michael@0: michael@0: michael@0: nsresult Init(nsIDOMWindow* aDOMWindow); michael@0: michael@0: protected: michael@0: michael@0: enum { michael@0: eStateUninitialized = -1, michael@0: eStateOff = false, michael@0: eStateOn = true michael@0: }; michael@0: michael@0: bool SelectionIsCollapsed(); michael@0: nsresult UpdateDirtyState(bool aNowDirty); michael@0: nsresult UpdateOneCommand(const char* aCommand); michael@0: nsresult UpdateCommandGroup(const nsAString& aCommandGroup); michael@0: michael@0: already_AddRefed GetCommandUpdater(); michael@0: michael@0: nsresult PrimeUpdateTimer(); michael@0: void TimerCallback(); michael@0: nsCOMPtr mUpdateTimer; michael@0: michael@0: nsWeakPtr mDOMWindow; michael@0: nsWeakPtr mDocShell; michael@0: int8_t mDirtyState; michael@0: int8_t mSelectionCollapsed; michael@0: bool mFirstDoOfFirstUndo; michael@0: michael@0: michael@0: }; michael@0: michael@0: extern "C" nsresult NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult); michael@0: michael@0: michael@0: #endif // nsComposerCommandsUpdater_h__