#include <stdlib.h>#include <gtk/gtk.h>#include "ink_draw.h"#include "ScribbleLog.h"#include "ScribbleUtils.h"Go to the source code of this file.
Functions | |
| int | ink_setDrawable (GdkDrawable *pDrawable) |
| gboolean | setPenSizeAtrr (int iPenSize) |
| gboolean | setPenColorAttr (GdkColor *pGdkColor) |
| void | ink_draw_line (int x0, int y0, int x1, int y1) |
| void | draw_ink (PtrInk ink) |
| void | draw_stroke (PtrStroke stroke) |
Variables | |
| static GdkDrawable * | pCurrDrawable = NULL |
| static GdkGC * | pCurrGDKGC = NULL |
| static int | iLastPenSize = -1 |
| static int | iLastHwColor = -1 |
| void draw_ink | ( | PtrInk | ink | ) |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
Definition at line 106 of file ink_draw.c.
00107 { 00108 int nStrokes; 00109 PtrStroke stroke = NULL; 00110 if (ink == NULL) 00111 return; 00112 00113 stroke = ink->firstStroke; 00114 nStrokes = get_num_of_strokes (ink); 00115 SB_INKPRINTF("nStrokes=%d\n", nStrokes); 00116 if (stroke == NULL || nStrokes <= 0) 00117 { 00118 return; 00119 } 00120 00121 while (stroke) 00122 { 00123 draw_stroke (stroke); 00124 stroke = stroke->nextStroke; 00125 } 00126 }

| void draw_stroke | ( | PtrStroke | stroke | ) |
Definition at line 129 of file ink_draw.c.
00130 { 00131 PtrInkPoint point = NULL; 00132 int nPoints; 00133 if (stroke == NULL) 00134 return; 00135 00136 point = stroke->firstPoint; 00137 nPoints = get_num_of_points (stroke); 00138 if (point == NULL || nPoints <= 0) 00139 return; 00140 00141 //select pensize 00142 setPenSizeAtrr(stroke->iPenSize); 00143 //set pen color 00144 setPenColorAttr(&stroke->gdkColor); 00145 00146 SB_INKPRINTF("(nPoints=%d)\n", nPoints); 00147 // only one point in the stroke 00148 if ( 1==nPoints ) 00149 { 00150 ink_draw_line(point->x, point->y,point->x, point->y); 00151 return; 00152 } 00153 00154 while (point->nextPoint) 00155 { 00156 ink_draw_line(point->x, point->y, 00157 point->nextPoint->x,point->nextPoint->y); 00158 point = point->nextPoint; 00159 } 00160 }

| void ink_draw_line | ( | int | x0, | |
| int | y0, | |||
| int | x1, | |||
| int | y1 | |||
| ) |
Definition at line 95 of file ink_draw.c.
00096 { 00097 GdkPoint points[2]; 00098 points[0].x=(gint)x0; 00099 points[0].y=(gint)y0; 00100 points[1].x=(gint)x1; 00101 points[1].y=(gint)y1; 00102 gdk_draw_lines(pCurrDrawable,pCurrGDKGC,points,2); 00103 }
| int ink_setDrawable | ( | GdkDrawable * | pDrawable | ) |
Definition at line 46 of file ink_draw.c.
00047 { 00048 //avoiding duplicated efforts 00049 if(pCurrDrawable==pDrawable) return 0; 00050 00051 pCurrDrawable=pDrawable; 00052 00053 if(pCurrGDKGC) 00054 g_object_unref(pCurrGDKGC); 00055 00056 pCurrGDKGC=gdk_gc_new(pDrawable); 00057 if(NULL==pCurrGDKGC) 00058 { 00059 SB_INKERRPRINTF("error when create GDKGC\n"); 00060 return -1; 00061 } 00062 SB_INKPRINTF("create gdk gc successfully\n"); 00063 return 0; 00064 }
| gboolean setPenColorAttr | ( | GdkColor * | pGdkColor | ) |
Definition at line 84 of file ink_draw.c.
00085 { 00086 HW_COLOR iColor=Util_HWCOLORFromGdkColor(pGdkColor); 00087 if(iLastHwColor != iColor) 00088 { 00089 gdk_gc_set_rgb_fg_color(pCurrGDKGC,pGdkColor); 00090 iLastHwColor=iColor; 00091 } 00092 return TRUE; 00093 }

| gboolean setPenSizeAtrr | ( | int | iPenSize | ) |
Definition at line 68 of file ink_draw.c.
00069 { 00070 if(iLastPenSize != iPenSize) 00071 { 00072 gdk_gc_set_line_attributes(pCurrGDKGC, 00073 iPenSize, 00074 GDK_LINE_SOLID, 00075 GDK_CAP_PROJECTING, 00076 GDK_JOIN_MITER); 00077 iLastPenSize=iPenSize; 00078 } 00079 return TRUE; 00080 }
int iLastHwColor = -1 [static] |
Definition at line 82 of file ink_draw.c.
int iLastPenSize = -1 [static] |
Definition at line 66 of file ink_draw.c.
GdkDrawable* pCurrDrawable = NULL [static] |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
Definition at line 43 of file ink_draw.c.
GdkGC* pCurrGDKGC = NULL [static] |
Definition at line 44 of file ink_draw.c.
1.5.6