X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/941aa6e9dcad8baa3952be9fc50c7635be8eaab4..cca9f97b05c31a51ce886d5b14db93aa741cd95e:/src/viklayer.h?ds=inline diff --git a/src/viklayer.h b/src/viklayer.h index 01331c98..0225fe5e 100644 --- a/src/viklayer.h +++ b/src/viklayer.h @@ -18,12 +18,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -#include -#include "vikwindow.h" - #ifndef _VIKING_LAYER_H #define _VIKING_LAYER_H +#include +#include +#include +#include + +#include "uibuilder.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)) @@ -47,7 +54,7 @@ struct _VikLayer { gboolean visible; gboolean realized; - VikTreeview *vt; /* simply a refernce */ + VikTreeview *vt; /* simply a reference */ GtkTreeIter iter; /* for explicit "polymorphism" (function type switching) */ @@ -61,23 +68,36 @@ enum { VIK_LAYER_TRW, VIK_LAYER_COORD, VIK_LAYER_GEOREF, + VIK_LAYER_GPS, VIK_LAYER_MAPS, + VIK_LAYER_DEM, VIK_LAYER_NUM_TYPES }; +/* 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, - 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); +typedef VikLayerToolFuncStatus (*VikToolMouseMoveFunc) (VikLayer *, GdkEventMotion *, gpointer); typedef void (*VikToolActivationFunc) (VikLayer *, gpointer); +typedef gboolean (*VikToolKeyFunc) (VikLayer *, GdkEventKey *, gpointer); typedef struct _VikToolInterface VikToolInterface; struct _VikToolInterface { @@ -87,63 +107,17 @@ struct _VikToolInterface { VikToolActivationFunc activate; VikToolActivationFunc deactivate; VikToolMouseFunc click; - VikToolMouseFunc move; + VikToolMouseMoveFunc move; 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. */ + GdkCursorType cursor_type; + const GdkPixdata *cursor_data; + const GdkCursor *cursor; }; /* 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; -} VikLayerParamData; - -typedef struct { - const gchar *name; - guint8 type; - gint16 group; - const gchar *title; - guint8 widget_type; - const gpointer widget_data; - const 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_SPINBUTTON, -VIK_LAYER_WIDGET_ENTRY, -VIK_LAYER_WIDGET_FILEENTRY, -VIK_LAYER_WIDGET_HSCALE, -VIK_LAYER_WIDGET_COLOR, -VIK_LAYER_WIDGET_COMBOBOX, -}; - -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, -}; /* layer interface functions */ @@ -157,17 +131,19 @@ typedef void (*VikLayerFuncRealize) (VikLayer *,VikTreevi /* rarely used, this is called after a read operation or properties box is run. * usually used to create GC's that depend on params, * but GC's can also be created from create() or set_param() */ -typedef void (*VikLayerFuncPostRead) (VikLayer *,gpointer vp); +typedef void (*VikLayerFuncPostRead) (VikLayer *,VikViewport *vp,gboolean from_file); typedef void (*VikLayerFuncFree) (VikLayer *); /* do _not_ use this unless absolutely neccesary. Use the dynamic properties (see coordlayer for example) * returns TRUE if OK was pressed */ -typedef gboolean (*VikLayerFuncProperties) (VikLayer *,VikViewport *); /* gpointer is a VikViewport */ +typedef gboolean (*VikLayerFuncProperties) (VikLayer *,VikViewport *); 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 *); @@ -175,7 +151,6 @@ typedef const gchar * (*VikLayerFuncSublayerRenameRequest) (VikLayer *,const gch gint,VikViewport *,GtkTreeIter *); /* first gpointer is a VikLayersPanel */ typedef gboolean (*VikLayerFuncSublayerToggleVisible) (VikLayer *,gint,gpointer); -typedef VikLayer * (*VikLayerFuncCopy) (VikLayer *,VikViewport *); typedef void (*VikLayerFuncMarshall) (VikLayer *, guint8 **, gint *); typedef VikLayer * (*VikLayerFuncUnmarshall) (guint8 *, gint, VikViewport *); @@ -188,7 +163,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); @@ -197,6 +176,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; @@ -214,6 +201,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; @@ -223,12 +213,14 @@ 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; @@ -240,6 +232,7 @@ struct _VikLayerInterface { VikLayerFuncReadFileData read_file_data; VikLayerFuncWriteFileData write_file_data; + VikLayerFuncDeleteItem delete_item; VikLayerFuncCopyItem copy_item; VikLayerFuncPasteItem paste_item; VikLayerFuncFreeCopiedItem free_copied_item; @@ -255,18 +248,21 @@ void vik_layer_draw ( VikLayer *l, gpointer data ); 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); 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_realize ( VikLayer *l, VikTreeview *vt, GtkTreeIter * layer_iter ); -void vik_layer_post_read ( VikLayer *layer, gpointer vp ); +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 ); @@ -283,4 +279,8 @@ gboolean vik_layer_sublayer_toggle_visible ( VikLayer *l, gint subtype, gpointer /* TODO: put in layerspanel */ GdkPixbuf *vik_layer_load_icon ( gint 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 ); + #endif