• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

xap_App.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource Application Framework
00004  * Copyright (C) 1998,1999 AbiSource, Inc.
00005  * Copyright (C) 2004 Hubert Figuiere
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
00021  */
00022 
00023 
00024 #ifndef XAP_APP_H
00025 #define XAP_APP_H
00026 
00027 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00028  * so even if it's commented out in-file that's still a lot of work for
00029  * the preprocessor to do...
00030  */
00031 #ifndef UT_TYPES_H
00032 #include "ut_types.h"
00033 #endif
00034 #include "ut_vector.h"
00035 #include "ut_Language.h"
00036 #include "ut_string_class.h"
00037 #include "xap_AppImpl.h"
00038 #include "xav_Listener.h"
00039 #include <map>
00040 #include <string>
00041 #include <list>
00042 
00043 #define NUM_MODELESSID 39
00044 
00045 class XAP_DialogFactory;
00046 class XAP_Dialog_Modeless;
00047 class XAP_Toolbar_ControlFactory;
00048 class XAP_Frame;
00049 class EV_EditMethodContainer;
00050 class EV_EditBindingMap;
00051 class EV_EditEventMapper;
00052 class EV_Menu_ActionSet;
00053 class EV_Toolbar_ActionSet;
00054 class XAP_BindingSet;
00055 class XAP_Prefs;
00056 class XAP_StringSet;
00057 class XAP_Dictionary;
00058 class PD_DocumentRange;
00059 class AV_View;
00060 class AD_Document;
00061 class XAP_EncodingManager;
00062 class UT_String;
00063 class XAP_Menu_Factory;
00064 class XAP_Toolbar_Factory;
00065 class UT_UUIDGenerator;
00066 class GR_GraphicsFactory;
00067 class GR_Graphics;
00068 class GR_AllocInfo;
00069 class XAP_InputModes;
00070 class AV_Listener;
00071 class GR_EmbedManager;
00072 class XAP_Module;
00073 class UT_ScriptLibrary;
00074 
00075 
00076 #define XAP_SD_FILENAME_LENGTH 256
00077 #define XAP_SD_MAX_FILES 5
00078 
00084 struct ABI_EXPORT XAP_StateData
00085 {
00086     XAP_StateData();
00087     UT_uint32 iFileCount;
00088     char filenames[XAP_SD_MAX_FILES][XAP_SD_FILENAME_LENGTH];
00089     UT_uint32 iDocPos[XAP_SD_MAX_FILES];
00090     UT_sint32 iXScroll[XAP_SD_MAX_FILES];
00091     UT_sint32 iYScroll[XAP_SD_MAX_FILES];
00092 };
00093 
00094 /*****************************************************************
00095 ******************************************************************
00096 ** This file defines the base class for the cross-platform
00097 ** application.  This is used to hold all of the application-specific
00098 ** data.  Only one of these is created by the application.
00099 ******************************************************************
00100 *****************************************************************/
00101 
00102 class ABI_EXPORT XAP_App
00103 {
00104 public:                                 /* TODO these should be protected */
00105     static const char* s_szBuild_ID;
00106     static const char* s_szBuild_Version;
00107     static const char* s_szBuild_Options;
00108     static const char* s_szBuild_Target;
00109     static const char* s_szBuild_CompileTime;
00110     static const char* s_szBuild_CompileDate;
00111     static const char* s_szAbiSuite_Home;
00112 
00113 public:
00114     static const char* getBuildId ();
00115     static const char* getBuildVersion ();
00116     static const char* getBuildOptions ();
00117     static const char* getBuildTarget ();
00118     static const char* getBuildCompileTime ();
00119     static const char* getBuildCompileDate ();
00120     static const char* getAbiSuiteHome ();
00121 
00122 public:
00123     XAP_App(const char * szAppName);
00124     virtual ~XAP_App();
00125 
00126     XAP_AppImpl* getImpl()
00127             { return m_pImpl; }
00128 
00129     virtual const char * getDefaultEncoding () const = 0 ;
00130 
00131     virtual bool                    initialize(const char * szKeyBindingsKey, const char * szKeyBindingsDefaultValue);
00132     virtual bool                    rememberFrame(XAP_Frame* pFrame, XAP_Frame* pCloneOf = 0);
00133     virtual bool                    forgetFrame(XAP_Frame * pFrame);
00134     virtual bool                    forgetClones(XAP_Frame * pFrame);
00135     virtual bool                    getClones(UT_GenericVector<XAP_Frame*> *pvClonesCopy, XAP_Frame * pFrame);
00136     virtual XAP_Frame *             newFrame() = 0;
00137     virtual void                    reallyExit() = 0;
00138 
00139     bool                        updateClones(XAP_Frame * pFrame);
00140 
00141     virtual void                    notifyFrameCountChange (); // default is empty method
00142     UT_sint32                   getFrameCount() const;
00143     XAP_Frame *                     getFrame(UT_sint32 ndx) const;
00144     UT_sint32                   findFrame(XAP_Frame * pFrame) const;
00145     UT_sint32                   findFrame(const char * szFilename) const;
00146 
00147     void                        enumerateFrames(UT_Vector & v) const;
00148     std::list< AD_Document* >   getDocuments( const AD_Document * pExclude = 0 ) const;
00149     void                        enumerateDocuments(UT_Vector & v, const AD_Document * pExclude) const;
00150     const char *                    getApplicationTitleForTitleBar() const;
00151     const char *                    getApplicationName() const;
00152 
00153     virtual void                rebuildMenus(void);
00154 
00155     EV_EditMethodContainer *            getEditMethodContainer() const;
00156     EV_EditBindingMap *             getBindingMap(const char * szName);
00157     XAP_BindingSet *                getBindingSet(void)
00158     { return m_pBindingSet;}        /* the set of binding maps */
00159     const EV_Menu_ActionSet *           getMenuActionSet() const;
00160     const EV_Toolbar_ActionSet *            getToolbarActionSet() const;
00161     const XAP_EncodingManager *         getEncodingManager() const;
00162     EV_Menu_ActionSet *             getMenuActionSet();
00163     EV_Toolbar_ActionSet *              getToolbarActionSet();
00164 
00165     // only used in ispell builds because aspell doesn't suck...
00166     bool                        addWordToDict(const UT_UCSChar * pWord, UT_uint32 len);
00167     bool                        isWordInDict(const UT_UCSChar * pWord, UT_uint32 len) const;
00168     void                        suggestWord(UT_GenericVector<UT_UCSChar*> * pVecSuggestions, const UT_UCSChar * pWord, UT_uint32 lenWord);
00169     XAP_Prefs *                     getPrefs() const;
00170     bool                        getPrefsValue(const gchar * szKey, const gchar ** pszValue) const;
00171     bool                        getPrefsValue(const UT_String &stKey, UT_String &stValue) const;
00172     bool                        getPrefsValueBool(const gchar * szKey, bool * pbValue) const;
00173 
00174     static XAP_App *                getApp();
00175 
00176     virtual XAP_DialogFactory *         getDialogFactory() = 0;
00177     virtual XAP_Toolbar_ControlFactory *        getControlFactory() = 0;
00178 
00179     virtual const XAP_StringSet *           getStringSet() const = 0;
00180     virtual void                        migrate(const char *oldName, const char *newName, const char *path) const;
00181     virtual const char *                getUserPrivateDirectory() const = 0;
00182     virtual const char *                getAbiSuiteLibDir() const;
00183     virtual const char *                getAbiSuiteAppDir() const = 0;
00184     virtual bool                    findAbiSuiteLibFile(std::string & path, const char * filename, const char * subdir = 0);
00185     virtual bool                    findAbiSuiteAppFile(std::string & path, const char * filename, const char * subdir = 0); // doesn't check user-dir
00186     virtual void                    copyToClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard = true) = 0;
00187     virtual void                    pasteFromClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard, bool bHonorFormatting = true) = 0;
00188     virtual bool                    canPasteFromClipboard() = 0;
00189     virtual void                    cacheCurrentSelection(AV_View *) = 0;
00190     virtual void                addClipboardFmt (const char * /*szFormat*/) {}
00191     virtual void                deleteClipboardFmt (const char * /*szFormat*/) {}
00192     void                        rememberFocussedFrame(void * pJustFocussedFrame);
00193     XAP_Frame *                 getLastFocussedFrame() const;
00194     XAP_Frame *                 findValidFrame() const;
00195     bool                        safeCompare(XAP_Frame * lff, XAP_Frame * f);
00196     UT_sint32                   safefindFrame(XAP_Frame * f) const;
00197     void                        clearLastFocussedFrame();
00198     void                        clearIdTable();
00199     bool                        setDebugBool(void) { m_bDebugBool = true; return m_bDebugBool; }
00200     bool                        clearDebugBool(void) { m_bDebugBool = false; return m_bDebugBool; }
00201     bool                        isDebug(void) { return m_bDebugBool; }
00202     void                        rememberModelessId(UT_sint32 id, XAP_Dialog_Modeless * pDialog);
00203     void                        forgetModelessId(UT_sint32 id);
00204     bool                        isModelessRunning(UT_sint32 id);
00205     XAP_Dialog_Modeless *               getModelessDialog(UT_sint32 id);
00206     void                        closeModelessDlgs();
00207     void                        notifyModelessDlgsOfActiveFrame(XAP_Frame *p_Frame);
00208     void                        notifyModelessDlgsCloseFrame(XAP_Frame *p_Frame);
00209 
00210     virtual void                    setViewSelection(AV_View * /*pView*/) {}; //subclasses override
00211     virtual AV_View *               getViewSelection() { return static_cast<AV_View *>(NULL);} ; // subclasses override
00212 
00213     virtual bool                    setGeometry(UT_sint32 x, UT_sint32 y,
00214                                     UT_uint32 width, UT_uint32 height, UT_uint32 flags = 0);
00215     virtual bool                    getGeometry(UT_sint32 *x, UT_sint32 *y,
00216                                     UT_uint32 *width, UT_uint32 *height, UT_uint32 *flags = 0);
00217     virtual void                    parseAndSetGeometry(const char *string);
00218     XAP_Menu_Factory *              getMenuFactory(void) const { return m_pMenuFactory; }
00219     XAP_Toolbar_Factory *               getToolbarFactory(void) const { return m_pToolbarFactory; }
00220 
00221     enum BidiSupportType {
00222         BIDI_SUPPORT_NONE,
00223         BIDI_SUPPORT_GUI,
00224         BIDI_SUPPORT_FULL
00225     };
00226 
00227     virtual BidiSupportType             theOSHasBidiSupport() const {return BIDI_SUPPORT_NONE;}
00228     void                        setEnableSmoothScrolling(bool b);
00229     bool                        isSmoothScrollingEnabled(void) { return m_bEnableSmoothScrolling; }
00230 
00231     void                        setBonoboRunning(void) { m_bBonoboRunning = true; }
00232     bool                        isBonoboRunning(void) const { return m_bBonoboRunning; }
00233     virtual void                    getDefaultGeometry(UT_uint32& /*width*/,
00234                                                        UT_uint32& /*height*/,
00235                                                        UT_uint32& /*flags*/) {}
00236 
00237     const UT_LangRecord *               getKbdLanguage() const { return m_pKbdLang; }
00238     void                        setKbdLanguage(const char * pszLang);
00239 
00240     UT_UUIDGenerator *              getUUIDGenerator() const { return m_pUUIDGenerator; }
00241     std::string                     createUUIDString() const;
00242 
00243     bool                        openURL(const char * url) { return m_pImpl->openURL(url); }
00244     bool                        openHelpURL(const char * url) { return m_pImpl->openHelpURL(url); }
00245     UT_String                   localizeHelpUrl(const char * pathBeforeLang,
00246                                     const char * pathAfterLang, const char * remoteURLbase)
00247                             { return m_pImpl->localizeHelpUrl(pathBeforeLang, pathAfterLang, remoteURLbase); }
00248 
00249     GR_GraphicsFactory *                getGraphicsFactory() const { return m_pGraphicsFactory; }
00250     void                        setDefaultGraphicsId(UT_uint32 i);
00251     /* primary graphics allocator */
00252     GR_Graphics *                   newGraphics(GR_AllocInfo &ai) const;
00253     /* secondary graphics allocator; use only in special cases */
00254     GR_Graphics *                   newGraphics(UT_uint32 iClassId, GR_AllocInfo &ai) const;
00255     virtual GR_Graphics *               newDefaultScreenGraphics() const = 0;
00256 
00257     virtual UT_sint32               setInputMode(const char * szName, bool bForce=false);
00258     const char *                    getInputMode() const;
00259     EV_EditEventMapper *                getEditEventMapper() const;
00260     bool                        addListener(AV_Listener * pListener, AV_ListenerId * pListenerId);
00261     bool                        removeListener(AV_ListenerId listenerId);
00262     virtual bool                    notifyListeners(AV_View * pView, const AV_ChangeMask hint,void * pPrivateData = NULL);
00263 
00264     bool                    registerEmbeddable(GR_EmbedManager * pEmbed, const char *uid = NULL);
00265     bool                        unRegisterEmbeddable(const char *uid);
00266     GR_EmbedManager *               getEmbeddableManager(GR_Graphics * pG, const char * szObjectType);
00267     XAP_Module *                getPlugin(const char * szPluginName);
00268 
00269     static const char*          findNearestFont(const char* pszFontFamily,
00270                                                 const char* pszFontStyle,
00271                                                 const char* pszFontVariant,
00272                                                 const char* pszFontWeight,
00273                                                 const char* pszFontStretch,
00274                                                 const char* pszFontSize,
00275                                                 const char* pszLang);
00276 
00277     bool                        saveState(bool bQuit);
00278     bool                        retrieveState();
00279     virtual void                clearStateInfo(){};
00280 
00281     bool                        getDisableDoubleBuffering() const;
00282     void                        setDisableDoubleBuffering( bool v );
00283     bool                        getNoGUI() const;
00284     void                        setNoGUI( bool v );
00285 
00286     // signal wrapper
00287     static void signalWrapper(int sig_num);
00288     // catch the signals
00289     virtual void catchSignals(int signum) = 0;
00290     // Override in AP.
00291     virtual void saveRecoveryFiles() = 0;
00292 
00293 protected:
00294     void                        _setAbiSuiteLibDir(const char * sz);
00295     virtual const char *                _getKbdLanguage() {return NULL;}
00296     void                        _setUUIDGenerator(UT_UUIDGenerator * pG) { m_pUUIDGenerator = pG; }
00297 
00298     virtual bool                _saveState(XAP_StateData & sd);
00299     virtual bool                _retrieveState(XAP_StateData & sd);
00300 
00301     const char *                    m_szAppName;
00302     const char *                    m_szAbiSuiteLibDir;
00303 
00304     EV_EditMethodContainer *            m_pEMC;         /* the set of all possible EditMethods in the app */
00305     XAP_BindingSet *                m_pBindingSet;      /* the set of binding maps */
00306     EV_Menu_ActionSet *             m_pMenuActionSet;   /* the set of all possible menu actions in the app */
00307     EV_Toolbar_ActionSet *              m_pToolbarActionSet;
00308     XAP_Dictionary *                m_pDict;
00309     XAP_Prefs *                 m_prefs;        /* populated in AP_<platform>App::initialize() */
00310 
00311     UT_GenericVector<XAP_Frame*>            m_vecFrames;
00312     typedef std::map<std::string, UT_GenericVector<XAP_Frame*>*> CloneMap;
00313     CloneMap    m_hashClones;
00314     XAP_Frame *                 m_lastFocussedFrame;
00315     XAP_Menu_Factory *                          m_pMenuFactory;
00316     XAP_Toolbar_Factory *               m_pToolbarFactory;
00317 
00318     struct modeless_pair
00319     {
00320         UT_sint32 id;
00321         XAP_Dialog_Modeless * pDialog;
00322     } m_IdTable[NUM_MODELESSID+1];
00323 
00324     static XAP_App *                m_pApp;
00325     bool                        m_bAllowCustomizing;
00326     bool                        m_bAreCustomized;
00327     bool                        m_bDebugBool;
00328     bool                        m_bBonoboRunning;
00329     bool                        m_bEnableSmoothScrolling;
00330     bool                        m_bDisableDoubleBuffering;
00331     bool                        m_bNoGUI;
00332 private:
00333     const UT_LangRecord *               m_pKbdLang;
00334     UT_UUIDGenerator *              m_pUUIDGenerator;
00335 
00336     GR_GraphicsFactory *                m_pGraphicsFactory;
00337     UT_uint32                   m_iDefaultGraphicsId;
00338 
00339     XAP_InputModes *                m_pInputModes;
00340     std::map<std::string, GR_EmbedManager *> m_mapEmbedManagers;
00341     XAP_App(const XAP_App&);            // should not even be called. Just to avoid a warning.
00342     void operator=(const XAP_App&);
00343 #ifdef DEBUG
00344     void _fundamentalAsserts() const;
00345 #endif
00346     XAP_AppImpl* m_pImpl;
00347     UT_GenericVector<AV_Listener *>         m_vecPluginListeners;
00348     UT_ScriptLibrary *             m_pScriptLibrary;
00349 };
00350 
00351 #endif /* XAP_APP_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1