color-notebook.cpp revision ae6e93089ea75b10dd594e4750ae5a5df1d7353d
/*
* A notebook with RGB, CMYK, CMS, HSL, and Wheel pages
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
*
* This code is in public domain
*/
#define noDUMP_CHANGE_INFO
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstddef>
#include "dialogs/dialog-events.h"
#include "preferences.h"
#include "widgets/spw-utilities.h"
#include "svg/svg-icc-color.h"
#include "inkscape.h"
#include "document.h"
#include "profile-manager.h"
#include "color-profile.h"
#include "cms-system.h"
#include "tools-switch.h"
#include "ui/tools/tool-base.h"
#include "ui/widget/color-entry.h"
#include "ui/widget/color-icc-selector.h"
#include "ui/widget/color-notebook.h"
#include "ui/widget/color-scales.h"
#include "ui/widget/color-wheel-selector.h"
struct SPColorNotebookTracker {
};
static SPColorSelectorClass *parent_class;
#define XPAD 4
#define YPAD 1
{
if (!type) {
sizeof(SPColorNotebookClass),
0, // base_init
0, // base_finalize
0, // class_finalize
0, // class_data
sizeof(SPColorNotebook),
0, // n_preallocs
0 // value_table
};
type = g_type_register_static(SP_TYPE_COLOR_SELECTOR, "SPColorNotebook", &info, static_cast<GTypeFlags>(0));
}
return type;
}
{
}
static void
{
if ( colorbook )
{
// remember the page we switched to
}
}
static void
{
{
}
}
void ColorNotebook::init()
{
_updating = false;
_book = gtk_notebook_new ();
// Dont show the notebook tabs, use radiobuttons instead
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
_addPage(_available_pages[i]);
}
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
#if GTK_CHECK_VERSION(3,0,0)
#else
static_cast<GtkAttachOptions>(0),
#endif
row++;
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// restore the last active page
/* Commented out: see comment at the bottom of the header file
{
gboolean found = FALSE;
_popup = gtk_menu_new();
GtkMenu *menu = GTK_MENU (_popup);
for (int i = 0; i < _trackerList->len; i++ )
{
SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (g_ptr_array_index (_trackerList, i));
if ( entry )
{
GtkWidget *item = gtk_check_menu_item_new_with_label (_(entry->name));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), entry->enabledFull);
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
g_signal_connect (G_OBJECT (item), "activate",
G_CALLBACK (sp_color_notebook_menuitem_response),
reinterpret_cast< gpointer > (entry) );
found = TRUE;
}
}
GtkWidget *arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
gtk_widget_show (arrow);
_btn = gtk_button_new ();
gtk_widget_show (_btn);
gtk_container_add (GTK_CONTAINER (_btn), arrow);
GtkWidget *align = gtk_alignment_new (1.0, 0.0, 0.0, 0.0);
gtk_widget_show (align);
gtk_container_add (GTK_CONTAINER (align), _btn);
// but first fix it so it remembers its settings in prefs and does not take that much space (entire vertical column!)
gtk_table_attach (GTK_TABLE (table), align, 2, 3, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD);
g_signal_connect_swapped(G_OBJECT(_btn), "event", G_CALLBACK (sp_color_notebook_menu_handler), G_OBJECT(_csel));
if ( !found )
{
gtk_widget_set_sensitive (_btn, FALSE);
}
}
*/
row++;
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/* Create color management icons */
GtkWidget *colormanaged = gtk_image_new_from_icon_name ("color-management-icon", GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_set_sensitive (_box_colormanaged, false);
GtkWidget *outofgamut = gtk_image_new_from_icon_name ("out-of-gamut-icon", GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_set_sensitive (_box_outofgamut, false);
GtkWidget *toomuchink = gtk_image_new_from_icon_name ("too-much-ink-icon", GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_set_sensitive (_box_toomuchink, false);
#endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/* Color picker */
_btn_picker = gtk_button_new ();
g_signal_connect(G_OBJECT(_btn_picker), "clicked", G_CALLBACK(ColorNotebook::_picker_clicked), _csel);
/* Create RGBA entry and color preview */
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
//the "too much ink" icon is initially hidden
#endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#if GTK_CHECK_VERSION(3,0,0)
#else
gtk_table_attach (GTK_TABLE (table), rgbabox, 0, 2, row, row + 1, GTK_FILL, GTK_SHRINK, XPAD, YPAD);
#endif
#ifdef SPCS_PREVIEW
#endif
_selected_color.signal_changed.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorChanged));
_selected_color.signal_dragged.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorDragged));
_selected_color.signal_grabbed.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorGrabbed));
_selected_color.signal_released.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorReleased));
}
{
}
{
if ( _switchId )
{
if ( _book )
{
_switchId = 0;
}
}
if ( _buttons )
{
delete [] _buttons;
_buttons = 0;
}
}
static void
{
}
{
}
{
return GTK_WIDGET(colorbook);
}
: ColorSelector( csel )
{
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#endif
}
SPColorSelector *s = SP_COLOR_SELECTOR(w);
}
{
}
void ColorNotebook::_colorChanged()
{
_updating = true;
_updating = false;
}
{
// Set the dropper into a "one click" mode, so it reverts to the previous tool after a click
}
// TODO pass in param so as to avoid the need for SP_ACTIVE_DOCUMENT
void ColorNotebook::_updateICCButtons()
{
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/* update color management icon*/
/* update out-of-gamut icon */
gtk_widget_set_sensitive (_box_outofgamut, false);
Inkscape::ColorProfile* target_profile = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str());
if ( target_profile )
}
/* update too-much-ink icon */
gtk_widget_set_sensitive (_box_toomuchink, false);
Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str());
double ink_sum = 0;
}
/* Some literature states that when the sum of paint values exceed 320%, it is considered to be a satured color,
which means the paper can get too wet due to an excessive ammount of ink. This may lead to several issues
such as misalignment and poor quality of printing in general.*/
if ( ink_sum > 3.2 )
gtk_widget_set_sensitive (_box_toomuchink, true);
} else {
}
}
#endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
}
void ColorNotebook::_setCurrentPage(int i)
{
}
}
{
return;
}
}
}
}
void ColorNotebook::_onSelectedColorChanged() {
if (_updating) {
return;
}
}
void ColorNotebook::_onSelectedColorDragged() {
if (_updating) {
return;
}
}
void ColorNotebook::_onSelectedColorGrabbed() {
if (_updating) {
return;
}
_grabbed();
}
void ColorNotebook::_onSelectedColorReleased() {
if (_updating) {
return;
}
_released();
}
if (selector_widget) {
selector_widget->show();
gint page_num = gtk_notebook_append_page( GTK_NOTEBOOK(_book), selector_widget->gobj(), tab_label->gobj());
if (page_num > 0) {
}
}
return selector_widget->gobj();
}
/* Commented out: see comment at the bottom of the header file
GtkWidget* ColorNotebook::getPage(GType page_type, guint submode)
{
gint count = 0;
gint i = 0;
GtkWidget* page = 0;
// count = gtk_notebook_get_n_pages (_book);
count = 200;
for ( i = 0; i < count && !page; i++ )
{
page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (_book), i);
if ( page )
{
SPColorSelector* csel;
guint pagemode;
csel = SP_COLOR_SELECTOR (page);
pagemode = csel->base->getSubmode();
if ( G_TYPE_FROM_INSTANCE (page) == page_type
&& pagemode == submode )
{
// found it.
break;
}
else
{
page = 0;
}
}
else
{
break;
}
}
return page;
}
void ColorNotebook::removePage( GType page_type, guint submode )
{
GtkWidget *page = 0;
page = getPage(page_type, submode);
if ( page )
{
gint where = gtk_notebook_page_num (GTK_NOTEBOOK (_book), page);
if ( where >= 0 )
{
if ( gtk_notebook_get_current_page (GTK_NOTEBOOK (_book)) == where )
{
// getColorAlpha(_color, &_alpha);
}
gtk_notebook_remove_page (GTK_NOTEBOOK (_book), where);
}
}
}
static gint sp_color_notebook_menu_handler( GtkWidget *widget, GdkEvent *event )
{
if (event->type == GDK_BUTTON_PRESS)
{
SPColorSelector* csel = SP_COLOR_SELECTOR(widget);
(dynamic_cast<ColorNotebook*>(csel->base))->menuHandler( event );
// Tell calling code that we have handled this event; the buck
// stops here.
return TRUE;
}
//Tell calling code that we have not handled this event; pass it on.
return FALSE;
}
gint ColorNotebook::menuHandler( GdkEvent* event )
{
GdkEventButton *bevent = (GdkEventButton *) event;
gtk_menu_popup (GTK_MENU( _popup ), NULL, NULL, NULL, NULL,
bevent->button, bevent->time);
return TRUE;
}
static void sp_color_notebook_menuitem_response (GtkMenuItem *menuitem, gpointer user_data)
{
gboolean active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem));
SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (user_data);
if ( entry )
{
if ( active )
{
(dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(entry->backPointer)->base))->addPage(entry->type, entry->submode);
}
else
{
(dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(entry->backPointer)->base))->removePage(entry->type, entry->submode);
}
}
}
*/
/*
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 :