verbs.h revision fc107cfef5bc34e9a1cf5e4ff419f754e68129f5
#ifndef SEEN_SP_VERBS_H
#define SEEN_SP_VERBS_H
/*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* Ted Gould <ted@gould.cx>
* David Yip <yipdw@rose-hulman.edu>
*
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) (date unspecified) Authors
* This code is in public domain if done by Lauris
* This code is GPL if done by Ted or David
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cstring>
#include <string>
//#include "require-config.h" /* HAVE_GTK_WINDOW_FULLSCREEN */
struct SPAction;
} // namespace View
} // namespace UI
} // namespace Inkscape
/**
* This anonymous enum is used to provide a list of the Verbs
* which are defined staticly in the verb files. There may be
* other verbs which are defined dynamically also.
*/
enum {
/* Header */
SP_VERB_INVALID, /**< A dummy verb to represent doing something wrong. */
SP_VERB_NONE, /**< A dummy verb to represent not having a verb. */
/* File */
SP_VERB_FILE_NEW, /**< A new file in a new window. */
SP_VERB_FILE_OPEN, /**< Open a file. */
SP_VERB_FILE_REVERT, /**< Revert this file to its original state. */
SP_VERB_FILE_SAVE, /**< Save the current file with its saved filename */
SP_VERB_FILE_SAVE_AS, /**< Save the current file with a new filename */
SP_VERB_FILE_SAVE_A_COPY, /**< Save a copy of the current file */
// SP_VERB_FILE_EXPORT,
SP_VERB_FILE_IMPORT_FROM_OCAL, /**< Import the file from Open Clip Art Library */
// SP_VERB_FILE_EXPORT_TO_OCAL, /**< Export the file to Open Clip Art Library */
/* Edit */
/* Selection */
#if HAVE_POTRACE
#endif
SP_VERB_SELECTION_ARRANGE, // Former SP_VERB_SELECTION_GRIDTILE
/* Layer */
/* Object */
/* Tag */
/* Tools */
#if HAVE_POTRACE
#endif
SP_VERB_CONTEXT_LPE, /* not really a tool but used for editing LPE parameters on-canvas for example */
SP_VERB_CONTEXT_LPETOOL, /* note that this is very different from SP_VERB_CONTEXT_LPE above! */
/* Tool preferences */
#if HAVE_POTRACE
#endif
/* Zooming and desktop settings */
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
#endif /* HAVE_GTK_WINDOW_FULLSCREEN */
// SP_VERB_VIEW_COLOR_MODE_PRINT_COLORS_PREVIEW,
/* Dialogs */
/* Help */
//SP_VERB_SHOW_LICENSE,
/* Tutorials */
#if HAVE_POTRACE
#endif
/* Effects */
/* Fit Canvas */
/* LockAndHide */
/* Color management */
/*Scripting*/
/* Alignment */
/* Footer */
};
#include <map>
#include <vector>
/**
* A class to represent things the user can do. In many ways
* these are 'action factories' as they are used to create
* individual actions that are based on a given view.
*/
/** An easy to use defition of the table of verbs by code. */
/** A table of all the dynamically created verbs. */
/** The table of statically created verbs which are mostly
'base verbs'. */
/* Plus one because there is an entry for SP_VERB_LAST */
/** A string comparison function to be used in the Verb ID lookup
to find the different verbs in the hash map. */
struct ltstr {
return true;
return false;
} else {
}
}
};
/** An easy to use definition of the table of verbs by ID. */
/** Quick lookup of verbs by ID */
static VerbIDTable _verb_ids;
/** A simple typedef to make using the action table easier. */
/** A list of all the actions that have been created for this
verb. It is referenced by the view that they are created for. */
/** A unique textual ID for the verb. */
char const * _id;
/** The full name of the verb. (shown on menu entries) */
char const * _name;
/** Tooltip for the verb. */
char const * _tip;
char * _full_tip; // includes shortcut
unsigned int _shortcut;
/** Name of the image that represents the verb. */
char const * _image;
/**
* Unique numerical representation of the verb. In most cases
* it is a value from the anonymous enum at the top of this
* file.
*/
unsigned int _code;
/** Name of the group the verb belongs to. */
char const * _group;
/**
* Whether this verb is set to default to sensitive or
* insensitive when new actions are created.
*/
bool _default_sensitive;
/**
* Allows for preliminary setting of the \c _default_sensitive
* value without effecting existing actions.
* This function is mostly used at initialization where there are
* not actions to effect. I can't think of another case where it
* should be used.
*
* @param in_val New value.
*/
/** Accessor to get the \c _default_sensitive value. */
bool get_default_sensitive (void) { return _default_sensitive; }
/** Accessor to get the internal variable. */
/** Accessor to get the internal variable. */
/** Accessor to get the internal variable. */
/** Accessor to get the internal variable. */
char const * get_short_tip (void) { return _tip; };
/** Accessor to get the internal variable. */
char const * get_tip (void) ;
/** Accessor to get the internal variable. */
/** Get the verbs group */
/** Set the name after initialization. */
/** Set the tooltip after initialization. */
SPAction *make_action_helper (Inkscape::ActionContext const & context, void (*perform_fun)(SPAction *, void *), void *in_pntr = NULL);
/**
* Inititalizes the Verb with the parameters.
*
* This function also sets \c _actions to NULL.
*
* @warning NO DATA IS COPIED BY CALLING THIS FUNCTION.
*
* In many respects this is very bad object oriented design, but it
* is done for a reason. All verbs today are of two types: 1) static
* or 2) created for extension. In the static case all of the
* strings are constants in the code, and thus don't really need to
* be copied. In the extensions case the strings are identical to
* the ones already created in the extension object, copying them
* would be a waste of memory.
*
* @param code Goes to \c _code.
* @param id Goes to \c _id.
* @param name Goes to \c _name.
* @param tip Goes to \c _tip.
* @param image Goes to \c _image.
*/
char const * id,
char const * name,
char const * tip,
char const * image,
char const * group) :
_actions(0),
_full_tip(0),
_shortcut(0),
_default_sensitive(true)
{
}
Verb (char const * id, char const * name, char const * tip, char const * image, char const * group);
/**
* A function to turn a code into a verb.
*
* This is an inline function to translate the codes which are
* static quickly. This should optimize into very quick code
* everywhere which hard coded \c codes are used. In the case
* where the \c code is not static the \c get_search function
* is used.
*
* @param code The code to be translated
* @return A pointer to a verb object or a NULL if not found.
*/
if (code <= SP_VERB_LAST) {
return _base_verbs[code];
} else {
return get_search(code);
}
}
/**
* Print a message to stderr indicating that this verb needs a GUI to run
*/
// Yes, multiple public, protected and private sections are bad. We'll clean that up later
/**
* Returns the size of the internal base verb array.
*
* This is an inline function intended for testing. This should normally not be used.
* For testing, a subclass that returns this value can be created to verify that the
* length matches the enum values, etc.
*
* @return The size in elements of the internal base array.
*/
static void list (void);
}; /* Verb class */
} /* Inkscape namespace */
#endif // SEEN_SP_VERBS_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :