# Bakery::App_WithDoc Class Reference

Main Window which supports documents. More...

`#include <App_WithDoc.h>`

Inheritance diagram for Bakery::App_WithDoc:

[legend]

List of all members.

## Public Types
enum | enumSaveChanges { SAVECHANGES_Save, SAVECHANGES_Cancel, SAVECHANGES_Discard }
## Public Member Functions
| App_WithDoc (const Glib::ustring &appname="")
| Don't forget to call init() too.
virtual | ~App_WithDoc ()
virtual void | init ()
virtual void | on_menu_file_open ()
virtual void | on_menu_file_saveas ()
virtual void | offer_saveas ()
virtual void | on_menu_file_save ()
virtual void | on_menu_file_close ()
virtual void | on_menu_edit_copy ()
virtual void | on_menu_edit_paste ()
virtual void | on_menu_edit_clear ()
## Static Public Member Functions
static bool | file_exists (const Glib::ustring &uri)
## Protected Types
typedef std::list< Glib::ustring > | type_list_strings
## Protected Member Functions
virtual void | init_create_document ()
virtual Document * | get_document ()
| static_cast<> or dynamic_cast<> this pointer to the correct type.
virtual const Document * | get_document () const
| static_cast<> or dynamic_cast<> this pointer to the correct type.
virtual void | set_document_modified (bool bModified=true)
virtual bool | open_document (const Glib::ustring &file_uri)
| Open the document from a file at a URI.
bool | open_document_from_data (const guchar *data, std::size_t length)
| Open the document using the supplied document contents.
virtual void | document_history_add (const Glib::ustring &file_uri)
virtual void | document_history_remove (const Glib::ustring &file_uri)
virtual void | on_document_modified (bool modified)
| Update visual status.
virtual bool | on_document_load ()
| override this to show document contents.
virtual void | offer_to_save_changes ()
virtual void | cancel_close_or_exit ()
| Stop the File|Close or the File|Exit.
virtual void | close_mark_or_destroy ()
| destroy it or mark it for destruction.
virtual void | update_window_title ()
virtual void | after_successful_save ()
virtual void | ui_warning (const Glib::ustring &text, const Glib::ustring &secondary_text)=0
virtual Glib::ustring | ui_file_select_open (const Glib::ustring &ui_file_select_open=Glib::ustring())=0
virtual Glib::ustring | ui_file_select_save (const Glib::ustring &old_file_uri)=0
| Present a user interface that allows the user to select a location to save the file.
virtual void | ui_show_modification_status ()=0
virtual enumSaveChanges | ui_offer_to_save_changes ()=0
## Static Protected Member Functions
static void | add_mime_type (const Glib::ustring &mime_type)
| Add a MIME-type that this application can support.
static Glib::ustring | get_conf_fullkey (const Glib::ustring &key)
## Protected Attributes
Document * | m_pDocument
bool | m_bCloseAfterSave
## Static Protected Attributes
static type_list_strings | m_mime_types

## Detailed Description

Main Window which supports documents.

This is an abstract class. You must use a class such as App_WithDoc_Gtk, which implements the ui_* methods for a particular GUI toolkit.

Features:

- 1 document per application instance. Uses Document-derived class polymorphically.
- Override init_create_document() to create new blank document.
- Appropriate Default handling of document open, save, save as.
- Appropriate checking of document 'modified' status - asks user about unsaved changes.
- Asks user about overwriting existing documents.
- Override methods to add/change menus/toolbars/statusbar.
  - Default is basic File, Edit, Help menus and toolbar icons.
- Shows document name (or 'untitled') in window title.
- Shows * in title bar for unsaved docs. Overridable to e.g. shade a Save icon.
- Enforces a file extension.
- Recent Documents menu item - if you use add_mime_type().

TODO:

- Printing -?
  - Print Setup
  - Print Preview
  - Multiple document-types:
  - File/New sub menu
  - Some way to associate a view with a document type: class factory.

## Member Typedef Documentation

typedef std::list<Glib::ustring> Bakery::App_WithDoc::type_list_strings`[protected]`

## Member Enumeration Documentation

enum Bakery::App_WithDoc::enumSaveChanges

Enumerator:

  SAVECHANGES_Save |
  SAVECHANGES_Cancel |
  SAVECHANGES_Discard |

## Constructor & Destructor Documentation

Bakery::App_WithDoc::App_WithDoc | ( | const Glib::ustring & | appname = `""` | ) |

Don't forget to call init() too.

virtual Bakery::App_WithDoc::~App_WithDoc | ( |  | ) | `[virtual]`

## Member Function Documentation

virtual void Bakery::App_WithDoc::init | ( |  | ) | `[virtual]`

Reimplemented from Bakery::App.

Reimplemented in Bakery::App_WithDoc_Gtk.

static bool Bakery::App_WithDoc::file_exists | ( | const Glib::ustring & | uri | ) | `[static]`

virtual void Bakery::App_WithDoc::init_create_document | ( |  | ) | `[protected, virtual]`

static void Bakery::App_WithDoc::add_mime_type | ( | const Glib::ustring & | mime_type | ) | `[static, protected]`

Add a MIME-type that this application can support.

You should also register the MIME-type when the application is installed: See http://freedesktop.org/Standards/AddingMIMETutor

