scbpage.h

Go to the documentation of this file.
00001 #ifndef SCBPAGE_H_
00002 #define SCBPAGE_H_
00003 
00004 /*
00005  * File Name  : scbpage.h
00006  * 
00007  * Description: Scribble library page definition
00008  */
00009 
00010 /*
00011  * This file is part of liberscribble.
00012  *
00013  * liberscribble 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  * liberscribble 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) 2008 iRex Technologies B.V.
00029  * All rights reserved.
00030  */
00031 
00032 
00033 //----------------------------------------------------------------------------
00034 // Include Files
00035 //----------------------------------------------------------------------------
00036 
00037 // system include files, between < >
00038 
00039 // ereader include files, between < >
00040 
00041 // local include files, between " "
00042 #include "scbconfig.h"
00043 #include "scbstream.h"
00044 #include "scbstrokes.h"
00045 
00046 #ifdef __cplusplus
00047 extern "C"
00048 {
00049 #endif
00050 
00051 
00052 //----------------------------------------------------------------------------
00053 // Definitions
00054 //---------------------------------------------------------------------------- 
00055 
00056 
00057 //----------------------------------------------------------------------------
00058 // Forward Declarations
00059 //----------------------------------------------------------------------------
00060 
00061 
00062 //----------------------------------------------------------------------------
00063 // Type Declarations
00064 //----------------------------------------------------------------------------
00065     
00066 typedef struct _ScbPageId
00067 {
00068     char   id[ERSCRIBBLE_MAX_PAGEID_LEN];    /**< id of the page, equal to the start anchor of page */
00069     int    position;                         /**< file position of the page,
00070                                            current it is equal to page number */
00071     gint64 annotation_id;                    /**< annotation id of the page,
00072                                            it is used for query data in metadat DB
00073                                            Caller should NOT modify this value */
00074 } ScbPageId;
00075 
00076 typedef ScbPageId * ScbPageIdPtr;
00077 
00078 typedef struct _ScbPageStyle
00079 {
00080     int             orientation;           /**< Orientation of a page, e.g. 0, 90, 270 */
00081     ScbColor        bgColor;               /**< Background color of a page */
00082 } ScbPageStyle;
00083 
00084 typedef struct _ScbPageOptHist
00085 {
00086     // TODO. maybe a list of operation history is needed
00087     int a;
00088 } ScbPageOptHist;
00089 
00090 // Erase context. This context is used for recording necessary information when tring to
00091 // erase a stroke. There are two erase mode in real scenario: in "Point" mode, only one point
00092 // is considered as the erase area, the actual erasing function does the hit test with this
00093 // point; in "Line" mode, a line with two points is considered as the erase area, the erasing
00094 // function does the hit test with this line.
00095 typedef struct _ScbPageEraseCtx
00096 {
00097     ScbDevPoint     p1;             /**< start point of an erase line. */
00098     ScbDevPoint     p2;             /**< end point of an erase line */
00099     double          zoom;           /**< zoom setting of the erasing */
00100     gboolean        bInit;          /**< Indicates whether the context has been set before,
00101                                          if bInit is true, it means point p1 has been set, then scribble
00102                                          library does hit test in "Point" mode; otherwise, p1 and p2 are
00103                                          both set, library does hit test in "Line" mode */
00104 } ScbPageEraseCtx;
00105 
00106 typedef ScbPageEraseCtx * ScbPageEraseCtxPtr;
00107 
00108 typedef struct _ScbPageAttributes
00109 {
00110     unsigned short  minor_version;    /**< minor version number of the scribble library */
00111     ScbPageStyle    style;            /**< page style */
00112     ScbRect         area;             /**< page area  */
00113     int             strokes_number;   /**< number of the strokes in a page */
00114 } ScbPageAttributes;
00115 
00116 typedef struct _ScbPage
00117 {
00118     ScbPageAttributes attributes;     /**< page attributes */
00119     ScbPageId         id;             /**< page id */
00120     ScbPageOptHist    actions;        /**< actions list which records the recent operations */
00121     ScbStrokes        strokes;        /**< stroke list of the page */
00122     ScbStrokes        del_strokes;     /**< deleted stroke list of the page */
00123     int               timestamp;      /**< timestamp of last access to this page. */
00124     gboolean          is_blob_loaded; /**< if the blob of a page has been loaded, erscribble need
00125                                            not acess the metadb again */
00126 } ScbPage;
00127 
00128 typedef ScbPage * ScbPagePtr;
00129 
00130 
00131 //----------------------------------------------------------------------------
00132 // Global Constants
00133 //----------------------------------------------------------------------------
00134 
00135 
00136 //============================================================================
00137 // Public Functions
00138 //============================================================================
00139 
00140 // Construct an empty scribble page
00141 // @return return the pointer of created page instance
00142 ScbPagePtr erscribble_page_new();
00143 
00144 // Set the size to the page
00145 void erscribble_page_set_size(ScbPagePtr ptr, const int width, const int height);
00146 
00147 // Free a page instance
00148 // @param ptr the page instance that needs to be deleted
00149 void erscribble_page_free(ScbPagePtr ptr);
00150 
00151 // Clear strokes of a page
00152 // @param ptr the page instance on which strokes should be cleared.
00153 void erscribble_page_clear_strokes(ScbPagePtr ptr);
00154 
00155 // Set ID of a page
00156 // @param page the instance of the scribble page
00157 // @param id the id to be set
00158 void erscribble_page_copy_id(ScbPageIdPtr dst, const ScbPageIdPtr src);
00159 
00160 // Generate a page id by page anchor, file position and the annotation id.
00161 // @param ptr the pointer of page id instance
00162 // @param position the file position of the page
00163 // @param anchor the start anchor of the page
00164 void erscribble_page_set_id(ScbPageIdPtr ptr, const int position, const char *anchor, const int anno_id);
00165 
00166 // Reset a page id to the initial status
00167 // @param ptr the pointer of the page id instance
00168 void erscribble_page_reset_id(ScbPageIdPtr ptr);
00169 
00170 // Get the number of strokes in a page
00171 // @param ptr the pointer of scribble page instance
00172 // @return return the number of strokes
00173 int erscribble_page_get_stroke_count(ScbPagePtr ptr);
00174 
00175 // Add a stroke into the scribble page
00176 // @param page the pointer of a scribble page instance
00177 // @param stroke the pointer of a scribble stroke
00178 // @return return TRUE if the stroke is successfully added into the page
00179 gboolean erscribble_page_add_stroke(ScbPagePtr page, ScbStrokePtr stroke);
00180 
00181 // Get the address of strokes list in a scribble page
00182 // @param page the pointer of a scribble page instance
00183 // @return return the pointer of strokes list
00184 ScbStrokesPtr erscribble_page_get_strokes(ScbPagePtr page);
00185 
00186 // Initialize an erase context
00187 // @param ptr the pointer of an erase context
00188 void erscribble_page_erase_init(ScbPageEraseCtxPtr ptr);
00189 
00190 // Make hit test when caller needs erase a stroke or some strokes
00191 // @param page the pointer of a scribble page instance
00192 // @param point the point used for hit test
00193 // @param ptr the context of current erase operation, if a point is maintained in advance,
00194 // the composite line will be used for hit test
00195 // @return return a list of strokes instance if hit test succeeds, other wise return NULL
00196 ScbStrokesPtr erscribble_page_erase_hit_test(ScbPagePtr page, ScbDevPointPtr point, ScbPageEraseCtxPtr ptr);
00197 
00198 gboolean erscribble_page_load(ScbPagePtr page, ScbStreamPtr stream);
00199 gboolean erscribble_page_write_stream(ScbPagePtr page, ScbStreamPtr stream);
00200 int erscribble_page_get_length(ScbPagePtr ptr);
00201 void erscribble_page_set_minor_version_number(ScbPagePtr page, const unsigned short minor);
00202 
00203 // Dump the data of page
00204 // This function can be used for debug
00205 void erscribble_page_dump(ScbPagePtr ptr);
00206 
00207 
00208 #ifdef __cplusplus
00209 }
00210 #endif
00211 
00212 #endif
Generated by  doxygen 1.6.2-20100208