NULL);
g_object_set_data (G_OBJECT (highlight), "object", object);
+ g_object_set_data (G_OBJECT (highlight), "view", view);
g_object_set_data (G_OBJECT (highlight), "outline", outline);
g_signal_connect (G_OBJECT (outline), "event",
G_CALLBACK (passthrough_event_handler), view_object);
+ /* send to top, then lower below all items that form the foregound */
gnome_canvas_item_raise_to_top (highlight);
+ gl_view_raise_fg (view);
gl_debug (DEBUG_VIEW, "END");
NULL);
g_object_set_data (G_OBJECT (highlight), "object", object);
+ g_object_set_data (G_OBJECT (highlight), "view", view);
g_object_set_data (G_OBJECT (highlight), "outline", outline);
gnome_canvas_points_free (points);
+ /* send to top, then lower below all items that form the foregound */
gnome_canvas_item_raise_to_top (highlight);
+ gl_view_raise_fg (view);
gl_debug (DEBUG_VIEW, "END");
NULL);
- g_object_set_data (G_OBJECT (highlight), "outline", outline);
-
g_object_set_data (G_OBJECT (highlight), "object", object);
+ g_object_set_data (G_OBJECT (highlight), "view", view);
+
+ g_object_set_data (G_OBJECT (highlight), "outline", outline);
g_signal_connect (G_OBJECT (highlight), "event",
G_CALLBACK (passthrough_event_handler), view_object);
+ /* send to top, then lower below all items that form the foregound */
gnome_canvas_item_raise_to_top (highlight);
+ gl_view_raise_fg (view);
gl_debug (DEBUG_VIEW, "END");
glViewHighlightStyle style)
{
glLabelObject *object;
+ glView *view;
gdouble w, h;
GnomeCanvasItem *outline; /* Outline around item */
GnomeCanvasItem *tl, *tr, *bl, *br; /* Handles at four corners */
object = g_object_get_data (G_OBJECT (highlight), "object");
gl_label_object_get_size (object, &w, &h);
+ view = g_object_get_data (G_OBJECT (highlight), "view");
+
outline = g_object_get_data (G_OBJECT (highlight), "outline");
tl = g_object_get_data (G_OBJECT (highlight), "tl");
"y2", h + 1.0,
NULL);
+ /* send to top, then lower below all items that form the foregound */
gnome_canvas_item_raise_to_top (highlight);
+ gl_view_raise_fg (view);
gl_debug (DEBUG_VIEW, "END");
}
update_resizable_line (GnomeCanvasItem *highlight)
{
glLabelObject *object;
+ glView *view;
gdouble dx, dy;
GnomeCanvasPoints *points;
GnomeCanvasItem *outline; /* Outline around item */
object = g_object_get_data (G_OBJECT (highlight), "object");
gl_label_object_get_size (object, &dx, &dy);
+ view = g_object_get_data (G_OBJECT (highlight), "view");
+
points = gnome_canvas_points_new (2);
outline = g_object_get_data (G_OBJECT (highlight), "outline");
gnome_canvas_points_free (points);
+ /* send to top, then lower below all items that form the foregound */
gnome_canvas_item_raise_to_top (highlight);
+ gl_view_raise_fg (view);
gl_debug (DEBUG_VIEW, "END");
}
update_simple (GnomeCanvasItem *highlight)
{
glLabelObject *object;
+ glView *view;
gdouble w, h;
GnomeCanvasItem *outline; /* Outline around item */
object = g_object_get_data (G_OBJECT (highlight), "object");
gl_label_object_get_size (object, &w, &h);
+ view = g_object_get_data (G_OBJECT (highlight), "view");
+
outline = g_object_get_data (G_OBJECT (highlight), "outline");
gnome_canvas_item_set (outline,
"y2", h + 0.5,
NULL);
+ /* send to top, then lower below all items that form the foregound */
gnome_canvas_item_raise_to_top (highlight);
+ gl_view_raise_fg (view);
gl_debug (DEBUG_VIEW, "END");
}
static GdkAtom clipboard_atom = GDK_NONE;
#define HOME_SCALE 2.0
-static gdouble scales[] = { 8.0, 6.0, 4.0, 3.0,
+static gdouble scales[] = {
+ 8.0, 6.0, 4.0, 3.0,
2.0,
1.5, 1.0, 0.5, 0.25,
0.0
/* Local function prototypes */
/*===========================================*/
-static void gl_view_class_init (glViewClass *class);
-static void gl_view_init (glView * view);
-static void gl_view_finalize (GObject * object);
+static void gl_view_class_init (glViewClass *class);
+static void gl_view_init (glView *view);
+static void gl_view_finalize (GObject *object);
static void gl_view_construct (glView *view);
static GtkWidget *gl_view_construct_canvas (glView *view);
static void gl_view_construct_selection (glView *view);
-static gdouble get_apropriate_scale (gdouble w, gdouble h);
+static gdouble get_apropriate_scale (gdouble w, gdouble h);
-static void draw_rect_bg (glView * view);
-static void draw_rounded_rect_bg (glView * view);
-static void draw_round_bg (glView * view);
-static void draw_cd_bg (glView * view);
+static void draw_rect_bg_fg (glView *view);
+static void draw_rounded_rect_bg_fg (glView *view);
+static void draw_round_bg_fg (glView *view);
+static void draw_cd_bg_fg (glView *view);
-static int canvas_event (GnomeCanvas * canvas,
- GdkEvent * event,
- glView *view);
-static int canvas_event_arrow_mode (GnomeCanvas * canvas,
- GdkEvent * event, glView *view);
+static int canvas_event (GnomeCanvas *canvas,
+ GdkEvent *event,
+ glView *view);
+static int canvas_event_arrow_mode (GnomeCanvas *canvas,
+ GdkEvent *event,
+ glView *view);
-static void select_region (glView * view,
+static void select_region (glView *view,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
-static void select_object (glViewObject *view_object);
-static void unselect_object (glViewObject *view_object);
-static gboolean object_at (glView * view,
+static void select_object (glViewObject *view_object);
+static void unselect_object (glViewObject *view_object);
+static gboolean object_at (glView *view,
gdouble x, gdouble y);
-static gboolean object_selected (glViewObject *view_object);
-static gboolean multiple_items_selected (glView * view);
+static gboolean object_selected (glViewObject *view_object);
+static gboolean multiple_items_selected (glView *view);
-static int item_event_arrow_mode (GnomeCanvasItem * item,
- GdkEvent * event,
- glViewObject *view_object);
+static int item_event_arrow_mode (GnomeCanvasItem *item,
+ GdkEvent *event,
+ glViewObject *view_object);
-static GtkWidget *new_selection_menu (glView * view);
+static GtkWidget *new_selection_menu (glView *view);
-static void popup_selection_menu (glView *view,
- glViewObject *view_object, GdkEvent *event);
+static void popup_selection_menu (glView *view,
+ glViewObject *view_object,
+ GdkEvent *event);
-static void move_selected_items (glView * view, gdouble dx, gdouble dy);
-static void move_item (GnomeCanvasItem * item, gdouble dx, gdouble dy);
+static void move_selected_items (glView *view,
+ gdouble dx, gdouble dy);
+static void move_item (GnomeCanvasItem *item,
+ gdouble dx, gdouble dy);
-static void raise_selection_cb (GtkWidget * widget, glView * view);
-static void lower_selection_cb (GtkWidget * widget, glView * view);
+static void raise_selection_cb (GtkWidget *widget, glView *view);
+static void lower_selection_cb (GtkWidget *widget, glView *view);
-static void selection_clear_cb (GtkWidget * widget,
- GdkEventSelection * event, gpointer data);
+static void selection_clear_cb (GtkWidget *widget,
+ GdkEventSelection *event,
+ gpointer data);
-static void selection_get_cb (GtkWidget * widget,
- GtkSelectionData * selection_data, guint info,
- guint time, gpointer data);
+static void selection_get_cb (GtkWidget *widget,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ gpointer data);
-static void selection_received_cb (GtkWidget * widget,
- GtkSelectionData * selection_data,
- guint time, gpointer data);
+static void selection_received_cb (GtkWidget *widget,
+ GtkSelectionData *selection_data,
+ guint time,
+ gpointer data);
\f
/****************************************************************************/
/* Boilerplate Object stuff. */
}
static void
-gl_view_class_init (glViewClass * class)
+gl_view_class_init (glViewClass *class)
{
GObjectClass *object_class = (GObjectClass *) class;
}
static void
-gl_view_init (glView * view)
+gl_view_init (glView *view)
{
gl_debug (DEBUG_VIEW, "START");
}
static void
-gl_view_finalize (GObject * object)
+gl_view_finalize (GObject *object)
{
glView *view;
}
GtkWidget *
-gl_view_new (glLabel * label)
+gl_view_new (glLabel *label)
{
glView *view = g_object_new (gl_view_get_type (), NULL);
/* PRIVATE. Construct composite widget. */
/*---------------------------------------------------------------------------*/
static void
-gl_view_construct (glView * view)
+gl_view_construct (glView *view)
{
GtkWidget *wvbox, *wscroll;
/* PRIVATE. Create canvas w/ a background in the shape of the label/card. */
/*---------------------------------------------------------------------------*/
static GtkWidget *
-gl_view_construct_canvas (glView * view)
+gl_view_construct_canvas (glView *view)
{
gdouble scale;
glLabel *label = view->label;
case GL_TEMPLATE_STYLE_RECT:
if (label_template->label_round == 0.0) {
/* Square corners. */
- draw_rect_bg (view);
+ draw_rect_bg_fg (view);
} else {
/* Rounded corners. */
- draw_rounded_rect_bg (view);
+ draw_rounded_rect_bg_fg (view);
}
break;
case GL_TEMPLATE_STYLE_ROUND:
- draw_round_bg (view);
+ draw_round_bg_fg (view);
break;
case GL_TEMPLATE_STYLE_CD:
- draw_cd_bg (view);
+ draw_cd_bg_fg (view);
break;
default:
g_warning ("Unknown template label style");
break;
}
+ gl_debug (DEBUG_VIEW, "n_bg_items = %d, n_fg_items = %d",
+ view->n_bg_items, view->n_fg_items);
g_signal_connect (G_OBJECT (view->canvas), "event",
G_CALLBACK (canvas_event), view);
/* PRIVATE. Create selection targets. */
/*---------------------------------------------------------------------------*/
static void
-gl_view_construct_selection (glView * view)
+gl_view_construct_selection (glView *view)
{
gl_debug (DEBUG_VIEW, "START");
/* PRIVATE. Draw simple recangular background. */
/*---------------------------------------------------------------------------*/
static void
-draw_rect_bg (glView * view)
+draw_rect_bg_fg (glView *view)
{
glLabel *label = view->label;
glTemplate *template;
/* PRIVATE. Draw rounded recangular background. */
/*---------------------------------------------------------------------------*/
static void
-draw_rounded_rect_bg (glView * view)
+draw_rounded_rect_bg_fg (glView *view)
{
glLabel *label = view->label;
GnomeCanvasPoints *label_points, *margin_points;
/* PRIVATE. Draw round background. */
/*---------------------------------------------------------------------------*/
static void
-draw_round_bg (glView * view)
+draw_round_bg_fg (glView *view)
{
glLabel *label = view->label;
glTemplate *template;
/* PRIVATE. Draw CD style background, circular w/ concentric hole. */
/*---------------------------------------------------------------------------*/
static void
-draw_cd_bg (glView * view)
+draw_cd_bg_fg (glView *view)
{
glLabel *label = view->label;
glTemplate *template;
gl_debug (DEBUG_VIEW, "END");
}
+/*****************************************************************************/
+/* Raise foreground items to top. */
+/*****************************************************************************/
+void gl_view_raise_fg (glView *view)
+{
+ GList *p;
+
+ for (p = view->fg_item_list; p != NULL; p = p->next) {
+ gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(p->data));
+ }
+}
+
/*****************************************************************************/
/* Set arrow mode. */
/*****************************************************************************/
void
-gl_view_arrow_mode (glView * view)
+gl_view_arrow_mode (glView *view)
{
static GdkCursor *cursor = NULL;
/* Set create text object mode. */
/*****************************************************************************/
void
-gl_view_object_create_mode (glView * view,
+gl_view_object_create_mode (glView *view,
glLabelObjectType type)
{
GdkCursor *cursor;
/* Select all items. */
/*****************************************************************************/
void
-gl_view_select_all (glView * view)
+gl_view_select_all (glView *view)
{
GList *p;
/* Remove all selections */
/*****************************************************************************/
void
-gl_view_unselect_all (glView * view)
+gl_view_unselect_all (glView *view)
{
GList *p, *p_next;
/* "Cut" selected items and place in clipboard selections. */
/*****************************************************************************/
void
-gl_view_cut (glView * view)
+gl_view_cut (glView *view)
{
gl_debug (DEBUG_VIEW, "START");
/* "Copy" selected items to clipboard selections. */
/*****************************************************************************/
void
-gl_view_copy (glView * view)
+gl_view_copy (glView *view)
{
GList *p;
glViewObject *view_object;
/* "Paste" from private clipboard selection. */
/*****************************************************************************/
void
-gl_view_paste (glView * view)
+gl_view_paste (glView *view)
{
gl_debug (DEBUG_VIEW, "START");
/* PRIVATE. Select all objects within given rectangular region. */
/*---------------------------------------------------------------------------*/
static void
-select_region (glView * view,
+select_region (glView *view,
gdouble x1,
gdouble y1,
gdouble x2,
static void
select_object (glViewObject *view_object)
{
- glView * view;
+ glView *view;
gl_debug (DEBUG_VIEW, "START");
static void
unselect_object (glViewObject *view_object)
{
- glView * view;
+ glView *view;
gl_debug (DEBUG_VIEW, "START");
/* PRIVATE. Return object at (x,y). */
/*---------------------------------------------------------------------------*/
static gboolean
-object_at (glView * view,
+object_at (glView *view,
gdouble x,
gdouble y)
{
/* PRIVATE. Are there multiple objects in our current selection? */
/*---------------------------------------------------------------------------*/
static gboolean
-multiple_items_selected (glView * view)
+multiple_items_selected (glView *view)
{
gl_debug (DEBUG_VIEW, "");
/* PRIVATE. create menu for multiple selections. */
/*---------------------------------------------------------------------------*/
GtkWidget *
-new_selection_menu (glView * view)
+new_selection_menu (glView *view)
{
GtkWidget *menu, *menuitem;
/* Delete selected objects. */
/*---------------------------------------------------------------------------*/
void
-gl_view_delete_selection (glView * view)
+gl_view_delete_selection (glView *view)
{
GList *p, *p_next;
/* PRIVATE. raise item to front callback. */
/*---------------------------------------------------------------------------*/
static void
-raise_selection_cb (GtkWidget * widget,
- glView * view)
+raise_selection_cb (GtkWidget *widget,
+ glView *view)
{
GList *p;
/* PRIVATE. lower item to back callback. */
/*---------------------------------------------------------------------------*/
static void
-lower_selection_cb (GtkWidget * widget,
- glView * view)
+lower_selection_cb (GtkWidget *widget,
+ glView *view)
{
GList *p;
/* PRIVATE. move selected items */
/*---------------------------------------------------------------------------*/
static void
-move_selected_items (glView * view,
+move_selected_items (glView *view,
gdouble dx,
gdouble dy)
{
/* PRIVATE. Handle "selection-clear" signal. */
/*---------------------------------------------------------------------------*/
static void
-selection_clear_cb (GtkWidget * widget,
- GdkEventSelection * event,
- gpointer data)
+selection_clear_cb (GtkWidget *widget,
+ GdkEventSelection *event,
+ gpointer data)
{
glView *view = GL_VIEW (data);
/* PRIVATE. Handle "selection-get" signal. */
/*---------------------------------------------------------------------------*/
static void
-selection_get_cb (GtkWidget * widget,
- GtkSelectionData * selection_data,
- guint info,
- guint time,
- gpointer data)
+selection_get_cb (GtkWidget *widget,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ gpointer data)
{
glView *view = GL_VIEW (data);
gchar *buffer;
/* PRIVATE. Handle "selection-received" signal. (Result of Paste) */
/*---------------------------------------------------------------------------*/
static void
-selection_received_cb (GtkWidget * widget,
- GtkSelectionData * selection_data,
- guint time,
- gpointer data)
+selection_received_cb (GtkWidget *widget,
+ GtkSelectionData *selection_data,
+ guint time,
+ gpointer data)
{
glView *view = GL_VIEW (data);
glLabel *label = NULL;
/* Zoom in one "notch" */
/*****************************************************************************/
void
-gl_view_zoom_in (glView * view)
+gl_view_zoom_in (glView *view)
{
gint i, i_min;
gdouble dist, dist_min;
/* Zoom out one "notch" */
/*****************************************************************************/
void
-gl_view_zoom_out (glView * view)
+gl_view_zoom_out (glView *view)
{
gint i, i_min;
gdouble dist, dist_min;
/* Set current zoom factor to explicit value. */
/*****************************************************************************/
void
-gl_view_set_zoom (glView * view,
- gdouble scale)
+gl_view_set_zoom (glView *view,
+ gdouble scale)
{
gl_debug (DEBUG_VIEW, "START");
/* Get current zoom factor. */
/*****************************************************************************/
gdouble
-gl_view_get_zoom (glView * view)
+gl_view_get_zoom (glView *view)
{
gl_debug (DEBUG_VIEW, "");
GL_VIEW_STATE_OBJECT_CREATE
} glViewState;
-#define GL_TYPE_VIEW (gl_view_get_type ())
-#define GL_VIEW(obj) (GTK_CHECK_CAST((obj), GL_TYPE_VIEW, glView ))
-#define GL_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_VIEW, glViewClass))
-#define GL_IS_VIEW(obj) (GTK_CHECK_TYPE ((obj), GL_TYPE_VIEW))
+#define GL_TYPE_VIEW (gl_view_get_type ())
+#define GL_VIEW(obj) (GTK_CHECK_CAST((obj), GL_TYPE_VIEW, glView ))
+#define GL_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_VIEW, glViewClass))
+#define GL_IS_VIEW(obj) (GTK_CHECK_TYPE ((obj), GL_TYPE_VIEW))
#define GL_IS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_VIEW))
typedef struct _glView glView;
#include "view-object.h"
struct _glView {
- GtkVBox parent_widget;
+ GtkVBox parent_widget;
- glLabel *label;
+ glLabel *label;
- GtkWidget *canvas;
- gdouble scale;
- gint n_bg_items;
- GList *bg_item_list;
- gint n_fg_items;
- GList *fg_item_list;
+ GtkWidget *canvas;
+ gdouble scale;
+ gint n_bg_items;
+ GList *bg_item_list;
+ gint n_fg_items;
+ GList *fg_item_list;
- glViewState state;
+ glViewState state;
glLabelObjectType create_type;
- GList *object_list;
- GList *selected_object_list;
+ GList *object_list;
+ GList *selected_object_list;
- gint have_selection;
- glLabel *selection_data;
- GtkWidget *invisible;
+ gint have_selection;
+ glLabel *selection_data;
+ GtkWidget *invisible;
- GtkWidget *menu;
+ GtkWidget *menu;
};
struct _glViewClass {
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
-extern guint gl_view_get_type (void);
+extern guint gl_view_get_type (void);
-extern GtkWidget *gl_view_new (glLabel * label);
+extern GtkWidget *gl_view_new (glLabel *label);
-extern void gl_view_arrow_mode (glView * view);
-extern void gl_view_object_create_mode (glView * view,
- glLabelObjectType type);
+extern void gl_view_raise_fg (glView *view);
-extern void gl_view_select_object (glView *view, glViewObject *view_object);
-extern void gl_view_select_all (glView *view);
-extern void gl_view_unselect_all (glView *view);
-extern void gl_view_delete_selection (glView *view);
+extern void gl_view_arrow_mode (glView *view);
+extern void gl_view_object_create_mode (glView *view,
+ glLabelObjectType type);
+extern void gl_view_select_object (glView *view,
+ glViewObject *view_object);
+extern void gl_view_select_all (glView *view);
+extern void gl_view_unselect_all (glView *view);
+extern void gl_view_delete_selection (glView *view);
-extern int gl_view_item_event_handler (GnomeCanvasItem * item,
- GdkEvent * event,
- glViewObject *view_object);
-extern void gl_view_cut (glView * view);
-extern void gl_view_copy (glView * view);
-extern void gl_view_paste (glView * view);
+extern int gl_view_item_event_handler (GnomeCanvasItem *item,
+ GdkEvent *event,
+ glViewObject *view_object);
-extern void gl_view_zoom_in (glView * view);
-extern void gl_view_zoom_out (glView * view);
-extern void gl_view_set_zoom (glView * view, gdouble scale);
-extern gdouble gl_view_get_zoom (glView * view);
+extern void gl_view_cut (glView *view);
+extern void gl_view_copy (glView *view);
+extern void gl_view_paste (glView *view);
+
+extern void gl_view_zoom_in (glView *view);
+extern void gl_view_zoom_out (glView *view);
+extern void gl_view_set_zoom (glView *view, gdouble scale);
+extern gdouble gl_view_get_zoom (glView *view);
#endif