scbpage.h File Reference

#include "scbconfig.h"
#include "scbstream.h"
#include "scbstrokes.h"
Include dependency graph for scbpage.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _ScbPageId
struct  _ScbPageStyle
struct  _ScbPageOptHist
struct  _ScbPageEraseCtx
struct  _ScbPageAttributes
struct  _ScbPage

Typedefs

typedef struct _ScbPageId ScbPageId
typedef ScbPageIdScbPageIdPtr
typedef struct _ScbPageStyle ScbPageStyle
typedef struct _ScbPageOptHist ScbPageOptHist
typedef struct _ScbPageEraseCtx ScbPageEraseCtx
typedef ScbPageEraseCtxScbPageEraseCtxPtr
typedef struct _ScbPageAttributes ScbPageAttributes
typedef struct _ScbPage ScbPage
typedef ScbPageScbPagePtr

Functions

ScbPagePtr erscribble_page_new ()
void erscribble_page_set_size (ScbPagePtr ptr, const int width, const int height)
void erscribble_page_free (ScbPagePtr ptr)
void erscribble_page_clear_strokes (ScbPagePtr ptr)
void erscribble_page_copy_id (ScbPageIdPtr dst, const ScbPageIdPtr src)
void erscribble_page_set_id (ScbPageIdPtr ptr, const int position, const char *anchor, const int anno_id)
void erscribble_page_reset_id (ScbPageIdPtr ptr)
int erscribble_page_get_stroke_count (ScbPagePtr ptr)
gboolean erscribble_page_add_stroke (ScbPagePtr page, ScbStrokePtr stroke)
ScbStrokesPtr erscribble_page_get_strokes (ScbPagePtr page)
void erscribble_page_erase_init (ScbPageEraseCtxPtr ptr)
ScbStrokesPtr erscribble_page_erase_hit_test (ScbPagePtr page, ScbDevPointPtr point, ScbPageEraseCtxPtr ptr)
gboolean erscribble_page_load (ScbPagePtr page, ScbStreamPtr stream)
gboolean erscribble_page_write_stream (ScbPagePtr page, ScbStreamPtr stream)
int erscribble_page_get_length (ScbPagePtr ptr)
void erscribble_page_set_minor_version_number (ScbPagePtr page, const unsigned short minor)
void erscribble_page_dump (ScbPagePtr ptr)

Typedef Documentation

typedef struct _ScbPage ScbPage

Definition at line 106 of file scbpage.h.

typedef struct _ScbPageId ScbPageId

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 76 of file scbpage.h.

typedef ScbPage* ScbPagePtr

Definition at line 128 of file scbpage.h.

typedef struct _ScbPageStyle ScbPageStyle

Function Documentation

gboolean erscribble_page_add_stroke ( ScbPagePtr  page,
ScbStrokePtr  stroke 
)

Definition at line 181 of file scbpage.c.

References ERSCRIBBLE_RET_FALSE_IF, _ScbStrokes::strokes, and _ScbPage::strokes.

Referenced by notepad::CNotepadDoc::on_scribble_begin().

00182 {
00183     ERSCRIBBLE_RET_FALSE_IF(NULL == page || NULL == stroke, "Invalid pointer!");        
00184     page->strokes.strokes = g_list_append(page->strokes.strokes, stroke);
00185 
00186     return TRUE;
00187 }

Here is the caller graph for this function:

void erscribble_page_clear_strokes ( ScbPagePtr  ptr  ) 

Definition at line 154 of file scbpage.c.

References _ScbPage::del_strokes, ERSCRIBBLE_RET_IF, erscribble_strokes_free(), and _ScbPage::strokes.

Referenced by test::ScribbleMgr::clear_page(), notepad::CNotepadDoc::clear_page(), erscribble_doc_delete_page_impl(), erscribble_page_free(), load_page_data(), and remove_oldest_page_data().

00155 {
00156     ERSCRIBBLE_RET_IF(NULL == ptr, "Attempt to operate on NULL pointer!");
00157 
00158     erscribble_strokes_free(&ptr->strokes);
00159     erscribble_strokes_free(&ptr->del_strokes);
00160 }

Here is the call graph for this function:

Here is the caller graph for this function:

void erscribble_page_copy_id ( ScbPageIdPtr  dst,
const ScbPageIdPtr  src 
)

Definition at line 85 of file scbpage.c.

References _ScbPageId::annotation_id, ERSCRIBBLE_MAX_PAGEID_LEN, _ScbPageId::id, and _ScbPageId::position.

