Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Document.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2000 Murray Cumming
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the Free
00016  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 #ifndef BAKERY_DOCUMENT_H
00020 #define BAKERY_DOCUMENT_H
00021 
00022 #include "bakery/View/View.h"
00023 #include <glibmm.h>
00024 
00025 #include <iostream>
00026 
00027 namespace Bakery
00028 {
00029 
00034 class Document
00035 {
00036 public: 
00037   Document();
00038   virtual ~Document();
00039 
00040   /* Saves the data to disk.
00041    * Asks the View to update this document before saving to disk,
00042    * but you should probably ensure that the document is updated more regularly than this,
00043    * so that different parts of the GUI are synchronized.
00044    * Only saves if the document has been modified.
00045    * bool indicates success.
00046    */
00047   virtual bool save();
00048 
00049   /* Loads data from disk, then asks the View to update itself.
00050    * bool indicates success.
00051    */
00052   virtual bool load();
00053 
00054   virtual bool get_modified() const;
00055   virtual void set_modified(bool bVal = true);
00056 
00058   virtual bool get_is_new() const;
00060   void set_is_new(bool bVal);
00061 
00062   virtual Glib::ustring get_contents() const;
00063   virtual void set_contents(const Glib::ustring& strVal);
00064 
00065   virtual Glib::ustring get_file_uri_with_extension(const Glib::ustring& uri);
00066   
00067   virtual Glib::ustring get_file_uri() const;
00068   virtual void set_file_uri(const Glib::ustring& file_uri, bool bEnforceFileExtension = false);
00069 
00071   virtual Glib::ustring get_name() const;
00072   static Glib::ustring util_file_uri_get_name(const Glib::ustring& file_uri, const Glib::ustring& file_extension);
00073 
00074   virtual bool get_read_only() const;
00075   virtual void set_read_only(bool bVal);
00076   
00078   virtual void set_view(ViewBase* pView);
00079   virtual ViewBase* get_view();
00080 
00081   virtual void set_file_extension(const Glib::ustring& strVal);
00082   virtual Glib::ustring get_file_extension() const;
00083 
00084   //Signals
00087   typedef sigc::signal<void, bool> type_signal_modified;
00088 
00092   type_signal_modified& signal_modified();
00093 
00094   typedef sigc::signal<void> type_signal_forget;
00095 
00099   type_signal_forget& signal_forget();
00100 
00102 
00103 protected:
00107   virtual bool load_after();
00108 
00112   virtual bool save_before();
00113 
00114   virtual bool read_from_disk();
00115   virtual bool write_to_disk();
00116 
00117   Glib::ustring m_strContents;
00118   Glib::ustring m_file_uri;
00119   Glib::ustring m_file_extension;
00120 
00121   ViewBase* m_pView;
00122 
00123   type_signal_modified signal_modified_;
00124   type_signal_forget signal_forget_;
00125   
00126   bool m_bModified;
00127   bool m_bIsNew; //see get_is_new().
00128   bool m_bReadOnly;
00129 };
00130 
00131 } //namespace
00132 
00133 #endif //GNOME_APPWITHDOCS_DOCUMENT_H

Generated on Tue Jan 4 19:00:07 2005 for bakery by  doxygen 1.3.9.1