]> git.street.me.uk Git - andy/viking.git/blobdiff - src/viklayer.h
Use the last selected date when initializing the date search.
[andy/viking.git] / src / viklayer.h
index bae2e7fb6e0eacfa954eefde84a230a5c3340805..f7d16a9120c1d8c4b5742efb68408633328bd2a2 100644 (file)
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 
+#include "uibuilder.h"
 #include "vikwindow.h"
 #include "viktreeview.h"
 #include "vikviewport.h"
 
 #include "vikwindow.h"
 #include "viktreeview.h"
 #include "vikviewport.h"
 
+G_BEGIN_DECLS
+
 #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))
@@ -53,119 +56,59 @@ struct _VikLayer {
   gboolean visible;
 
   gboolean realized;
   gboolean visible;
 
   gboolean realized;
+  VikViewport *vvp;/* simply a reference */
   VikTreeview *vt; /* simply a reference */
   GtkTreeIter iter;
 
   /* for explicit "polymorphism" (function type switching) */
   VikTreeview *vt; /* simply a reference */
   GtkTreeIter iter;
 
   /* for explicit "polymorphism" (function type switching) */
-  guint16 type;
-};
-
-
-
-enum {
-  VIK_LAYER_AGGREGATE = 0,
-  VIK_LAYER_TRW,
-  VIK_LAYER_COORD,
-  VIK_LAYER_GEOREF,
-  VIK_LAYER_GPS,
-  VIK_LAYER_MAPS,
-  VIK_LAYER_DEM,
-  VIK_LAYER_NUM_TYPES
+  VikLayerTypeEnum type;
 };
 
 };
 
+/* I think most of these are ignored,
+ * returning GRAB_FOCUS grabs the focus for mouse move,
+ * mouse click, release always grabs focus. Focus allows key presses
+ * to be handled.
+ * It used to be that, if ignored, Viking could look for other layers.
+ * this was useful for clicking a way/trackpoint in any layer,
+ * if no layer was selected (find way/trackpoint)
+ */
 typedef enum { 
   VIK_LAYER_TOOL_IGNORED=0,
   VIK_LAYER_TOOL_ACK,
   VIK_LAYER_TOOL_ACK_REDRAW_ABOVE,
   VIK_LAYER_TOOL_ACK_REDRAW_ALL,
 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 
+  VIK_LAYER_TOOL_ACK_REDRAW_IF_VISIBLE,
+  VIK_LAYER_TOOL_ACK_GRAB_FOCUS, /* only for move */
 } VikLayerToolFuncStatus;
 
 /* gpointer is tool-specific state created in the constructor */
 typedef gpointer (*VikToolConstructorFunc) (VikWindow *, VikViewport *);
 typedef void (*VikToolDestructorFunc) (gpointer);
 typedef VikLayerToolFuncStatus (*VikToolMouseFunc) (VikLayer *, GdkEventButton *, gpointer);
 } VikLayerToolFuncStatus;
 
 /* 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 VikLayerToolFuncStatus (*VikToolMouseMoveFunc) (VikLayer *, GdkEventMotion *, gpointer);
 typedef void (*VikToolActivationFunc) (VikLayer *, gpointer);
 typedef gboolean (*VikToolKeyFunc) (VikLayer *, GdkEventKey *, gpointer);
 
 typedef struct _VikToolInterface VikToolInterface;
 struct _VikToolInterface {
 typedef void (*VikToolActivationFunc) (VikLayer *, gpointer);
 typedef gboolean (*VikToolKeyFunc) (VikLayer *, GdkEventKey *, gpointer);
 
 typedef struct _VikToolInterface VikToolInterface;
 struct _VikToolInterface {
-  gchar *name;
+  GtkRadioActionEntry radioActionEntry;
   VikToolConstructorFunc create;
   VikToolDestructorFunc destroy;
   VikToolActivationFunc activate;
   VikToolActivationFunc deactivate;
   VikToolMouseFunc click;
   VikToolConstructorFunc create;
   VikToolDestructorFunc destroy;
   VikToolActivationFunc activate;
   VikToolActivationFunc deactivate;
   VikToolMouseFunc click;
-  VikToolMouseFunc move;
+  VikToolMouseMoveFunc move;
   VikToolMouseFunc release;
   VikToolMouseFunc release;
-  VikToolKeyFunc key_press; /* return FALSE if we don't use the key press -- should return AFLSE most of the time if we want any shortcuts / UI keybindings to work! use sparingly. */
-  const GdkPixdata *cursor;
+  VikToolKeyFunc key_press; /* return FALSE if we don't use the key press -- should return FALSE most of the time if we want any shortcuts / UI keybindings to work! use sparingly. */
+  gboolean pan_handler; // Call click & release funtions even when 'Pan Mode' is on
+  GdkCursorType cursor_type;
+  const GdkPixdata *cursor_data;
+  const GdkCursor *cursor;
 };
 
 /* Parameters (for I/O and Properties) */
 };
 
 /* Parameters (for I/O and Properties) */
