1 /* AbiSource Application Framework 2 * Copyright (C) 1998-2000 AbiSource, Inc. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 * 02110-1301 USA. 18 */ 19 20 21 #ifndef AV_LISTENER_H 22 #define AV_LISTENER_H 23 24 /* pre-emptive dismissal; ut_types.h is needed by just about everything, 25 * so even if it's commented out in-file that's still a lot of work for 26 * the preprocessor to do... 27 */ 28 #ifndef UT_TYPES_H 29 #include "ut_types.h" 30 #endif 31 32 class AV_View; 33 34 typedef UT_uint32 AV_ListenerId; 35 36 37 typedef enum _AV_ListenerType 38 { 39 AV_LISTENER_MENU, 40 AV_LISTENER_TOOLBAR, 41 AV_LISTENER_LEFTRULER, 42 AV_LISTENER_TOPRULER, 43 AV_LISTENER_SCROLLBAR, 44 AV_LISTENER_VIEW, 45 AV_LISTENER_STATUSBAR, 46 AV_LISTENER_CARET, 47 AV_LISTENER_PLUGIN, 48 AV_LISTENER_PLUGIN_EXTRA 49 50 } AV_ListenerType; 51 52 // TODO how did we fill this mask so fast? 53 // TODO next it'll need to become a 32-bit mask. YEP done! MES 2/10/2004 54 typedef UT_uint32 AV_ChangeMask; 55 #define AV_CHG_NONE (static_cast<AV_ChangeMask>(0x0000)) 56 #define AV_CHG_DO (static_cast<AV_ChangeMask>(0x0001)) // canDo 57 #define AV_CHG_DIRTY (static_cast<AV_ChangeMask>(0x0002)) // isDirty 58 #define AV_CHG_EMPTYSEL (static_cast<AV_ChangeMask>(0x0004)) // isSelectionEmpty 59 #define AV_CHG_FILENAME (static_cast<AV_ChangeMask>(0x0008)) // getFilename 60 #define AV_CHG_FMTBLOCK (static_cast<AV_ChangeMask>(0x0010)) // getBlockFormat 61 #define AV_CHG_FMTCHAR (static_cast<AV_ChangeMask>(0x0020)) // getCharFormat 62 #define AV_CHG_CLIPBOARD (static_cast<AV_ChangeMask>(0x0040)) 63 #define AV_CHG_PAGECOUNT (static_cast<AV_ChangeMask>(0x0080)) // number of pages 64 #define AV_CHG_WINDOWSIZE (static_cast<AV_ChangeMask>(0x0100)) 65 #define AV_CHG_FMTSECTION (static_cast<AV_ChangeMask>(0x0200)) 66 #define AV_CHG_COLUMN (static_cast<AV_ChangeMask>(0x0400)) 67 #define AV_CHG_INPUTMODE (static_cast<AV_ChangeMask>(0x0800)) 68 #define AV_CHG_FMTSTYLE (static_cast<AV_ChangeMask>(0x1000)) // getStyle 69 #define AV_CHG_INSERTMODE (static_cast<AV_ChangeMask>(0x2000)) 70 #define AV_CHG_HDRFTR (static_cast<AV_ChangeMask>(0x4000)) 71 #define AV_CHG_DIRECTIONMODE (static_cast<AV_ChangeMask>(0x4000)) 72 #define AV_CHG_FRAMEDATA (static_cast<AV_ChangeMask>(0x8000)) // frame-level preferences (pFrameData) 73 #define AV_CHG_KEYPRESSED (static_cast<AV_ChangeMask>(0x10000)) // A key was pressed 74 #define AV_CHG_BLOCKCHECK (static_cast<AV_ChangeMask>(0x20000)) // Checking a block in background 75 #define AV_CHG_FOCUS (static_cast<AV_ChangeMask>(0x40000)) // Change of focus 76 #define AV_CHG_MOUSEPOS (static_cast<AV_ChangeMask>(0x80000)) // Change of mouse position 77 #define AV_CHG_CELL (static_cast<AV_ChangeMask>(0x100000)) // Change of active cell/caret moved out of table 78 #define AV_CHG_ALL (static_cast<AV_ChangeMask>(0xFFFFFFFF)) 79 80 #define AV_CHG_SAVE (static_cast<AV_ChangeMask>(AV_CHG_DO | AV_CHG_DIRTY | AV_CHG_FILENAME)) 81 #define AV_CHG_TYPING (static_cast<AV_ChangeMask>(AV_CHG_DO | AV_CHG_DIRTY | AV_CHG_EMPTYSEL | AV_CHG_COLUMN)) 82 #define AV_CHG_MOTION (static_cast<AV_ChangeMask>(AV_CHG_EMPTYSEL | AV_CHG_FMTSTYLE | AV_CHG_FMTBLOCK | AV_CHG_FMTSECTION | AV_CHG_FMTCHAR | AV_CHG_COLUMN | AV_CHG_CELL)) 83 #define AV_CHG_STYLE_PARA (static_cast<AV_ChangeMask>(AV_CHG_FMTBLOCK | AV_CHG_FMTCHAR)) 84 /* 85 Various UI elements (title, toolbar, etc.) need to stay in sync with 86 the current state of an AV_View. They can do so by registering 87 an AV_Listener with the AV_View in order to be notified of the existence 88 of certain changes to the document as they occur. 89 90 Note that these notifications do *not* pass any document state, they 91 simply note the existence of a certain category of changes to that state. 92 93 The view will notify each registered listener (in an undefined order). 94 When the listener registers, it is provided an ID which may be used 95 later to refer to it. 96 */ 97 98 class ABI_EXPORT AV_Listener 99 { 100 public: ~AV_Listener()101 virtual ~AV_Listener() {} 102 103 virtual bool notify(AV_View * pView, const AV_ChangeMask mask) = 0; 104 virtual AV_ListenerType getType(void) = 0; 105 }; 106 107 108 class ABI_EXPORT AV_ListenerExtra : public AV_Listener 109 { 110 public: 111 virtual bool notify(AV_View * pView, const AV_ChangeMask mask, void * pPrivateData =NULL) = 0; 112 virtual AV_ListenerType getType(void) = 0; 113 }; 114 115 #endif /* AV_LISTENER_H */ 116