X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/70a23263f2aea090c9134e379601e72131797af2..020b155be89ee1825309eb6d8d1958f3b46c310d:/src/viklayer.h?ds=inline diff --git a/src/viklayer.h b/src/viklayer.h index 22404e2b..f08658ae 100644 --- a/src/viklayer.h +++ b/src/viklayer.h @@ -18,11 +18,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -#include - #ifndef _VIKING_LAYER_H #define _VIKING_LAYER_H +#include +#include +#include +#include + +#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)) @@ -56,29 +63,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 +115,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 +175,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 *); @@ -166,6 +185,8 @@ typedef const gchar * (*VikLayerFuncSublayerRenameRequest) (VikLayer *,const gch 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 *); @@ -176,8 +197,12 @@ typedef VikLayerParamData 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); /* treeview drag and drop method. called on the destination layer. it is given a source and destination layer, @@ -185,6 +210,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; @@ -202,6 +235,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; @@ -211,12 +247,17 @@ 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; VikLayerFuncSublayerToggleVisible sublayer_toggle_visible; VikLayerFuncCopy copy; + VikLayerFuncMarshall marshall; + VikLayerFuncUnmarshall unmarshall; /* for I/O */ VikLayerFuncSetParam set_param; @@ -226,6 +267,7 @@ struct _VikLayerInterface { VikLayerFuncReadFileData read_file_data; VikLayerFuncWriteFileData write_file_data; + VikLayerFuncDeleteItem delete_item; VikLayerFuncCopyItem copy_item; VikLayerFuncPasteItem paste_item; VikLayerFuncFreeCopiedItem free_copied_item; @@ -247,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_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 ); @@ -257,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 ); +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 );