notepad_doc.h

Go to the documentation of this file.
00001 #ifndef __NOTEPAD_DOC_H__
00002 #define __NOTEPAD_DOC_H__
00003 
00004 /**
00005  * File Name  : notepad_doc.h
00006  *
00007  * Description: notepad document class
00008  */
00009 
00010 /*
00011  * This file is part of notepad.
00012  *
00013  * notepad is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * notepad is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2010 IREX Technologies B.V.
00029  * All rights reserved.
00030  */
00031  
00032 #include <glib.h>
00033 #include <gtk/gtk.h> 
00034 
00035 #include "notepad_utils.h"
00036 #include "notepad_point.h"
00037 #include "notepad_filestore.h"
00038 #include <liberscribble/scb.h>
00039 
00040 namespace notepad 
00041 {
00042 
00043     class CNotepadDoc
00044     {
00045         public:
00046             // object lifecycle
00047             CNotepadDoc();
00048             ~CNotepadDoc();
00049 
00050         private:
00051             CNotepadDoc(const CNotepadDoc&);            // no copy 
00052             CNotepadDoc& operator=(const CNotepadDoc&); // no assignment
00053 
00054         public:
00055             // document lifecycle
00056             np_result open(const gchar* filename);      // document filename is absolute
00057             np_result create(const gchar* filename);    // create empty document
00058             np_result save_page(const int pageno, bool update_last_read = false); // saves latest changes of current page
00059             np_result rename(const gchar* filename);    // saves current document using other name
00060             void      close();
00061             int       get_num_pages();                  // Retrieves the number of pages
00062             gchar*    get_full_filename();              // Retrieves the filename with path and extension
00063             gchar*    get_filename_without_dir_and_ext(); // Retrieves the short filename without path and extension
00064             CFileStore* getFileStore();                 // Retrieve the filestore class
00065             gboolean  get_page_dirty();                 // Retrieve the dirty flag
00066 
00067         private:
00068             void generate_page_id(ScbPageId& pageId, const int pageno);
00069 
00070             // page functions
00071         public:
00072             void insert_page(const int pageno);
00073             void add_page(const int pageno);
00074             void delete_page(const int pageno);
00075             void clear_page(const int pageno);
00076             gboolean set_last_read(gint value);
00077             gint     get_last_read(void);
00078 
00079         public:
00080             // drawing functions
00081 
00082             void on_scribble_begin(
00083                     const int           pageno,
00084                     GCtx&               gctx,
00085                     GdkImage*           image,
00086                     CNPoint&            apoint);
00087 
00088             void on_scribble_move(
00089                     const int           pageno,
00090                     GCtx&               gctx,
00091                     GdkImage*           image,
00092                     CNPoint&            apoint);
00093 
00094             void on_scribble_end(
00095                     const int           pageno,
00096                     GCtx&               gctx,
00097                     GdkImage*           image,
00098                     CNPoint&            apoint);
00099 
00100             void on_erase_begin(
00101                     const int           pageno,
00102                     GCtx&               gctx,
00103                     GdkImage*           image,
00104                     CNPoint&            apoint);
00105 
00106             void on_erase_move(
00107                     const int           pageno,
00108                     GCtx&               gctx,
00109                     GdkImage*           image,
00110                     CNPoint&            apoint);
00111 
00112             void on_erase_end(
00113                     const int           pageno,
00114                     GCtx&               gctx,
00115                     GdkImage*           image,
00116                     CNPoint&            apoint);
00117 
00118             void draw_scribble_page(const int pageno, GCtx& gctx, GdkImage* image); 
00119 
00120         private:
00121             void draw_stroke(GCtx& gctx, GdkImage*  image, ScbStrokePtr stroke);
00122             void draw_erased_strokes(GCtx& gctx, GdkImage* image, ScbStrokesPtr strokes);
00123 
00124         private:
00125             ScbPath         path;                       //< The scribble document path.
00126             ScbDocPtr       doc;                        //< The scribble document.
00127             ScbPagePtr      page;                       //< Page currently used.
00128             ScbStrokePtr    stroke;                     //< Stroke currently used.
00129             ScbPageEraseCtx erase_context;              //< Used by erscribble library.
00130 
00131             gboolean        dirty;                      //< Used to decide if to save or not
00132 
00133             CFileStore*     file_store;                 //< Storage
00134     };
00135 
00136 }
00137 
00138 #endif // __NOTEPAD_DOC_H__
Generated by  doxygen 1.6.2-20100208