rect-context.cpp revision dbe32b890d08ee7a085dcee01234f24e32db5ee1
4911N/A#define __SP_RECT_CONTEXT_C__
#include "macros.h"
#include "display/sp-canvas.h"
#include "sp-rect.h"
#include "document.h"
#include "sp-namedview.h"
#include "selection.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_Escape:
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));
GString *xs = SP_PX_TO_METRIC_STRING(r.dimensions()[NR::X], desktop->namedview->getDefaultMetric());
GString *ys = SP_PX_TO_METRIC_STRING(r.dimensions()[NR::Y], desktop->namedview->getDefaultMetric());
rc._message_context->setF(Inkscape::NORMAL_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);