Back to index

texmacs  1.0.7.15
qt_color_picker_widget.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003  * MODULE     : qt_color_picker_widget.cpp
00004  * DESCRIPTION: 
00005  * COPYRIGHT  : (C) 2010 Miguel de Benito Delgado
00006  *******************************************************************************
00007  * This software falls under the GNU general public license version 3 or later.
00008  * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009  * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010  ******************************************************************************/
00011 
00012 #include "qt_color_picker_widget.hpp"
00013 #include "qt_utilities.hpp"
00014 
00015 #include "message.hpp"
00016 #include "scheme.hpp"
00017 
00018 #include <QColorDialog>
00019 
00020 
00024 inline tm_ostream& 
00025 operator<< (tm_ostream& out, const QColor& col) {
00026   return out << "Color: " << col << "\n";
00027 }
00028 
00029 qt_color_picker_widget_rep::qt_color_picker_widget_rep 
00030   (command call_back, bool pickPattern, array<tree> proposals)
00031 : _commandAfterExecution(call_back), _pickPattern(pickPattern)
00032 {
00033   (void) proposals;
00034 }
00035 
00036 qt_color_picker_widget_rep::~qt_color_picker_widget_rep() { }
00037 
00038 void
00039 qt_color_picker_widget_rep::send (slot s, blackbox val) {
00040   if (DEBUG_QT)
00041     cout << "qt_color_picker_widget_rep::send " << slot_name(s) << LF;
00042   switch (s) {
00043     case SLOT_VISIBILITY:   // Activates the widget
00044       TYPE_CHECK (type_box (val) == type_helper<bool>::id);
00045       if (open_box<bool>(val) == true)
00046         showDialog();
00047       break;
00048     default:
00049       qt_widget_rep::send (s, val);
00050   }
00051 }
00052 
00056 widget
00057 qt_color_picker_widget_rep::plain_window_widget (string title, command q)
00058 {
00059   _windowTitle = title;
00060   (void) q;
00061   return this;
00062 }
00063 
00064 void
00065 qt_color_picker_widget_rep::showDialog() {
00066   if (_pickPattern) {
00067     // do stuff
00068   } else {
00069 #if 0 //(QT_VERSION >= 0x040500)
00070     QColor _sel = QColorDialog::getColor(Qt::white, 0, to_qstring(_windowTitle));
00071 #else
00072     QColor _sel = QColorDialog::getColor(Qt::white);
00073 #endif
00074     if(_sel.isValid()) {
00075       _commandAfterExecution (list_object (object (tree (from_qcolor (_sel)))));
00076     }
00077   }
00078 }
00079