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

xap_CocoaApp.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 AbiSource, Inc.
00005  * Copyright (C) 2001, 2003-2004, 2009 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_COCOAAPP_H
00025 #define XAP_COCOAAPP_H
00026 
00027 //  BAD HACK BAD HACK I can't include Foundation/NSTimer.h
00028 //  because AP_Args somehow won't compile Obj-C.
00029 typedef double NSTimeInterval;
00030 
00031 #include <unistd.h>
00032 #include <sys/stat.h>
00033 #include "xap_App.h"
00034 #include "xap_CocoaDialogFactory.h"
00035 #include "xap_Cocoa_TB_CFactory.h"
00036 
00037 class XAP_Args;
00038 class XAP_CocoaToolbar_Icons;
00039 class AV_View;
00040 class EV_CocoaMenuBar;
00041 
00042 /*****************************************************************
00043 ******************************************************************
00044 ** Only one of these is created by the application.
00045 ******************************************************************
00046 *****************************************************************/
00047 
00048 class XAP_CocoaApp : public XAP_App
00049 {
00050 public:
00051     XAP_CocoaApp(const char* szAppName);
00052     virtual ~XAP_CocoaApp();
00053 
00054     virtual const char *                    getDefaultEncoding () const;
00055 
00056     virtual bool                            initialize(const char * szKeyBindingsKey, const char * szKeyBindingsDefaultValue);
00057     virtual XAP_Frame *                     newFrame() = 0;
00058     virtual void                            reallyExit();
00059     virtual void                            notifyFrameCountChange ();
00060 
00061     virtual XAP_DialogFactory *             getDialogFactory();
00062     virtual XAP_Toolbar_ControlFactory *    getControlFactory();
00063     virtual const XAP_StringSet *           getStringSet() const = 0;
00064     virtual const char *                    getAbiSuiteAppDir() const = 0;
00065     virtual void                            copyToClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard = true) = 0;
00066     virtual void                            pasteFromClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard, bool bHonorFormatting = true) = 0;
00067     virtual bool                            canPasteFromClipboard() = 0;
00068     virtual const char *                    getUserPrivateDirectory() const;
00069     virtual bool                            findAbiSuiteBundleFile(std::string & path, const char * filename, const char * subdir = 0); // checks only bundle
00070     virtual bool                            findAbiSuiteLibFile(std::string & path, const char * filename, const char * subdir = 0);
00071     virtual bool                            findAbiSuiteAppFile(std::string & path, const char * filename, const char * subdir = 0); // doesn't check user-dir
00072 
00073     virtual void                            setSelectionStatus(AV_View * pView) = 0;
00074     virtual void                            clearSelection() = 0;
00075     virtual bool                            getCurrentSelection(const char** formatList,
00076                                                                 void ** ppData, UT_uint32 * pLen,
00077                                                                 const char **pszFormatFound) = 0;
00078     virtual void                            cacheCurrentSelection(AV_View *) = 0;
00079 
00080     typedef enum
00081     {
00082         GEOMETRY_FLAG_POS =     1 << 0,
00083         GEOMETRY_FLAG_SIZE =    1 << 1
00084     } windowGeometryFlags;
00085 
00086     struct windowGeometry
00087     {
00088         int x, y;
00089         UT_uint32 width, height;
00090         XAP_CocoaApp::windowGeometryFlags flags;
00091     };
00092 
00093     virtual void                    setGeometry(int x, int y, UT_uint32 width, UT_uint32 height,
00094                                                 windowGeometryFlags flags);
00095     virtual void                    getGeometry(int * x, int * y, UT_uint32 * width, UT_uint32 * height,
00096                                                 windowGeometryFlags * flags);
00097 
00098     void                            setTimeOfLastEvent(NSTimeInterval eventTime);
00099     NSTimeInterval                  getTimeOfLastEvent() const { return m_eventTime; };
00100     virtual BidiSupportType         theOSHasBidiSupport() const;
00101     EV_CocoaMenuBar*                getCocoaMenuBar(void) const { return m_pCocoaMenu; };
00102     XAP_Frame *                     _getFrontFrame(void);
00103     XAP_CocoaToolbar_Icons *        getToolbarIcons () const { return m_pCocoaToolbarIcons; }
00104 protected:
00105     virtual const char*          _findNearestFont(const char* pszFontFamily,
00106                                                 const char* pszFontStyle,
00107                                                 const char* pszFontVariant,
00108                                                 const char* pszFontWeight,
00109                                                 const char* pszFontStretch,
00110                                                 const char* pszFontSize,
00111                                                 const char* pszLang);
00112     bool                            _loadFonts();
00113     void                            _setAbiSuiteLibDir();
00114 private:
00115     XAP_CocoaToolbar_Icons *        m_pCocoaToolbarIcons;
00116     AP_CocoaDialogFactory           m_dialogFactory;
00117     AP_CocoaToolbar_ControlFactory  m_controlFactory;
00118 
00119     windowGeometry          m_geometry;
00120     NSTimeInterval          m_eventTime; // e->time field of a recent X event
00121                                          // (we use this to sync clipboard
00122                                          // operations with the server).
00123 
00124 protected:              // TODO move that to private
00125     EV_CocoaMenuBar*            m_pCocoaMenu;
00126     const char*         m_szMenuLayoutName;
00127     const char*         m_szMenuLabelSetName;
00128 };
00129 
00130 #endif /* XAP_COCOAAPP_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1