#include "scbstroke.h"
Go to the source code of this file.
typedef struct _ScbStrokes ScbStrokes |
Copyright (C) 2008 iRex Technologies B.V. All rights reserved.
typedef ScbStrokes* ScbStrokesPtr |
Definition at line 69 of file scbstrokes.h.
void erscribble_strokes_add_stroke | ( | ScbStrokesPtr | strokes, | |
ScbStrokePtr | stroke | |||
) |
Definition at line 113 of file scbstrokes.c.
References ERSCRIBBLE_RET_IF, and _ScbStrokes::strokes.
Referenced by erscribble_strokes_line_hit_test(), erscribble_strokes_load(), and erscribble_strokes_point_hit_test().
00115 { 00116 ERSCRIBBLE_RET_IF(NULL == strokes || NULL == stroke, "Invalid storkes or stroke pointer!"); 00117 strokes->strokes = g_list_append(strokes->strokes, stroke); 00118 }
void erscribble_strokes_add_strokes | ( | ScbStrokesPtr | dst, | |
const ScbStrokesPtr | src | |||
) |
Definition at line 121 of file scbstrokes.c.
References ERSCRIBBLE_RET_IF, and _ScbStrokes::strokes.
00123 { 00124 ERSCRIBBLE_RET_IF(NULL == dst || NULL == src, "Invalid pointer(s)!"); 00125 dst->strokes = g_list_concat(dst->strokes, src->strokes); 00126 }
void erscribble_strokes_clear | ( | ScbStrokesPtr | strokes | ) |
Definition at line 95 of file scbstrokes.c.
References ERSCRIBBLE_RET_IF, and _ScbStrokes::strokes.
Referenced by erscribble_page_clear(), and erscribble_strokes_load().
00096 { 00097 ERSCRIBBLE_RET_IF(NULL == strokes, "Attempt to release NULL pointer!"); 00098 00099 g_list_free(strokes->strokes); 00100 strokes->strokes = NULL; 00101 }
ScbStrokePtr erscribble_strokes_detach_stroke | ( | ScbStrokesPtr | strokes, | |
ScbStrokePtr | stroke | |||
) |
Definition at line 129 of file scbstrokes.c.
References ERSCRIBBLE_RET_NULL_IF, and _ScbStrokes::strokes.
Referenced by erscribble_strokes_line_hit_test(), and erscribble_strokes_point_hit_test().
00131 { 00132 ERSCRIBBLE_RET_NULL_IF(NULL == strokes || NULL == stroke, "Invalid pointer!"); 00133 strokes->strokes = g_list_remove(strokes->strokes, stroke); 00134 return stroke; 00135 }
void erscribble_strokes_dump | ( | ScbStrokesPtr | strokes | ) |
Definition at line 279 of file scbstrokes.c.
References _stroke_dump(), and _ScbStrokes::strokes.
Referenced by erscribble_page_dump().
00280 { 00281 if (strokes) 00282 { 00283 g_list_foreach(strokes->strokes, _stroke_dump, 0); 00284 } 00285 }
void erscribble_strokes_erase_driver_draw | ( | ScbStrokesPtr | strokes | ) |
Definition at line 205 of file scbstrokes.c.
References _ScbStroke::attributes, ERSCRIBBLE_DEV_COLOR_WHITE, erscribble_stroke_driver_draw(), and _ScbStrokes::strokes.
00206 { 00207 if (NULL == strokes) 00208 { 00209 return; 00210 } 00211 00212 GList *ptr = g_list_first(strokes->strokes); 00213 ScbStrokePtr stroke = NULL; 00214 while (ptr) 00215 { 00216 stroke = (ScbStrokePtr)ptr->data; 00217 if (stroke) 00218 { 00219 ScbDevColor old = stroke->attributes.color; 00220 // use reverse color 00221 // TODO. The WHITE color is not always correct. 00222 // We should the draw the erased part by background color in the future. 00223 stroke->attributes.color = ERSCRIBBLE_DEV_COLOR_WHITE; 00224 erscribble_stroke_driver_draw(stroke); 00225 stroke->attributes.color = old; 00226 } 00227 ptr = g_list_next(ptr); 00228 } 00229 }
void erscribble_strokes_free | ( | ScbStrokesPtr | strokes | ) |
Definition at line 82 of file scbstrokes.c.
References _stroke_release(), ERSCRIBBLE_RET_IF, and _ScbStrokes::strokes.
Referenced by erscribble_page_clear_strokes(), 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().
00083 { 00084 ERSCRIBBLE_RET_IF(NULL == strokes, "Attempt to release NULL pointer!"); 00085 00086 // release all stroke 00087 g_list_foreach(strokes->strokes, _stroke_release, NULL); 00088 00089 // now the pointers are wild pointers 00090 g_list_free(strokes->strokes); 00091 strokes->strokes = NULL; 00092 }
int erscribble_strokes_get_count | ( | const ScbStrokesPtr | strokes | ) |
Definition at line 104 of file scbstrokes.c.
References ERSCRIBBLE_INVALID_COUNT, ERSCRIBBLE_RET_INT_IF, and _ScbStrokes::strokes.
Referenced by erscribble_page_get_stroke_count(), and remove_oldest_page_data().
00105 { 00106 ERSCRIBBLE_RET_INT_IF(NULL == strokes, ERSCRIBBLE_INVALID_COUNT, "Invalid strokes pointer!"); 00107 00108 // here, the list contains a empty item, so we need to decrease one 00109 return g_list_length(strokes->strokes); 00110 }
ScbStrokesPtr erscribble_strokes_line_hit_test | ( | ScbStrokesPtr | strokes, | |
ScbDevPointPtr | point1, | |||
ScbDevPointPtr | point2, | |||
const ScbHitTestCtxPtr | ctx | |||
) |
Definition at line 171 of file scbstrokes.c.
References ERSCRIBBLE_RET_NULL_IF, erscribble_stroke_line_hit_test(), erscribble_strokes_add_stroke(), erscribble_strokes_detach_stroke(), erscribble_strokes_new(), LOGPRINTF, and _ScbStrokes::strokes.
Referenced by erscribble_page_erase_hit_test().
00175 { 00176 ERSCRIBBLE_RET_NULL_IF(NULL == strokes, "Invalid strokes list pointer!"); 00177 00178 ScbStrokesPtr result = NULL; 00179 ScbStrokePtr stroke = NULL; 00180 GList* ptr = g_list_first(strokes->strokes); 00181 while(ptr) 00182 { 00183 stroke = (ScbStrokePtr)ptr->data; 00184 if (stroke && erscribble_stroke_line_hit_test(stroke, point1, point2, ctx)) 00185 { 00186 LOGPRINTF("line hit"); 00187 if (NULL == result) 00188 { 00189 result = g_new0(ScbStrokes, 1); 00190 if (!erscribble_strokes_new(result)) 00191 { 00192 return NULL; 00193 } 00194 } 00195 // move from one list to the other 00196 erscribble_strokes_add_stroke(result, stroke); 00197 erscribble_strokes_detach_stroke(strokes, stroke); 00198 } 00199 ptr = g_list_next(ptr); 00200 } 00201 return result; 00202 }
gboolean erscribble_strokes_load | ( | ScbStrokesPtr | strokes, | |
ScbStreamPtr | stream, | |||
const int | strokes_num | |||
) |
Definition at line 232 of file scbstrokes.c.
References ERSCRIBBLE_RET_FALSE_IF, erscribble_stroke_free(), erscribble_stroke_load(), erscribble_stroke_new(), erscribble_strokes_add_stroke(), and erscribble_strokes_clear().
Referenced by erscribble_page_load().
00233 { 00234 ERSCRIBBLE_RET_FALSE_IF(NULL == strokes || NULL == stream, "Invalid strokes or stream!"); 00235 00236 erscribble_strokes_clear(strokes); 00237 00238 int i = 0; 00239 for (; i < strokes_num; ++i) 00240 { 00241 ScbStrokePtr stroke = erscribble_stroke_new(); 00242 if (erscribble_stroke_load(stroke, stream)) 00243 { 00244 erscribble_strokes_add_stroke(strokes, stroke); 00245 } 00246 else 00247 { 00248 erscribble_stroke_free(stroke); 00249 return FALSE; 00250 } 00251 } 00252 00253 return TRUE; 00254 }
gboolean erscribble_strokes_new | ( | ScbStrokesPtr | ptr | ) |
Definition at line 74 of file scbstrokes.c.
References ERSCRIBBLE_RET_FALSE_IF, and _ScbStrokes::strokes.
Referenced by erscribble_page_new(), erscribble_strokes_line_hit_test(), and erscribble_strokes_point_hit_test().
00075 { 00076 ERSCRIBBLE_RET_FALSE_IF(NULL == ptr, "Invalid pointer!"); 00077 ptr->strokes = 0; 00078 return TRUE; 00079 }
ScbStrokesPtr erscribble_strokes_point_hit_test | ( | ScbStrokesPtr | strokes, | |
ScbDevPointPtr | point, | |||
const ScbHitTestCtxPtr | ctx | |||
) |
Definition at line 138 of file scbstrokes.c.
References ERSCRIBBLE_RET_NULL_IF, erscribble_stroke_point_hit_test(), erscribble_strokes_add_stroke(), erscribble_strokes_detach_stroke(), erscribble_strokes_new(), LOGPRINTF, and _ScbStrokes::strokes.
Referenced by erscribble_page_erase_hit_test().
00141 { 00142 ERSCRIBBLE_RET_NULL_IF(NULL == strokes, "Invalid strokes list pointer!"); 00143 00144 ScbStrokesPtr result = NULL; 00145 ScbStrokePtr stroke = NULL; 00146 GList* ptr = g_list_first(strokes->strokes); 00147 while(ptr) 00148 { 00149 stroke = (ScbStrokePtr)ptr->data; 00150 if (stroke && erscribble_stroke_point_hit_test(stroke, point, ctx)) 00151 { 00152 LOGPRINTF("point hit"); 00153 if (NULL == result) 00154 { 00155 result = g_new0(ScbStrokes, 1); 00156 if (! erscribble_strokes_new(result)) 00157 { 00158 return NULL; 00159 } 00160 } 00161 // move from one stroke list to the other 00162 erscribble_strokes_add_stroke(result, stroke); 00163 erscribble_strokes_detach_stroke(strokes, stroke); 00164 } 00165 ptr = g_list_next(ptr); 00166 } 00167 return result; 00168 }
gboolean erscribble_strokes_write_stream | ( | ScbStrokesPtr | strokes, | |
ScbStreamPtr | stream | |||
) |
Definition at line 257 of file scbstrokes.c.
References ERSCRIBBLE_RET_FALSE_IF, erscribble_stroke_write_stream(), and _ScbStrokes::strokes.
Referenced by erscribble_page_write_stream().
00258 { 00259 ERSCRIBBLE_RET_FALSE_IF(NULL == strokes || NULL == stream, "Invalid strokes or stream!"); 00260 00261 ScbStrokePtr stroke = NULL; 00262 GList* item = g_list_first(strokes->strokes); 00263 while(item) 00264 { 00265 stroke = (ScbStrokePtr)item->data; 00266 00267 if (erscribble_stroke_write_stream(stroke, stream) == FALSE) 00268 { 00269 return FALSE; 00270 } 00271 00272 item = g_list_next(item); 00273 } 00274 00275 return TRUE; 00276 }