]> granicus.if.org Git - graphviz/commitdiff
add jumptable for gvplugin_device callbacks
authorellson <devnull@localhost>
Fri, 29 Jul 2005 22:08:24 +0000 (22:08 +0000)
committerellson <devnull@localhost>
Fri, 29 Jul 2005 22:08:24 +0000 (22:08 +0000)
    - needed so that (non-builtin) plugins can be loaded into static binaries

lib/gvc/gvcint.h
lib/gvc/gvdevice.c
lib/gvc/gvevent.c
lib/gvc/gvplugin_device.h

index 28445612608a6dc1c6eb2f83abcf381271932e47..3cd0a523d1902ebcce5b7da4da4ef34576bcdc50 100644 (file)
@@ -129,6 +129,14 @@ extern "C" {
        int alloc;
     } gv_argvlist_t;
 
+    typedef struct gvdevice_callbacks_s {
+       void (*refresh) (GVJ_t * job);
+        void (*button_press) (GVJ_t * job, int button, pointf pointer);
+        void (*button_release) (GVJ_t * job, int button, pointf pointer);
+        void (*motion) (GVJ_t * job, pointf pointer);
+        void (*modify) (GVJ_t * job, char *name, char *value);
+    } gvdevice_callbacks_t;
+
     struct GVJ_s {
        GVJ_t *next;  /* linked list of jobs */
        GVJ_t *next_active;   /* linked list of active jobs (e.g. multiple windows) */
@@ -137,8 +145,9 @@ extern "C" {
        FILE *output_file;
        int output_lang;
 
-       gvplugin_active_device_t device;
        gvplugin_active_render_t render;
+       gvplugin_active_device_t device;
+       gvdevice_callbacks_t *callbacks;
 
 #ifndef DISABLE_CODEGENS
        codegen_t *codegen;     /* current  codegen */
index 4f1dfb0fcc91931afd8a9e284e08309c41dc9928..e898ac44702e619a9326fa3d68f8042527104fe3 100644 (file)
@@ -77,14 +77,18 @@ int gvdevice_features(GVJ_t * job)
     return features;
 }
 
+extern gvdevice_callbacks_t gvdevice_callbacks;
+
 void gvdevice_finalize(GVC_t * gvc)
 {
     GVJ_t *job = gvc->active_jobs;
     gvdevice_engine_t *gvde = job->device.engine;
 
     if (gvde) {
-       if (gvde->finalize)
+       if (gvde->finalize) {
+           job->callbacks = &gvdevice_callbacks;
            gvde->finalize(gvc);
+       }
     }
 #ifndef DISABLE_CODEGENS
     else {
index 1481d90f28e61c268e37ab9039802a09c956fa13..72f718d31f8b6135732a4b59300ceaaf5de0f747 100644 (file)
@@ -23,7 +23,7 @@
 #define ZOOMFACTOR 1.1
 #define EPSILON .0001
 
-void gvevent_refresh(GVJ_t * job)
+static void gvevent_refresh(GVJ_t * job)
 {
     emit_graph(job, job->g);
 }
@@ -283,7 +283,7 @@ static void gvevent_select_current_obj(GVJ_t * job)
         }
     }
 
-#if 0
+#if 1
 for (i = 0; i < job->selected_obj_type_name.argc; i++)
     fprintf(stderr,"%s%s", job->selected_obj_type_name.argv[i],
        (i==(job->selected_obj_type_name.argc - 1))?"\n":" ");
@@ -293,7 +293,7 @@ fprintf(stderr,"\n");
 #endif
 }
 
-void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
+static void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
 {
     switch (button) {
     case 1: /* select / create in edit mode */
@@ -337,7 +337,13 @@ void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
     job->oldpointer = pointer;
 }
 
-void gvevent_motion(GVJ_t * job, pointf pointer)
+static void gvevent_button_release(GVJ_t *job, int button, pointf pointer)
+{
+    job->click = 0;
+    job->active = 0;
+}
+
+static void gvevent_motion(GVJ_t * job, pointf pointer)
 {
     double dx = pointer.x - job->oldpointer.x;
     double dy = pointer.y - job->oldpointer.y;
@@ -363,12 +369,6 @@ void gvevent_motion(GVJ_t * job, pointf pointer)
     job->oldpointer = pointer;
 }
 
-void gvevent_button_release(GVJ_t *job, int button, pointf pointer)
-{
-    job->click = 0;
-    job->active = 0;
-}
-
 static int quit_cb(GVJ_t * job)
 {
     return 1;
@@ -457,3 +457,11 @@ gvevent_key_binding_t gvevent_key_binding[] = {
 };
 
 int gvevent_key_binding_size = ARRAY_SIZE(gvevent_key_binding);
+
+gvdevice_callbacks_t gvdevice_callbacks = {
+    gvevent_refresh,
+    gvevent_button_press,
+    gvevent_button_release,
+    gvevent_motion,
+    NULL,
+};
index c56af4d1e84d136eef1991e4be28e9e4d770a57b..67f3b903678128a85794e7d0b17bece93900090f 100644 (file)
@@ -28,13 +28,6 @@ extern "C" {
        void (*finalize) (GVC_t * gvc);
     };
 
-/* callbacks */
-    extern void gvevent_refresh(GVJ_t * job);
-    extern void gvevent_button_press(GVJ_t * job, int button, pointf pointer);
-    extern void gvevent_button_release(GVJ_t * job, int button, pointf pointer);
-    extern void gvevent_motion(GVJ_t * job, pointf pointer);
-
-
 #ifdef __cplusplus
 }
 #endif