color-notebook.cpp revision a24300c2eab4cabe40a694337648df816de022ff
/**
* @file
* A notebook with RGB, CMYK, CMS, HSL, and Wheel pages - implementation
*/
/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Tomasz Boczkowski <penginsbacon@gmail.com> (c++-sification)
*
* Copyright (C) 2001-2014 Authors
*
* 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 <gtkmm/notebook.h>
#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"
#define XPAD 4
#define YPAD 1
namespace Inkscape {
namespace UI {
namespace Widget {
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#endif
_initUI();
_selected_color.signal_changed.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorChanged));
_selected_color.signal_dragged.connect(sigc::mem_fun(this, &ColorNotebook::_onSelectedColorChanged));
}
{
if ( _buttons )
{
delete [] _buttons;
_buttons = 0;
}
}
{
}
void ColorNotebook::_initUI()
{
notebook->set_show_border(false);
notebook->set_show_tabs(false);
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
_addPage(_available_pages[i]);
}
#if GTK_CHECK_VERSION(3,0,0)
#else
attach(*Glib::wrap(_buttonbox), 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, static_cast<Gtk::AttachOptions>(0), XPAD, YPAD);
#endif
row++;
#if GTK_CHECK_VERSION(3,0,0)
#else
attach(*notebook, 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, XPAD * 2, YPAD);
#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::_onPickerClicked), this);
/* 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
#endif
#ifdef SPCS_PREVIEW
#endif
}
{
// Set the dropper into a "one click" mode, so it reverts to the previous tool after a click
}
{
return;
}
}
}
}
void ColorNotebook::_onSelectedColorChanged() {
}
{
if (colorbook) {
// remember the page we switched to
}
}
// 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)
{
}
}
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) {
}
}
}
}
}
}
/* 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 :