rtk.h

Go to the documentation of this file.
00001 /*
00002  *  STK2 : stage's internal graphics toolkit based on RTK2
00003  *
00004  *  Copyright (C) 2001-2005 Andrew Howard ahoward@usc.edu, Richard
00005  *  Vaughan vaughan@sfu.ca
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 /*
00024  * Desc: Combined Stk functions
00025  * Author: Andrew Howard, Richard Vaughan
00026 
00027  * CVS: $Id: rtk.h,v 1.16 2006/03/24 20:12:42 pooya Exp $
00028  */
00029 
00030 #ifndef STK_H
00031 #define STK_H
00032 
00033 #include <stdio.h>
00034 #include <math.h>
00035 #include <gtk/gtk.h>
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 #define STK_CANVAS_LAYERS 100
00042 
00043 // Movement mask for canvases
00044 #define STK_MOVE_PAN   (1 << 0)
00045 #define STK_MOVE_ZOOM  (1 << 1)
00046 
00047 // Movement masks for figures
00048 #define STK_MOVE_TRANS (1 << 0)
00049 #define STK_MOVE_ROT   (1 << 1)
00050 #define STK_MOVE_SCALE (1 << 2)
00051 
00052 // Event codes for figures
00053 #define STK_EVENT_PRESS     1
00054 #define STK_EVENT_MOTION    2
00055 #define STK_EVENT_RELEASE   3
00056 #define STK_EVENT_MOUSE_OVER 4
00057 #define STK_EVENT_MOUSE_NOT_OVER 5
00058 
00059 // Export image formats
00060 #define STK_IMAGE_FORMAT_JPEG 0
00061 #define STK_IMAGE_FORMAT_PPM  1  
00062 #define STK_IMAGE_FORMAT_PNG  2  
00063 #define STK_IMAGE_FORMAT_PNM  3 
00064 
00065 // Color space conversion macros
00066 #define STK_RGB16(r, g, b) (((b) >> 3) | (((g) & 0xFC) << 3) | (((r) & 0xF8) << 8))
00067 #define STK_R_RGB16(x) (((x) >> 8) & 0xF8)
00068 #define STK_G_RGB16(x) (((x) >> 3) & 0xFC)
00069 #define STK_B_RGB16(x) (((x) << 3) & 0xF8)
00070 
00071   
00072 // Useful forward declarations
00073 struct _stg_rtk_canvas_t;
00074 struct _stg_rtk_table_t;
00075 struct _stg_rtk_fig_t;
00076 struct _stg_rtk_stroke_t;
00077 struct _stg_rtk_region_t;
00078 struct _stg_rtk_menuitem_t;
00079 
00080 struct _stg_rtk_flasher_t; // rtv experimental
00081   
00082 struct AVCodec;
00083 struct AVCodecContext;
00084 
00085 
00086 /***************************************************************************
00087  * Library functions
00088  ***************************************************************************/
00089 
00090 // Initialise the library.
00091 // Pass in the program arguments through argc, argv
00092 int stg_rtk_initxx(int *argc, char ***argv);
00093 
00094   
00095 /***************************************************************************
00096  * Application functions
00097  ***************************************************************************/
00098 
00099 // Structure describing and application
00100 typedef struct _stg_rtk_app_t
00101 {
00102   int must_quit;
00103   int has_quit;
00104 
00105   // Linked list of canvases
00106   struct _stg_rtk_canvas_t *canvas;
00107 
00108   // Linked list of tables
00109   struct _stg_rtk_table_t *table;
00110   
00111 } stg_rtk_app_t;
00112   
00113 // Create the application
00114 stg_rtk_app_t *stg_rtk_app_create(void);
00115 
00116 // Destroy the application
00117 void stg_rtk_app_destroy(stg_rtk_app_t *app);
00118   
00119 // Main loop for the app (blocking).  Will return only when the gui is closed by
00120 // the user.
00121 int stg_rtk_app_main(stg_rtk_app_t *app);
00122 
00123 // Do the initial main loop stuff
00124 void stg_rtk_app_main_init(stg_rtk_app_t *app);
00125 
00126 // Do the final main loop stuff
00127 void stg_rtk_app_main_term(stg_rtk_app_t *app);
00128 
00129 // Process pending events (non-blocking). Returns non-zero if the app
00130 // should quit.
00131 int stg_rtk_app_main_loop(stg_rtk_app_t *app);
00132 
00133 
00134 /***************************************************************************
00135  * Canvas functions
00136  ***************************************************************************/
00137   
00138 // Structure describing a canvas
00139 typedef struct _stg_rtk_canvas_t
00140 {
00141   // Linked list of canvases
00142   struct _stg_rtk_canvas_t *next, *prev;
00143 
00144   // Link to our parent app
00145   struct _stg_rtk_app_t *app;
00146 
00147   // Gtk stuff
00148   //GtkWidget *frame;
00149   //GtkWidget *layout;
00150   GtkWidget *canvas;
00151   // GDK stuff
00152   GdkPixmap *bg_pixmap, *fg_pixmap;
00153   GdkGC *gc;
00154   GdkColormap *colormap;
00155   //GdkFont *font;
00156 
00157   // Default font name
00158   //char *fontname;
00159 
00160   // Canvas background color
00161   GdkColor bgcolor;
00162   
00163   // Default line width
00164   int linewidth;
00165 
00166   // Physical size of window
00167   int sizex, sizey;
00168     
00169   // Coordinate transform
00170   // Logical coords of middle of canvas
00171   // and logical/device scale (eg m/pixel)
00172   double ox, oy;
00173   double sx, sy;
00174 
00175   // Flag set if canvas has been destroyed
00176   int destroyed;
00177   
00178   // Flags controlling background re-rendering
00179   int bg_dirty;
00180 
00181   // Flags controlling foreground re-rendering
00182   int fg_dirty;
00183   struct _stg_rtk_region_t *fg_dirty_region;
00184 
00185   // Non-zero if there are deferred calculations to be done.
00186   int calc_deferred;
00187 
00188   // Movement mask for the canvas
00189   int movemask;
00190 
00191   // Head of linked-list of top-level (parentless) figures.
00192   struct _stg_rtk_fig_t *fig;
00193 
00194   // Head of linked-list of figures ordered by layer.
00195   struct _stg_rtk_fig_t *layer_fig;
00196 
00197   // Head of linked-list of moveble figures.
00198   struct _stg_rtk_fig_t *moveable_fig;
00199   
00200   // Mouse stuff
00201   int mouse_mode;
00202   double mouse_start_x, mouse_start_y, mouse_start_a;
00203   struct _stg_rtk_fig_t *zoom_fig;
00204   struct _stg_rtk_fig_t *mouse_over_fig;
00205   struct _stg_rtk_fig_t *mouse_selected_fig;
00206   struct _stg_rtk_fig_t *mouse_selected_fig_last;  
00207 
00208   // linked list of figs that are shown for a short period, then
00209   // hidden or destroyed - rtv experimental
00210   struct _stg_rtk_flasher_t *flashers;
00211   
00212   // toggle these bytes to individually show and hide layers - rtv
00213   char layer_show[STK_CANVAS_LAYERS];
00214 
00215   // arbitrary user data
00216   void *userdata;
00217 
00218 } stg_rtk_canvas_t;
00219 
00220 
00221 // Create a canvas on which to draw stuff.
00222 stg_rtk_canvas_t *stg_rtk_canvas_create(stg_rtk_app_t *app);
00223 
00224 // Destroy the canvas
00225 void stg_rtk_canvas_destroy(stg_rtk_canvas_t *canvas);
00226 
00227 // See if the canvas has been closed
00228 int stg_rtk_canvas_isclosed(stg_rtk_canvas_t *canvas);
00229 
00230 // Set the canvas title
00231 void stg_rtk_canvas_title(stg_rtk_canvas_t *canvas, const char *title);
00232 
00233 // Set the size of a canvas
00234 // (sizex, sizey) is the width and height of the canvas, in pixels.
00235 void stg_rtk_canvas_size(stg_rtk_canvas_t *canvas, int sizex, int sizey);
00236 
00237 // Get the canvas size
00238 // (sizex, sizey) is the width and height of the canvas, in pixels.
00239 void stg_rtk_canvas_get_size(stg_rtk_canvas_t *canvas, int *sizex, int *sizey);
00240 
00241 // Set the origin of a canvas
00242 // (ox, oy) specifies the logical point that maps to the center of the
00243 // canvas.
00244 void stg_rtk_canvas_origin(stg_rtk_canvas_t *canvas, double ox, double oy);
00245 
00246 // Get the origin of a canvas
00247 // (ox, oy) specifies the logical point that maps to the center of the
00248 // canvas.
00249 void stg_rtk_canvas_get_origin(stg_rtk_canvas_t *canvas, double *ox, double *oy);
00250 
00251 // Scale a canvas
00252 // Sets the pixel width and height in logical units
00253 void stg_rtk_canvas_scale(stg_rtk_canvas_t *canvas, double sx, double sy);
00254 
00255 // Get the scale of the canvas
00256 // (sx, sy) are the pixel with and height in logical units
00257 void stg_rtk_canvas_get_scale(stg_rtk_canvas_t *canvas, double *sx, double *sy);
00258 
00259 // Set the movement mask
00260 // Set the mask to a bitwise combination of STK_MOVE_TRANS, STK_MOVE_SCALE.
00261 // to enable user manipulation of the canvas.
00262 void stg_rtk_canvas_movemask(stg_rtk_canvas_t *canvas, int mask);
00263 
00264 // Set the default font for text strokes
00265 // void stg_rtk_canvas_font(stg_rtk_canvas_t *canvas, const char *fontname);
00266 
00267 // Set the canvas backround color
00268 void stg_rtk_canvas_bgcolor(stg_rtk_canvas_t *canvas, double r, double g, double b);
00269 
00270 // Set the default line width.
00271 void stg_rtk_canvas_linewidth(stg_rtk_canvas_t *canvas, int width);
00272 
00273 // Re-render the canvas
00274 void stg_rtk_canvas_render(stg_rtk_canvas_t *canvas);
00275 
00276 // Export an image.
00277 // [filename] is the name of the file to save.
00278 // [format] is the image file format (STK_IMAGE_FORMAT_JPEG, STK_IMAGE_FORMAT_PPM).
00279 void stg_rtk_canvas_export_image(stg_rtk_canvas_t *canvas, const char *filename, int format);
00280 
00281 /*
00282 // Export canvas to xfig file
00283 int stg_rtk_canvas_export_xfig(stg_rtk_canvas_t *canvas, char *filename);
00284 */
00285 
00286 // Start movie capture.
00287 // [filename] is the name of the file to save.
00288 // [fps] is the rate at which the caller will write frames (e.g. 5fps, 10fps).
00289 // [speed] is the ultimate playback speed of the movie (e.g. 1x, 2x).
00290 int stg_rtk_canvas_movie_start(stg_rtk_canvas_t *canvas,
00291                            const char *filename, double fps, double speed);
00292 
00293 // Start movie capture.
00294 void stg_rtk_canvas_movie_frame(stg_rtk_canvas_t *canvas);
00295 
00296 // Stop movie capture.
00297 void stg_rtk_canvas_movie_stop(stg_rtk_canvas_t *canvas);
00298 
00299 // rtv experimental
00300 // Maintain a list of figures that are shown for a set time, then hidden.
00301 typedef struct _stg_rtk_flasher_t
00302 {
00303   struct _stg_rtk_fig_t* fig; // a figure to be shown for a set period
00304   int duration; // decremented on each call to stg_rtk_canvas_flash_update()
00305   int kill; // if zero, the fig is hidden on timeout, if non-zero, the
00306   // figure is destroyed instead
00307 
00308   // list hooks
00309   struct _stg_rtk_flasher_t* next, *prev;
00310 } stg_rtk_flasher_t;
00311 
00312 // Add this figure to the list of flashers. It will be shown until
00313 // stg_rtk_canvas_flash_update() is called [duration] times, then it will
00314 // be destroyed if [kill] is non-zero, or hidden, if [kill] is zero
00315 void stg_rtk_canvas_flash( stg_rtk_canvas_t* canvas, 
00316                        struct _stg_rtk_fig_t* fig, int duration, int kill );
00317 
00318 // Decrement the flasher's counters. Those that time out get hidden
00319 // and removed from the flasher list
00320 void stg_rtk_canvas_flash_update( stg_rtk_canvas_t* canvas );
00321 
00322 // show and hide individual layers
00323 void stg_rtk_canvas_layer_show( stg_rtk_canvas_t* canvas, int layer, char show );
00324 
00325 // end rtv experimental
00326 
00327 /***************************************************************************
00328  * Figure functions
00329  ***************************************************************************/
00330   
00331 // Structure describing a color
00332 typedef GdkColor stg_rtk_color_t;
00333 
00334 // Callback function signatures
00335 typedef void (*stg_rtk_mouse_fn_t) (struct _stg_rtk_fig_t *fig, int event, int mode);
00336 
00337 
00338 // Structure describing a figure
00339 typedef struct _stg_rtk_fig_t
00340 {
00341   // Pointer to parent canvas
00342   struct _stg_rtk_canvas_t *canvas;
00343 
00344   // Pointer to our parent figure
00345   struct _stg_rtk_fig_t *parent;
00346 
00347   // Head of a linked-list of children.
00348   struct _stg_rtk_fig_t *child;
00349   
00350   // Linked-list of siblings
00351   struct _stg_rtk_fig_t *sibling_next, *sibling_prev;
00352 
00353   // Linked-list of figures ordered by layer  
00354   struct _stg_rtk_fig_t *layer_next, *layer_prev;
00355 
00356   // Linked-list of figures that are moveable.
00357   struct _stg_rtk_fig_t *moveable_next, *moveable_prev;
00358 
00359   // Arbitrary user data
00360   void *userdata;
00361   
00362   // Layer this fig belongs to
00363   int layer;
00364 
00365   // Flag set to true if figure should be displayed
00366   int show;
00367 
00368   // Movement mask (a bit vector)
00369   int movemask;
00370   
00371   // Origin, scale of figure
00372   // relative to parent.
00373   double ox, oy, oa;
00374   double cos, sin;
00375   double sx, sy;
00376 
00377   // Origin, scale of figure
00378   // in global cs.
00379   double dox, doy, doa;
00380   double dcos, dsin;
00381   double dsx, dsy;
00382 
00383   // Bounding box for the figure in local cs; contains all of the
00384   // strokes for this figure.
00385   double min_x, min_y, max_x, max_y;
00386 
00387   // Bounding region for the figure in device cs; contains all the
00388   // strokes for this figure.
00389   struct _stg_rtk_region_t *region;
00390   
00391   // List of strokes
00392   int stroke_size;
00393   int stroke_count;
00394   struct _stg_rtk_stroke_t **strokes;
00395 
00396   // Drawing context information.  Just a list of default args for
00397   // drawing primitives.
00398   stg_rtk_color_t dc_color;
00399   //int dc_xfig_color;
00400   int dc_linewidth;
00401 
00402   // if > 0, the visibility of this figure is toggled with this
00403   // interval. To stop blinking but remember the interval, make the
00404   // value negative. (rtv)
00405   int blink_interval_ms;
00406 
00407   // Event callback functions.
00408   stg_rtk_mouse_fn_t mouse_fn;
00409 
00410 } stg_rtk_fig_t;
00411 
00412 
00413 // Figure creation/destruction
00414 //stg_rtk_fig_t *stg_rtk_fig_create(stg_rtk_canvas_t *canvas, stg_rtk_fig_t *parent, int layer);
00415 stg_rtk_fig_t *stg_rtk_fig_create(stg_rtk_canvas_t *canvas, stg_rtk_fig_t *parent, int layer );
00416 void stg_rtk_fig_destroy(stg_rtk_fig_t *fig);
00417 
00418 // Recursively free a whole tree of figures (rtv)
00419 void stg_rtk_fig_and_descendents_destroy( stg_rtk_fig_t* fig );
00420 
00421 // create a figure and set its user data pointer (rtv)
00422 stg_rtk_fig_t *stg_rtk_fig_create_ex(stg_rtk_canvas_t *canvas, stg_rtk_fig_t *parent, 
00423                              int layer, void* userdata );
00424 
00425 // Set the mouse event callback function.
00426 void stg_rtk_fig_add_mouse_handler(stg_rtk_fig_t *fig, stg_rtk_mouse_fn_t callback);
00427 
00428 // Unset the mouse event callback function.
00429 void stg_rtk_fig_remove_mouse_handler(stg_rtk_fig_t *fig, stg_rtk_mouse_fn_t callback);
00430 
00431 // Clear all existing strokes from a figure.
00432 void stg_rtk_fig_clear(stg_rtk_fig_t *fig);
00433 
00434 // Show or hide the figure
00435 void stg_rtk_fig_show(stg_rtk_fig_t *fig, int show);
00436 
00437 // Set the movement mask
00438 // Set the mask to a bitwise combination of STK_MOVE_TRANS, STK_MOVE_ROT, etc,
00439 // to enable user manipulation of the figure.
00440 void stg_rtk_fig_movemask(stg_rtk_fig_t *fig, int mask);
00441 
00442 // See if the mouse is over this figure
00443 int stg_rtk_fig_mouse_over(stg_rtk_fig_t *fig);
00444 
00445 // See if the figure has been selected
00446 int stg_rtk_fig_mouse_selected(stg_rtk_fig_t *fig);
00447 
00448 // Set the figure origin (local coordinates).
00449 void stg_rtk_fig_origin(stg_rtk_fig_t *fig, double ox, double oy, double oa);
00450 
00451 // Set the figure origin (global coordinates).
00452 void stg_rtk_fig_origin_global(stg_rtk_fig_t *fig, double ox, double oy, double oa);
00453 
00454 // Get the current figure origin (local coordinates).
00455 void stg_rtk_fig_get_origin(stg_rtk_fig_t *fig, double *ox, double *oy, double *oa);
00456 
00457 // Set the figure scale
00458 void stg_rtk_fig_scale(stg_rtk_fig_t *fig, double scale);
00459 
00460 // Set the color for strokes.  Color is specified as an (r, g, b)
00461 // tuple, with values in range [0, 1].
00462 void stg_rtk_fig_color(stg_rtk_fig_t *fig, double r, double g, double b);
00463 
00464 // Set the color for strokes.  Color is specified as an RGB32 value (8
00465 // bits per color).
00466 void stg_rtk_fig_color_rgb32(stg_rtk_fig_t *fig, int color);
00467 
00468 // Set the color for strokes.  Color is specified as an xfig color.
00469 //void stg_rtk_fig_color_xfig(stg_rtk_fig_t *fig, int color);
00470 
00471 // Set the line width.
00472 void stg_rtk_fig_linewidth(stg_rtk_fig_t *fig, int width);
00473 
00474 // Draw a single point.
00475 void stg_rtk_fig_point(stg_rtk_fig_t *fig, double ox, double oy);
00476 
00477 // Draw a line between two points.
00478 void stg_rtk_fig_line(stg_rtk_fig_t *fig, double ax, double ay, double bx, double by);
00479 
00480 // Draw a line centered on the given point.
00481 void stg_rtk_fig_line_ex(stg_rtk_fig_t *fig, double ox, double oy, double oa, double size);
00482 
00483 // Draw a rectangle centered on (ox, oy) with orientation oa and size (sx, sy).
00484 void stg_rtk_fig_rectangle(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00485                        double sx, double sy, int filled);
00486 
00487 // Draw an ellipse centered on (ox, oy) with orientation oa and size (sx, sy).
00488 void stg_rtk_fig_ellipse(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00489                      double sx, double sy, int filled);
00490 
00491 // Draw an arc between min_th and max_th on the ellipse as above
00492 void stg_rtk_fig_ellipse_arc( stg_rtk_fig_t *fig, double ox, double oy, double oa,
00493                           double sx, double sy, double min_th, double max_th);
00494 
00495 // Create a polygon
00496 void stg_rtk_fig_polygon(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00497                          int point_count, double points[][2], int filled);
00498                          //int point_count, double* points, int filled);
00499 
00500 // Draw an arrow from point (ox, oy) with orientation oa and length len.
00501 void stg_rtk_fig_arrow(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00502                    double len, double head);
00503 
00504 // Draw an arrow between points (ax, ay) and (bx, by).
00505 void stg_rtk_fig_arrow_ex(stg_rtk_fig_t *fig, double ax, double ay,
00506                       double bx, double by, double head);
00507 
00508 // create a fancy arrow that can be filled
00509 void stg_rtk_fig_arrow_fancy(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00510                          double len, double head, double thickness, int filled );
00511 
00512 // Draw single or multiple lines of text.  Lines are deliminted with
00513 // '\n'.
00514 void stg_rtk_fig_text(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00515                   const char *text);
00516 
00517 // Draw single or multiple lines of text in a bubble.  Lines are deliminted with
00518 // '\n'.
00519 void stg_rtk_fig_text_bubble(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00520                   const char *text, double bx, double by);
00521 
00522 // Draw a grid.  Grid is centered on (ox, oy) with size (dx, dy) with
00523 // spacing (sp).
00524 void stg_rtk_fig_grid(stg_rtk_fig_t *fig, double ox, double oy,
00525                   double dx, double dy, double sp);
00526 
00527 // Draw an image.  bpp specifies the number of bits per pixel, and
00528 // must be 16.
00529 void stg_rtk_fig_image(stg_rtk_fig_t *fig, double ox, double oy, double oa,
00530                    double scale, int width, int height, int bpp, void *image, void *mask);
00531 
00532 // start toggling the show flag for the figure at approximately the
00533 // desired millisecond interval - set to < 1 to stop blinking
00534 void stg_rtk_fig_blink( stg_rtk_fig_t* fig, int interval_ms, int flag );
00535 
00536 
00537 /***************************************************************************
00538  * Primitive strokes for figures.
00539  ***************************************************************************/
00540 
00541 // Signature for stroke methods.
00542 typedef void (*stg_rtk_stroke_fn_t) (struct _stg_rtk_fig_t *fig, void *stroke);
00543 
00544 
00545 // Structure describing a stroke (base structure for all strokes).
00546 typedef struct _stg_rtk_stroke_t
00547 {
00548   // Color
00549   stg_rtk_color_t color;
00550 
00551   // Xfig color
00552   //int xfig_color;
00553 
00554   // Line width
00555   int linewidth;
00556 
00557   // Function used to free data associated with stroke
00558   stg_rtk_stroke_fn_t freefn;
00559 
00560   // Function used to compute onscreen appearance
00561   stg_rtk_stroke_fn_t calcfn;
00562   
00563   // Function used to render stroke
00564   stg_rtk_stroke_fn_t drawfn;
00565 
00566   // Function used to render stroke to xfig
00567   //stg_rtk_stroke_fn_t xfigfn;
00568   
00569 } stg_rtk_stroke_t;
00570 
00571 
00572 // Struct describing a point
00573 typedef struct
00574 {  
00575   double x, y; 
00576 } stg_rtk_point_t;
00577 
00578 
00579 // Struct describing a point stroke
00580 typedef struct
00581 {
00582   stg_rtk_stroke_t stroke;
00583 
00584   // Point in logical local coordinates.
00585   double ox, oy;
00586 
00587   // Point in absolute physical coordinates.
00588   GdkPoint point;
00589   
00590 } stg_rtk_point_stroke_t;
00591 
00592 
00593 // Polygon/polyline stroke
00594 typedef struct
00595 {
00596   stg_rtk_stroke_t stroke;
00597 
00598   // Origin of figure in logical local coordinates.
00599   double ox, oy, oa;
00600 
00601   // Zero if this is a polyline, Non-zero if this is a polygon.
00602   int closed;
00603   
00604   // Non-zero if polygon should be filled.
00605   int filled;
00606 
00607   // A list of points in the polygon, in both local logical
00608   // coordinates and absolute physical coordinates.
00609   int point_count;
00610   stg_rtk_point_t *lpoints;
00611   GdkPoint *ppoints;
00612   
00613 } stg_rtk_polygon_stroke_t;
00614 
00615 
00616 // Struct describing text stroke
00617 typedef struct
00618 {
00619   stg_rtk_stroke_t stroke;
00620 
00621   // Origin of the text in logical local coordinates.
00622   double ox, oy, oa;
00623 
00624   // Text width and height calculated by Pango
00625   double width, height;
00626   
00627   // Origin of the text in absolute physical coordinates.
00628   GdkPoint point;
00629   
00630   // Pango layout
00631   PangoLayout *layout;
00632 
00633   // The text
00634   char *text;
00635   
00636 } stg_rtk_text_stroke_t;
00637 
00638 
00639 // Structure describing an image stroke
00640 typedef struct
00641 {
00642   stg_rtk_stroke_t stroke;
00643 
00644   // Origin of figure in local logical coordinates.
00645   double ox, oy, oa;
00646 
00647   // Rectangle containing the image (absolute physical coordinates).
00648   double points[4][2];
00649 
00650   // Image data
00651   double scale;
00652   int width, height, bpp;
00653   void *image, *mask;
00654 
00655 } stg_rtk_image_stroke_t;
00656 
00657 
00658 /***************************************************************************
00659  * Region manipulation (used internal for efficient redrawing).
00660  ***************************************************************************/
00661 
00662 // Info about a region
00663 typedef struct _stg_rtk_region_t
00664 {
00665   // Bounding box
00666   GdkRectangle rect;
00667   
00668 } stg_rtk_region_t;
00669 
00670 
00671 // Create a new region.
00672 stg_rtk_region_t *stg_rtk_region_create(void);
00673 
00674 // Destroy a region.
00675 void stg_rtk_region_destroy(stg_rtk_region_t *region);
00676 
00677 // Set a region to empty.
00678 void stg_rtk_region_set_empty(stg_rtk_region_t *region);
00679 
00680 // Set the region to the union of the two given regions.
00681 void stg_rtk_region_set_union(stg_rtk_region_t *regiona, stg_rtk_region_t *regionb);
00682 
00683 // Set the region to the union of the region with a rectangle
00684 void stg_rtk_region_set_union_rect(stg_rtk_region_t *region, int ax, int ay, int bx, int by);
00685 
00686 // Get the bounding rectangle for the region.
00687 void stg_rtk_region_get_brect(stg_rtk_region_t *region, GdkRectangle *rect);
00688 
00689 // Test to see if a region is empty.
00690 int stg_rtk_region_test_empty(stg_rtk_region_t *region);
00691 
00692 // Test for intersection betweenr regions.
00693 int stg_rtk_region_test_intersect(stg_rtk_region_t *regiona, stg_rtk_region_t *regionb);
00694 
00695 
00696 /***************************************************************************
00697  * Menus : menus, submenus and menu items.
00698  ***************************************************************************/
00699 
00700 // Callback function signatures
00701 typedef void (*stg_rtk_menuitem_fn_t) (struct _stg_rtk_menuitem_t *menuitem);
00702 
00703 
00704 // Info about a menu
00705 typedef struct
00706 {
00707   // Which canvas we are attached to.
00708   stg_rtk_canvas_t *canvas;
00709 
00710   // GTK widget holding the menu label widget.
00711   GtkWidget *item;
00712 
00713   // GTK menu item widget.
00714   GtkWidget *menu;
00715   
00716 } stg_rtk_menu_t;
00717 
00718 
00719 // Info about a menu item
00720 typedef struct _stg_rtk_menuitem_t
00721 {
00722   // Which menu we are attached to.
00723   stg_rtk_menu_t *menu;
00724 
00725   // GTK menu item widget.
00726   GtkWidget *item;
00727 
00728   // Flag set if item has been activated.
00729   int activated;
00730 
00731   // Flag set if this is a check-menu item
00732   int checkitem;
00733 
00734   // Flag set if item is checked.
00735   int checked;          
00736 
00737   // User data (mainly for callbacks)
00738   void *userdata;
00739   
00740   // Callback function
00741   stg_rtk_menuitem_fn_t callback;
00742   
00743 } stg_rtk_menuitem_t;
00744 
00745 
00746 // Create a menu
00747 stg_rtk_menu_t *stg_rtk_menu_create(stg_rtk_canvas_t *canvas, const char *label);
00748 
00749 // Create a sub menu
00750 stg_rtk_menu_t *stg_rtk_menu_create_sub(stg_rtk_menu_t *menu, const char *label);
00751 
00752 // Delete a menu
00753 void stg_rtk_menu_destroy(stg_rtk_menu_t *menu);
00754 
00755 // Create a new menu item.  Set check to TRUE if you want a checkbox
00756 // with the menu item
00757 stg_rtk_menuitem_t *stg_rtk_menuitem_create(stg_rtk_menu_t *menu,
00758                                     const char *label, int check);
00759 
00760 // Set the callback for a menu item.  This function will be called
00761 // when the user selects the menu item.
00762 void stg_rtk_menuitem_set_callback(stg_rtk_menuitem_t *item,
00763                                stg_rtk_menuitem_fn_t callback);
00764 
00765 // Delete a menu item.
00766 void stg_rtk_menuitem_destroy(stg_rtk_menuitem_t *item);
00767 
00768 // Test to see if the menu item has been activated.  Calling this
00769 // function will reset the flag.
00770 int stg_rtk_menuitem_isactivated(stg_rtk_menuitem_t *item);
00771 
00772 // Set the check state of a menu item.
00773 void stg_rtk_menuitem_check(stg_rtk_menuitem_t *item, int check);
00774 
00775 // Test to see if the menu item is checked.
00776 int stg_rtk_menuitem_ischecked(stg_rtk_menuitem_t *item);
00777 
00778 // Enable/disable the menu item
00779 int stg_rtk_menuitem_enable(stg_rtk_menuitem_t *item, int enable);
00780 
00781 
00782 /***************************************************************************
00783  * Tables : provides a list of editable var = value pairs.
00784  ***************************************************************************/
00785 
00786 // Info about a single item in a table
00787 typedef struct _stg_rtk_tableitem_t
00788 {
00789   struct _stg_rtk_tableitem_t *next, *prev;  // Linked list of items
00790   struct _stg_rtk_table_t *table;
00791   GtkWidget *label;  // Label widget
00792   GtkObject *adj;    // Object for storing spin box results.
00793   GtkWidget *spin;   // Spin box widget
00794   double value;      // Last recorded value of the item
00795 } stg_rtk_tableitem_t;
00796 
00797 
00798 // Info about a table
00799 typedef struct _stg_rtk_table_t
00800 {
00801   struct _stg_rtk_table_t *next, *prev;  // Linked list of tables
00802   stg_rtk_app_t *app;         // Link to our parent app
00803   GtkWidget *frame;       // A top-level window to put the table in.
00804   GtkWidget *table;       // The table layout
00805   int destroyed;          // Flag set to true if the GTK frame has been destroyed.
00806   int item_count;         // Number of items currently in the table
00807   int row_count;          // Number of rows currently in the table
00808   stg_rtk_tableitem_t *item;  // Linked list of items that belong in the table
00809 } stg_rtk_table_t;
00810 
00811 // Create a new table
00812 stg_rtk_table_t *stg_rtk_table_create(stg_rtk_app_t *app, int width, int height);
00813 
00814 // Delete the table
00815 void stg_rtk_table_destroy(stg_rtk_table_t *table);
00816 
00817 // Create a new item in the table
00818 stg_rtk_tableitem_t *stg_rtk_tableitem_create_int(stg_rtk_table_t *table,
00819                                           const char *label, int low, int high);
00820 
00821 // Set the value of a table item (as an integer)
00822 void stg_rtk_tableitem_set_int(stg_rtk_tableitem_t *item, int value);
00823 
00824 // Get the value of a table item (as an integer)
00825 int stg_rtk_tableitem_get_int(stg_rtk_tableitem_t *item);
00826 
00827 #ifdef __cplusplus
00828 }
00829 #endif
00830 
00831 #endif
00832 

Generated on Thu Dec 13 14:35:18 2007 for Stage by  doxygen 1.4.6