liberscribble/include/scbpage.h File Reference

#include "scbconfig.h"
#include "scbstrokes.h"

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ScbPageId
struct  _ScbPageStyle
struct  _ScbPageOptHist
struct  _ScbPageEraseCtx
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 _ScbPage ScbPage
typedef ScbPageScbPagePtr

Functions

void scb_page_id_from_int (ScbPageIdPtr ptr, const int number)
void scb_page_id_from_str (ScbPageIdPtr ptr, const char *str)
ScbPagePtr scb_page_new ()
void scb_page_free (ScbPagePtr ptr)
void scb_page_clear (ScbPagePtr ptr)
void scb_page_set_id (ScbPagePtr page, ScbPageIdPtr id)
int scb_page_get_stroke_count (ScbPagePtr ptr)
gboolean scb_page_add_stroke (ScbPagePtr page, ScbStrokePtr stroke)
ScbStrokesPtr scb_page_get_strokes (ScbPagePtr page)
void scb_page_erase_fast_draw (ScbPagePtr ptr, ScbDevPointPtr point)
void scb_page_erase_fast_draw_done (ScbPagePtr ptr, ScbDevPointPtr point)
void scb_page_erase_init (ScbPageEraseCtxPtr ptr)
ScbStrokesPtr scb_page_erase_hit_test (ScbPagePtr page, ScbDevPointPtr point, ScbPageEraseCtxPtr ptr)
gboolean scb_page_save (ScbPagePtr page, ScbXmlPtr ptr)
gboolean scb_page_load (ScbPagePtr page, ScbXmlPtr ptr)
void scb_page_dump (ScbPagePtr ptr)


Typedef Documentation

typedef struct _ScbPage ScbPage

Definition at line 66 of file scbpage.h.

typedef struct _ScbPageId ScbPageId

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

Definition at line 44 of file scbpage.h.

typedef ScbPage* ScbPagePtr

Definition at line 83 of file scbpage.h.

typedef struct _ScbPageStyle ScbPageStyle


Function Documentation

gboolean scb_page_add_stroke ( ScbPagePtr  page,
ScbStrokePtr  stroke 
)

Definition at line 125 of file scbpage.c.

00126 {
00127     SCB_RET_FALSE_IF(NULL == page || NULL == stroke, "Invalid pointer!");        
00128     g_list_append(page->strokes.strokes, stroke);
00129     return TRUE;
00130 }

void scb_page_clear ( ScbPagePtr  ptr  ) 

Definition at line 110 of file scbpage.c.

00111 {
00112     SCB_RET_IF(NULL == ptr, "Attempt to take action on NULL pointer!");
00113     scb_strokes_empty(&ptr->strokes);
00114     scb_strokes_empty(&ptr->delStrokes);
00115 }

Here is the call graph for this function:

void scb_page_dump ( ScbPagePtr  ptr  ) 

Definition at line 388 of file scbpage.c.

00389 {
00390     SCB_RET_IF(NULL == ptr, "Attempt to dump on NULL page pointer!");
00391 
00392     SCB_DUMP("================= Page %s Information =================", ptr->id.id);
00393     SCB_DUMP("orientation %d", ptr->style.orientation);
00394     SCB_DUMP("rect (%d, %d) - (%d, %d)", ptr->rect.left, ptr->rect.top, 
00395         ptr->rect.right, ptr->rect.bottom);
00396     scb_strokes_dump(&ptr->strokes);
00397     SCB_DUMP("==================== Page %s Done =====================", ptr->id.id);
00398 }

Here is the call graph for this function:

void scb_page_erase_fast_draw ( ScbPagePtr  ptr,
ScbDevPointPtr  point 
)

Definition at line 139 of file scbpage.c.

00140 {
00141     ScbHitTestCtx ctx; ctx.size = SCB_DEF_ERASE_SIZE;
00142     ScbStrokesPtr strokes = NULL;
00143     if (!bEraseCtxInit)
00144     {
00145         _erase_ctx.count = 0;
00146         bEraseCtxInit = TRUE;
00147     }
00148     
00149     if (0 == _erase_ctx.count)
00150     {
00151         _erase_ctx.p1 = *point;
00152         _erase_ctx.count = 1;
00153         strokes = scb_strokes_point_hit_test(&page->strokes, point, &ctx);
00154     }
00155     else
00156     {
00157         if (_erase_ctx.count > 1)
00158         {
00159             _erase_ctx.p1 = _erase_ctx.p2;
00160         }
00161         _erase_ctx.p2 = *point;    
00162         strokes = scb_strokes_line_hit_test(&page->strokes, 
00163             &_erase_ctx.p1, 
00164             &_erase_ctx.p2,
00165             &ctx);
00166     }
00167 
00168     // result
00169     if (strokes)
00170     {
00171         scb_strokes_erase_fast_draw(strokes);
00172         scb_strokes_add_strokes(&page->delStrokes, (const ScbStrokesPtr)&strokes);
00173         scb_strokes_detach(strokes);
00174     }
00175 }

