rect-context.cpp revision 700fe8603c02a9d683dd7b1ccdfae489b61ea2c2
5f135a319884b2e8977d5c31ac9891386176c8e7Mark Andrews * Rectangle drawing context
5f135a319884b2e8977d5c31ac9891386176c8e7Mark Andrews * Lauris Kaplinski <lauris@kaplinski.com>
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk * bulia byak <buliabyak@users.sf.net>
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk * Copyright (C) 2000-2005 authors
62a6147e51fd1ccb9ec1c1b6c97b6e9b9ef1f002Evan Hunt * Copyright (C) 2000-2001 Ximian, Inc.
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk * Released under GNU GPL, read the file 'COPYING' for more information
#include "display/sp-canvas.h"
#include "sp-rect.h"
#include "document.h"
#include "sp-namedview.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "desktop-handles.h"
#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-rect.xpm"
#include "rect-context.h"
#include "sp-metrics.h"
#include "object-edit.h"
#include "xml/node-event-vector.h"
#include "prefs-utils.h"
#include "context-fns.h"
static gint sp_rect_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
if (!type) {
sizeof(SPRectContextClass),
sizeof(SPRectContext),
return type;
if (item) {
if (shape_repr) {
if (item) {
if (shape_repr) {
static gint sp_rect_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
case GDK_BUTTON_PRESS:
return ret;
static bool dragging;
event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
case GDK_BUTTON_PRESS:
event_context->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE);
dragging = true;
case GDK_MOTION_NOTIFY:
if ( dragging
case GDK_BUTTON_RELEASE:
dragging = false;
case GDK_KEY_PRESS:
case GDK_Alt_L:
case GDK_Alt_R:
case GDK_Control_L:
case GDK_Control_R:
case GDK_Shift_L:
case GDK_Shift_R:
case GDK_Meta_R:
if (!dragging){
NULL);
case GDK_Up:
case GDK_Down:
case GDK_KP_Up:
case GDK_KP_Down:
if (!MOD__CTRL_ONLY)
case GDK_x:
case GDK_X:
if (MOD__ALT_ONLY) {
case GDK_g:
case GDK_G:
if (MOD__SHIFT_ONLY) {
ret = true;
case GDK_Escape:
case GDK_space:
if (dragging) {
dragging = false;
case GDK_KEY_RELEASE:
case GDK_Alt_L:
case GDK_Alt_R:
case GDK_Control_L:
case GDK_Control_R:
case GDK_Shift_L:
case GDK_Shift_R:
case GDK_Meta_R:
if (!ret) {
return ret;
rc.item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
sp_rect_position_set(SP_RECT(rc.item), r.min()[NR::X], r.min()[NR::Y], r.dimensions()[NR::X], r.dimensions()[NR::Y]);
sp_rect_set_ry (SP_RECT(rc.item), TRUE, CLAMP(rc.ry, 0, MIN(r.dimensions()[NR::X], r.dimensions()[NR::Y])/2));
bool is_golden_ratio = false;
is_golden_ratio = true;
is_golden_ratio = true;
if (!is_golden_ratio) {
rc._message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y);
rc._message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1.618 : 1); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str);
rc._message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1 : 1.618); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str);
rc._message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio rectangle; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str);