+/* --> moved to uibuilder.h */
 
 
-typedef union {
-  gdouble d;
-  guint32 u;
-  gint32 i;
-  gboolean b;
-  const gchar *s;
-  GdkColor c;
-  GList *sl;
-} VikLayerParamData;
-
-typedef struct {
-  const gchar *name;
-  guint8 type;
-  gint16 group;
-  const gchar *title;
-  guint8 widget_type;
-  gpointer widget_data;
-  gpointer extra_widget_data;
-} VikLayerParam;
-
-enum {
-VIK_LAYER_NOT_IN_PROPERTIES=-2,
-VIK_LAYER_GROUP_NONE=-1
-};
-
-enum {
-VIK_LAYER_WIDGET_CHECKBUTTON=0,
-VIK_LAYER_WIDGET_RADIOGROUP,
-VIK_LAYER_WIDGET_RADIOGROUP_STATIC,
-VIK_LAYER_WIDGET_SPINBUTTON,
-VIK_LAYER_WIDGET_ENTRY,
-VIK_LAYER_WIDGET_FILEENTRY,
-VIK_LAYER_WIDGET_HSCALE,
-VIK_LAYER_WIDGET_COLOR,
-VIK_LAYER_WIDGET_COMBOBOX,
-VIK_LAYER_WIDGET_FILELIST,
-};
-
-typedef struct {
-  gdouble min;
-  gdouble max;
-  gdouble step;
-  guint8 digits;
-} VikLayerParamScale;
-
-/* id is index */
-enum {
-VIK_LAYER_PARAM_DOUBLE=1,
-VIK_LAYER_PARAM_UINT,
-VIK_LAYER_PARAM_INT,
-VIK_LAYER_PARAM_STRING,
-VIK_LAYER_PARAM_BOOLEAN,
-VIK_LAYER_PARAM_COLOR,
-
-/* NOTE: string layer works auniquely: data.sl should NOT be free'd when
- * the internals call get_param -- i.e. it should be managed w/in the layer.
- * The value passed by the internals into set_param should also be managed
- * by the layer -- i.e. free'd by the layer.
- */
-
-VIK_LAYER_PARAM_STRING_LIST,
-};
 
 /* layer interface functions */
 
 
 /* layer interface functions */
 