virtual Document* Bakery::App_WithDoc::get_document | ( |  | ) | `[protected, virtual]`

static_cast<> or dynamic_cast<> this pointer to the correct type.

virtual const Document* Bakery::App_WithDoc::get_document | ( |  | ) | const`[protected, virtual]`

static_cast<> or dynamic_cast<> this pointer to the correct type.

virtual void Bakery::App_WithDoc::set_document_modified | ( | bool | bModified = `true` | ) | `[protected, virtual]`

virtual bool Bakery::App_WithDoc::open_document | ( | const Glib::ustring & | file_uri | ) | `[protected, virtual]`

Open the document from a file at a URI.

This will check whether the document is already open.

Returns:
  true indicates success.

bool Bakery::App_WithDoc::open_document_from_data | ( | const guchar * | data,
|  | std::size_t | length |
| ) |  |  | `[protected]`

Open the document using the supplied document contents.

Unlike open_document(), this has no way to know whether the document is already open.

Parameters:

  | data | A pointer to the bytes of the document contents.
  | length | The number of bytes in the data.

Returns:
  true indicates success.

virtual void Bakery::App_WithDoc::document_history_add | ( | const Glib::ustring & | file_uri | ) | `[protected, virtual]`

Reimplemented in Bakery::App_WithDoc_Gtk.

virtual void Bakery::App_WithDoc::document_history_remove | ( | const Glib::ustring & | file_uri | ) | `[protected, virtual]`

Reimplemented in Bakery::App_WithDoc_Gtk.

virtual void Bakery::App_WithDoc::on_menu_file_open | ( |  | ) | `[virtual]`

virtual void Bakery::App_WithDoc::on_menu_file_saveas | ( |  | ) | `[virtual]`

virtual void Bakery::App_WithDoc::offer_saveas | ( |  | ) | `[virtual]`

virtual void Bakery::App_WithDoc::on_menu_file_save | ( |  | ) | `[virtual]`

virtual void Bakery::App_WithDoc::on_menu_file_close | ( |  | ) | `[virtual]`

Reimplemented from Bakery::App.

virtual void Bakery::App_WithDoc::on_menu_edit_copy | ( |  | ) | `[virtual]`

Reimplemented from Bakery::App.

virtual void Bakery::App_WithDoc::on_menu_edit_paste | ( |  | ) | `[virtual]`

Reimplemented from Bakery::App.

virtual void Bakery::App_WithDoc::on_menu_edit_clear | ( |  | ) | `[virtual]`

Reimplemented from Bakery::App.

virtual void Bakery::App_WithDoc::on_document_modified | ( | bool | modified | ) | `[protected, virtual]`

Update visual status.

virtual bool Bakery::App_WithDoc::on_document_load | ( |  | ) | `[protected, virtual]`

override this to show document contents.

virtual void Bakery::App_WithDoc::offer_to_save_changes | ( |  | ) | `[protected, virtual]`

virtual void Bakery::App_WithDoc::cancel_close_or_exit | ( |  | ) | `[protected, virtual]`

Stop the File|Close or the File|Exit.

virtual void Bakery::App_WithDoc::close_mark_or_destroy | ( |  | ) | `[protected, virtual]`

destroy it or mark it for destruction.

virtual void Bakery::App_WithDoc::update_window_title | ( |  | ) | `[protected, virtual]`

Reimplemented in Bakery::App_WithDoc_Gtk.

virtual void Bakery::App_WithDoc::after_successful_save | ( |  | ) | `[protected, virtual]`

virtual void Bakery::App_WithDoc::ui_warning | ( | const Glib::ustring & | text,
|  | const Glib::ustring & | secondary_text |
| ) |  |  | `[protected, pure virtual]`

Implemented in Bakery::App_WithDoc_Gtk.

virtual Glib::ustring Bakery::App_WithDoc::ui_file_select_open | ( | const Glib::ustring & | ui_file_select_open = `Glib::ustring()` | ) | `[protected, pure virtual]`

Implemented in Bakery::App_WithDoc_Gtk.

virtual Glib::ustring Bakery::App_WithDoc::ui_file_select_save | ( | const Glib::ustring & | old_file_uri | ) | `[protected, pure virtual]`

Present a user interface that allows the user to select a location to save the file.

Parameters:

  | old_file_uri | The existing URI of the file, if any.

Returns:
  The URI of the file chosen by the user.

Implemented in Bakery::App_WithDoc_Gtk.

virtual void Bakery::App_WithDoc::ui_show_modification_status | ( |  | ) | `[protected, pure virtual]`

Implemented in Bakery::App_WithDoc_Gtk.

virtual enumSaveChanges Bakery::App_WithDoc::ui_offer_to_save_changes | ( |  | ) | `[protected, pure virtual]`

Implemented in Bakery::App_WithDoc_Gtk.

static Glib::ustring Bakery::App_WithDoc::get_conf_fullkey | ( | const Glib::ustring & | key | ) | `[static, protected]`

## Member Data Documentation

Document* Bakery::App_WithDoc::m_pDocument`[protected]`

bool Bakery::App_WithDoc::m_bCloseAfterSave`[protected]`

type_list_strings Bakery::App_WithDoc::m_mime_types`[static, protected]`

The documentation for this class was generated from the following file:

- App_WithDoc.h