App_WithDoc.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_APP_WITHDOC_H
00020 #define BAKERY_APP_WITHDOC_H
00021 
00022 #include <bakery/App/App.h>
00023 #include <bakery/Document/Document.h>
00024 
00025 namespace Bakery
00026 {
00027 
00056 class App_WithDoc : virtual public App //virtual because App_WithDoc_Gtk will inherit it via App_With_Doc and via App_Gtk.
00057 {
00058 public: 
00060   App_WithDoc(const Glib::ustring& appname = ""); //TODO: appname when using get_derived_widget()
00061 
00062   virtual ~App_WithDoc();
00063 
00064   virtual void init(); //overridden to create document.
00065 
00066   enum enumSaveChanges
00067   {
00068     SAVECHANGES_Save,
00069     SAVECHANGES_Cancel,
00070     SAVECHANGES_Discard
00071   };
00072 
00073   static bool file_exists(const Glib::ustring& uri);
00074 
00075 protected:
00076   virtual void init_create_document(); //override this to new() the specific document type.
00077 
00082   static void add_mime_type(const Glib::ustring& mime_type);
00083 
00085   virtual Document* get_document();
00086 
00088   virtual const Document* get_document() const ;
00089 
00090   virtual void set_document_modified(bool bModified = true);
00091 
00096   virtual bool open_document(const Glib::ustring& file_uri);
00097 
00098   //This cannot be virtual, because that would break our ABI.
00099   //Hopefully that is not necessary.
00106   bool open_document_from_data(const guchar* data, std::size_t length);
00107 
00108   virtual void document_history_add(const Glib::ustring& file_uri);
00109   virtual void document_history_remove(const Glib::ustring& file_uri);
00110 
00111 public:
00112   // We can not take function pointers of these methods in 
00113   // a derived class if they are protected - for instance, with sigc::mem_fun()
00114   //Signal handlers:
00115 
00116   //Menu items:
00117   virtual void on_menu_file_open();
00118   virtual void on_menu_file_saveas(); //signal handler.
00119   virtual void offer_saveas(); //For direct use.
00120   virtual void on_menu_file_save(); //signal handler.
00121   virtual void on_menu_file_close();
00122 
00123   virtual void on_menu_edit_copy();
00124   virtual void on_menu_edit_paste();
00125   virtual void on_menu_edit_clear();
00126 
00127 protected:
00128   //Document:
00129 
00131   virtual void on_document_modified(bool modified);
00132 
00134   virtual bool on_document_load();
00135 
00136   virtual void offer_to_save_changes();
00137 
00139   virtual void cancel_close_or_exit();
00140 
00142   virtual void close_mark_or_destroy();
00143 
00144   virtual void update_window_title();
00145 
00146   virtual void after_successful_save(); //e.g. disable File|Save.
00147 
00148   virtual void ui_warning(const Glib::ustring& text, const Glib::ustring& secondary_text) = 0;
00149   virtual Glib::ustring ui_file_select_open(const Glib::ustring& ui_file_select_open = Glib::ustring()) = 0;
00150 
00155   virtual Glib::ustring ui_file_select_save(const Glib::ustring& old_file_uri) = 0;
00156 
00157   virtual void ui_show_modification_status() = 0;
00158 
00159   virtual enumSaveChanges ui_offer_to_save_changes() = 0;
00160 
00161   static Glib::ustring get_conf_fullkey(const Glib::ustring& key);
00162 
00163   //Document:
00164   Document* m_pDocument; //An instance of a derived type.
00165   bool m_bCloseAfterSave;
00166 
00167   //Mime types which this application can load and save:
00168   typedef std::list<Glib::ustring> type_list_strings;
00169   static type_list_strings m_mime_types;
00170 };
00171 
00172 } //namespace
00173 
00174 #endif //BAKERY_APP_WITHDOC_H

Generated on Thu Jan 17 07:44:58 2008 for bakery by  doxygen 1.5.4