lpe-tool-context.cpp revision 6ccdb18a54dcf42ccf8a0854542a6cfc973c9061
/*
* LPEToolContext: a context for a generic tool composed of subtools that are given by LPEs
*
* Authors:
* Maximilian Albert <maximilian.albert@gmail.com>
* Lauris Kaplinski <lauris@kaplinski.com>
* Abhishek Sharma
*
* Copyright (C) 1998 The Free Software Foundation
* Copyright (C) 1999-2005 authors
* Copyright (C) 2001-2002 Ximian, Inc.
* Copyright (C) 2008 Maximilian Albert
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gdk/gdkkeysyms.h>
#include "macros.h"
#include "pixmaps/cursor-crosshairs.xpm"
#include "desktop.h"
#include "message-context.h"
#include "preferences.h"
#include "shape-editor.h"
#include "selection.h"
#include "desktop-handles.h"
#include "document.h"
#include "display/canvas-bpath.h"
#include "display/canvas-text.h"
#include "message-stack.h"
#include "sp-path.h"
#include "lpe-tool-context.h"
const int num_subtools = 8;
SubtoolEntry lpesubtools[] = {
// this must be here to account for the "all inactive" action
};
#include "sp-factory.h"
namespace {
return new SPLPEToolContext();
}
bool lpetoolContextRegistered = ToolFactory::instance().registerObject("/tools/lpetool", createLPEToolContext);
}
return SPLPEToolContext::prefsPath;
}
static void
{
// event_context_class->setup = sp_lpetool_context_setup;
// event_context_class->set = sp_lpetool_context_set;
// event_context_class->root_handler = sp_lpetool_context_root_handler;
// event_context_class->item_handler = sp_lpetool_context_item_handler;
}
this->splpetoolcontext = lpetoolcontext;
}
SPLPEToolContext* lc = this;
delete lc->cpencontext;
lc->shape_editor = 0;
lc->_lpetool_message_context = 0;
}
static void
{
new (lc) SPLPEToolContext();
}
static void
{
delete lc->shape_editor;
if (lc->canvas_bbox) {
}
delete lc->measuring_items;
if (lc->_lpetool_message_context) {
delete lc->_lpetool_message_context;
}
}
static void
{
}
void CLPEToolContext::setup() {
// if (((SPEventContextClass *) sp_lpetool_context_parent_class)->setup)
// ((SPEventContextClass *) sp_lpetool_context_parent_class)->setup(ec);
CPenContext::setup();
selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_lpetool_context_selection_changed), (gpointer)lc));
// TODO temp force:
ec->enableSelectionCue();
if (item) {
}
ec->enableSelectionCue();
}
}
/**
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new nodepath and reassigns listeners to the new selected item's repr.
*/
{
}
static void
{
}
}
/*
//pass on up to parent class to handle common attributes.
if ( sp_lpetool_context_parent_class->set ) {
sp_lpetool_context_parent_class->set(ec, key, val);
}
*/
}
static gint
{
}
case GDK_BUTTON_PRESS:
{
// select the clicked item but do nothing else
break;
}
case GDK_BUTTON_RELEASE:
// TODO: do we need to catch this or can we pass it on to the parent handler?
break;
default:
break;
}
if (!ret) {
// if (((SPEventContextClass *) sp_lpetool_context_parent_class)->item_handler)
// ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->item_handler(ec, item, event);
}
return ret;
}
{
}
bool ret = false;
if (sp_pen_context_has_waiting_LPE(lc)) {
// quit when we are waiting for a LPE to be applied
//ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event);
return ret;
}
case GDK_BUTTON_PRESS:
// don't do anything for now if we are inactive (except clearing the selection
// since this was a click into empty space)
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Choose a construction tool from the toolbar."));
ret = true;
break;
}
// save drag origin
event_context->within_tolerance = true;
using namespace Inkscape::LivePathEffect;
//bool over_stroke = lc->shape_editor->is_over_stroke(Geom::Point(event->button.x, event->button.y), true);
sp_pen_context_wait_for_LPE_mouse_clicks(lc, type, Inkscape::LivePathEffect::Effect::acceptsNumClicks(type));
// we pass the mouse click on to pen tool as the first click which it should collect
//ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event);
}
break;
case GDK_BUTTON_RELEASE:
{
/**
break;
**/
}
case GDK_KEY_PRESS:
/**
switch (get_group0_keyval (&event->key)) {
}
break;
**/
case GDK_KEY_RELEASE:
/**
switch (get_group0_keyval(&event->key)) {
case GDK_Control_L:
case GDK_Control_R:
dc->_message_context->clear();
break;
default:
break;
}
**/
default:
break;
}
if (!ret) {
// if (((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler) {
// ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event);
// }
}
return ret;
}
/*
* Finds the index in the list of geometric subtools corresponding to the given LPE type.
* Returns -1 if no subtool is found.
*/
int
for (int i = 0; i < num_subtools; ++i) {
return i;
}
}
return -1;
}
/*
* Checks whether an item has a construction applied as LPE and if so returns the index in
* lpesubtools of this construction
*/
{
if (!SP_IS_LPE_ITEM(item)) {
return -1;
}
if (!lpe) {
return -1;
}
}
/*
* Attempts to perform the construction of the given type (i.e., to apply the corresponding LPE) to
* a single selected item. Returns whether we succeeded.
*/
bool
{
// TODO: should we check whether type represents a valid geometric construction?
if (item && SP_IS_LPE_ITEM(item) && Inkscape::LivePathEffect::Effect::acceptsNumClicks(type) == 0) {
return true;
}
return false;
}
void
{
if (index != -1) {
} else {
return;
}
}
void
}
/*
* Reads the limiting bounding box from preferences and draws it on the screen
*/
// TODO: Note that currently the bbox is not user-settable; we simply use the page borders
void
{
if (lc->canvas_bbox) {
}
return;
A *= doc2dt;
B *= doc2dt;
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(lc->canvas_bbox), 0x0000ffff, 0.8, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT, 5, 5);
}
static void
const double t, const double length, bool /*use_curvature*/ = false)
{
using namespace Geom;
}
void
{
if (!selection) {
}
double lengthval;
if (SP_IS_PATH(i->data)) {
if (!show)
arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px");
// TODO: must we free arc_length?
}
}
}
void
{
}
}
void
{
double lengthval;
arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px");
// TODO: must we free arc_length?
}
}
void
{
if (show) {
} else {
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :