bakery
2.6
Main Page
Namespaces
Classes
Files
File List
File Members
bakery
Document
Document.h
Go to the documentation of this file.
1
/*
2
* Copyright 2000 Murray Cumming
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
13
*
14
* You should have received a copy of the GNU Library General Public
15
* License along with this library; if not, write to the Free
16
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
*/
18
19
#ifndef BAKERY_DOCUMENT_H
20
#define BAKERY_DOCUMENT_H
21
22
#include "
bakery/View/View.h
"
23
#include <glibmm.h>
24
25
#include <iostream>
26
27
namespace
Bakery
28
{
29
34
class
Document
35
{
36
public
:
37
Document
();
38
virtual
~Document
();
39
40
/* Saves the data to disk.
41
* Asks the View to update this document before saving to disk,
42
* but you should probably ensure that the document is updated more regularly than this,
43
* so that different parts of the GUI are synchronized.
44
* Only saves if the document has been modified.
45
* bool indicates success.
46
*/
47
bool
save
();
48
49
/* Loads data from disk, using the URI (set with set_file_uri()) then asks the View to update itself.
50
* bool indicates success.
51
*/
52
bool
load
();
53
54
//This can't be virtual because that would break ABI.
55
//Hopefully it doesn't need to be.
56
/* Loads data from disk, using the URI (set with set_file_uri()) then asks the View to update itself.
57
* bool indicates success.
58
*/
59
bool
load_from_data
(
const
guchar* data, std::size_t length);
60
61
62
virtual
bool
get_modified
()
const
;
63
virtual
void
set_modified
(
bool
bVal =
true
);
64
66
virtual
bool
get_is_new
()
const
;
68
void
set_is_new
(
bool
bVal);
69
70
virtual
Glib::ustring
get_contents
()
const
;
71
virtual
void
set_contents
(
const
Glib::ustring& strVal);
72
73
virtual
Glib::ustring
get_file_uri_with_extension
(
const
Glib::ustring& uri);
74
75
virtual
Glib::ustring
get_file_uri
()
const
;
76
virtual
void
set_file_uri
(
const
Glib::ustring& file_uri,
bool
bEnforceFileExtension =
false
);
77
79
virtual
Glib::ustring
get_name
()
const
;
80
static
Glib::ustring
util_file_uri_get_name
(
const
Glib::ustring& file_uri,
const
Glib::ustring& file_extension);
81
82
virtual
bool
get_read_only
()
const
;
83
virtual
void
set_read_only
(
bool
bVal);
84
86
virtual
void
set_view
(
ViewBase
* pView);
87
virtual
ViewBase
*
get_view
();
88
89
virtual
void
set_file_extension
(
const
Glib::ustring& strVal);
90
virtual
Glib::ustring
get_file_extension
()
const
;
91
92
//Signals
95
typedef
sigc::signal<void, bool>
type_signal_modified
;
96
100
type_signal_modified
&
signal_modified
();
101
102
typedef
sigc::signal<void>
type_signal_forget
;
103
107
type_signal_forget
&
signal_forget
();
108
110
111
protected
:
115
virtual
bool
load_after
();
116
120
virtual
bool
save_before
();
121
122
virtual
bool
read_from_disk
();
123
virtual
bool
write_to_disk
();
124
125
Glib::ustring
m_strContents
;
126
Glib::ustring
m_file_uri
;
127
Glib::ustring
m_file_extension
;
128
129
ViewBase
*
m_pView
;
130
131
type_signal_modified
signal_modified_
;
132
type_signal_forget
signal_forget_
;
133
134
bool
m_bModified
;
135
bool
m_bIsNew
;
//see get_is_new().
136
bool
m_bReadOnly
;
137
};
138
139
}
//namespace
140
141
#endif //GNOME_APPWITHDOCS_DOCUMENT_H
Generated by
1.8.1.2