Referenced by notepad::CNotepadDoc::add_page(), test::ScribbleMgr::copy_page_id(), erscribble_doc_get_page(), notepad::CNotepadDoc::insert_page(), and notepad::CNotepadDoc::on_scribble_begin().

00086 {
00087     if (dst && src)
00088     {
00089         strncpy(dst->id, src->id, ERSCRIBBLE_MAX_PAGEID_LEN);
00090         dst->position = src->position;
00091         dst->annotation_id = src->annotation_id;
00092     }
00093 }

Here is the caller graph for this function:

void erscribble_page_dump ( ScbPagePtr  ptr  ) 

Definition at line 297 of file scbpage.c.

References _ScbPageAttributes::area, _ScbPage::attributes, _ScbRect::bottom, DUMPPRINTF, ERSCRIBBLE_RET_IF, erscribble_strokes_dump(), _ScbPageId::id, _ScbPage::id, _ScbRect::left, _ScbPageStyle::orientation, _ScbRect::right, _ScbPage::strokes, _ScbPageAttributes::style, and _ScbRect::top.

Referenced by _page_dump().

00298 {
00299     ERSCRIBBLE_RET_IF(NULL == ptr, "Attempt to dump on NULL page pointer!");
00300 
00301     DUMPPRINTF("================= Page %s Information =================", ptr->id.id);
00302     DUMPPRINTF("orientation %d", ptr->attributes.style.orientation);
00303     DUMPPRINTF("rect (%d, %d) - (%d, %d)", ptr->attributes.area.left, ptr->attributes.area.top, 
00304         ptr->attributes.area.right, ptr->attributes.area.bottom);
00305     erscribble_strokes_dump(&ptr->strokes);
00306     DUMPPRINTF("==================== Page %s Done =====================", ptr->id.id);
00307 }

Here is the call graph for this function:

Here is the caller graph for this function:

ScbStrokesPtr erscribble_page_erase_hit_test ( ScbPagePtr  page,
ScbDevPointPtr  point,
ScbPageEraseCtxPtr  ptr 
)

Definition at line 204 of file scbpage.c.

References _ScbPageEraseCtx::bInit, ctx, ERSCRIBBLE_DEF_ERASE_SIZE, erscribble_strokes_line_hit_test(), erscribble_strokes_point_hit_test(), _ScbPageEraseCtx::p1, _ScbPageEraseCtx::p2, _ScbHitTestCtx::size, _ScbPage::strokes, _ScbPageEraseCtx::zoom, and _ScbHitTestCtx::zoom.

Referenced by test::ScribbleMgr::on_erase_begin(), notepad::CNotepadDoc::on_erase_begin(), test::ScribbleMgr::on_erase_end(), notepad::CNotepadDoc::on_erase_end(), test::ScribbleMgr::on_erase_move(), and notepad::CNotepadDoc::on_erase_move().

00205 {
00206     ScbStrokesPtr strokes = NULL;
00207     ScbHitTestCtx ctx; 
00208     ctx.size = ERSCRIBBLE_DEF_ERASE_SIZE;
00209     ctx.zoom = eraCtx->zoom;
00210     if (!eraCtx->bInit)
00211     {
00212         eraCtx->p1 = *point;
00213         eraCtx->bInit = TRUE;
00214         strokes = erscribble_strokes_point_hit_test(&page->strokes, point, &ctx);
00215     }
00216     else
00217     {
00218         eraCtx->p2 = eraCtx->p1;
00219         eraCtx->p1 = *point;
00220         strokes = erscribble_strokes_line_hit_test(&page->strokes, 
00221             &eraCtx->p2, 
00222             &eraCtx->p1,
00223             &ctx);
00224     }
00225 
00226     return strokes;
00227 }

Here is the call graph for this function:

Here is the caller graph for this function:

void erscribble_page_erase_init ( ScbPageEraseCtxPtr  ptr  ) 

Definition at line 197 of file scbpage.c.

References _ScbPageEraseCtx::bInit, and _ScbPageEraseCtx::zoom.

Referenced by test::ScribbleMgr::on_erase_begin(), notepad::CNotepadDoc::on_erase_begin(), and test::ScribbleMgr::on_erase_move().

00198 {
00199     ptr->zoom = 1.0;
00200     ptr->bInit = FALSE;
00201 }

Here is the caller graph for this function:

void erscribble_page_free ( ScbPagePtr  ptr  ) 

Definition at line 145 of file scbpage.c.

References erscribble_page_clear_strokes(), and ERSCRIBBLE_RET_IF.

Referenced by _page_release(), erscribble_pages_remove_page(), and load_pages_basic_data().

