Debian Codegraph @

src/af/xap/cocoa/xap_CocoaApp.h

raw
1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2
3 /* AbiSource Application Framework
4 * Copyright (C) 1998 AbiSource, Inc.
5 * Copyright (C) 2001, 2003-2004, 2009 Hubert Figuiere
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301 USA.
21 */
22
23
24 #ifndef XAP_COCOAAPP_H
25 #define XAP_COCOAAPP_H
26
27 // BAD HACK BAD HACK I can't include Foundation/NSTimer.h
28 // because AP_Args somehow won't compile Obj-C.
29 typedef double NSTimeInterval;
30
31 #include <unistd.h>
32 #include <sys/stat.h>
33 #include "xap_App.h"
34 #include "xap_CocoaDialogFactory.h"
35 #include "xap_Cocoa_TB_CFactory.h"
36
37 class XAP_Args;
38 class XAP_CocoaToolbar_Icons;
39 class AV_View;
40 class EV_CocoaMenuBar;
41
42 /*****************************************************************
43 ******************************************************************
44 ** Only one of these is created by the application.
45 ******************************************************************
46 *****************************************************************/
47
48 class XAP_CocoaApp : public XAP_App
49 {
50 public:
51 XAP_CocoaApp(const char* szAppName);
52 virtual ~XAP_CocoaApp();
53
54 virtual const char * getDefaultEncoding () const;
55
56 virtual bool initialize(const char * szKeyBindingsKey, const char * szKeyBindingsDefaultValue);
57 virtual XAP_Frame * newFrame() = 0;
58 virtual void reallyExit();
59 virtual void notifyFrameCountChange ();
60
61 virtual XAP_DialogFactory * getDialogFactory();
62 virtual XAP_Toolbar_ControlFactory * getControlFactory();
63 virtual const XAP_StringSet * getStringSet() const = 0;
64 virtual const char * getAbiSuiteAppDir() const = 0;
65 virtual void copyToClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard = true) = 0;
66 virtual void pasteFromClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard, bool bHonorFormatting = true) = 0;
67 virtual bool canPasteFromClipboard() = 0;
68 virtual const char * getUserPrivateDirectory();
69 virtual bool findAbiSuiteBundleFile(std::string & path, const char * filename, const char * subdir = 0); // checks only bundle
70 virtual bool findAbiSuiteLibFile(std::string & path, const char * filename, const char * subdir = 0);
71 virtual bool findAbiSuiteAppFile(std::string & path, const char * filename, const char * subdir = 0); // doesn't check user-dir
72
73 virtual void setSelectionStatus(AV_View * pView) = 0;
74 virtual void clearSelection() = 0;
75 virtual bool getCurrentSelection(const char** formatList,
76 void ** ppData, UT_uint32 * pLen,
77 const char **pszFormatFound) = 0;
78 virtual void cacheCurrentSelection(AV_View *) = 0;
79
80 typedef enum
81 {
82 GEOMETRY_FLAG_POS = 1 << 0,
83 GEOMETRY_FLAG_SIZE = 1 << 1
84 } windowGeometryFlags;
85
86 struct windowGeometry
87 {
88 int x, y;
89 UT_uint32 width, height;
90 XAP_CocoaApp::windowGeometryFlags flags;
91 };
92
93 virtual void setGeometry(int x, int y, UT_uint32 width, UT_uint32 height,
94 windowGeometryFlags flags);
95 virtual void getGeometry(int * x, int * y, UT_uint32 * width, UT_uint32 * height,
96 windowGeometryFlags * flags);
97
98 void setTimeOfLastEvent(NSTimeInterval eventTime);
99 NSTimeInterval getTimeOfLastEvent() const { return m_eventTime; };
100 virtual UT_sint32 makeDirectory(const char * szPath, const UT_sint32 mode ) const;
101 virtual BidiSupportType theOSHasBidiSupport() const;
102 EV_CocoaMenuBar* getCocoaMenuBar(void) const { return m_pCocoaMenu; };
103 XAP_Frame * _getFrontFrame(void);
104 XAP_CocoaToolbar_Icons * getToolbarIcons () const { return m_pCocoaToolbarIcons; }
105 protected:
106 virtual const char* _findNearestFont(const char* pszFontFamily,
107 const char* pszFontStyle,
108 const char* pszFontVariant,
109 const char* pszFontWeight,
110 const char* pszFontStretch,
111 const char* pszFontSize,
112 const char* pszLang);
113 bool _loadFonts();
114 void _setAbiSuiteLibDir();
115 private:
116 XAP_CocoaToolbar_Icons * m_pCocoaToolbarIcons;
117 AP_CocoaDialogFactory m_dialogFactory;
118 AP_CocoaToolbar_ControlFactory m_controlFactory;
119
120 windowGeometry m_geometry;
121 NSTimeInterval m_eventTime; // e->time field of a recent X event
122 // (we use this to sync clipboard
123 // operations with the server).
124
125 protected: // TODO move that to private
126 EV_CocoaMenuBar* m_pCocoaMenu;
127 const char* m_szMenuLayoutName;
128 const char* m_szMenuLabelSetName;
129 };
130
131 #endif /* XAP_COCOAAPP_H */