@@ -192,28 +135,37 @@ typedef void          (*VikLayerFuncChangeCoordMode)       (VikLayer *,VikCoordM
 
 typedef void          (*VikLayerFuncSetMenuItemsSelection)          (VikLayer *,guint16);
 typedef guint16          (*VikLayerFuncGetMenuItemsSelection)          (VikLayer *);
 
 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 */
 typedef void          (*VikLayerFuncAddMenuItems)          (VikLayer *,GtkMenu *,gpointer); /* gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerAddMenuItems)  (VikLayer *,GtkMenu *,gpointer, /* first gpointer is a VikLayersPanel */
-                                                            gint,gpointer,GtkTreeIter *);
+                                                            gint,gpointer,GtkTreeIter *,VikViewport *);
 typedef const gchar * (*VikLayerFuncSublayerRenameRequest) (VikLayer *,const gchar *,gpointer,
                                                             gint,VikViewport *,GtkTreeIter *); /* first gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerToggleVisible) (VikLayer *,gint,gpointer);
 typedef const gchar * (*VikLayerFuncSublayerRenameRequest) (VikLayer *,const gchar *,gpointer,
                                                             gint,VikViewport *,GtkTreeIter *); /* first gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerToggleVisible) (VikLayer *,gint,gpointer);
+typedef const gchar * (*VikLayerFuncSublayerTooltip)       (VikLayer *,gint,gpointer);
+typedef const gchar * (*VikLayerFuncLayerTooltip)          (VikLayer *);
+typedef gboolean      (*VikLayerFuncLayerSelected)         (VikLayer *,gint,gpointer,gint,gpointer); /* 2nd gpointer is a VikLayersPanel */
 
 typedef void          (*VikLayerFuncMarshall)              (VikLayer *, guint8 **, gint *);
 typedef VikLayer *    (*VikLayerFuncUnmarshall)            (guint8 *, gint, VikViewport *);
 
 /* returns TRUE if needs to redraw due to changed param */
 
 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 *);
+/* in parameter gboolean denotes if for file I/O, as opposed to display/cut/copy etc... operations */
+typedef gboolean      (*VikLayerFuncSetParam)              (VikLayer *, guint16, VikLayerParamData, VikViewport *, gboolean);
 
 
+/* in parameter gboolean denotes if for file I/O, as opposed to display/cut/copy etc... operations */
 typedef VikLayerParamData
 typedef VikLayerParamData
-                      (*VikLayerFuncGetParam)              (VikLayer *, guint16);
+                      (*VikLayerFuncGetParam)              (VikLayer *, guint16, gboolean);
+
+typedef void          (*VikLayerFuncChangeParam)           (GtkWidget *, ui_change_values );
 
 
-typedef void          (*VikLayerFuncReadFileData)          (VikLayer *, FILE *);
+typedef gboolean      (*VikLayerFuncReadFileData)          (VikLayer *, FILE *, const gchar *); // gchar* is the directory path. Function should report success or failure
 typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 
 /* item manipulation */
 typedef void          (*VikLayerFuncDeleteItem)            (VikLayer *, gint, gpointer);
                                                          /*      layer, subtype, pointer to sub-item */
 typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 
 /* item manipulation */
 typedef void          (*VikLayerFuncDeleteItem)            (VikLayer *, gint, gpointer);
                                                          /*      layer, subtype, pointer to sub-item */
+typedef void          (*VikLayerFuncCutItem)               (VikLayer *, gint, gpointer);
 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          (*VikLayerFuncCopyItem)              (VikLayer *, gint, gpointer, guint8 **, guint *);
                                                          /*      layer, subtype, pointer to sub-item, return pointer, return len */
 typedef gboolean      (*VikLayerFuncPasteItem)             (VikLayer *, gint, guint8 *, guint);
@@ -224,6 +176,11 @@ typedef void          (*VikLayerFuncFreeCopiedItem)        (gint, gpointer);
  */
 typedef void         (*VikLayerFuncDragDropRequest)       (VikLayer *, VikLayer *, GtkTreeIter *, GtkTreePath *);
 
  */
 typedef void         (*VikLayerFuncDragDropRequest)       (VikLayer *, VikLayer *, GtkTreeIter *, GtkTreePath *);
 
