本文整理汇总了C++中SPObject::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ SPObject::getId方法的具体用法?C++ SPObject::getId怎么用?C++ SPObject::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPObject
的用法示例。
在下文中一共展示了SPObject::getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// For debugging
Glib::ustring
DrawingItem::name()
{
SPObject *object = static_cast<SPObject *>(_user_data);
if (object) {
if(object->getId())
return object->getId();
else
return "No object id";
} else {
return "No associated object";
}
}
示例2: _updateMessageFromSelection
void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) {
GSList const *items = selection->itemList();
if (!items) { // no items
_context.set(Inkscape::NORMAL_MESSAGE, _when_nothing);
} else {
SPItem *item = SP_ITEM(items->data);
SPObject *layer = selection->desktop()->layerForObject(item);
SPObject *root = selection->desktop()->currentRoot();
// Layer name
gchar *layer_name;
if (layer == root) {
layer_name = g_strdup(_("root"));
} else {
char const *layer_label;
bool is_label = false;
if (layer->label()) {
layer_label = layer->label();
is_label = true;
} else {
layer_label = layer->defaultLabel();
}
char *quoted_layer_label = xml_quote_strdup(layer_label);
if (is_label) {
layer_name = g_strdup_printf(_("layer <b>%s</b>"), quoted_layer_label);
} else {
layer_name = g_strdup_printf(_("layer <b><i>%s</i></b>"), quoted_layer_label);
}
g_free(quoted_layer_label);
}
// Parent name
SPObject *parent = item->parent;
gchar const *parent_label = parent->getId();
char *quoted_parent_label = xml_quote_strdup(parent_label);
gchar *parent_name = g_strdup_printf(_("<i>%s</i>"), quoted_parent_label);
g_free(quoted_parent_label);
gchar *in_phrase;
guint num_layers = selection->numberOfLayers();
guint num_parents = selection->numberOfParents();
if (num_layers == 1) {
if (num_parents == 1) {
if (layer == parent)
in_phrase = g_strdup_printf(_(" in %s"), layer_name);
else
in_phrase = g_strdup_printf(_(" in group %s (%s)"), parent_name, layer_name);
} else {
in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> parents (%s)", " in <b>%i</b> parents (%s)", num_parents), num_parents, layer_name);
}
} else {
in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> layers", " in <b>%i</b> layers", num_layers), num_layers);
}
g_free (layer_name);
g_free (parent_name);
if (!items->next) { // one item
char *item_desc = item->description();
if (SP_IS_USE(item) && SP_IS_SYMBOL(item->firstChild())) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Convert symbol to group to edit"), _when_selected);
} else if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up original"), _when_selected);
} else if (SP_IS_TEXT_TEXTPATH(item)) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up path"), _when_selected);
} else if (SP_IS_FLOWTEXT(item) && !SP_FLOWTEXT(item)->has_internal_frame()) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up frame"), _when_selected);
} else {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s.",
item_desc, in_phrase, _when_selected);
}
g_free(item_desc);
} else { // multiple items
int object_count = g_slist_length((GSList *)items);
gchar *objects_str = NULL;
GSList *terms = collect_terms ((GSList *)items);
int n_terms = g_slist_length(terms);
if (n_terms == 0) {
objects_str = g_strdup_printf (
// this is only used with 2 or more objects
ngettext("<b>%i</b> object selected", "<b>%i</b> objects selected", object_count),
object_count);
} else if (n_terms == 1) {
objects_str = g_strdup_printf (
// this is only used with 2 or more objects
ngettext("<b>%i</b> object of type <b>%s</b>", "<b>%i</b> objects of type <b>%s</b>", object_count),
object_count, (gchar *) terms->data);
} else if (n_terms == 2) {
objects_str = g_strdup_printf (
// this is only used with 2 or more objects
ngettext("<b>%i</b> object of types <b>%s</b>, <b>%s</b>", "<b>%i</b> objects of types <b>%s</b>, <b>%s</b>", object_count),
//.........这里部分代码省略.........
示例3: gtk_entry_set_text
/**
* \param selection Selection to use; should not be NULL.
*/
static void
sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection )
{
g_assert (selection != NULL);
if (gtk_object_get_data (GTK_OBJECT (spw), "blocked"))
return;
if (!selection->singleItem()) {
gtk_widget_set_sensitive (GTK_WIDGET (spw), FALSE);
return;
} else {
gtk_widget_set_sensitive (GTK_WIDGET (spw), TRUE);
}
gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE));
SPItem *item = selection->singleItem();
/* Sensitive */
GtkWidget *w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "sensitive"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), item->isLocked());
/* Hidden */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "hidden"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), item->isExplicitlyHidden());
if (SP_OBJECT_IS_CLONED (item)) {
/* ID */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
gtk_entry_set_text (GTK_ENTRY (w), "");
gtk_widget_set_sensitive (w, FALSE);
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
gtk_label_set_text (GTK_LABEL (w), _("Ref"));
/* Label */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
gtk_entry_set_text (GTK_ENTRY (w), "");
gtk_widget_set_sensitive (w, FALSE);
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label_label"));
gtk_label_set_text (GTK_LABEL (w), _("Ref"));
} else {
SPObject *obj = (SPObject*)item;
/* ID */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
gtk_entry_set_text (GTK_ENTRY (w), obj->getId());
gtk_widget_set_sensitive (w, TRUE);
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
gtk_label_set_markup_with_mnemonic (GTK_LABEL (w), _("_Id"));
/* Label */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
gtk_entry_set_text (GTK_ENTRY (w), obj->defaultLabel());
gtk_widget_set_sensitive (w, TRUE);
/* Title */
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title"));
gchar *title = obj->title();
if (title) {
gtk_entry_set_text(GTK_ENTRY(w), title);
g_free(title);
}
else gtk_entry_set_text(GTK_ENTRY(w), "");
gtk_widget_set_sensitive(w, TRUE);
/* Description */
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc"));
GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w));
gchar *desc = obj->desc();
if (desc) {
gtk_text_buffer_set_text(buf, desc, -1);
g_free(desc);
} else {
gtk_text_buffer_set_text(buf, "", 0);
}
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc_frame"));
gtk_widget_set_sensitive(w, TRUE);
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity"));
GtkWidget* int_table = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity_table"));
if (int_table){
gtk_container_remove(GTK_CONTAINER(w), int_table);
}
const gchar* int_labels[10] = {"onclick", "onmouseover", "onmouseout", "onmousedown", "onmouseup", "onmousemove","onfocusin", "onfocusout", "onactivate", "onload"};
int_table = sp_attribute_table_new (obj, 10, int_labels, int_labels);
gtk_widget_show_all (int_table);
gtk_object_set_data(GTK_OBJECT(spw), "interactivity_table", int_table);
gtk_container_add (GTK_CONTAINER (w), int_table);
}
//.........这里部分代码省略.........
示例4: set
void SPObject::set(unsigned int key, gchar const* value) {
g_assert(key != SP_ATTR_INVALID);
SPObject* object = this;
switch (key) {
case SP_ATTR_ID:
//XML Tree being used here.
if ( !object->cloned && object->getRepr()->type() == Inkscape::XML::ELEMENT_NODE ) {
SPDocument *document=object->document;
SPObject *conflict=NULL;
gchar const *new_id = value;
if (new_id) {
conflict = document->getObjectById((char const *)new_id);
}
if ( conflict && conflict != object ) {
if (!document->isSeeking()) {
sp_object_ref(conflict, NULL);
// give the conflicting object a new ID
gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL);
conflict->getRepr()->setAttribute("id", new_conflict_id);
g_free(new_conflict_id);
sp_object_unref(conflict, NULL);
} else {
new_id = NULL;
}
}
if (object->getId()) {
document->bindObjectToId(object->getId(), NULL);
SPObjectImpl::setId(object, 0);
}
if (new_id) {
SPObjectImpl::setId(object, new_id);
document->bindObjectToId(object->getId(), object);
}
g_free(object->_default_label);
object->_default_label = NULL;
}
break;
case SP_ATTR_INKSCAPE_LABEL:
g_free(object->_label);
if (value) {
object->_label = g_strdup(value);
} else {
object->_label = NULL;
}
g_free(object->_default_label);
object->_default_label = NULL;
break;
case SP_ATTR_INKSCAPE_COLLECT:
if ( value && !strcmp(value, "always") ) {
object->setCollectionPolicy(SPObject::ALWAYS_COLLECT);
} else {
object->setCollectionPolicy(SPObject::COLLECT_WITH_PARENT);
}
break;
case SP_ATTR_XML_SPACE:
if (value && !strcmp(value, "preserve")) {
object->xml_space.value = SP_XML_SPACE_PRESERVE;
object->xml_space.set = TRUE;
} else if (value && !strcmp(value, "default")) {
object->xml_space.value = SP_XML_SPACE_DEFAULT;
object->xml_space.set = TRUE;
} else if (object->parent) {
SPObject *parent;
parent = object->parent;
object->xml_space.value = parent->xml_space.value;
}
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
break;
case SP_ATTR_STYLE:
sp_style_read_from_object(object->style, object);
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
break;
default:
break;
}
}