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

xap_Frame.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  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 
00023 #ifndef XAP_Frame_H
00024 #define XAP_Frame_H
00025 
00026 #include <string>
00027 
00028 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00029  * so even if it's commented out in-file that's still a lot of work for
00030  * the preprocessor to do...
00031  */
00032 #ifndef UT_TYPES_H
00033 #include "ut_types.h"
00034 #endif
00035 #include "ut_string_class.h"
00036 #include "ut_vector.h"
00037 #include "ut_misc.h"
00038 
00039 #include "xav_Listener.h"   // for AV_ListenerID
00040 
00041 #include "xap_Dlg_MessageBox.h"
00042 #include "xap_Strings.h"
00043 #include "xap_Types.h"
00044 
00045 #include "gr_Graphics.h"
00046 #include <gsf/gsf-input.h>
00047 
00048 class XAP_App;
00049 class XAP_DialogFactory;
00050 class ap_ViewListener;
00051 class AV_View;
00052 class AD_Document;
00053 class EV_EditEventMapper;
00054 class EV_EditBindingMap;
00055 class EV_Mouse;
00056 class EV_Toolbar;
00057 class EV_Keyboard;
00058 class EV_Menu;
00059 class AV_ScrollObj;
00060 class ap_Scrollbar_ViewListener;
00061 class UT_Worker;
00062 class UT_Timer;
00063 
00064 /*****************************************************************
00065 ******************************************************************
00066 ** This file defines the base class for the cross-platform
00067 ** application frame.  This is used to hold all of the
00068 ** window-specific data.  One of these is created for each
00069 ** top-level document window.  (If we do splitter windows,
00070 ** the views will probably share this frame instance.)
00071 ******************************************************************
00072 *****************************************************************/
00073 
00074 
00075 
00077 
00078 // FOR FUTURE REFERENCE: XAP_FrameImpl defines services that are quite specific
00079 // to the _implementation_ of the frame, and involve platform specific code
00080 // XAP_Frame defines services that are specific to public interface (from the
00081 // point of view of abi code) of the visible frame and not the implementation
00082 // The line between these two things _is_ sometimes ambiguous. use your judgement
00083 // when adding something onto the frame code
00084 
00085 #include "xap_FrameImpl.h"
00086 
00087 class ABI_EXPORT XAP_Frame
00088 {
00089 public:
00090     XAP_Frame(XAP_FrameImpl *pFrameImpl);
00091     XAP_Frame(XAP_Frame * pFrame);
00092     virtual ~XAP_Frame();
00093 
00094     virtual bool                initialize(const char * szKeyBindingsKey, const char * szKeyBindingsDefaultValue,
00095                                            const char * szMenuLayoutKey, const char * szMenuLayoutDefaultValue,
00096                                            const char * szMenuLabelSetKey, const char * szMenuLabelSetDefaultValue,
00097                                            const char * szToolbarLayoutsKey, const char * szToolbarLayoutsDefaultValue,
00098                                            const char * szToolbarLabelSetKey, const char * szToolbarLabelSetDefaultValue);
00099 
00100     virtual XAP_Frame *         cloneFrame() = 0;
00101     virtual XAP_Frame *         buildFrame(XAP_Frame * pClone) = 0;
00102     virtual UT_Error            loadDocument(AD_Document* pDoc) = 0;
00103     virtual UT_Error            loadDocument(const char * szFilename, int ieft) = 0;
00104     virtual UT_Error            loadDocument(const char * szFileName, int ieft, bool createNew) = 0;
00105     virtual UT_Error            loadDocument(GsfInput * input, int ieft) = 0;
00106     virtual UT_Error            importDocument (const char * szFilename, int ieft, bool markClean = false) = 0;
00107 
00108     // thin interface functions to facilities provided by the helper
00109     bool close() { return m_pFrameImpl->_close(); }
00110     bool raise() { return m_pFrameImpl->_raise(); }
00111     bool show() { return m_pFrameImpl->_show(); }
00112     bool updateTitle() { return m_pFrameImpl->_updateTitle(); }
00113     void setCursor(GR_Graphics::Cursor cursor) { m_pFrameImpl->_setCursor(cursor); }
00114     virtual void queue_resize() { m_pFrameImpl->_queue_resize(); }
00115     void setFullScreen(bool isFullScreen) { m_pFrameImpl->_setFullScreen(isFullScreen); }
00116     void hideMenuScroll(bool bHideMenuScroll) {
00117         m_bHideMenuScroll = bHideMenuScroll;
00118         m_pFrameImpl->_hideMenuScroll(bHideMenuScroll);}
00119     virtual XAP_DialogFactory * getDialogFactory() { return m_pFrameImpl->_getDialogFactory(); }
00120     virtual EV_Toolbar * _newToolbar(XAP_Frame *frame, const char *szLayout, const char *szLanguage) { return m_pFrameImpl->_newToolbar(frame, szLayout, szLanguage); }
00121     virtual EV_Menu* getMainMenu() { return m_pFrameImpl->_getMainMenu(); }
00122 
00123     XAP_FrameImpl * getFrameImpl() const { return m_pFrameImpl; }
00124 
00125     void                        nullUpdate () const { m_pFrameImpl->_nullUpdate(); }
00126     AV_View *                   getCurrentView() const;
00127     AD_Document *               getCurrentDoc() const;
00128     void                        setView(AV_View * pView) {m_pView = pView;}
00129     void                        setDoc(AD_Document * pDoc) {m_pDoc = pDoc;}
00130     const char *                getFilename() const;
00131     const UT_UTF8String &       getTitle() const;
00132     const char *                getNonDecoratedTitle() const;
00133 
00134     XAP_FrameMode getFrameMode();
00135     void setFrameMode(XAP_FrameMode iFrameMode);
00136     bool                        isDirty() const;
00137 
00138     void                        setViewNumber(UT_uint32 n);
00139     UT_uint32                   getViewNumber() const;
00140     const char *                getViewKey() const;
00141 
00142     inline void *               getFrameData() const { return m_pData; }
00143 
00144     virtual void                setXScrollRange() = 0;
00145     virtual void                setYScrollRange() = 0;
00146     virtual void                quickZoom(UT_uint32 iZoom) = 0;
00147     bool runModalContextMenu(AV_View * pView, const char * szMenuName,
00148         UT_sint32 x, UT_sint32 y) { return m_pFrameImpl->_runModalContextMenu(pView, szMenuName, x, y); }
00149 
00150     typedef enum { z_200, z_100, z_75, z_PAGEWIDTH, z_WHOLEPAGE, z_PERCENT } tZoomType;
00151     virtual void                setZoomPercentage(UT_uint32 iZoom);
00152     virtual UT_uint32           getZoomPercentage();
00153     void                        setZoomType(XAP_Frame::tZoomType z_Type){ m_zoomType = z_Type; }
00154     XAP_Frame::tZoomType        getZoomType() { return m_zoomType; }
00155     void                        updateZoom();
00156     void                        quickZoom(void);
00157 
00158     virtual void                setStatusMessage(const char * szMsg) = 0;
00159     // TODO change that to be the main call.
00160     void                        setStatusMessage(const std::string & s)
00161     {
00162         setStatusMessage(s.c_str());
00163     }
00164 
00165     virtual void                toggleRuler(bool /*bRulerOn*/) { } //
00166     virtual void                toggleTopRuler(bool /*bRulerOn*/) = 0;
00167     virtual void                toggleLeftRuler(bool /*bRulerOn*/) = 0;
00168     virtual void                toggleBar(UT_uint32 /* iBarNb */, bool /* bBarOn */) { }
00169     virtual void                toggleStatusBar(bool /* bStatusBarOn */) { }
00170     virtual bool                getBarVisibility(UT_uint32 /*iBarNb*/) { return true; }
00171 
00172     EV_Mouse *                  getMouse() { return m_pFrameImpl->m_pMouse; }
00173     EV_Keyboard *               getKeyboard() { return m_pFrameImpl->m_pKeyboard; }
00174 
00175     EV_Toolbar *                getToolbar(UT_sint32 ibar);
00176     UT_sint32                   findToolbarNr(EV_Toolbar * pTB);
00177     virtual void                rebuildMenus(void) { m_pFrameImpl->_rebuildMenus();}
00178     bool                        repopulateCombos();
00179 
00180     void                        rebuildAllToolbars(void);
00181     void                        refillToolbarsInFrameData(void) { m_pFrameImpl->_refillToolbarsInFrameData(); }
00182     void                        dragBegin(XAP_Toolbar_Id srcId,
00183                                           EV_Toolbar * pTBsrc);
00184     void                        dragDropToIcon(XAP_Toolbar_Id srcId,
00185                                                XAP_Toolbar_Id destId,
00186                                                EV_Toolbar * pTBsrc,
00187                                                EV_Toolbar * pTBdest);
00188     void                        dragDropToTB(XAP_Toolbar_Id srcId,
00189                                              EV_Toolbar * pTBsrc,
00190                                              EV_Toolbar * pTBdest);
00191     void                        dragEnd(XAP_Toolbar_Id srcId);
00192     bool                        isBackupRunning(void)
00193     { return m_bBackupRunning;}
00194     UT_sint32                   getAutoSavePeriod(void)
00195     { return m_iAutoSavePeriod;}
00196     void                        setAutoSaveFile(bool);
00197     void                        setAutoSaveFilePeriod(int);
00198     void                        setAutoSaveFileExt(const UT_String &);
00199 
00200     XAP_Dialog_MessageBox *      createMessageBox(XAP_String_Id id,
00201                                                   XAP_Dialog_MessageBox::tButtons buttons,
00202                                                   XAP_Dialog_MessageBox::tAnswer default_answer,
00203                                                   ...);
00204 
00205     XAP_Dialog_MessageBox::tAnswer      showMessageBox(XAP_String_Id id,
00206                                                        XAP_Dialog_MessageBox::tButtons buttons,
00207                                                        XAP_Dialog_MessageBox::tAnswer default_answer);
00208 
00209     XAP_Dialog_MessageBox::tAnswer      showMessageBox(const std::string & sz,
00210                                                        XAP_Dialog_MessageBox::tButtons buttons,
00211                                                        XAP_Dialog_MessageBox::tAnswer default_answer);
00212 
00213     XAP_Dialog_MessageBox::tAnswer      showMessageBox(const char * sz,
00214                                                        XAP_Dialog_MessageBox::tButtons buttons,
00215                                                        XAP_Dialog_MessageBox::tAnswer default_answer);
00216 
00217     XAP_Dialog_MessageBox::tAnswer      showMessageBox(XAP_String_Id id,
00218                                                        XAP_Dialog_MessageBox::tButtons buttons,
00219                                                        XAP_Dialog_MessageBox::tAnswer default_answer,
00220                                                        const char * sz);
00221 
00222     XAP_Dialog_MessageBox::tAnswer      showMessageBox(XAP_Dialog_MessageBox * pDialog);
00223 
00224     UT_Error        backup(const char* stExt = 0, UT_sint32 iEFT = -1);
00225     UT_String       makeBackupName (const char * szExt = 0);
00226 
00227     bool                        isStatusBarShown(void) const { return m_bShowStatusbar;}
00228     bool                        isMenuBarShown(void) const { return m_bShowMenubar;}
00229     virtual void                setStatusBarShown(bool /*bShowStatusbar*/) {}
00230     virtual void                setMenuBarShown(bool /*bShowMenubar*/) {}
00231     time_t                      getTimeSinceSave() const;
00232     bool                        isFrameLocked(void) const
00233                                 {return m_bIsFrameLocked;}
00234     void                        setFrameLocked(bool bLock)
00235                                 {m_bIsFrameLocked = bLock;}
00236     bool                        isMenuScrollHidden(void) const
00237     { return m_bHideMenuScroll;}
00238     UT_RGBColor getColorSelBackground () const;
00239     UT_RGBColor getColorSelForeground () const;
00240 
00241     void dragText();
00242     virtual UT_sint32 getDocumentAreaXoff(void)
00243     { return 0;}
00244     virtual UT_sint32 getDocumentAreaYoff(void)
00245     { return 0;}
00246 protected:
00247     friend class XAP_FrameImpl;
00248 
00249     AD_Document *               m_pDoc;         /* to our in-memory representation of a document */
00250     AV_View *                   m_pView;        /* to our view on the document */
00251     ap_ViewListener *           m_pViewListener;
00252     AV_ListenerId               m_lid;
00253     AV_ScrollObj *              m_pScrollObj;   /* to our scroll handler */
00254     UT_uint32                   m_nView;
00255     int                         m_iUntitled;
00256     ap_Scrollbar_ViewListener * m_pScrollbarViewListener;
00257     AV_ListenerId               m_lidScrollbarViewListener;
00258     XAP_Frame::tZoomType        m_zoomType;
00259     GR_Graphics::Cursor         m_cursor;
00260     void *                      m_pData;        /* app-specific frame data */
00261     bool                        m_bHideMenuScroll;
00262 
00263     static int                  _getNextUntitledNumber();
00264 
00265 private:
00266     void                        _createAutoSaveTimer();
00267     void                        _removeAutoSaveFile();
00268 
00269     UT_UTF8String               m_sTitle;
00270     UT_UTF8String               m_sNonDecoratedTitle;
00271 
00272     UT_uint32                   m_iIdAutoSaveTimer;
00273     UT_uint32                   m_iAutoSavePeriod;
00274     UT_String                   m_stAutoSaveExt;
00275     UT_String                   m_stAutoSaveNamePrevious;
00276     bool                        m_bBackupRunning;
00277     bool                        m_bBackupInProgress;
00278 
00279     static int                  s_iUntitled;
00280 
00281     XAP_Toolbar_Id              m_isrcId;
00282     UT_sint32                   m_isrcTBNr;
00283     XAP_Toolbar_Id              m_idestId;
00284     UT_sint32                   m_idestTBNr;
00285     bool                        m_bisDragging;
00286     bool                        m_bHasDropped;
00287     bool                        m_bHasDroppedTB;
00288 
00289     bool                        m_bFirstDraw; // WL_REFACTOR: should this go into the helper?
00290     bool                        m_bShowStatusbar;
00291     bool                        m_bShowMenubar;
00292     bool                        m_bIsFrameLocked;
00293 
00294     XAP_FrameImpl *           m_pFrameImpl; /* set by platform specific code */
00295     UT_uint32                   m_iZoomPercentage;
00296 };
00297 
00298 #endif /* XAP_Frame_H */
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306 
00307 

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1