Here is the call graph for this function:

void scb_page_erase_fast_draw_done ( ScbPagePtr  ptr,
ScbDevPointPtr  point 
)

Definition at line 178 of file scbpage.c.

00179 {
00180     ScbStrokesPtr strokes = NULL;
00181     ScbHitTestCtx ctx; ctx.size = SCB_DEF_ERASE_SIZE;
00182     if (0 == _erase_ctx.count)
00183     {
00184         _erase_ctx.p1 = *point;
00185         _erase_ctx.count = 1;
00186         strokes = scb_strokes_point_hit_test(&page->strokes, point, &ctx);
00187     }
00188     else
00189     {
00190         if (_erase_ctx.count > 1)
00191         {
00192             _erase_ctx.p1 = _erase_ctx.p2;
00193         }
00194         _erase_ctx.p2 = *point;    
00195         strokes = scb_strokes_line_hit_test(&page->strokes, 
00196             &_erase_ctx.p1, 
00197             &_erase_ctx.p2,
00198             &ctx);
00199     }
00200 
00201     // strokes to erase
00202     if (strokes)
00203     {
00204         scb_strokes_erase_fast_draw(strokes);
00205         scb_strokes_add_strokes(&page->delStrokes, (const ScbStrokesPtr)&strokes);
00206         scb_strokes_detach(strokes);
00207     }
00208 
00209     // reset
00210     _erase_ctx.count = 0;
00211 }

Here is the call graph for this function:

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

Definition at line 219 of file scbpage.c.

00220 {
00221     ScbStrokesPtr strokes = NULL;
00222     ScbHitTestCtx ctx; 
00223     ctx.size = SCB_DEF_ERASE_SIZE;
00224     ctx.zoom = eraCtx->zoom;
00225     if (!eraCtx->bInit)
00226     {
00227         eraCtx->p1 = *point;
00228         eraCtx->bInit = TRUE;
00229         strokes = scb_strokes_point_hit_test(&page->strokes, point, &ctx);
00230     }
00231     else
00232     {
00233         eraCtx->p2 = eraCtx->p1;
00234         eraCtx->p1 = *point;
00235         strokes = scb_strokes_line_hit_test(&page->strokes, 
00236             &eraCtx->p2, 
00237             &eraCtx->p1,
00238             &ctx);
00239     }
00240 
00241     return strokes;
00242 }

Here is the call graph for this function:

void scb_page_erase_init ( ScbPageEraseCtxPtr  ptr  ) 

Definition at line 213 of file scbpage.c.

00214 {
00215     ptr->zoom = 1.0;
00216     ptr->bInit = FALSE;
00217 }

void scb_page_free ( ScbPagePtr  ptr  ) 

Definition at line 90 of file scbpage.c.

00091 {
00092     SCB_RET_IF(NULL == ptr, "Attempt to release NULL pointer!");
00093         
00094     scb_strokes_free(&ptr->strokes);
00095     scb_strokes_free(&ptr->delStrokes);
00096     g_free(ptr);
00097 }

Here is the call graph for this function:

int scb_page_get_stroke_count ( ScbPagePtr  ptr  ) 

Definition at line 118 of file scbpage.c.

00119 {
00120     SCB_RET_INT_IF(NULL == ptr, SCB_INVALID_COUNT, "Invalid page pointer!");
00121     return scb_strokes_get_count(&ptr->strokes);
00122 }

Here is the call graph for this function:

ScbStrokesPtr scb_page_get_strokes ( ScbPagePtr  page  ) 

Definition at line 133 of file scbpage.c.

00134 {
00135     SCB_RET_NULL_IF(NULL == page, "Attempt to access NULL pointer!");
00136     return &page->strokes;
00137 }

void scb_page_id_from_int ( ScbPageIdPtr  ptr,
const int  number 
)

Definition at line 36 of file scbpage.c.

00037 {
00038     if (ptr)
00039     {
00040         snprintf(ptr->id, SCB_MAX_PAGEID_LEN, "%d", number);
00041     }
00042 }

void scb_page_id_from_str ( ScbPageIdPtr  ptr,
const char *  str 
)

Definition at line 44 of file scbpage.c.

00045 {
00046     if (ptr && str)
00047     {
00048         strncpy(ptr->id, str, SCB_MAX_PAGEID_LEN);
00049     }
00050 }

gboolean scb_page_load ( ScbPagePtr  page,
ScbXmlPtr  ptr 
)

Definition at line 275 of file scbpage.c.

