Back to index

texmacs  1.0.7.15
qt_utilities.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : qt_utilities.hpp
00004 * DESCRIPTION: Utilities for QT
00005 * COPYRIGHT  : (C) 2008  Massimiliano Gubinelli
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 #ifndef QT_UTILITIES_HPP
00012 #define QT_UTILITIES_HPP
00013 
00014 #include "message.hpp"
00015 
00016 #include <QRect>
00017 #include <QSize>
00018 #include <QPoint>
00019 #include <QString>
00020 #include <QColor>
00021 
00022 class QStringList;
00023 
00024 typedef quartet<SI,SI,SI,SI> coord4;
00025 typedef pair<SI,SI> coord2;
00026 
00027 QColor to_qcolor (const string& );
00028 QColor to_qcolor (color c);
00029 string from_qcolor (const QColor& );
00030 QRect to_qrect (const coord4 & p);
00031 QPoint to_qpoint (const coord2 & p);
00032 QSize to_qsize (const coord2 & p);
00033 coord4 from_qrect (const QRect & rect);
00034 coord2 from_qpoint (const QPoint & pt);
00035 coord2 from_qsize (const QSize & s);
00036 QString to_qstylesheet(int style);
00037 QString to_qstylesheet(int style, color c);
00038 QSize qt_decode_length (string width, QWidget* qwid);
00039 
00040 QStringList to_qstringlist(array<string> l);
00041 array<string> from_qstringlist(const QStringList& l);
00042 QString to_qstring (string s);
00043 QString utf8_to_qstring (string s);  //<! convert a string with texmacs internal encoding to a QString via Utf8 encoding
00044 string from_qstring (const QString & s);  //<! convert an utf8 texmacs string to a QString
00045 string from_qstring_utf8 (const QString & s);  //<! convert a QString to a TeXmacs utf8 string
00046 string qt_translate (string s); 
00047 bool qt_supports (url u);
00048 void qt_image_size (url image, int& w, int& h);
00049 void qt_convert_image (url image, url dest, int w =0, int h =0);
00050 void qt_image_to_eps (url image, url eps, int w_pt =0, int h_pt =0, int dpi= 0);
00051 
00052 string qt_application_directory ();
00053 string qt_get_date (string lan, string fm);
00054 
00055 bool qt_print (bool&, bool&, string&, url&, string&, string&, string&);
00056 
00057 /******************************************************************************
00058 * Type checking
00059 ******************************************************************************/
00060 
00061 inline void
00062 check_type_void (blackbox bb, string s) {
00063   if (!is_nil (bb)) {
00064     cerr << "\nslot type= " << s << "\n";
00065     FAILED ("type mismatch");
00066   }
00067 }
00068 
00069 template<class T> void
00070 check_type (blackbox bb, string s) {
00071   if (type_box (bb) != type_helper<T>::id) {
00072     cerr << "\nslot type= " << s << "\n";
00073     FAILED ("type mismatch");
00074   }
00075 }
00076 
00077 template<class T1, class T2> inline void
00078 check_type (blackbox bb, string s) {
00079   check_type<pair<T1,T2> > (bb, s);
00080 }
00081 
00082 extern widget the_keyboard_focus;
00083 
00084 extern int nr_windows; 
00085   // the run-loop should exit when the number of windows is zero
00086 
00090 extern tm_ostream& operator << (tm_ostream& out, QRect rect);
00091 #define TYPE_CHECK(b) ASSERT (b, "type mismatch")
00092 #define NOT_IMPLEMENTED \
00093 { if (DEBUG_QT) cout << "STILL NOT IMPLEMENTED\n"; }
00094 
00095 #endif  // QT_UTILITIES_HPP