scbstroke.h

Go to the documentation of this file.
00001 #ifndef SCBSTROKE_H_
00002 #define SCBSTROKE_H_
00003 
00004 /*
00005  * File Name  : scbstroke.h
00006  * 
00007  * Description: Scribble library stroke definition
00008  */
00009 
00010 /*
00011  * This file is part of liberscribble.
00012  *
00013  * liberscribble is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * liberscribble is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2008 iRex Technologies B.V.
00029  * All rights reserved.
00030  */
00031  
00032 
00033 //----------------------------------------------------------------------------
00034 // Include Files
00035 //----------------------------------------------------------------------------
00036 
00037 // system include files, between < >
00038 #include <glib.h>
00039 
00040 // ereader include files, between < >
00041 
00042 // local include files, between " "
00043 #include "scbcolor.h"
00044 #include "scbpoints.h"
00045 #include "scbtype.h"
00046 #include "scbstream.h"
00047 
00048 G_BEGIN_DECLS
00049 
00050     
00051 //----------------------------------------------------------------------------
00052 // Definitions
00053 //---------------------------------------------------------------------------- 
00054 
00055 
00056 //----------------------------------------------------------------------------
00057 // Forward Declarations
00058 //----------------------------------------------------------------------------
00059 
00060 
00061 //----------------------------------------------------------------------------
00062 // Type Declarations
00063 //----------------------------------------------------------------------------
00064     
00065 typedef struct _ScbStrokeAttributes
00066 {
00067     ScbDevColor     color;          /**< Device color of the stroke */
00068     float           zoom;           /**< Zoom setting of the stroke */
00069     int             layer;          /**< Drawint layer of the stroke,
00070                                     "0" means drawing on the content */
00071     int             shape_id;       /**< ID of the drawing shape */
00072     int             size_id;        /**< ID of the shape size */
00073     int             points_number;  /**< Number of the stroke points */
00074 } ScbStrokeAttributes;
00075 
00076 typedef ScbStrokeAttributes * ScbStrokeAttributesPtr;
00077 
00078 typedef struct _ScbStroke
00079 {
00080     ScbStrokeAttributes attributes; /**< Attributes of the stroke */
00081     ScbRect             rect;       /**< Out bounding rectangle of the stroke,
00082                                     it can be used for hit test */
00083     ScbPoints           points;     /**< Scribble points list */
00084 } ScbStroke;
00085 
00086 typedef ScbStroke * ScbStrokePtr;
00087 
00088 typedef struct _ScbHitTestCtx
00089 {
00090     int             size;           /**< Hit test size, it is used for expand the area of
00091                                     a hit pint */
00092     double          zoom;           /**< Current zoom setting when a hit happens */
00093 } ScbHitTestCtx;
00094 
00095 typedef ScbHitTestCtx * ScbHitTestCtxPtr;
00096 
00097 
00098 //----------------------------------------------------------------------------
00099 // Global Constants
00100 //----------------------------------------------------------------------------
00101 
00102 
00103 //============================================================================
00104 // Public Functions
00105 //============================================================================
00106 
00107 // Create a new scribble instance
00108 // @return return the pointer of created scribble instance
00109 ScbStrokePtr erscribble_stroke_new();
00110 
00111 // Create a new stroke instance with specified attributes
00112 // @param pAttr pointer of a stroke attributes instance
00113 // @return return the pointer of a stroke instance
00114 ScbStrokePtr erscribble_stroke_new_with_attributes(ScbStrokeAttributesPtr pAttr);
00115 
00116 // Release a stroke instance, all of the memory it used will be freed
00117 // @param stroke the stroke instance to be released
00118 void erscribble_stroke_free(ScbStrokePtr stroke);
00119 
00120 // Get the number of stroke points
00121 // @param stroke the stroke instance
00122 // @return return the number of stroke points
00123 int erscribble_stroke_get_point_count(ScbStrokePtr stroke);
00124 
00125 // Get start address of the points data
00126 // @param stroke the stroke instance
00127 // @return return the pointer of the first scribble point
00128 ScbPointPtr erscribble_stroke_get_point_data(ScbStrokePtr stroke);
00129 
00130 // Add a ScbPoint to the stroke
00131 // @param stroke the stroke instance
00132 // @param point the scribble point to be added
00133 // @return return error code of the adding operation. 
00134 int erscribble_stroke_add_point(ScbStrokePtr stroke, 
00135                                 ScbDevPointPtr point);
00136 
00137 // Draw the point by driver
00138 // By using ioctl, draw operation will take about 0.2 second to 
00139 // draw a stroke (25 points), while mouse event happens every 0.00048 second.
00140 // In this case some points are ignored. To resolve this problem, driver records
00141 // every point in an array and draw them when driver is ready(record 25 points every time).
00142 // If it is the last point (for example, the hit point of mouse release), the driver
00143 // should draw all of the recorded points whatever its number is.
00144 // @param stroke the stroke instance
00145 // @param point the hit point generated by the mouse event
00146 // @param is_last_point flag indicating whether it is the last point
00147 void erscribble_stroke_driver_draw_point(ScbStrokePtr stroke, 
00148                                          ScbDevPointPtr point,
00149                                          gboolean is_last_point);
00150 
00151 
00152 // Draw the whole stroke according to current attributes by driver
00153 // @param stroke the stroke to be drawn
00154 void erscribble_stroke_driver_draw(ScbStrokePtr stroke);
00155 
00156 // Hit test the point
00157 // Estimate whether the hit point intersects the area of the target stroke
00158 // @param stroke the target stroke instance
00159 // @param point the hit pint
00160 // @param ctx the hit test context
00161 // @return return TRUE if the point is located in stroke area, otherwise return FALSE
00162 gboolean erscribble_stroke_point_hit_test(ScbStrokePtr stroke, 
00163                                           ScbDevPointPtr point, 
00164                                           const ScbHitTestCtxPtr ctx);
00165 
00166 // Hit test the line
00167 // Estimate whether a line intersects the area of the target stroke
00168 // @param stroke the target stroke instance
00169 // @param point1 the start point of the line
00170 // @param point2 the end point of the line
00171 // @param ctx the hit test context
00172 // @return return TRUE if the point is located in stroke area, otherwise return FALSE
00173 gboolean erscribble_stroke_line_hit_test(ScbStrokePtr stroke, 
00174                                          ScbDevPointPtr point1,
00175                                          ScbDevPointPtr point2,
00176                                          const ScbHitTestCtxPtr ctx);
00177 
00178 // Set shape id of the stroke
00179 // @param stroke the target stroke instance
00180 // @param shape_id the shape to be set
00181 void erscribble_stroke_set_shape(ScbStrokePtr stroke, const int shape_id);
00182 
00183 // Set the size id of the stroke
00184 // @param stroke the target stroke instance
00185 // @param size_id the size to be set
00186 void erscribble_stroke_set_size(ScbStrokePtr stroke, const int size_id);
00187 
00188 // Get the shape id of the stroke
00189 // @param stroke the target stroke instance
00190 // @return return the shape id of current stroke, return -1 if stroke is invalid
00191 int erscribble_stroke_get_shape(ScbStrokePtr stroke);
00192 
00193 // Get the size id of the stroke
00194 // @param stroke the target stroke instance
00195 // @return return the size id of current stroke, return -1 if stroke is invalid
00196 int erscribble_stroke_get_size(ScbStrokePtr stroke);
00197 
00198 // (DEPRECATED) Set color for a stroke
00199 // @param stroke the target stroke instance
00200 // @param color the color to be set
00201 void erscribble_stroke_set_color(ScbStrokePtr stroke, const ScbDevColor color);
00202 
00203 // (DEPRECATED) Get color of a stroke
00204 // @param stroke the target stroke instance
00205 // @return return the color of the stroke
00206 ScbDevColor erscribble_stroke_get_color(ScbStrokePtr stroke);
00207 
00208 // Dump the data of stroke
00209 // This function can be used for debug
00210 void erscribble_stroke_dump(ScbStrokePtr ptr);
00211 
00212 // load a scribble stroke from memory stream
00213 gboolean erscribble_stroke_load(ScbStrokePtr stroke, ScbStreamPtr stream);
00214 
00215 // write a stroke to stream
00216 gboolean erscribble_stroke_write_stream(ScbStrokePtr stroke, ScbStreamPtr stream);
00217 
00218 
00219 G_END_DECLS
00220 
00221 #endif
Generated by  doxygen 1.6.2-20100208