]> git.street.me.uk Git - andy/viking.git/blobdiff - src/viklayer.h
Simplify tools enable/disable codes
[andy/viking.git] / src / viklayer.h
index 4ea4368d2d286174cd2ac75dfc2af44d0165f173..f81c5c5e35e92e421822d920e2505e15b04cc524 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
-#include <stdio.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 IS_VIK_LAYER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIK_LAYER_TYPE))
 #define IS_VIK_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIK_LAYER_TYPE))
 
-typedef struct _VikLayer VikLayer;
 typedef struct _VikLayerClass VikLayerClass;
 
 struct _VikLayerClass
@@ -56,29 +62,39 @@ struct _VikLayer {
 
 
 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;
-  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) */
@@ -98,8 +114,8 @@ typedef struct {
   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 {
@@ -158,6 +174,8 @@ typedef gboolean      (*VikLayerFuncProperties)            (VikLayer *,VikViewpo
 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 *);
@@ -178,7 +196,11 @@ typedef VikLayerParamData
 typedef void          (*VikLayerFuncReadFileData)          (VikLayer *, FILE *);
 typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 
+/* 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);
 
@@ -187,6 +209,14 @@ typedef void          (*VikLayerFuncFreeCopiedItem)        (gint, gpointer);
  */
 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;
 
@@ -204,6 +234,9 @@ struct _VikLayerInterface {
   gchar **                          params_groups;
   guint8                            params_groups_count;
 
+  /* menu items to be created */
+  VikStdLayerMenuItem               menu_items_selection;
+
   VikLayerFuncCreate                create;
   VikLayerFuncRealize               realize;
   VikLayerFuncPostRead              post_read;
@@ -213,6 +246,9 @@ struct _VikLayerInterface {
   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;
@@ -230,6 +266,7 @@ struct _VikLayerInterface {
   VikLayerFuncReadFileData          read_file_data;
   VikLayerFuncWriteFileData         write_file_data;
 
+  VikLayerFuncDeleteItem            delete_item;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
@@ -251,6 +288,8 @@ gboolean vik_layer_set_param (VikLayer *layer, guint16 id, VikLayerParamData dat
 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 );