icon.cpp revision c879fdcc23d547db88270136480d08c5a13da9ff
/** \file
* SPIcon: Generic icon widget
*/
/*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2002 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "path-prefix.h"
#include <gtk/gtkiconfactory.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkimage.h>
#include "prefs-utils.h"
#include "inkscape.h"
#include "document.h"
#include "sp-item.h"
#include "display/nr-arena.h"
#include "display/nr-arena-item.h"
#include "icon.h"
static int sp_icon_get_phys_size(int size);
unsigned r, unsigned g, unsigned b );
static void injectCustomSize();
static GtkWidgetClass *parent_class;
static bool sizeDirty = true;
static bool sizeMapDone = false;
static GtkIconSize iconSizeLookup[] = {
GTK_ICON_SIZE_MENU, // for Inkscape::ICON_SIZE_DECORATION
};
{
if (!type) {
GtkTypeInfo info = {
"SPIcon",
sizeof(SPIcon),
sizeof(SPIconClass),
};
}
return type;
}
static void
{
}
static void
{
}
static void
{
}
}
}
}
}
}
static void
{
}
static void
{
if (GTK_WIDGET_DRAWABLE(widget)) {
}
}
{
if ( GTK_WIDGET_DRAWABLE(widget) ) {
if (pixels) {
// don't pass the nr_free because we're caching the pixel
// space loaded through ...
// I just changed this. make sure sp_icon_image_load still does the right thing.
row_pixels += 4;
}
}
} else {
/* TODO: We should do something more useful if we can't load the image. */
}
}
}
return TRUE;
}
{
}
}
{
}
}
{
//g_message("Got a change bump for this icon");
sizeDirty = true;
}
static GtkWidget *
{
}
}
if ( tryLoad ) {
gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
if ( !sizeMapDone ) {
}
if ( img ) {
if ( type == GTK_IMAGE_STOCK ) {
img = 0;
if ( dump ) {
}
} else {
if ( dump ) {
}
img = 0;
}
}
}
if ( !widget ) {
}
return widget;
}
{
}
{
if ( widget ) {
if ( GTK_IS_IMAGE(widget) ) {
} else {
}
}
return result;
}
// Try to load the named svg, falling back to pixmaps
guchar *
{
if (!px) {
}
return px;
}
sp_icon_get_gtk_size(int size)
{
static int count = 0;
char c[64];
}
}
static void injectCustomSize()
{
// TODO - still need to handle the case of theme changes and resize, especially as we can't re-register a string.
if ( !sizeMapDone )
{
if ( newSizeEnum ) {
if ( dump ) {
g_message("Registered (%d, %d) <= (%d, %d) as index %d", newWidth, newHeight, width, height, newSizeEnum);
}
} else if ( dump ) {
g_message("size lookup array too small to store entry");
}
}
}
sizeMapDone = true;
}
}
static int sp_icon_get_phys_size(int size)
{
static bool init = false;
if ( !sizeMapDone ) {
}
GtkIconSize const gtkSizes[] = {
};
guint const val_ix = (gtkSizes[i] <= GTK_ICON_SIZE_DIALOG) ? (guint)gtkSizes[i] : (guint)Inkscape::ICON_SIZE_DECORATION;
}
}
}
if ( !init ) {
sizeDirty = false;
if ( dump ) {
g_message( "Default icon sizes:" );
}
GtkIconSize const gtkSizes[] = {
};
"GTK_ICON_SIZE_MENU",
"GTK_ICON_SIZE_SMALL_TOOLBAR",
"GTK_ICON_SIZE_LARGE_TOOLBAR",
"GTK_ICON_SIZE_BUTTON",
"GTK_ICON_SIZE_DND",
"GTK_ICON_SIZE_DIALOG",
"inkscape-decoration"
};
for (unsigned i = 0; i < G_N_ELEMENTS(gtkSizes); ++i) {
guint const val_ix = (gtkSizes[i] <= GTK_ICON_SIZE_DIALOG) ? (guint)gtkSizes[i] : (guint)Inkscape::ICON_SIZE_DECORATION;
bool used = false;
used = true;
}
if (dump) {
g_message(" =-- %u size:%d %c(%d, %d) '%s'",
i, gtkSizes[i],
}
if (pb) {
// TODO perhaps check a few more stock icons to get a range on sizes.
if ( newSize > 0 ) {
}
if (dump) {
}
}
}
//g_object_unref(icon);
init = true;
}
}
{
if (image) {
: 0 );
: 0 );
int const x1 = std::min(area->x + area->width, widget.allocation.x + padx + static_cast<int>(icon->psize) );
int const y1 = std::min(area->y + area->height, widget.allocation.y + pady + static_cast<int>(icon->psize) );
}
}
static guchar *
{
// TODO: bulia, please look over
gsize bytesWritten = 0;
-1,
&error);
if (!pb) {
// TODO: bulia, please look over
gsize bytesWritten = 0;
-1,
&error);
}
if (pb) {
if (!gdk_pixbuf_get_has_alpha(pb))
}
for (unsigned y = 0; y < psize; y++) {
}
return px;
}
return NULL;
}
// takes doc, root, icon, and icon name to produce pixels
extern "C" guchar *
{
if (doc) {
/* Find bbox in document */
{
}
/* This is in document coordinates, i.e. pixels */
/* Update to renderable state */
double sf = 1.0;
NRMatrix t;
/* Item integer bbox in points */
if ( dump ) {
g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 );
}
/* Find button visible area */
if ( dump ) {
}
{
if ( dump ) {
g_message(" resizing" );
}
/* Item integer bbox in points */
if ( dump ) {
g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 );
}
/* Find button visible area */
if ( dump ) {
}
}
}
//dx = (psize - width) / 2;
//dy = (psize - height) / 2;
dx=(dx-width)/2; // watch out for psize, since 'unsigned'-'signed' can cause problems if the result is negative
/* Actual renderable area */
if ( dump ) {
g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.x0, (double)area.y0, (double)area.x1, (double)area.y1 );
g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.x0, (double)ua.y0, (double)ua.x1, (double)ua.y1 );
}
/* Set up pixblock */
/* Render */
NRPixBlock B;
nr_pixblock_release(&B);
if ( useOverlay ) {
}
}
}
}
return px;
} // end of sp_icon_doc_icon()
struct svg_doc_cache_t
{
};
{
key += ":";
key += ":";
return key;
}
}
return NULL;
}
{
// Fall back from user prefs dir into system locations.
iconsvg += ".svg";
// Try each document in turn until we successfully load the icon from one
// Did we already load this doc?
info = 0;
{
}
}
/* Try to load from document. */
if (!info &&
// prep the document
/* Create new arena */
/* Create ArenaItem and set transform */
/* fixme: Memory manage root if needed (Lauris) */
// store into the cache
info = new svg_doc_cache_t;
}
if (info) {
}
// toss the filename
// move on to the next document if we couldn't get anything
}
return px;
}
// returns true if icon needed preloading, false if nothing was done
{
if (px) {
return false;
} else {
if (px) {
}
return true;
}
}
static guchar *
{
if (!px) {
if (px) {
}
}
return px;
}
unsigned r, unsigned g, unsigned b)
{
for ( int y = 0; y < height; y += 4 ) {
for ( int x = 0; x < width; x += 4 ) {
*(ptr++) = r;
*(ptr++) = g;
*(ptr++) = b;
*(ptr++) = 0xff;
}
}
// point at the last pixel
if ( width > 2 ) {
px[4] = r;
px[5] = g;
px[6] = b;
ptr[-12] = r;
ptr[-11] = g;
ptr[-10] = b;
}
ptr[-4] = r;
ptr[-3] = g;
ptr[-2] = b;
if ( height > 2 ) {
}
}
}
class preRenderItem
{
public:
{}
};
#include <queue>
static bool callbackHooked = false;
{
if ( !callbackHooked )
{
callbackHooked = true;
}
}
if (!pendingRenders.empty()) {
}
if (!pendingRenders.empty()) {
return TRUE;
} else {
callbackHooked = false;
return FALSE;
}
}
/*
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:encoding=utf-8:textwidth=99 :