13 #ifndef HAS_LIVES_WIDGET_HELPER_QT_H
14 #define HAS_LIVES_WIDGET_HELPER_QT_H
26 #include <QtCore/QLinkedList>
28 #include <QtGui/QScreen>
29 #include <QtGui/QWindow>
30 #include <QtGui/QTextCursor>
31 #include <QtGui/QTextDocumentFragment>
32 #include <QtGui/QShortcutEvent>
33 #include <QtGui/QWheelEvent>
34 #include <QtGui/QImageWriter>
35 #include <QtGui/QImageReader>
36 #include <QtCore/QDebug>
37 #include <QtCore/QTime>
38 #include <QtGui/QFont>
39 #include <QtGui/QFontDatabase>
40 #include <QtCore/QStandardPaths>
41 #include <QtCore/QLocale>
42 #include <QtCore/QMutableLinkedListIterator>
44 #include <QtWidgets/QApplication>
45 #include <QtWidgets/QDesktopWidget>
46 #include <QtWidgets/QCompleter>
47 #include <QtWidgets/QLabel>
48 #include <QtWidgets/QColorDialog>
49 #include <QtWidgets/QWidget>
50 #include <QtWidgets/QWidgetAction>
51 #include <QtWidgets/QStyledItemDelegate>
52 #include <QtWidgets/QHeaderView>
53 #include <QtWidgets/QSplitter>
54 #include <QtWidgets/QLineEdit>
55 #include <QtWidgets/QPushButton>
56 #include <QtWidgets/QToolButton>
57 #include <QtWidgets/QToolBar>
58 #include <QtWidgets/QTableWidget>
59 #include <QtWidgets/QDialog>
60 #include <QtWidgets/QMessageBox>
61 #include <QtWidgets/QDialogButtonBox>
62 #include <QtWidgets/QBoxLayout>
63 #include <QtWidgets/QComboBox>
64 #include <QtWidgets/QMenu>
65 #include <QtWidgets/QMenuBar>
66 #include <QtWidgets/QLabel>
67 #include <QtWidgets/QMainWindow>
68 #include <QtWidgets/QFileDialog>
69 #include <QtWidgets/QLayout>
70 #include <QtWidgets/QTextEdit>
71 #include <QtWidgets/QTreeWidget>
72 #include <QtWidgets/QRadioButton>
73 #include <QtWidgets/QButtonGroup>
74 #include <QtWidgets/QProgressBar>
75 #include <QtWidgets/QDoubleSpinBox>
76 #include <QtWidgets/QCheckBox>
77 #include <QtWidgets/QShortcut>
78 #include <QtWidgets/QGridLayout>
79 #include <QtWidgets/QFrame>
80 #include <QtWidgets/QGroupBox>
81 #include <QtWidgets/QScrollArea>
82 #include <QtWidgets/QScrollBar>
84 #include <QtGui/QColor>
85 #include <QtCore/QAbstractItemModel>
86 #include <QtWidgets/QAbstractSlider>
87 #include <QtWidgets/QAbstractButton>
88 #include <QtCore/QSharedPointer>
89 #include <QtGui/QStandardItemModel>
90 #include <QtCore/QModelIndex>
91 #include <QtCore/QTimer>
92 #include <QtCore/QThread>
93 #include <QtCore/QProcess>
94 #include <QtCore/QAbstractNativeEventFilter>
95 #include <QtCore/QCoreApplication>
100 #define GTK_CHECK_VERSION(a,b,c) 1
102 #define LIVES_LITTLE_ENDIAN 0
103 #define LIVES_BIG_ENDIAN 1
105 #define LIVES_MAXINT INT_MAX
106 #define LIVES_MAXUINT32 UINT32_MAX
107 #define LIVES_MAXSIZE SIZE_MAX
108 #define LIVES_MAXFLOAT FLT_MAX
110 #define LIVES_UNLIKELY(a) Q_UNLIKELY(a)
111 #define LIVES_LIKELY(a) Q_LIKELY(a)
113 #define MAX_CURSOR_WIDTH 32
115 #define G_GNUC_MALLOC
119 typedef void *livespointer;
120 typedef const void *livesconstpointer;
122 #define LIVES_INT_TO_POINTER(a) lives_int_to_pointer(a)
123 #define LIVES_UINT_TO_POINTER(a) lives_uint_to_pointer(a)
124 #define LIVES_POINTER_TO_INT(a) lives_pointer_to_int(a)
126 LIVES_INLINE livespointer lives_int_to_pointer(int32_t a) {
127 return (livespointer)a;
130 LIVES_INLINE livespointer lives_uint_to_pointer(uint32_t a) {
131 return (livespointer)a;
134 LIVES_INLINE int32_t lives_pointer_to_int(livesconstpointer p) {
135 uint64_t xint = (uint64_t)p;
136 return (int32_t)(xint & 0xFFFF);
140 livespointer(*malloc)(
size_t n_bytes);
141 livespointer(*realloc)(livespointer mem,
143 void (*free)(livespointer mem);
145 livespointer(*calloc)(
size_t n_blocks,
146 size_t n_block_bytes);
147 livespointer(*try_malloc)(
size_t n_bytes);
148 livespointer(*try_realloc)(livespointer mem,
152 LiVESMemVTable *static_alt_vtable;
155 livespointer(*lives_malloc)(
size_t size);
156 livespointer(*lives_realloc)(livespointer ptr,
size_t new_size);
157 livespointer(*lives_try_malloc)(
size_t size);
158 livespointer(*lives_try_realloc)(livespointer ptr,
size_t new_size);
159 livespointer(_lives_calloc)(
size_t n_blocks,
size_t n_block_bytes);
162 livespointer malloc_wrapper(
size_t size) {
163 livespointer ptr = (static_alt_vtable->malloc)(size);
164 Q_ASSERT(ptr != NULL);
169 livespointer realloc_wrapper(livespointer old_ptr,
size_t new_size) {
170 livespointer ptr = (static_alt_vtable->realloc)(old_ptr,new_size);
171 Q_ASSERT(ptr != NULL);
176 livespointer try_malloc_wrapper(
size_t size) {
177 return (static_alt_vtable->malloc)(size);
181 livespointer try_realloc_wrapper(livespointer old_ptr,
size_t new_size) {
182 return (static_alt_vtable->realloc)(old_ptr,new_size);
187 livespointer ptr = (static_alt_vtable->calloc)(1,size);
188 Q_ASSERT(ptr != NULL);
193 LIVES_INLINE livespointer lives_try_malloc0(
size_t size) {
194 return (static_alt_vtable->calloc)(1,size);
198 LIVES_INLINE livespointer lives_try_malloc0_n(
size_t nmemb,
size_t nmemb_bytes) {
199 return (static_alt_vtable->calloc)(nmemb,nmemb_bytes);
207 extern char *trString;
210 char *translate(
const char *String) {
212 if (strlen(String)) {
213 QString qs = QString::fromLocal8Bit(
dgettext(PACKAGE, String));
214 trString = strdup(qs.toUtf8().constData());
215 }
else trString=strdup(String);
219 char *translate_with_plural(
const char *String,
const char *StringPlural,
unsigned long int n) {
221 if (strlen(String)) {
222 QString qs = QString::fromLocal8Bit(
dngettext(PACKAGE, String, StringPlural, n));
223 trString = strdup(qs.toUtf8().constData());
224 }
else trString=strdup(String);
229 int lives_printerr(
const char *format, ...) {
232 va_start(args, format);
233 int r = vasprintf(&buff, format, args);
242 #define lives_strdup(a) strdup(a)
243 #define lives_strndup(a,b) strndup(a,b)
245 char *lives_strdup_printf(
const char *format, ...) {
248 va_start(args, format);
249 int r = vasprintf(&buff, format, args);
255 int lives_snprintf(
char *buff,
size_t len,
const char *format, ...) {
257 va_start(args, format);
258 int r = vsnprintf(buff, len, format, args);
264 void lives_strfreev(
char **str_array) {
266 for (
int i = 0; str_array[i] != NULL; i++)
272 #define ISUPPER(c) ((c) >= 'A' && (c) <= 'Z')
273 #define TOLOWER(c) (ISUPPER (c) ? (c) - 'A' + 'a' : (c))
275 int lives_ascii_strcasecmp(
const char *s1,
const char *s2) {
279 c1 = (int)(uint8_t) TOLOWER(*s1);
280 c2 = (int)(uint8_t) TOLOWER(*s2);
286 return (((
int)(uint8_t) *s1) - ((
int)(uint8_t) *s2));
290 int lives_ascii_strncasecmp(
const char *s1,
const char *s2,
size_t len) {
293 while (len && *s1 && *s2) {
295 c1 = (int)(uint8_t) TOLOWER(*s1);
296 c2 = (int)(uint8_t) TOLOWER(*s2);
302 if (len)
return (((
int)(uint8_t) *s1) - ((
int)(uint8_t) *s2));
307 char *lives_strconcat(
const char *string1, ...) {
315 l = 1 + strlen(string1);
316 va_start(args, string1);
317 s = va_arg(args,
char *);
320 s = va_arg(args,
char *);
323 concat = (
char *)malloc(l);
325 ptr = stpcpy(ptr, string1);
326 va_start(args, string1);
327 s = va_arg(args,
char *);
329 ptr = stpcpy(ptr, s);
330 s = va_arg(args,
char *);
338 char *lives_build_filename(
const char *first, ...) {
339 char *fname = strdup(
""), *tmp;
345 va_start(args, first);
347 piece = va_arg(args,
char *);
348 if (piece == NULL)
break;
349 if (strstr(piece,
"\\")) {
357 va_start(args, first);
359 piece = va_arg(args,
char *);
360 if (piece == NULL)
break;
361 tmp = lives_strdup_printf(
"%s%s%s",fname,sep,piece);
370 fname = strdup(QDir::cleanPath(qs).toUtf8().constData());
372 fname = strdup(QDir::cleanPath(qs).toLocal8Bit().constData());
378 char *lives_strstrip(
char *
string) {
379 QString qs = QString::fromUtf8(
string);
381 memcpy(
string,qs.toUtf8().constData(),qs.toUtf8().size());
386 char *lives_strrstr(
const char *haystack,
const char *needle) {
391 needle_len = strlen(needle);
392 haystack_len = strlen(haystack);
394 return (
char *)haystack;
395 if (haystack_len < needle_len)
397 p = haystack + haystack_len - needle_len;
398 while (p >= haystack) {
399 for (i = 0; i < needle_len; i++)
400 if (p[i] != needle[i])
411 LIVES_INLINE char *lives_filename_to_utf8(
const char *ostr, ssize_t len,
size_t *bytes_read,
size_t *bytes_written,
void *error) {
413 QString qs = QString::fromLocal8Bit(ostr);
414 return strdup(qs.toUtf8().constData());
420 LIVES_INLINE char *lives_filename_from_utf8(
const char *ostr, ssize_t len,
size_t *bytes_read,
size_t *bytes_written,
void *error) {
422 QString qs = QString::fromUtf8(ostr);
423 return strdup(qs.toLocal8Bit().constData());
430 #define LIVES_DIR_SEPARATOR_S "/"
432 #define LIVES_DIR_SEPARATOR_S "\\"
435 char *L2U8(
const char *local_string) {
437 QString qs = QString::fromLocal8Bit(local_string);
438 return strdup(qs.toUtf8().constData());
444 char *U82L(
const char *utf8_string) {
446 QString qs = QString::fromUtf8(utf8_string);
447 return strdup(qs.toLocal8Bit().constData());
454 char *lives_utf8_strdown(
char *
string,
size_t len) {
455 QString qs = QString::fromUtf8(
string);
457 return strdup(qs.toUtf8().constData());
462 #define ABS(a) qAbs(a)
465 char *lives_find_program_in_path(
const char *prog) {
466 QString qs = QStandardPaths::findExecutable(prog);
467 if (qs ==
"")
return NULL;
468 return strdup(qs.toLocal8Bit().constData());
481 typedef boolean(*LiVESWidgetSourceFunc)(livespointer data);
483 typedef int (*LiVESCompareFunc)(livesconstpointer a, livesconstpointer b);
495 uint32_t
lives_timer_add(uint32_t interval, LiVESWidgetSourceFunc
function, livespointer data);
498 #define G_PRIORITY_LOW 0
499 #define G_PRIORITY_HIGH 1
501 LIVES_INLINE uint32_t lives_idle_add_full(
int prio, LiVESWidgetSourceFunc
function, livespointer data, livespointer destnot) {
506 LIVES_INLINE uint32_t lives_idle_add(LiVESWidgetSourceFunc
function, livespointer data) {
511 #define g_object_freeze_notify(a) (a)
512 #define g_object_thaw_notify(a) (a)
515 LIVES_INLINE void lives_set_application_name(
const char *name) {
516 qapp->setApplicationName(QString::fromUtf8(name));
521 return qapp->applicationName().toLocal8Bit().constData();
525 class SleeperThread :
public QThread {
527 static void msleep(
unsigned long msecs) {
528 QThread::msleep(msecs);
533 SleeperThread::msleep(microsec);
537 LIVES_INLINE int lives_mkdir_with_parents(
const char *name,
int mode) {
539 mode_t omask = umask(mode);
541 QString qs = QString::fromUtf8(name);
543 bool ret = qd.mkpath(qs);
551 #define lives_strtod(a,b) strtod(a,b)
553 char *lives_path_get_basename(
const char *path) {
555 QString qs = qf.fileName();
556 return strdup(qs.toUtf8().constData());
559 char *lives_path_get_dirname(
const char *path) {
562 QString qs = dir.path();
563 return strdup(qs.toUtf8().constData());
567 typedef int LiVESFileTest;
568 #define LIVES_FILE_TEST_EXISTS 1
569 #define LIVES_FILE_TEST_IS_DIR 2
570 #define LIVES_FILE_TEST_IS_REGULAR 3
573 boolean lives_file_test(
const char *fname, LiVESFileTest test) {
575 if (test == LIVES_FILE_TEST_EXISTS) {
578 if (test == LIVES_FILE_TEST_IS_DIR) {
581 if (test == LIVES_FILE_TEST_IS_REGULAR) {
588 char *lives_get_current_dir() {
589 QString qs = QDir::current().path();
591 return strdup(qs.toUtf8().constData());
593 return strdup(qs.toLocal8Bit().constData());
603 typedef LiVESClosure LiVESWidgetClosure;
610 typedef void (*LiVESPixbufDestroyNotify)(uchar *, livespointer);
613 typedef int lives_painter_content_t;
624 if (error->message != NULL) free(error->message);
628 #define lives_strerror(a) strerror(a)
631 typedef QScreen LiVESXScreen;
632 typedef QScreen LiVESXDisplay;
633 typedef QScreen LiVESXDevice;
639 typedef QFile LiVESIOChannel;
647 typedef QStyle::StateFlag LiVESWidgetState;
649 #define LIVES_WIDGET_STATE_NORMAL QStyle::State_Enabled
650 #define LIVES_WIDGET_STATE_ACTIVE QStyle::State_Active
651 #define LIVES_WIDGET_STATE_PRELIGHT QStyle::State_MouseOver
652 #define LIVES_WIDGET_STATE_SELECTED QStyle::State_Selected
654 #define LIVES_WIDGET_STATE_INSENSITIVE QStyle::State_None
656 #define LIVES_WIDGET_STATE_FOCUSED QStyle::State_HasFocus
661 #define LIVES_WIDGET_COLOR_HAS_ALPHA (1)
662 #define LIVES_WIDGET_COLOR_SCALE(x) (x)
663 #define LIVES_WIDGET_COLOR_SCALE_255(x) ((double)x/255.)
666 typedef Qt::KeyboardModifiers LiVESXModifierType;
668 #define LIVES_CONTROL_MASK Qt::ControlModifier
669 #define LIVES_ALT_MASK Qt::AltModifier
670 #define LIVES_SHIFT_MASK Qt::ShiftModifier
671 #define LIVES_LOCK_MASK Qt::ShiftModifier
674 #define LIVES_KEY_Left (static_cast<uint32_t>(Qt::Key_Left))
675 #define LIVES_KEY_Right (static_cast<uint32_t>(Qt::Key_Right))
676 #define LIVES_KEY_Up (static_cast<uint32_t>(Qt::Key_Up))
677 #define LIVES_KEY_Down (static_cast<uint32_t>(Qt::Key_Down))
679 #define LIVES_KEY_BackSpace (static_cast<uint32_t>(Qt::Key_Backspace))
680 #define LIVES_KEY_Return (static_cast<uint32_t>(Qt::Key_Return))
681 #define LIVES_KEY_Tab (static_cast<uint32_t>(Qt::Key_Tab))
682 #define LIVES_KEY_Home (static_cast<uint32_t>(Qt::Key_Home))
683 #define LIVES_KEY_End (static_cast<uint32_t>(Qt::Key_End))
684 #define LIVES_KEY_Slash (static_cast<uint32_t>(Qt::Key_Slash))
685 #define LIVES_KEY_Space (static_cast<uint32_t>(Qt::Key_Space))
686 #define LIVES_KEY_Plus (static_cast<uint32_t>(Qt::Key_Plus))
687 #define LIVES_KEY_Minus (static_cast<uint32_t>(Qt::Key_Minus))
688 #define LIVES_KEY_Equal (static_cast<uint32_t>(Qt::Key_Equal))
690 #define LIVES_KEY_1 (static_cast<uint32_t>(Qt::Key_1))
691 #define LIVES_KEY_2 (static_cast<uint32_t>(Qt::Key_2))
692 #define LIVES_KEY_3 (static_cast<uint32_t>(Qt::Key_3))
693 #define LIVES_KEY_4 (static_cast<uint32_t>(Qt::Key_4))
694 #define LIVES_KEY_5 (static_cast<uint32_t>(Qt::Key_5))
695 #define LIVES_KEY_6 (static_cast<uint32_t>(Qt::Key_6))
696 #define LIVES_KEY_7 (static_cast<uint32_t>(Qt::Key_7))
697 #define LIVES_KEY_8 (static_cast<uint32_t>(Qt::Key_8))
698 #define LIVES_KEY_9 (static_cast<uint32_t>(Qt::Key_9))
699 #define LIVES_KEY_0 (static_cast<uint32_t>(Qt::Key_0))
701 #define LIVES_KEY_a (static_cast<uint32_t>(Qt::Key_A))
702 #define LIVES_KEY_b (static_cast<uint32_t>(Qt::Key_B))
703 #define LIVES_KEY_c (static_cast<uint32_t>(Qt::Key_C))
704 #define LIVES_KEY_d (static_cast<uint32_t>(Qt::Key_D))
705 #define LIVES_KEY_e (static_cast<uint32_t>(Qt::Key_E))
706 #define LIVES_KEY_f (static_cast<uint32_t>(Qt::Key_F))
707 #define LIVES_KEY_g (static_cast<uint32_t>(Qt::Key_G))
708 #define LIVES_KEY_h (static_cast<uint32_t>(Qt::Key_H))
709 #define LIVES_KEY_i (static_cast<uint32_t>(Qt::Key_I))
710 #define LIVES_KEY_j (static_cast<uint32_t>(Qt::Key_J))
711 #define LIVES_KEY_k (static_cast<uint32_t>(Qt::Key_K))
712 #define LIVES_KEY_l (static_cast<uint32_t>(Qt::Key_L))
713 #define LIVES_KEY_m (static_cast<uint32_t>(Qt::Key_M))
714 #define LIVES_KEY_n (static_cast<uint32_t>(Qt::Key_N))
715 #define LIVES_KEY_o (static_cast<uint32_t>(Qt::Key_O))
716 #define LIVES_KEY_p (static_cast<uint32_t>(Qt::Key_P))
717 #define LIVES_KEY_q (static_cast<uint32_t>(Qt::Key_Q))
718 #define LIVES_KEY_r (static_cast<uint32_t>(Qt::Key_R))
719 #define LIVES_KEY_s (static_cast<uint32_t>(Qt::Key_S))
720 #define LIVES_KEY_t (static_cast<uint32_t>(Qt::Key_T))
721 #define LIVES_KEY_u (static_cast<uint32_t>(Qt::Key_U))
722 #define LIVES_KEY_v (static_cast<uint32_t>(Qt::Key_V))
723 #define LIVES_KEY_w (static_cast<uint32_t>(Qt::Key_W))
724 #define LIVES_KEY_x (static_cast<uint32_t>(Qt::Key_X))
725 #define LIVES_KEY_y (static_cast<uint32_t>(Qt::Key_Y))
726 #define LIVES_KEY_z (static_cast<uint32_t>(Qt::Key_Z))
728 #define LIVES_KEY_F1 (static_cast<uint32_t>(Qt::Key_F1))
729 #define LIVES_KEY_F2 (static_cast<uint32_t>(Qt::Key_F2))
730 #define LIVES_KEY_F3 (static_cast<uint32_t>(Qt::Key_F3))
731 #define LIVES_KEY_F4 (static_cast<uint32_t>(Qt::Key_F4))
732 #define LIVES_KEY_F5 (static_cast<uint32_t>(Qt::Key_F5))
733 #define LIVES_KEY_F6 (static_cast<uint32_t>(Qt::Key_F6))
734 #define LIVES_KEY_F7 (static_cast<uint32_t>(Qt::Key_F7))
735 #define LIVES_KEY_F8 (static_cast<uint32_t>(Qt::Key_F8))
736 #define LIVES_KEY_F9 (static_cast<uint32_t>(Qt::Key_F9))
737 #define LIVES_KEY_F10 (static_cast<uint32_t>(Qt::Key_F10))
738 #define LIVES_KEY_F11 (static_cast<uint32_t>(Qt::Key_F11))
739 #define LIVES_KEY_F12 (static_cast<uint32_t>(Qt::Key_F12))
741 #define LIVES_KEY_Page_Up (static_cast<uint32_t>(Qt::Key_PageUp))
742 #define LIVES_KEY_Page_Down (static_cast<uint32_t>(Qt::Key_PageDown))
744 #define LIVES_KEY_Escape (static_cast<uint32_t>(Qt::Key_Escape))
746 typedef int LiVESAccelFlags;
748 typedef class LiVESAccelGroup LiVESAccelGroup;
749 typedef class LiVESWidget LiVESWidget;
752 typedef void LiVESXEvent;
753 typedef void LiVESXXEvent;
754 typedef void LiVESXEventMotion;
755 typedef void LiVESXEventFocus;
757 typedef QCursor LiVESXCursor;
760 #define LIVES_SCROLL_UP 1
761 #define LIVES_SCROLL_DOWN 2
765 LiVESXModifierType state;
789 #define LIVES_BUTTON_PRESS 1
790 #define LIVES_BUTTON_RELEASE 2
791 #define LIVES_BUTTON2_PRESS 3
794 typedef void LiVESXEventCrossing;
795 typedef void LiVESXEventConfigure;
796 typedef void LiVESXEventDelete;
799 typedef class LiVESObject LiVESObject;
801 typedef void (*LiVESWidgetCallback)(LiVESWidget *widget, livespointer data);
803 LiVESClosure *lives_cclosure_new(ulong func, livespointer data, livespointer dest_func) {
804 LiVESClosure *cl =
new LiVESClosure;
805 cl->function = (ulong)func;
812 typedef boolean(*LiVESScrollEventCallback)(LiVESWidget *widget, LiVESXEventScroll *, livespointer data);
813 typedef boolean(*LiVESExposeEventCallback)(LiVESWidget *widget, LiVESXEventExpose *, livespointer data);
814 typedef boolean(*LiVESEnterEventCallback)(LiVESWidget *widget, LiVESXEventCrossing *, livespointer data);
815 typedef boolean(*LiVESButtonEventCallback)(LiVESWidget *widget, LiVESXEventButton *, livespointer data);
816 typedef boolean(*LiVESConfigureEventCallback)(LiVESWidget *widget, LiVESXEventConfigure *, livespointer data);
817 typedef boolean(*LiVESDeleteEventCallback)(LiVESWidget *widget, LiVESXEventDelete *, livespointer data);
818 typedef boolean(*LiVESAccelCallback)(LiVESAccelGroup *group, LiVESObject *obj, uint32_t keyval, LiVESXModifierType mod, livespointer data);
820 #define LIVES_GUI_CALLBACK(a) (ulong)(a)
823 typedef void LiVESTargetEntry;
825 typedef bool LiVESFilterReturn;
827 #define LIVES_FILTER_REMOVE true
828 #define LIVES_FILTER_CONTINUE false
834 LiVESAccelFlags flags;
835 LiVESAccelGroup *group;
840 const char *signal_name;
841 LiVESClosure *closure;
856 boolean return_true() {
861 typedef uint32_t LiVESEventMask;
862 #define LIVES_EXPOSURE_MASK (1<<0)
863 #define LIVES_POINTER_MOTION_MASK (1<<1)
864 #define LIVES_POINTER_MOTION_HINT_MASK (1<<2)
865 #define LIVES_BUTTON_MOTION_MASK (1<<3)
866 #define LIVES_BUTTON1_MOTION_MASK (1<<4)
867 #define LIVES_BUTTON2_MOTION_MASK (1<<5)
868 #define LIVES_BUTTON3_MOTION_MASK (1<<6)
869 #define LIVES_BUTTON_PRESS_MASK (1<<7)
870 #define LIVES_BUTTON_RELEASE_MASK (1<<8)
871 #define LIVES_KEY_PRESS_MASK (1<<9)
872 #define LIVES_KEY_RELEASE_MASK (1<<10)
873 #define LIVES_ENTER_NOTIFY_MASK (1<<11)
874 #define LIVES_LEAVE_NOTIFY_MASK (1<<12)
875 #define LIVES_FOCUS_CHANGE_MASK (1<<13)
876 #define LIVES_STRUCTURE_MASK (1<<14)
877 #define LIVES_PROPERTY_CHANGE_MASK (1<<15)
878 #define LIVES_VISIBILITY_NOTIFY_MASK (1<<16)
879 #define LIVES_PROXIMITY_IN_MASK (1<<17)
880 #define LIVES_PROXIMITY_OUT_MASK (1<<18)
881 #define LIVES_SUBSTRUCTURE_MASK (1<<19)
882 #define LIVES_SCROLL_MASK (1<<20)
883 #define LIVES_TOUCH_MASK (1<<21)
884 #define LIVES_SMOOTH_SCROLL_MASK (1<<22)
886 #define LIVES_ALL_EVENTS_MASK 0xFFFF
889 #define LIVES_WIDGET_EXPOSE_EVENT "update"
890 #define LIVES_WIDGET_SCROLL_EVENT "scroll_event"
891 #define LIVES_WIDGET_ENTER_EVENT "enter-event"
892 #define LIVES_WIDGET_BUTTON_PRESS_EVENT "button-press-event"
893 #define LIVES_WIDGET_CONFIGURE_EVENT "resize"
894 #define LIVES_WIDGET_DELETE_EVENT "close-event"
900 #define LIVES_WIDGET_CLICKED_EVENT "clicked"
901 #define LIVES_WIDGET_TOGGLED_EVENT "toggled"
902 #define LIVES_WIDGET_CHANGED_EVENT "changed"
903 #define LIVES_WIDGET_ACTIVATE_EVENT "activate"
904 #define LIVES_WIDGET_VALUE_CHANGED_EVENT "value-changed"
905 #define LIVES_WIDGET_SELECTION_CHANGED_EVENT "selection-changed"
906 #define LIVES_WIDGET_CURRENT_FOLDER_CHANGED_EVENT "current-folder-changed"
907 #define LIVES_WIDGET_RESPONSE_EVENT "response"
915 static QString make_col(LiVESWidgetColor *col) {
916 QString qc = QString(
"rgba(%1,%2,%3,%4)")
918 .arg(col->green*255.)
920 .arg(col->alpha*255.);
926 LIVES_OBJECT_TYPE_UNKNOWN,
927 LIVES_OBJECT_TYPE_TIMER,
928 LIVES_WIDGET_TYPE_BUTTON,
929 LIVES_WIDGET_TYPE_SPIN_BUTTON,
930 LIVES_WIDGET_TYPE_RADIO_BUTTON,
931 LIVES_WIDGET_TYPE_CHECK_BUTTON,
932 LIVES_WIDGET_TYPE_COLOR_BUTTON,
933 LIVES_WIDGET_TYPE_TOOL_BUTTON,
934 LIVES_WIDGET_TYPE_TOOLBAR,
935 LIVES_WIDGET_TYPE_BUTTON_BOX,
936 LIVES_WIDGET_TYPE_TEXT_VIEW,
937 LIVES_WIDGET_TYPE_SCALE,
938 LIVES_WIDGET_TYPE_SCROLLBAR,
939 LIVES_WIDGET_TYPE_SCROLLED_WINDOW,
940 LIVES_WIDGET_TYPE_PROGRESS_BAR,
941 LIVES_WIDGET_TYPE_PANED,
942 LIVES_WIDGET_TYPE_MENU,
943 LIVES_WIDGET_TYPE_MENU_ITEM,
944 LIVES_WIDGET_TYPE_TOOL_ITEM,
945 LIVES_WIDGET_TYPE_RADIO_MENU_ITEM,
946 LIVES_WIDGET_TYPE_CHECK_MENU_ITEM,
947 LIVES_WIDGET_TYPE_MENU_TOOL_BUTTON,
948 LIVES_WIDGET_TYPE_MENU_BAR,
949 LIVES_WIDGET_TYPE_ENTRY,
950 LIVES_WIDGET_TYPE_FRAME,
951 LIVES_WIDGET_TYPE_FILE_CHOOSER,
952 LIVES_WIDGET_TYPE_ARROW,
953 LIVES_WIDGET_TYPE_RULER,
954 LIVES_WIDGET_TYPE_COMBO,
955 LIVES_WIDGET_TYPE_TABLE,
956 LIVES_WIDGET_TYPE_DIALOG,
957 LIVES_WIDGET_TYPE_MESSAGE_DIALOG,
958 LIVES_WIDGET_TYPE_ALIGNMENT,
959 LIVES_WIDGET_TYPE_IMAGE,
960 LIVES_WIDGET_TYPE_LABEL,
961 LIVES_WIDGET_TYPE_NOTEBOOK,
962 LIVES_WIDGET_TYPE_TREE_VIEW,
963 LIVES_WIDGET_TYPE_HSEPARATOR,
964 LIVES_WIDGET_TYPE_VSEPARATOR,
965 LIVES_WIDGET_TYPE_MAIN_WINDOW,
966 LIVES_WIDGET_TYPE_SUB_WINDOW,
967 LIVES_WIDGET_TYPE_EVENT_BOX,
968 LIVES_WIDGET_TYPE_DRAWING_AREA,
969 LIVES_WIDGET_TYPE_HBOX,
970 LIVES_WIDGET_TYPE_VBOX,
974 LIVES_INLINE QKeySequence make_qkey_sequence(uint32_t key, LiVESXModifierType mods) {
975 return static_cast<Qt::Key
>(key) | mods;
978 LIVES_INLINE uint32_t qkeysequence_get_key(QKeySequence ks) {
979 return ks[0] & 0x01FFFFFF;
983 LIVES_INLINE LiVESXModifierType qkeysequence_get_mod(QKeySequence ks) {
984 return static_cast<LiVESXModifierType
>(ks[0] & 0xF2000000);
988 class evFilter :
public QObject {
992 bool eventFilter(QObject *obj, QEvent *
event);
999 class nevfilter :
public QAbstractNativeEventFilter {
1002 virtual bool nativeEventFilter(
const QByteArray &eventType, livespointer message,
long *);
1008 class LiVESObject :
public QWidget {
1013 void block_signal(ulong handler_id);
1014 void block_signals(
const char *signame);
1015 void block_signals(ulong func, livespointer data);
1016 void unblock_signal(ulong handler_id);
1017 void unblock_signals(
const char *signame);
1018 void unblock_signals(ulong func, livespointer data);
1019 void disconnect_signal(ulong handler_id);
1021 void add_accel(LiVESAccel *accel);
1022 void add_accel(ulong handler_id,
const char *signal_name, ulong funcptr, livespointer data);
1023 void add_accel(
const char *signal_name, LiVESAccelGroup *group, uint32_t key, LiVESXModifierType mod, LiVESAccelFlags flags);
1025 boolean remove_accel(LiVESAccel *accel);
1026 boolean remove_accels(LiVESAccelGroup *, uint32_t key, LiVESXModifierType mod);
1028 boolean remove_accel_group(LiVESAccelGroup *group);
1029 void add_accel_group(LiVESAccelGroup *group);
1031 QList<LiVESAccelGroup *> get_accel_groups();
1033 QList<LiVESAccel *> get_accels_for(LiVESAccelGroup *group, QKeySequence ks);
1034 QList<LiVESAccel *> get_accels_for(ulong func, livespointer data);
1035 QList<LiVESAccel *> get_accels_for(
const char *signame);
1036 LiVESAccel *get_accel_for(ulong handler_id);
1038 boolean activate_accel(uint32_t key, LiVESXModifierType mod);
1039 boolean activate_accel(QKeySequence ks);
1041 void remove_all_accels();
1048 LiVESObject(
const LiVESObject &xobj) {
1054 if (floating) floating =
false;
1055 else inc_refcount();
1058 void inc_refcount() {
1062 void dec_refcount() {
1063 if (--refcount == 0) {
1068 void no_refcount() {
1073 void set_type(LiVESObjectType xtype) {
1077 LiVESObjectType get_type() {
1085 QList<LiVESAccel *>accels;
1086 QList<LiVESAccelGroup *>accel_groups;
1087 LiVESObjectType type;
1090 eFilter =
new evFilter();
1091 (
static_cast<QObject *
>(
this))->installEventFilter(eFilter);
1093 type = LIVES_OBJECT_TYPE_UNKNOWN;
1096 void finalise(
void) {
1097 (
static_cast<QObject *
>(
this))->deleteLater();
1100 while (accel_groups.size() > 0) {
1101 remove_accel_group(accel_groups[0]);
1104 remove_all_accels();
1110 typedef struct LiVESList LiVESList;
1113 livesconstpointer data;
1119 typedef struct LiVESSList LiVESSList;
1122 livesconstpointer data;
1126 typedef LiVESList LiVESDList;
1129 LIVES_INLINE livesconstpointer lives_list_nth_data(LiVESList *list, uint32_t n) {
1130 for (
unsigned int i = 0; i < n && list != NULL; i++) list = list->next;
1131 if (list == NULL)
return NULL;
1132 livesconstpointer data = list->data;
1136 LIVES_INLINE LiVESList *lives_list_nth(LiVESList *list, uint32_t n) {
1137 for (
unsigned int i = 0; i < n && list != NULL; i++) list = list->next;
1141 LIVES_INLINE livesconstpointer lives_slist_nth_data(LiVESSList *list, uint32_t n) {
1142 for (
unsigned int i = 0; i < n && list != NULL; i++) list = list->next;
1143 if (list == NULL)
return NULL;
1144 livesconstpointer data = list->data;
1150 for (i = 0; list != NULL; i++) list = list->next;
1154 LIVES_INLINE int lives_slist_length(LiVESSList *list) {
1156 for (i = 0; list != NULL; i++) list = list->next;
1162 LIVES_INLINE LiVESList *lives_list_remove(LiVESList *list, livesconstpointer data) {
1163 LiVESList *olist = list;
1164 for (
int i = 0; list->data != data && list != NULL; i++) list = list->next;
1165 if (list == NULL)
return NULL;
1166 if (list->prev != NULL) list->prev->next = list->next;
1167 else olist = list->next;
1168 if (list->next != NULL) list->next->prev = list->prev;
1170 list->next = list->prev = NULL;
1176 LIVES_INLINE LiVESList *lives_list_remove_link(LiVESList *olist, LiVESList *list) {
1177 if (olist == NULL)
return NULL;
1179 if (list->prev != NULL) list->prev->next = list->next;
1180 else olist = list->next;
1181 if (list->next != NULL) list->next->prev = list->prev;
1183 list->next = list->prev = NULL;
1189 LIVES_INLINE LiVESSList *lives_slist_remove(LiVESSList *list, livesconstpointer data) {
1190 LiVESSList *olist = list, *xlist = list;
1191 for (
int i = 0; list->data != data && list != NULL; i++) {
1195 if (list == NULL)
return NULL;
1197 xlist->next = list->next;
1199 if (list == olist) olist = list->next;
1207 LIVES_INLINE LiVESList *lives_list_append(LiVESList *list, livesconstpointer data) {
1208 LiVESList *olist=NULL, *xlist=list;
1210 while (list != NULL) {
1215 LiVESList *elem = (LiVESList *)malloc(
sizeof(LiVESList));
1220 if (olist == NULL) xlist = elem;
1225 LIVES_INLINE LiVESSList *lives_slist_append(LiVESSList *list, livesconstpointer data) {
1226 LiVESSList *olist=NULL, *xlist=list;
1228 while (list != NULL) {
1233 LiVESSList *elem = (LiVESSList *)malloc(
sizeof(LiVESSList));
1237 if (olist == NULL) xlist = elem;
1242 LIVES_INLINE LiVESList *lives_list_prepend(LiVESList *list, livesconstpointer data) {
1243 LiVESList *elem = (LiVESList *)malloc(
sizeof(LiVESList));
1251 LIVES_INLINE LiVESSList *lives_slist_prepend(LiVESSList *list, livesconstpointer data) {
1252 LiVESSList *elem = (LiVESSList *)malloc(
sizeof(LiVESSList));
1259 LIVES_INLINE LiVESList *lives_list_insert(LiVESList *list, livespointer data,
int pos) {
1260 if (pos == 0)
return lives_list_prepend(list, data);
1262 LiVESList *xlist = list, *olist = NULL;
1264 while (list != NULL && pos != 0) {
1270 LiVESList *elem = (LiVESList *)malloc(
sizeof(LiVESList));
1272 elem->next = olist->next;
1274 if (elem->next != NULL) elem->next->prev = elem;
1277 if (xlist == NULL) xlist = elem;
1284 LIVES_INLINE LiVESList *lives_list_find(LiVESList *list, livesconstpointer data) {
1285 while (list != NULL) {
1286 if (list->data == data)
return list;
1293 LIVES_INLINE LiVESList *lives_list_find_custom(LiVESList *list, livesconstpointer data, LiVESCompareFunc func) {
1294 while (list != NULL) {
1295 if (! func(list->data, data))
1306 while (list != NULL) {
1316 while (list != NULL) {
1324 LIVES_INLINE LiVESList *lives_list_previous(LiVESList *list) {
1325 if (list == NULL)
return NULL;
1330 LIVES_INLINE LiVESList *lives_list_last(LiVESList *list) {
1331 if (list == NULL)
return NULL;
1332 while (list->next != NULL) list=list->next;
1338 LIVES_INLINE LiVESList *lives_list_delete_link(LiVESList *list, LiVESList *link) {
1339 list = lives_list_remove_link(list, link);
1345 LIVES_INLINE LiVESList *lives_list_copy(LiVESList *list) {
1346 LiVESList *new_list = NULL;
1347 while (list != NULL) {
1348 lives_list_append(new_list, list->data);
1355 LIVES_INLINE LiVESList *lives_list_concat(LiVESList *a, LiVESList *b) {
1356 LiVESList *xlist = lives_list_last(a);
1364 char **lives_strsplit(
const char *
string,
const char *delimiter,
int max_tokens) {
1365 LiVESSList *string_list = NULL,*slist;
1369 const char *remainder;
1371 max_tokens = INT_MAX;
1373 s = strstr(remainder, delimiter);
1375 size_t delimiter_len = strlen(delimiter);
1376 while (--max_tokens && s) {
1378 len = s - remainder;
1379 string_list = lives_slist_prepend(string_list, lives_strndup(remainder, len));
1381 remainder = s + delimiter_len;
1382 s = strstr(remainder, delimiter);
1387 string_list = lives_slist_prepend(string_list,
lives_strdup(remainder));
1389 str_array = (
char **)lives_malloc((n + 1) *
sizeof(
char *));
1390 str_array[n--] = NULL;
1391 for (slist = string_list; slist; slist = slist->next)
1392 str_array[n--] = (
char *)slist->data;
1393 lives_slist_free(string_list);
1399 char *lives_strdelimit(
char *
string,
const char *delimiters,
char new_delim) {
1401 for (c =
string; *c; c++) {
1402 if (strchr(delimiters, *c))
1411 char *lives_strstr_len(
const char *haystack, ssize_t haystack_len,
const char *needle) {
1412 if (haystack_len < 0)
1413 return (
char *)strstr(haystack, needle);
1415 const char *p = haystack;
1416 size_t needle_len = strlen(needle);
1419 if (needle_len == 0)
1420 return (
char *)haystack;
1421 if (haystack_len < needle_len)
1423 end = haystack + haystack_len - needle_len;
1424 while (p <= end && *p) {
1425 for (i = 0; i < needle_len; i++)
1426 if (p[i] != needle[i])
1438 #define ICON_SCALE(a) ((int)(1.0 * a))
1439 typedef QSize LiVESIconSize;
1440 #define LIVES_ICON_SIZE_INVALID QSize(0,0)
1441 #define LIVES_ICON_SIZE_MENU QSize(ICON_SCALE(16),ICON_SCALE(16))
1442 #define LIVES_ICON_SIZE_SMALL_TOOLBAR QSize(ICON_SCALE(16),ICON_SCALE(16))
1443 #define LIVES_ICON_SIZE_LARGE_TOOLBAR QSize(ICON_SCALE(24),ICON_SCALE(24))
1444 #define LIVES_ICON_SIZE_BUTTON QSize(ICON_SCALE(16),ICON_SCALE(16))
1445 #define LIVES_ICON_SIZE_DND QSize(ICON_SCALE(32),ICON_SCALE(32))
1446 #define LIVES_ICON_SIZE_DIALOG QSize(ICON_SCALE(48),ICON_SCALE(48))
1449 typedef Qt::TransformationMode LiVESInterpType;
1450 #define LIVES_INTERP_BEST Qt::SmoothTransformation
1451 #define LIVES_INTERP_NORMAL Qt::SmoothTransformation
1452 #define LIVES_INTERP_FAST Qt::FastTransformation
1454 typedef int LiVESResponseType;
1455 #define LIVES_RESPONSE_NONE QDialogButtonBox::InvalidRole
1456 #define LIVES_RESPONSE_OK QDialogButtonBox::AcceptRole
1457 #define LIVES_RESPONSE_CANCEL QDialogButtonBox::RejectRole
1459 #define LIVES_RESPONSE_ACCEPT QDialogButtonBox::AcceptRole
1461 #define LIVES_RESPONSE_YES QDialogButtonBox::YesRole
1462 #define LIVES_RESPONSE_NO QDialogButtonBox::NoRole
1464 #define LIVES_RESPONSE_INVALID QDialogButtonBox::InvalidRole
1465 #define LIVES_RESPONSE_SHOW_DETAILS 100
1467 #define LIVES_RESPONSE_RETRY 101
1468 #define LIVES_RESPONSE_ABORT 102
1469 #define LIVES_RESPONSE_RESET 103
1471 typedef QStyle::StandardPixmap LiVESArrowType;
1472 #define LIVES_ARROW_UP QStyle::SP_ArrowUp
1473 #define LIVES_ARROW_DOWN QStyle::SP_ArrowDown
1474 #define LIVES_ARROW_LEFT QStyle::SP_ArrowLeft
1475 #define LIVES_ARROW_RIGHT QStyle::SP_ArrowRight
1476 #define LIVES_ARROW_NONE -1
1478 class LiVESWidget :
public LiVESObject {
1483 Q_PROPERTY(
bool prelight READ get_prelight WRITE set_prelight)
1485 void set_prelight(
bool val) {
1486 (
static_cast<QObject *
>(
static_cast<QWidget *
>(
this)))->setProperty(
"prelight", val);
1489 bool get_prelight() {
1490 QVariant qv = (
static_cast<QObject *
>(
static_cast<QWidget *
>(
this)))->property(
"prelight");
1491 return qv.value<
bool>();
1494 void set_fg_color(LiVESWidgetState state,
const LiVESWidgetColor *col);
1495 void set_bg_color(LiVESWidgetState state,
const LiVESWidgetColor *col);
1496 void set_base_color(LiVESWidgetState state,
const LiVESWidgetColor *col);
1497 void set_text_color(LiVESWidgetState state,
const LiVESWidgetColor *col);
1499 LiVESWidgetColor *get_fg_color(LiVESWidgetState state);
1500 LiVESWidgetColor *get_bg_color(LiVESWidgetState state);
1502 void update_stylesheet();
1505 LiVESWidget() : parent(NULL) {
1507 QVariant qv = QVariant::fromValue(static_cast<LiVESObject *>(
this));
1508 (
static_cast<QWidget *
>(
this))->setProperty(
"LiVESObject", qv);
1510 fg_norm=bg_norm=base_norm=text_norm=NULL;
1511 fg_act=bg_act=base_act=text_act=NULL;
1512 fg_insen=bg_insen=base_insen=text_insen=NULL;
1513 fg_hover=bg_hover=base_hover=text_hover=NULL;
1514 fg_sel=bg_sel=base_sel=text_sel=NULL;
1515 state = LIVES_WIDGET_STATE_NORMAL;
1517 events_mask = LIVES_EXPOSURE_MASK;
1518 onetime_events_mask = 0;
1520 static_cast<QObject *
>(
static_cast<QWidget *
>(
this))->connect(static_cast<QObject *>(static_cast<QWidget *>(
this)),
1521 SIGNAL(destroyed()),
1522 static_cast<QObject *>(static_cast<QWidget *>(
this)),
1523 SLOT(onDestroyed()));
1528 void onDestroyed() {
1540 void add_child(LiVESWidget *child) {
1541 if (child->parent != NULL)
return;
1542 child->set_parent(
this);
1544 children = lives_list_append(children,child);
1547 void remove_child(LiVESWidget *child) {
1548 children = lives_list_remove(children,child);
1549 child->set_parent(NULL);
1550 child->dec_refcount();
1553 void set_parent(LiVESWidget *new_parent) {
1554 parent = new_parent;
1557 LiVESWidget *get_parent() {
1561 QString get_name() {
1565 void set_events(uint32_t mask) {
1569 void add_onetime_event_block(uint32_t mask) {
1570 onetime_events_mask |= mask;
1573 void remove_onetime_event_block(uint32_t mask) {
1574 if (onetime_events_mask & mask) onetime_events_mask ^= mask;
1577 uint32_t get_onetime_events_block() {
1578 return onetime_events_mask;
1581 uint32_t get_events() {
1585 int count_children() {
1586 return lives_list_length(children);
1589 LiVESList *get_children() {
1593 void set_children(LiVESList *xchildren) {
1594 lives_list_free(children);
1595 children = xchildren;
1598 LiVESWidget *get_child(
int index) {
1599 return (LiVESWidget *)lives_list_nth_data(children,index);
1603 int get_child_index(LiVESWidget *child) {
1604 LiVESList *xchildren = children;
1606 for (i = 0; xchildren != NULL; i++) {
1607 if (xchildren->data == child)
return i;
1612 LiVESWidgetState get_state() {
1616 void set_state(LiVESWidgetState xstate) {
1619 if (state & LIVES_WIDGET_STATE_INSENSITIVE) {
1626 if (state & LIVES_WIDGET_STATE_PRELIGHT) {
1627 if (!get_prelight()) set_prelight(
true);
1629 if (get_prelight()) set_prelight(
false);
1636 void cb_wrapper_clicked() {
1638 call_accels_for(LIVES_WIDGET_CLICKED_EVENT);
1641 void cb_wrapper_toggled() {
1643 call_accels_for(LIVES_WIDGET_CLICKED_EVENT);
1647 void cb_wrapper_changed() {
1649 call_accels_for(LIVES_WIDGET_CHANGED_EVENT);
1653 void cb_wrapper_value_changed() {
1655 call_accels_for(LIVES_WIDGET_VALUE_CHANGED_EVENT);
1658 void cb_wrapper_selection_changed() {
1660 call_accels_for(LIVES_WIDGET_SELECTION_CHANGED_EVENT);
1663 void cb_wrapper_current_folder_changed() {
1665 call_accels_for(LIVES_WIDGET_CURRENT_FOLDER_CHANGED_EVENT);
1668 void cb_wrapper_activate() {
1670 call_accels_for(LIVES_WIDGET_ACTIVATE_EVENT);
1673 void cb_wrapper_response() {
1675 call_accels_for(LIVES_WIDGET_RESPONSE_EVENT);
1679 LiVESList *children;
1680 LiVESWidget *parent;
1683 LiVESWidgetColor *fg_norm,*bg_norm,*base_norm,*text_norm;
1684 LiVESWidgetColor *fg_act,*bg_act,*base_act,*text_act;
1685 LiVESWidgetColor *fg_insen,*bg_insen,*base_insen,*text_insen;
1686 LiVESWidgetColor *fg_hover,*bg_hover,*base_hover,*text_hover;
1687 LiVESWidgetColor *fg_sel,*bg_sel,*base_sel,*text_sel;
1689 LiVESWidgetState state;
1691 uint32_t events_mask;
1692 uint32_t onetime_events_mask;
1694 void call_accels_for(
const char *type) {
1695 QList<LiVESAccel *> ql = get_accels_for(type);
1696 for (
int i=0; i < ql.size(); i++) {
1697 LiVESWidgetCallback *cb = (LiVESWidgetCallback *)ql[i]->closure->function;
1698 (*cb)(
this, ql[i]->closure->data);
1705 #define LIVES_IS_WIDGET_OBJECT(a) 1
1706 #define LIVES_IS_WIDGET(a) 1
1707 #define LIVES_IS_CONTAINER(a) 1
1708 #define LIVES_IS_XWINDOW(a) 1
1710 #define LIVES_IS_BUTTON(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_BUTTON || \
1711 static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_CHECK_BUTTON)
1712 #define LIVES_IS_PUSH_BUTTON(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_BUTTON || \
1713 static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_RADIO_BUTTON)
1714 #define LIVES_IS_RANGE(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_SCALE || \
1715 static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_SCROLLBAR)
1716 #define LIVES_IS_LABEL(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_LABEL)
1717 #define LIVES_IS_TOGGLE_BUTTON(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_CHECK_BUTTON)
1718 #define LIVES_IS_HBOX(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_HBOX)
1719 #define LIVES_IS_VBOX(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_VBOX)
1720 #define LIVES_IS_COMBO(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_COMBO)
1721 #define LIVES_IS_ENTRY(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_ENTRY)
1722 #define LIVES_IS_MENU(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_MENU)
1723 #define LIVES_IS_MENU_BAR(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_MENU_BAR)
1724 #define LIVES_IS_MENU_ITEM(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_MENU_ITEM)
1725 #define LIVES_IS_TOOLBAR(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_TOOLBAR)
1726 #define LIVES_IS_FILE_CHOOSER(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_FILE_CHOOSER)
1727 #define LIVES_IS_SCALE(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_SCALE)
1728 #define LIVES_IS_FRAME(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_FRAME)
1729 #define LIVES_IS_TOOL_ITEM(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_TOOL_ITEM)
1730 #define LIVES_IS_WINDOW(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_MAIN_WINDOW)
1731 #define LIVES_IS_DIALOG(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_SUB_WINDOW || \
1732 static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_MESSAGE_DIALOG)
1733 #define LIVES_IS_PANED(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_PANED)
1734 #define LIVES_IS_TABLE(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_TABLE)
1735 #define LIVES_IS_IMAGE(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_IMAGE)
1736 #define LIVES_IS_PIXBUF(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_IMAGE)
1737 #define LIVES_IS_NOTEBOOK(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_NOTEBOOK)
1738 #define LIVES_IS_SPIN_BUTTON(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_SPIN_BUTTON)
1739 #define LIVES_IS_SCROLLBAR(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_SCROLLBAR)
1740 #define LIVES_IS_TREE_VIEW(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_TREE_VIEW)
1741 #define LIVES_IS_TEXT_VIEW(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_TEXT_VIEW)
1742 #define LIVES_IS_TEXT_BUFFER(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_TEXT_BUFFER)
1743 #define LIVES_IS_SCROLLED_WINDOW(a) (static_cast<LiVESObject *>(a)->get_type() == LIVES_WIDGET_TYPE_SCROLLED_WINDOW)
1746 bool evFilter::eventFilter(QObject *obj, QEvent *
event) {
1754 switch (event->type()) {
1756 case (QEvent::Shortcut): {
1757 QShortcutEvent *qevent =
static_cast<QShortcutEvent *
>(event);
1758 QKeySequence ks = qevent->key();
1759 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1760 object->activate_accel(ks);
1764 case (QEvent::Wheel): {
1765 QWheelEvent *qevent =
static_cast<QWheelEvent *
>(event);
1766 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1767 LiVESWidget *widget =
static_cast<LiVESWidget *
>(object);
1768 if (!(widget->get_events() & LIVES_SCROLL_MASK))
return true;
1769 if (!(widget->get_onetime_events_block() & LIVES_SCROLL_MASK)) {
1770 widget->remove_onetime_event_block(LIVES_SCROLL_MASK);
1774 QList<LiVESAccel *>accels =
object->get_accels_for(LIVES_WIDGET_SCROLL_EVENT);
1775 LiVESXEventScroll *scrollevent = NULL;
1776 if (qevent->angleDelta().y() > 0) scrollevent->direction = LIVES_SCROLL_UP;
1777 else scrollevent->direction = LIVES_SCROLL_DOWN;
1779 scrollevent->state = QApplication::queryKeyboardModifiers();
1781 for (
int i=0; i < accels.size(); i++) {
1782 LiVESScrollEventCallback *cb = (LiVESScrollEventCallback *)accels[i]->closure->function;
1783 bool ret = (*cb)(widget, scrollevent, accels[i]->closure->data);
1784 if (ret)
return true;
1788 case (QEvent::Paint): {
1789 QPaintEvent *qevent =
static_cast<QPaintEvent *
>(event);
1790 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1791 LiVESWidget *widget =
static_cast<LiVESWidget *
>(object);
1792 if (!(widget->get_events() & LIVES_EXPOSURE_MASK))
return true;
1793 if (!(widget->get_onetime_events_block() & LIVES_EXPOSURE_MASK)) {
1794 widget->remove_onetime_event_block(LIVES_EXPOSURE_MASK);
1798 QList<LiVESAccel *>accels =
object->get_accels_for(LIVES_WIDGET_EXPOSE_EVENT);
1799 LiVESXEventExpose *exposeevent = NULL;
1800 QRect qr = qevent->rect();
1801 exposeevent->area.x = qr.x();
1802 exposeevent->area.y = qr.y();
1803 exposeevent->area.width = qr.width();
1804 exposeevent->area.height = qr.height();
1806 exposeevent->count = 0;
1808 for (
int i=0; i < accels.size(); i++) {
1809 LiVESExposeEventCallback *cb = (LiVESExposeEventCallback *)accels[i]->closure->function;
1810 bool ret = (*cb)(widget, exposeevent, accels[i]->closure->data);
1811 if (ret)
return true;
1815 case (QEvent::Enter): {
1817 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1818 LiVESWidget *widget =
static_cast<LiVESWidget *
>(object);
1819 if (!(widget->get_events() & LIVES_ENTER_NOTIFY_MASK))
return true;
1820 if (!(widget->get_onetime_events_block() & LIVES_ENTER_NOTIFY_MASK)) {
1821 widget->remove_onetime_event_block(LIVES_ENTER_NOTIFY_MASK);
1825 QList<LiVESAccel *>accels =
object->get_accels_for(LIVES_WIDGET_ENTER_EVENT);
1826 LiVESXEventCrossing *crossingevent = NULL;
1828 for (
int i=0; i < accels.size(); i++) {
1829 LiVESEnterEventCallback *cb = (LiVESEnterEventCallback *)accels[i]->closure->function;
1830 bool ret = (*cb)(widget, crossingevent, accels[i]->closure->data);
1831 if (ret)
return true;
1835 case (QEvent::MouseButtonPress): {
1836 QMouseEvent *qevent =
static_cast<QMouseEvent *
>(event);
1837 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1838 LiVESWidget *widget =
static_cast<LiVESWidget *
>(object);
1839 if (!(widget->get_events() & LIVES_BUTTON_PRESS_MASK))
return true;
1840 if (!(widget->get_onetime_events_block() & LIVES_BUTTON_PRESS_MASK)) {
1841 widget->remove_onetime_event_block(LIVES_BUTTON_PRESS_MASK);
1845 QList<LiVESAccel *>accels =
object->get_accels_for(LIVES_WIDGET_BUTTON_PRESS_EVENT);
1847 LiVESXEventButton *buttonevent = NULL;
1848 if (qevent->button() == Qt::LeftButton) buttonevent->button = 1;
1849 if (qevent->button() == Qt::MidButton) buttonevent->button = 2;
1850 if (qevent->button() == Qt::RightButton) buttonevent->button = 3;
1852 buttonevent->type = LIVES_BUTTON_PRESS;
1853 buttonevent->time = qtime->elapsed();
1855 for (
int i=0; i < accels.size(); i++) {
1856 LiVESButtonEventCallback *cb = (LiVESButtonEventCallback *)accels[i]->closure->function;
1857 bool ret = (*cb)(widget, buttonevent, accels[i]->closure->data);
1858 if (ret)
return true;
1862 case (QEvent::MouseButtonDblClick): {
1863 QMouseEvent *qevent =
static_cast<QMouseEvent *
>(event);
1864 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1865 LiVESWidget *widget =
static_cast<LiVESWidget *
>(object);
1866 if (!(widget->get_events() & LIVES_BUTTON_PRESS_MASK))
return true;
1867 if (!(widget->get_onetime_events_block() & LIVES_BUTTON_PRESS_MASK)) {
1868 widget->remove_onetime_event_block(LIVES_BUTTON_PRESS_MASK);
1872 QList<LiVESAccel *>accels =
object->get_accels_for(LIVES_WIDGET_BUTTON_PRESS_EVENT);
1874 LiVESXEventButton *buttonevent = NULL;
1875 if (qevent->button() == Qt::LeftButton) buttonevent->button = 1;
1876 if (qevent->button() == Qt::MidButton) buttonevent->button = 2;
1877 if (qevent->button() == Qt::RightButton) buttonevent->button = 3;
1879 buttonevent->type = LIVES_BUTTON2_PRESS;
1881 for (
int i=0; i < accels.size(); i++) {
1882 LiVESButtonEventCallback *cb = (LiVESButtonEventCallback *)accels[i]->closure->function;
1883 bool ret = (*cb)(widget, buttonevent, accels[i]->closure->data);
1884 if (ret)
return true;
1888 case (QEvent::Resize): {
1890 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1891 LiVESWidget *widget =
static_cast<LiVESWidget *
>(object);
1892 QList<LiVESAccel *>accels =
object->get_accels_for(LIVES_WIDGET_CONFIGURE_EVENT);
1893 LiVESXEventConfigure *configureevent = NULL;
1895 for (
int i=0; i < accels.size(); i++) {
1896 LiVESConfigureEventCallback *cb = (LiVESConfigureEventCallback *)accels[i]->closure->function;
1897 bool ret = (*cb)(widget, configureevent, accels[i]->closure->data);
1898 if (ret)
return true;
1902 case (QEvent::Close): {
1904 LiVESObject *
object =
static_cast<LiVESObject *
>(obj);
1905 LiVESWidget *widget =
static_cast<LiVESWidget *
>(object);
1906 QList<LiVESAccel *>accels =
object->get_accels_for(LIVES_WIDGET_DELETE_EVENT);
1907 LiVESXEventDelete *deleteevent = NULL;
1909 for (
int i=0; i < accels.size(); i++) {
1910 LiVESDeleteEventCallback *cb = (LiVESDeleteEventCallback *)accels[i]->closure->function;
1911 bool ret = (*cb)(widget, deleteevent, accels[i]->closure->data);
1912 if (ret)
return true;
1927 void LiVESWidget::update_stylesheet() {
1928 QWidget *qw =
static_cast<QWidget *
>(
this);
1932 stylesheet =
"QWidget#" + widgetName +
" {color: ";
1933 col=make_col(fg_norm);
1935 stylesheet +=
"; background-color: ";
1936 col=make_col(bg_norm);
1938 stylesheet +=
"; selection-background-color: ";
1939 col=make_col(bg_sel);
1941 stylesheet +=
"; selection-color: ";
1942 col=make_col(fg_sel);
1944 stylesheet +=
" } ";
1945 stylesheet =
"QWidget#" + widgetName +
":active {color: ";
1946 col=make_col(fg_act);
1948 stylesheet +=
"; background-color: ";
1949 col=make_col(bg_act);
1951 stylesheet +=
" } ";
1952 stylesheet =
"QWidget#" + widgetName +
":[prelight=true] {color: ";
1953 col=make_col(fg_hover);
1955 stylesheet +=
"; background-color: ";
1956 col=make_col(bg_hover);
1958 stylesheet +=
" } ";
1959 stylesheet =
"QWidget#" + widgetName +
":hover {color: ";
1960 col=make_col(fg_hover);
1962 stylesheet +=
"; background-color: ";
1963 col=make_col(bg_hover);
1965 stylesheet +=
" } ";
1966 stylesheet =
"QWidget#" + widgetName +
":disabled {color: ";
1967 col=make_col(fg_insen);
1969 stylesheet +=
"; background-color: ";
1970 col=make_col(bg_insen);
1972 stylesheet +=
" } ";
1974 qw->setStyleSheet(stylesheet);
1980 void LiVESWidget::set_fg_color(LiVESWidgetState state,
const LiVESWidgetColor *col) {
1982 case (LIVES_WIDGET_STATE_NORMAL):
1985 case (LIVES_WIDGET_STATE_ACTIVE):
1988 case (LIVES_WIDGET_STATE_INSENSITIVE):
1991 case (LIVES_WIDGET_STATE_PRELIGHT):
1994 case (LIVES_WIDGET_STATE_SELECTED):
2000 update_stylesheet();
2004 void LiVESWidget::set_bg_color(LiVESWidgetState state,
const LiVESWidgetColor *col) {
2006 case (LIVES_WIDGET_STATE_NORMAL):
2009 case (LIVES_WIDGET_STATE_ACTIVE):
2012 case (LIVES_WIDGET_STATE_INSENSITIVE):
2015 case (LIVES_WIDGET_STATE_PRELIGHT):
2018 case (LIVES_WIDGET_STATE_SELECTED):
2024 update_stylesheet();
2028 void LiVESWidget::set_base_color(LiVESWidgetState state,
const LiVESWidgetColor *col) {
2030 case (LIVES_WIDGET_STATE_NORMAL):
2033 case (LIVES_WIDGET_STATE_ACTIVE):
2036 case (LIVES_WIDGET_STATE_INSENSITIVE):
2039 case (LIVES_WIDGET_STATE_PRELIGHT):
2042 case (LIVES_WIDGET_STATE_SELECTED):
2048 update_stylesheet();
2052 void LiVESWidget::set_text_color(LiVESWidgetState state,
const LiVESWidgetColor *col) {
2054 case (LIVES_WIDGET_STATE_NORMAL):
2057 case (LIVES_WIDGET_STATE_ACTIVE):
2060 case (LIVES_WIDGET_STATE_INSENSITIVE):
2063 case (LIVES_WIDGET_STATE_PRELIGHT):
2066 case (LIVES_WIDGET_STATE_SELECTED):
2072 update_stylesheet();
2076 LiVESWidgetColor *LiVESWidget::get_fg_color(LiVESWidgetState state) {
2078 case (LIVES_WIDGET_STATE_NORMAL):
2081 case (LIVES_WIDGET_STATE_ACTIVE):
2084 case (LIVES_WIDGET_STATE_INSENSITIVE):
2087 case (LIVES_WIDGET_STATE_PRELIGHT):
2090 case (LIVES_WIDGET_STATE_SELECTED):
2100 LiVESWidgetColor *LiVESWidget::get_bg_color(LiVESWidgetState state) {
2102 case (LIVES_WIDGET_STATE_NORMAL):
2105 case (LIVES_WIDGET_STATE_ACTIVE):
2108 case (LIVES_WIDGET_STATE_INSENSITIVE):
2111 case (LIVES_WIDGET_STATE_PRELIGHT):
2114 case (LIVES_WIDGET_STATE_SELECTED):
2124 ulong
lives_signal_connect(LiVESObject *
object,
const char *signal_name, ulong funcptr, livespointer data) {
2128 object->add_accel(handler_id, signal_name, funcptr, data);
2130 if (!strcmp(signal_name, LIVES_WIDGET_CLICKED_EVENT)) {
2131 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2133 static_cast<QObject *>(
object),
2134 SLOT(cb_wrapper_clicked()));
2135 }
else if (!strcmp(signal_name, LIVES_WIDGET_TOGGLED_EVENT)) {
2136 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2138 static_cast<QObject *>(
object),
2139 SLOT(cb_wrapper_toggled()));
2140 }
else if (!strcmp(signal_name, LIVES_WIDGET_CHANGED_EVENT)) {
2142 if (LIVES_IS_COMBO(
object))
2143 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2144 SIGNAL(currentTextChanged()),
2145 static_cast<QObject *>(
object),
2146 SLOT(cb_wrapper_changed()));
2148 else if (LIVES_IS_ENTRY(
object))
2149 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2150 SIGNAL(textChanged()),
2151 static_cast<QObject *>(
object),
2152 SLOT(cb_wrapper_changed()));
2155 QTreeWidget *qtw =
dynamic_cast<QTreeWidget *
>(object);
2157 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2158 SIGNAL(itemSelectionChanged()),
2159 static_cast<QObject *>(
object),
2160 SLOT(cb_wrapper_changed()));
2164 }
else if (!strcmp(signal_name, LIVES_WIDGET_VALUE_CHANGED_EVENT)) {
2166 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2167 SIGNAL(valueChanged()),
2168 static_cast<QObject *>(
object),
2169 SLOT(cb_wrapper_value_changed()));
2171 }
else if (!strcmp(signal_name, LIVES_WIDGET_SELECTION_CHANGED_EVENT)) {
2173 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2174 SIGNAL(currentChanged()),
2175 static_cast<QObject *>(
object),
2176 SLOT(cb_wrapper_selection_changed()));
2178 }
else if (!strcmp(signal_name, LIVES_WIDGET_CURRENT_FOLDER_CHANGED_EVENT)) {
2180 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2181 SIGNAL(currentUrlChanged()),
2182 static_cast<QObject *>(
object),
2183 SLOT(cb_wrapper_current_folder_changed()));
2185 }
else if (!strcmp(signal_name, LIVES_WIDGET_ACTIVATE_EVENT)) {
2187 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2188 SIGNAL(triggered()),
2189 static_cast<QObject *>(
object),
2190 SLOT(cb_wrapper_activate()));
2192 }
else if (!strcmp(signal_name, LIVES_WIDGET_RESPONSE_EVENT)) {
2194 (
static_cast<QObject *
>(object))->connect(static_cast<QObject *>(
object),
2196 static_cast<QObject *>(
object),
2197 SLOT(cb_wrapper_response()));
2206 LIVES_INLINE void lives_widget_object_set_data(LiVESObject *widget,
const char *prop, livespointer value) {
2207 QVariant v = qVariantFromValue((livespointer) value);
2208 widget->setProperty(prop, v);
2212 LIVES_INLINE livespointer lives_widget_object_get_data(LiVESObject *widget,
const char *prop) {
2213 QVariant v = widget->property(prop);
2214 return v.value<livespointer>();
2220 #define lives_signal_connect_after(a,b,c,d) lives_signal_connect(a,b,c,d)
2224 void LiVESObject::add_accel(LiVESAccel *accel) {
2225 accels.push_back(accel);
2232 void LiVESObject::add_accel(ulong handler_id,
const char *signal_name, ulong funcptr, livespointer data) {
2233 LiVESAccel *accel =
new LiVESAccel;
2234 accel->handler_id = handler_id;
2235 accel->signal_name = strdup(signal_name);
2236 LiVESClosure *cl =
new LiVESClosure;
2237 cl->function = funcptr;
2239 accel->closure = cl;
2244 void LiVESObject::add_accel(
const char *signal_name, LiVESAccelGroup *group, uint32_t key, LiVESXModifierType mod, LiVESAccelFlags flags) {
2245 LiVESAccel *accel =
new LiVESAccel;
2246 accel->handler_id = 0;
2247 accel->signal_name = strdup(signal_name);
2248 accel->closure = NULL;
2249 accel->group = group;
2250 accel->ks = make_qkey_sequence(key, mod);
2251 accel->flags = flags;
2256 boolean LiVESObject::remove_accel(LiVESAccel *accel) {
2257 QList<LiVESAccel *>::iterator it = accels.begin();
2259 while (it != accels.end()) {
2260 if (((LiVESAccel *)*it) == accel) {
2261 delete accel->shortcut;
2262 delete accel->signal_name;
2263 delete accel->closure;
2274 boolean LiVESObject::activate_accel(uint32_t key, LiVESXModifierType mod) {
2275 return activate_accel(make_qkey_sequence(key, mod));
2279 boolean LiVESObject::activate_accel(QKeySequence ks) {
2280 for (
int j=0; j < accel_groups.size(); j++) {
2281 QList<LiVESAccel *> ql = get_accels_for(accel_groups.at(j), ks);
2282 for (
int i=0; i < ql.size(); i++) {
2283 LiVESAccel *accel = ql.at(i);
2284 if (accel->closure != NULL) {
2285 LiVESAccelCallback *cb = (LiVESAccelCallback *)accel->closure->function;
2286 uint32_t key = qkeysequence_get_key(ks);
2287 LiVESXModifierType mod = qkeysequence_get_mod(ks);
2288 (*cb)(accel->group,
this, key, mod, accel->closure->data);
2290 if (!strcmp(accel->signal_name, LIVES_WIDGET_CLICKED_EVENT)) {
2291 QAbstractButton *widget =
dynamic_cast<QAbstractButton *
>(
this);
2292 if (widget != NULL) widget->click();
2295 if (!strcmp(accel->signal_name, LIVES_WIDGET_TOGGLED_EVENT)) {
2296 QAbstractButton *widget =
dynamic_cast<QAbstractButton *
>(
this);
2297 if (widget != NULL) widget->toggle();
2309 void LiVESObject::remove_all_accels() {
2310 QList<LiVESAccel *>::iterator it = accels.begin();
2311 while (it != accels.end()) {
2312 remove_accel((LiVESAccel *)*it);
2317 QList<LiVESAccel *> LiVESObject::get_accels_for(ulong func, livespointer data) {
2318 QList<LiVESAccel *> ql;
2319 for (
int i=0; i < accels.size(); i++) {
2320 if (accels[i]->closure == NULL)
continue;
2321 if (accels[i]->closure->function == func && accels[i]->closure->data == data) ql.push_back(accels[i]);
2327 QList<LiVESAccel *> LiVESObject::get_accels_for(
const char *signame) {
2328 QList<LiVESAccel *> ql;
2329 for (
int i=0; i < accels.size(); i++) {
2330 if (accels[i]->signal_name == signame) ql.push_back(accels[i]);
2336 LiVESAccel *LiVESObject::get_accel_for(ulong handler_id) {
2337 for (
int i=0; i < accels.size(); i++) {
2338 if (accels[i]->handler_id == handler_id) {
2346 void LiVESObject::block_signal(ulong handler_id) {
2347 LiVESAccel *accel = get_accel_for(handler_id);
2348 accel->blocked =
true;
2352 void LiVESObject::block_signals(
const char *signame) {
2353 QList<LiVESAccel *>ql = get_accels_for(signame);
2354 for (
int i=0; i < ql.size(); i++) {
2355 ql[i]->blocked =
true;
2359 void LiVESObject::block_signals(ulong func, livespointer data) {
2360 QList<LiVESAccel *>ql = get_accels_for(func,data);
2361 for (
int i=0; i < ql.size(); i++) {
2362 ql[i]->blocked =
true;
2367 void LiVESObject::unblock_signal(ulong handler_id) {
2368 LiVESAccel *accel = get_accel_for(handler_id);
2369 accel->blocked =
false;
2373 void LiVESObject::unblock_signals(
const char *signame) {
2374 QList<LiVESAccel *>ql = get_accels_for(signame);
2375 for (
int i=0; i < ql.size(); i++) {
2376 ql[i]->blocked =
false;
2381 void LiVESObject::unblock_signals(ulong func, livespointer data) {
2382 QList<LiVESAccel *>ql = get_accels_for(func,data);
2383 for (
int i=0; i < ql.size(); i++) {
2384 ql[i]->blocked =
false;
2389 void LiVESObject::disconnect_signal(ulong handler_id) {
2390 LiVESAccel *accel = get_accel_for(handler_id);
2391 remove_accel(accel);
2395 QList<LiVESAccelGroup *> LiVESObject::get_accel_groups() {
2396 return accel_groups;
2401 class LiVESBox :
public LiVESWidget {};
2404 class LiVESHBox :
public LiVESBox,
public QHBoxLayout {
2407 set_type(LIVES_WIDGET_TYPE_HBOX);
2412 class LiVESEventBox :
public LiVESBox,
public QHBoxLayout {
2415 set_type(LIVES_WIDGET_TYPE_EVENT_BOX);
2420 class LiVESDrawingArea :
public LiVESBox,
public QHBoxLayout {
2422 LiVESDrawingArea() {
2423 set_type(LIVES_WIDGET_TYPE_DRAWING_AREA);
2428 class LiVESVBox :
public LiVESBox,
public QVBoxLayout {
2431 set_type(LIVES_WIDGET_TYPE_VBOX);
2436 typedef class LiVESRange LiVESRange;
2438 class LiVESAdjustment :
public LiVESObject {
2442 LiVESAdjustment(
double xval,
double low,
double upp,
double step_i,
double page_i,
double page_s) :
2443 value(xval), lower(low), upper(upp), step_increment(step_i), page_increment(page_i), page_size(page_s), frozen(
FALSE) {};
2445 void set_value(
double newval);
2446 void set_lower(
double newval);
2448 void set_upper(
double newval);
2449 void set_step_increment(
double newval);
2450 void set_page_increment(
double newval);
2451 void set_page_size(
double newval);
2453 void set_owner(LiVESWidget *widget) {
2457 LiVESWidget *get_owner() {
2462 double get_value() {
2467 double get_upper() {
2472 double get_lower() {
2476 double get_step_increment() {
2477 return step_increment;
2480 double get_page_increment() {
2481 return page_increment;
2484 double get_page_size() {
2500 double step_increment;
2501 double page_increment;
2511 qlabel = qlabel.replace(
'&',
"&&");
2512 qlabel = qlabel.replace(
'_',
'&');
2518 qlabel = qlabel.replace(
'&',
'_');
2519 qlabel = qlabel.replace(
"__",
"&");
2524 class LiVESButtonBase :
public LiVESWidget {
2530 LiVESButtonBase(QString qs) {
2534 void set_use_underline(
bool use) {
2535 QAbstractButton *qab =
dynamic_cast<QAbstractButton *
>(
this);
2537 if (use && !use_underline) {
2539 qab->setText(qmake_mnemonic(qab->text()));
2540 }
else if (!use && use_underline) {
2541 qab->setText(qmake_underline(qab->text()));
2544 use_underline = use;
2547 bool get_use_underline() {
2548 return use_underline;
2555 use_underline =
false;
2562 class LiVESToggleButton :
public LiVESButtonBase,
public QCheckBox {};
2567 class LiVESButton :
public LiVESButtonBase,
public QPushButton {
2574 LiVESButton(QString qs) {
2578 LiVESWidget *get_layout() {
2579 if (layout == NULL) {
2580 layout =
new LiVESVBox;
2581 (
static_cast<QPushButton *
>(
this))->setLayout(dynamic_cast<QLayout *>(layout));
2582 if ((static_cast<LiVESWidget *>(
this))->isVisible()) layout->setVisible(
true);
2589 LiVESWidget *layout;
2591 set_type(LIVES_WIDGET_TYPE_BUTTON);
2599 class LiVESSpinButton :
public LiVESButtonBase,
public QDoubleSpinBox {
2602 LiVESSpinButton(LiVESAdjustment *xadj,
double climb_rate, uint32_t digits) : adj(xadj) {
2605 adj->set_owner(
this);
2607 setDecimals(digits);
2608 setSingleStep(climb_rate);
2610 setValue(adj->get_value());
2611 setMinimum(adj->get_lower());
2612 setMaximum(adj->get_upper());
2616 LiVESAdjustment *get_adj() {
2620 void valueChanged(
double value) {
2622 adj->set_value(value);
2627 LiVESAdjustment *adj;
2630 set_type(LIVES_WIDGET_TYPE_SPIN_BUTTON);
2638 class LiVESRadioButton :
public LiVESButtonBase,
public QRadioButton {
2640 LiVESRadioButton() {
2644 LiVESRadioButton(QString qs) {
2648 void set_group(LiVESSList *xlist) {
2652 LiVESSList *get_list() {
2657 ~LiVESRadioButton() {
2658 QButtonGroup *qbg = (QButtonGroup *)lives_slist_nth_data(slist, 0);
2659 QList<QAbstractButton *> ql = qbg->buttons();
2660 if (ql.size() == 1) lives_slist_remove(slist, (livesconstpointer)qbg);
2668 set_type(LIVES_WIDGET_TYPE_RADIO_BUTTON);
2675 class LiVESCheckButton :
public LiVESToggleButton {
2678 LiVESCheckButton() {
2682 LiVESCheckButton(QString qs) {
2688 set_type(LIVES_WIDGET_TYPE_CHECK_BUTTON);
2695 class LiVESButtonBox :
public LiVESWidget,
public QDialogButtonBox {
2698 set_type(LIVES_WIDGET_TYPE_BUTTON_BOX);
2705 class LiVESMenuBar :
public LiVESWidget,
public QMenuBar {
2708 set_type(LIVES_WIDGET_TYPE_MENU_BAR);
2712 void reorder_child(LiVESWidget *child,
int pos) {
2713 LiVESList *children = get_children();
2714 LiVESList *new_children;
2715 QMenuBar *qmenu =
static_cast<QMenuBar *
>(
this);
2717 for (
int i = 0; children != NULL; i++) {
2718 if (i==pos) lives_list_append(new_children,child);
2719 else if (children->data != (livespointer)child) lives_list_append(new_children,children->data);
2720 qmenu->removeAction((QAction *)(children->data));
2721 children = children->next;
2724 children = new_children;
2726 for (
int i = 0; new_children != NULL; i++) {
2727 qmenu->addAction((QAction *)(new_children->data));
2728 new_children = new_children->next;
2731 set_children(new_children);
2741 class LiVESMenu :
public LiVESWidget,
public QMenu {
2744 set_type(LIVES_WIDGET_TYPE_MENU);
2747 void reorder_child(LiVESWidget *child,
int pos) {
2748 LiVESList *children = get_children();
2749 LiVESList *new_children;
2750 QMenu *qmenu =
static_cast<QMenu *
>(
this);
2752 for (
int i = 0; children != NULL; i++) {
2753 if (i==pos) lives_list_append(new_children,child);
2754 else if (children->data != (livespointer)child) lives_list_append(new_children,children->data);
2755 qmenu->removeAction((QAction *)(children->data));
2756 children = children->next;
2759 children = new_children;
2761 for (
int i = 0; new_children != NULL; i++) {
2762 qmenu->addAction((QAction *)(new_children->data));
2763 new_children = new_children->next;
2766 set_children(new_children);
2772 class LiVESTornOffMenu :
public LiVESMenu {
2774 LiVESTornOffMenu(LiVESMenu *menu) {
2775 QWidget *qmenu =
static_cast<QWidget *
>(
static_cast<QMenu *
>(menu));
2776 QWidget *parentWidget = qmenu->parentWidget();
2777 QWidget *qwidget = (
static_cast<QWidget *
>(
static_cast<QMenu *
>(
this)));
2778 qwidget->setParent(parentWidget, Qt::Window | Qt::Tool);
2779 qwidget->setAttribute(Qt::WA_DeleteOnClose,
true);
2780 qwidget->setAttribute(Qt::WA_X11NetWmWindowTypeMenu,
true);
2781 qwidget->setWindowTitle(qmenu->windowTitle());
2782 qwidget->setEnabled(qmenu->isEnabled());
2784 QList<QAction *> items = qmenu->actions();
2785 for (
int i = 0; i < items.count(); i++)
2786 qwidget->addAction(items.at(i));
2788 set_parent(menu->get_parent());
2790 if (qmenu->isVisible()) {
2792 qwidget->setVisible(
true);
2802 class LiVESMenuItem :
public LiVESWidget,
public QAction {
2804 LiVESMenuItem(LiVESWidget *parent) : QAction(static_cast<QObject *>(static_cast<LiVESObject *>(parent))) {
2805 set_type(LIVES_WIDGET_TYPE_MENU_ITEM);
2808 LiVESMenuItem(
const QString &text, LiVESWidget *parent) : QAction(text, static_cast<QObject *>(static_cast<LiVESObject *>(parent))) {
2809 set_type(LIVES_WIDGET_TYPE_MENU_ITEM);
2810 this->setText(text);
2819 class LiVESToolItem :
public LiVESWidget,
public QHBoxLayout {
2825 LiVESWidget *get_layout() {
2826 if (layout == NULL) {
2827 layout =
new LiVESVBox;
2828 (
static_cast<QHBoxLayout *
>(
this))->addLayout(dynamic_cast<QLayout *>(layout));
2829 if ((static_cast<LiVESWidget *>(
this))->isVisible()) layout->setVisible(
true);
2836 LiVESWidget *layout;
2839 set_type(LIVES_WIDGET_TYPE_TOOL_ITEM);
2846 typedef LiVESMenuItem LiVESImageMenuItem;
2850 class LiVESMenuToolButton :
public LiVESToolItem,
public QWidgetAction {
2853 LiVESMenuToolButton(
const QString &text, LiVESWidget *parent, LiVESWidget *icon) :
2854 QWidgetAction(static_cast<QObject *>(static_cast<LiVESObject *>(parent))) {
2855 QPushButton *qbutton =
new QPushButton(text);
2856 set_type(LIVES_WIDGET_TYPE_MENU_TOOL_BUTTON);
2857 setDefaultWidget(qbutton);
2866 class LiVESCheckMenuItem :
public LiVESWidget,
public QAction {
2868 LiVESCheckMenuItem(LiVESWidget *parent) : QAction(static_cast<QObject *>(static_cast<LiVESObject *>(parent))) {
2871 LiVESCheckMenuItem(
const QString &text, LiVESWidget *parent) : QAction(text, static_cast<QObject *>(static_cast<LiVESObject *>(parent))) {
2877 set_type(LIVES_WIDGET_TYPE_CHECK_MENU_ITEM);
2885 class LiVESRadioMenuItem :
public LiVESMenuItem {
2888 LiVESRadioMenuItem(LiVESWidget *parent) : LiVESMenuItem(parent) {
2892 LiVESRadioMenuItem(
const QString &text, LiVESWidget *parent) : LiVESMenuItem(text, parent) {
2898 void set_group(LiVESSList *xlist) {
2902 LiVESSList *get_list() {
2907 ~LiVESRadioMenuItem() {
2908 QActionGroup *qag =
const_cast<QActionGroup *
>(
static_cast<const QActionGroup *
>(lives_slist_nth_data(slist, 0)));
2909 QList<QAction *> ql = qag->actions();
2910 if (ql.size() == 1) lives_slist_remove(slist, (livesconstpointer)qag);
2918 set_type(LIVES_WIDGET_TYPE_RADIO_MENU_ITEM);
2925 class LiVESCombo :
public LiVESWidget,
public QComboBox {
2928 set_type(LIVES_WIDGET_TYPE_COMBO);
2933 class LiVESHSeparator :
public LiVESWidget,
public QHBoxLayout {
2936 QFrame *line =
new QFrame();
2937 line->setFrameShape(QFrame::HLine);
2938 line->setFrameShadow(QFrame::Sunken);
2940 set_type(LIVES_WIDGET_TYPE_HSEPARATOR);
2946 class LiVESVSeparator :
public LiVESWidget,
public QVBoxLayout {
2949 QFrame *line =
new QFrame();
2950 line->setFrameShape(QFrame::VLine);
2951 line->setFrameShadow(QFrame::Sunken);
2953 set_type(LIVES_WIDGET_TYPE_VSEPARATOR);
2959 class LiVESTextBuffer :
public LiVESWidget,
public QTextDocument {
2963 insert = QTextCursor(
this);
2966 QTextCursor get_cursor() {
2977 class LiVESTextView :
public LiVESWidget,
public QTextEdit {
2981 buff =
new LiVESTextBuffer();
2985 LiVESTextView(LiVESTextBuffer *xbuff) : QTextEdit(), buff(xbuff) {
2986 set_type(LIVES_WIDGET_TYPE_TEXT_VIEW);
2995 LiVESTextBuffer *get_buffer() {
3000 LiVESTextBuffer *buff;
3003 set_type(LIVES_WIDGET_TYPE_TEXT_VIEW);
3012 class LiVESTextMark :
public LiVESObject,
public QTextCursor {
3015 LiVESTextMark(LiVESTextBuffer *tbuff,
const char *mark_name,
3016 int where,
boolean left_gravity) : QTextCursor(tbuff), name(mark_name), lgrav(left_gravity) {
3017 (
static_cast<QTextCursor *
>(
this))->setPosition(where);
3024 QString get_name() {
3036 class LiVESRange :
public LiVESWidget {
3040 LiVESRange(LiVESAdjustment *adj) {
3044 virtual void init(LiVESAdjustment *adj) {}
3046 LiVESAdjustment *get_adj() {
3051 void valueChanged(
int value) {
3053 adj->set_value(value);
3058 LiVESAdjustment *adj;
3063 class LiVESScale :
public LiVESRange,
public QSlider {
3066 LiVESScale(Qt::Orientation, LiVESAdjustment *xadj) : LiVESRange(xadj) {
3067 set_type(LIVES_WIDGET_TYPE_SCALE);
3070 void init(LiVESAdjustment *adj) {
3071 adj->set_owner(
this);
3072 setMinimum(adj->get_lower());
3073 setMaximum(adj->get_upper());
3074 setValue(adj->get_value());
3075 setSingleStep(adj->get_step_increment());
3076 setPageStep(adj->get_page_increment());
3081 class LiVESScrollbar :
public LiVESRange,
public QScrollBar {
3083 LiVESScrollbar(Qt::Orientation, LiVESAdjustment *xadj) : LiVESRange(xadj) {
3084 set_type(LIVES_WIDGET_TYPE_SCROLLBAR);
3087 void init(LiVESAdjustment *adj) {
3088 adj->set_owner(
this);
3089 setMinimum(adj->get_lower());
3090 setMaximum(adj->get_upper());
3091 setValue(adj->get_value());
3092 setSingleStep(adj->get_step_increment());
3093 setPageStep(adj->get_page_increment());
3098 typedef LiVESScrollbar LiVESHScrollbar;
3101 class LiVESEntry :
public LiVESWidget,
public QLineEdit {
3104 set_type(LIVES_WIDGET_TYPE_ENTRY);
3109 class LiVESProgressBar :
public LiVESWidget,
public QProgressBar {
3111 LiVESProgressBar() {
3112 set_type(LIVES_WIDGET_TYPE_PROGRESS_BAR);
3117 class LiVESPaned :
public LiVESWidget,
public QSplitter {
3121 set_type(LIVES_WIDGET_TYPE_PANED);
3126 class LiVESLabel :
public LiVESWidget,
public QLabel {
3128 LiVESLabel(QString qstring) {
3129 set_type(LIVES_WIDGET_TYPE_LABEL);
3132 LiVESWidget *get_mnemonic_widget() {
3136 void set_mnemonic_widget(LiVESWidget *widget) {
3140 void set_owner(LiVESWidget *xowner) {
3144 LiVESWidget *get_owner() {
3148 void set_text(QString text) {
3155 LiVESWidget *mnemonicw;
3160 class LiVESRuler :
public LiVESWidget,
public QSlider {
3163 set_type(LIVES_WIDGET_TYPE_RULER);
3170 class LiVESScrolledWindow :
public LiVESWidget,
public QScrollArea {
3172 LiVESScrolledWindow(LiVESAdjustment *xhadj, LiVESAdjustment *xvadj) : hadj(xhadj), vadj(xvadj) {
3173 set_type(LIVES_WIDGET_TYPE_SCROLLED_WINDOW);
3174 hadj->set_owner(
this);
3175 vadj->set_owner(
this);
3177 QScrollBar *hs = horizontalScrollBar();
3178 hs->setMinimum(hadj->get_lower());
3179 hs->setMaximum(hadj->get_upper());
3180 hs->setValue(hadj->get_value());
3181 hs->setSingleStep(hadj->get_step_increment());
3182 hs->setPageStep(hadj->get_page_increment());
3184 QScrollBar *vs = verticalScrollBar();
3185 vs->setMinimum(vadj->get_lower());
3186 vs->setMaximum(vadj->get_upper());
3187 vs->setValue(vadj->get_value());
3188 vs->setSingleStep(vadj->get_step_increment());
3189 vs->setPageStep(vadj->get_page_increment());
3193 LiVESAdjustment *get_hadj() {
3197 LiVESAdjustment *get_vadj() {
3202 LiVESAdjustment *hadj;
3203 LiVESAdjustment *vadj;
3211 class LiVESToolButton :
public LiVESToolItem,
public QToolButton {
3214 LiVESToolButton(LiVESWidget *icon_widget,
const char *label) {
3215 set_type(LIVES_WIDGET_TYPE_TOOL_BUTTON);
3216 set_icon_widget(icon_widget);
3217 layout =
new LiVESVBox;
3218 QBoxLayout *ql =
static_cast<QVBoxLayout *
>(layout);
3219 ql->setParent(static_cast<QToolButton *>(
this));
3221 if (label != NULL) {
3222 LiVESWidget *widget =
new LiVESLabel(label);
3223 layout->add_child(widget);
3224 label_widget =
dynamic_cast<LiVESLabel *
>(widget);
3225 (
static_cast<QBoxLayout *
>(layout))->addWidget(static_cast<QLabel *>(label_widget));
3226 }
else label_widget = NULL;
3230 void set_icon_widget(LiVESWidget *widget) {
3231 if (icon_widget != NULL) remove_child(icon_widget);
3234 if (widget != NULL) qim =
dynamic_cast<QImage *
>(widget);
3236 QPixmap *qpx =
new QPixmap();
3237 qpx->convertFromImage(*qim);
3238 QIcon *qi =
new QIcon(*qpx);
3240 setIconSize(LIVES_ICON_SIZE_SMALL_TOOLBAR);
3241 icon_widget = widget;
3247 void set_label_widget(LiVESWidget *widget) {
3248 if (label_widget != NULL) {
3249 layout->remove_child(static_cast<LiVESWidget *>(label_widget));
3250 layout->removeWidget(static_cast<LiVESWidget *>(label_widget));
3252 if (widget != NULL) {
3253 layout->addWidget(widget);
3254 label_widget =
dynamic_cast<LiVESLabel *
>(widget);
3255 layout->add_child(label_widget);
3256 label_widget->set_owner(
this);
3257 }
else label_widget = NULL;
3261 void set_use_underline(
bool use) {
3262 QAbstractButton *qab =
dynamic_cast<QAbstractButton *
>(
this);
3264 if (use && !use_underline) {
3266 qab->setText(qmake_mnemonic(qab->text()));
3267 }
else if (!use && use_underline) {
3268 qab->setText(qmake_underline(qab->text()));
3271 use_underline = use;
3274 bool get_use_underline() {
3275 return use_underline;
3282 use_underline =
false;
3286 LiVESWidget *icon_widget;
3287 LiVESLabel *label_widget;
3298 typedef class LiVESWindow LiVESWindow;
3300 class LiVESAccelGroup {
3302 void add_all_accelerators(LiVESObject *window);
3303 void add_widget(LiVESObject *window);
3304 void remove_all_accelerators(LiVESObject *window);
3305 void remove_widget(LiVESObject *window);
3307 void connect(uint32_t key, LiVESXModifierType mod, LiVESAccelFlags flags, LiVESWidgetClosure *closure);
3308 void disconnect(LiVESWidgetClosure *closure);
3313 QList<LiVESObject *>widgets;
3314 QList<LiVESAccel *>accels;
3322 void LiVESObject::add_accel_group(LiVESAccelGroup *group) {
3323 accel_groups.push_back(group);
3324 group->add_all_accelerators(
this);
3325 group->add_widget(
this);
3330 boolean LiVESObject::remove_accel_group(LiVESAccelGroup *group) {
3331 if (accel_groups.removeAll(group) > 0) {
3332 group->remove_all_accelerators(
this);
3333 group->remove_widget(
this);
3341 boolean LiVESObject::remove_accels(LiVESAccelGroup *group, uint32_t key, LiVESXModifierType mods) {
3343 QKeySequence ks = make_qkey_sequence(key, mods);
3345 QList<LiVESAccel *>::iterator it = accels.begin();
3346 while (it != accels.end()) {
3347 if (((LiVESAccel *)*it)->group == group && ((LiVESAccel *)*it)->ks == ks) {
3348 remove_accel((LiVESAccel *)*it);
3357 QList<LiVESAccel *> LiVESObject::get_accels_for(LiVESAccelGroup *group, QKeySequence ks) {
3358 QList<LiVESAccel *> ql;
3359 for (
int i=0; i < accels.size(); i++) {
3360 if (accels[i]->group == group && accels[i]->ks == ks) ql.push_back(accels[i]);
3367 class LiVESWindow :
public LiVESWidget {};
3369 typedef int LiVESWindowPosition;
3370 #define LIVES_WIN_POS_DEFAULT 0
3371 #define LIVES_WIN_POS_CENTER_ALWAYS 1
3374 class LiVESMainWindow :
public LiVESWindow,
public QMainWindow {
3377 set_type(LIVES_WIDGET_TYPE_MAIN_WINDOW);
3378 set_position(LIVES_WIN_POS_DEFAULT);
3381 LiVESWidget *get_layout() {
3382 if (layout == NULL) {
3383 layout =
new LiVESVBox;
3384 (
static_cast<QMainWindow *
>(
this))->setLayout(dynamic_cast<QLayout *>(layout));
3385 if ((static_cast<LiVESWidget *>(
this))->isVisible()) layout->setVisible(
true);
3391 void set_position(LiVESWindowPosition xpos) {
3395 LiVESWindowPosition get_position() {
3401 LiVESWidget *layout;
3402 LiVESWindowPosition pos;
3408 void LiVESAccelGroup::add_all_accelerators(LiVESObject *
object) {
3409 for (
int i=0; i < accels.size(); i++) {
3410 object->add_accel(accels.at(i));
3414 void LiVESAccelGroup::add_widget(LiVESObject *window) {
3415 widgets.push_back(window);
3419 void LiVESAccelGroup::remove_all_accelerators(LiVESObject *
object) {
3420 while (accels.size() > 0) {
3421 object->remove_accel(accels.at(0));
3426 void LiVESAccelGroup::remove_widget(LiVESObject *window) {
3427 widgets.removeAll(window);
3431 LiVESAccelGroup::~LiVESAccelGroup() {
3432 while (widgets.size() > 0) {
3433 remove_all_accelerators(widgets.at(0));
3438 class LiVESVLayout:
public LiVESWidget,
public QVBoxLayout {};
3440 class LiVESDialog :
public LiVESWindow,
public QDialog {
3443 QDialog *qd =
static_cast<QDialog *
>(
this);
3444 QVBoxLayout *layout =
new QVBoxLayout;
3445 layout->setMargin(0);
3446 qd->setLayout(layout);
3448 contentArea =
new LiVESVLayout();
3449 QVBoxLayout *ca =
dynamic_cast<QVBoxLayout *
>(contentArea);
3451 layout->insertLayout(0, ca);
3453 actionArea =
new LiVESButtonBox;
3454 QDialogButtonBox *bb =
dynamic_cast<QDialogButtonBox *
>(actionArea);
3455 bb->setContentsMargins(0, 0, 0, 0);
3456 layout->addWidget(bb);
3458 set_type(LIVES_WIDGET_TYPE_DIALOG);
3460 add_child(actionArea);
3461 add_child(contentArea);
3465 LiVESWidget *get_content_area() {
3469 LiVESWidget *get_action_area() {
3473 LiVESWidget *get_layout() {
3474 if (layout == NULL) {
3475 layout =
new LiVESVBox;
3476 (
static_cast<QDialog *
>(
this))->setLayout(dynamic_cast<QLayout *>(layout));
3477 if ((static_cast<LiVESWidget *>(
this))->isVisible()) layout->setVisible(
true);
3484 LiVESWidget *layout;
3485 LiVESWidget *contentArea;
3486 LiVESWidget *actionArea;
3490 typedef int LiVESDialogFlags;
3491 typedef QMessageBox::Icon LiVESMessageType;
3493 #define LIVES_MESSAGE_INFO QMessageBox::Information
3494 #define LIVES_MESSAGE_WARNING QMessageBox::Warning
3495 #define LIVES_MESSAGE_QUESTION QMessageBox::Question
3496 #define LIVES_MESSAGE_ERROR QMessageBox::Warning
3497 #define LIVES_MESSAGE_OTHER QMessageBox::NoIcon
3499 typedef int LiVESButtonsType;
3500 #define LIVES_BUTTONS_NONE 0
3502 class LiVESMessageDialog :
public LiVESWindow,
public QMessageBox {
3504 LiVESMessageDialog() {
3505 QMessageBox *qd =
static_cast<QMessageBox *
>(
this);
3506 QVBoxLayout *layout =
new QVBoxLayout;
3507 layout->setMargin(0);
3508 qd->setLayout(layout);
3510 contentArea =
new LiVESVLayout();
3511 QVBoxLayout *ca =
dynamic_cast<QVBoxLayout *
>(contentArea);
3513 layout->insertLayout(0, ca);
3515 actionArea =
new LiVESButtonBox;
3516 QDialogButtonBox *bb =
dynamic_cast<QDialogButtonBox *
>(actionArea);
3517 bb->setContentsMargins(0, 0, 0, 0);
3518 layout->addWidget(bb);
3520 set_type(LIVES_WIDGET_TYPE_DIALOG);
3522 add_child(actionArea);
3523 add_child(contentArea);
3527 LiVESWidget *get_content_area() {
3531 LiVESWidget *get_action_area() {
3535 LiVESWidget *get_layout() {
3536 if (layout == NULL) {
3537 layout =
new LiVESVBox;
3538 (
static_cast<QDialog *
>(
this))->setLayout(dynamic_cast<QLayout *>(layout));
3539 if ((static_cast<LiVESWidget *>(
this))->isVisible()) layout->setVisible(
true);
3546 LiVESWidget *layout;
3547 LiVESWidget *contentArea;
3548 LiVESWidget *actionArea;
3552 typedef void LiVESAboutDialog;
3555 class LiVESAlignment:
public LiVESWidget,
public QGridLayout {
3557 float xalign, yalign, xscale, yscale;
3559 LiVESAlignment(
float xxalign,
float yyalign,
float xxscale,
float yyscale) :
3564 set_type(LIVES_WIDGET_TYPE_ALIGNMENT);
3567 void set_alignment(
float xxalign,
float yyalign,
float xxscale,
float yyscale) {
3582 class LiVESImage :
public LiVESWidget,
public QImage {
3589 LiVESImage(QImage *lim) {
3593 LiVESImage(
int width,
int height, QImage::Format fmt) {
3597 LiVESImage(uint8_t *data,
int width,
int height,
int bpl, QImage::Format fmt, QImageCleanupFunction cleanupFunction,
3598 livespointer cleanupInfo) {
3604 set_type(LIVES_WIDGET_TYPE_IMAGE);
3612 class LiVESArrow :
public LiVESImage {
3614 LiVESArrow(QImage *image) {
3615 set_type(LIVES_WIDGET_TYPE_ARROW);
3620 #define LIVES_CELL_RENDERER_TEXT 1
3621 #define LIVES_CELL_RENDERER_SPIN 2
3622 #define LIVES_CELL_RENDERER_TOGGLE 3
3623 #define LIVES_CELL_RENDERER_PIXBUF 4
3631 typedef QHeaderView::ResizeMode LiVESTreeViewColumnSizing;
3633 #define LIVES_TREE_VIEW_COLUMN_GROW_ONLY QHeaderView::Stretch
3634 #define LIVES_TREE_VIEW_COLUMN_AUTOSIZE QHeaderView::ResizeToContents
3635 #define LIVES_TREE_VIEW_COLUMN_FIXED QHeaderView::Fixed
3637 typedef class LiVESTreeView LiVESTreeView;
3638 typedef LiVESTreeView LiVESTreeSelection;
3641 class LiVESTreeViewColumn :
public LiVESObject,
public QStyledItemDelegate {
3642 friend LiVESTreeView;
3646 LiVESTreeViewColumn(
int rendertype) {
3650 void set_title(
const char *xtitle) {
3651 title = strdup(xtitle);
3654 void set_expand(
boolean xexpand) {
3658 void add_attribute(
const char *attr,
int col) {
3659 tvattrcol *attrcol =
new tvattrcol;
3660 attrcol->attr = strdup(attr);
3662 attributes.push_back(attrcol);
3665 void set_sizing(LiVESTreeViewColumnSizing xsizing) {
3670 void set_fixed_width(
int xfwidth) {
3675 QList<tvattrcol *> get_attributes() {
3680 ~LiVESTreeViewColumn() {
3682 for (
int i=0; i < attributes.size(); i++) {
3683 delete attributes[i]->attr;
3691 LiVESTreeViewColumnSizing sizing;
3692 QList<tvattrcol *>attributes;
3698 typedef LiVESTreeViewColumn LiVESCellRenderer;
3701 typedef QAbstractItemView::SelectionMode LiVESSelectionMode;
3702 #define LIVES_SELECTION_NONE QAbstractItemView::NoSelection
3703 #define LIVES_SELECTION_SINGLE QAbstractItemView::SingleSelection
3704 #define LIVES_SELECTION_MULTIPLE QAbstractItemView::MultiSelection
3707 typedef class LiVESTreeStore LiVESTreeStore;
3710 class LiVESTreeModel :
public LiVESObject,
public QStandardItemModel {
3711 friend LiVESTreeStore;
3715 QStandardItemModel *to_qsimodel() {
3716 QStandardItemModel *qsim =
static_cast<QStandardItemModel *
>(
this);
3717 QVariant qv = QVariant::fromValue(static_cast<LiVESObject *>(
this));
3718 qsim->setProperty(
"LiVESObject", qv);
3722 int get_coltype(
int index) {
3723 return coltypes[index];
3726 void set_tree_widget(LiVESTreeView *twidget);
3727 QTreeWidget *get_qtree_widget();
3730 void set_coltypes(
int ncols,
int *types) {
3731 for (
int i = 0; i < ncols; i++) {
3732 coltypes.append(types[i]);
3738 LiVESTreeView *widget;
3739 QList<int> coltypes;
3744 typedef LiVESTreeModel LiVESListModel;
3747 class LiVESTreeView :
public LiVESWidget,
public QTreeWidget {
3752 set_type(LIVES_WIDGET_TYPE_TREE_VIEW);
3754 QAbstractSlider *sbar =
static_cast<QAbstractSlider *
>(horizontalScrollBar());
3755 hadj =
new LiVESAdjustment(sbar->value(), sbar->minimum(), sbar->maximum(), sbar->singleStep(), sbar->pageStep(), -1.);
3756 hadj->set_owner(
this);
3757 sbar->connect(sbar, SIGNAL(valueChanged(
int)), static_cast<QObject *>(static_cast<LiVESObject *>(
this)), SLOT(hvalue_changed(
int)));
3759 sbar =
static_cast<QAbstractSlider *
>(verticalScrollBar());
3760 vadj =
new LiVESAdjustment(sbar->value(), sbar->minimum(), sbar->maximum(), sbar->singleStep(), sbar->pageStep(), -1.);
3761 vadj->set_owner(
this);
3762 sbar->connect(sbar, SIGNAL(valueChanged(
int)), static_cast<QObject *>(static_cast<LiVESObject *>(
this)), SLOT(vvalue_changed(
int)));
3766 void set_model(LiVESTreeModel *xmodel) {
3768 xmodel->set_tree_widget(
this);
3769 QStandardItemModel *qmodel = xmodel->to_qsimodel();
3770 (
static_cast<QAbstractItemView *
>(
this))->setModel(static_cast<QAbstractItemModel *>(qmodel));
3773 LiVESTreeModel *get_model() {
3779 void append_column(LiVESTreeViewColumn *col) {
3783 QList<tvattrcol *> ql = col->get_attributes();
3784 QList<QStandardItem *> qvals;
3785 QStandardItemModel *qmodel = model->to_qsimodel();
3789 for (
int i=0; i < ql.size(); i++) {
3790 attrcol = ql[i]->col;
3791 if (!strcmp(ql[i]->attr,
"text")) {
3794 qmodel->appendColumn(qvals);
3797 else if (!strcmp(ql[i]->attr,
"pixbuf")) {
3799 qmodel->appendColumn(qvals);
3802 else if (!strcmp(ql[i]->attr,
"active")) {
3804 qmodel->appendColumn(qvals);
3808 int newcol = qmodel->columnCount();
3809 QTreeView *qtv =
static_cast<QTreeView *
>(
this);
3810 if (col->fwidth != -1) {
3811 qtv->setColumnWidth(newcol, col->fwidth);
3814 QHeaderView *qv = (
static_cast<QTreeView *
>(
this))->header();
3815 qv->setSectionResizeMode(newcol, col->sizing);
3821 LiVESAdjustment *get_hadj() {
3825 LiVESAdjustment *get_vadj() {
3846 LiVESTreeModel *model;
3847 LiVESAdjustment *hadj, *vadj;
3851 #define LIVES_COL_TYPE_STRING 1
3852 #define LIVES_COL_TYPE_INT 2
3853 #define LIVES_COL_TYPE_UINT 3
3854 #define LIVES_COL_TYPE_BOOLEAN 4
3855 #define LIVES_COL_TYPE_PIXBUF 5
3858 typedef QTreeWidgetItem LiVESTreeIter;
3860 void LiVESTreeModel::set_tree_widget(LiVESTreeView *twidget) {
3864 QTreeWidget *LiVESTreeModel::get_qtree_widget() {
3865 return static_cast<QTreeWidget *
>(widget);
3870 class LiVESTreeStore :
public LiVESTreeModel {
3872 LiVESTreeStore(
int ncols,
int *types) {}
3877 class LiVESListStore :
public LiVESListModel {
3879 LiVESListStore(
int ncols,
int *types) {}
3887 void LiVESAdjustment::set_value(
double newval) {
3888 if (newval != value) {
3893 if (LIVES_IS_SCALE(owner)) {
3894 (
dynamic_cast<QAbstractSlider *
>(owner))->setValue(newval);
3895 }
else if (LIVES_IS_SCROLLBAR(owner)) {
3896 (
dynamic_cast<QScrollBar *
>(owner))->setValue(newval);
3897 }
else if (LIVES_IS_SPIN_BUTTON(owner)) {
3899 (
dynamic_cast<QDoubleSpinBox *
>(owner))->setValue(newval);
3900 }
else if (LIVES_IS_TREE_VIEW(owner)) {
3901 if (
this == (dynamic_cast<LiVESTreeView *>(owner))->get_hadj()) {
3902 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setValue(newval);
3904 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setValue(newval);
3906 }
else if (LIVES_IS_SCROLLED_WINDOW(owner)) {
3907 if (
this == (dynamic_cast<LiVESScrolledWindow *>(owner))->get_hadj()) {
3908 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setValue(newval);
3910 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setValue(newval);
3917 void LiVESAdjustment::set_upper(
double newval) {
3918 if (newval != upper) {
3923 if (LIVES_IS_SCALE(owner)) {
3924 (
dynamic_cast<QAbstractSlider *
>(owner))->setMaximum(newval);
3925 }
else if (LIVES_IS_SCROLLBAR(owner)) {
3927 (
dynamic_cast<QScrollBar *
>(owner))->setMaximum(newval);
3928 }
else if (LIVES_IS_SPIN_BUTTON(owner)) {
3930 (
dynamic_cast<QDoubleSpinBox *
>(owner))->setMaximum(newval);
3931 }
else if (LIVES_IS_TREE_VIEW(owner)) {
3932 if (
this == (dynamic_cast<LiVESTreeView *>(owner))->get_hadj()) {
3933 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setMaximum(newval);
3935 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setMaximum(newval);
3937 }
else if (LIVES_IS_SCROLLED_WINDOW(owner)) {
3938 if (
this == (dynamic_cast<LiVESScrolledWindow *>(owner))->get_hadj()) {
3939 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setMaximum(newval);
3941 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setMaximum(newval);
3951 void LiVESAdjustment::set_lower(
double newval) {
3952 if (newval != lower) {
3956 if (LIVES_IS_SCALE(owner)) {
3957 (
dynamic_cast<QAbstractSlider *
>(owner))->setMinimum(newval);
3958 }
else if (LIVES_IS_SCROLLBAR(owner)) {
3960 (
dynamic_cast<QScrollBar *
>(owner))->setMinimum(newval);
3961 }
else if (LIVES_IS_SPIN_BUTTON(owner)) {
3963 (
dynamic_cast<QDoubleSpinBox *
>(owner))->setMinimum(newval);
3964 }
else if (LIVES_IS_TREE_VIEW(owner)) {
3965 if (
this == (dynamic_cast<LiVESTreeView *>(owner))->get_hadj()) {
3966 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setMinimum(newval);
3968 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setMinimum(newval);
3970 }
else if (LIVES_IS_SCROLLED_WINDOW(owner)) {
3971 if (
this == (dynamic_cast<LiVESScrolledWindow *>(owner))->get_hadj()) {
3972 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setMinimum(newval);
3974 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setMinimum(newval);
3982 void LiVESAdjustment::set_step_increment(
double newval) {
3983 if (newval != step_increment) {
3984 step_increment = newval;
3988 if (LIVES_IS_SCALE(owner)) {
3989 (
dynamic_cast<QAbstractSlider *
>(owner))->setSingleStep(newval);
3990 }
else if (LIVES_IS_SCROLLBAR(owner)) {
3992 (
dynamic_cast<QScrollBar *
>(owner))->setSingleStep(newval);
3993 }
else if (LIVES_IS_SPIN_BUTTON(owner)) {
3995 (
dynamic_cast<QDoubleSpinBox *
>(owner))->setSingleStep(newval);
3996 }
else if (LIVES_IS_TREE_VIEW(owner)) {
3997 if (
this == (dynamic_cast<LiVESTreeView *>(owner))->get_hadj()) {
3998 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setSingleStep(newval);
4000 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setSingleStep(newval);
4002 }
else if (LIVES_IS_SCROLLED_WINDOW(owner)) {
4003 if (
this == (dynamic_cast<LiVESScrolledWindow *>(owner))->get_hadj()) {
4004 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setSingleStep(newval);
4006 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setSingleStep(newval);
4013 void LiVESAdjustment::set_page_increment(
double newval) {
4014 if (newval != page_increment) {
4015 page_increment = newval;
4019 if (LIVES_IS_SCALE(owner)) {
4020 (
dynamic_cast<QAbstractSlider *
>(owner))->setPageStep(newval);
4021 }
else if (LIVES_IS_SCROLLBAR(owner)) {
4023 (
dynamic_cast<QScrollBar *
>(owner))->setPageStep(newval);
4024 }
else if (LIVES_IS_TREE_VIEW(owner)) {
4025 if (
this == (dynamic_cast<LiVESTreeView *>(owner))->get_hadj()) {
4026 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setPageStep(newval);
4028 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setPageStep(newval);
4030 }
else if (LIVES_IS_SCROLLED_WINDOW(owner)) {
4031 if (
this == (dynamic_cast<LiVESScrolledWindow *>(owner))->get_hadj()) {
4032 (
dynamic_cast<QAbstractScrollArea *
>(owner))->horizontalScrollBar()->setPageStep(newval);
4034 (
dynamic_cast<QAbstractScrollArea *
>(owner))->verticalScrollBar()->setPageStep(newval);
4041 void LiVESAdjustment::set_page_size(
double newval) {
4043 if (newval != page_size) {
4052 class LiVESTable :
public LiVESWidget,
public QGridLayout {
4056 set_type(LIVES_WIDGET_TYPE_TABLE);
4061 LiVESWidget *layout;
4066 typedef QWindow LiVESXWindow;
4068 typedef class LiVESImage LiVESPixbuf;
4070 typedef LiVESWidget LiVESEditable;
4071 typedef LiVESWidget LiVESContainer;
4072 typedef LiVESWidget LiVESMenuShell;
4073 typedef LiVESWidget LiVESBin;
4075 typedef QSlider LiVESScaleButton;
4076 typedef void LiVESExpander;
4079 void qt_jpeg_save(LiVESPixbuf *pixbuf,
const char *fname, LiVESError **errptr,
int quality) {
4081 QImageWriter qiw(QString::fromUtf8(fname),
"jpeg");
4083 QImageWriter qiw(QString::fromLocal8Bit(fname),
"jpeg");
4085 qiw.setQuality(quality);
4086 if (!qiw.write(static_cast<QImage>(*pixbuf))) {
4087 if (errptr != NULL) {
4088 *errptr = (LiVESError *)malloc(
sizeof(LiVESError));
4089 (*errptr)->code = qiw.error();
4090 (*errptr)->message = strdup(qiw.errorString().toUtf8().constData());
4096 void qt_png_save(LiVESPixbuf *pixbuf,
const char *fname, LiVESError **errptr,
int cmp) {
4098 QImageWriter qiw(QString::fromUtf8(fname),
"png");
4100 QImageWriter qiw(QString::fromLocal8Bit(fname),
"png");
4102 qiw.setCompression(cmp);
4103 if (!qiw.write(static_cast<QImage>(*pixbuf))) {
4104 if (errptr != NULL) {
4105 *errptr = (LiVESError *)malloc(
sizeof(LiVESError));
4106 (*errptr)->code = qiw.error();
4107 (*errptr)->message = strdup(qiw.errorString().toUtf8().constData());
4115 typedef Qt::ScrollBarPolicy LiVESPolicyType;
4116 #define LIVES_POLICY_AUTOMATIC Qt::ScrollBarAsNeeded
4117 #define LIVES_POLICY_NEVER Qt::ScrollBarAlwaysOff
4118 #define LIVES_POLICY_ALWAYS Qt::ScrollBarAlwaysOn
4121 class LiVESFrame :
public LiVESWidget,
public QGroupBox {
4123 LiVESFrame(QString text) {
4124 set_type(LIVES_WIDGET_TYPE_FRAME);
4126 LiVESWidget *label_widget =
new LiVESLabel(text);
4127 set_label_widget(label_widget);
4131 void set_label(QString text) {
4132 label_widget->set_text(text);
4136 void set_label_widget(LiVESWidget *widget) {
4137 if (label_widget != NULL) {
4138 remove_child(static_cast<LiVESWidget *>(label_widget));
4140 if (widget != NULL) {
4141 add_child(label_widget);
4142 label_widget =
dynamic_cast<LiVESLabel *
>(widget);
4143 label_widget->set_owner(
this);
4144 setTitle(label_widget->text());
4146 label_widget = NULL;
4152 LiVESWidget *get_label_widget() {
4153 return static_cast<LiVESWidget *
>(label_widget);
4158 LiVESWidget *get_layout() {
4159 if (layout == NULL) {
4160 layout =
new LiVESVBox;
4161 (
static_cast<QGroupBox *
>(
this))->setLayout(dynamic_cast<QLayout *>(layout));
4162 if ((static_cast<LiVESWidget *>(
this))->isVisible()) layout->setVisible(
true);
4170 LiVESWidget *layout;
4171 LiVESLabel *label_widget;
4177 class LiVESFileChooser :
public LiVESWidget,
public QFileDialog {
4179 LiVESFileChooser() {
4180 set_type(LIVES_WIDGET_TYPE_FILE_CHOOSER);
4186 typedef int LiVESFileChooserAction;
4187 #define LIVES_FILE_CHOOSER_ACTION_OPEN 1
4188 #define LIVES_FILE_CHOOSER_ACTION_SAVE 2
4189 #define LIVES_FILE_CHOOSER_ACTION_SELECT_FOLDER 3
4190 #define LIVES_FILE_CHOOSER_ACTION_CREATE_FOLDER 4
4191 #define LIVES_FILE_CHOOSER_ACTION_SELECT_DEVICE 5
4194 class LiVESNotebook :
public LiVESWidget,
public QTabWidget {
4198 set_type(LIVES_WIDGET_TYPE_NOTEBOOK);
4202 for (
int i = 0; i < label_widgets.size(); i++) {
4203 label_widgets[i]->dec_refcount();
4207 void set_tab_label(LiVESWidget *child, LiVESWidget *xlabel) {
4208 int i = get_child_index(child);
4209 if (i == -1)
return;
4211 if (xlabel != NULL) {
4212 label_widgets[i]->dec_refcount();
4213 LiVESLabel *label =
dynamic_cast<LiVESLabel *
>(xlabel);
4214 label_widgets[i] = label;
4215 label->set_owner(
this);
4216 QLabel *qlabel =
static_cast<QLabel *
>(label);
4217 setTabText(i, qlabel->text());
4222 void append_page() {
4223 LiVESWidget *label_widget =
new LiVESLabel(NULL);
4224 label_widgets.append(label_widget);
4228 QList <LiVESWidget *> label_widgets;
4235 class LiVESToolbar :
public LiVESWidget,
public QToolBar {
4239 set_type(LIVES_WIDGET_TYPE_TOOLBAR);
4242 void add_action(QAction *act,
int pos) {
4243 actions.insert(pos, act);
4246 QAction *get_action(
int pos) {
4247 return actions.at(pos);
4251 return actions.size();
4255 QList<QAction *>actions;
4262 class LiVESColorButton :
public LiVESButtonBase,
public QPushButton {
4267 LiVESColorButton(
const LiVESWidgetColor *col) {
4268 set_type(LIVES_WIDGET_TYPE_COLOR_BUTTON);
4269 static_cast<QObject *
>(
static_cast<QPushButton *
>(
this))->connect(static_cast<QObject *>(static_cast<QPushButton *>(
this)),
4271 static_cast<QObject *>(static_cast<QPushButton *>(
this)),
4278 void set_colour(
const LiVESWidgetColor *col) {
4279 QColor xcolor(col->red * 255., col->green * 255., col->blue * 255., col->alpha * 255.);
4283 void set_colour(QColor xcolour) {
4284 if (colour != xcolour) {
4286 QPushButton *qpb =
static_cast<QPushButton *
>(
this);
4287 QPalette p = qpb->palette();
4288 QColor mycolour = xcolour;
4289 if (!use_alpha) mycolour.setAlpha(255);
4290 p.setColor(QPalette::Button, mycolour);
4298 QColor get_colour() {
4302 void get_colour(LiVESWidgetColor *col) {
4303 col->red = (float)colour.red() / 255.;
4304 col->green = (float)colour.green() / 255.;
4305 col->blue = (float)colour.blue() / 255.;
4306 col->alpha = (float)colour.alpha() / 255.;
4310 void set_title(
const char *xtitle) {
4311 title = QString::fromUtf8(xtitle);
4314 void set_use_alpha(
boolean val) {
4344 class LiVESTimer :
public LiVESObject,
public QTimer {
4347 LiVESTimer(uint32_t interval, LiVESWidgetSourceFunc xfunc, livespointer data);
4349 uint32_t get_handle() {
4360 LiVESWidgetSourceFunc func;
4365 static QList<LiVESTimer *> static_timers;
4368 LiVESTimer::LiVESTimer(uint32_t interval, LiVESWidgetSourceFunc xfunc, livespointer data) {
4369 set_type(LIVES_OBJECT_TYPE_TIMER);
4370 static_timers.append(
this);
4372 static_cast<QObject *
>(
static_cast<QTimer *
>(
this))->connect(static_cast<QObject *>(static_cast<QTimer *>(
this)),
4374 static_cast<QObject *>(static_cast<QTimer *>(
this)),
4381 void LiVESTimer::update() {
4383 boolean ret = (func)(data);
4386 static_timers.removeOne(
this);
4391 void remove_static_timer(uint32_t handle) {
4392 for (
int i = 0; i < static_timers.size(); i++) {
4393 if (static_timers.at(i)->get_handle() == handle) {
4394 static_timers.removeOne(static_timers.at(i));
4401 typedef Qt::ToolButtonStyle LiVESToolbarStyle;
4402 #define LIVES_TOOLBAR_ICONS Qt::ToolButtonIconOnly
4403 #define LIVES_TOOLBAR_TEXT Qt::ToolButtonTextOnly
4405 typedef QSize LiVESRequisition;
4407 typedef int LiVESTextIter;
4409 class LiVESTreePath {
4412 LiVESTreePath(
const char *
string) {
4414 QStringList qsl = qs.split(
":");
4417 for (
int i=0; i < qsl.size(); i++) {
4418 qli.append(qsl.at(i).toInt());
4424 LiVESTreePath(QList<int> qli) {
4438 int *get_indices() {
4446 void init(QList<int> qli) {
4448 indices = (
int *)(malloc(cnt *
sizeof(
int)));
4449 for (
int i=0; i < cnt; i++) {
4450 indices[i] = qli.at(i);
4457 typedef Qt::Orientation LiVESOrientation;
4458 #define LIVES_ORIENTATION_HORIZONTAL Qt::Horizontal
4459 #define LIVES_ORIENTATION_VERTICAL Qt::Vertical
4461 typedef int LiVESButtonBoxStyle;
4462 #define LIVES_BUTTONBOX_DEFAULT_STYLE 0
4463 #define LIVES_BUTTONBOX_SPREAD 1
4464 #define LIVES_BUTTONBOX_EDGE 2
4465 #define LIVES_BUTTONBOX_START 3
4466 #define LIVES_BUTTONBOX_END 4
4467 #define LIVES_BUTTONBOX_CENTER 5
4469 typedef int LiVESReliefStyle;
4471 #define LIVES_RELIEF_NORMAL 2
4472 #define LIVES_RELIEF_HALF 1
4473 #define LIVES_RELIEF_NONE 0
4475 #define LIVES_ACCEL_VISIBLE 1
4477 typedef int LiVESWindowType;
4478 #define LIVES_WINDOW_TOPLEVEL Qt::Window
4479 #define LIVES_WINDOW_POPUP Qt::Popup
4481 typedef QFrame::Shadow LiVESShadowType;
4482 #define LIVES_SHADOW_NONE QFrame::Plain
4483 #define LIVES_SHADOW_IN QFrame::Raised
4484 #define LIVES_SHADOW_OUT QFrame::Sunken
4485 #define LIVES_SHADOW_ETCHED_IN QFrame::Raised
4486 #define LIVES_SHADOW_ETCHED_OUT QFrame::Sunken
4490 typedef int LiVESPositionType;
4491 #define LIVES_POS_LEFT 1
4492 #define LIVES_POS_RIGHT 2
4493 #define LIVES_POS_TOP 3
4494 #define LIVES_POS_BOTTOM 4
4497 #define LIVES_WIDGET(a) ((LiVESWidget *)a)
4500 #define LIVES_EDITABLE(a) (a)
4502 #define LIVES_CONTAINER(a) LIVES_WIDGET(a)
4503 #define LIVES_GUI_OBJECT(a) LIVES_WIDGET(a)
4504 #define LIVES_EXPANDER(a) LIVES_WIDGET(a)
4505 #define LIVES_BIN(a) LIVES_WIDGET(a)
4506 #define LIVES_MENU_SHELL(a) LIVES_WIDGET(a)
4508 #define LIVES_WIDGET_OBJECT(a) ((LiVESObject *)a)
4509 #define LIVES_COMBO(a) ((LiVESCombo *)a)
4510 #define LIVES_HBOX(a) ((LiVESHBox *)a)
4511 #define LIVES_VBOX(a) ((LiVESVBox *)a)
4512 #define LIVES_BOX(a) ((LiVESBox *)a)
4513 #define LIVES_ALIGNMENT(a) ((LiVESAlignment *)a)
4514 #define LIVES_TOOLBAR(a) ((LiVESToolbar *)a)
4515 #define LIVES_TOOL_BUTTON(a) ((LiVESToolButton *)a)
4516 #define LIVES_EVENT_BOX(a) ((LiVESEventBox *)a)
4517 #define LIVES_DRAWING_AREA(a) ((LiVESDrawingArea *)a)
4518 #define LIVES_TEXT_VIEW(a) ((LiVESTextView *)a)
4519 #define LIVES_TEXT_BUFFER(a) ((LiVESTextBuffer *)a)
4520 #define LIVES_BUTTON_BOX(a) ((LiVESButtonBox *)a)
4521 #define LIVES_FRAME(a) ((LiVESFrame *)a)
4522 #define LIVES_SCALE(a) ((LiVESScale *)a)
4523 #define LIVES_RANGE(a) ((LiVESRange *)a)
4524 #define LIVES_ADJUSTMENT(a) ((LiVESAdjustment *)a)
4525 #define LIVES_TABLE(a) ((LiVESTable *)a)
4526 #define LIVES_NOTEBOOK(a) ((LiVESNotebook *)a)
4527 #define LIVES_MENU(a) ((LiVESMenu *)a)
4528 #define LIVES_MENU_ITEM(a) ((LiVESMenuItem *)a)
4529 #define LIVES_MENU_TOOL_ITEM(a) ((LiVESMenuToolItem *)a)
4530 #define LIVES_MENU_TOOL_BUTTON(a) ((LiVESMenuToolButton *)a)
4531 #define LIVES_RULER(a) ((LiVESRuler *)a)
4532 #define LIVES_CHECK_MENU_ITEM(a) ((LiVESCheckMenuItem *)a)
4533 #define LIVES_IMAGE(a) ((LiVESImage *)a)
4534 #define LIVES_PROGRESS_BAR(a) ((LiVESProgressBar *)a)
4535 #define LIVES_BUTTON(a) ((LiVESButton *)a)
4536 #define LIVES_SPIN_BUTTON(a) ((LiVESSpinButton *)a)
4537 #define LIVES_SCALE_BUTTON(a) ((LiVESScaleButton *)a)
4538 #define LIVES_TOGGLE_BUTTON(a) ((LiVESToggleButton *)a)
4539 #define LIVES_RADIO_BUTTON(a) ((LiVESRadioButton *)a)
4540 #define LIVES_RADIO_MENU_ITEM(a) ((LiVESRadioMenuItem *)a)
4541 #define LIVES_COLOR_BUTTON(a) ((LiVESColorButton *)a)
4542 #define LIVES_DIALOG(a) ((LiVESDialog *)a)
4543 #define LIVES_LABEL(a) ((LiVESLabel *)a)
4544 #define LIVES_ENTRY(a) ((LiVESEntry *)a)
4545 #define LIVES_PANED(a) ((LiVESPaned *)a)
4546 #define LIVES_FILE_CHOOSER(a) ((LiVESFileChooser *)a)
4547 #define LIVES_ACCEL_GROUP(a) ((LiVESAccelGroup *)a)
4548 #define LIVES_WINDOW(a) ((LiVESWindow *)a)
4549 #define LIVES_SCROLLED_WINDOW(a) ((LiVESScrolledWindow *)a)
4550 #define LIVES_TREE_MODEL(a) ((LiVESTreeModel *)a)
4551 #define LIVES_TREE_VIEW(a) ((LiVESTreeView *)a)
4552 #define LIVES_LIST_STORE(a) ((LiVESListStore *)a)
4553 #define LIVES_TOOL_ITEM(a) ((LiVESToolItem *)a)
4556 #define LIVES_STOCK_UNDO "edit-undo"
4557 #define LIVES_STOCK_REDO "edit-redo"
4558 #define LIVES_STOCK_ADD "list-add"
4559 #define LIVES_STOCK_REMOVE "list-remove"
4560 #define LIVES_STOCK_NO "media-record"
4561 #define LIVES_STOCK_QUIT "application-exit"
4562 #define LIVES_STOCK_OPEN "document-open"
4563 #define LIVES_STOCK_CLOSE "window-close"
4564 #define LIVES_STOCK_CLEAR "edit-clear"
4565 #define LIVES_STOCK_DELETE "edit-delete"
4566 #define LIVES_STOCK_SAVE_AS "document-save-as"
4567 #define LIVES_STOCK_SAVE "document-save"
4568 #define LIVES_STOCK_REFRESH "view-refresh"
4569 #define LIVES_STOCK_REVERT_TO_SAVED "document-revert"
4570 #define LIVES_STOCK_GO_BACK "go-previous"
4571 #define LIVES_STOCK_GO_FORWARD "go-next"
4572 #define LIVES_STOCK_REFRESH "view-refresh"
4573 #define LIVES_STOCK_MEDIA_PLAY "media-playback-start"
4574 #define LIVES_STOCK_MEDIA_STOP "media-playback-stop"
4575 #define LIVES_STOCK_MEDIA_REWIND "media-seek-backward"
4576 #define LIVES_STOCK_MEDIA_RECORD "media-record"
4577 #define LIVES_STOCK_MEDIA_PAUSE "media-pause"
4578 #define LIVES_STOCK_PREFERENCES "preferences-system"
4579 #define LIVES_STOCK_DIALOG_INFO "dialog-information"
4580 #define LIVES_STOCK_MISSING_IMAGE "image-missing"
4583 #define LIVES_STOCK_YES "gtk-yes" // non-standard image ?
4584 #define LIVES_STOCK_APPLY "gtk-apply" // non-standard image ?
4585 #define LIVES_STOCK_CANCEL "gtk-cancel" // non-standard image ?
4586 #define LIVES_STOCK_OK "gtk-ok" // non-standard image ?
4589 char LIVES_STOCK_LABEL_CANCEL[32];
4590 char LIVES_STOCK_LABEL_OK[32];
4591 char LIVES_STOCK_LABEL_YES[32];
4592 char LIVES_STOCK_LABEL_NO[32];
4593 char LIVES_STOCK_LABEL_SAVE[32];
4594 char LIVES_STOCK_LABEL_SAVE_AS[32];
4595 char LIVES_STOCK_LABEL_OPEN[32];
4596 char LIVES_STOCK_LABEL_QUIT[32];
4597 char LIVES_STOCK_LABEL_APPLY[32];
4598 char LIVES_STOCK_LABEL_CLOSE[32];
4599 char LIVES_STOCK_LABEL_REVERT[32];
4600 char LIVES_STOCK_LABEL_REFRESH[32];
4601 char LIVES_STOCK_LABEL_DELETE[32];
4602 char LIVES_STOCK_LABEL_GO_FORWARD[32];
4605 typedef int LiVESAttachOptions;
4606 #define LIVES_EXPAND 1
4607 #define LIVES_SHRINK 2
4608 #define LIVES_FILL 3
4615 typedef bool LiVESWrapMode;
4616 #define LIVES_WRAP_NONE false
4617 #define LIVES_WRAP_WORD true
4619 typedef Qt::Alignment LiVESJustification;
4621 #define LIVES_JUSTIFY_LEFT Qt::AlignLeft
4622 #define LIVES_JUSTIFY_RIGHT Qt::AlignRight
4623 #define LIVES_JUSTIFY_CENTER Qt::AlignHCenter
4624 #define LIVES_JUSTIFY_FILL Qt::AlignJustify
4631 LiVESWidget::~LiVESWidget() {
4632 if (LIVES_IS_SPIN_BUTTON(
this)) {
4633 LiVESAdjustment *adj = (
static_cast<LiVESSpinButton *
>(
this))->get_adj();
4634 adj->dec_refcount();
4637 if (LIVES_IS_RANGE(
this)) {
4638 LiVESAdjustment *adj = (
dynamic_cast<LiVESRange *
>(
this))->get_adj();
4639 adj->dec_refcount();
4642 if (LIVES_IS_TREE_VIEW(
this)) {
4643 LiVESAdjustment *adj = (
static_cast<LiVESTreeView *
>(
this))->get_hadj();
4644 adj->dec_refcount();
4645 adj = (
static_cast<LiVESTreeView *
>(
this))->get_vadj();
4646 adj->dec_refcount();
4649 if (LIVES_IS_SCROLLED_WINDOW(
this)) {
4650 LiVESAdjustment *adj = (
static_cast<LiVESScrolledWindow *
>(
this))->get_hadj();
4651 adj->dec_refcount();
4652 adj = (
static_cast<LiVESScrolledWindow *
>(
this))->get_vadj();
4653 adj->dec_refcount();
4657 if (parent != NULL) {
4659 parent->remove_child(
this);
4662 LiVESList *xchildren = children;
4665 while (xchildren != NULL) {
4667 xchildren = xchildren->next;
4670 lives_list_free(children);
4673 #define LINGO_ALIGN_LEFT Qt::AlignLeft
4674 #define LINGO_ALIGN_RIGHT Qt::AlignRight
4675 #define LINGO_ALIGN_CENTER Qt::AlignHCenter
4677 #define LINGO_SCALE 1
4679 typedef class lives_painter_t lives_painter_t;
4681 class LingoLayout :
public LiVESObject {
4683 LingoLayout(
const char *xtext,
const char *xfont,
double fsize) {
4684 text = QString::fromUtf8(xtext);
4685 font = QFont(QString::fromUtf8(xfont));
4686 font.setPointSizeF((
float)fsize);
4687 align = LINGO_ALIGN_LEFT;
4690 void set_alignment(
int xalign) {
4694 void set_text(
const char *xtext, ssize_t len) {
4695 text = QString::fromUtf8(xtext, len);
4698 void get_size(
int *bwidth,
int *bheight,
int pwidth,
int pheight);
4700 void set_coords(
int xx,
int xy,
int xwidth,
int xheight) {
4707 void render_text(lives_painter_t *painter);
4714 int x,y,width,height;
4717 LIVES_INLINE void lingo_layout_set_alignment(LingoLayout *l,
int alignment) {
4718 l->set_alignment(alignment);
4722 LIVES_INLINE void lingo_layout_set_text(LingoLayout *l,
const char *text, ssize_t len) {
4723 l->set_text(text, len);
4727 LIVES_INLINE void lingo_layout_set_coords(LingoLayout *l,
int x,
int y,
int width,
int height) {
4728 l->set_coords(x, y, width, height);
4732 LIVES_INLINE void lingo_layout_get_size(LingoLayout *l,
int *rw,
int *rh,
int width,
int height) {
4733 l->get_size(rw, rh, width, height);
4737 LIVES_INLINE void lingo_painter_show_layout(lives_painter_t *painter, LingoLayout *l) {
4738 l->render_text(painter);
4745 #ifdef PAINTER_QPAINTER
4746 # include <QtGui/QPainter>
4750 static void imclean(livespointer data) {
4754 typedef QImage::Format lives_painter_format_t;
4755 #define LIVES_PAINTER_FORMAT_A1 QImage::Format_Mono
4756 #define LIVES_PAINTER_FORMAT_A8 QImage::Format_Indexed8
4757 #define LIVES_PAINTER_FORMAT_ARGB32 QImage::Format_ARGB32_Premultiplied
4760 class lives_painter_surface_t :
public QImage,
public LiVESObject {
4764 lives_painter_surface_t(
int width,
int height, QImage::Format fmt) : QImage(width, height, fmt) {
4768 lives_painter_surface_t (uint8_t *data, lives_painter_format_t fmt,
int width,
int height,
int stride)
4769 : QImage(data,width,height,stride,fmt,imclean,(livespointer)data) {
4779 class lives_painter_t :
public QPainter {
4782 lives_painter_surface_t *target;
4786 lives_painter_t(QWidget *widget) : QPainter(widget) {
4791 lives_painter_t(lives_painter_surface_t *surf) : QPainter() {
4797 ~lives_painter_t() {
4806 p =
new QPainterPath();
4815 #define LIVES_PAINTER_CONTENT_COLOR 0
4817 typedef QPainter::CompositionMode lives_painter_operator_t;
4819 #define LIVES_PAINTER_OPERATOR_UNKNOWN QPainter::CompositionMode_SourceOver
4820 #define LIVES_PAINTER_OPERATOR_DEFAULT QPainter::CompositionMode_SourceOver
4822 #define LIVES_PAINTER_OPERATOR_DEST_OUT QPainter::CompositionMode_DestinationOut
4824 #define LIVES_PAINTER_OPERATOR_DIFFERENCE QPainter::CompositionMode_Difference
4825 #define LIVES_PAINTER_OPERATOR_OVERLAY QPainter::CompositionMode_Overlay
4827 typedef Qt::FillRule lives_painter_fill_rule_t;
4829 #define LIVES_PAINTER_FILL_RULE_WINDING Qt::WindingFill
4830 #define LIVES_PAINTER_FILL_RULE_EVEN_ODD Qt::OddEvenFill
4835 void LingoLayout::get_size(
int *bwidth,
int *bheight,
int pwidth,
int pheight) {
4837 QRect rect = qp.boundingRect(0, 0, pwidth, pheight, Qt::AlignLeft | Qt::AlignTop, text);
4838 *bwidth = rect.width();
4839 *bheight = rect.height();
4843 void LingoLayout::render_text(lives_painter_t *painter) {
4844 painter->drawText(x, y, width, height, align, text);
4852 #include "moc_widget-helper-qt.cpp"
#define lives_free(a)
Definition: support.h:14
int boolean
Definition: videoplugin.h:50
#define lives_strdup(a)
Definition: support.h:13
#define dgettext(Domain, Message)
Definition: support.h:39
#define dngettext(Domain, Message, MsgPlur, n)
Definition: support.h:40
#define TRUE
Definition: videoplugin.h:55
#define LIVES_INLINE
Definition: main.h:242
#define FALSE
Definition: videoplugin.h:56