+typedef gboolean      (*VikLayerFuncSelectClick)           (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
+typedef gboolean      (*VikLayerFuncSelectMove)            (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
+typedef gboolean      (*VikLayerFuncSelectRelease)         (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
+typedef gboolean      (*VikLayerFuncSelectedViewportMenu)  (VikLayer *, GdkEventButton *, VikViewport *);
+
 typedef enum {
   VIK_MENU_ITEM_PROPERTY=1,
   VIK_MENU_ITEM_CUT=2,
 typedef enum {
   VIK_MENU_ITEM_PROPERTY=1,
   VIK_MENU_ITEM_CUT=2,
@@ -237,7 +194,9 @@ typedef struct _VikLayerInterface VikLayerInterface;
 
 /* See vik_layer_* for function parameter names */
 struct _VikLayerInterface {
 
 /* See vik_layer_* for function parameter names */
 struct _VikLayerInterface {
-  const gchar *                     name;
+  const gchar *                     fixed_layer_name; // Used in .vik files - this should never change to maintain file compatibility
+  const gchar *                     name;             // Translate-able name used for display purposes
+  const gchar *                     accelerator;
   const GdkPixdata *                icon;
 
   VikToolInterface *                tools;
   const GdkPixdata *                icon;
 
   VikToolInterface *                tools;
@@ -268,6 +227,9 @@ struct _VikLayerInterface {
   VikLayerFuncSublayerAddMenuItems  sublayer_add_menu_items;
   VikLayerFuncSublayerRenameRequest sublayer_rename_request;
   VikLayerFuncSublayerToggleVisible sublayer_toggle_visible;
   VikLayerFuncSublayerAddMenuItems  sublayer_add_menu_items;
   VikLayerFuncSublayerRenameRequest sublayer_rename_request;
   VikLayerFuncSublayerToggleVisible sublayer_toggle_visible;
+  VikLayerFuncSublayerTooltip       sublayer_tooltip;
+  VikLayerFuncLayerTooltip          layer_tooltip;
+  VikLayerFuncLayerSelected         layer_selected;
 
   VikLayerFuncMarshall              marshall;
   VikLayerFuncUnmarshall            unmarshall;
 
   VikLayerFuncMarshall              marshall;
   VikLayerFuncUnmarshall            unmarshall;
@@ -275,30 +237,39 @@ struct _VikLayerInterface {
   /* for I/O */
   VikLayerFuncSetParam              set_param;
   VikLayerFuncGetParam              get_param;
   /* for I/O */
   VikLayerFuncSetParam              set_param;
   VikLayerFuncGetParam              get_param;
+  VikLayerFuncChangeParam           change_param;
 
   /* for I/O -- extra non-param data like TrwLayer data */
   VikLayerFuncReadFileData          read_file_data;
   VikLayerFuncWriteFileData         write_file_data;
 
   VikLayerFuncDeleteItem            delete_item;
 
   /* for I/O -- extra non-param data like TrwLayer data */
   VikLayerFuncReadFileData          read_file_data;
   VikLayerFuncWriteFileData         write_file_data;
 
   VikLayerFuncDeleteItem            delete_item;
+  VikLayerFuncCutItem               cut_item;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
 
   VikLayerFuncDragDropRequest       drag_drop_request;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
 
   VikLayerFuncDragDropRequest       drag_drop_request;
+
+  VikLayerFuncSelectClick           select_click;
+  VikLayerFuncSelectMove            select_move;
+  VikLayerFuncSelectRelease         select_release;
+  VikLayerFuncSelectedViewportMenu  show_viewport_menu;
 };
 
 };
 
-VikLayerInterface *vik_layer_get_interface ( gint type );
+VikLayerInterface *vik_layer_get_interface ( VikLayerTypeEnum type );
 
 
 
 
-void vik_layer_init ( VikLayer *vl, gint type );
-void vik_layer_draw ( VikLayer *l, gpointer data );
+void vik_layer_set_type ( VikLayer *vl, VikLayerTypeEnum type );
+void vik_layer_draw ( VikLayer *l, VikViewport *vp );
 void vik_layer_change_coord_mode ( VikLayer *l, VikCoordMode mode );
 void vik_layer_rename ( VikLayer *l, const gchar *new_name );
 void vik_layer_rename_no_copy ( VikLayer *l, gchar *new_name );
 const gchar *vik_layer_get_name ( VikLayer *l );
 
 void vik_layer_change_coord_mode ( VikLayer *l, VikCoordMode mode );
 void vik_layer_rename ( VikLayer *l, const gchar *new_name );
 void vik_layer_rename_no_copy ( VikLayer *l, gchar *new_name );
 const gchar *vik_layer_get_name ( VikLayer *l );
 
-gboolean vik_layer_set_param (VikLayer *layer, guint16 id, VikLayerParamData data, gpointer vp);
+gboolean vik_layer_set_param (VikLayer *layer, guint16 id, VikLayerParamData data, gpointer vp, gboolean is_file_operation);
+
+void vik_layer_set_defaults ( VikLayer *vl, VikViewport *vvp );
 
 void vik_layer_emit_update ( VikLayer *vl );
 
 
 void vik_layer_emit_update ( VikLayer *vl );
 
@@ -306,13 +277,13 @@ void vik_layer_emit_update ( VikLayer *vl );
 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 );
 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 );
+VikLayer *vik_layer_create ( VikLayerTypeEnum type, VikViewport *vp, gboolean interactive );
+gboolean vik_layer_properties ( VikLayer *layer, VikViewport *vp );
 
 void vik_layer_realize ( VikLayer *l, VikTreeview *vt, GtkTreeIter * layer_iter );
 void vik_layer_post_read ( VikLayer *layer, VikViewport *vp, gboolean from_file );
 
 
 void vik_layer_realize ( VikLayer *l, VikTreeview *vt, GtkTreeIter * layer_iter );
 void vik_layer_post_read ( VikLayer *layer, VikViewport *vp, gboolean from_file );
 
-gboolean vik_layer_sublayer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter );
+gboolean vik_layer_sublayer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter, VikViewport *vvp );
 
 VikLayer *vik_layer_copy ( VikLayer *vl, gpointer vp );
 void      vik_layer_marshall ( VikLayer *vl, guint8 **data, gint *len );
 
 VikLayer *vik_layer_copy ( VikLayer *vl, gpointer vp );
 void      vik_layer_marshall ( VikLayer *vl, guint8 **data, gint *len );
@@ -324,18 +295,30 @@ const gchar *vik_layer_sublayer_rename_request ( VikLayer *l, const gchar *newna
 
 gboolean vik_layer_sublayer_toggle_visible ( VikLayer *l, gint subtype, gpointer sublayer );
 
 
 gboolean vik_layer_sublayer_toggle_visible ( VikLayer *l, gint subtype, gpointer sublayer );
 
+const gchar* vik_layer_sublayer_tooltip ( VikLayer *l, gint subtype, gpointer sublayer );
+
+const gchar* vik_layer_layer_tooltip ( VikLayer *l );
+
+gboolean vik_layer_selected ( VikLayer *l, gint subtype, gpointer sublayer, gint type, gpointer vlp );
+
 /* TODO: put in layerspanel */
 /* TODO: put in layerspanel */
-GdkPixbuf *vik_layer_load_icon ( gint type );
+GdkPixbuf *vik_layer_load_icon ( VikLayerTypeEnum type );
 
 VikLayer *vik_layer_get_and_reset_trigger();
 void vik_layer_emit_update_secondary ( VikLayer *vl ); /* to be called by aggregate layer only. doesn't set the trigger */
 void vik_layer_emit_update_although_invisible ( VikLayer *vl );
 
 
 VikLayer *vik_layer_get_and_reset_trigger();
 void vik_layer_emit_update_secondary ( VikLayer *vl ); /* to be called by aggregate layer only. doesn't set the trigger */
 void vik_layer_emit_update_although_invisible ( VikLayer *vl );
 
-GdkCursor *vik_layer_get_tool_cursor ( gint layer_id, gint tool_id );
-void vik_layer_cursors_init();
-void vik_layer_cursors_uninit();
+VikLayerTypeEnum vik_layer_type_from_string ( const gchar *str );
 
 
+typedef struct {
+  VikLayerParamData data;
+  VikLayerParamType type;
+} VikLayerTypedParamData;
 
 
+void vik_layer_typed_param_data_free ( gpointer gp );
+VikLayerTypedParamData *vik_layer_typed_param_data_copy_from_data ( VikLayerParamType type, VikLayerParamData val );
+VikLayerTypedParamData *vik_layer_data_typed_param_copy_from_string ( VikLayerParamType type, const gchar *str );
 
 
+G_END_DECLS
 
 #endif
 
 #endif