Debian Codegraph @

src/af/xap/xp/xap_Frame.h

raw
1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2
3 /* AbiSource Application Framework
4 * Copyright (C) 1998 AbiSource, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA.
20 */
21
22
23 #ifndef XAP_Frame_H
24 #define XAP_Frame_H
25
26 #include <string>
27
28 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
29 * so even if it's commented out in-file that's still a lot of work for
30 * the preprocessor to do...
31 */
32 #ifndef UT_TYPES_H
33 #include "ut_types.h"
34 #endif
35 #include "ut_string_class.h"
36 #include "ut_vector.h"
37 #include "ut_misc.h"
38
39 #include "xav_Listener.h" // for AV_ListenerID
40
41 #include "xap_Dlg_MessageBox.h"
42 #include "xap_Strings.h"
43 #include "xap_Types.h"
44
45 #include "gr_Graphics.h"
46 #include <gsf/gsf-input.h>
47
48 class XAP_App;
49 class XAP_DialogFactory;
50 class ap_ViewListener;
51 class AV_View;
52 class AD_Document;
53 class EV_EditEventMapper;
54 class EV_EditBindingMap;
55 class EV_Mouse;
56 class EV_Toolbar;
57 class EV_Keyboard;
58 class EV_Menu;
59 class AV_ScrollObj;
60 class ap_Scrollbar_ViewListener;
61 class UT_Worker;
62 class UT_Timer;
63
64 /*****************************************************************
65 ******************************************************************
66 ** This file defines the base class for the cross-platform
67 ** application frame. This is used to hold all of the
68 ** window-specific data. One of these is created for each
69 ** top-level document window. (If we do splitter windows,
70 ** the views will probably share this frame instance.)
71 ******************************************************************
72 *****************************************************************/
73
74
75
76 //////////////////////////////////////////////////////////////////
77
78 // FOR FUTURE REFERENCE: XAP_FrameImpl defines services that are quite specific
79 // to the _implementation_ of the frame, and involve platform specific code
80 // XAP_Frame defines services that are specific to public interface (from the
81 // point of view of abi code) of the visible frame and not the implementation
82 // The line between these two things _is_ sometimes ambiguous. use your judgement
83 // when adding something onto the frame code
84
85 #include "xap_FrameImpl.h"
86
87 class ABI_EXPORT XAP_Frame
88 {
89 public:
90 XAP_Frame(XAP_FrameImpl *pFrameImpl);
91 XAP_Frame(XAP_Frame * pFrame);
92 virtual ~XAP_Frame();
93
94 virtual bool initialize(const char * szKeyBindingsKey, const char * szKeyBindingsDefaultValue,
95 const char * szMenuLayoutKey, const char * szMenuLayoutDefaultValue,
96 const char * szMenuLabelSetKey, const char * szMenuLabelSetDefaultValue,
97 const char * szToolbarLayoutsKey, const char * szToolbarLayoutsDefaultValue,
98 const char * szToolbarLabelSetKey, const char * szToolbarLabelSetDefaultValue);
99
100 virtual XAP_Frame * cloneFrame() = 0;
101 virtual XAP_Frame * buildFrame(XAP_Frame * pClone) = 0;
102 virtual UT_Error loadDocument(AD_Document* pDoc) = 0;
103 virtual UT_Error loadDocument(const char * szFilename, int ieft) = 0;
104 virtual UT_Error loadDocument(const char * szFileName, int ieft, bool createNew) = 0;
105 virtual UT_Error loadDocument(GsfInput * input, int ieft) = 0;
106 virtual UT_Error importDocument (const char * szFilename, int ieft, bool markClean = false) = 0;
107
108 // thin interface functions to facilities provided by the helper
109 bool close() { return m_pFrameImpl->_close(); }
110 bool raise() { return m_pFrameImpl->_raise(); }
111 bool show() { return m_pFrameImpl->_show(); }
112 bool updateTitle() { return m_pFrameImpl->_updateTitle(); }
113 void setCursor(GR_Graphics::Cursor cursor) { m_pFrameImpl->_setCursor(cursor); }
114 virtual void queue_resize() { m_pFrameImpl->_queue_resize(); }
115 void setFullScreen(bool isFullScreen) { m_pFrameImpl->_setFullScreen(isFullScreen); }
116 void hideMenuScroll(bool bHideMenuScroll) {
117 m_bHideMenuScroll = bHideMenuScroll;
118 m_pFrameImpl->_hideMenuScroll(bHideMenuScroll);}
119 virtual XAP_DialogFactory * getDialogFactory() { return m_pFrameImpl->_getDialogFactory(); }
120 virtual EV_Toolbar * _newToolbar(XAP_Frame *frame, const char *szLayout, const char *szLanguage) { return m_pFrameImpl->_newToolbar(frame, szLayout, szLanguage); }
121 virtual EV_Menu* getMainMenu() { return m_pFrameImpl->_getMainMenu(); }
122
123 XAP_FrameImpl * getFrameImpl() const { return m_pFrameImpl; }
124
125 void nullUpdate () const { m_pFrameImpl->_nullUpdate(); }
126 AV_View * getCurrentView() const;
127 AD_Document * getCurrentDoc() const;
128 void setView(AV_View * pView) {m_pView = pView;}
129 void setDoc(AD_Document * pDoc) {m_pDoc = pDoc;}
130 const char * getFilename() const;
131 const UT_UTF8String & getTitle() const;
132 const char * getNonDecoratedTitle() const;
133
134 XAP_FrameMode getFrameMode();
135 void setFrameMode(XAP_FrameMode iFrameMode);
136 bool isDirty() const;
137
138 void setViewNumber(UT_uint32 n);
139 UT_uint32 getViewNumber() const;
140 const char * getViewKey() const;
141
142 inline void * getFrameData() const { return m_pData; }
143
144 virtual void setXScrollRange() = 0;
145 virtual void setYScrollRange() = 0;
146 virtual void quickZoom(UT_uint32 iZoom) = 0;
147 bool runModalContextMenu(AV_View * pView, const char * szMenuName,
148 UT_sint32 x, UT_sint32 y) { return m_pFrameImpl->_runModalContextMenu(pView, szMenuName, x, y); }
149
150 typedef enum { z_200, z_100, z_75, z_PAGEWIDTH, z_WHOLEPAGE, z_PERCENT } tZoomType;
151 virtual void setZoomPercentage(UT_uint32 iZoom);
152 virtual UT_uint32 getZoomPercentage();
153 void setZoomType(XAP_Frame::tZoomType z_Type){ m_zoomType = z_Type; }
154 XAP_Frame::tZoomType getZoomType() { return m_zoomType; }
155 void updateZoom();
156 void quickZoom(void);
157
158 virtual void setStatusMessage(const char * szMsg) = 0;
159 // TODO change that to be the main call.
160 void setStatusMessage(const std::string & s)
161 {
162 setStatusMessage(s.c_str());
163 }
164
165 virtual void toggleRuler(bool /*bRulerOn*/) { } //
166 virtual void toggleTopRuler(bool /*bRulerOn*/) = 0;
167 virtual void toggleLeftRuler(bool /*bRulerOn*/) = 0;
168 virtual void toggleBar(UT_uint32 /* iBarNb */, bool /* bBarOn */) { }
169 virtual void toggleStatusBar(bool /* bStatusBarOn */) { }
170 virtual bool getBarVisibility(UT_uint32 /*iBarNb*/) { return true; }
171
172 EV_Mouse * getMouse() { return m_pFrameImpl->m_pMouse; }
173 EV_Keyboard * getKeyboard() { return m_pFrameImpl->m_pKeyboard; }
174
175 EV_Toolbar * getToolbar(UT_sint32 ibar);
176 UT_sint32 findToolbarNr(EV_Toolbar * pTB);
177 virtual void rebuildMenus(void) { m_pFrameImpl->_rebuildMenus();}
178 bool repopulateCombos();
179
180 void rebuildAllToolbars(void);
181 void refillToolbarsInFrameData(void) { m_pFrameImpl->_refillToolbarsInFrameData(); }
182 void dragBegin(XAP_Toolbar_Id srcId,
183 EV_Toolbar * pTBsrc);
184 void dragDropToIcon(XAP_Toolbar_Id srcId,
185 XAP_Toolbar_Id destId,
186 EV_Toolbar * pTBsrc,
187 EV_Toolbar * pTBdest);
188 void dragDropToTB(XAP_Toolbar_Id srcId,
189 EV_Toolbar * pTBsrc,
190 EV_Toolbar * pTBdest);
191 void dragEnd(XAP_Toolbar_Id srcId);
192 bool isBackupRunning(void)
193 { return m_bBackupRunning;}
194 UT_sint32 getAutoSavePeriod(void)
195 { return m_iAutoSavePeriod;}
196 void setAutoSaveFile(bool);
197 void setAutoSaveFilePeriod(int);
198 void setAutoSaveFileExt(const UT_String &);
199
200 XAP_Dialog_MessageBox * createMessageBox(XAP_String_Id id,
201 XAP_Dialog_MessageBox::tButtons buttons,
202 XAP_Dialog_MessageBox::tAnswer default_answer,
203 ...);
204
205 XAP_Dialog_MessageBox::tAnswer showMessageBox(XAP_String_Id id,
206 XAP_Dialog_MessageBox::tButtons buttons,
207 XAP_Dialog_MessageBox::tAnswer default_answer);
208
209 XAP_Dialog_MessageBox::tAnswer showMessageBox(const std::string & sz,
210 XAP_Dialog_MessageBox::tButtons buttons,
211 XAP_Dialog_MessageBox::tAnswer default_answer);
212
213 XAP_Dialog_MessageBox::tAnswer showMessageBox(const char * sz,
214 XAP_Dialog_MessageBox::tButtons buttons,
215 XAP_Dialog_MessageBox::tAnswer default_answer);
216
217 XAP_Dialog_MessageBox::tAnswer showMessageBox(XAP_String_Id id,
218 XAP_Dialog_MessageBox::tButtons buttons,
219 XAP_Dialog_MessageBox::tAnswer default_answer,
220 const char * sz);
221
222 XAP_Dialog_MessageBox::tAnswer showMessageBox(XAP_Dialog_MessageBox * pDialog);
223
224 UT_Error backup(const char* stExt = 0, UT_sint32 iEFT = -1);
225 UT_String makeBackupName (const char * szExt = 0);
226
227 bool isStatusBarShown(void) const { return m_bShowStatusbar;}
228 bool isMenuBarShown(void) const { return m_bShowMenubar;}
229 virtual void setStatusBarShown(bool /*bShowStatusbar*/) {}
230 virtual void setMenuBarShown(bool /*bShowMenubar*/) {}
231 time_t getTimeSinceSave() const;
232 bool isFrameLocked(void) const
233 {return m_bIsFrameLocked;}
234 void setFrameLocked(bool bLock)
235 {m_bIsFrameLocked = bLock;}
236 bool isMenuScrollHidden(void) const
237 { return m_bHideMenuScroll;}
238 UT_RGBColor getColorSelBackground () const;
239 UT_RGBColor getColorSelForeground () const;
240
241 void dragText();
242 virtual UT_sint32 getDocumentAreaXoff(void)
243 { return 0;}
244 virtual UT_sint32 getDocumentAreaYoff(void)
245 { return 0;}
246 protected:
247 friend class XAP_FrameImpl;
248
249 AD_Document * m_pDoc; /* to our in-memory representation of a document */
250 AV_View * m_pView; /* to our view on the document */
251 ap_ViewListener * m_pViewListener;
252 AV_ListenerId m_lid;
253 AV_ScrollObj * m_pScrollObj; /* to our scroll handler */
254 UT_uint32 m_nView;
255 int m_iUntitled;
256 ap_Scrollbar_ViewListener * m_pScrollbarViewListener;
257 AV_ListenerId m_lidScrollbarViewListener;
258 XAP_Frame::tZoomType m_zoomType;
259 GR_Graphics::Cursor m_cursor;
260 void * m_pData; /* app-specific frame data */
261 bool m_bHideMenuScroll;
262
263 static int _getNextUntitledNumber();
264
265 private:
266 void _createAutoSaveTimer();
267 void _removeAutoSaveFile();
268
269 UT_UTF8String m_sTitle;
270 UT_UTF8String m_sNonDecoratedTitle;
271
272 UT_uint32 m_iIdAutoSaveTimer;
273 UT_uint32 m_iAutoSavePeriod;
274 UT_String m_stAutoSaveExt;
275 UT_String m_stAutoSaveNamePrevious;
276 bool m_bBackupRunning;
277 bool m_bBackupInProgress;
278
279 static int s_iUntitled;
280
281 XAP_Toolbar_Id m_isrcId;
282 UT_sint32 m_isrcTBNr;
283 XAP_Toolbar_Id m_idestId;
284 UT_sint32 m_idestTBNr;
285 bool m_bisDragging;
286 bool m_bHasDropped;
287 bool m_bHasDroppedTB;
288
289 bool m_bFirstDraw; // WL_REFACTOR: should this go into the helper?
290 bool m_bShowStatusbar;
291 bool m_bShowMenubar;
292 bool m_bIsFrameLocked;
293
294 XAP_FrameImpl * m_pFrameImpl; /* set by platform specific code */
295 UT_uint32 m_iZoomPercentage;
296 };
297
298 #endif /* XAP_Frame_H */
299
300
301
302
303
304
305
306
307