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

Go to the source code of this file.
| typedef struct _ScbPageEraseCtx ScbPageEraseCtx |
| typedef ScbPageEraseCtx* ScbPageEraseCtxPtr |
| typedef struct _ScbPageId ScbPageId |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
| typedef ScbPageId* ScbPageIdPtr |
| typedef struct _ScbPageOptHist ScbPageOptHist |
| typedef ScbPage* ScbPagePtr |
| typedef struct _ScbPageStyle ScbPageStyle |
| 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 }

| 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 }

| 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 }

| 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 }

| 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 }

| void scb_page_erase_init | ( | ScbPageEraseCtxPtr | ptr | ) |
| 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 }

| 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 }

| 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 }

| 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 }

| 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 }

| void scb_page_set_id | ( | ScbPagePtr | page, | |
| ScbPageIdPtr | id | |||
| ) |
1.5.6