verbs.h revision 2739452e5199717fdd2bec57a05ca3e987957088
#ifndef SEEN_SP_VERBS_H
#define SEEN_SP_VERBS_H
/** \file
* \brief Frontend to actions
*
* 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
*/
#include <cstring>
#include <string>
#include <string.h>
#include "config.h"
#include "require-config.h" /* HAVE_GTK_WINDOW_FULLSCREEN */
#include "helper/helper-forward.h"
#include "forward.h"
/** \brief 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_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 */
/* Layer */
/* Object */
/* Tools */
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 */
/* Zooming and desktop settings */
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
#endif /* HAVE_GTK_WINDOW_FULLSCREEN */
// SP_VERB_VIEW_COLOR_MODE_PRINT_COLORS_PREVIEW,
/* Dialogs */
/*#ifdef WITH_INKBOARD
SP_VERB_XMPP_CLIENT,
#endif*/
/* Help */
//SP_VERB_SHOW_LICENSE,
/* Tutorials */
/* Effects */
/* Fit Canvas */
/* LockAndHide */
/* Color management */
/*Scripting*/
/* Footer */
};
#include <map>
/** \brief 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.
*/
/** \brief An easy to use defition of the table of verbs by code. */
/** \brief A table of all the dynamically created verbs. */
/** \brief 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 {
}
}
};
/** \brief An easy to use definition of the table of verbs by ID. */
/** \brief Quick lookup of verbs by ID */
static VerbIDTable _verb_ids;
/** \brief A simple typedef to make using the action table easier. */
/** \brief A list of all the actions that have been created for this
verb. It is referenced by the view that they are created for. */
/** \brief A unique textual ID for the verb. */
/** \brief The full name of the verb. (shown on menu entries) */
/** \brief Tooltip for the verb. */
unsigned int _shortcut;
/** \brief Name of the image that represents the verb. */
/** \brief 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;
/** \brief Whether this verb is set to default to sensitive or
insensitive when new actions are created. */
bool _default_sensitive;
/** \brief Allows for preliminary setting of the \c _default_sensitive
value without effecting existing actions
\param in_val New value
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.
*/
/** \brief Accessor to get the \c _default_sensitive value */
bool get_default_sensitive (void) { return _default_sensitive; }
/** \brief Accessor to get the internal variable. */
/** \brief Accessor to get the internal variable. */
/** \brief Accessor to get the internal variable. */
/** \brief Accessor to get the internal variable. */
/** \brief Accessor to get the internal variable. */
/** \brief Set the name after initialization. */
/** \brief Set the tooltip after initialization. */
SPAction * make_action_helper (Inkscape::UI::View::View * view, SPActionEventVector * vector, void * in_pntr = NULL);
/** \brief Inititalizes the Verb with the parameters
\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
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.
*/
_actions(0),
_full_tip(0),
_shortcut(0),
_default_sensitive(true)
{
}
/** \brief A function to turn a code into a verb.
\param code The code to be translated
\return A pointer to a verb object or a NULL if not found.
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.
*/
if (code <= SP_VERB_LAST) {
return _base_verbs[code];
} else {
return get_search(code);
}
}
// Yes, multiple public, protected and private sections are bad. We'll clean that up later
/** \brief Returns the size of the internal base verb array.
\return The size in elements of the internal base 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.
*/
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 :