00276 {
00277     // check
00278     SCB_RET_FALSE_IF(NULL == page || NULL == ptr, "Invalid page or xml pointer!");
00279 
00280     // load attributes
00281     ScbXmlPtr self = scb_xml_clone(ptr);
00282     char * tmp = self->xPath + strnlen(self->xPath, SCB_MAX_XML_PATH);
00283     snprintf(tmp, SCB_MAX_XML_PATH, "/page[%d]", self->index);
00284     char xPath[SCB_MAX_XML_PATH] = {0};
00285     strncpy(xPath, self->xPath, SCB_MAX_XML_PATH);
00286     int len = strnlen(xPath, SCB_MAX_XML_PATH);
00287     
00288     if (RET_ERR == ermXmlExist(&ptr->handle, xPath))
00289     {
00290         // nothing more
00291         return FALSE;
00292     }
00293         
00294     // background color
00295     char color[SCB_MAX_COLOR_LEN] = {0};
00296     ermXmlGetAttributeString(&self->handle, self->xPath, 
00297         "backgroundcolor", color, SCB_MAX_COLOR_LEN);
00298     scb_html_color_to_color(color, SCB_MAX_COLOR_LEN, &page->style.bgColor);
00299 
00300     // id
00301     ermXmlGetAttributeString(&ptr->handle, self->xPath,
00302         "id", page->id.id, SCB_MAX_PAGEID_LEN);
00303 
00304     // orientation
00305     strncat(xPath, "orientation", SCB_MAX_XML_PATH);
00306     ermXmlGetInt(&ptr->handle, xPath, &page->style.orientation);
00307     
00308     // height
00309     page->rect.left = page->rect.top = 0;
00310     int value = 0;
00311     xPath[len] = 0;
00312     strncat(xPath, "/height", SCB_MAX_XML_PATH);
00313     ermXmlGetInt(&ptr->handle, xPath, &value);
00314     page->rect.bottom = value;
00315 
00316     // width
00317     xPath[len] = 0;
00318     strncat(xPath, "/width", SCB_MAX_XML_PATH);
00319     ermXmlGetInt(&ptr->handle, xPath, &value);
00320     page->rect.right = value;
00321 
00322     // load strokes
00323     gboolean bRet = scb_strokes_load(&page->strokes, self);
00324     scb_xml_free(self);
00325     return bRet;
00326 }

Here is the call graph for this function:

ScbPagePtr scb_page_new (  ) 

Definition at line 64 of file scbpage.c.

00065 {
00066     ScbPagePtr ptr = g_new0(ScbPage, 1);    
00067     if (NULL == ptr)
00068     {
00069         // not enough memory, fatal error
00070         SCB_ERROR("Not enough memory for page!");
00071         return NULL;
00072     }    
00073 
00074     // init values
00075     if (!scb_strokes_new(&ptr->strokes))
00076     {
00077         g_free(ptr);
00078         return NULL;
00079     }
00080     
00081     ptr->rect.left      = SCB_DEF_PAGE_LEFT;
00082     ptr->rect.right     = SCB_DEF_PAGE_RIGHT;
00083     ptr->rect.top       = SCB_DEF_PAGE_TOP;
00084     ptr->rect.bottom    = SCB_DEF_PAGE_BOTTOM;
00085    
00086     return ptr;
00087 }

Here is the call graph for this function:

gboolean scb_page_save ( ScbPagePtr  page,
ScbXmlPtr  ptr 
)

Definition at line 245 of file scbpage.c.

00246 {
00247     // check
00248     SCB_RET_FALSE_IF(NULL == page || NULL == ptr, "Invalid page or xml pointer!");
00249             
00250     // construct xPath
00251     ScbXmlPtr self = scb_xml_clone(ptr);
00252     ermXmlNewString(&ptr->handle, self->xPath, "page", "");
00253     char * tmp = self->xPath + strnlen(self->xPath, SCB_MAX_XML_PATH);
00254     snprintf(tmp, SCB_MAX_XML_PATH,  "/page[%d]", ptr->index);
00255 
00256     // save attributes
00257     ermXmlSetAttributeString(&ptr->handle, self->xPath, "backgroundcolor",
00258         scb_color_to_html_color(&page->style.bgColor), SCB_MAX_COLOR_LEN);
00259     ermXmlSetAttributeString(&ptr->handle, self->xPath, 
00260             "id", page->id.id, SCB_MAX_PAGEID_LEN);
00261     ermXmlNewInt(&ptr->handle, self->xPath, 
00262             "orientation", page->style.orientation);
00263     ermXmlNewInt(&ptr->handle, self->xPath, 
00264             "height", page->rect.bottom - page->rect.top);
00265     ermXmlNewInt(&ptr->handle, self->xPath, 
00266             "width", page->rect.right - page->rect.left);
00267 
00268     // save strokes
00269     gboolean bRet = scb_strokes_save(&page->strokes, self);
00270     scb_xml_free(self);
00271     return bRet;
00272 }

Here is the call graph for this function:

void scb_page_set_id ( ScbPagePtr  page,
ScbPageIdPtr  id 
)

Definition at line 100 of file scbpage.c.

00101 {
00102     if (page && id)
00103     {
00104         strncpy(page->id.id, id->id, SCB_MAX_PAGEID_LEN);
00105     }
00106 }


Generated on Sun Dec 14 17:15:02 2008 by  doxygen 1.5.6