本文整理汇总了C++中GOO_CANVAS函数的典型用法代码示例。如果您正苦于以下问题:C++ GOO_CANVAS函数的具体用法?C++ GOO_CANVAS怎么用?C++ GOO_CANVAS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GOO_CANVAS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: create_clipping_page
GtkWidget *
create_clipping_page (void)
{
GtkWidget *vbox, *scrolled_win, *canvas;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
g_object_set (vbox, "margin", 4, NULL);
gtk_widget_show (vbox);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_SHADOW_IN);
gtk_widget_show (scrolled_win);
gtk_box_pack_start (GTK_BOX (vbox), scrolled_win);
gtk_widget_set_halign (scrolled_win, GTK_ALIGN_FILL);
gtk_widget_set_valign (scrolled_win, GTK_ALIGN_FILL);
gtk_widget_set_hexpand (scrolled_win, TRUE);
gtk_widget_set_vexpand (scrolled_win, TRUE);
canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
setup_canvas (GOO_CANVAS (canvas));
return vbox;
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:29,代码来源:mv-demo-clipping.c
示例2: sheet_change_zoom
void
sheet_change_zoom (const Sheet *sheet, gdouble rate)
{
gdouble scale;
sheet->priv->zoom *= rate;
scale = goo_canvas_get_scale (GOO_CANVAS (sheet));
scale = scale * rate;
goo_canvas_set_scale (GOO_CANVAS (sheet), scale);
}
开发者ID:dionysos-sf,项目名称:oregano,代码行数:10,代码来源:sheet.c
示例3: main
int
main ()
{
GtkWidget *window, *scrolled_win, *canvas;
GooCanvasItem *root, *rect_item, *text_item;
/* Initialize GTK+. */
gtk_init ();
/* Create the window and widgets. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
gtk_widget_show (window);
g_signal_connect (window, "delete_event", G_CALLBACK (on_delete_event),
NULL);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_SHADOW_IN);
gtk_widget_show (scrolled_win);
gtk_container_add (GTK_CONTAINER (window), scrolled_win);
canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
/* Add a few simple items. */
rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400,
"line-width", 10.0,
"radius-x", 20.0,
"radius-y", 10.0,
"stroke-color", "yellow",
"fill-color", "red",
NULL);
text_item = goo_canvas_text_new (root, "Hello World", 300, 300, -1,
GOO_CANVAS_ANCHOR_CENTER,
"font", "Sans 24",
NULL);
goo_canvas_item_rotate (text_item, 45, 300, 300);
/* Connect a signal handler for the rectangle item. */
g_signal_connect (rect_item, "button_press_event",
G_CALLBACK (on_rect_button_press), NULL);
/* Pass control to the GTK+ main event loop. */
gtk_main ();
return 0;
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:54,代码来源:simple-demo.c
示例4: setup_canvas
void
setup_canvas (GtkWidget *canvas)
{
GooCanvasItemModel *root;
root = goo_canvas_group_model_new (NULL, NULL);
goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
g_print ("\nTable at default size...\n");
create_table1 (canvas, root, 50, 50, -1, -1, FALSE);
g_print ("\nTable at reduced size...\n");
create_table1 (canvas, root, 250, 50, 30, 30, FALSE);
g_print ("\nTable at enlarged size...\n");
create_table1 (canvas, root, 450, 50, 100, 100, FALSE);
g_print ("\nTable with grid lines at default size...\n");
create_table1 (canvas, root, 50, 250, -1, -1, TRUE);
g_print ("\nTable with grid lines at reduced size...\n");
create_table1 (canvas, root, 250, 250, 30, 30, TRUE);
g_print ("\nTable with grid lines at enlarged size...\n");
create_table1 (canvas, root, 450, 250, 150, 150, TRUE);
g_print ("Multispanning table with grid lines at default size...\n");
create_table2 (canvas, root, 50, 450, -1, -1, TRUE);
g_print ("Multispanning table with grid lines at reduced size...\n");
create_table2 (canvas, root, 250, 450, 30, 30, TRUE);
g_print ("Multispanning table with grid lines at enlarged size...\n");
create_table2 (canvas, root, 450, 450, 150, 150, TRUE);
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:35,代码来源:mv-table-demo.c
示例5: create_focus_page
GtkWidget *
create_focus_page (void)
{
GtkWidget *vbox, *label, *scrolled_win, *canvas;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_widget_show (vbox);
label = gtk_label_new ("Use Tab, Shift+Tab or the arrow keys to move the keyboard focus between the canvas items.");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_SHADOW_IN);
gtk_widget_show (scrolled_win);
gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
canvas = goo_canvas_new ();
gtk_widget_set_can_focus (canvas, TRUE);
gtk_widget_set_size_request (canvas, 600, 450);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
g_signal_connect (canvas, "item_created",
G_CALLBACK (on_item_created), NULL);
setup_canvas (canvas);
return vbox;
}
开发者ID:anderflash,项目名称:goocanvas,代码行数:33,代码来源:mv-demo-focus.c
示例6: setup_canvas
static void
setup_canvas (GtkWidget *canvas)
{
GooCanvasItemModel *root;
root = goo_canvas_group_model_new (NULL, NULL);
goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
g_object_unref (root);
create_focus_box (canvas, 110, 80, 50, 30, "red");
create_focus_box (canvas, 300, 160, 50, 30, "orange");
create_focus_box (canvas, 500, 50, 50, 30, "yellow");
create_focus_box (canvas, 70, 400, 50, 30, "blue");
create_focus_box (canvas, 130, 200, 50, 30, "magenta");
create_focus_box (canvas, 200, 160, 50, 30, "green");
create_focus_box (canvas, 450, 450, 50, 30, "cyan");
create_focus_box (canvas, 300, 350, 50, 30, "grey");
create_focus_box (canvas, 900, 900, 50, 30, "gold");
create_focus_box (canvas, 800, 150, 50, 30, "thistle");
create_focus_box (canvas, 600, 800, 50, 30, "azure");
create_focus_box (canvas, 700, 250, 50, 30, "moccasin");
create_focus_box (canvas, 500, 100, 50, 30, "cornsilk");
create_focus_box (canvas, 200, 750, 50, 30, "plum");
create_focus_box (canvas, 400, 800, 50, 30, "orchid");
}
开发者ID:anderflash,项目名称:goocanvas,代码行数:25,代码来源:mv-demo-focus.c
示例7: boundedScroll
static scrollvalue boundedScroll(canvas_goocanvas *gcanvas, scrollvalue d)
{
/* get size of visible area in canvas units (meters) */
canvas_dimensions dim = gcanvas->get_viewport_dimensions() / 2;
// Data rect minimum and maximum
// limit stops - prevent scrolling beyond these
gdouble min_sy_cu = 0.95 * (gcanvas->bounds.min.y - dim.height);
gdouble min_sx_cu = 0.95 * (gcanvas->bounds.min.x - dim.width);
gdouble max_sy_cu = 0.95 * (gcanvas->bounds.max.y + dim.height);
gdouble max_sx_cu = 0.95 * (gcanvas->bounds.max.x + dim.width);
scrollvalue ret(std::min(std::max(d.x, min_sx_cu), max_sx_cu),
std::min(std::max(d.y, min_sy_cu), max_sy_cu));
/* adjust to screen center */
GooCanvas *gc = GOO_CANVAS(gcanvas->widget);
gdouble zoom = goo_canvas_get_scale(gc);
gdouble offx = gcanvas->widget->allocation.width / (2 * zoom);
gdouble offy = gcanvas->widget->allocation.height / (2 * zoom);
goo_canvas_scroll_to(gc, ret.x - offx, ret.y - offy);
return ret;
}
开发者ID:AMDmi3,项目名称:osm2go,代码行数:25,代码来源:canvas_goocanvas.cpp
示例8: printf
double canvas_t::set_zoom(double zoom) {
/* Limit a proposed zoom factor to sane ranges.
* Specifically the map is allowed to be no smaller than the viewport. */
canvas_goocanvas *gcanvas = static_cast<canvas_goocanvas *>(this);
/* get size of visible area in pixels and convert to meters of intended */
/* zoom by dividing by zoom (which is basically pix/m) */
const GtkAllocation &dim = widget->allocation;
double limit;
int delta;
if (dim.height < dim.width) {
limit = dim.height;
delta = gcanvas->bounds.max.y - gcanvas->bounds.min.y;
} else {
limit = dim.width;
delta = gcanvas->bounds.max.x - gcanvas->bounds.min.x;
}
limit *= 0.95 / zoom;
if (delta < limit) {
zoom /= (delta / limit);
printf("Can't zoom further out (%f)\n", zoom);
}
goo_canvas_set_scale(GOO_CANVAS(widget), zoom);
return zoom;
}
开发者ID:AMDmi3,项目名称:osm2go,代码行数:31,代码来源:canvas_goocanvas.cpp
示例9: create_focus_box
static void
create_focus_box (GtkWidget *canvas,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gchar *color)
{
GooCanvasItem *root, *item;
root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
item = goo_canvas_rect_new (root, x, y, width, height,
"stroke-pattern", NULL,
"fill-color", color,
"line-width", 5.0,
"can-focus", TRUE,
NULL);
g_object_set_data (G_OBJECT (item), "id", color);
g_signal_connect (item, "focus_in_event",
G_CALLBACK (on_focus_in), NULL);
g_signal_connect (item, "focus_out_event",
G_CALLBACK (on_focus_out), NULL);
g_signal_connect (item, "button_press_event",
G_CALLBACK (on_button_press), NULL);
g_signal_connect (item, "key_press_event",
G_CALLBACK (on_key_press), NULL);
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:30,代码来源:widgets-demo.c
示例10: goo_canvas_accessible_ref_child
static AtkObject*
goo_canvas_accessible_ref_child (AtkObject *object,
gint child_num)
{
GtkAccessible *accessible;
GtkWidget *widget;
GooCanvasItem *root;
AtkObject *atk_object;
/* Canvas only has one child, so return NULL if index is non zero */
if (child_num != 0)
return NULL;
accessible = GTK_ACCESSIBLE (object);
widget = accessible->widget;
/* Check if widget still exists. */
if (widget == NULL)
return NULL;
root = goo_canvas_get_root_item (GOO_CANVAS (widget));
if (!root)
return NULL;
atk_object = atk_gobject_accessible_for_object (G_OBJECT (root));
g_object_ref (atk_object);
return atk_object;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:29,代码来源:goocanvasatk.c
示例11: sheet_get_pointer
/**
* get the pointer position in goocanvas coordinates
*
* @attention shall not be called in event callbacks,
* except for GDK_MOTION_... where it is useless since
* the event itself contains the cursor position
*/
gboolean sheet_get_pointer (Sheet *sheet, gdouble *x, gdouble *y)
{
if (!sheet_get_pointer_pixel (sheet, x, y))
return FALSE;
goo_canvas_convert_from_pixels (GOO_CANVAS (sheet), x, y);
return TRUE;
}
开发者ID:felipebetancur,项目名称:oregano,代码行数:14,代码来源:sheet.c
示例12: node_dot_added_callback
static void
node_dot_added_callback (Schematic *schematic, Coords *pos, Sheet *sheet)
{
NodeItem *node_item;
Coords *key;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
node_item = g_hash_table_lookup (sheet->priv->node_dots, pos);
if (node_item == NULL) {
node_item = NODE_ITEM (g_object_new (TYPE_NODE_ITEM, NULL));
g_object_set (node_item,
"parent", goo_canvas_get_root_item (GOO_CANVAS (sheet)),
"x", pos->x,
"y", pos->y,
NULL);
}
node_item_show_dot (node_item, TRUE);
key = g_new0 (Coords, 1);
key->x = pos->x;
key->y = pos->y;
g_hash_table_insert (sheet->priv->node_dots, key, node_item);
}
开发者ID:hriesz,项目名称:oregano-old,代码行数:26,代码来源:sheet.c
示例13: draw_canvas_get_item_at
static DrawCanvasItem *
draw_canvas_get_item_at (DrawCanvas *canvas,
gdouble x,
gdouble y,
gboolean is_pointer_event)
{
GooCanvasItem *item;
g_return_val_if_fail(DRAW_IS_CANVAS(canvas), NULL);
/*
* Fetch the item underneath the pointer. If the item is not a
* DrawCanvasItem or the item is part of a selection group, work our way
* up until we find that top-most grabbable item.
*/
item = goo_canvas_get_item_at(GOO_CANVAS(canvas), x, y, is_pointer_event);
for (; item; item = goo_canvas_item_get_parent(item)) {
/*
* TODO: Check if part of a selection/group.
*/
if (DRAW_IS_CANVAS_ITEM(item)) {
return DRAW_CANVAS_ITEM(item);
}
}
return NULL;
}
开发者ID:chergert,项目名称:simply-draw,代码行数:28,代码来源:draw-canvas.c
示例14: init_display
void
init_display()
{
int i;
pcb.scale = 1.0;
for (i = 0; i < pcb.layers; i++) {
pcb.layer[i].canvas = GOO_CANVAS(goo_canvas_new());
gtk_object_ref(GTK_OBJECT(pcb.layer[i].canvas));
goo_canvas_set_bounds(pcb.layer[i].canvas,
0, 0, pcb.width, pcb.height);
pcb.layer[i].root =
goo_canvas_get_root_item(pcb.layer[i].canvas);
goo_canvas_image_new(pcb.layer[i].root, pcb.layer[i].img, 0, 0,
NULL);
init_layer_events(pcb.layer[i].root);
show_overlays(i);
}
pcb.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(pcb.window), 800, 600);
gtk_window_set_title(GTK_WINDOW(pcb.window), pcb.filename);
init_window_events(pcb.window);
pcb.scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show(pcb.scrolled);
gtk_container_add(GTK_CONTAINER(pcb.window), pcb.scrolled);
redisplay();
}
开发者ID:bert,项目名称:depcb,代码行数:31,代码来源:display.c
示例15: create_canvas
static void
create_canvas (GtkTable *table, gint row, gchar *text, gchar *id)
{
GtkWidget *label, *canvas;
GooCanvasItemModel *root, *rect;
char *view_id;
label = gtk_label_new (text);
gtk_table_attach (table, label, 0, 1, row, row + 1,
0, 0, 0, 0);
gtk_widget_show (label);
canvas = goo_canvas_new ();
g_signal_connect (canvas, "item_created",
G_CALLBACK (on_item_created), NULL);
gtk_widget_set_size_request (canvas, 200, 100);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 200, 100);
gtk_table_attach (table, canvas, 1, 2, row, row + 1, 0, 0, 0, 0);
gtk_widget_show (canvas);
root = goo_canvas_group_model_new (NULL, NULL);
goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
g_object_unref (root);
rect = goo_canvas_rect_model_new (root, 0, 0, 200, 100,
"stroke-pattern", NULL,
"fill-color", "yellow",
NULL);
view_id = g_strdup_printf ("%s-yellow", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
rect = goo_canvas_rect_model_new (root, 20, 20, 60, 60,
"stroke-pattern", NULL,
"fill-color", "blue",
NULL);
view_id = g_strdup_printf ("%s-blue", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
rect = goo_canvas_rect_model_new (root, 120, 20, 60, 60,
"stroke-pattern", NULL,
"fill-color", "red",
NULL);
view_id = g_strdup_printf ("%s-red", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:47,代码来源:mv-demo-grabs.c
示例16: create_window
static GtkWidget*
create_window (GooCanvasItemModel *model)
{
GtkWidget *window, *vbox, *label, *scrolled_win, *canvas;
/* Create the window and widgets. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
gtk_widget_show (window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
g_object_set (vbox, "margin", 4, NULL);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (window), vbox);
label = gtk_label_new ("Use Ctrl+Left Click to move items or Ctrl+Right Click to resize items");
g_object_set (label, "halign", GTK_ALIGN_START, NULL);
gtk_box_pack_start (GTK_BOX (vbox), label);
gtk_widget_show (label);
/* Create top canvas. */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_SHADOW_IN);
gtk_widget_show (scrolled_win);
gtk_box_pack_start (GTK_BOX (vbox), scrolled_win);
gtk_widget_set_halign (scrolled_win, GTK_ALIGN_FILL);
gtk_widget_set_valign (scrolled_win, GTK_ALIGN_FILL);
gtk_widget_set_hexpand (scrolled_win, TRUE);
gtk_widget_set_vexpand (scrolled_win, TRUE);
canvas = goo_canvas_new ();
g_object_set (G_OBJECT (canvas), "integer-layout", TRUE, NULL);
/* gtk_widget_set_size_request (canvas, 600, 250);*/
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
g_signal_connect (canvas, "item_created",
G_CALLBACK (on_item_created), NULL);
goo_canvas_set_root_item_model (GOO_CANVAS (canvas), model);
return window;
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:46,代码来源:mv-generic-position-demo.c
示例17: ground_track_delete
/** \brief Delete the ground track for a satellite.
* \param satmap The satellite map widget.
* \param sat Pointer to the satellite object.
* \param qth Pointer to the QTH data.
* \param obj the satellite object.
* \param clear_ssp Flag indicating whether SSP data should be cleared as well (TRUE=yes);
*
*/
void
ground_track_delete (GtkSatMap *satmap, sat_t *sat, qth_t *qth, sat_map_obj_t *obj, gboolean clear_ssp)
{
guint i,n;
gint j;
GooCanvasItemModel *line;
GooCanvasItemModel *root;
(void) qth; /* avoid unusued parameter compiler warning */
sat_log_log (SAT_LOG_LEVEL_DEBUG,
_("%s: Deleting ground track for %s"),
__FUNCTION__, sat->nickname);
root = goo_canvas_get_root_item_model (GOO_CANVAS (satmap->canvas));
/* remove plylines */
if (obj->track_data.lines != NULL) {
n = g_slist_length (obj->track_data.lines);
for (i = 0; i < n; i++) {
/* get line */
line = GOO_CANVAS_ITEM_MODEL (g_slist_nth_data (obj->track_data.lines, i));
/* find its ID and remove it */
j = goo_canvas_item_model_find_child (root, line);
if (j == -1) {
sat_log_log (SAT_LOG_LEVEL_ERROR,
_("%s: Could not find part %d of ground track"),
__FUNCTION__, j);
}
else {
goo_canvas_item_model_remove_child (root, j);
}
}
g_slist_free (obj->track_data.lines);
obj->track_data.lines = NULL;
}
/* clear SSP too? */
if (clear_ssp == TRUE) {
if (obj->track_data.latlon != NULL) {
/* free allocated ssp_t */
g_slist_foreach (obj->track_data.latlon, free_ssp, NULL);
/* free the SList itself */
g_slist_free (obj->track_data.latlon);
obj->track_data.latlon = NULL;
}
obj->track_orbit = 0;
}
}
开发者ID:kopaniapawel,项目名称:gpredict-1,代码行数:66,代码来源:gtk-sat-map-ground-track.c
示例18: create_canvas
static void
create_canvas (GtkGrid *grid, gint row, gchar *text, gchar *id)
{
GtkWidget *label, *canvas;
GooCanvasItem *root, *rect;
char *view_id;
label = gtk_label_new (text);
gtk_grid_attach (grid, label, 0, row, 1, 1);
gtk_widget_show (label);
canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 200, 100);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 200, 100);
gtk_grid_attach (grid, canvas, 1, row, 1, 1);
gtk_widget_show (canvas);
root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
rect = goo_canvas_rect_new (root, 0, 0, 200, 100,
"stroke-pattern", NULL,
"fill-color", "yellow",
NULL);
view_id = g_strdup_printf ("%s-yellow", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
setup_item_signals (rect);
rect = goo_canvas_rect_new (root, 20, 20, 60, 60,
"stroke-pattern", NULL,
"fill-color", "blue",
NULL);
view_id = g_strdup_printf ("%s-blue", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
setup_item_signals (rect);
rect = goo_canvas_rect_new (root, 120, 20, 60, 60,
"stroke-pattern", NULL,
"fill-color", "red",
NULL);
view_id = g_strdup_printf ("%s-red", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
setup_item_signals (rect);
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:44,代码来源:demo-grabs.c
示例19: rubberband_update
gboolean
rubberband_update (Sheet *sheet, GdkEvent *event)
{
GList *iter;
Coords cur, cmin, cmax;
double dx, dy; // TODO maybe keep track of subpixel changes, make em global/part of the rubberband_info struct and reset on finish
double width, height,
width_ng, height_ng;
RubberbandInfo *rubberband_info;
rubberband_info = sheet->priv->rubberband_info;
g_assert (event->type == GDK_MOTION_NOTIFY);
cur.x = event->motion.x;
cur.y = event->motion.y;
goo_canvas_convert_from_pixels (GOO_CANVAS (sheet), &cur.x, &cur.y);
width = fabs(rubberband_info->end.x - rubberband_info->start.x);
height = fabs(rubberband_info->end.y - rubberband_info->start.y);
width_ng = fabs(cur.x - rubberband_info->start.x);
height_ng = fabs(cur.y - rubberband_info->start.y);
dx = fabs (width_ng - width);
dy = fabs (height_ng - height);
NG_DEBUG ("motion :: dx=%lf, dy=%lf :: x=%lf, y=%lf :: w_ng=%lf, h_ng=%lf", dx, dy, cur.x, cur.y, width_ng, height_ng);
// TODO FIXME scroll window if needed (use http://developer.gnome.org/goocanvas/stable/GooCanvas.html#goo-canvas-scroll-to)
if (dx > 0.1 || dy > 0.1) { //a 0.1 change in pixel coords would be the least visible, silently ignore everything else
rubberband_info->end.x = cur.x;
rubberband_info->end.y = cur.y;
cmin.x = MIN(rubberband_info->start.x, rubberband_info->end.x);
cmin.y = MIN(rubberband_info->start.y, rubberband_info->end.y);
cmax.x = cmin.x + width_ng;
cmax.y = cmin.y + height_ng;
#if 1
for (iter = sheet->priv->items; iter; iter = iter->next) {
sheet_item_select_in_area (iter->data,
&cmin,
&cmax);
}
#endif
g_object_set (GOO_CANVAS_ITEM (rubberband_info->rectangle),
"x", cmin.x,
"y", cmin.y,
"width", width_ng,
"height", height_ng,
"visibility", GOO_CANVAS_ITEM_VISIBLE,
NULL);
goo_canvas_item_raise (GOO_CANVAS_ITEM (rubberband_info->rectangle), NULL);
}
return TRUE;
}
开发者ID:baboofei,项目名称:oregano,代码行数:55,代码来源:rubberband.c
示例20: sheet_keyboard_ungrab
void sheet_keyboard_ungrab (Sheet *sheet, GdkEvent *event)
{
g_return_if_fail (sheet);
g_return_if_fail (IS_SHEET (sheet));
#ifndef DEBUG_DISABLE_GRABBING
if (sheet->priv->keyboard_grabbed) {
sheet->priv->keyboard_grabbed = FALSE;
goo_canvas_keyboard_ungrab (GOO_CANVAS (sheet), GOO_CANVAS_ITEM (sheet->grid),
extract_time (event));
}
#endif
}
开发者ID:felipebetancur,项目名称:oregano,代码行数:12,代码来源:sheet.c
注:本文中的GOO_CANVAS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论