]> git.street.me.uk Git - andy/viking.git/blobdiff - src/viklayer.h
Using the new icon
[andy/viking.git] / src / viklayer.h
index bee0495770f5dd67cfd90a5d5718341468e284dc..f08658aec4c8fcf86f200d9c4e6f607df514bfb9 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
-
 #ifndef _VIKING_LAYER_H
 #define _VIKING_LAYER_H
 
 #ifndef _VIKING_LAYER_H
 #define _VIKING_LAYER_H
 
+#include <stdio.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixdata.h>
+
+#include "vikwindow.h"
+#include "viktreeview.h"
+#include "vikviewport.h"
+
 #define VIK_LAYER_TYPE            (vik_layer_get_type ())
 #define VIK_LAYER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_LAYER_TYPE, VikLayer))
 #define VIK_LAYER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_LAYER_TYPE, VikLayerClass))
 #define VIK_LAYER_TYPE            (vik_layer_get_type ())
 #define VIK_LAYER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_LAYER_TYPE, VikLayer))
 #define VIK_LAYER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_LAYER_TYPE, VikLayerClass))
@@ -55,29 +63,39 @@ struct _VikLayer {
 
 
 enum {
 
 
 enum {
-VIK_LAYER_AGGREGATE = 0,
-VIK_LAYER_TRW,
-VIK_LAYER_COORD,
-VIK_LAYER_GEOREF,
-VIK_LAYER_MAPS,
-VIK_LAYER_NUM_TYPES
+  VIK_LAYER_AGGREGATE = 0,
+  VIK_LAYER_TRW,
+  VIK_LAYER_COORD,
+  VIK_LAYER_GEOREF,
+  VIK_LAYER_GPS,
+  VIK_LAYER_MAPS,
+  VIK_LAYER_NUM_TYPES
 };
 
 };
 
-typedef enum { VIK_LAYER_TOOL_IGNORED=0,
-               VIK_LAYER_TOOL_ACK,
-               VIK_LAYER_TOOL_ACK_REDRAW_ABOVE,
-               VIK_LAYER_TOOL_ACK_REDRAW_ALL,
-               VIK_LAYER_TOOL_ACK_REDRAW_IF_VISIBLE }
-        VikLayerToolFuncStatus;
-typedef VikLayerToolFuncStatus (*VikToolInterfaceFunc) (VikLayer *,GdkEventButton *,gpointer);
+typedef enum { 
+  VIK_LAYER_TOOL_IGNORED=0,
+  VIK_LAYER_TOOL_ACK,
+  VIK_LAYER_TOOL_ACK_REDRAW_ABOVE,
+  VIK_LAYER_TOOL_ACK_REDRAW_ALL,
+  VIK_LAYER_TOOL_ACK_REDRAW_IF_VISIBLE 
+} VikLayerToolFuncStatus;
 
 
-/* gpointer is viewport */
+/* gpointer is tool-specific state created in the constructor */
+typedef gpointer (*VikToolConstructorFunc) (VikWindow *, VikViewport *);
+typedef void (*VikToolDestructorFunc) (gpointer);
+typedef VikLayerToolFuncStatus (*VikToolMouseFunc) (VikLayer *, GdkEventButton *, gpointer);
+typedef void (*VikToolActivationFunc) (VikLayer *, gpointer);
 
 typedef struct _VikToolInterface VikToolInterface;
 struct _VikToolInterface {
   gchar *name;
 
 typedef struct _VikToolInterface VikToolInterface;
 struct _VikToolInterface {
   gchar *name;
-  VikToolInterfaceFunc callback;
-  VikToolInterfaceFunc callback_release;
+  VikToolConstructorFunc create;
+  VikToolDestructorFunc destroy;
+  VikToolActivationFunc activate;
+  VikToolActivationFunc deactivate;
+  VikToolMouseFunc click;
+  VikToolMouseFunc move;
+  VikToolMouseFunc release;
 };
 
 /* Parameters (for I/O and Properties) */
 };
 
 /* Parameters (for I/O and Properties) */
@@ -97,8 +115,8 @@ typedef struct {
   gint16 group;
   const gchar *title;
   guint8 widget_type;
   gint16 group;
   const gchar *title;
   guint8 widget_type;
-  const gpointer widget_data;
-  const gpointer extra_widget_data;
+  gpointer widget_data;
+  gpointer extra_widget_data;
 } VikLayerParam;
 
 enum {
 } VikLayerParam;
 
 enum {
@@ -157,6 +175,8 @@ typedef gboolean      (*VikLayerFuncProperties)            (VikLayer *,VikViewpo
 typedef void          (*VikLayerFuncDraw)                  (VikLayer *,VikViewport *);
 typedef void          (*VikLayerFuncChangeCoordMode)       (VikLayer *,VikCoordMode);
 
 typedef void          (*VikLayerFuncDraw)                  (VikLayer *,VikViewport *);
 typedef void          (*VikLayerFuncChangeCoordMode)       (VikLayer *,VikCoordMode);
 
+typedef void          (*VikLayerFuncSetMenuItemsSelection)          (VikLayer *,guint16);
+typedef guint16          (*VikLayerFuncGetMenuItemsSelection)          (VikLayer *);
 typedef void          (*VikLayerFuncAddMenuItems)          (VikLayer *,GtkMenu *,gpointer); /* gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerAddMenuItems)  (VikLayer *,GtkMenu *,gpointer, /* first gpointer is a VikLayersPanel */
                                                             gint,gpointer,GtkTreeIter *);
 typedef void          (*VikLayerFuncAddMenuItems)          (VikLayer *,GtkMenu *,gpointer); /* gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerAddMenuItems)  (VikLayer *,GtkMenu *,gpointer, /* first gpointer is a VikLayersPanel */
                                                             gint,gpointer,GtkTreeIter *);
@@ -165,6 +185,8 @@ typedef const gchar * (*VikLayerFuncSublayerRenameRequest) (VikLayer *,const gch
 typedef gboolean      (*VikLayerFuncSublayerToggleVisible) (VikLayer *,gint,gpointer);
 
 typedef VikLayer *    (*VikLayerFuncCopy)                  (VikLayer *,VikViewport *);
 typedef gboolean      (*VikLayerFuncSublayerToggleVisible) (VikLayer *,gint,gpointer);
 
 typedef VikLayer *    (*VikLayerFuncCopy)                  (VikLayer *,VikViewport *);
+typedef void          (*VikLayerFuncMarshall)              (VikLayer *, guint8 **, gint *);
+typedef VikLayer *    (*VikLayerFuncUnmarshall)            (guint8 *, gint, VikViewport *);
 
 /* returns TRUE if needs to redraw due to changed param */
 typedef gboolean      (*VikLayerFuncSetParam)              (VikLayer *, guint16, VikLayerParamData, VikViewport *);
 
 /* returns TRUE if needs to redraw due to changed param */
 typedef gboolean      (*VikLayerFuncSetParam)              (VikLayer *, guint16, VikLayerParamData, VikViewport *);
@@ -175,10 +197,27 @@ typedef VikLayerParamData
 typedef void          (*VikLayerFuncReadFileData)          (VikLayer *, FILE *);
 typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 
 typedef void          (*VikLayerFuncReadFileData)          (VikLayer *, FILE *);
 typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 
-typedef gpointer      (*VikLayerFuncCopyItem)              (VikLayer *, gint, gpointer);
-typedef gboolean      (*VikLayerFuncPasteItem)             (VikLayer *, gint, gpointer);
+/* item manipulation */
+typedef void          (*VikLayerFuncDeleteItem)            (VikLayer *, gint, gpointer);
+                                                         /*      layer, subtype, pointer to sub-item */
+typedef void          (*VikLayerFuncCopyItem)              (VikLayer *, gint, gpointer, guint8 **, guint *);
+                                                         /*      layer, subtype, pointer to sub-item, return pointer, return len */
+typedef gboolean      (*VikLayerFuncPasteItem)             (VikLayer *, gint, guint8 *, guint);
 typedef void          (*VikLayerFuncFreeCopiedItem)        (gint, gpointer);
 
 typedef void          (*VikLayerFuncFreeCopiedItem)        (gint, gpointer);
 
+/* treeview drag and drop method. called on the destination layer. it is given a source and destination layer, 
+ * and the source and destination iters in the treeview. 
+ */
+typedef void         (*VikLayerFuncDragDropRequest)       (VikLayer *, VikLayer *, GtkTreeIter *, GtkTreePath *);
+
+typedef enum {
+  VIK_MENU_ITEM_PROPERTY=1,
+  VIK_MENU_ITEM_CUT=2,
+  VIK_MENU_ITEM_COPY=4,
+  VIK_MENU_ITEM_PASTE=8,
+  VIK_MENU_ITEM_DELETE=16,
+  VIK_MENU_ITEM_ALL=0xff
+} VikStdLayerMenuItem;
 
 typedef struct _VikLayerInterface VikLayerInterface;
 
 
 typedef struct _VikLayerInterface VikLayerInterface;
 
@@ -196,6 +235,9 @@ struct _VikLayerInterface {
   gchar **                          params_groups;
   guint8                            params_groups_count;
 
   gchar **                          params_groups;
   guint8                            params_groups_count;
 
+  /* menu items to be created */
+  VikStdLayerMenuItem               menu_items_selection;
+
   VikLayerFuncCreate                create;
   VikLayerFuncRealize               realize;
   VikLayerFuncPostRead              post_read;
   VikLayerFuncCreate                create;
   VikLayerFuncRealize               realize;
   VikLayerFuncPostRead              post_read;
@@ -205,12 +247,17 @@ struct _VikLayerInterface {
   VikLayerFuncDraw                  draw;
   VikLayerFuncChangeCoordMode       change_coord_mode;
 
   VikLayerFuncDraw                  draw;
   VikLayerFuncChangeCoordMode       change_coord_mode;
 
+  VikLayerFuncSetMenuItemsSelection set_menu_selection;
+  VikLayerFuncGetMenuItemsSelection get_menu_selection;
+
   VikLayerFuncAddMenuItems          add_menu_items;
   VikLayerFuncSublayerAddMenuItems  sublayer_add_menu_items;
   VikLayerFuncSublayerRenameRequest sublayer_rename_request;
   VikLayerFuncSublayerToggleVisible sublayer_toggle_visible;
 
   VikLayerFuncCopy                  copy;
   VikLayerFuncAddMenuItems          add_menu_items;
   VikLayerFuncSublayerAddMenuItems  sublayer_add_menu_items;
   VikLayerFuncSublayerRenameRequest sublayer_rename_request;
   VikLayerFuncSublayerToggleVisible sublayer_toggle_visible;
 
   VikLayerFuncCopy                  copy;
+  VikLayerFuncMarshall              marshall;
+  VikLayerFuncUnmarshall            unmarshall;
 
   /* for I/O */
   VikLayerFuncSetParam              set_param;
 
   /* for I/O */
   VikLayerFuncSetParam              set_param;
@@ -220,9 +267,12 @@ struct _VikLayerInterface {
   VikLayerFuncReadFileData          read_file_data;
   VikLayerFuncWriteFileData         write_file_data;
 
   VikLayerFuncReadFileData          read_file_data;
   VikLayerFuncWriteFileData         write_file_data;
 
+  VikLayerFuncDeleteItem            delete_item;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
+
+  VikLayerFuncDragDropRequest       drag_drop_request;
 };
 
 VikLayerInterface *vik_layer_get_interface ( gint type );
 };
 
 VikLayerInterface *vik_layer_get_interface ( gint type );
@@ -239,6 +289,8 @@ gboolean vik_layer_set_param (VikLayer *layer, guint16 id, VikLayerParamData dat
 void vik_layer_emit_update ( VikLayer *vl );
 
 /* GUI */
 void vik_layer_emit_update ( VikLayer *vl );
 
 /* GUI */
+void vik_layer_set_menu_items_selection(VikLayer *l, guint16 selection);
+guint16 vik_layer_get_menu_items_selection(VikLayer *l);
 void vik_layer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp );
 VikLayer *vik_layer_create ( gint type, gpointer vp, GtkWindow *w, gboolean interactive );
 gboolean vik_layer_properties ( VikLayer *layer, gpointer vp );
 void vik_layer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp );
 VikLayer *vik_layer_create ( gint type, gpointer vp, GtkWindow *w, gboolean interactive );
 gboolean vik_layer_properties ( VikLayer *layer, gpointer vp );
@@ -249,6 +301,10 @@ void vik_layer_post_read ( VikLayer *layer, gpointer vp );
 gboolean vik_layer_sublayer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter );
 
 VikLayer *vik_layer_copy ( VikLayer *vl, gpointer vp );
 gboolean vik_layer_sublayer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter );
 
 VikLayer *vik_layer_copy ( VikLayer *vl, gpointer vp );
+void      vik_layer_marshall ( VikLayer *vl, guint8 **data, gint *len );
+VikLayer *vik_layer_unmarshall ( guint8 *data, gint len, VikViewport *vvp );
+void      vik_layer_marshall_params ( VikLayer *vl, guint8 **data, gint *len );
+void      vik_layer_unmarshall_params ( VikLayer *vl, guint8 *data, gint len, VikViewport *vvp );
 
 const gchar *vik_layer_sublayer_rename_request ( VikLayer *l, const gchar *newname, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter );
 
 
 const gchar *vik_layer_sublayer_rename_request ( VikLayer *l, const gchar *newname, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter );