00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00023 #ifndef SCBMACRO_H_
00024 #define SCBMACRO_H_
00025
00027
00028
00029
00030
00031
00033
00034
00035 #ifdef __cplusplus
00036 extern "C"
00037 {
00038 #endif
00039
00041
00042
00043 #define SCB_GTK_DRAW_PAGE(doc, pageId, drawable, gc)\
00044 {\
00045 if (doc)\
00046 {\
00047 ScbPagePtr SCB_page = scb_doc_get_page(doc, pageId);\
00048 if (SCB_page)\
00049 {\
00050 ScbStrokesPtr SCB_strokes = scb_page_get_strokes(SCB_page);\
00051 if (SCB_strokes)\
00052 {\
00053 ScbStrokePtr SCB_stroke = NULL;\
00054 GdkColor GDK_color;\
00055 ScbColor SCB_color;\
00056 GdkLineStyle GDK_lineStyle = GDK_LINE_SOLID; \
00057 GList *SCB_ptr = g_list_first(SCB_strokes->strokes);\
00058 while (SCB_ptr)\
00059 {\
00060 SCB_stroke = (ScbStrokePtr)SCB_ptr->data;\
00061 if (SCB_stroke)\
00062 {\
00063 scb_dev_color_to_color(&SCB_color, SCB_stroke->style.color);\
00064 GDK_color.pixel = SCB_color.pixel;\
00065 GDK_color.red = SCB_color.red;\
00066 GDK_color.green = SCB_color.green;\
00067 GDK_color.blue = SCB_color.blue;\
00068 gdk_gc_set_rgb_fg_color(gc, &GDK_color);\
00069 gdk_gc_set_line_attributes (gc, \
00070 SCB_stroke->style.penSize, \
00071 GDK_lineStyle, \
00072 GDK_CAP_PROJECTING, \
00073 GDK_JOIN_MITER);\
00074 gdk_draw_lines(drawable, \
00075 gc, \
00076 (GdkPoint *)scb_stroke_get_point_data(SCB_stroke), \
00077 scb_stroke_get_point_count(SCB_stroke));\
00078 }\
00079 SCB_ptr = g_list_next(SCB_ptr);\
00080 }\
00081 }\
00082 }\
00083 }\
00084 }
00085
00086
00088
00090
00091
00092
00093
00094 #define SCB_TOOLBAR_INIT(doc, channel, id)\
00095 {\
00096 doc->context.appId = id;\
00097 SCB_TOOLBAR_UPDATE(doc, channel);\
00098 }
00099
00100 #define SCB_TOOLBAR_MAP(doc, s, i)\
00101 {\
00102 ScbTBSItem item;\
00103 item.state = s;\
00104 item.iconId = i;\
00105 scb_doc_add_map_item(doc, &item);\
00106 }
00107
00108 #define SCB_TOOLBAR_UPDATE(doc, channel)\
00109 {\
00110 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pen);\
00111 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pen1pixel);\
00112 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pen3pixel);\
00113 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pen5pixel);\
00114 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pen7pixel);\
00115 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pencolorbl);\
00116 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pencolordg);\
00117 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pencolorlg);\
00118 tbRemovePlatformIcon(channel, doc->context.appId, iconID_pencolorwh);\
00119 tbRemovePlatformIcon(channel, doc->context.appId, iconID_eraseline);\
00120 int __tbi;\
00121 ScbTBSItemPtr __tbitem = (ScbTBSItemPtr)doc->context.table->data;\
00122 for(__tbi = 0; __tbi < doc->context.table->len; ++__tbi)\
00123 {\
00124 if (SCB_TBS_SCRIBBLE == __tbitem->state)\
00125 {\
00126 tbAppendPlatformIcon(channel, doc->context.appId, __tbitem->iconId, ccVwrToolbar);\
00127 }\
00128 ++__tbitem;\
00129 }\
00130 if (SCB_TBS_SCRIBBLE == doc->context.curState)\
00131 {\
00132 tbSetStatePlatformIcon(channel, doc->context.appId, iconID_pen, iconState_selected);\
00133 }\
00134 int __tbIconIndex = (int)iconID_pen1pixel + doc->context.curStrokeStyle.penSize/2;\
00135 __tbitem = (ScbTBSItemPtr)doc->context.table->data;\
00136 if (SCB_TBS_SELECT_PEN_SIZE == doc->context.curState)\
00137 {\
00138 for(__tbi = 0; __tbi < doc->context.table->len; ++__tbi)\
00139 {\
00140 if (SCB_TBS_SELECT_PEN_SIZE == __tbitem->state)\
00141 {\
00142 tbAppendPlatformIcon(channel, doc->context.appId, __tbitem->iconId, ccVwrToolbar);\
00143 }\
00144 ++__tbitem;\
00145 }\
00146 tbSetStatePlatformIcon(channel, doc->context.appId, __tbIconIndex, iconState_selected);\
00147 }\
00148 else\
00149 {\
00150 for(__tbi = 0; __tbi < doc->context.table->len; ++__tbi)\
00151 {\
00152 if (__tbIconIndex == __tbitem->iconId)\
00153 {\
00154 tbAppendPlatformIcon(channel, doc->context.appId, __tbitem->iconId, ccVwrToolbar);\
00155 break;\
00156 }\
00157 ++__tbitem;\
00158 }\
00159 }\
00160 __tbIconIndex = (int)iconID_pencolorbl + (int)SCB_DEV_COLOR_BLACK - (int)doc->context.curStrokeStyle.color;\
00161 __tbitem = (ScbTBSItemPtr)doc->context.table->data;\
00162 if (SCB_TBS_SELECT_LINE_COLOR == doc->context.curState)\
00163 {\
00164 for(__tbi = 0; __tbi < doc->context.table->len; ++__tbi)\
00165 {\
00166 if (SCB_TBS_SELECT_LINE_COLOR == __tbitem->state)\
00167 {\
00168 tbAppendPlatformIcon(channel, doc->context.appId, __tbitem->iconId, ccVwrToolbar);\
00169 }\
00170 ++__tbitem;\
00171 }\
00172 tbSetStatePlatformIcon(channel, doc->context.appId, __tbIconIndex, iconState_selected);\
00173 }\
00174 else\
00175 {\
00176 for(__tbi = 0; __tbi < doc->context.table->len; ++__tbi)\
00177 {\
00178 if (__tbIconIndex == __tbitem->iconId)\
00179 {\
00180 tbAppendPlatformIcon(channel, doc->context.appId, __tbitem->iconId, ccVwrToolbar);\
00181 break;\
00182 }\
00183 ++__tbitem;\
00184 }\
00185 }\
00186 __tbitem = (ScbTBSItemPtr)doc->context.table->data;\
00187 for(__tbi = 0; __tbi < doc->context.table->len; ++__tbi)\
00188 {\
00189 if (SCB_TBS_ERASE == __tbitem->state)\
00190 {\
00191 tbAppendPlatformIcon(channel, doc->context.appId, __tbitem->iconId, ccVwrToolbar);\
00192 }\
00193 ++__tbitem;\
00194 }\
00195 if (SCB_TBS_ERASE == doc->context.curState)\
00196 {\
00197 tbSetStatePlatformIcon(channel, doc->context.appId, iconID_eraseline, iconState_selected);\
00198 }\
00199 }
00200
00202
00203
00204
00205
00207 #define SCB_ACTION_SCRIBBLE(doc, channel, iconId)\
00208 {\
00209 if (SCB_TBS_SCRIBBLE == doc->context.curState)\
00210 {\
00211 doc->context.curState = SCB_TBS_NONE;\
00212 }\
00213 else\
00214 {\
00215 doc->context.curState = SCB_TBS_SCRIBBLE;\
00216 }\
00217 SCB_TOOLBAR_UPDATE(doc, channel)\
00218 }
00219
00221
00223 #define SCB_ACTION_SELECT_PEN_SIZE(doc, channel, iconId)\
00224 {\
00225 if (SCB_TBS_SELECT_PEN_SIZE != doc->context.curState)\
00226 {\
00227 doc->context.curState = SCB_TBS_SELECT_PEN_SIZE;\
00228 }\
00229 else\
00230 {\
00231 doc->context.curState = SCB_TBS_SCRIBBLE;\
00232 doc->context.curStrokeStyle.penSize = ((int)iconId - (int)iconID_pen1pixel) * 2 + 1;\
00233 }\
00234 SCB_TOOLBAR_UPDATE(doc, channel)\
00235 }
00236
00238
00240 #define SCB_ACTION_SELECT_LINE_COLOR(doc, channel, iconId)\
00241 {\
00242 if (SCB_TBS_SELECT_LINE_COLOR != doc->context.curState)\
00243 {\
00244 doc->context.curState = SCB_TBS_SELECT_LINE_COLOR;\
00245 }\
00246 else\
00247 {\
00248 doc->context.curState = SCB_TBS_SCRIBBLE;\
00249 doc->context.curStrokeStyle.color = SCB_DEV_COLOR_BLACK - ((int)iconId - (int)iconID_pencolorbl);\
00250 }\
00251 SCB_TOOLBAR_UPDATE(doc, channel)\
00252 }
00253
00255
00257 #define SCB_ACTION_ERASE(doc, channel, iconId)\
00258 {\
00259 if (SCB_TBS_ERASE != doc->context.curState)\
00260 {\
00261 doc->context.curState = SCB_TBS_ERASE;\
00262 }\
00263 else\
00264 {\
00265 doc->context.curState = SCB_TBS_SCRIBBLE;\
00266 }\
00267 SCB_TOOLBAR_UPDATE(doc, channel)\
00268 }
00269
00271
00273 #define SCB_TOOLBAR_ON_RECEIVE_MSG(doc, channel, iconId)\
00274 {\
00275 if (iconID_pen == iconId)\
00276 {\
00277 SCB_ACTION_SCRIBBLE(doc, channel, iconId);\
00278 }\
00279 else if ((int)iconID_pen1pixel <= iconId && (int)iconID_pen7pixel >= iconId)\
00280 {\
00281 SCB_ACTION_SELECT_PEN_SIZE(doc, channel, iconId);\
00282 }\
00283 else if ((int)iconID_pencolorbl <= iconId && (int)iconID_pencolorwh >= iconId)\
00284 {\
00285 SCB_ACTION_SELECT_LINE_COLOR(doc, channel, iconId);\
00286 }\
00287 else if (iconID_eraseline == iconId)\
00288 {\
00289 SCB_ACTION_ERASE(doc, channel, iconId);\
00290 }\
00291 }
00292
00293
00294 #ifdef __cplusplus
00295 }
00296 #endif
00297
00298 #endif