00146 {
00147     ERSCRIBBLE_RET_IF(NULL == ptr, "Attempt to release NULL pointer!");
00148 
00149     erscribble_page_clear_strokes(ptr);
00150     g_free(ptr);
00151 }

Here is the call graph for this function:

Here is the caller graph for this function:

int erscribble_page_get_length ( ScbPagePtr  ptr  ) 

Definition at line 230 of file scbpage.c.

References _ScbStroke::attributes, _ScbPage::attributes, erscribble_page_get_stroke_count(), erscribble_stroke_get_point_count(), _ScbStrokes::strokes, _ScbPage::strokes, and _ScbPageAttributes::strokes_number.

Referenced by erscribble_doc_save_page().

00231 {
00232     // set the strokes number before exporting
00233     ptr->attributes.strokes_number = erscribble_page_get_stroke_count(ptr);
00234 
00235     int length = sizeof(ptr->attributes);
00236 
00237     ScbStrokePtr stroke  = NULL;
00238     GList* item = g_list_first(ptr->strokes.strokes);
00239     while(item)
00240     {
00241         stroke = (ScbStrokePtr)item->data;
00242         
00243         // set points number before exporting
00244         stroke->attributes.points_number = erscribble_stroke_get_point_count(stroke);
00245         
00246         // add by stroke attributes
00247         length += sizeof(stroke->attributes);
00248 
00249         // add by stroke points
00250         length += stroke->attributes.points_number * sizeof(ScbDevPoint);
00251 
00252         item = g_list_next(item);   
00253     }
00254 
00255     return length;
00256 }

Here is the call graph for this function:

Here is the caller graph for this function:

int erscribble_page_get_stroke_count ( ScbPagePtr  ptr  ) 

Definition at line 174 of file scbpage.c.

References ERSCRIBBLE_INVALID_COUNT, ERSCRIBBLE_RET_INT_IF, erscribble_strokes_get_count(), and _ScbPage::strokes.

Referenced by erscribble_page_get_length(), load_page_data(), and save_page_data().

00175 {
00176     ERSCRIBBLE_RET_INT_IF(NULL == ptr, ERSCRIBBLE_INVALID_COUNT, "Invalid page pointer!");
00177     return erscribble_strokes_get_count(&ptr->strokes);
00178 }

Here is the call graph for this function:

Here is the caller graph for this function:

ScbStrokesPtr erscribble_page_get_strokes ( ScbPagePtr  page  ) 

Definition at line 190 of file scbpage.c.

References ERSCRIBBLE_RET_NULL_IF, and _ScbPage::strokes.

Referenced by notepad::CNotepadDoc::draw_scribble_page().

00191 {
00192     ERSCRIBBLE_RET_NULL_IF(NULL == page, "Attempt to access NULL pointer!");
00193     return &page->strokes;
00194 }

Here is the caller graph for this function:

gboolean erscribble_page_load ( ScbPagePtr  page,
ScbStreamPtr  stream 
)

Definition at line 265 of file scbpage.c.

References _ScbPage::attributes, erscribble_read_stream(), ERSCRIBBLE_RET_FALSE_IF, erscribble_strokes_load(), _ScbPage::strokes, and _ScbPageAttributes::strokes_number.

Referenced by erscribble_doc_get_page(), and load_page_data().

00266 {
00267     // read the page attributes at the first
00268     ERSCRIBBLE_RET_FALSE_IF(page == NULL || stream == NULL, "Invalid page structure or stream");
00269 
00270     gboolean ret = erscribble_read_stream(stream, &page->attributes, sizeof(page->attributes));
00271 
00272     if (ret == FALSE)
00273     {
00274         return ret;
00275     }
00276 
00277     return erscribble_strokes_load(&page->strokes, stream, page->attributes.strokes_number);
00278 }

Here is the call graph for this function:

Here is the caller graph for this function:

ScbPagePtr erscribble_page_new (  ) 

Definition at line 107 of file scbpage.c.

References _ScbPageId::annotation_id, _ScbPageAttributes::area, _ScbPage::attributes, _ScbRect::bottom, ERRORPRINTF, ERSCRIBBLE_DEF_PAGE_BOTTOM, ERSCRIBBLE_DEF_PAGE_LEFT, ERSCRIBBLE_DEF_PAGE_RIGHT, ERSCRIBBLE_DEF_PAGE_TOP, erscribble_strokes_new(), _ScbPage::id, _ScbPage::is_blob_loaded, _ScbRect::left, _ScbPageId::position, _ScbRect::right, _ScbPage::strokes, and _ScbRect::top.

Referenced by notepad::CNotepadDoc::add_page(), erscribble_doc_get_page(), notepad::CNotepadDoc::insert_page(), load_pages_basic_data(), and notepad::CNotepadDoc::on_scribble_begin().

00108 {
00109     ScbPagePtr ptr = g_new0(ScbPage, 1);
00110     if (NULL == ptr)
00111     {
00112         // not enough memory, fatal error
00113         ERRORPRINTF("Not enough memory for page!");
00114         return NULL;
00115     }
00116 
00117     // init values
00118     if (!erscribble_strokes_new(&ptr->strokes))
00119     {
00120         g_free(ptr);
00121         return NULL;
00122     }
00123 
00124     ptr->attributes.area.left      = ERSCRIBBLE_DEF_PAGE_LEFT;
00125     ptr->attributes.area.right     = ERSCRIBBLE_DEF_PAGE_RIGHT;
00126     ptr->attributes.area.top       = ERSCRIBBLE_DEF_PAGE_TOP;
00127     ptr->attributes.area.bottom    = ERSCRIBBLE_DEF_PAGE_BOTTOM;
00128 
00129     // initialize the position and annotation id to be -1
00130     ptr->id.position      = -1;
00131     ptr->id.annotation_id = -1;
00132 
00133     // set the flag is_blob_loaded to be false
00134     ptr->is_blob_loaded = FALSE;
00135 
00136     return ptr;
00137 }

Here is the call graph for this function:

Here is the caller graph for this function:

void erscribble_page_reset_id ( ScbPageIdPtr  ptr  ) 

Definition at line 96 of file scbpage.c.

References _ScbPageId::annotation_id, ERSCRIBBLE_MAX_PAGEID_LEN, _ScbPageId::id, and _ScbPageId::position.

Referenced by test::ScribbleMgr::clear_page_id().

00097 {
00098     if (ptr)
00099     {
00100         memset(ptr->id, 0, ERSCRIBBLE_MAX_PAGEID_LEN);
00101         ptr->position = -1;
00102         ptr->annotation_id = -1;
00103     }
00104 }

Here is the caller graph for this function:

void erscribble_page_set_id ( ScbPageIdPtr  ptr,
const int  position,
const char *  anchor,
const int  anno_id 
)

Definition at line 72 of file scbpage.c.

References _ScbPageId::annotation_id, ERSCRIBBLE_MAX_PAGEID_LEN, _ScbPageId::id, and _ScbPageId::position.

Referenced by test::ScribbleMgr::generate_page_id(), and load_pages_basic_data().

00073 {
00074     if (ptr)
00075     {
00076         strncpy(ptr->id, anchor, ERSCRIBBLE_MAX_PAGEID_LEN);
00077         ptr->position = position;
00078         // the annotation id should be set to invalid
00079         // and then it would be set by query database
00080         ptr->annotation_id = anno_id;
00081     }
00082 }

Here is the caller graph for this function:

void erscribble_page_set_minor_version_number ( ScbPagePtr  page,
const unsigned short  minor 
)

Definition at line 259 of file scbpage.c.

References _ScbPage::attributes, and _ScbPageAttributes::minor_version.

Referenced by erscribble_doc_save_page().

00260 {
00261     page->attributes.minor_version = minor;
00262 }

Here is the caller graph for this function:

void erscribble_page_set_size ( ScbPagePtr  ptr,
const int  width,
const int  height 
)

Definition at line 139 of file scbpage.c.

References _ScbPageAttributes::area, _ScbPage::attributes, _ScbRect::bottom, _ScbRect::left, _ScbRect::right, and _ScbRect::top.

00140 {
00141     ptr->attributes.area.right = ptr->attributes.area.left + width;
00142     ptr->attributes.area.bottom = ptr->attributes.area.top + height;
00143 }

gboolean erscribble_page_write_stream ( ScbPagePtr  page,
ScbStreamPtr  stream 
)

Definition at line 281 of file scbpage.c.

References _ScbPage::attributes, erscribble_strokes_write_stream(), erscribble_write_stream(), and _ScbPage::strokes.

Referenced by erscribble_doc_save_page().

00282 {
00283     // write the page attributes into stream
00284     if (erscribble_write_stream(stream, &page->attributes, sizeof(page->attributes)))
00285     {
00286         // write the stokes data into stream
00287         if (erscribble_strokes_write_stream(&page->strokes, stream))
00288         {
00289             return TRUE;
00290         }
00291     }
00292 
00293     return FALSE;
00294 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208