summaryrefslogtreecommitdiffstats
path: root/src/modules/objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/objects')
-rw-r--r--src/modules/objects/Makefile.am143
-rw-r--r--src/modules/objects/class_button.cpp178
-rw-r--r--src/modules/objects/class_button.h58
-rw-r--r--src/modules/objects/class_buttongroup.cpp87
-rw-r--r--src/modules/objects/class_buttongroup.h44
-rw-r--r--src/modules/objects/class_checkbox.cpp128
-rw-r--r--src/modules/objects/class_checkbox.h48
-rw-r--r--src/modules/objects/class_combobox.cpp368
-rw-r--r--src/modules/objects/class_combobox.h71
-rw-r--r--src/modules/objects/class_dialog.cpp89
-rw-r--r--src/modules/objects/class_dialog.h44
-rw-r--r--src/modules/objects/class_dockwindow.cpp276
-rw-r--r--src/modules/objects/class_dockwindow.h49
-rw-r--r--src/modules/objects/class_file.cpp488
-rw-r--r--src/modules/objects/class_file.h113
-rw-r--r--src/modules/objects/class_groupbox.cpp376
-rw-r--r--src/modules/objects/class_groupbox.h64
-rw-r--r--src/modules/objects/class_hbox.cpp128
-rw-r--r--src/modules/objects/class_hbox.h47
-rw-r--r--src/modules/objects/class_label.cpp409
-rw-r--r--src/modules/objects/class_label.h54
-rw-r--r--src/modules/objects/class_layout.cpp274
-rw-r--r--src/modules/objects/class_layout.h52
-rw-r--r--src/modules/objects/class_lcd.cpp180
-rw-r--r--src/modules/objects/class_lcd.h51
-rw-r--r--src/modules/objects/class_lineedit.cpp461
-rw-r--r--src/modules/objects/class_lineedit.h81
-rw-r--r--src/modules/objects/class_list.cpp392
-rw-r--r--src/modules/objects/class_list.h64
-rw-r--r--src/modules/objects/class_listbox.cpp390
-rw-r--r--src/modules/objects/class_listbox.h70
-rw-r--r--src/modules/objects/class_listview.cpp557
-rw-r--r--src/modules/objects/class_listview.h102
-rw-r--r--src/modules/objects/class_listviewitem.cpp421
-rw-r--r--src/modules/objects/class_listviewitem.h88
-rw-r--r--src/modules/objects/class_mainwindow.cpp158
-rw-r--r--src/modules/objects/class_mainwindow.h47
-rw-r--r--src/modules/objects/class_menubar.cpp76
-rw-r--r--src/modules/objects/class_menubar.h40
-rw-r--r--src/modules/objects/class_multilineedit.cpp1217
-rw-r--r--src/modules/objects/class_multilineedit.h110
-rw-r--r--src/modules/objects/class_painter.cpp1007
-rw-r--r--src/modules/objects/class_painter.h96
-rw-r--r--src/modules/objects/class_pixmap.cpp317
-rw-r--r--src/modules/objects/class_pixmap.h72
-rw-r--r--src/modules/objects/class_popupmenu.cpp361
-rw-r--r--src/modules/objects/class_popupmenu.h58
-rw-r--r--src/modules/objects/class_process.cpp317
-rw-r--r--src/modules/objects/class_process.h74
-rw-r--r--src/modules/objects/class_progressbar.cpp162
-rw-r--r--src/modules/objects/class_progressbar.h51
-rw-r--r--src/modules/objects/class_radiobutton.cpp138
-rw-r--r--src/modules/objects/class_radiobutton.h51
-rw-r--r--src/modules/objects/class_slider.cpp287
-rw-r--r--src/modules/objects/class_slider.h64
-rw-r--r--src/modules/objects/class_socket.cpp1331
-rw-r--r--src/modules/objects/class_socket.h185
-rw-r--r--src/modules/objects/class_spinbox.cpp265
-rw-r--r--src/modules/objects/class_spinbox.h64
-rw-r--r--src/modules/objects/class_tabwidget.cpp541
-rw-r--r--src/modules/objects/class_tabwidget.h61
-rw-r--r--src/modules/objects/class_tbrowser.cpp143
-rw-r--r--src/modules/objects/class_tbrowser.h52
-rw-r--r--src/modules/objects/class_toolbar.cpp156
-rw-r--r--src/modules/objects/class_toolbar.h50
-rw-r--r--src/modules/objects/class_toolbutton.cpp341
-rw-r--r--src/modules/objects/class_toolbutton.h69
-rw-r--r--src/modules/objects/class_urllabel.cpp330
-rw-r--r--src/modules/objects/class_urllabel.h64
-rw-r--r--src/modules/objects/class_vbox.cpp128
-rw-r--r--src/modules/objects/class_vbox.h45
-rw-r--r--src/modules/objects/class_widget.cpp1745
-rw-r--r--src/modules/objects/class_widget.h113
-rw-r--r--src/modules/objects/class_window.cpp158
-rw-r--r--src/modules/objects/class_window.h64
-rw-r--r--src/modules/objects/class_wizard.cpp371
-rw-r--r--src/modules/objects/class_wizard.h79
-rw-r--r--src/modules/objects/class_workspace.cpp262
-rw-r--r--src/modules/objects/class_workspace.h53
-rw-r--r--src/modules/objects/class_wrapper.cpp269
-rw-r--r--src/modules/objects/class_wrapper.h53
-rw-r--r--src/modules/objects/class_xmlreader.cpp343
-rw-r--r--src/modules/objects/class_xmlreader.h46
-rw-r--r--src/modules/objects/libkviobjects.cpp1066
-rw-r--r--src/modules/objects/object_macros.h90
85 files changed, 19685 insertions, 0 deletions
diff --git a/src/modules/objects/Makefile.am b/src/modules/objects/Makefile.am
new file mode 100644
index 00000000..c4574582
--- /dev/null
+++ b/src/modules/objects/Makefile.am
@@ -0,0 +1,143 @@
+###############################################################################
+# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <stefanek@tin.it>
+###############################################################################
+
+AM_CPPFLAGS = -I$(SS_TOPSRCDIR)/src/kvilib/include/ -I$(SS_TOPSRCDIR)/src/kvirc/include/ \
+$(SS_INCDIRS) $(SS_CPPFLAGS) -DGLOBAL_KVIRC_DIR=\"$(globalkvircdir)\"
+
+pluglib_LTLIBRARIES = libkviobjects.la
+
+libkviobjects_la_LDFLAGS = -module -avoid-version $(SS_LDFLAGS) $(SS_LIBDIRS)
+
+libkviobjects_la_SOURCES = libkviobjects.cpp \
+ class_button.cpp \
+ class_buttongroup.cpp \
+ class_checkbox.cpp \
+ class_combobox.cpp \
+ class_dialog.cpp \
+ class_dockwindow.cpp \
+ class_file.cpp \
+ class_groupbox.cpp \
+ class_label.cpp \
+ class_layout.cpp \
+ class_lcd.cpp \
+ class_lineedit.cpp \
+ class_list.cpp \
+ class_listbox.cpp \
+ class_listview.cpp \
+ class_listviewitem.cpp \
+ class_mainwindow.cpp \
+ class_menubar.cpp \
+ class_multilineedit.cpp \
+ class_popupmenu.cpp \
+ class_process.cpp \
+ class_progressbar.cpp \
+ class_radiobutton.cpp \
+ class_slider.cpp \
+ class_socket.cpp \
+ class_spinbox.cpp \
+ class_tabwidget.cpp \
+ class_toolbar.cpp \
+ class_toolbutton.cpp \
+ class_painter.cpp \
+ class_pixmap.cpp \
+ class_tbrowser.cpp \
+ class_widget.cpp \
+ class_window.cpp \
+ class_wizard.cpp \
+ class_workspace.cpp \
+ class_wrapper.cpp \
+ class_urllabel.cpp \
+ class_xmlreader.cpp \
+ class_vbox.cpp \
+ class_hbox.cpp
+
+
+libkviobjects_la_LIBADD = $(SS_LIBLINK) ../../kvilib/build/libkvilib.la
+
+noinst_HEADERS= class_button.h \
+ class_buttongroup.h \
+ class_checkbox.h \
+ class_combobox.h \
+ class_dialog.h \
+ class_dockwindow.h \
+ class_file.h \
+ class_groupbox.h \
+ class_label.h \
+ class_layout.h \
+ class_lcd.h \
+ class_lineedit.h \
+ class_list.h \
+ class_listbox.h \
+ class_listview.h \
+ class_listviewitem.h \
+ class_mainwindow.h \
+ class_menubar.h \
+ class_multilineedit.h \
+ class_painter.h \
+ class_pixmap.h \
+ class_popupmenu.h \
+ class_process.h \
+ class_progressbar.h \
+ class_radiobutton.h \
+ class_slider.h \
+ class_socket.h \
+ class_spinbox.h \
+ class_tabwidget.h \
+ class_tbrowser.h \
+ class_toolbar.h \
+ class_toolbutton.h \
+ class_urllabel.h \
+ class_widget.h \
+ class_window.h \
+ class_wizard.h \
+ class_workspace.h \
+ class_wrapper.h \
+ class_xmlreader.h \
+ class_vbox.h \
+ class_hbox.h \
+ object_macros.h
+
+m_%.moc: %.h
+ $(SS_QT_MOC) $< -o $@
+
+class_checkbox.cpp: m_class_checkbox.moc
+class_combobox.cpp: m_class_combobox.moc
+class_button.cpp: m_class_button.moc
+class_dialog.cpp: m_class_dialog.moc
+class_dockwindow.cpp: m_class_dockwindow.moc
+class_file.cpp: m_class_file.moc
+class_groupbox.cpp: m_class_groupbox.moc
+class_label.cpp: m_class_label.moc
+class_layout.cpp: m_class_layout.moc
+class_lcd.cpp: m_class_lcd.moc
+class_lineedit.cpp: m_class_lineedit.moc
+class_list.cpp: m_class_list.moc
+class_listbox.cpp: m_class_listbox.moc
+class_listview.cpp: m_class_listview.moc
+class_listviewitem.cpp: m_class_listviewitem.moc
+class_listbox.cpp: m_class_listbox.moc
+class_mainwindow.cpp: m_class_mainwindow.moc
+class_menubar.cpp: m_class_menubar.moc
+class_multilineedit.cpp: m_class_multilineedit.moc
+class_painter.cpp: m_class_painter.moc
+class_pixmap.cpp: m_class_pixmap.moc
+class_popupmenu.cpp: m_class_popupmenu.moc
+class_process.cpp: m_class_process.moc
+class_progressbar.cpp: m_class_progressbar.moc
+class_radiobutton.cpp: m_class_radiobutton.moc
+class_slider.cpp: m_class_slider.moc
+class_socket.cpp: m_class_socket.moc
+class_spinbox.cpp: m_class_spinbox.moc
+class_tabwidget.cpp: m_class_tabwidget.moc
+class_tbrowser.cpp: m_class_tbrowser.moc
+class_toolbar.cpp: m_class_toolbar.moc
+class_toolbutton.cpp: m_class_toolbutton.moc
+class_urllabel.cpp: m_class_urllabel.moc
+class_widget.cpp: m_class_widget.moc
+class_window.cpp: m_class_window.moc
+class_wizard.cpp: m_class_wizard.moc
+class_workspace.cpp: m_class_workspace.moc
+class_wrapper.cpp: m_class_wrapper.moc
+class_xmlreader.cpp: m_class_xmlreader.moc
+
diff --git a/src/modules/objects/class_button.cpp b/src/modules/objects/class_button.cpp
new file mode 100644
index 00000000..54d1525a
--- /dev/null
+++ b/src/modules/objects/class_button.cpp
@@ -0,0 +1,178 @@
+//
+// File : class_button.cpp
+// Creation date : Wed 13 Sep 2000 02:42:05 CEST by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "kvi_debug.h"
+
+
+#include "kvi_error.h"
+#include <qiconset.h>
+#include "kvi_iconmanager.h"
+
+#include "class_button.h"
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_button,"button","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"setText", functionSetText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"text", functionText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"setAutoDefault", functionSetAutoDefault)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"setToggleButton", functionSetToggleButton)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"setOn", functionSetOn)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"isOn", functionIsOn)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"toggle", functionToggle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"setIsMenuButton", functionSetIsMenuButton)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"isMenuButton", functionIsMenuButton)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"clickEvent", functionclickEvent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_button,"setImage", functionSetImage)
+
+
+KVSO_END_REGISTERCLASS(KviKvsObject_button)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_button,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_button)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_button)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_button)
+
+bool KviKvsObject_button::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QPushButton(parentScriptWidget(),name()),true);
+ connect(widget(),SIGNAL(clicked()),this,SLOT(slotClicked()));
+ return true;
+}
+
+bool KviKvsObject_button::functionText(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setString(((QPushButton *)widget())->text());
+ return true;
+}
+
+bool KviKvsObject_button::functionSetText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QPushButton *)widget())->setText(szText);
+ return true;
+}
+bool KviKvsObject_button::functionSetAutoDefault(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QPushButton *)widget())->setAutoDefault(bEnabled);
+ return true;
+}
+bool KviKvsObject_button::functionSetToggleButton(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QPushButton *)widget())->setToggleButton(bEnabled);
+ return true;
+}
+bool KviKvsObject_button::functionSetOn(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QPushButton *)widget())->setOn(bEnabled);
+ return true;
+}
+// FIX ME
+bool KviKvsObject_button::functionSetIsMenuButton(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ /*if(widget())
+ ((QPushButton *)widget())->setIsMenuButton(bEnabled);
+ */
+
+ return true;
+}
+bool KviKvsObject_button::functionIsMenuButton(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setBoolean(((QPushButton *)widget())->isMenuButton());
+ return true;
+}
+//
+bool KviKvsObject_button::functionIsOn(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setBoolean(((QPushButton *)widget())->isOn());
+ return true;
+}
+bool KviKvsObject_button::functionToggle(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) ((QPushButton *)widget())->toggle();
+ return true;
+}
+// FIX ME
+bool KviKvsObject_button::functionSetImage(KviKvsObjectFunctionCall *c)
+{
+ QString icon;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("icon",KVS_PT_STRING,0,icon)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ QPixmap * pix = g_pIconManager->getImage(icon);
+ if(pix){
+ #ifdef COMPILE_USE_QT4
+ ((QPushButton *)widget())->setIconSet(*pix);
+ #else
+ ((QPushButton *)widget())->setIconSet(QIconSet(*pix,QIconSet::Small));
+ #endif
+ }
+ else{
+ #ifdef COMPILE_USE_QT4
+ ((QPushButton *)widget())->setIcon(QIconSet());
+ #else
+ ((QPushButton *)widget())->setIconSet(QIconSet());
+ #endif
+ }
+ return true;
+}
+bool KviKvsObject_button::functionclickEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("clicked",c);
+ return true;
+}
+
+void KviKvsObject_button::slotClicked()
+{
+ KviKvsVariantList *params=0;
+ callFunction(this,"clickEvent",params);
+}
+
+
+#include "m_class_button.moc"
diff --git a/src/modules/objects/class_button.h b/src/modules/objects/class_button.h
new file mode 100644
index 00000000..5c752e48
--- /dev/null
+++ b/src/modules/objects/class_button.h
@@ -0,0 +1,58 @@
+#ifndef _CLASS_BUTTON_H_
+#define _CLASS_BUTTON_H_
+//
+// File : class_button.h
+// Creation date : Wed 13 Sep 2000 02:42:05 CEST by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qpushbutton.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_button : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_button)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionSetText(KviKvsObjectFunctionCall *c);
+ bool functionIsChecked(KviKvsObjectFunctionCall *c);
+ bool functionText(KviKvsObjectFunctionCall *c);
+ bool functionSetAutoDefault(KviKvsObjectFunctionCall *c);
+ bool functionSetToggleButton(KviKvsObjectFunctionCall *c);
+ bool functionSetOn(KviKvsObjectFunctionCall *c);
+ bool functionIsOn(KviKvsObjectFunctionCall *c);
+ bool functionToggle(KviKvsObjectFunctionCall *c);
+ bool functionSetIsMenuButton(KviKvsObjectFunctionCall *c);
+ bool functionIsMenuButton(KviKvsObjectFunctionCall *c);
+ bool functionSetImage(KviKvsObjectFunctionCall *c);
+ bool functionclickEvent(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void slotClicked();
+};
+
+#endif // !_CLASS_BUTTON_H_
diff --git a/src/modules/objects/class_buttongroup.cpp b/src/modules/objects/class_buttongroup.cpp
new file mode 100644
index 00000000..5f9f1756
--- /dev/null
+++ b/src/modules/objects/class_buttongroup.cpp
@@ -0,0 +1,87 @@
+//
+// File : class_buttongroup.cpp
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <qbuttongroup.h>
+#include "class_buttongroup.h"
+#include <qradiobutton.h>
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+
+/*
+ @doc: buttongroup
+ @keyterms:
+ buttongroup object class,
+ @title:
+ buttongroup class
+ @type:
+ class
+ @short:
+ Provides a buttongroup bar.
+ @inherits:
+ [class]groupbox[/class]
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This widget organizes buttons in a group.
+ It will be usually a parent for other child controls.
+ You can either use a child layout to manage the children geometries
+ or use $setColumnLayout function to manage the layout automatically.
+ The class ineriths groupbox.
+
+ @functions:
+
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_buttongroup,"buttongroup","groupbox")
+
+KVSO_END_REGISTERCLASS(KviKvsObject_buttongroup)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_buttongroup,KviKvsObject_groupbox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_buttongroup)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_buttongroup)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_buttongroup)
+
+// CHECK ME
+bool KviKvsObject_buttongroup::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ #ifdef COMPILE_USE_QT4
+ QButtonGroup *group=new QButtonGroup(parentScriptWidget());
+ group->setObjectName(name());
+ setObject(group,true);
+ #else
+ setObject(new QButtonGroup(name(),parentScriptWidget()), true);
+ #endif
+
+
+ return true;
+}
+
+
diff --git a/src/modules/objects/class_buttongroup.h b/src/modules/objects/class_buttongroup.h
new file mode 100644
index 00000000..472051ec
--- /dev/null
+++ b/src/modules/objects/class_buttongroup.h
@@ -0,0 +1,44 @@
+#ifndef _CLASS_BUTTONGROUP_H_
+#define _CLASS_BUTTONGROUP_H_
+//
+// File : class_buttongroup.h
+// Creation date : Jan 23 CEST 2007
+// by Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qbuttongroup.h>
+#include "class_groupbox.h"
+#include "object_macros.h"
+
+class KviKvsObject_buttongroup : public KviKvsObject_groupbox
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_buttongroup)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+
+};
+#endif //!_CLASS_GROUPBOX_H_
+
diff --git a/src/modules/objects/class_checkbox.cpp b/src/modules/objects/class_checkbox.cpp
new file mode 100644
index 00000000..a651adb8
--- /dev/null
+++ b/src/modules/objects/class_checkbox.cpp
@@ -0,0 +1,128 @@
+//vim: ts=8
+// File : class_checkbox.cpp
+// Creation date : Wed Sep 20 23:01:47 CEST 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_styled_controls.h"
+
+#include "class_checkbox.h"
+
+/*
+ @doc: checkbox
+ @title:
+ checkbox class
+ @type:
+ class
+ @short:
+ Check box with a text description
+ @inherits:
+ [class]object[/class]
+ [class]button[/class]
+ @description:
+ This widget provides a check box - it is a kind of a toggle
+ button. It can have two states: on (checked) and off
+ (unchecked).
+ @functions:
+ !fn: <bool> $isChecked()
+ Returns '1' if the check box is checked, '0' otherwise.[br]
+ See also [classfnc]$setChecked[/classfnc]().
+ !fn: $setChecked([<bChecked:bool>])
+ Sets the check box 'checked state' to <bool>.
+ !fn: $setText([<text:string>])
+ Sets the check box 'checked state' to <bool>.[br]
+ See also [classfnc]$isChecked[/classfnc]().
+ !fn: $toggleEvent(<bToggled:bool>)
+ Called by KVIrc when the checkbox state is toggled.
+ The default implementation emits the toggled(<bool>) signal.
+*/
+
+//---------------------------------------------------------------------------------
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_checkbox,"checkbox","button")
+ // appearance
+ KVSO_REGISTER_HANDLER(KviKvsObject_checkbox,"setChecked",function_setChecked)
+ KVSO_REGISTER_HANDLER(KviKvsObject_checkbox,"isChecked",function_isChecked)
+ KVSO_REGISTER_HANDLER(KviKvsObject_checkbox,"toggleEvent",function_toggleEvent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_checkbox,"setText",function_setText)
+KVSO_END_REGISTERCLASS(KviKvsObject_checkbox)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_checkbox,KviKvsObject_button)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_checkbox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_checkbox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_checkbox)
+
+bool KviKvsObject_checkbox::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ KviStyledCheckBox * cb = new KviStyledCheckBox(parentScriptWidget(), name());
+ setObject(cb, true);
+ connect(cb,SIGNAL(toggled(bool)),this,SLOT(toggled(bool)));
+ connect(widget(),SIGNAL(clicked()),this,SLOT(slotClicked()));
+ return true;
+}
+
+bool KviKvsObject_checkbox::function_isChecked(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setBoolean(((KviStyledCheckBox *)widget())->isChecked());
+ return true;
+}
+
+bool KviKvsObject_checkbox::function_setChecked(KviKvsObjectFunctionCall *c)
+{
+ bool bChecked;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bChecked",KVS_PT_BOOL,KVS_PF_OPTIONAL,bChecked)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((KviStyledCheckBox *)widget())->setChecked(bChecked);
+ return true;
+}
+
+bool KviKvsObject_checkbox::function_setText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((KviStyledCheckBox *)widget())->setText(szText);
+ return true;
+}
+
+bool KviKvsObject_checkbox::function_toggleEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("toggled",c,c->params());
+ return true;
+}
+
+void KviKvsObject_checkbox::toggled(bool b)
+{
+ KviKvsVariantList params(new KviKvsVariant(b));
+ callFunction(this,"toggleEvent",&params);
+}
+
+
+#include "m_class_checkbox.moc"
diff --git a/src/modules/objects/class_checkbox.h b/src/modules/objects/class_checkbox.h
new file mode 100644
index 00000000..1d19a432
--- /dev/null
+++ b/src/modules/objects/class_checkbox.h
@@ -0,0 +1,48 @@
+#ifndef _CLASS_CHECKBOX_H_
+#define _CLASS_CHECKBOX_H_
+
+//vim: ts=8
+// File : class_checkbox.h
+// Creation date : Wed Sep 20 23:02:11 CEST 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qcheckbox.h>
+#include "class_button.h"
+#include "object_macros.h"
+
+class KviKvsObject_checkbox : public KviKvsObject_button
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_checkbox)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+ bool function_setChecked(KviKvsObjectFunctionCall *c);
+ bool function_isChecked(KviKvsObjectFunctionCall *c);
+ bool function_toggleEvent(KviKvsObjectFunctionCall *c);
+ bool function_setText(KviKvsObjectFunctionCall *c);
+protected slots:
+ void toggled(bool b);
+};
+#endif // !_CLASS_CHECKBOX_H_
diff --git a/src/modules/objects/class_combobox.cpp b/src/modules/objects/class_combobox.cpp
new file mode 100644
index 00000000..9c8ffadf
--- /dev/null
+++ b/src/modules/objects/class_combobox.cpp
@@ -0,0 +1,368 @@
+//vim: ts=8
+// File : class_combobox.cpp
+// Creation date : Thu Mar 22 20:57:45 CET 2001 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "kvi_error.h"
+#include "kvi_locale.h"
+#include "kvi_debug.h"
+
+
+#include "class_list.h"
+#include "class_combobox.h"
+#include <qlineedit.h>
+#include <qstring.h>
+
+/*
+ @doc: combobox
+ @keyterms:
+ combobox object class, selection
+ @title:
+ combobox class
+ @type:
+ class
+ @short:
+ Combined button and popup list
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ @functions:
+ !fn: $insertItem(<text:string>, <index:int>)
+ Inserts a text item at position <index>. If index is negative or
+ not specified the item is appended.
+ !fn: $changeItem(<text:string>, <index:uint>)
+ Changes text of item at <index> to <text>.
+ !fn: $removeItem(<index:uint>)
+ Removes item at given index.
+ !fn: $setMaxCount(<num:uint>)
+ Sets the maximum number of items the combo box can hold to
+ <num>. If <num> is smaller than the current number of items,
+ the list is truncated at the end. There is no limit by default.
+ !fn: <integer> $maxCount()
+ Returns the current maximum number of items in the combo box.
+ !fn: <integer> $count()
+ Returns number of items in the widget.
+ !fn: <string> $current()
+ Returns currently selected item.
+ !fn: <integer> $currentItem()
+ Returns index of currently selected item.
+ !fn: $setEditable(<bflag:boolean>)
+ Make the input field editable, if <bflag>. Otherwise the
+ user may only choose one of the items in the combo box.[br]
+ If the parameter is ommited, it is assumed to be false.
+ !fn: <boolean> $editable()
+ Returns whether the combobox is editable or not.
+ !fn: $setEditText(<text:string>,[<quiet:bool>])
+ Sets the text in the embedded line edit to newText without
+ changing the combo's contents. Does nothing if the combo
+ isn't editable. If the optional quiet parameter is true no warning will be print if text will be empty.
+ !fn: $clear()
+ Removes all the items from the combo box
+ !fn: $textAt(<index:uint>)
+ Returns item at given index.
+ !fn: $setCurrentItem(<index:uint>)
+ Sets the current combobox item. This is the item to be
+ displayed on the combobox button.
+ !fn: $activatedEvent(<index:integer>)
+ This function is called by the framework when a new item has activated. The index value is the position of the new item.[br]
+ The default implementation emits the [classfnc]$activated[/classfnc]() signal,
+ !fn: $textChangedEvent(<text:string>)
+ This function is called when the text in an editable combobox has changed.[br]
+ The function return the new text in its argument.[br]
+ The default implementation emits the [classfnc]$textChanged[/classfnc]() signal.
+ @signals:
+ !sg: $textChanged()
+ This signal is emitted by the default implementation of [classfnc]$textChangedEvent[/classfnc]().
+ !sg: $activated()
+ This signal is emitted by the default implementation of [classfnc]$activatedEvent[/classfnc]().
+
+*/
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_combobox,"combobox","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"insertItem", functioninsertItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"changeItem", functionchangeItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"removeItem", functionremoveItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"clear", functionclear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"setMaxCount", functionsetMaxCount)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"maxCount", functionmaxCount)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"count", functioncount)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"current", functioncurrent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"currentItem", functioncurrentItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"setEditable", functionsetEditable);
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"editable", functioneditable)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"setEditText", functionsetEditText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"textAt", functiontextAt)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"textLineEdit", functiontextLineEdit)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"setTextLineEdit", functionsetTextLineEdit)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"setCurrentItem", functionsetCurrentItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"popup", functionpopup)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"setInsertionPolicy", functionsetInsertionPolicy)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"textChangedEvent", functiontextChangedEvent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_combobox,"activatedEvent", functionactivatedEvent)
+
+KVSO_END_REGISTERCLASS(KviKvsObject_combobox)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_combobox,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_combobox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_combobox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_combobox)
+
+bool KviKvsObject_combobox::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QComboBox(parentScriptWidget(), name()), true);
+ connect (((QComboBox *)widget()),SIGNAL(activated( int )),this,SLOT(slotActivated( int )));
+ return true;
+}
+
+bool KviKvsObject_combobox::functioninsertItem(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iIndex;
+ QString szItem;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("item",KVS_PT_STRING,0,szItem)
+ KVSO_PARAMETER("index",KVS_PT_INT,KVS_PF_OPTIONAL,iIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ if(c->paramCount()==1)
+ ((QComboBox *)widget())->insertItem(szItem);
+ else
+ ((QComboBox *)widget())->insertItem(szItem, iIndex);
+ return true;
+}
+bool KviKvsObject_combobox::functionclear(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) ((QComboBox *)widget())->clear();
+ return true;
+}
+bool KviKvsObject_combobox::functionchangeItem(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t uIndex,cnt;
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if (szText.isEmpty()) c->warning(__tr2qs("No string parameter given - using empty string"));
+ if(uIndex >= (cnt = ((QComboBox *)widget())->count()))
+ {
+ c->warning(__tr2qs("Item index [%d] is too big - defaulting to " \
+ "$count() - 1 [%d]"), uIndex, cnt);
+ uIndex = cnt - 1;
+ }
+
+ ((QComboBox *)widget())->changeItem(szText, uIndex);
+
+ return true;
+
+}
+bool KviKvsObject_combobox::functionremoveItem(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t uIndex,cnt;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(uIndex >= (cnt = ((QComboBox *)widget())->count()))
+ {
+ c->warning(__tr2qs("Item index [%d] is too big - defaulting to " \
+ "$count() - 1 [%d]"), uIndex, cnt);
+ uIndex = cnt - 1;
+ }
+
+ ((QComboBox *)widget())->removeItem(uIndex);
+
+ return true;
+
+}
+bool KviKvsObject_combobox::functionsetMaxCount(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t iMax;
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("count",KVS_PT_UNSIGNEDINTEGER,0,iMax)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QComboBox *)widget())->setMaxCount(iMax);
+ return true;
+}
+bool KviKvsObject_combobox::functionmaxCount(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QComboBox *)widget())->maxCount());
+ return true;
+}
+bool KviKvsObject_combobox::functioncount(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QComboBox *)widget())->count());
+ return true;
+}
+bool KviKvsObject_combobox::functioncurrent(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setString(((QComboBox *)widget())->currentText().local8Bit().data());
+ return true;
+}
+bool KviKvsObject_combobox::functioncurrentItem(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QComboBox *)widget())->currentItem());
+ return true;
+}
+bool KviKvsObject_combobox::functiontextLineEdit(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setString(((QComboBox *)widget())->lineEdit()->text());
+ return true;
+}
+
+bool KviKvsObject_combobox::functionsetEditable(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bflag",KVS_PT_BOOLEAN,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ {
+ ((QComboBox *)widget())->setEditable(bFlag);
+ if (bFlag) connect (((QComboBox *)widget())->lineEdit(),SIGNAL(textChanged(const QString & )),this,SLOT(slottextChanged(const QString & )));
+ else
+ disconnect (((QComboBox *)widget())->lineEdit(),SIGNAL(textChanged(const QString & )),this,SLOT(slottextChanged(const QString & )));
+ }
+
+ return true;
+}
+bool KviKvsObject_combobox::functionsetTextLineEdit(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QComboBox *)widget())->lineEdit()->setText(szText);
+ return true;
+}
+
+bool KviKvsObject_combobox::functioneditable(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((QComboBox *)widget())->editable());
+ return true;
+}
+bool KviKvsObject_combobox::functionsetEditText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ bool bQuiet=false;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETER("quiet",KVS_PT_BOOLEAN,KVS_PF_OPTIONAL,bQuiet)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if (szText.isEmpty() && !bQuiet) c->warning("No string parameter given - using empty string");
+ ((QComboBox *)widget())->setEditText(szText);
+ return true;
+}
+bool KviKvsObject_combobox::functiontextAt(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ c->returnValue()->setString(((QComboBox *)widget())->text(uIndex));
+ return true;
+}
+bool KviKvsObject_combobox::functionsetCurrentItem(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QComboBox *)widget())->setCurrentItem(uIndex);
+ return true;
+}
+bool KviKvsObject_combobox::functionpopup(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QComboBox *)widget())->popup();
+ return true;
+}
+bool KviKvsObject_combobox::functionsetInsertionPolicy(KviKvsObjectFunctionCall *c)
+{
+ QString szPolicy;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("policy",KVS_PT_STRING,0,szPolicy)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(KviQString::equalCI(szPolicy,"NoInsertion"))
+ ((QComboBox *)widget())->setInsertionPolicy(QComboBox::NoInsertion);
+ else if(KviQString::equalCI(szPolicy,"AtTop"))
+ ((QComboBox *)widget())->setInsertionPolicy(QComboBox::AtTop);
+ else if(KviQString::equalCI(szPolicy,"AtBotton"))
+ ((QComboBox *)widget())->setInsertionPolicy(QComboBox::AtBottom);
+ else if(KviQString::equalCI(szPolicy,"AtCurrent"))
+ ((QComboBox *)widget())->setInsertionPolicy(QComboBox::AtCurrent);
+ else if(KviQString::equalCI(szPolicy,"AfterCurrent"))
+ ((QComboBox *)widget())->setInsertionPolicy(QComboBox::AfterCurrent);
+ else if(KviQString::equalCI(szPolicy,"BeforeCurrent"))
+ ((QComboBox *)widget())->setInsertionPolicy(QComboBox::BeforeCurrent);
+ else c->warning(__tr2qs("Invalid insertion Policy %Q"),&szPolicy);
+ return true;
+}
+
+
+
+bool KviKvsObject_combobox::functiontextChangedEvent(KviKvsObjectFunctionCall *c)
+{
+
+ emitSignal("textChanged",c,c->params());
+ return true;
+
+}
+
+void KviKvsObject_combobox::slottextChanged(const QString &text)
+{
+ KviKvsVariantList params(new KviKvsVariant(text));
+ callFunction(this,"textChangedEvent",&params);
+}
+
+bool KviKvsObject_combobox::functionactivatedEvent(KviKvsObjectFunctionCall *c)
+{
+
+ emitSignal("activated",c,c->params());
+ return true;
+
+}
+
+void KviKvsObject_combobox::slotActivated(int i)
+{
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)i));
+ callFunction(this,"activatedEvent",&params);
+}
+
+
+#include "m_class_combobox.moc"
diff --git a/src/modules/objects/class_combobox.h b/src/modules/objects/class_combobox.h
new file mode 100644
index 00000000..d4da7c6b
--- /dev/null
+++ b/src/modules/objects/class_combobox.h
@@ -0,0 +1,71 @@
+#ifndef _CLASS_COMBOBOX_H_
+#define _CLASS_COMBOBOX_H_
+
+//vim: ts=8
+// File : class_combobox.h
+// Creation date : Thu Mar 22 20:57:28 CET 2001 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include <qcombobox.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_combobox : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_combobox)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functioninsertItem(KviKvsObjectFunctionCall *c);
+ bool functionchangeItem(KviKvsObjectFunctionCall *c);
+ bool functionremoveItem(KviKvsObjectFunctionCall *c);
+ bool functionclear(KviKvsObjectFunctionCall *c);
+//#warning "$insertPixItem"
+//#warning "$changePixItem"
+
+ bool functioncount(KviKvsObjectFunctionCall *c);
+ bool functionsetMaxCount(KviKvsObjectFunctionCall *c);
+ bool functionmaxCount(KviKvsObjectFunctionCall *c);
+ bool functioncurrent(KviKvsObjectFunctionCall *c);
+ bool functioncurrentItem(KviKvsObjectFunctionCall *c);
+ bool functionsetEditable(KviKvsObjectFunctionCall *c);
+ bool functioneditable(KviKvsObjectFunctionCall *c);
+ bool functionsetEditText(KviKvsObjectFunctionCall *c);
+ bool functiontextAt(KviKvsObjectFunctionCall *c);
+ bool functiontextLineEdit(KviKvsObjectFunctionCall *c);
+ bool functionsetTextLineEdit(KviKvsObjectFunctionCall *c);
+
+ bool functionsetInsertionPolicy(KviKvsObjectFunctionCall *c);
+
+ bool functionsetCurrentItem(KviKvsObjectFunctionCall *c);
+ bool functionpopup(KviKvsObjectFunctionCall *c);
+ bool functiontextChangedEvent(KviKvsObjectFunctionCall *c);
+ bool functionactivatedEvent(KviKvsObjectFunctionCall *c);
+protected slots:
+ void slottextChanged(const QString &);
+ void slotActivated(int);
+};
+
+#endif // !_CLASS_COMBOBOX_H_
diff --git a/src/modules/objects/class_dialog.cpp b/src/modules/objects/class_dialog.cpp
new file mode 100644
index 00000000..f062f004
--- /dev/null
+++ b/src/modules/objects/class_dialog.cpp
@@ -0,0 +1,89 @@
+//
+// File : class_dialog.cpp
+// Creation date : Sun Apr 10 22:51:48 CEST 2002 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_dialog.h"
+
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_frame.h"
+#include "kvi_app.h"
+
+#include <qdialog.h>
+
+
+/*
+ @doc: dialog
+ @title:
+ dialog class
+ @type:
+ class
+ @short:
+ A toplevel dialog object
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ Rappresents a dialog object. The class is really
+ similar to the widget class, it has only a couple of minor differences.
+ A dialog is always a top-level widget, but if it has a parent, its default
+ location is centered on top of the parent. It will also share the parent's taskbar entry.
+ If you call $setModal(1) then the dialog will have non-blocking modal behaviour:
+ it will appear above its parent widget and block its input until it's closed.
+ @functions:
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_dialog,"dialog","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_dialog,"setModal",functionSetModal)
+KVSO_END_REGISTERCLASS(KviKvsObject_dialog)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_dialog,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_dialog)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_dialog)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_dialog)
+
+bool KviKvsObject_dialog::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ QWidget * w = g_pApp->activeModalWidget();
+ if(!w)w = g_pFrame;
+ QDialog * d = new QDialog(parentScriptWidget() ? parentScriptWidget() : w,name());
+ //d->setModal(true);
+ setObject(d);
+ return true;
+}
+bool KviKvsObject_dialog::functionSetModal(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QDialog *)widget())->setModal(bEnabled);
+ return true;
+}
+
+
diff --git a/src/modules/objects/class_dialog.h b/src/modules/objects/class_dialog.h
new file mode 100644
index 00000000..b284baf3
--- /dev/null
+++ b/src/modules/objects/class_dialog.h
@@ -0,0 +1,44 @@
+#ifndef _CLASS_DIALOG_H_
+#define _CLASS_DIALOG_H_
+//
+// File : class_dialog.h
+// Creation date : Sun Apr 10 22:51:48 CEST 2002 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_widget.h"
+
+class QDialog;
+
+#include "object_macros.h"
+
+class KviKvsObject_dialog : public KviKvsObject_widget
+{
+
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_dialog)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+ bool functionSetModal(KviKvsObjectFunctionCall *c);
+};
+
+#endif // !_CLASS_DIALOG_H_
+
diff --git a/src/modules/objects/class_dockwindow.cpp b/src/modules/objects/class_dockwindow.cpp
new file mode 100644
index 00000000..fc439b23
--- /dev/null
+++ b/src/modules/objects/class_dockwindow.cpp
@@ -0,0 +1,276 @@
+//=============================================================================
+//
+// File : class_dockwindow.cpp
+// Created on Thu 29 Dec 2005 23:45:11 by Szymon Stefanek
+//
+// This file is part of the KVIrc IRC Client distribution
+// Copyright (C) 2005 Szymon Stefanek <pragma at kvirc dot net>
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "class_dockwindow.h"
+
+#include "kvi_frame.h"
+#include "kvi_locale.h"
+#include "kvi_qstring.h"
+#ifdef COMPILE_USE_QT4
+ #include <QDockWidget>
+ #define QT_DOCK_WINDOW QDockWidget
+#else
+ #include <qdockwindow.h>
+ #define QT_DOCK_WINDOW QDockWindow
+#endif
+#include <qlayout.h>
+
+/*
+ @doc: dockwindow
+ @title:
+ dockwindow class
+ @type:
+ class
+ @short:
+ A window dockable to the KVIrc main frame
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ A window dockable to the KVIrc main frame borders (like a toolbar).
+ The window has an implicit layout that will automatically manage
+ the children depending on the dock window's orientation.
+ @functions:
+ !fn: $addWidget(<widget:hobject>)
+ Adds <widget> to the internal layout of this dock window.[br]
+ The widget must be a child of this dock window (otherwise strange things may happen).
+ !fn: <string> $orientation()
+ Returns the string "vertical" or "horizontal" depending on the orientation of this dock window.
+ !fn: $setOrientation(<orientation:string>)
+ Forces the orentation of this dock window. <ordientation> must be either "horizontal" or "vertical".[br]
+ Please note that KVIrc sets the orientation automatically when it is moved between the main frame docks by the user.
+ !fn: <bool> $resizeEnabled()
+ Returns $true if resizing of this window is enabled and false otherwise.
+ !fn: $setResizeEnabled(<bEnabled:bool>)
+ Enabled or disabled resizing of this window.
+ !fn: $setAllowedDockAreas(<docks:string>)
+ Sets the allowed main window dock areas for this dock window.[br]
+ <docks> must be a combination of "l","r","t","b","f" and "m".[br]
+ "l" stands for left dock area, "r" stands for right dock area, "t" stands for the top dock areas, "b" stands for the bottom dock area, "f" stands for "floating" and "m" for "minimized".[br]
+ If a flag is present then the related block area is enabled,otherwise it is disabled.
+ !fn: $dock(<dockarea:string>)
+ Docks this dock window to the specified dockarea of the main KVIrc window which can be one of "l" (left dock area), "t" (top dock area), "r" (right dock area), "b" (bottom dock area), "f" (floating) and "m" (minimized).
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_dockwindow,"dockwindow","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_dockwindow,"addWidget",function_addWidget)
+ KVSO_REGISTER_HANDLER(KviKvsObject_dockwindow,"orientation",function_orientation)
+ KVSO_REGISTER_HANDLER(KviKvsObject_dockwindow,"setOrientation",function_setOrientation)
+ KVSO_REGISTER_HANDLER(KviKvsObject_dockwindow,"resizeEnabled",function_resizeEnabled)
+ KVSO_REGISTER_HANDLER(KviKvsObject_dockwindow,"setResizeEnabled",function_setResizeEnabled)
+ KVSO_REGISTER_HANDLER(KviKvsObject_dockwindow,"setAllowedDockAreas",function_setAllowedDockAreas)
+ KVSO_REGISTER_HANDLER(KviKvsObject_dockwindow,"dock",function_dock)
+KVSO_END_REGISTERCLASS(KviKvsObject_dockwindow)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_dockwindow,KviKvsObject_widget)
+KVSO_END_CONSTRUCTOR(KviKvsObject_dockwindow)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_dockwindow)
+KVSO_END_DESTRUCTOR(KviKvsObject_dockwindow)
+
+#define _pDockWindow ((QT_DOCK_WINDOW *)widget())
+
+bool KviKvsObject_dockwindow::init(KviKvsRunTimeContext * pContext,KviKvsVariantList * pParams)
+{
+#ifdef COMPILE_USE_QT4
+ QDockWidget * pWidget = new QDockWidget(g_pFrame);
+ pWidget->setObjectName(getName());
+ setObject(pWidget);
+#else //!COMPILE_USE_QT4
+ setObject(new QT_DOCK_WINDOW(g_pFrame,getName()),true);
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+
+bool KviKvsObject_dockwindow::function_addWidget(KviKvsObjectFunctionCall *c)
+{
+ kvs_hobject_t hWidget;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hWidget)
+ KVSO_PARAMETERS_END(c)
+
+ if(!widget())return true; // hum ? dead ?
+
+ if(hWidget == (kvs_hobject_t)0)
+ {
+ // null widget ?
+ c->warning(__tr2qs("Can't add a null object"));
+ return true;
+ }
+
+ KviKvsObject * pWidget = KviKvsKernel::instance()->objectController()->lookupObject(hWidget);
+ if(!pWidget)
+ {
+ c->warning(__tr2qs("Invalid object handle passed as parameter (the object is no longer existing ?)"));
+ return true;
+ }
+
+ if(!pWidget->object())
+ {
+ c->warning(__tr2qs("Object in invalid state"));
+ return true;
+ }
+
+ if(!pWidget->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't set a non-widget object to be the main widget of a dock window"));
+ return true;
+ }
+
+ if(((QWidget *)(pWidget->object()))->parent() != (QObject *)_pDockWindow)
+ {
+ c->warning(__tr2qs("The added widget is not a child of this dock window"));
+ }
+
+#ifdef COMPILE_USE_QT4
+ _pDockWindow->setWidget((QWidget *)(pWidget->object()));
+#else //!COMPILE_USE_QT4
+ _pDockWindow->boxLayout()->addWidget((QWidget *)(pWidget->object()));
+ ((QWidget *)(pWidget->object()))->show();
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+
+bool KviKvsObject_dockwindow::function_orientation(KviKvsObjectFunctionCall * c)
+{
+ if(!widget())return true; // hum ? dead ?
+#ifdef COMPILE_USE_QT4
+ c->returnValue()->setString(QString("horizontal"));
+#else //!COMPILE_USE_QT4
+ c->returnValue()->setString(_pDockWindow->orientation() == Qt::Horizontal ? QString("horizontal") : QString("vertical"));
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+
+bool KviKvsObject_dockwindow::function_setOrientation(KviKvsObjectFunctionCall * c)
+{
+ QString szOrientation;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("orientation",KVS_PT_NONEMPTYSTRING,0,szOrientation)
+ KVSO_PARAMETERS_END(c)
+
+ if(!widget())return true; // hum ? dead ?
+#ifndef COMPILE_USE_QT4
+ _pDockWindow->setOrientation(KviQString::equalCI(szOrientation,"vertical") ? Qt::Vertical : Qt::Horizontal);
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+
+bool KviKvsObject_dockwindow::function_resizeEnabled(KviKvsObjectFunctionCall * c)
+{
+ if(!widget())return true; // hum ? dead ?
+#ifdef COMPILE_USE_QT4
+ c->returnValue()->setBoolean(false);
+#else //!COMPILE_USE_QT4
+ c->returnValue()->setBoolean(_pDockWindow->isResizeEnabled());
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+
+bool KviKvsObject_dockwindow::function_setResizeEnabled(KviKvsObjectFunctionCall * c)
+{
+ bool bResizeEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bResizeEnabled)
+ KVSO_PARAMETERS_END(c)
+
+ if(!widget())return true; // hum ? dead ?
+
+#ifndef COMPILE_USE_QT4
+ _pDockWindow->setResizeEnabled(bResizeEnabled);
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+
+bool KviKvsObject_dockwindow::function_setAllowedDockAreas(KviKvsObjectFunctionCall * c)
+{
+ QString szFlags;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("docks",KVS_PT_STRING,0,szFlags)
+ KVSO_PARAMETERS_END(c)
+
+ if(!widget())return true; // hum ? dead ?
+
+#ifdef COMPILE_USE_QT4
+ Qt::DockWidgetAreas fAreas = Qt::NoDockWidgetArea;
+ if(szFlags.find('t',false))fAreas |= Qt::TopDockWidgetArea;
+ if(szFlags.find('l',false))fAreas |= Qt::LeftDockWidgetArea;
+ if(szFlags.find('r',false))fAreas |= Qt::RightDockWidgetArea;
+ if(szFlags.find('b',false))fAreas |= Qt::BottomDockWidgetArea;
+ _pDockWindow->setAllowedAreas(fAreas);
+ QDockWidget::DockWidgetFeatures fFeatures = _pDockWindow->features();
+ if(szFlags.find('f',false))
+ fFeatures |= QDockWidget::DockWidgetFloatable;
+ else
+ fFeatures &= ~QDockWidget::DockWidgetFloatable;
+ // no support for minimized dock widgets
+ _pDockWindow->setFeatures(fFeatures);
+#else //!COMPILE_USE_QT4
+ g_pFrame->setDockEnabled(_pDockWindow,Qt::DockTop,szFlags.find('t',false) != -1);
+ g_pFrame->setDockEnabled(_pDockWindow,Qt::DockLeft,szFlags.find('l',false) != -1);
+ g_pFrame->setDockEnabled(_pDockWindow,Qt::DockRight,szFlags.find('r',false) != -1);
+ g_pFrame->setDockEnabled(_pDockWindow,Qt::DockBottom,szFlags.find('b',false) != -1);
+ g_pFrame->setDockEnabled(_pDockWindow,Qt::DockTornOff,szFlags.find('f',false) != -1);
+ g_pFrame->setDockEnabled(_pDockWindow,Qt::DockMinimized,szFlags.find('m',false) != -1);
+#endif //!COMPILE_USE_QT4
+
+ return true;
+}
+
+
+bool KviKvsObject_dockwindow::function_dock(KviKvsObjectFunctionCall * c)
+{
+ QString szDock;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("dock",KVS_PT_STRING,0,szDock)
+ KVSO_PARAMETERS_END(c)
+
+ if(!widget())return true; // hum ? dead ?
+#ifdef COMPILE_USE_QT4
+ g_pFrame->removeDockWidget(_pDockWindow);
+ if(szDock.find('m',false) == -1)_pDockWindow->setFloating(false);
+ if(szDock.find('t',false) != -1)g_pFrame->addDockWidget(Qt::TopDockWidgetArea,_pDockWindow);
+ else if(szDock.find('l',false) != -1)g_pFrame->addDockWidget(Qt::LeftDockWidgetArea,_pDockWindow);
+ else if(szDock.find('r',false) != -1)g_pFrame->addDockWidget(Qt::RightDockWidgetArea,_pDockWindow);
+ else if(szDock.find('b',false) != -1)g_pFrame->addDockWidget(Qt::BottomDockWidgetArea,_pDockWindow);
+ else if(szDock.find('f',false) != -1)_pDockWindow->setFloating(true);
+ else if(szDock.find('m',false) != -1)qDebug("Sorry: no support for minimized dock widgets in Qt4");
+ else c->warning(__tr2qs("Invalid dock area specified"));
+
+#else //!COMPILE_USE_QT4
+ if(szDock.find('t',false) != -1)g_pFrame->moveDockWindow(_pDockWindow,Qt::DockTop,false,100);
+ else if(szDock.find('l',false) != -1)g_pFrame->moveDockWindow(_pDockWindow,Qt::DockLeft,false,100);
+ else if(szDock.find('r',false) != -1)g_pFrame->moveDockWindow(_pDockWindow,Qt::DockRight,false,100);
+ else if(szDock.find('b',false) != -1)g_pFrame->moveDockWindow(_pDockWindow,Qt::DockBottom,false,100);
+ else if(szDock.find('f',false) != -1)g_pFrame->moveDockWindow(_pDockWindow,Qt::DockTornOff,false,100);
+ else if(szDock.find('m',false) != -1)g_pFrame->moveDockWindow(_pDockWindow,Qt::DockMinimized,false,100);
+ else c->warning(__tr2qs("Invalid dock area specified"));
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+
+#include "m_class_dockwindow.moc"
diff --git a/src/modules/objects/class_dockwindow.h b/src/modules/objects/class_dockwindow.h
new file mode 100644
index 00000000..4576a43d
--- /dev/null
+++ b/src/modules/objects/class_dockwindow.h
@@ -0,0 +1,49 @@
+#ifndef _CLASS_DOCKWINDOW_H_
+#define _CLASS_DOCKWINDOW_H_
+//=============================================================================
+//
+// File : class_dockwindow.h
+// Created on Thu 29 Dec 2005 23:45:11 by Szymon Stefanek
+//
+// This file is part of the KVIrc IRC Client distribution
+// Copyright (C) 2005 Szymon Stefanek <pragma at kvirc dot net>
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "kvi_settings.h"
+#include "object_macros.h"
+
+#include "class_widget.h"
+
+class KviKvsObject_dockwindow : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_dockwindow)
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool function_addWidget(KviKvsObjectFunctionCall *c);
+ bool function_orientation(KviKvsObjectFunctionCall *c);
+ bool function_setOrientation(KviKvsObjectFunctionCall *c);
+ bool function_resizeEnabled(KviKvsObjectFunctionCall *c);
+ bool function_setResizeEnabled(KviKvsObjectFunctionCall * c);
+ bool function_setAllowedDockAreas(KviKvsObjectFunctionCall * c);
+ bool function_dock(KviKvsObjectFunctionCall * c);
+};
+
+#endif //!_CLASS_DOCKWINDOW_H_
diff --git a/src/modules/objects/class_file.cpp b/src/modules/objects/class_file.cpp
new file mode 100644
index 00000000..3429278e
--- /dev/null
+++ b/src/modules/objects/class_file.cpp
@@ -0,0 +1,488 @@
+//vim: ts=8
+// File : class_file.cpp
+// Creation date : Thu Sep 21 04:42:16 CEST 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+//#warning "Add QFILEINFO to this stuff ?"
+
+#include "class_file.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_error.h"
+#include "kvi_fileutils.h"
+#include <qstringlist.h>
+
+
+// needed for $open()
+const char * const mod_tbl[] = {
+ "Raw",
+ "ReadOnly",
+ "WriteOnly",
+ "ReadWrite",
+ "Append",
+ "Truncate"
+ };
+#ifdef COMPILE_USE_QT4
+#define IO_RAW QIODevice::Unbuffered
+#define IO_READONLY QIODevice::ReadOnly
+#define IO_WRITEONLY QIODevice::WriteOnly
+#define IO_READWRITE QIODevice::ReadWrite
+#define IO_APPEND QIODevice::Append
+#define IO_TRUNCATE QIODevice::Truncate
+//#define IO_TRANSLATE QIODevice::Text
+#else
+#define IO_RAW IO_Raw
+#define IO_READONLY IO_ReadOnly
+#define IO_WRITEONLY IO_WriteOnly
+#define IO_READWRITE IO_ReadWrite
+#define IO_APPEND IO_Append
+#define IO_TRUNCATE IO_Truncate
+#endif
+#ifdef COMPILE_USE_QT4
+const QIODevice::OpenMode mod_cod[] = {
+#else
+const int mod_cod[] = {
+#endif
+ IO_RAW,
+ IO_READONLY,
+ IO_WRITEONLY,
+ IO_READWRITE,
+ IO_APPEND,
+ IO_TRUNCATE
+ };
+
+#define mod_num (sizeof(mod_tbl) / sizeof(mod_tbl[0]))
+
+/*
+ @doc: file
+ @keyterms:
+ file object class, creating files
+ @title:
+ file class
+ @type:
+ class
+ @short:
+ I/O device that operates on files
+ @inherits:
+ [class]object[/class]
+ @description:
+ This object class provides access to files - basic I/O
+ operations, copying, removing etc...
+ @functions:
+ !fn: $setName(<file_name:string>)
+ Sets the file name to <file_name>. It does [b]not move[/b] the file,
+ it just changes the file the object is "pointing to". You can
+ not change names of already open files.[br]
+ See also: [classfnc]$open[/classfnc](),
+ [classfnc]$name[/classfnc]().
+ !fn: <string> $name()
+ Returns name set by [classfnc]$setName[/classfnc]().[br]
+ See also: [classfnc]$setName[/classfnc]().
+ !fn: $open(<mode1:string>, <mode2:string>)
+ Attempts to open the file in specified mode or modes "sum".
+ Valid modes are:[br]
+ [pre]
+ Raw - raw, non-buffered access[br]
+ ReadOnly - opens the file read-only[br]
+ WriteOnly - opens the file write-only[br]
+ ReadWrite - opens the file in read-write mode[br]
+ Append - opens the file in append mode. The file index is set to the end of the file.[br]
+ Truncate - truncates the file[br]
+ [/pre]
+ If you call this function without any parameters, the file is
+ opened in ReadOnly mode.[br]
+ When working with buffered files, data is not written directly
+ to the file at once. You must call [classfnc]$flush[/classfnc]() to force it.[br]
+ See also: [classfnc]$close[/classfnc](),
+ [classfnc]$flush[/classfnc]().
+ !fn: <boolean> $isOpen()
+ Returns '1' if the file is open, '0' otherwise.
+ !fn: $close()
+ Closes the file, flushing the buffers first.[br]
+ See also: [classfnc]$flush[/classfnc]().
+ !fn: $flush()
+ Flushes the file buffer to disk. Calling this after opening the
+ file in 'Raw' mode doesn't make much sense.[br]
+ See also: [classfnc]$open[/classfnc](),
+ [classfnc]$close[/classfnc]().
+ !fn: <integer> $size()
+ Returns current file size.
+ !fn: <boolean> $atEnd()
+ Returns '1' if you have reached end of the file, '0' otherwise.
+ [br]See also: [classfnc]$seek[/classfnc](),
+ [classfnc]$where[/classfnc]().
+ !fn: <integer> $where()
+ Returns current position in the file (file index).[br]
+ See also: [classfnc]$seek[/classfnc]().
+ !fn: $seek(<index:integer>)
+ Sets the file index to <index>.[br]
+ See also: [classfnc]$where[/classfnc](),
+ [classfnc]$atEnd[/classfnc]().
+ !fn: $putch(<char>)
+ Writes character <char> to the file and increments file
+ index.[br]
+ See also: [classfnc]$getch[/classfnc](),
+ [classfnc]$ungetch[/classfnc]().
+ !fn: <char> $getch()
+ Reads a character from the file and increments file index.[br]
+ See also: [classfnc]$putch[/classfnc](),
+ [classfnc]$ungetch[/classfnc]().
+ !fn: $ungetch(<char>)
+ Puts the character <char> back to the file and
+ decrements the file index. This is usually called to undo a
+ $getch() call.[br]
+ See also: [classfnc]$getch[/classfnc],
+ [classfnc]$putch[/classfnc]().
+ !fn: $readLine(<text_line:string>)
+ Reads a line of text from the file and increments file index.
+ !fn: $writeLine(<text_line:string>)
+ Appends a line of text to the end of the file.
+ $readBlock()
+ $writeBlock()
+ $writeHex()
+ $readHex()
+*/
+
+
+//---------------------------------------------------------------------------------
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_file,"file","object")
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"setName", functionsetName)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"name", functionname)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"open", functionopen)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"isOpen", functionisOpen)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"close", functionclose)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"flush", functionflush)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"size", functionsize)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"atEnd", functionatEnd)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"where", functionwhere)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"seek", functionseek)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"putch", functionputch)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"getch", functiongetch)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"ungetch", functionunGetch)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"readBlock", functionreadBlock)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"writeBlock", functionwriteBlock)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"readLine", functionreadLine)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"writeLine", functionwriteLine)
+/* KVSO_REGISTER_HANDLER(KviKvsObject_file,"hexWrite", functionHexWrite)
+ KVSO_REGISTER_HANDLER(KviKvsObject_file,"hexRead", functionHexRead)
+*/
+ KVSO_END_REGISTERCLASS(KviKvsObject_file)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_file,KviKvsObject)
+ m_pFile = new QFile();
+KVSO_END_CONSTRUCTOR(KviKvsObject_file)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_file)
+if (m_pFile) delete m_pFile;
+m_pFile=0;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_file)
+
+
+bool KviKvsObject_file::functionsetName(KviKvsObjectFunctionCall *c)
+{
+ QString szName;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("file_name",KVS_PT_STRING,0,szName)
+ KVSO_PARAMETERS_END(c)
+ if (m_pFile) m_pFile->setName(szName);
+ return true;
+}
+bool KviKvsObject_file::functionname(KviKvsObjectFunctionCall *c)
+{
+ if (m_pFile) c->returnValue()->setString(m_pFile->name());
+ return true;
+}
+
+bool KviKvsObject_file::functionopen(KviKvsObjectFunctionCall *c)
+{
+ QStringList modes;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("file_mode",KVS_PT_STRINGLIST,KVS_PF_OPTIONAL,modes)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pFile) return true;
+ if(m_pFile->name().isEmpty())
+ {
+ c->warning(__tr2qs("Empty filename string"));
+ return true;
+ }
+ #ifdef COMPILE_USE_QT4
+ QIODevice::OpenMode mod,sum;
+ if (modes.empty()) sum = IO_READONLY; // if no parameters given, default to ReadWrite | Append
+ else
+ {
+ for ( int idx=0;idx<modes.count();idx++)
+ {
+ mod = IO_ReadOnly;
+ for(unsigned int j = 0; j < mod_num; j++)
+ {
+ if(KviQString::equalCI(modes.at(idx), mod_tbl[j]))
+ {
+ mod=mod_cod[j];
+ break;
+ }
+ }
+ if(mod!=IO_ReadOnly)
+ sum = sum | mod;
+ else
+ c->warning(__tr2qs("No such open mode: '%Q'"),&modes.at(idx));
+ }
+ }
+#else
+ int mod,sum=0;
+if (!modes.first()) sum = IO_READONLY; // if no parameters given, default to ReadWrite | Append
+ else
+ {
+ for ( QStringList::Iterator it = modes.begin(); it != modes.end(); ++it )
+ {
+
+ mod = 0;
+ for(unsigned int j = 0; j < mod_num; j++)
+ {
+ if(KviQString::equalCI((*it), mod_tbl[j]))
+ {
+ mod=mod_cod[j];
+ break;
+ }
+ }
+ if(mod)
+ sum = sum | mod;
+ else
+ c->warning(__tr2qs("No such open mode: '%Q'"),&(*it));
+ }
+ }
+#endif
+ m_pFile->open(sum);
+ return true;
+}
+
+bool KviKvsObject_file::functionisOpen(KviKvsObjectFunctionCall *c)
+{
+ if (m_pFile) c->returnValue()->setBoolean(m_pFile->isOpen());
+ return true;
+}
+
+bool KviKvsObject_file::functionclose(KviKvsObjectFunctionCall *c)
+{
+ if (!m_pFile->isOpen()) c->warning(__tr2qs("File is not open!"));
+ else m_pFile->close();
+ return true;
+}
+bool KviKvsObject_file::functionflush(KviKvsObjectFunctionCall *c)
+{
+ if (!m_pFile->isOpen()) c->warning(__tr2qs("File is not open!"));
+ else m_pFile->flush();
+ return true;
+}
+
+bool KviKvsObject_file::functionsize(KviKvsObjectFunctionCall *c)
+{
+ if (m_pFile) c->returnValue()->setInteger((kvs_int_t)(m_pFile->size()));
+ return true;
+}
+bool KviKvsObject_file::functionatEnd(KviKvsObjectFunctionCall *c)
+{
+ if (m_pFile) c->returnValue()->setInteger((kvs_int_t)(m_pFile->size()));
+ return true;
+}
+
+
+bool KviKvsObject_file::functionwhere(KviKvsObjectFunctionCall *c)
+{
+ if (!m_pFile->isOpen()) c->warning(__tr2qs("File is not open!"));
+ else c->returnValue()->setInteger((kvs_int_t)(m_pFile->at()));
+ return true;
+}
+bool KviKvsObject_file::functionseek(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pFile) return true;
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+ else m_pFile->at(uIndex);
+ return true;
+}
+
+bool KviKvsObject_file::functionputch(KviKvsObjectFunctionCall *c)
+{
+ QString szChar;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("char",KVS_PT_STRING,KVS_PF_OPTIONAL,szChar)
+ KVSO_PARAMETERS_END(c)
+ if (m_pFile)
+ {
+ if (szChar.length()>1)c->warning(__tr2qs("Argument to long, using only first char"));
+ const char *ch=szChar;
+ if (m_pFile->putch(ch[0])<0) c->warning(__tr2qs("Write error occured !"));
+ }
+
+ return true;
+}
+bool KviKvsObject_file::functiongetch(KviKvsObjectFunctionCall *c)
+{
+ if (!m_pFile) return true;
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+ else
+ {
+ int chInt=m_pFile->getch();
+ if (chInt<0) c->warning(__tr("Read error occured !")); // c->error ?
+ QString szChar = QChar(chInt);
+ c->returnValue()->setString(szChar);
+ }
+ return true;
+}
+bool KviKvsObject_file::functionunGetch(KviKvsObjectFunctionCall *c)
+{
+ QString szChar;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("char",KVS_PT_STRING,0,szChar)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pFile) return true;
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+ else
+ {
+ if (szChar.length()>1) c->warning(__tr2qs("Argument to long, using only first char"));
+ const char *ch=szChar;
+ if (m_pFile->ungetch(ch[0])<0) c->warning(__tr2qs("An error occured !"));// c->error ?
+ }
+ return true;
+}
+bool KviKvsObject_file::functionreadBlock(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uLen;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("lenght",KVS_PT_UNSIGNEDINTEGER,0,uLen)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pFile) return true;
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+ else
+ {
+ char * buff = new char[uLen + 1];
+ m_pFile->flush(); // advice from QFile man page (to avoid trash)
+ int rlen = m_pFile->readBlock(buff, uLen);
+ buff[rlen] = '\0';
+ QString szBlock(buff);
+ c->returnValue()->setString(szBlock);
+ }
+ return true;
+}
+
+bool KviKvsObject_file::functionwriteBlock(KviKvsObjectFunctionCall *c)
+{
+ QString szBlock;
+ kvs_uint_t uLen;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("lenght",KVS_PT_UNSIGNEDINTEGER,0,uLen)
+ KVSO_PARAMETER("text_block",KVS_PT_STRING,0,szBlock)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pFile) return true;
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+ const char *block=szBlock;
+ int rlen = m_pFile->writeBlock(block, uLen);
+ c->returnValue()->setInteger(rlen);
+ m_pFile->flush();
+ return true;
+}
+bool KviKvsObject_file::functionreadLine(KviKvsObjectFunctionCall *c)
+{
+ if (!m_pFile) return true;
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+ else
+ {
+ QString buffer;
+ KviFileUtils::readLine(m_pFile,buffer);
+ c->returnValue()->setString(buffer);
+ }
+ return true;
+}
+bool KviKvsObject_file::functionwriteLine(KviKvsObjectFunctionCall *c)
+{
+ QString szLine;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text_line",KVS_PT_STRING,0,szLine)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pFile) return true;
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+ else
+ {
+ QTextStream ts(m_pFile);
+ ts << szLine;
+ }
+ return true;
+}
+// fixme
+/*
+
+bool KviScriptFileObject::functionHexWrite(KviCommand * c, KviParameterList * p,
+ KviStr & b)
+{
+ ENTER_STACK_FRAME(c, "file::hexWrite");
+ if(!p->count())
+ return c->error(KviError_notEnoughParameters);
+
+ char * val = 0;
+ int len = p->first()->hexToBuffer(&val,false);
+
+ if(len < 1)
+ {
+ c->warning(__tr("Nothing to write"));
+ return c->leaveStackFrame();
+ }
+
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+
+ if(m_pFile->putch(*val) < 0)
+ c->warning(__tr("Write error occured !")); // c->error ?
+
+ KviStr::freeBuffer(val);
+
+ return c->leaveStackFrame();
+}
+
+bool KviScriptFileObject::functionHexRead(KviCommand * c, KviParameterList * p,
+ KviStr & b)
+{
+ if(!m_pFile->isOpen())
+ c->warning(__tr("File is not open !"));
+
+ char ch = m_pFile->getch();
+
+ KviStr tmp;
+ tmp.bufferToHex(&ch, 1);
+ b.append(tmp);
+
+ return true;
+}
+
+*/
+#include "m_class_file.moc"
diff --git a/src/modules/objects/class_file.h b/src/modules/objects/class_file.h
new file mode 100644
index 00000000..01a54d19
--- /dev/null
+++ b/src/modules/objects/class_file.h
@@ -0,0 +1,113 @@
+#ifndef _CLASS_FILE_H_
+#define _CLASS_FILE_H_
+//vim: ts=8
+// File : class_file.h
+// Creation date : Thu Sep 21 04:43:01 CEST 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qfile.h>
+#include <qtextstream.h>
+#include "kvi_string.h"
+
+
+/*
+//class KviCommand;
+class KviParameterList;
+
+class KviScriptFileObject : public KviScriptObject
+{
+ Q_OBJECT
+public:
+ KviScriptFileObject(KviScriptObjectClass *, KviScriptObject *, const char *);
+ virtual ~KviScriptFileObject();
+
+ static void registerSelf();
+ static void unregisterSelf();
+
+protected:
+ bool functionSetName(KviCommand *, KviParameterList *, KviStr &);
+ bool functionName(KviCommand *, KviParameterList *, KviStr &);
+ bool functionOpen(KviCommand *, KviParameterList *, KviStr &);
+ bool functionIsOpen(KviCommand *, KviParameterList *, KviStr &);
+ bool functionClose(KviCommand *, KviParameterList *, KviStr &);
+ bool functionFlush(KviCommand *, KviParameterList *, KviStr &);
+ bool functionSize(KviCommand *, KviParameterList *, KviStr &);
+
+ bool functionAtEnd(KviCommand *, KviParameterList *, KviStr &);
+ // int QFile at() const
+ bool functionWhere(KviCommand *, KviParameterList *, KviStr &);
+ // void QFile at(int)
+ bool functionSeek(KviCommand *, KviParameterList *, KviStr &);
+ bool functionPutch(KviCommand *, KviParameterList *, KviStr &);
+ bool functionGetch(KviCommand *, KviParameterList *, KviStr &);
+ bool functionUngetch(KviCommand *, KviParameterList *, KviStr &);
+
+ bool functionReadBlock(KviCommand *, KviParameterList *, KviStr &);
+ bool functionWriteBlock(KviCommand *, KviParameterList *, KviStr &);
+
+ bool functionReadLine(KviCommand *, KviParameterList *, KviStr &);
+ bool functionWriteLine(KviCommand *, KviParameterList *, KviStr &);
+ bool functionHexWrite(KviCommand *, KviParameterList *, KviStr &);
+ bool functionHexRead(KviCommand *, KviParameterList *, KviStr &);
+
+protected:
+ QFile * m_pFile;
+};
+
+*/
+
+#include "object_macros.h"
+
+class KviKvsObject_file : public KviKvsObject
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_file)
+protected:
+ bool functionsetName(KviKvsObjectFunctionCall *c);
+ bool functionname(KviKvsObjectFunctionCall *c);
+ bool functionopen(KviKvsObjectFunctionCall *c);
+ bool functionisOpen(KviKvsObjectFunctionCall *c);
+ bool functionclose(KviKvsObjectFunctionCall *c);
+ bool functionflush(KviKvsObjectFunctionCall *c);
+ bool functionsize(KviKvsObjectFunctionCall *c);
+
+ bool functionatEnd(KviKvsObjectFunctionCall *c);
+ // int QFile at() const
+ bool functionwhere(KviKvsObjectFunctionCall *c);
+ // void QFile at(int)
+ bool functionseek(KviKvsObjectFunctionCall *c);
+ bool functionputch(KviKvsObjectFunctionCall *c);
+ bool functiongetch(KviKvsObjectFunctionCall *c);
+ bool functionunGetch(KviKvsObjectFunctionCall *c);
+
+ bool functionreadBlock(KviKvsObjectFunctionCall *c);
+ bool functionwriteBlock(KviKvsObjectFunctionCall *c);
+
+ bool functionreadLine(KviKvsObjectFunctionCall *c);
+ bool functionwriteLine(KviKvsObjectFunctionCall *c);
+/* bool functionHexWrite(KviKvsObjectFunctionCall *c);
+ bool functionHexRead(KviKvsObjectFunctionCall *c);
+*/
+protected:
+ QFile * m_pFile;
+};
+#endif // !_CLASS_FILE_H_
diff --git a/src/modules/objects/class_groupbox.cpp b/src/modules/objects/class_groupbox.cpp
new file mode 100644
index 00000000..14e640d1
--- /dev/null
+++ b/src/modules/objects/class_groupbox.cpp
@@ -0,0 +1,376 @@
+//
+// File : class_groupbox.cpp
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <kvi_tal_groupbox.h>
+#include "class_groupbox.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+// Tables used in $setAlignment , $alignment and in $setOrientation & $orientation
+
+const char * const align_tbl[] = {
+ "Left",
+ "Right",
+ "HCenter"
+ };
+const int align_cod[] = {
+ Qt::AlignLeft,
+ Qt::AlignRight,
+ Qt::AlignHCenter
+ };
+#define align_num (sizeof(align_tbl) / sizeof(align_tbl[0]))
+
+
+/*
+ @doc: groupbox
+ @keyterms:
+ groupbox object class,
+ @title:
+ groupbox class
+ @type:
+ class
+ @short:
+ Provides a groupbox bar.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This widget can be used to display a groupbox.
+ It will be usually a parent for other child controls.
+ You can either use a child layout to manage the children geometries
+ or use $setColumnLayout to manage the layout automatically.
+ @functions:
+ !fn: $setTitle(<text:String>)
+ Sets the group box title to <text>.
+ !fn: <string> $title()
+ Returns the group box title text.
+ !fn: $setFlat(<bflag:boolean>)
+ Sets whether the group box is painted flat. Valid Values are 1 or 0.
+ !fn: <boolean> $isFlat()
+ Returns 1 (TRUE) if the group box is painted flat; otherwise returns 0 (FALSE).
+ !fn: <boolean> $isCheckable()
+ Returns 1 (TRUE) if the group box has a checkbox in its title; otherwise returns 0 (FALSE).
+ !fn: $setCheckable(<bflag:boolean>)
+ Sets whether the group box has a checkbox in its title: Valid values are 1 or 0.
+ !fn: $setInsideMargin(<margin:uint>)
+ Sets the the width of the inside margin to m pixels.
+ !fn: <integer> $insideMargin()
+ Returns the width of the empty space between the items in the group and margin of groupbox.
+ !fn: $setInsideSpacing(<spacing:uint>)
+ Sets the width of the empty space between each of the items in the group to m pixels.
+ !fn: <integer> $insideSpacing()
+ Returns the width of the empty space between each of the items in the group.
+ !fn: $setColumns(<columns:uint>)
+ Sets the number of columns or rows (depending of the orientation) in the group box.
+ !fn: <integer> $columns()
+ Returns the number of columns or rows in the groupbox.
+ !fn: $addSpace()
+ Adds an empty cell at the next free position.
+ !fn: <string> $alignment()
+ Returns the alignment of the group box title.
+ !fn: $setAlignment(<alignment:string>)
+ Set the alignment of the groupbox; Valid values are Left,Right,HCenter.
+ !fn: $setOrientation<orientation:string>
+ Sets the group box's orientation. Valid values are: Horizontal, Vertical.
+ !fn: $setColumnLayout(<columns:integer>,<orientation:string>)
+ Enables the automatic layout management. The children are arranged in n columns with the specified orientation.[br]
+ Valid values for <orientation> are: Horizontal, Vertical.
+ @examples:
+ [example]
+ |-Start:[br]
+ #Let's start.[br]
+ #first we'll create the main widget.[br]
+ %widget=$new(widget)[br]
+ [br]
+ #then the groupbox [br]
+ %gb=$new(groupbox,%widget)[br]
+ %gb->$setTitle(Login)[br]
+ %gb->$setAlignment("Left")[br]
+ [br]
+ #now we create the labels and lineedits.[br]
+ %labeluser=$new(label,%gb)[br]
+ %labeluser->$settext(User: )[br]
+ %labelpass=$new(label,%gb)[br]
+ %labelpass->$settext(Pass: )[br]
+ %inputuser=$new(lineedit,%gb)[br]
+ %inputpass=$new(lineedit,%gb)[br]
+ %inputpass->$setechomode("password")[br]
+ [br]
+ #now lets' layouting the groupbox's element's.[br]
+ %layoutgb=$new(layout,%gb)[br]
+ %layoutgb->$setmargin(20)[br]
+ %layoutgb->$addwidget(%labeluser,0,0)[br]
+ %layoutgb->$addwidget(%labelpass,1,0)[br]
+ %layoutgb->$addwidget(%inputuser,0,1)[br]
+ %layoutgb->$addwidget(%inputpass,1,1)[br]
+ [br]
+ # now we create a fake widget and managing the two buttons layout.[br]
+ %fakewidget=$new(widget,%widget)[br]
+ %layoutbtn=$new(layout,%fakewidget)[br]
+ %btnok=$new(button,%fakewidget)[br]
+ %btnok->$settext("OK")[br]
+ %btncancel=$new(button,%fakewidget)[br]
+ %btncancel->$settext("Cancel")[br]
+ %layoutbtn->$addwidget(%btnok,0,0)[br]
+ %layoutbtn->$addwidget(%btncancel,0,1)[br]
+ [br]
+ #And finally we create a main layout with the groupbox (and its "children")[br]
+ #and fakewiget (with its buttons children).
+ %mainlayout=$new(layout,%widget)[br]
+ %mainlayout->$setspacing(10)[br]
+ %mainlayout->$setmargin(10)[br]
+ %mainlayout->$addwidget(%gb,0,0)[br]
+ %mainlayout->$addwidget(%fakewidget,1,0)[br]
+ [br]
+ #Let's show our nice login request =D ! [br]
+ %widget->$show()[br]
+ [/example]
+
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_groupbox,"groupbox","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setTitle", functionSetTitle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"title", functionTitle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setFlat", functionSetFlat)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"isFlat", functionIsFlat)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setCheckable", functionSetCheckable)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"isCheckable", functionIsCheckable)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setInsideMargin", functionSetInsideMargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"insideMargin", functionInsideMargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setInsideSpacing", functionSetInsideSpacing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"insideSpacing", functionInsideSpacing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setColumns", functionSetColumns)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"columns", functionColumns)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"addSpace", functionAddSpace)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"alignment", functionAlignment)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setAlignment", functionSetAlignment)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setOrientation", functionSetOrientation)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"isChecked", functionIsChecked)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setChecked", functionSetChecked)
+ KVSO_REGISTER_HANDLER(KviKvsObject_groupbox,"setColumnLayout",functionSetColumnLayout)
+KVSO_END_REGISTERCLASS(KviKvsObject_groupbox)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_groupbox,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_groupbox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_groupbox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_groupbox)
+
+bool KviKvsObject_groupbox::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+#ifdef COMPILE_USE_QT4
+ KviTalGroupBox *groupbox=new KviTalGroupBox(name(),parentScriptWidget());
+ groupbox->setObjectName(name());
+ setObject(groupbox,true);
+#else
+ setObject(new KviTalGroupBox(name(),parentScriptWidget()), true);
+#endif
+ return true;
+}
+
+bool KviKvsObject_groupbox::functionSetTitle(KviKvsObjectFunctionCall *c)
+{
+ QString szTitle;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("title",KVS_PT_STRING,0,szTitle)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalGroupBox *)widget())->setTitle(szTitle);
+ return true;
+}
+bool KviKvsObject_groupbox::functionTitle(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setString(((KviTalGroupBox *)widget())->title());
+ return true;
+}
+bool KviKvsObject_groupbox::functionSetFlat(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalGroupBox *)widget())->setFlat(bEnabled);
+ return true;
+}
+bool KviKvsObject_groupbox::functionIsFlat(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isFlat());
+ return true;
+}
+bool KviKvsObject_groupbox::functionSetCheckable(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalGroupBox *)widget())->setCheckable(bEnabled);
+ return true;
+}
+bool KviKvsObject_groupbox::functionIsCheckable(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isCheckable());
+ return true;
+}
+bool KviKvsObject_groupbox::functionSetChecked(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalGroupBox *)widget())->setChecked(bEnabled);
+ return true;
+}
+bool KviKvsObject_groupbox::functionIsChecked(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isChecked());
+ return true;
+}
+bool KviKvsObject_groupbox::functionSetInsideMargin(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uMargin;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,uMargin)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalGroupBox *)widget())->setInsideMargin(uMargin);
+ return true;
+}
+bool KviKvsObject_groupbox::functionInsideMargin(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((KviTalGroupBox *)widget())->insideMargin());
+ return true;
+}
+bool KviKvsObject_groupbox::functionSetInsideSpacing(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uSpacing;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalGroupBox *)widget())->setInsideSpacing(uSpacing);
+ return true;
+}
+bool KviKvsObject_groupbox::functionInsideSpacing(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((KviTalGroupBox *)widget())->insideSpacing());
+ return true;
+}
+bool KviKvsObject_groupbox::functionSetColumns(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uColums;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("colums",KVS_PT_UNSIGNEDINTEGER,0,uColums)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalGroupBox *)widget())->setColumns(uColums);
+ return true;
+}
+bool KviKvsObject_groupbox::functionColumns(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((KviTalGroupBox *)widget())->columns());
+ return true;
+}
+bool KviKvsObject_groupbox::functionAddSpace(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t iSpace;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("colums",KVS_PT_UNSIGNEDINTEGER,0,iSpace)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) (((KviTalGroupBox *)widget())->addSpace(iSpace));
+ return true;
+}
+
+bool KviKvsObject_groupbox::functionSetAlignment(KviKvsObjectFunctionCall *c)
+{
+ QString szAlign;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("alignment",KVS_PT_STRING,0,szAlign)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ for(unsigned int i = 0; i < align_num; i++)
+ {
+ if(KviQString::equalCI(szAlign, align_tbl[i]))
+ {
+ ((KviTalGroupBox *)widget())->setAlignment(align_cod[i]);
+ return true;
+ }
+ }
+ c->warning(__tr2qs("Unknown alignment"));
+ return true;
+}
+bool KviKvsObject_groupbox::functionAlignment(KviKvsObjectFunctionCall *c)
+{
+ int mode = ((KviTalGroupBox *)widget())->alignment();
+ QString szAlignment="";
+ for(unsigned int i = 0; i < align_num; i++)
+ {
+ if(mode == align_cod[i])
+ {
+ szAlignment=align_tbl[i];
+ break;
+ }
+ }
+ c->returnValue()->setString(szAlignment);
+ return true;
+}
+
+bool KviKvsObject_groupbox::functionSetOrientation(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("orientation",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szMode, "Horizontal"))
+ ((KviTalGroupBox *)widget())->setOrientation(Qt::Horizontal);
+ else
+ if(KviQString::equalCI(szMode, "Vertical"))
+ ((KviTalGroupBox *)widget())->setOrientation(Qt::Vertical);
+ else c->warning( __tr2qs("Unknown orientation: "));
+ return true;
+}
+
+bool KviKvsObject_groupbox::functionSetColumnLayout(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ kvs_uint_t uCol;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("columns",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("orientation",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(szMode=="Horizontal")
+ ((KviTalGroupBox *)widget())->setColumnLayout(uCol,Qt::Horizontal);
+ else
+ if(szMode=="Vertical")
+ ((KviTalGroupBox *)widget())->setColumnLayout(uCol,Qt::Vertical);
+ else c->warning( __tr2qs("Unknown orientation: "));
+ return true;
+}
+
diff --git a/src/modules/objects/class_groupbox.h b/src/modules/objects/class_groupbox.h
new file mode 100644
index 00000000..c63bb46b
--- /dev/null
+++ b/src/modules/objects/class_groupbox.h
@@ -0,0 +1,64 @@
+#ifndef _CLASS_GROUPBOX_H_
+#define _CLASS_GROUPBOX_H_
+//
+// File : class_groupbox.h
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <kvi_tal_groupbox.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_groupbox : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_groupbox)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+
+ bool functionSetTitle(KviKvsObjectFunctionCall *c);
+ bool functionTitle(KviKvsObjectFunctionCall *c);
+ bool functionSetFlat(KviKvsObjectFunctionCall *c);
+ bool functionIsFlat(KviKvsObjectFunctionCall *c);
+ bool functionSetCheckable(KviKvsObjectFunctionCall *c);
+ bool functionIsCheckable(KviKvsObjectFunctionCall *c);
+ bool functionSetInsideMargin(KviKvsObjectFunctionCall *c);
+ bool functionInsideMargin(KviKvsObjectFunctionCall *c);
+ bool functionSetInsideSpacing(KviKvsObjectFunctionCall *c);
+ bool functionInsideSpacing(KviKvsObjectFunctionCall *c);
+ bool functionSetColumns(KviKvsObjectFunctionCall *c);
+ bool functionColumns(KviKvsObjectFunctionCall *c);
+ bool functionAddSpace(KviKvsObjectFunctionCall *c);
+ bool functionAlignment(KviKvsObjectFunctionCall *c);
+ bool functionSetAlignment(KviKvsObjectFunctionCall *c);
+ bool functionSetOrientation(KviKvsObjectFunctionCall *c);
+ bool functionIsChecked(KviKvsObjectFunctionCall *c);
+ bool functionSetChecked(KviKvsObjectFunctionCall *c);
+ bool functionSetColumnLayout(KviKvsObjectFunctionCall *c);
+
+};
+#endif //!_CLASS_GROUPBOX_H_
+
diff --git a/src/modules/objects/class_hbox.cpp b/src/modules/objects/class_hbox.cpp
new file mode 100644
index 00000000..48174312
--- /dev/null
+++ b/src/modules/objects/class_hbox.cpp
@@ -0,0 +1,128 @@
+//
+// File : class_hbox.cpp
+// Creation date : Wed Mar 01 2005 23:00:01 by Alessandro Carbone & Tonino Imbesi
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002-2006 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#define _KVI_DEBUG_CHECK_RANGE_
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+
+#include "class_hbox.h"
+
+/*
+ @doc: hbox
+ @keyterms:
+ hbox object class, child widgets
+ @title:
+ hbox class
+ @type:
+ class
+ @short:
+ Manages child widget horizontal geometry
+ @inherits:
+ [class]object[/class]
+ @description:
+ The hbox class widget provides horizontal geometry management for its child widgets.
+ @functions:
+ !fn: $setSpacing(<spacing:uint>)
+ Sets the default spacing of the widgets in pixels
+ !fn: $setMargin(<margin:uint>)
+ Sets the dimension of the layout margin : the distance from the border to the outermost child widget edges.
+ !fn: $setStretchFactor(<widget:hobject>,<stretch:uint>)
+ Sets the stretch factor of widget to stretch.
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_hbox,"hbox","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_hbox,"setMargin", functionsetMargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_hbox,"setSpacing", functionsetSpacing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_hbox,"setStretchFactor", functionsetStretchFactor )
+KVSO_END_REGISTERCLASS(KviKvsObject_hbox)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_hbox,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_hbox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_hbox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_hbox)
+
+bool KviKvsObject_hbox::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+
+ setObject(new KviTalHBox(parentScriptWidget()), true);
+ return true;
+}
+bool KviKvsObject_hbox::functionsetMargin(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uMargin;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,uMargin)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalHBox *)widget())->setMargin(uMargin);
+ return true;
+}
+
+bool KviKvsObject_hbox::functionsetSpacing(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uSpacing;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalHBox *)widget())->setSpacing(uSpacing);
+ return true;
+}
+bool KviKvsObject_hbox::functionsetStretchFactor(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject * pObject;
+ kvs_hobject_t hObject;
+ kvs_uint_t uStretch;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("stretch",KVS_PT_UNSIGNEDINTEGER,0,uStretch)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!pObject->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!pObject->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ if(((KviKvsObject_widget *)pObject)->widget()->parentWidget() != widget())
+ {
+ c->warning(__tr2qs("The widget must be a child of this hbox"));
+ return true;
+ }
+ ((KviTalHBox *)widget())->setStretchFactor(((QWidget *)(pObject->object())),uStretch);
+ return true;
+}
+
+
diff --git a/src/modules/objects/class_hbox.h b/src/modules/objects/class_hbox.h
new file mode 100644
index 00000000..c0489f28
--- /dev/null
+++ b/src/modules/objects/class_hbox.h
@@ -0,0 +1,47 @@
+#ifndef _CLASS_HBOX_H_
+#define _CLASS_HBOX_H_
+//
+// File : class_hbox.h
+// Creation date : Wed Mar 01 2005 23:00:01 by Alessandro Carbone & Tonino Imbesi
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002-2006 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include "kvi_string.h"
+
+#include "kvi_tal_hbox.h"
+#include "object_macros.h"
+#include "class_widget.h"
+
+class KviKvsObject_hbox : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_hbox)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionsetMargin(KviKvsObjectFunctionCall *c);
+ bool functionsetSpacing(KviKvsObjectFunctionCall *c);
+ bool functionsetStretchFactor(KviKvsObjectFunctionCall *c);
+
+
+};
+
+
+#endif //_CLASS_HBOX_H_
diff --git a/src/modules/objects/class_label.cpp b/src/modules/objects/class_label.cpp
new file mode 100644
index 00000000..9c629818
--- /dev/null
+++ b/src/modules/objects/class_label.cpp
@@ -0,0 +1,409 @@
+//vim: ts=8
+// File : class_label.cpp
+// Creation date : Mon Sep 18 14:21:48 CEST 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Krzysztof Godlewski
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <qfont.h>
+#include <qpixmap.h>
+#include <qmessagebox.h>
+#include "class_label.h"
+//#include "kvi_fileutils.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+
+
+// Tables used in $setAlignment & $alignment
+const char * const align_tbl[] = {
+ "Left",
+ "Right",
+ "HCenter",
+ "VCenter",
+ "Center",
+ "Top",
+ "Bottom",
+ "WordBreak"
+ };
+#ifdef COMPILE_USE_QT4
+ #define QT_LABEL_ALIGNLEFT Qt::AlignLeft
+ #define QT_LABEL_ALIGNRIGHT Qt::AlignRight
+ #define QT_LABEL_ALIGNHCENTER Qt::AlignHCenter
+ #define QT_LABEL_ALIGNVCENTER Qt::AlignVCenter
+ #define QT_LABEL_ALIGNCENTER Qt::AlignCenter
+ #define QT_LABEL_ALIGNTOP Qt::AlignTop
+ #define QT_LABEL_ALIGNBOTTOM Qt::AlignBottom
+ #define QT_LABEL_JUSTIFY Qt::AlignJustify
+#else
+ #define QT_LABEL_ALIGNLEFT QLabel::AlignLeft
+ #define QT_LABEL_ALIGNRIGHT QLabel::AlignRight
+ #define QT_LABEL_ALIGNHCENTER QLabel::AlignHCenter
+ #define QT_LABEL_ALIGNVCENTER QLabel::AlignVCenter
+ #define QT_LABEL_ALIGNCENTER QLabel::AlignCenter
+ #define QT_LABEL_ALIGNTOP QLabel::AlignTop
+ #define QT_LABEL_ALIGNBOTTOM QLabel::AlignBottom
+ #define QT_LABEL_JUSTIFY QLabel::WordBreak
+#endif
+
+const int align_cod[] = {
+ QT_LABEL_ALIGNLEFT,
+ QT_LABEL_ALIGNRIGHT,
+ QT_LABEL_ALIGNHCENTER,
+ QT_LABEL_ALIGNVCENTER,
+ QT_LABEL_ALIGNCENTER,
+ QT_LABEL_ALIGNTOP,
+ QT_LABEL_ALIGNBOTTOM,
+ QT_LABEL_JUSTIFY,
+ };
+
+#define align_num (sizeof(align_tbl) / sizeof(align_tbl[0]))
+
+// used in $frameStyle & $setFrameStyle
+const char * const frame_tbl[] = {
+ "NoFrame",
+ "Box",
+ "Panel",
+ "WinPanel",
+ "Hline",
+ // shadow styles
+ "Plain",
+ "Raised",
+ "Sunken"
+ };
+
+const int frame_cod[] = {
+ QFrame::NoFrame,
+ QFrame::Box,
+ QFrame::Panel,
+ QFrame::WinPanel,
+ QFrame::HLine,
+ QFrame::Plain,
+ QFrame::Raised,
+ QFrame::Sunken
+ };
+
+#define frame_num (sizeof(frame_tbl) / sizeof(frame_tbl[0]))
+
+
+/*
+ @doc: label
+ @keyterms:
+ label object class, show image
+ @title:
+ label class
+ @type:
+ class
+ @short:
+ Displays text or an image
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This widget can be used to display a text or an image. It can
+ have different frame styles and text/image alignment.
+ @functions:
+ !fn: $setText(<text:string>)
+ Sets the text to be displayed by the label.
+ The text can contain limited html tags.
+ See also [classfnc]$text[/classfnc]().
+ !fn: <string> $text()
+ Returns the text currently displayed by the label.
+ See also [classfnc]$setText[/classfnc]().
+ !fn: <integer> $margin()
+ Returns current value of margin for this label (default is 0).
+ See also [classfnc]$setMargin[/classfnc]().
+ !fn: $setMargin(<margin:uint>)
+ Sets margin width / height to <margin>.
+ See also [classfnc]$margin[/classfnc]().
+ !fn: <boolean> $autoResize()
+ Returns 1, if auto-resize ability of the label is enabled.
+ See also [classfnc]$setAutoResize[/classfnc]().
+ !fn: $setAutoResize(<benabled:boolean>)
+ Sets auto-resize ability to enabled (if <benabled> is 1) or disabled
+ (if <benabled> is 0). If auto-resize is enabled, the label will
+ automagically resize itself accordingly to the 'size' of the
+ text it contains.
+ See also [classfnc]$autoResize[/classfnc]().
+ !fn: <string> $alignment()
+ Returns a string containing alignment flags that are set for
+ this label. The flags are separated by commas. An example output
+ could look like this:[br]
+ [pre]Bottom, Right[/pre][br]
+ See [classfnc]$setAlignment[/classfnc]() for explanation of all
+ alignment flags.
+ !fn: $setAlignment(<flag1:string>, <flag2:string>, ...)
+ This function sets alignment flags, given as parameters, for
+ this label. Valid flags are:
+ [pre]
+ Right - Text is aligned to right border[br]
+ Left - Text is aligned to left border[br]
+ Top - Text is aligned to the top border[br]
+ Bottom - Text is aligned to the bottom border[br]
+ HCenter - Text is horizontally centered[br]
+ VCenter - Text is vertically centered[br]
+ Center - Equals HCenter + VCenter[br]
+ WordBreak - Enables automatic word breaking[br]
+ [/pre]
+ It is obvious that you can not set for example [i]Right[/i]
+ and [i]Left[/i] simoultaneously - this will [b]NOT[/b]
+ result in an error message - this will simply not work :)
+ !fn: $clear()
+ Clears the label. Equal to calling
+ [classfnc]$setText[/classfnc]("")
+ !fn: $frameStyle()
+ Returns a string containing this label's frame-style flags,
+ separated with commas. Output from this function could look like
+ this:
+ [pre]Panel, Raised[/pre]
+ See [classfnc]$setFrameStyle[/classfnc]() for a list of all
+ frame-style flags and their explenation.
+ !fn: $setFrameStyle(<flag1>, <flag2>, ...)
+ Sets the frame-style flags to the ones passed as arguments.
+ The flags can either decide of the shape or shadow of the
+ label's frame. Valid shape flags are:[br]
+ [pre]
+ NoFrame - draw no frame. You shouldn't specify a shadow when
+ using this.[br]
+ Box - draws a rectangular box. Its borders can be
+ [i]Raised[/i] or [i]Sunken[/i][br]
+ Panel - draws a rectangular panel which can be
+ [i]Raised[/i] or [i]Sunken[/i][br]
+ WinPanel - similar to [i]Panel[/i], but is more in Win95
+ style[br]
+ Hline - draws a horizontal line that frames nothing (useful as separator)
+ [/pre]
+ Valid shadow flags are:[br]
+ [pre]
+ Plain - no 3D effect (draws using foreground color)[br]
+ Raised - makes the label look like it was raised above the
+ parent widget[br]
+ Sunken - makes the label look like it was "pushed" inside
+ the parent widget[br]
+ [/pre]
+ !fn: $setImage(<image_id>)
+ Sets the image to be displayed on this label.
+ Giving empty argument clears the pixmap[br]
+ See the [doc:image_id]image identifier[/doc] documentation for
+ the explaination of the <image_id> parameter.
+
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_label,"label","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"setText",functionSetText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"text", functionText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"margin", functionMargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"setMargin", functionSetMargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"autoResize", functionAutoResize)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"setAutoResize", functionSetAutoResize)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"alignment", functionAlignment)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"setAlignment", functionSetAlignment)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"clear", functionClear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"frameStyle", functionFrameStyle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"setFrameStyle", functionSetFrameStyle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_label,"setImage", functionSetImage)
+KVSO_END_REGISTERCLASS(KviKvsObject_label)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_label,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_label)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_label)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_label)
+
+bool KviKvsObject_label::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QLabel(parentScriptWidget(), name()), true);
+ return true;
+}
+
+bool KviKvsObject_label::functionSetText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QLabel *)widget())->setText(szText);
+ return true;
+}
+bool KviKvsObject_label::functionText(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setString(((QLabel *)widget())->text());
+ return true;
+}
+
+bool KviKvsObject_label::functionSetMargin(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t iMargin;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,iMargin)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QLabel *)widget())->setMargin(iMargin);
+ return true;
+}
+bool KviKvsObject_label::functionMargin(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QLabel *)widget())->margin());
+ return true;
+}
+
+// FIX ME
+bool KviKvsObject_label::functionSetAutoResize(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ #ifdef COMPILE_USE_QT4
+ return true;
+ #else
+ if(widget())
+ ((QLabel *)widget())->setAutoResize(bEnabled);
+ return true;
+ #endif
+}
+bool KviKvsObject_label::functionAutoResize(KviKvsObjectFunctionCall *c)
+{
+ #ifdef COMPILE_USE_QT4
+ if (widget()) c->returnValue()->setBoolean(true);
+ #else
+ if (widget()) c->returnValue()->setBoolean(((QLabel *)widget())->autoResize());
+ #endif
+ return true;
+}
+//
+bool KviKvsObject_label::functionSetAlignment(KviKvsObjectFunctionCall *c)
+{
+ QStringList alignment;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("alignment",KVS_PT_STRINGLIST,KVS_PF_OPTIONAL,alignment)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ int align,sum=0;
+ for ( QStringList::Iterator it = alignment.begin(); it != alignment.end(); ++it )
+ {
+
+ align = 0;
+ for(unsigned int j = 0; j < align_num; j++)
+ {
+ if(KviQString::equalCI((*it), align_tbl[j]))
+ {
+ align=align_cod[j];
+ break;
+ }
+ }
+ if(align)
+ sum = sum | align;
+ else
+ c->warning(__tr2qs("Unknown alignment: '%Q'"),&(*it));
+
+ }
+ ((QLabel *)widget())->setAlignment(sum);
+ return true;
+}
+bool KviKvsObject_label::functionAlignment(KviKvsObjectFunctionCall *c)
+{
+ int mode = ((QLabel *)widget())->alignment();
+ QString szAlignment="";
+ for(unsigned int i = 0; i < align_num; i++)
+ {
+ if(mode == align_cod[i])
+ {
+ szAlignment=align_tbl[i];
+ break;
+ }
+ }
+ c->returnValue()->setString(szAlignment);
+ return true;
+}
+bool KviKvsObject_label::functionClear(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QLabel *)widget())->clear();
+ return true;
+}
+
+
+bool KviKvsObject_label::functionSetFrameStyle(KviKvsObjectFunctionCall *c)
+{
+
+ QStringList style;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("style",KVS_PT_STRINGLIST,KVS_PF_OPTIONAL,style)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ int framestyle,sum=0;
+ for ( QStringList::Iterator it = style.begin(); it != style.end(); ++it )
+ {
+ framestyle = 0;
+ for(unsigned int j = 0; j < align_num; j++)
+ {
+ if(KviQString::equalCI((*it), frame_tbl[j]))
+ {
+ framestyle=frame_cod[j];
+ break;
+ }
+ }
+ if(framestyle)
+ sum = sum | framestyle;
+ else
+ c->warning(__tr2qs("Unknown style: '%Q'"),&(*it));
+
+ }
+ ((QLabel *)widget())->setFrameStyle(sum);
+ return true;
+
+
+
+
+}
+bool KviKvsObject_label::functionFrameStyle(KviKvsObjectFunctionCall *c)
+{
+ int mode = ((QLabel *)widget())->frameStyle();
+ QString szStyle="";
+ for(unsigned int i = 0; i < frame_num; i++)
+ {
+ if(mode == frame_cod[i])
+ {
+ szStyle=frame_tbl[i];
+ break;
+ }
+ }
+ c->returnValue()->setString(szStyle);
+ return true;
+}
+bool KviKvsObject_label::functionSetImage(KviKvsObjectFunctionCall *c)
+{
+
+ QString icon;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("icon",KVS_PT_STRING,0,icon)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ QPixmap * pix = g_pIconManager->getImage(icon);
+ if(pix) ((QLabel *)widget())->setPixmap(*pix);
+ return true;
+}
diff --git a/src/modules/objects/class_label.h b/src/modules/objects/class_label.h
new file mode 100644
index 00000000..38fa58a3
--- /dev/null
+++ b/src/modules/objects/class_label.h
@@ -0,0 +1,54 @@
+#ifndef _CLASS_LABEL_H_
+#define _CLASS_LABEL_H_
+//vim: ts=8
+// File : class_label.h
+// Creation date : Mon Sep 18 14:21:48 CEST 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qlabel.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_label : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_label)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionSetTitle(KviKvsObjectFunctionCall *c);
+ bool functionSetText(KviKvsObjectFunctionCall *c);
+ bool functionText(KviKvsObjectFunctionCall *c);
+ bool functionMargin(KviKvsObjectFunctionCall *c);
+ bool functionSetMargin(KviKvsObjectFunctionCall *c);
+ bool functionAutoResize(KviKvsObjectFunctionCall *c);
+ bool functionSetAutoResize(KviKvsObjectFunctionCall *c);
+ bool functionAlignment(KviKvsObjectFunctionCall *c);
+ bool functionSetAlignment(KviKvsObjectFunctionCall *c);
+ bool functionClear(KviKvsObjectFunctionCall *c);
+ bool functionFrameStyle(KviKvsObjectFunctionCall *c);
+ bool functionSetFrameStyle(KviKvsObjectFunctionCall *c);
+ bool functionSetImage(KviKvsObjectFunctionCall *c);
+};
+#endif // !_CLASS_LABEL_H_
diff --git a/src/modules/objects/class_layout.cpp b/src/modules/objects/class_layout.cpp
new file mode 100644
index 00000000..900b9856
--- /dev/null
+++ b/src/modules/objects/class_layout.cpp
@@ -0,0 +1,274 @@
+//
+// File : class_layout.cpp
+// Creation date : Fri Now 22 2002 00:50:01 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#define _KVI_DEBUG_CHECK_RANGE_
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+
+#include "class_layout.h"
+
+#ifdef COMPILE_USE_QT4
+#define QLAYOUT_AUTO_CONSTRAINT QLayout::SetDefaultConstraint
+#define QLAYOUT_FIXED QLayout::SetFixedSize
+#define QLAYOUT_FREE_RESIZE QLayout::SetNoConstraint
+#define QLAYOUT_MINIMUM QLayout::SetMinimumSize
+#else
+#define QLAYOUT_AUTO_CONSTRAINT QLayout::Auto
+#define QLAYOUT_FIXED QLayout::Fixed
+#define QLAYOUT_FREE_RESIZE QLayout::FreeResize
+#define QLAYOUT_MINIMUM QLayout::Minimum
+#endif
+
+
+/*
+ @doc: layout
+ @keyterms:
+ layout object class, child widgets
+ @title:
+ layout class
+ @type:
+ class
+ @short:
+ Manages child widget geometry
+ @inherits:
+ [class]object[/class]
+ @description:
+ The layout is a geometry management tool for child widgets.
+ You create a layout , give it some widgets to manage and it will layout them
+ automatically.[br]
+ The parent of the layout must be the widget for which child widget geometries have to be managed.
+ A layout is a grid of NxM cells in which you insert child widgets with [classfnc:layout]$addWidget[/classfnc]().[br]
+ Widgets that must span multiple cells can be added to the layout with [classfnc:layout]$addMultiCellWidget[/classfnc]().[br]
+ @functions:
+ !fn: $addWidget(<widget:object widget>,<row:uint>,<column:uint>)
+ Adds a widget to this layout placing it at position <row>,<column> in the grid
+ !fn: $addMultiCellWidget(<widget:object widget>,<start_row:uint>,<end_row:uint>,<start_col:uint>,<end_col:uint>)
+ Adds a widget to this layout spanning multiple grid cells
+ !fn: $setRowStretch(<row:uint>,<stretch:uint>)
+ Sets the stretch value for a particular row of this layout. The <stretch_value>
+ must be a positive integer. The rows with bigger stretch values will take more space
+ in the layout.
+ !fn: $setColStretch(<column:uint>,<stretch:uint>)
+ Sets the stretch value for a particular column in this layout. The <stretch_value>
+ must be a positive integer. The rows with bigger stretch values will take more space
+ in the layout.
+ !fn: $addRowSpacing(<row:uint>,<spacing:uint>)
+ Sets the minimum height of the specified <row> to <spacing> which must be a positive integer
+ !fn: $addColSpacing(<column:uint>,<spacing:uint>)
+ Sets the minimum width of the specigfied <column> to <spacing> which must be a positive integer
+ !fn: $setSpacing(<spacing:uint>)
+ Sets the default spacing of the widgets in pixels
+ !fn: $setMargin(<margin:uint>)
+ Sets the dimension of the layout margin : the distance from the border to the outermost child widget edges.
+ !fn: $setResizeMode(<resize_mode:string>)
+ Sets the resize mode of the parent widget in relation to this layout.
+ <mode> can be one of:[br]
+ -Auto: this is the default[br]
+ -Fixed: the parent widget of this layout is resized to the "sizeHint" value and it cannot be resized by the user.[br]
+ -Minimum: the minimum size of the parent widget of this layout is set to minimumSize() and it cannot be smaller[br]
+ -FreeResize: the parent widget of this layout is not constrained at all[br]
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_layout,"layout","object")
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"addWidget", functionAddWidget)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"addMultiCellWidget", functionAddMultiCellWidget)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"setRowStretch", functionSetRowStretch)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"setColStretch", functionSetColStretch)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"addRowSpacing", functionAddRowSpacing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"addColSpacing", functionAddColSpacing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"setMargin", functionSetMargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"setSpacing", functionSetSpacing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_layout,"setResizeMode", functionSetResizeMode)
+KVSO_END_REGISTERCLASS(KviKvsObject_layout)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_layout,KviKvsObject)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_layout)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_layout)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_layout)
+
+bool KviKvsObject_layout::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ QWidget * w = parentScriptWidget();
+
+ if(!w)
+ {
+ pContext->warning(__tr2qs("The parent of a layout must be a widget!"));
+ return false;
+ }
+ setObject(new QGridLayout(w));
+ return true;
+}
+
+bool KviKvsObject_layout::functionAddWidget(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject * pObject;
+ kvs_hobject_t hObject;
+ kvs_uint_t uCol,uRow;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("row",KVS_PT_UNSIGNEDINTEGER,0,uRow)
+ KVSO_PARAMETER("col",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!pObject->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!pObject->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ ((QGridLayout *)object())->addWidget(((QWidget *)(pObject->object())),uRow,uCol);
+ return true;
+}
+bool KviKvsObject_layout::functionAddMultiCellWidget(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject * pObject;
+ kvs_hobject_t hObject;
+ kvs_uint_t uStartCol,uStartRow,uEndCol,uEndRow;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("start_row",KVS_PT_UNSIGNEDINTEGER,0,uStartRow)
+ KVSO_PARAMETER("end_row",KVS_PT_UNSIGNEDINTEGER,0,uEndRow)
+ KVSO_PARAMETER("start_column",KVS_PT_UNSIGNEDINTEGER,0,uStartCol)
+ KVSO_PARAMETER("end_column",KVS_PT_UNSIGNEDINTEGER,0,uEndCol)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!pObject->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!pObject->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ ((QGridLayout *)object())->addMultiCellWidget(((QWidget *)(pObject->object())),uStartRow,uEndRow,uStartCol,uEndCol);
+ return true;
+}
+bool KviKvsObject_layout::functionSetRowStretch(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uRow,uStretch;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("row",KVS_PT_UNSIGNEDINTEGER,0,uRow)
+ KVSO_PARAMETER("stretch",KVS_PT_UNSIGNEDINTEGER,0,uStretch)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ ((QGridLayout *)object())->setRowStretch(uRow,uStretch);
+ return true;
+}
+bool KviKvsObject_layout::functionSetColStretch(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uCol,uStretch;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("stretch",KVS_PT_UNSIGNEDINTEGER,0,uStretch)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ ((QGridLayout *)object())->setColStretch(uCol,uStretch);
+ return true;
+}
+
+bool KviKvsObject_layout::functionSetMargin(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uMargin;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,uMargin)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QGridLayout *)object())->setMargin(uMargin);
+ return true;
+}
+
+bool KviKvsObject_layout::functionSetSpacing(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uSpacing;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QGridLayout *)object())->setSpacing(uSpacing);
+ return true;
+}
+
+
+bool KviKvsObject_layout::functionAddRowSpacing(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uSpacing,uRow;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("row",KVS_PT_UNSIGNEDINTEGER,0,uRow)
+ KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QGridLayout *)object())->addRowSpacing(uRow,uSpacing);
+ return true;
+}
+
+bool KviKvsObject_layout::functionAddColSpacing(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uSpacing,uCol;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QGridLayout *)object())->addColSpacing(uCol,uSpacing);
+ return true;
+}
+
+bool KviKvsObject_layout::functionSetResizeMode(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("resize_mode",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+#ifdef COMPILE_USE_QT4
+ QLayout::SizeConstraint r = QLAYOUT_AUTO_CONSTRAINT;
+#else
+ QLayout::ResizeMode r = QLAYOUT_AUTO_CONSTRAINT;
+#endif
+ if(KviQString::equalCI(szMode,"FreeResize")) r = QLAYOUT_FREE_RESIZE;
+ else if(KviQString::equalCI(szMode,"Minimum")) r = QLAYOUT_MINIMUM;
+ else if(KviQString::equalCI(szMode,"Fixed"))r = QLAYOUT_FIXED;
+ else c->warning(__tr2qs("Invalid resize mode defaulting to Auto"));
+ ((QGridLayout *)object())->setResizeMode(r);
+ return true;
+
+}
+
diff --git a/src/modules/objects/class_layout.h b/src/modules/objects/class_layout.h
new file mode 100644
index 00000000..e821316a
--- /dev/null
+++ b/src/modules/objects/class_layout.h
@@ -0,0 +1,52 @@
+#ifndef _CLASS_LAYOUT_H_
+#define _CLASS_LAYOUT_H_
+//
+// File : class_layout.h
+// Creation date : Fri Now 22 2002 00:50:01 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include "kvi_string.h"
+
+#include <qlayout.h>
+#include "object_macros.h"
+
+class KviKvsObject_layout : public KviKvsObject
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_layout)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionAddWidget(KviKvsObjectFunctionCall *c);
+ bool functionAddMultiCellWidget(KviKvsObjectFunctionCall *c);
+ bool functionSetRowStretch(KviKvsObjectFunctionCall *c);
+ bool functionSetColStretch(KviKvsObjectFunctionCall *c);
+ bool functionSetMargin(KviKvsObjectFunctionCall *c);
+ bool functionSetSpacing(KviKvsObjectFunctionCall *c);
+ bool functionAddRowSpacing(KviKvsObjectFunctionCall *c);
+ bool functionAddColSpacing(KviKvsObjectFunctionCall *c);
+ bool functionSetResizeMode(KviKvsObjectFunctionCall *c);
+
+
+};
+
+
+#endif //_CLASS_LAYOUT_H_
diff --git a/src/modules/objects/class_lcd.cpp b/src/modules/objects/class_lcd.cpp
new file mode 100644
index 00000000..0f0ba49a
--- /dev/null
+++ b/src/modules/objects/class_lcd.cpp
@@ -0,0 +1,180 @@
+//
+// File : class_lcd.cpp
+// Creation date : Mon Gen 27 14:30:48 CEST 2005 by Tonino Imbesi(Grifisx)
+// and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "class_lcd.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+/*
+ @doc: lcdnumber
+ @keyterms:
+ lcdnumber object class, lcd
+ @title:
+ lcdnumber class
+ @type:
+ class
+ @short:
+ The lcdNumber widget displays a number with LCD-like digits.
+ @inherits:
+
+ @description:
+ It can display a number in just about any size. It can display decimal,
+ hexadecimal, octal or binary numbers.
+ @functions:
+ !fn: $setDisplayStr(<number:string>)
+ Displays the number represented by the string s.
+ !fn: $setDisplayInt(<number:integer>)
+ Sets the displayed value rounded to the nearest integer to number.
+ !fn: $setDisplayDouble(<number:double>)
+ Sets the displayed value to number (double).
+ !fn: $setMode(<mode:string>)
+ Sets the current display mode (number base): valid mode are HEX,BIN,OCT,DEC.
+ !fn: $setSegmentStyles(<style:string>)
+ Sets the style of the lcdnumber, valid styles are: Outline,Filled,Flat.
+ !fn: $setNumDigits(<number:integer>)
+ Sets the lcd number value.
+ !fn: <boolean> $checkOverflow()
+ Returns TRUE if num is too big to be displayed in its entirety;
+ otherwise returns FALSE.
+ !fn: $setSmallDecimalPoint(<bflag:boolean>)
+ Sets the the decimal point style, valid bool values are 1 or 0.
+ !fn: <boolean> $checkOverflow(<number:integer>)
+ Returns 1 (TRUE) if num is too big to be displayed in its entirety; otherwise returns 0 (FALSE).
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_lcd,"lcdnumber","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"setDisplayStr", functiondisplayStr)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"setDisplayInt", functiondisplayInt)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"setDisplayDouble", functiondisplayDouble)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"setMode", functionsetMode)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"setSegmentStyle", functionsetSegmentStyle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"setNumDigits", functionsetNumDigits)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"setSmallDecimalPoint",functionsetSmallDecimalPoint)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lcd,"checkOverflow", functioncheckOverflow)
+KVSO_END_REGISTERCLASS(KviKvsObject_lcd)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_lcd,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_lcd)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_lcd)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_lcd)
+
+bool KviKvsObject_lcd::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QLCDNumber(parentScriptWidget(), name()), true);
+ return true;
+}
+
+bool KviKvsObject_lcd::functiondisplayInt(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iDigit;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("number",KVS_PT_INT,0,iDigit)
+ KVSO_PARAMETERS_END(c)
+ if(widget())((QLCDNumber *)widget())->display((int)iDigit);
+ return true;
+}
+
+bool KviKvsObject_lcd::functiondisplayStr(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("number",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((QLCDNumber *)widget())->display(szText);
+ return true;
+}
+
+bool KviKvsObject_lcd::functiondisplayDouble(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dDigit;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("number",KVS_PT_DOUBLE,0,dDigit)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((QLCDNumber *)widget())->display(dDigit);
+ return true;
+}
+bool KviKvsObject_lcd::functionsetMode(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("mode",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szMode, "HEX")) ((QLCDNumber *)widget())->setHexMode();
+ else if(KviQString::equalCI(szMode, "DEC")) ((QLCDNumber *)widget())->setDecMode();
+ else if(KviQString::equalCI(szMode, "BIN")) ((QLCDNumber *)widget())->setBinMode();
+ else if(KviQString::equalCI(szMode, "OCT")) ((QLCDNumber *)widget())->setOctMode();
+ else c->warning( __tr2qs("Unknown mode "));
+ return true;
+}
+bool KviKvsObject_lcd::functionsetSegmentStyle(KviKvsObjectFunctionCall *c)
+{
+ QString szStyle;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("style",KVS_PT_STRING,0,szStyle)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szStyle, "Outline")) ((QLCDNumber *)widget())->setSegmentStyle(QLCDNumber::Outline);
+ else if(KviQString::equalCI(szStyle, "Filled")) ((QLCDNumber *)widget())->setSegmentStyle(QLCDNumber::Filled);
+ else if(KviQString::equalCI(szStyle, "Flat")) ((QLCDNumber *)widget())->setSegmentStyle(QLCDNumber::Flat);
+ else c->warning( __tr2qs("Unknown segment style "));
+ return true;
+}
+bool KviKvsObject_lcd::functionsetNumDigits(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t digit;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("digit",KVS_PT_DOUBLE,0,digit)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((QLCDNumber *)widget())->setNumDigits(digit);
+ return true;
+}
+bool KviKvsObject_lcd::functionsetSmallDecimalPoint(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bflag",KVS_PT_BOOLEAN,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((QLCDNumber *)widget())->setSmallDecimalPoint(bFlag);
+ return true;
+}
+bool KviKvsObject_lcd::functioncheckOverflow(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t iDigit;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("digit",KVS_PT_DOUBLE,0,iDigit)
+ KVSO_PARAMETERS_END(c)
+ if(widget())c->returnValue()->setBoolean(((QLCDNumber *)widget())->checkOverflow(iDigit));
+ return true;
+}
+
+
diff --git a/src/modules/objects/class_lcd.h b/src/modules/objects/class_lcd.h
new file mode 100644
index 00000000..4976850a
--- /dev/null
+++ b/src/modules/objects/class_lcd.h
@@ -0,0 +1,51 @@
+#ifndef _CLASS_LCD_H_
+#define _CLASS_LCD_H_
+
+// File : class_lcd.h
+// Creation date : Mon Gen 27 14:30:48 CEST 2005 by Tonino Imbesi(Grifisx)
+// and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qlcdnumber.h>
+#include "class_widget.h"
+
+
+class KviKvsObject_lcd : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_lcd)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functiondisplayStr(KviKvsObjectFunctionCall *c);
+ bool functionsetMode(KviKvsObjectFunctionCall *c);
+ bool functionsetSegmentStyle(KviKvsObjectFunctionCall *c);
+ bool functionsetNumDigits(KviKvsObjectFunctionCall *c);
+ bool functionsetSmallDecimalPoint(KviKvsObjectFunctionCall *c);
+ bool functioncheckOverflow(KviKvsObjectFunctionCall *c);
+ bool functiondisplayInt(KviKvsObjectFunctionCall *c);
+ bool functiondisplayDouble(KviKvsObjectFunctionCall *c);
+};
+
+#endif // !_CLASS_LCD_H_
diff --git a/src/modules/objects/class_lineedit.cpp b/src/modules/objects/class_lineedit.cpp
new file mode 100644
index 00000000..c8ba58ff
--- /dev/null
+++ b/src/modules/objects/class_lineedit.cpp
@@ -0,0 +1,461 @@
+//vim: ts=8
+// File : class_lineedit.cpp
+// Creation date : Wed 20 Sep 2000 04:34:40 CEST by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+
+#include "class_lineedit.h"
+
+static const char * mode_tbl[] = {
+ "Normal",
+ "NoEcho",
+ "Password"
+ };
+
+static const int mode_cod[] = {
+ QLineEdit::Normal,
+ QLineEdit::NoEcho,
+ QLineEdit::Password
+ };
+
+#define mode_num (sizeof(mode_tbl) / sizeof(mode_tbl[0]))
+
+
+/*
+ @doc: lineedit
+ @keyterms:
+ lineedit object class, line editor, input
+ @title:
+ lineedit class
+ @type:
+ class
+ @short:
+ Simple line editor for inputting short text
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This is a simple, one-line editor usually used for inputting
+ short text like names, phone numbers etc. It can display text
+ in three echo modes (see [classfnc]$setEchoMode[/classfnc]()
+ for details).
+ @functions:
+ !fn: <string> $text()
+ Returns text contained by the widget.[br]
+ See also [classfnc]$setText[/classfnc]().
+ !fn: $setText(<text:string>)
+ Sets editor text to <text>.[br]
+ See also [classfnc]$text[/classfnc]().
+ !fn: $setEchoMode(<echo_mode:string>)
+ Sets the line edit's echo mode. Possible value are:[br]
+ -Normal: display chars as they entered[br]
+ -Noecho : do not display anything[br]
+ -Password : display asterisks instead of the characters actually entered[br]
+ See also [classfnc]$echoMode[/classfnc]().
+ !fn: <string> $echoMode()
+ Return the line edit's echo mode.
+ See also [classfnc]$setEchoMode[/classfnc]().
+ !fn: <integer> $maxLength()
+ Returns the current maximum length of the text that can be typed
+ in the editor.[br]
+ See also [classfnc]$setMaxLength[/classfnc]().
+ !fn: $setMaxLength(<max_lenght:integer>)
+ Sets maximum length of the text that can be typed in the
+ editor.[br]
+ See also [classfnc]$maxLength[/classfnc]().
+ !fn: <boolean> $frame()
+ Returns '1' if the editor is drawn inside a frame, which is 2
+ pixels wide, '0' otherwise.[br]
+ See also [classfnc]$setFrame[/classfnc]().
+ !fn: $setFrame(<bframe:boolean>)
+ Sets editor frame drawing to <bool>.[br]
+ See also [classfnc]$frame[/classfnc]().
+ !fn: <integer> $cursorPosition()
+ Returns current cursor position in the editor.[br]
+ See also [classfnc]$setCursorPosition[/classfnc]().
+ !fn: $setCursorPosition(<index:integer>)
+ Moves the cursor to place pointed by <index>.[br]
+ See also [classfnc]$cursorPosition[/classfnc]().
+ !fn: $selectAll()
+ Selects whole text inside the editor.[br]
+ See also [classfnc]$setSelection[/classfnc](),
+ [classfnc]$cut[/classfnc](), [classfnc]$copy[/classfnc](),
+ [classfnc]$paste[/classfnc]().
+ !fn: $setSelection(<start:integer>, <length:integer>)
+ Selects <length> characters in the editor starting at position
+ <start>.[br]
+ See also [classfnc]$selectAll[/classfnc](),
+ [classfnc]$cut[/classfnc](), [classfnc]$copy[/classfnc](),
+ [classfnc]$paste[/classfnc]().
+ !fn: $copy()
+ Copies selected text in the editor to the clipboard.[br]
+ See also [classfnc]$setSelection[/classfnc](),
+ [classfnc]$cut[/classfnc](), [classfnc]$paste[/classfnc]().
+ !fn: $cut()
+ Cuts selected text from the editor to the clipboard.[br]
+ See also [classfnc]$setSelection[/classfnc](),
+ [classfnc]$copy[/classfnc](), [classfnc]$paste[/classfnc]().
+ !fn: $paste()
+ Pastes text from the clipboard into the editor. The pasted text
+ will start at cursor position.[br]
+ See also [classfnc]$setSelection[/classfnc](),
+ [classfnc]$copy[/classfnc](), [classfnc]$cut[/classfnc]().
+ !fn: $clear()
+ Deletes all text from the editor. Equal to calling [classfnc]$setText[/classfnc]("").
+ !fn: $setDragEnabled(<bEnabled:bool>)
+ With this property user can drag text in the lineedit.
+ !fn: $setReadOnly(<bReadonly:boolean>)
+ Sets the lineedit to read only mode.
+ !fn: $setInputMask(<mask:string>)
+ Sets the validation input mask to inputMask.[br]
+ Example:[br]
+ [br]
+ %esempio->$setInputMask( "+99 99 99 99 99;_" );[br]
+ %esempio->$setInputMask( "000.000.000.000;_" );[br]
+ %esempio->Ip Number Mask.[br]
+ %esempio->setInputMask( ">AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#" );[br]
+ [br]
+ The mask format understands these mask characters:[br]
+ Character Meaning[br]
+ A ASCII alphabetic character required. A-Z, a-z.[br]
+ a ASCII alphabetic character permitted but not required.[br]
+ N ASCII alphanumeric character required. A-Z, a-z, 0-9.[br]
+ n ASCII alphanumeric character permitted but not required.[br]
+ X Any character required.[br]
+ x Any character permitted but not required.[br]
+ 9 ASCII digit required. 0-9.[br]
+ 0 ASCII digit permitted but not required.[br]
+ D ASCII digit required. 1-9.[br]
+ d ASCII digit permitted but not required.[br]
+ # ASCII digit or plus/minus sign permitted but not required.[br]
+ > All following alphabetic characters are uppercased.[br]
+ < All following alphabetic characters are lowercased.[br]
+ ! Switch off case conversion.[br]
+ \ Use \ to escape the special characters listed above to use them as separators.[br]
+ [br]
+ The mask consists of a string of mask characters and separators, optionally[br]
+ followed by a semi-colon and the character used for blanks: the blank characters [br]
+ are always removed from the text after editing. The default blank character is space. [br]
+ !fn: $returnPressedEvent()
+ This function is called by the framework when the enter key is pressed.
+ !fn: $lostFocusEvent()
+ Called when the lineedit lost focus.
+ !fn: $textChangedEvent(<new text:string>)
+ This event is called when the text changed, In $0 there is the new text.
+ @signals:
+ !sg: $returnPressed()
+ This signal is emitted by the default implementation of [classfnc]$returnPressedEvent[/classfnc]().
+ !sg: $lostFocus()
+ This signal is emitted by the default implementation of [classfnc]$lostFocusEvent[/classfnc]().
+ !sg: $textChanged()
+ This signal is emitted by the default implementation of [classfnc]$textChangedEvent[/classfnc]().
+
+*/
+
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_lineedit,"lineedit","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"text", functionText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setText", functionSetText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"maxLength", functionMaxLength)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setMaxLength", functionSetMaxLength)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"frame", functionFrame)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setCursorPosition", functionSetCursorPosition)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"cursorPosition", functionCursorPosition)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setFrame", functionSetFrame)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"selectAll" , functionSelectAll)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setSelection", functionSetSelection)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"copy", functionCopy)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"cut", functionCut)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"paste", functionPaste)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"echoMode", functionEchoMode)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setEchoMode", functionSetEchoMode)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"clear", functionClear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setDragEnabled", functionDragAndDrop)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setInputMask", functionSetInputMask)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"setReadOnly", functionSetReadOnly)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"returnPressedEvent", functionreturnPressedEvent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"lostFocusEvent", functionlostFocusEvent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_lineedit,"textChangedEvent", functiontextChangedEvent)
+
+
+KVSO_END_REGISTERCLASS(KviKvsObject_lineedit)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_lineedit,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_lineedit)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_lineedit)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_lineedit)
+
+
+bool KviKvsObject_lineedit::init(KviKvsRunTimeContext * pContext,KviKvsVariantList * pParams)
+{
+ setObject(new QLineEdit(parentScriptWidget(),getName()),true);
+ connect(widget(),SIGNAL(returnPressed()),this,SLOT(slotreturnPressed()));
+ connect(widget(),SIGNAL(lostFocus()),this,SLOT(slotlostFocus()));
+ connect(widget(),SIGNAL(textChanged(const QString & )),this,SLOT(slottextChanged(const QString & )));
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionText(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setString(((QLineEdit *)widget())->text());
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QLineEdit *)widget())->setText(szText);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionMaxLength(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setInteger(((QLineEdit *)widget())->maxLength());
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetMaxLength(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t iMaxlen;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("maxlen",KVS_PT_UNSIGNEDINTEGER,0,iMaxlen)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QLineEdit *)widget())->setMaxLength(iMaxlen);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionFrame(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((QLineEdit *)widget())->frame());
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetFrame(KviKvsObjectFunctionCall *c)
+{
+ bool bFrame;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bframe",KVS_PT_BOOL,0,bFrame)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QLineEdit *)widget())->setFrame(bFrame);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionCursorPosition(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setInteger(((QLineEdit *)widget())->cursorPosition());
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetCursorPosition(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t iPos;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("position",KVS_PT_UNSIGNEDINTEGER,0,iPos)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QLineEdit *)widget())->setCursorPosition(iPos);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSelectAll(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QLineEdit *)widget())->selectAll();
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetSelection(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uStart,uLen;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("start",KVS_PT_UNSIGNEDINTEGER,0,uStart)
+ KVSO_PARAMETER("len",KVS_PT_UNSIGNEDINTEGER,0,uLen)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QLineEdit *)widget())->setSelection(uStart, uLen);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionCopy(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QLineEdit *)widget())->copy();
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionCut(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QLineEdit *)widget())->cut();
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionPaste(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QLineEdit *)widget())->paste();
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionEchoMode(KviKvsObjectFunctionCall *c)
+{
+ int mode = ((QLineEdit *)widget())->echoMode();
+ QString szEchomode="";
+ for(unsigned int i = 0; i < mode_num; i++)
+ {
+ if(mode == mode_cod[i])
+ {
+ szEchomode=mode_tbl[i];
+ break;
+ }
+ }
+ c->returnValue()->setString(szEchomode);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetEchoMode(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("mode",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ for(unsigned int i = 0; i < mode_num; i++)
+ {
+ if(KviQString::equalCI(szMode, mode_tbl[i]))
+ {
+ ((QLineEdit *)widget())->setEchoMode( \
+ ((QLineEdit::EchoMode)mode_cod[i]));
+ return true;
+ }
+ }
+ c->warning(__tr2qs("Unknown echo mode %Q"),&szMode);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionClear(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QLineEdit *)widget())->clear();
+ return true;
+}
+
+//-| Grifisx & Noldor |-Start:
+bool KviKvsObject_lineedit::functionDragAndDrop(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QLineEdit *)widget())->setDragEnabled(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetReadOnly(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bReadonly",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QLineEdit *)widget())->setReadOnly(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionSetInputMask(KviKvsObjectFunctionCall *c)
+{
+ QString szMask;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("mask",KVS_PT_STRING,0,szMask)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QLineEdit *)widget())->setInputMask(szMask);
+ return true;
+}
+
+bool KviKvsObject_lineedit::functionreturnPressedEvent(KviKvsObjectFunctionCall *c)
+{
+
+ emitSignal("returnPressed",c);
+ return true;
+
+}
+
+void KviKvsObject_lineedit::slotreturnPressed()
+{
+ KviKvsVariantList * params = 0;
+ callFunction(this,"returnPressedEvent",params);
+
+}
+// FIND ME
+bool KviKvsObject_lineedit::functionlostFocusEvent(KviKvsObjectFunctionCall *c)
+{
+
+
+ emitSignal("lostFocus",c);
+ return true;
+
+}
+
+void KviKvsObject_lineedit::slotlostFocus()
+{
+ KviKvsVariantList * params = 0;
+ callFunction(this,"lostFocusEvent",params);
+}
+/////
+bool KviKvsObject_lineedit::functiontextChangedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("textChanged",c,c->params());
+ return true;
+
+}
+
+void KviKvsObject_lineedit::slottextChanged(const QString &text)
+{
+ KviKvsVariantList params(new KviKvsVariant(text));
+ callFunction(this,"textChangedEvent",&params);
+}
+
+
+#include "m_class_lineedit.moc"
diff --git a/src/modules/objects/class_lineedit.h b/src/modules/objects/class_lineedit.h
new file mode 100644
index 00000000..d7036824
--- /dev/null
+++ b/src/modules/objects/class_lineedit.h
@@ -0,0 +1,81 @@
+#ifndef _CLASS_LINEEDIT_H_
+#define _CLASS_LINEEDIT_H_
+//vim: ts=8
+// File : class_lineedit.h
+// Creation date : Wed 20 Sep 2000 04:34:22 CEST by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qlineedit.h>
+#include "class_widget.h"
+
+//#warning "Signals !"
+
+#include "object_macros.h"
+
+class KviKvsObject_lineedit : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_lineedit)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+
+
+ bool functionText(KviKvsObjectFunctionCall *c);
+ bool functionSetText(KviKvsObjectFunctionCall *c);
+ bool functionMaxLength(KviKvsObjectFunctionCall *c);
+ bool functionSetMaxLength(KviKvsObjectFunctionCall *c);
+ bool functionFrame(KviKvsObjectFunctionCall *c);
+ bool functionSetCursorPosition(KviKvsObjectFunctionCall *c);
+ bool functionCursorPosition(KviKvsObjectFunctionCall *c);
+ bool functionSetFrame(KviKvsObjectFunctionCall *c);
+ bool functionSelectAll(KviKvsObjectFunctionCall *c);
+ bool functionSetSelection(KviKvsObjectFunctionCall *c);
+ bool functionCopy(KviKvsObjectFunctionCall *c);
+ bool functionCut(KviKvsObjectFunctionCall *c);
+
+ bool functionPaste(KviKvsObjectFunctionCall *c);
+ bool functionEchoMode(KviKvsObjectFunctionCall *c);
+ bool functionSetEchoMode(KviKvsObjectFunctionCall *c);
+ bool functionClear(KviKvsObjectFunctionCall *c);
+ bool functionDragAndDrop(KviKvsObjectFunctionCall *c);
+ bool functionSetInputMask(KviKvsObjectFunctionCall *c);
+ bool functionSetReadOnly(KviKvsObjectFunctionCall *c);
+
+ bool functionreturnPressedEvent(KviKvsObjectFunctionCall *c);
+
+ bool functionlostFocusEvent(KviKvsObjectFunctionCall *c);
+
+ bool functiontextChangedEvent(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void slotreturnPressed();
+ void slotlostFocus();
+ void slottextChanged(const QString &);
+
+};
+
+
+#endif // ! _CLASS_LINEEDIT_H_
diff --git a/src/modules/objects/class_list.cpp b/src/modules/objects/class_list.cpp
new file mode 100644
index 00000000..2d6c9e84
--- /dev/null
+++ b/src/modules/objects/class_list.cpp
@@ -0,0 +1,392 @@
+//=============================================================================
+//
+// File : class_list.cpp
+// Creation date : Wed Sep 09 2000 21:07:55 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//============================================================================
+
+#include "kvi_debug.h"
+
+#include "kvi_malloc.h"
+#include "kvi_locale.h"
+
+#include "class_list.h"
+
+#include <stdlib.h>
+
+
+/*
+ @doc: list
+ @keyterms:
+ list object class, sorted list
+ @title:
+ list class
+ @type:
+ class
+ @short:
+ Abstracts a double linked list of strings
+ @inherits:
+ [class]object[/class]
+ @description:
+
+
+ This object class abstracts a double linked list of strings.
+ You can insert/remove items by zero based position, at the end (tail) or at the
+ beginning (head). The list incorporates an efficient iteration
+ method by using the [classfnc:list]$moveFirst[/classfnc](),[classfnc:list]$moveLast[/classfnc](),
+ [classfnc:list]$moveNext[/classfnc](),[classfnc:list]$movePrev[/classfnc](),
+ [classfnc:list]$current[/classfnc]() and [classfnc:list]$eof[/classfnc]() functions.
+ @functions:
+ !fn: <integer> $count()
+ Returns the number of items in the list
+
+ !fn: <boolean> $isEmpty()
+ Returns $true if the list is empty, $false otherwise.
+
+ !fn: $clear()
+ Removes all the items from the list.This is the same as
+ [classfnc:list]$removeAll[/classfnc]().
+
+ !fn: $removeAll()
+ Removes all the items from the list. This is the same as
+ [classfnc:list]$clear[/classfnc]().
+
+ !fn: $append(<item:variant>)
+ Inserts the <item> at the end (tail) of the list.
+
+ !fn: $prepend(<item:variant>)
+ Inserts the <item> at the beginning (head) of the list.
+
+ !fn: $insert(<index:uint>,<item:variant>)
+ Inserts the <item> at zero-based position <index> in the list.
+ If <index> is greater or equal to [classfnc:list]$count[/classfnc]()
+ then the item is simply appended to the end of the list.
+
+ !fn: $add(<index:uint>,<item:variant>)
+ This is exactly the same as [classfnc:list]$insert[/classfnc]().
+
+ !fn: <variant> $item(<index:uint>)
+ Returns the item at zero-based <index>. If <index> is greater
+ or equal to [classfnc:list]$count[/classfnc]() (beyond the end of the list)
+ then [fnc]$nothing[/fnc] is returned.
+
+ !fn: <boolean> $remove(<index:uint>)
+ Removes the item at zero-based <index>. Returns $true
+ if the item was succesfully removed and $false otherwise (i.e. <index>
+ pointed beyond the end of the list).
+
+ !fn: <boolean> $removeFirst()
+ Removes the first item from the list. Returns $true
+ if the item was succesfully removed (the list was not empty)
+ and $false otherwise.
+
+ !fn: <boolean> $removeLast()
+ Removes the last item from the list. Returns $true
+ if the item was succesfully removed (the list was not empty)
+ and $false otherwise.
+
+ !fn: <boolean> $removeCurrent()
+ Removes the current item from the list. Returns $true
+ if the item was succesfully removed or $false otherwise.
+ Invalidates any iteration operation.
+
+ !fn: <boolean> $moveFirst()
+ Moves the iterator to the first item in the list and returns
+ $true if the move was succesfull (i.e., the list is not empty)
+ and $false otherwise.
+
+ !fn: <boolean> $moveLast()
+ Moves the iterator to the last item in the list and returns
+ $true if the move was succesfull (i.e., the list is not empty)
+ and $false otherwise.
+
+ !fn: <boolean> $movePrev()
+ Moves the iterator to the previous item and returns $true
+ if the move was succesfull (i.e., there IS a previous item)
+ and $false otherwise.
+
+ !fn: <boolean> $moveNext()
+ Moves the iterator to the next item and returns $true
+ if the move was succesfull (i.e., there IS a next item)
+ and $false otherwise.
+
+ !fn: <boolean> $eof()
+ Returns $true if the iterator points to a valid
+ item in the list (and thus [classfnc:list]$current[/classfnc]()
+ would return a valid value) and $false otherwise.
+
+ !fn: <boolean> $current()
+ Returns the item pointed by the current iterator
+ or [fnc]$nothing[/fnc] is the iterator is not valid (points
+ beyond the end of the list).
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_list,"list","object")
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"count",function_count)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"isEmpty",function_isEmpty)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"clear",function_clear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"removeAll",function_clear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"append",function_append)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"prepend",function_prepend)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"insert",function_insert)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"add",function_insert)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"at",function_at)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"item",function_at)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"remove",function_remove)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"removeFirst",function_removeFirst)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"removeLast",function_removeLast)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"removeCurrent",function_removeCurrent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"moveFirst",function_moveFirst)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"moveNext",function_moveNext)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"movePrev",function_movePrev)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"moveLast",function_moveLast)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"sort",function_sort)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"eof",function_eof)
+ KVSO_REGISTER_HANDLER(KviKvsObject_list,"current",function_current)
+KVSO_END_REGISTERCLASS(KviKvsObject_list)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_list,KviKvsObject)
+ m_pDataList = new KviPointerList<KviKvsVariant>;
+ m_pDataList->setAutoDelete(true);
+KVSO_END_CONSTRUCTOR(KviKvsObject_list)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_list)
+ delete m_pDataList;
+ m_pDataList = 0;
+KVSO_END_CONSTRUCTOR(KviKvsObject_list)
+
+bool KviKvsObject_list::function_current(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setNothing();
+ return true;
+ }
+ KviKvsVariant * v = m_pDataList->current();
+ if(v)c->returnValue()->copyFrom(*v);
+ else c->returnValue()->setNothing();
+ return true;
+}
+
+bool KviKvsObject_list::function_eof(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(true);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->current() != 0);
+ return true;
+}
+
+bool KviKvsObject_list::function_moveLast(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->last() != 0);
+ return true;
+}
+
+bool KviKvsObject_list::function_movePrev(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->prev() != 0);
+ return true;
+}
+
+bool KviKvsObject_list::function_moveNext(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->next() != 0);
+ return true;
+}
+
+bool KviKvsObject_list::function_moveFirst(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->first() != 0);
+ return true;
+}
+
+bool KviKvsObject_list::function_removeLast(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->removeLast());
+ return true;
+}
+
+bool KviKvsObject_list::function_removeCurrent(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ if(m_pDataList->current())
+ {
+ m_pDataList->removeCurrent();
+ c->returnValue()->setBoolean(true);
+ } else {
+ c->returnValue()->setBoolean(false);
+ }
+ return true;
+}
+
+bool KviKvsObject_list::function_removeFirst(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->removeFirst());
+ return true;
+}
+
+bool KviKvsObject_list::function_remove(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UINT,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->remove(uIndex));
+ return true;
+}
+
+bool KviKvsObject_list::function_at(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UINT,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pDataList)
+ {
+ c->returnValue()->setNothing();
+ return true;
+ }
+ KviKvsVariant * v = m_pDataList->at(uIndex);
+ if(v)c->returnValue()->copyFrom(*v);
+ else c->returnValue()->setNothing();
+ return true;
+}
+
+bool KviKvsObject_list::function_insert(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KviKvsVariant * pVar;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UINT,0,uIndex)
+ KVSO_PARAMETER("item",KVS_PT_VARIANT,0,pVar)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pDataList)return true;
+ m_pDataList->insert(uIndex,new KviKvsVariant(*pVar));
+ return true;
+}
+
+bool KviKvsObject_list::function_prepend(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pVar;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("item",KVS_PT_VARIANT,0,pVar)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pDataList)return true;
+ m_pDataList->prepend(new KviKvsVariant(*pVar));
+ return true;
+}
+
+bool KviKvsObject_list::function_append(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pVar;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("item",KVS_PT_VARIANT,0,pVar)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pDataList)return true;
+ m_pDataList->append(new KviKvsVariant(*pVar));
+ return true;
+}
+
+bool KviKvsObject_list::function_clear(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)return true;
+ m_pDataList->clear();
+ return true;
+}
+
+inline int kvi_compare(const KviKvsVariant * p1,const KviKvsVariant * p2)
+{
+ return p1->compare(p2);
+}
+
+bool KviKvsObject_list::function_sort(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)return true;
+ m_pDataList->sort();
+ return true;
+}
+
+bool KviKvsObject_list::function_isEmpty(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setBoolean(true);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pDataList->isEmpty());
+ return true;
+}
+
+bool KviKvsObject_list::function_count(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pDataList)
+ {
+ c->returnValue()->setInteger(0);
+ return true;
+ }
+ c->returnValue()->setInteger(m_pDataList->count());
+ return true;
+}
+
diff --git a/src/modules/objects/class_list.h b/src/modules/objects/class_list.h
new file mode 100644
index 00000000..41d2816e
--- /dev/null
+++ b/src/modules/objects/class_list.h
@@ -0,0 +1,64 @@
+#ifndef _CLASS_LIST_H_
+#define _CLASS_LIST_H_
+//=========================================================================================
+//
+// File : class_list.h
+// Creation date : Wed Sep 09 2000 21:07:01 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2000-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=========================================================================================
+
+#include "kvi_settings.h"
+#include "kvi_string.h"
+#include "kvi_pointerlist.h"
+#include "kvi_kvs_variant.h"
+#include "object_macros.h"
+
+
+class KviKvsObject_list : public KviKvsObject
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_list)
+protected:
+ KviPointerList<KviKvsVariant> * m_pDataList;
+protected:
+ KviPointerList<KviKvsVariant> * dataList() const { return m_pDataList; };
+public:
+ bool function_count(KviKvsObjectFunctionCall *c);
+ bool function_isEmpty(KviKvsObjectFunctionCall *c);
+ bool function_clear(KviKvsObjectFunctionCall *c);
+ bool function_append(KviKvsObjectFunctionCall *c);
+ bool function_prepend(KviKvsObjectFunctionCall *c);
+ bool function_insert(KviKvsObjectFunctionCall *c);
+ bool function_at(KviKvsObjectFunctionCall *c);
+ bool function_remove(KviKvsObjectFunctionCall *c);
+ bool function_removeFirst(KviKvsObjectFunctionCall *c);
+ bool function_removeLast(KviKvsObjectFunctionCall *c);
+ bool function_removeCurrent(KviKvsObjectFunctionCall *c);
+ bool function_moveFirst(KviKvsObjectFunctionCall *c);
+ bool function_moveNext(KviKvsObjectFunctionCall *c);
+ bool function_movePrev(KviKvsObjectFunctionCall *c);
+ bool function_moveLast(KviKvsObjectFunctionCall *c);
+ bool function_eof(KviKvsObjectFunctionCall *c);
+ bool function_current(KviKvsObjectFunctionCall *c);
+ bool function_sort(KviKvsObjectFunctionCall *c);
+};
+
+
+#endif //_CLASS_LIST_H_
diff --git a/src/modules/objects/class_listbox.cpp b/src/modules/objects/class_listbox.cpp
new file mode 100644
index 00000000..111f7952
--- /dev/null
+++ b/src/modules/objects/class_listbox.cpp
@@ -0,0 +1,390 @@
+//vim: ts=8
+// File : class_listbox.cpp
+// Creation date : Sat Oct 2 03:40:28 CET 2004 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2004 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "kvi_error.h"
+#include "kvi_locale.h"
+#include "kvi_debug.h"
+
+
+#include "kvi_tal_listbox.h"
+
+#include "class_list.h"
+#include "class_listbox.h"
+
+/*
+ @doc: listbox
+ @keyterms:
+ listbox object class
+ @title:
+ listbox class
+ @type:
+ class
+ @short:
+ A widget displaying a list of items
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ The listbox class is a widget displaying a list of string items.[br]
+ The listbox can operate in four selection modes: single, multi, extended
+ and none. In the "single" mode only one item can be selected at a time
+ and that item is also the current one. In the "multi" mode multiple
+ items can be selected and unselected and the current item may or may not
+ be one of the selected items. In the "extended" mode multiple items
+ can be selected but they must be selected in a single mouse action
+ or by keeping the shift button pressed while clicking on the item.
+ In this mode the current item is always one of the selected items.[br]
+ In the "none" mode no items can be selected and the current item
+ may be any item in the list.[br]
+ In most situations you will operate the listbox in "single" mode
+ (and this is the default mode set at widget creation).
+ @functions:
+ !fn: $setSelectionMode(<selection_mode:string>)
+ Sets the current selection mode specified by the parameter <mode>
+ that can be one of the following string:[br]
+ "single" : only one item can be selected at a time[br]
+ "multi" : multiple items can be selected at a time[br]
+ "extended" : multiple items can be selected but only in a single mouse interaction[br]
+ "none" : no items can be selected[br]
+ The default mode is "single"
+ !fn: <string> $selectionMode()
+ Returns the current selection mode
+ !fn: $insertItem(<text:string>, <index:uint>)
+ Inserts a text item at position <index>. If index is negative or
+ not specified the item is appended.
+ !fn: $changeItem(<text:string>, <index:uint>)
+ Changes text of item at <index> to <text>.
+ !fn: $removeItem(<index:uindex>)
+ Removes item at given index.
+ !fn: $count()
+ Returns number of items in the widget.
+ !fn: <string> $currentText()
+ Returns the text of the currently selected item.
+ !fn: <integer> $currentItem()
+ Returns index of current item or -1 if no item is current.
+ !fn: $textAt(<index:integer>)
+ Returns item at given index.
+ !fn: $setCurrentItem(<index:integer>)
+ Sets the current listbox item.
+ !fn: $clear()
+ Removes all the items
+ !fn: <boolean> $isSelected(<index:integer>)
+ Returns 1 if the item at <index> is selected and 0 otherwise
+ !fn: $setSelected(<index:integer>,<bSelected:boolean>)
+ Changes the selection status of the item at <index> to the value
+ specified by <bSelected>. If <bSelected> is 1 the item is selected,
+ if <bSelected> is 0 the item is unselected.
+ !fn: $selectionChangeEvent()
+ This function is called by KVIrc when the selection in the listbox changes.
+ !fn: $currentItemChangeEvent()
+ This function is called by KVIrc when the current item changes.
+ !fn: <index:integer> $onItemEvent()
+ This function is called by KVIrc when the current item pointed by the mouse changes and gives in $0 the item index.
+ !fn: <array:x,y,width,height> $itemRect(<item:index>)
+ Returns the rectangle on the screen that item occupies, or an invalid rectangle if item is 0 or is not currently visible.
+
+ @signals:
+ !sg: <string> $currentItemChange()
+ This signal is emitted by the default implementation of [classfnc]$currentItemChangeEvent[/classfnc]().[br]
+ !sg: <string> $onItem()
+ This signal is emitted by the default implementation of [classfnc]$onItemEvent[/classfnc]().[br]
+
+ */
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_listbox,"listbox","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"insertItem", functioninsertItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"changeItem", functionchangeItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"removeItem", functionremoveItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"clear", functionclear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"count", functioncount)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"currentText", functioncurrentText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"currentItem", functioncurrentItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"textAt", functiontextAt);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"itemAt", functionitemAt);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"itemRect", functionitemRect);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"setCurrentItem", functionsetCurrentItem);
+
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"setSelectionMode",functionsetSelectionMode);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"selectionMode",functionselectionMode);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"setSelected",functionsetSelected);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"isSelected",functionisSelected);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"currentItemChangeEvent",functioncurrentItemChangeEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"onItemEvent",functiononItemEvent);
+
+
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_listbox,"selectionChangeEvent")
+
+
+KVSO_END_REGISTERCLASS(KviKvsObject_listbox)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_listbox,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_listbox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_listbox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_listbox)
+
+bool KviKvsObject_listbox::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ KviTalListBox * b = new KviTalListBox(parentScriptWidget());
+ b->setSelectionMode(KviTalListBox::Single);
+ connect(b,SIGNAL(selectionChanged()),this,SLOT(selectionChanged()));
+ connect(b,SIGNAL(currentChanged(KviTalListBoxItem *)),this,SLOT(currentItemChanged(KviTalListBoxItem *)));
+
+ connect(b,SIGNAL(onItem(KviTalListBoxItem *)),this,SLOT(onItem(KviTalListBoxItem *)));
+
+ setObject(b,true);;
+ return true;
+}
+
+bool KviKvsObject_listbox::functioninsertItem(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iIndex;
+ QString szItem;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szItem)
+ KVSO_PARAMETER("index",KVS_PT_INT,KVS_PF_OPTIONAL,iIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalListBox *)widget())->insertItem(szItem, iIndex);
+ return true;
+}
+bool KviKvsObject_listbox::functionclear(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) ((KviTalListBox *)widget())->clear();
+ return true;
+}
+bool KviKvsObject_listbox::functionchangeItem(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t uIndex,cnt;
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if (szText.isEmpty()) c->warning(__tr2qs("No string parameter given - using empty string"));
+ if(uIndex >= (cnt = ((KviTalListBox *)widget())->count()))
+ {
+ c->warning(__tr2qs("Item index [%d] is too big - defaulting to " \
+ "$count() - 1 [%d]"), uIndex, cnt);
+ uIndex = cnt - 1;
+ }
+
+ ((KviTalListBox *)widget())->changeItem(szText, uIndex);
+
+ return true;
+
+}
+bool KviKvsObject_listbox::functionremoveItem(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t uIndex,cnt;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(uIndex >= (cnt = ((KviTalListBox *)widget())->count()))
+ {
+ c->warning(__tr2qs("Item index [%d] is too big - defaulting to " \
+ "$count() - 1 [%d]"), uIndex, cnt);
+ uIndex = cnt - 1;
+ }
+
+ ((KviTalListBox *)widget())->removeItem(uIndex);
+
+ return true;
+
+}
+
+bool KviKvsObject_listbox::functioncount(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((KviTalListBox *)widget())->count());
+ return true;
+}
+bool KviKvsObject_listbox::functioncurrentText(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setString(((KviTalListBox *)widget())->currentText().local8Bit().data());
+ return true;
+}
+bool KviKvsObject_listbox::functioncurrentItem(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((KviTalListBox *)widget())->currentItem());
+ return true;
+}
+
+bool KviKvsObject_listbox::functiontextAt(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ c->returnValue()->setString(((KviTalListBox *)widget())->text(uIndex));
+ return true;
+}
+bool KviKvsObject_listbox::functionsetCurrentItem(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalListBox *)widget())->setCurrentItem(uIndex);
+ return true;
+}
+bool KviKvsObject_listbox::functionsetSelectionMode(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("selection_mode",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ KviTalListBox::SelectionMode iMode = KviTalListBox::Single;
+
+ if(KviQString::equalCI(szMode,"single")) iMode = KviTalListBox::Single;
+
+ else if(KviQString::equalCI(szMode,"multi")) iMode = KviTalListBox::Multi;
+
+ else if(KviQString::equalCI(szMode,"extended")) iMode = KviTalListBox::Extended;
+
+ else if(KviQString::equalCI(szMode,"none")) iMode = KviTalListBox::NoSelection;
+
+ else c->warning(__tr2qs("Invalid selection mode '%Q' assuming single"),&szMode);
+ ((KviTalListBox *)widget())->setSelectionMode(iMode);
+
+ return true;
+}
+bool KviKvsObject_listbox::functionselectionMode(KviKvsObjectFunctionCall *c)
+{
+
+ if(!widget()) return true;
+ switch(((KviTalListBox *)widget())->selectionMode())
+ {
+ case KviTalListBox::Single: c->returnValue()->setString("single"); break;
+ case KviTalListBox::Multi: c->returnValue()->setString("multi"); break;
+ case KviTalListBox::Extended: c->returnValue()->setString("extended"); break;
+ case KviTalListBox::NoSelection: c->returnValue()->setString("none"); break;
+ default: c->returnValue()->setString("single"); break;
+ }
+ return true;
+}
+
+bool KviKvsObject_listbox::functionisSelected(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())c->returnValue()->setBoolean(((KviTalListBox *)widget())->isSelected(uIndex));
+ return true;
+}
+bool KviKvsObject_listbox::functionsetSelected(KviKvsObjectFunctionCall *c)
+{
+ bool bSel;
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETER("benabled",KVS_PT_BOOLEAN,0,bSel)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((KviTalListBox *)widget())->setSelected(uIndex,bSel);
+ return true;
+}
+bool KviKvsObject_listbox::functionitemAt(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uX,uY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("uX",KVS_PT_UNSIGNEDINTEGER,0,uX)
+ KVSO_PARAMETER("uY",KVS_PT_UNSIGNEDINTEGER,0,uY)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ c->returnValue()->setInteger(((KviTalListBox *)widget())->index(((KviTalListBox *)widget())->itemAt(QPoint(uX,uY))));
+ return true;
+}
+
+bool KviKvsObject_listbox::functioncurrentItemChangeEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("currentItemChange",c,c->params());
+
+ return true;
+}
+
+void KviKvsObject_listbox::selectionChanged()
+{
+ KviKvsVariantList *params=0;
+ callFunction(this,"selectionChangeEvent",0,0);
+}
+
+void KviKvsObject_listbox::currentItemChanged(KviTalListBoxItem *item)
+{
+ if (!item) callFunction(this,"currentItemChangeEvent",0,0);
+ else
+ {
+ KviKvsVariantList params(new KviKvsVariant(item->text()));
+ callFunction(this,"currentItemChangeEvent",0,&params);
+ }
+
+}
+bool KviKvsObject_listbox::functiononItemEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("onItem",c,c->params());
+
+ return true;
+}
+
+void KviKvsObject_listbox::onItem(KviTalListBoxItem *item)
+{
+ KviTalListBox *lbx = (KviTalListBox *)(item->listBox());
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)lbx->index(item)));
+ callFunction(this,"onItemEvent",0,&params);
+}
+
+
+bool KviKvsObject_listbox::functionitemRect(KviKvsObjectFunctionCall *c)
+{
+kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("uIndex",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ {
+ QRect rect=((KviTalListBox *)widget())->itemRect(((KviTalListBox *)widget())->item(uIndex));
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)rect.left()));
+ a->set(1,new KviKvsVariant((kvs_int_t)rect.top()));
+ a->set(2,new KviKvsVariant((kvs_int_t)rect.width()));
+ a->set(3,new KviKvsVariant((kvs_int_t)rect.height()));
+ c->returnValue()->setArray(a);
+ }
+ return true;
+}
+
+
+#include "m_class_listbox.moc"
diff --git a/src/modules/objects/class_listbox.h b/src/modules/objects/class_listbox.h
new file mode 100644
index 00000000..471337fd
--- /dev/null
+++ b/src/modules/objects/class_listbox.h
@@ -0,0 +1,70 @@
+#ifndef _CLASS_LISTBOX_H_
+#define _CLASS_LISTBOX_H_
+
+//vim: ts=8
+// File : class_listbox.h
+// Creation date : Sat Oct 2 03:40:28 CET 2004 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2004 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "class_widget.h"
+
+class KviTalListBox;
+class KviTalListBoxItem;
+
+#include "object_macros.h"
+
+class KviKvsObject_listbox: public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_listbox)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+
+ bool functioninsertItem(KviKvsObjectFunctionCall *c);
+ bool functionchangeItem(KviKvsObjectFunctionCall *c);
+ bool functionremoveItem(KviKvsObjectFunctionCall *c);
+ bool functioncount(KviKvsObjectFunctionCall *c);
+ bool functioncurrentText(KviKvsObjectFunctionCall *c);
+ bool functioncurrentItem(KviKvsObjectFunctionCall *c);
+ bool functiontextAt(KviKvsObjectFunctionCall *c);
+ bool functionsetCurrentItem(KviKvsObjectFunctionCall *c);
+ bool functionclear(KviKvsObjectFunctionCall *c);
+ bool functionsetSelectionMode(KviKvsObjectFunctionCall *c);
+ bool functionselectionMode(KviKvsObjectFunctionCall *c);
+ bool functionsetSelected(KviKvsObjectFunctionCall *c);
+ bool functionisSelected(KviKvsObjectFunctionCall *c);
+ bool functioncurrentItemChangeEvent(KviKvsObjectFunctionCall *c);
+ bool functiononItemEvent(KviKvsObjectFunctionCall *c);
+
+ bool functionitemAt(KviKvsObjectFunctionCall *c);
+ bool functionitemRect(KviKvsObjectFunctionCall *c);
+protected slots:
+ void selectionChanged();
+ void currentItemChanged(KviTalListBoxItem *);
+ void onItem(KviTalListBoxItem *);
+};
+
+
+#endif // !_CLASS_COMBOBOX_H_
diff --git a/src/modules/objects/class_listview.cpp b/src/modules/objects/class_listview.cpp
new file mode 100644
index 00000000..f571788c
--- /dev/null
+++ b/src/modules/objects/class_listview.cpp
@@ -0,0 +1,557 @@
+//=================================================================================
+//
+// File : class_listview.cpp
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2006 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2005-2006 Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=================================================================================
+
+
+#include "kvi_tal_listview.h"
+#ifdef COMPILE_USE_QT4
+#include <q3header.h>
+#include <qevent.h>
+#else
+#include <qheader.h>
+#endif
+#include "class_listview.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+
+
+/*
+ @doc: listview
+ @keyterms:
+ listview widget class
+ @title:
+ listview class
+ @type:
+ class
+ @short:
+ A listview class
+ @inherits:
+ [class]widget[/class]
+ @description:
+ It can display and control a hierarchy of multi-column items, and provides the ability to add new items at any time.
+ The items are added by creating children [class]listviewitem[/class] objects: simply allocating them with $new
+ will add the items to the listview and simply deleting them will remove them.
+ Allocating a [class]listviewitem[/class] item2 as a child of item1 will insert it to the same listview creating
+ a subtree of items spannig from item1. The subtree can be opened or closed by a simple click either
+ on the parent item or on the little plus sign on the side of it (when [classfnc:listview]$setRootIsDecorated[/classfnc]
+ is set to $true. The listview can be in Single, Multi, Extended or NoSelection selection mode.
+ In single selection mode there can be only one selected item at a time and the selected item is also
+ the current item (this mode is the default). In Multi and Extended selection mode there can be multiple selected items
+ and the current item is one of them. The difference between Multi and Extended is in the way
+ that items can be selected by the mouse actions: experiment with the two modes :).
+ The NoSelection mode has obviously no selection at all.
+ @functions:
+ !fn: $addColumn(<text_label:string> <width:unsigned integer>)
+ Adds a width pixels wide column with the column header label to the list view.
+
+ !fn: $setSorting(<column:integer>,<bAscending:boolean>)
+ Sets the list view to be sorted by column column in ascending order if ascending is 1 or descending order if it is FALSE.
+ If column is -1, sorting is disabled and the user cannot sort columns by clicking on the column headers
+
+ !fn: $hideListViewHeader()
+ Hide the listview column header.
+
+ !fn: $showListViewHeader()
+ Show the listview column header.
+
+ !fn: <boolean> $isListViewHeaderVisible()
+ Returns '1' if the listview header is currently visible. Otherwise this function returns '0'.
+
+ !fn: $setAllColumnsShowFocus(<bAllColumnsShowFocus:boolean>)
+ When the argument is $true, causes the listview to display the focus and selection
+ by highlighting all the columns of the item. When the argument is $false then
+ only the first column is selected/highlighted.
+
+ !fn: $setSelectionMode(<mode:string>)
+ Sets the selection mode for this listview. <mode> can be one of "Single","NoSelection","Multi" or "Extended".
+
+ !fn: <listviewitem> $selectedItem()
+ Returns the currently selected [class]listviewitem[/class] or $null if no items are selected.
+ This function works only if the list view is in single selection mode.
+
+ !fn: <listviewitem> $currentItem()
+ Returns the current [class]listviewitem[/class] or $null if no item is current at the moment.
+
+ !fn: <listviewitem> $firstChild()
+ Returns the first child [class]listviewitem[/class] of this listview or $null if there are no items at all.
+
+ !fn: $clickEvent(<item:object>)
+ This function is called when the user clicks in the list view.
+ In its argument the [class]listviewitem[/class] object clicked or 0 if the user didn't click on an item.[br]
+ The default implementation emits the [classfnc]$clicked[/classfnc]() signal.
+
+ !fn: $selectionChangedEvent(<item:object>)
+ This event handle whenever the set of selected items has changed.
+ The argument is the newly selected item if the listview is in single selection mode.[br]
+ When the listview is in Multi or Extended selection mode then item is always $null.[br]
+ The default implementation emits the [classfnc]$selectionChanged[/classfnc]() signal.
+
+ !fn: $currentChangedEvent(<item:object>)
+ This event are called whenever the current item has changed.
+ In its argument is the newly selected item or 0 if the change made no item current.[br]
+ The default implementation emits the [classfnc]$currentChanged[/classfnc]() signal.
+
+ !fn: $returnPressedEvent(<item:object>)
+ This function is called by the framework when the enter key is pressed.[br]
+ In its arument the currrent item.[br]
+ The default implementation emits the [classfnc]$returnPressed[/classfnc]() signal.
+
+ !fn: $spacePressedEvent(<item:object>)
+ This function is called by the framework when the space key is pressed.[br]
+ In its arument the currrent item.[br]
+ The default implementation emits the [classfnc]$spacePressed[/classfnc]() signal.
+
+ !fn: $onItemEvent(<item:object)
+ This event is called by framwork when the user moves the mouse cursor onto item.
+ The default implementation emits the [classfnc]$onItem[/classfnc]() signal.
+
+ !fn: $itemExpandedEvent(<item:object>)
+ This event is called when an item has been expanded, i.e. when the children of item are shown.
+ The default implementation emits the [classfnc]$expanded[/classfnc]() signal.
+
+ !fn: $itemCollapsedEvent(<item:object>)
+ This event is called when an item has been collapsed, i.e. when the children of item are hidden.
+ The default implementation emits the [classfnc]$collapsed[/classfnc]() signal.
+
+ !fn: $itemRenamedEvent(<item:object>,<col:integer>,<text:string>)
+ This event is called when the item has been renamed in text, e.g. by in in-place renaming, in column col.[br]
+ The default implementation emits the [classfnc]$itemRenamed[/classfnc]() signal.
+
+ !fn: $rightButtonClickEvent(<item:object>,<x:integer>,>y:integer>)
+ This signal is emitted when the right button is clicked.[br]
+ The arguments are the relevant item (may be 0), the point in global coordinates and the relevant column (or -1 if the click was outside the list).
+ The default implementation emits the [classfnc]$rightButtonClicked[/classfnc]() signal.
+ @signals:
+ !sg: $clicked()
+ This signal is emitted by the default implementation of [classfnc]$clickEvent[/classfnc]().
+ !sg: $selectionChanged()
+ This signal is emitted by the default implementation of [classfnc]$selectionChangedEvent[/classfnc]().
+ !sg: $currentChanged()
+ This signal is emitted by the default implementation of [classfnc]$currentChangedEvent[/classfnc]().
+ !sg: $returnPressed()
+ This signal is emitted by the default implementation of [classfnc]$returnPressedEvent[/classfnc]().
+ !sg: $spacePressed()
+ This signal is emitted by the default implementation of [classfnc]$spacePredssedEvent[/classfnc]().
+ !sg: $onItem()
+ This signal is emitted by the default implementation of [classfnc]$onItemEvent[/classfnc]().
+ !sg: $itemExpanded()
+ This signal is emitted by the default implementation of [classfnc]$itemExpandedEvent[/classfnc]().
+ !sg: $itemCollapsed()
+ This signal is emitted by the default implementation of [classfnc]$itemCollapsedEvent[/classfnc]().
+ !sg: $itemRenamed()
+ This signal is emitted by the default implementation of [classfnc]$itemRenamedEvent[/classfnc]().
+ !sg: $rightButtonClicked()
+ This signal is emitted by the default implementation of [classfnc]$rightButtonClickedEvent[/classfnc]().
+
+
+*/
+
+//---------------------------------------------------------------------------------
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_listview,"listview","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"addColumn",function_addColumn)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"setColumnText",function_setColumnText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"setSorting",function_setSorting)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"setRootIsDecorated",function_setRootIsDecorated)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"setAllColumnsShowFocus",function_setAllColumnsShowFocus)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"clear",function_clear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"selectedItem",function_selectedItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"currentItem",function_currentItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"setSelectionMode",function_setSelectionMode)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"listViewHeaderIsVisible",function_listViewHeaderIsVisible)
+
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"hideListViewHeader",function_hideListViewHeader)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"showListViewHeader",function_showListViewHeader)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"firstChild",function_firstChild)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"selectionChangedEvent",function_selectionChangedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"currentChangedEvent",function_currentChangedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"returnPressedEvent",function_returnPressedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"spacePressedEvent",function_spacePressedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"onItemEvent",function_onItemEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"itemClickedEvent",function_itemClickedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"itemExpandedEvent",function_itemExpandedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"itemCollapsedEvent",function_itemCollapsedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"itemRenamedEvent",function_itemRenamedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listview,"rightButtonClickedEvent",function_rightButtonClickedEvent);
+
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_listview,"fileDroppedEvent")
+
+KVSO_END_REGISTERCLASS(KviKvsObject_listview)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_listview,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_listview)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_listview)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_listview)
+
+bool KviKvsObject_listview::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new KviKvsMdmListView(parentScriptWidget(),name(),this),true);
+ connect(widget(),SIGNAL(clicked(KviTalListViewItem *)),this,SLOT(slotClicked(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(selectionChanged(KviTalListViewItem *)),this,SLOT(slotSelectionChanged(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(selectionChanged()),this,SLOT(slotMultipleSelectionChanged()));
+ connect(widget(),SIGNAL(currentChanged(KviTalListViewItem *)),this,SLOT(slotCurrentChanged(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(returnPressed(KviTalListViewItem *)),this,SLOT(slotReturnPressed(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(spacePressed(KviTalListViewItem *)),this,SLOT(slotSpacePressed(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(onItem(KviTalListViewItem *)),this,SLOT(slotOnItem(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(expanded(KviTalListViewItem *)),this,SLOT(slotItemExpanded(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(collapsed(KviTalListViewItem *)),this,SLOT(slotItemCollapsed(KviTalListViewItem *)));
+ connect(widget(),SIGNAL(rightButtonClicked(KviTalListViewItem *,const QPoint &,int)),this,SLOT(slotRightButtonClicked(KviTalListViewItem *,const QPoint &,int)));
+ connect(widget(),SIGNAL(itemRenamed(KviTalListViewItem *,int,const QString &)),this,SLOT(slotItemRenamed(KviTalListViewItem *,int,const QString &)));
+ return true;
+}
+
+bool KviKvsObject_listview::function_addColumn(KviKvsObjectFunctionCall *c)
+{
+ QString szLabel;
+ kvs_int_t iW;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETER("width",KVS_PT_INT,0,iW)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalListView *)object())->addColumn(szLabel,iW);
+ return true;
+}
+/*
+bool KviKvsObject_listview::function_setAcceptDrops(KviKvsObjectFunctionCall *c)
+{
+ bool bEnable;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnable",KVS_PT_BOOLEAN,0,bEnable)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalListView *)object())->setAcceptDrops(bEnable);
+ return true;
+}
+*/
+bool KviKvsObject_listview::function_clear(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ ((KviTalListView *)object())->clear();
+ return true;
+}
+
+bool KviKvsObject_listview::function_selectedItem(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setHObject(KviKvsObject_listviewitem::itemToHandle(((KviTalListView *)widget())->selectedItem()));
+ else
+ c->returnValue()->setHObject((kvs_hobject_t)0);
+ return true;
+}
+
+bool KviKvsObject_listview::function_firstChild(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setHObject(KviKvsObject_listviewitem::itemToHandle(((KviTalListView *)widget())->firstChild()));
+ else
+ c->returnValue()->setHObject((kvs_hobject_t)0);
+ return true;
+}
+
+bool KviKvsObject_listview::function_currentItem(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setHObject(KviKvsObject_listviewitem::itemToHandle(((KviTalListView *)widget())->currentItem()));
+ else
+ c->returnValue()->setHObject((kvs_hobject_t)0);
+ return true;
+}
+
+bool KviKvsObject_listview::function_setColumnText(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t uCol;
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())((KviTalListView *)widget())->setColumnText(uCol,szText);
+ return true;
+}
+
+bool KviKvsObject_listview::function_setSelectionMode(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("mode",KVS_PT_NONEMPTYSTRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szMode,"NoSelection"))
+ ((KviTalListView *)widget())->setSelectionMode(KviTalListView::NoSelection);
+ else if(KviQString::equalCI(szMode,"Multi"))
+ ((KviTalListView *)widget())->setSelectionMode(KviTalListView::Multi);
+ else if(KviQString::equalCI(szMode,"Extended"))
+ ((KviTalListView *)widget())->setSelectionMode(KviTalListView::Extended);
+ else if(KviQString::equalCI(szMode,"Single"))
+ ((KviTalListView *)widget())->setSelectionMode(KviTalListView::Single);
+ else c->warning(__tr2qs("Invalid selection mode '%Q'"),&szMode);
+ return true;
+}
+
+bool KviKvsObject_listview::function_setSorting(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iCol;
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_INT,0,iCol)
+ KVSO_PARAMETER("benabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalListView *)widget())->setSorting(iCol,bEnabled);
+ return true;
+}
+
+
+bool KviKvsObject_listview::function_setRootIsDecorated(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalListView *)widget())->setRootIsDecorated(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_listview::function_setAllColumnsShowFocus(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bAllColumnsShowFocus",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if (widget())((KviTalListView *)widget())->setAllColumnsShowFocus(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_listview::function_hideListViewHeader(KviKvsObjectFunctionCall *c)
+{
+// ((KviTalListView *)widget())->header()->hide();
+ return true;
+}
+bool KviKvsObject_listview::function_showListViewHeader(KviKvsObjectFunctionCall *c)
+{
+// ((KviTalListView *)widget())->header()->show();
+ return true;
+}
+bool KviKvsObject_listview::function_listViewHeaderIsVisible(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setBoolean(((KviTalListView *)widget())->header()->isVisible());
+ return true;
+}
+
+bool KviKvsObject_listview::function_itemClickedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("itemClicked",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotClicked(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"itemClickedEvent",0,&params);
+}
+
+bool KviKvsObject_listview::function_selectionChangedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("selectionChanged",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotSelectionChanged(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"selectionChangedEvent",0,&params);
+}
+
+void KviKvsObject_listview::slotMultipleSelectionChanged()
+{
+ KviKvsVariantList params(new KviKvsVariant((kvs_hobject_t)0));
+ callFunction(this,"selectionChangedEvent",0,&params);
+}
+
+
+bool KviKvsObject_listview::function_currentChangedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("currentChanged",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotCurrentChanged(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"currentChangedEvent",0,&params);
+}
+
+
+bool KviKvsObject_listview::function_returnPressedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("returnPressed",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotReturnPressed(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"returnPressedEvent",0,&params);
+}
+
+bool KviKvsObject_listview::function_spacePressedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("spacePressed",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotSpacePressed(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"spacePressedEvent",0,&params);
+}
+
+bool KviKvsObject_listview::function_onItemEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("onItem",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotOnItem(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"onItemEvent",0,&params);
+}
+
+
+bool KviKvsObject_listview::function_itemExpandedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("itemExpanded",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotItemExpanded(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"itemExpandedEvent",0,&params);
+}
+
+bool KviKvsObject_listview::function_itemCollapsedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("itemCollapsed",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotItemCollapsed(KviTalListViewItem * i)
+{
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)));
+ callFunction(this,"itemCollapsedEvent",0,&params);
+}
+
+bool KviKvsObject_listview::function_rightButtonClickedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("rightButtonClicked",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotRightButtonClicked(KviTalListViewItem * i,const QPoint &coor, int col)
+{
+ KviKvsVariant *xpos=new KviKvsVariant((kvs_int_t)coor.x());
+ KviKvsVariant *ypos=new KviKvsVariant((kvs_int_t)coor.y());
+ KviKvsVariant *column=new KviKvsVariant((kvs_int_t)col);
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(i)),xpos,ypos,column);
+ callFunction(this,"rightButtonClickedEvent",0,&params);
+}
+
+bool KviKvsObject_listview::function_itemRenamedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("itemRenamed",c,c->params());
+ return true;
+}
+
+void KviKvsObject_listview::slotItemRenamed(KviTalListViewItem *item,int col,const QString & szText)
+{
+ KviKvsVariant *column=new KviKvsVariant((kvs_int_t)col);
+ KviKvsVariant *txt=new KviKvsVariant(szText);
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(item)),column,txt);
+ callFunction(this,"itemRenamedEvent",0,&params);
+}
+void KviKvsObject_listview::fileDropped(QString &szFile,KviTalListViewItem *item)
+{
+ KviKvsVariant *file=new KviKvsVariant(szFile);
+ KviKvsVariantList params(new KviKvsVariant(KviKvsObject_listviewitem::itemToHandle(item)),file);
+ callFunction(this,"fileDroppedEvent",0,&params);
+}
+
+KviKvsMdmListView::KviKvsMdmListView(QWidget * par,const char * name,KviKvsObject_listview *parent)
+:KviTalListView(par)
+{
+ m_pParentScript=parent;
+ setAcceptDrops(true);
+ viewport()->setAcceptDrops( TRUE );
+
+}
+KviKvsMdmListView::~KviKvsMdmListView()
+{
+}
+
+void KviKvsMdmListView::contentsDragEnterEvent( QDragEnterEvent *e )
+{
+ if ( !KviUriDrag::canDecode(e))
+ {
+ e->ignore();
+ return;
+ }
+
+}
+
+
+void KviKvsMdmListView::contentsDropEvent(QDropEvent *e)
+{
+ QStringList list;
+ if(KviUriDrag::decodeLocalFiles(e,list))
+ {
+ if(!list.isEmpty())
+ {
+ QStringList::ConstIterator it = list.begin(); //kewl ! :)
+ for( ; it != list.end(); ++it )
+ {
+ QString tmp = *it; //wow :)
+ #ifndef COMPILE_ON_WINDOWS
+ if(tmp[0] != '/')tmp.prepend("/"); //HACK HACK HACK for Qt bug (?!?)
+ #endif
+ KviTalListViewItem *i = itemAt( contentsToViewport(e->pos()) );
+ m_pParentScript->fileDropped(tmp,i);
+ }
+ }
+ }
+
+}
+#include "m_class_listview.moc"
diff --git a/src/modules/objects/class_listview.h b/src/modules/objects/class_listview.h
new file mode 100644
index 00000000..7849f36c
--- /dev/null
+++ b/src/modules/objects/class_listview.h
@@ -0,0 +1,102 @@
+#ifndef _CLASS_LISTVIEW_H_
+#define _CLASS_LISTVIEW_H_
+//=================================================================================
+//
+// File : class_listview.h
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2006 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2005-2006 Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=================================================================================
+
+#include "kvi_tal_listview.h"
+#include "kvi_draganddrop.h"
+#include "class_widget.h"
+#include "class_listviewitem.h"
+
+#include "object_macros.h"
+
+class KviKvsObject_listview : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_listview)
+
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+ void fileDropped(QString &,KviTalListViewItem *);
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool function_addColumn(KviKvsObjectFunctionCall *c);
+ bool function_setColumnText(KviKvsObjectFunctionCall *c);
+ bool function_takeItem(KviKvsObjectFunctionCall *c);
+ bool function_setSorting(KviKvsObjectFunctionCall *c);
+ bool function_setRootIsDecorated(KviKvsObjectFunctionCall *c);
+ bool function_clear(KviKvsObjectFunctionCall *c);
+ bool function_setAllColumnsShowFocus(KviKvsObjectFunctionCall *c);
+ bool function_itemClickedEvent(KviKvsObjectFunctionCall *c);
+ bool function_selectionChangedEvent(KviKvsObjectFunctionCall *c);
+ bool function_currentChangedEvent(KviKvsObjectFunctionCall *c);
+ bool function_returnPressedEvent(KviKvsObjectFunctionCall *c);
+ bool function_spacePressedEvent(KviKvsObjectFunctionCall *c);
+ bool function_onItemEvent(KviKvsObjectFunctionCall *c);
+ bool function_itemExpandedEvent(KviKvsObjectFunctionCall *c);
+ bool function_itemCollapsedEvent(KviKvsObjectFunctionCall *c);
+ bool function_itemRenamedEvent(KviKvsObjectFunctionCall *c);
+ bool function_rightButtonClickedEvent(KviKvsObjectFunctionCall *c);
+ bool function_selectedItem(KviKvsObjectFunctionCall *c);
+ bool function_currentItem(KviKvsObjectFunctionCall *c);
+ bool function_setSelectionMode(KviKvsObjectFunctionCall *c);
+ bool function_firstChild(KviKvsObjectFunctionCall *c);
+ bool function_listViewHeaderIsVisible(KviKvsObjectFunctionCall *c);
+ bool function_showListViewHeader(KviKvsObjectFunctionCall *c);
+ bool function_hideListViewHeader(KviKvsObjectFunctionCall *c);
+
+ bool function_setAcceptDrops(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void slotClicked(KviTalListViewItem *);
+ void slotSelectionChanged(KviTalListViewItem *);
+ void slotMultipleSelectionChanged();
+ void slotCurrentChanged(KviTalListViewItem *);
+ void slotReturnPressed(KviTalListViewItem *);
+ void slotSpacePressed(KviTalListViewItem *);
+ void slotOnItem(KviTalListViewItem *);
+ void slotItemExpanded(KviTalListViewItem *);
+ void slotItemCollapsed(KviTalListViewItem *);
+ void slotItemRenamed(KviTalListViewItem *,int,const QString &);
+ void slotRightButtonClicked(KviTalListViewItem * i,const QPoint &coor, int col);
+};
+
+class KviKvsMdmListView : public KviTalListView
+{
+ Q_OBJECT
+public:
+ KviKvsMdmListView(QWidget * par,const char * name,KviKvsObject_listview *);
+
+ virtual ~KviKvsMdmListView();
+protected:
+ KviKvsObject_listview *m_pParentScript;
+ void contentsDropEvent(QDropEvent *e);
+ void contentsDragEnterEvent( QDragEnterEvent *e );
+
+};
+#endif //!_CLASS_LISTVIEW_H_
diff --git a/src/modules/objects/class_listviewitem.cpp b/src/modules/objects/class_listviewitem.cpp
new file mode 100644
index 00000000..31df9020
--- /dev/null
+++ b/src/modules/objects/class_listviewitem.cpp
@@ -0,0 +1,421 @@
+//mdm:
+// File : class_ListViewItem.h
+// Creation date : Thu Feb 1 14:39:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+#include "class_listviewitem.h"
+#include "class_pixmap.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+
+
+/*
+ @doc: listviewitem
+ @keyterms:
+ listview listviewitem class
+ @title:
+ listviewitem class
+ @type:
+ class
+ @short:
+ A listviewitem class
+ @inherits:
+ [class]listviewitem[/class]
+ @description:
+ The listviewitem class implements a list view item.
+ A list view item is a multi-column object capable of displaying itself in a [class]listview[/class].
+ To use this class you must instantiate it with another listviewitem or a [class]listview[/class]
+ as parent. The item will be automatically displayed.
+ You can set the text and a pixmap in each column and you can make it checkable
+ with [classfnc:listviewitem]$setCheckable[/classfnc]().
+ A checkable listviewitem will display a small check mark in the first column.
+ @functions:
+ !fn: $setText(<column:integer>,<text:string>)
+ Sets the text in column column to text, if column is a valid column number and text is different from the existing text.
+
+ !fn: <string> $text(<column:integer>)
+ Returs the text of the specified column.
+
+ !fn: $setPixmap(<column:integer>,<pixmap:hobject or imageID>)
+ Sets the pixmap in column column to pm, if pm is non-null and different from the current pixmap, and if column is non-negative.
+ Pixmap can be a Kvirc imageid, an image file or a [class]pixmap[/class] object.
+
+ !fn: $setRenameEnabled(<col:integer>,<bEnabled:boolean>)
+ If b is TRUE (1), this item can be in-place renamed in the column col by the user; otherwise it cannot be renamed in-place.
+
+ !fn: $setEnabled(<bEnabled:boolean>)
+ Enables or disables the item
+
+ !fn: $isEnabled()
+ Returns $true if this item is enabled and $false otherwise
+
+ !fn: $setOpen(<bOpen:boolean>)
+ Opens or closes the item to show its children items
+
+ !fn: $isOpen()
+ Returns the open state of this item
+
+ !fn: $setCheckable(<bCheckable:boolean>)
+ Makes this item checkable or not. This function should be called immediately
+ after the item creation: changing this property later at runtime may have
+ strange results (like the item being moved inside the list, text disappearing,
+ hidden children etc... don't do it :D ).
+
+ !fn: $isCheckable()
+ Returns $true if this item is checkable and $false otherwise
+
+ !fn: $setChecked(<bChecked:boolean>)
+ Sets this item to be checked or not. [classfnc:listviewitem]$setCheckable[/classfnc]() must
+ have been previously called.
+
+ !fn: $isChecked()
+ Returns the check status of this item. [classfnc:listviewitem]$setCheckable[/classfnc]() must
+ have been previously called.
+
+ !fn: <listviewitem> $firstChild()
+ Returns the first child item of this listviewitem or $null if this item has no children.
+
+ !fn: <listviewitem> $nextSibling()
+ Returns the next sibling item of this listviewitem or $null if there are no sibling items.
+ Next sibling stands for the item at the same tree level coming just after :)
+*/
+
+
+//===========================================================================================
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_listviewitem,"listviewitem","object")
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"setText",function_setText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"text",function_text)
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"setPixmap",function_setPixmap);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"setRenameEnabled",function_setRenameEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"setEnabled",function_setEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"isEnabled",function_isEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"setOpen",function_setOpen);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"isOpen",function_isOpen);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"setCheckable",function_setCheckable);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"isCheckable",function_isCheckable);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"setChecked",function_setChecked);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"isChecked",function_isChecked);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"firstChild",function_firstChild);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listviewitem,"nextSibling",function_nextSibling);
+KVSO_END_REGISTERCLASS(KviKvsObject_listviewitem)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_listviewitem,KviKvsObject)
+
+ m_pListViewItem = 0;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_listviewitem)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_listviewitem)
+
+ if(m_pListViewItem)delete m_pListViewItem;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_listviewitem)
+
+bool KviKvsObject_listviewitem::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ if (!parentObject())
+ {
+ pContext->error(__tr2qs("The listviewitem cannot be parentless"));
+ return false;
+ }
+ if(parentObject()->inherits("KviKvsObject_listviewitem"))
+ {
+ m_pListViewItem = new KviKvsMdmStandardListViewItem(this,((KviKvsObject_listviewitem *)parentObject())->m_pListViewItem);
+ } else {
+ if(parentObject()->inherits("KviKvsObject_listview"))
+ m_pListViewItem = new KviKvsMdmStandardListViewItem(this,((KviTalListView *)parentScriptWidget()));
+ else {
+ pContext->error(__tr2qs("The parent of the listviewitem must be either another listviewitem or a listview"));
+ return false;
+ }
+ }
+ return true;
+}
+
+void KviKvsObject_listviewitem::childDestroyed()
+{
+ if(m_pListViewItem == 0)return;
+ m_pListViewItem = 0;
+ die();
+}
+
+KviKvsMdmStandardListViewItem::KviKvsMdmStandardListViewItem(KviKvsObject_listviewitem * ob,KviTalListView * par)
+:KviTalListViewItem(par), m_pMasterObject(ob)
+{
+}
+
+KviKvsMdmStandardListViewItem::KviKvsMdmStandardListViewItem(KviKvsObject_listviewitem * ob,KviTalListViewItem * par)
+:KviTalListViewItem(par), m_pMasterObject(ob)
+{
+}
+
+KviKvsMdmStandardListViewItem::~KviKvsMdmStandardListViewItem()
+{
+ if(m_pMasterObject)m_pMasterObject->childDestroyed();
+}
+
+
+
+KviKvsMdmCheckListViewItem::KviKvsMdmCheckListViewItem(KviKvsObject_listviewitem * ob,KviTalListView * par)
+:KviTalCheckListItem(par,QString::null,KviTalCheckListItem::CheckBox), m_pMasterObject(ob)
+{
+}
+
+KviKvsMdmCheckListViewItem::KviKvsMdmCheckListViewItem(KviKvsObject_listviewitem * ob,KviTalListViewItem * par)
+:KviTalCheckListItem(par,QString::null,KviTalCheckListItem::CheckBox), m_pMasterObject(ob)
+{
+}
+
+KviKvsMdmCheckListViewItem::~KviKvsMdmCheckListViewItem()
+{
+ if(m_pMasterObject)m_pMasterObject->childDestroyed();
+}
+
+
+kvs_hobject_t KviKvsObject_listviewitem::itemToHandle(KviTalListViewItem * it)
+{
+ if(!it)return (kvs_hobject_t)0;
+ KviKvsObject_listviewitem * pObject;
+ if(it->rtti() == 1)pObject = ((KviKvsMdmCheckListViewItem *)it)->masterObject();
+ else pObject = ((KviKvsMdmStandardListViewItem *)it)->masterObject();
+ if(!pObject)return (kvs_hobject_t)0;
+ return pObject->handle();
+}
+
+
+bool KviKvsObject_listviewitem::function_setText(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uCol;
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if(m_pListViewItem)
+ m_pListViewItem->setText(uCol,szText);
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_firstChild(KviKvsObjectFunctionCall *c)
+{
+ if(m_pListViewItem)
+ c->returnValue()->setHObject(itemToHandle(m_pListViewItem->firstChild()));
+ else
+ c->returnValue()->setHObject((kvs_hobject_t)0);
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_nextSibling(KviKvsObjectFunctionCall *c)
+{
+ if(m_pListViewItem)
+ c->returnValue()->setHObject(itemToHandle(m_pListViewItem->nextSibling()));
+ else
+ c->returnValue()->setHObject((kvs_hobject_t)0);
+ return true;
+}
+
+
+bool KviKvsObject_listviewitem::function_setRenameEnabled(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uCol;
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(m_pListViewItem)
+ m_pListViewItem->setRenameEnabled(uCol,bEnabled);
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_setEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(m_pListViewItem)
+ m_pListViewItem->setEnabled(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_isEnabled(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pListViewItem)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pListViewItem->isEnabled());
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_setOpen(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(m_pListViewItem)
+ m_pListViewItem->setOpen(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_isOpen(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pListViewItem)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pListViewItem->isOpen());
+ return true;
+}
+
+
+bool KviKvsObject_listviewitem::function_setChecked(KviKvsObjectFunctionCall *c)
+{
+ bool bChecked;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bChecked",KVS_PT_BOOL,0,bChecked)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pListViewItem)return true;
+ if(m_pListViewItem->rtti() != 1)return true; // not a QCheckListItem
+ ((KviKvsMdmCheckListViewItem *)m_pListViewItem)->setOn(bChecked);
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_isChecked(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pListViewItem)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ if(m_pListViewItem->rtti() != 1)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(((KviKvsMdmCheckListViewItem *)m_pListViewItem)->isOn());
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_setCheckable(KviKvsObjectFunctionCall *c)
+{
+ bool bCheckable;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bCheckable",KVS_PT_BOOL,0,bCheckable)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pListViewItem)return true;
+ if(bCheckable)
+ {
+ if(m_pListViewItem->rtti() == 1)return true; // a QCheckListItem already
+ KviTalListViewItem * pParent = m_pListViewItem->parent();
+ KviTalListView * pLV = (KviTalListView *)m_pListViewItem->listView();
+ // swap the items, so we don't die now
+ KviTalListViewItem * pThis = m_pListViewItem;
+ m_pListViewItem = 0;
+ delete pThis;
+ if(pParent)
+ m_pListViewItem = new KviKvsMdmCheckListViewItem(this,pParent);
+ else
+ m_pListViewItem = new KviKvsMdmCheckListViewItem(this,pLV);
+ } else {
+ if(m_pListViewItem->rtti() != 1)return true; // not a QCheckListItem yet
+ KviTalListViewItem * pParent = m_pListViewItem->parent();
+ KviTalListView * pLV = (KviTalListView *)m_pListViewItem->listView();
+ // swap the items, so we don't die now
+ KviTalListViewItem * pThis = m_pListViewItem;
+ m_pListViewItem = 0;
+ delete pThis;
+ if(pParent)
+ m_pListViewItem = new KviKvsMdmStandardListViewItem(this,pParent);
+ else
+ m_pListViewItem = new KviKvsMdmStandardListViewItem(this,pLV);
+ }
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_isCheckable(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pListViewItem)
+ {
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ c->returnValue()->setBoolean(m_pListViewItem->rtti() == 1);
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_text(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uCol;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETERS_END(c)
+ if(m_pListViewItem)
+ c->returnValue()->setString(m_pListViewItem->text(uCol));
+ return true;
+}
+
+bool KviKvsObject_listviewitem::function_setPixmap(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uCol;
+ KviKvsObject *obPixmap;
+ kvs_hobject_t obHpixmap;
+ KviKvsVariant * vPixmap;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("pixmap",KVS_PT_VARIANT,0,vPixmap)
+ KVSO_PARAMETERS_END(c)
+ QPixmap *pix = 0;
+ if(vPixmap->isHObject())
+ {
+ vPixmap->asHObject(obHpixmap);
+ obPixmap=KviKvsKernel::instance()->objectController()->lookupObject(obHpixmap);
+ if (!obPixmap->inherits("KviKvsObject_pixmap"))
+ {
+ c->warning(__tr2qs("Pixmap object or image Id required"));
+ return true;
+ }
+ pix=((KviKvsObject_pixmap *)obPixmap)->getPixmap();
+ } else {
+ QString szPix;
+ vPixmap->asString(szPix);
+ pix=g_pIconManager->getImage(szPix);
+ if(!pix)
+ {
+ c->warning(__tr2qs("Error occured: the suitable file '%Q' is not of the correct format or it is not a valid icon number."),&szPix);
+ return true;
+ }
+ }
+ m_pListViewItem->setPixmap(uCol,*pix);
+ return true;
+}
+
+#include "m_class_listviewitem.moc"
diff --git a/src/modules/objects/class_listviewitem.h b/src/modules/objects/class_listviewitem.h
new file mode 100644
index 00000000..eb806324
--- /dev/null
+++ b/src/modules/objects/class_listviewitem.h
@@ -0,0 +1,88 @@
+#ifndef _CLASS_LISTVIEWITEM_H_
+#define _CLASS_LISTVIEWITEM_H_
+//mdm:
+// File : class_ListViewItem.h
+// Creation date : Thu Feb 1 14:39:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+#include "kvi_tal_listview.h"
+#include "class_widget.h"
+
+
+
+#include "object_macros.h"
+
+class KviKvsObject_listviewitem : public KviKvsObject
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_listviewitem)
+ void childDestroyed();
+protected:
+ KviTalListViewItem * m_pListViewItem;
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+protected:
+ bool function_setText(KviKvsObjectFunctionCall *c);
+ bool function_insertItem(KviKvsObjectFunctionCall *c);
+ bool function_setPixmap(KviKvsObjectFunctionCall *c);
+ bool function_setRenameEnabled(KviKvsObjectFunctionCall *c);
+ bool function_setEnabled(KviKvsObjectFunctionCall *c);
+ bool function_isEnabled(KviKvsObjectFunctionCall *c);
+ bool function_setOpen(KviKvsObjectFunctionCall *c);
+ bool function_isOpen(KviKvsObjectFunctionCall *c);
+ bool function_text(KviKvsObjectFunctionCall *c);
+ bool function_setCheckable(KviKvsObjectFunctionCall *c);
+ bool function_isCheckable(KviKvsObjectFunctionCall *c);
+ bool function_setChecked(KviKvsObjectFunctionCall *c);
+ bool function_isChecked(KviKvsObjectFunctionCall *c);
+ bool function_firstChild(KviKvsObjectFunctionCall *c);
+ bool function_nextSibling(KviKvsObjectFunctionCall *c);
+public:
+ static kvs_hobject_t itemToHandle(KviTalListViewItem * it);
+};
+
+
+
+class KviKvsMdmStandardListViewItem : public KviTalListViewItem
+{
+public:
+ KviKvsMdmStandardListViewItem(KviKvsObject_listviewitem * ob,KviTalListView * par);
+ KviKvsMdmStandardListViewItem(KviKvsObject_listviewitem * ob,KviTalListViewItem * par);
+ virtual ~KviKvsMdmStandardListViewItem();
+protected:
+ KviKvsObject_listviewitem * m_pMasterObject;
+public:
+ KviKvsObject_listviewitem * masterObject(){ return m_pMasterObject; }
+};
+
+class KviKvsMdmCheckListViewItem : public KviTalCheckListItem
+{
+public:
+ KviKvsMdmCheckListViewItem(KviKvsObject_listviewitem * ob,KviTalListView * par);
+ KviKvsMdmCheckListViewItem(KviKvsObject_listviewitem * ob,KviTalListViewItem * par);
+ virtual ~KviKvsMdmCheckListViewItem();
+protected:
+ KviKvsObject_listviewitem * m_pMasterObject;
+public:
+ KviKvsObject_listviewitem * masterObject(){ return m_pMasterObject; }
+};
+
+#endif // !_CLASS_LISTVIEWITEM_H_
diff --git a/src/modules/objects/class_mainwindow.cpp b/src/modules/objects/class_mainwindow.cpp
new file mode 100644
index 00000000..e30f480b
--- /dev/null
+++ b/src/modules/objects/class_mainwindow.cpp
@@ -0,0 +1,158 @@
+//mdm:
+// File : class_mainwindow.cpp
+// Creation date : Mon Feb 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "kvi_tal_mainwindow.h"
+#include "class_mainwindow.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+
+/*
+ @doc: mainwindow
+ @keyterms:
+ mainwindow object class,
+ @title:
+ mainwindow class
+ @type:
+ class
+ @short:
+ Provides a mainwindow.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ The mainwindow class provides a main application window, with menubar, toolbars.
+ @functions:
+ !fn: $setCentralWidget(<widget:object>)
+ Sets the central widget for the main window to <wid>.
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_mainwindow,"mainwindow","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_mainwindow,"setCentralWidget",functionsetCentralWidget)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mainwindow,"setDockEnabled",functionsetDockEnabled)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mainwindow,"isDockEnabled",functionisDockEnabled)
+
+KVSO_END_REGISTERCLASS(KviKvsObject_mainwindow)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_mainwindow,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_mainwindow)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_mainwindow)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_mainwindow)
+
+bool KviKvsObject_mainwindow::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new KviTalMainWindow(parentScriptWidget(), name()), true);
+ return true;
+}
+
+bool KviKvsObject_mainwindow::functionsetCentralWidget(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject * pObject;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!pObject->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!pObject->object()->inherits("KviKvsObject_widget"))
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return TRUE;
+ }
+ if(widget()) ((KviTalMainWindow *)widget())->setCentralWidget(((QWidget *)(pObject->object())));
+ return true;
+}
+bool KviKvsObject_mainwindow::functionsetDockEnabled(KviKvsObjectFunctionCall *c)
+{
+ QString szDockarea;
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("dock area",KVS_PT_STRING,0,szDockarea)
+ KVSO_PARAMETER("bool enabled",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ {
+#ifndef COMPILE_USE_QT4
+ if(KviQString::equalCI(szDockarea,"Top"))
+ ((KviTalMainWindow *)widget())->setDockEnabled(Qt::DockTop,bFlag);
+ else if(KviQString::equalCI(szDockarea,"Left"))
+ ((KviTalMainWindow *)widget())->setDockEnabled(Qt::DockLeft,bFlag);
+ else if(KviQString::equalCI(szDockarea,"Right"))
+ ((KviTalMainWindow *)widget())->setDockEnabled(Qt::DockRight,bFlag);
+ else if(KviQString::equalCI(szDockarea,"Bottom"))
+ ((KviTalMainWindow *)widget())->setDockEnabled(Qt::DockBottom,bFlag);
+ else if(KviQString::equalCI(szDockarea,"Minimized"))
+ ((KviTalMainWindow *)widget())->setDockEnabled(Qt::DockMinimized,bFlag);
+ else if(KviQString::equalCI(szDockarea,"TornOff"))
+ ((KviTalMainWindow *)widget())->setDockEnabled(Qt::DockTornOff,bFlag);
+ else if(KviQString::equalCI(szDockarea,"Unmanaged"))
+ ((KviTalMainWindow *)widget())->setDockEnabled(Qt::DockUnmanaged,bFlag);
+ else c->warning(__tr2qs("Unknown dock area '%Q'"),&szDockarea);
+#endif
+ }
+ return true;
+
+}
+bool KviKvsObject_mainwindow::functionisDockEnabled(KviKvsObjectFunctionCall *c)
+{
+
+ QString szDockarea;
+ bool bFlag = false;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("dock_area",KVS_PT_STRING,0,szDockarea)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+#ifndef COMPILE_USE_QT4
+ if(KviQString::equalCI(szDockarea,"Top")) bFlag=((KviTalMainWindow *)widget())->isDockEnabled(Qt::DockTop);
+ else if(KviQString::equalCI(szDockarea,"Left")) bFlag=((KviTalMainWindow *)widget())->isDockEnabled(Qt::DockLeft);
+ else if(KviQString::equalCI(szDockarea,"Right")) bFlag=((KviTalMainWindow *)widget())->isDockEnabled(Qt::DockRight);
+ else if(KviQString::equalCI(szDockarea,"Bottom"))bFlag=((KviTalMainWindow *)widget())->isDockEnabled(Qt::DockBottom);
+ else if(KviQString::equalCI(szDockarea,"Minimized")) bFlag=((KviTalMainWindow *)widget())->isDockEnabled(Qt::DockMinimized);
+ else if(KviQString::equalCI(szDockarea,"TornOff")) bFlag=((KviTalMainWindow *)widget())->isDockEnabled(Qt::DockTornOff);
+ else if(KviQString::equalCI(szDockarea,"Unmanaged")) bFlag=((KviTalMainWindow *)widget())->isDockEnabled(Qt::DockUnmanaged);
+ else
+ {
+ c->warning(__tr2qs("Unknown dock area '%Q'"),&szDockarea);
+ return true;
+ }
+#endif
+ c->returnValue()->setBoolean(bFlag);
+ return true;
+
+}
diff --git a/src/modules/objects/class_mainwindow.h b/src/modules/objects/class_mainwindow.h
new file mode 100644
index 00000000..7afddf8c
--- /dev/null
+++ b/src/modules/objects/class_mainwindow.h
@@ -0,0 +1,47 @@
+#ifndef _CLASS_MAINWINDOW_H_
+#define _CLASS_MAINWINDOW_H_
+//
+// File : class_mainwindow.h
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+//#include <qmainwindow.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_mainwindow : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_mainwindow)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionsetCentralWidget(KviKvsObjectFunctionCall *c);
+ bool functionsetDockEnabled(KviKvsObjectFunctionCall *c);
+ bool functionisDockEnabled(KviKvsObjectFunctionCall *c);
+
+};
+
+
+#endif //!_CLASS_MAINWINDOW_H_
+
diff --git a/src/modules/objects/class_menubar.cpp b/src/modules/objects/class_menubar.cpp
new file mode 100644
index 00000000..90ad0e7d
--- /dev/null
+++ b/src/modules/objects/class_menubar.cpp
@@ -0,0 +1,76 @@
+//
+// File : class_menubar.cpp
+// Creation date : Tue Now 26 13:16:59 CEST 2002 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include "class_menubar.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+
+/*
+ @doc: menubar
+ @title:
+ menubar class
+ @type:
+ class
+ @short:
+ A menu bar object implementation
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+
+ @functions:
+ !fn: <integer> $insertItem(<text:string>)
+ Returns an integer that identifies the inserted item.
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_menubar,"menubar","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_menubar,"inserItem",functionInsertItem)
+KVSO_END_REGISTERCLASS(KviKvsObject_menubar)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_menubar,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_menubar)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_menubar)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_menubar)
+
+bool KviKvsObject_menubar::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QMenuBar(parentScriptWidget(), name()));
+ return true;
+}
+
+bool KviKvsObject_menubar::functionInsertItem(KviKvsObjectFunctionCall *c)
+{
+ QString szItem;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("item",KVS_PT_STRING,0,szItem)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QMenuBar *)widget())->insertItem(szItem);
+ return true;
+}
diff --git a/src/modules/objects/class_menubar.h b/src/modules/objects/class_menubar.h
new file mode 100644
index 00000000..c959d272
--- /dev/null
+++ b/src/modules/objects/class_menubar.h
@@ -0,0 +1,40 @@
+#ifndef _CLASS_MENUBAR_H_
+#define _CLASS_MENUBAR_H_
+//
+// File : class_menubar.h
+// Creation date : Tue Now 26 13:15:48 CEST 2002 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <qmenubar.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_menubar : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_menubar)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionInsertItem(KviKvsObjectFunctionCall *c);
+};
+#endif // !_CLASS_MENUBAR_H_
diff --git a/src/modules/objects/class_multilineedit.cpp b/src/modules/objects/class_multilineedit.cpp
new file mode 100644
index 00000000..6b2f8af9
--- /dev/null
+++ b/src/modules/objects/class_multilineedit.cpp
@@ -0,0 +1,1217 @@
+//vim: ts=8
+// File : class_multilineedit.cpp
+// Creation date : Mon Feb 19 00:45:34 CET by Krzysztof Godlewski
+//
+// Modification date: Thu 15 Feb 2005 22:00 :00
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "kvi_error.h"
+#include "kvi_debug.h"
+#include "kvi_locale.h"
+#include "kvi_malloc.h"
+#include <qfile.h>
+#ifdef COMPILE_USE_QT4
+ #include <q3multilineedit.h>
+#include <QTextStream>
+
+#include <q3stylesheet.h>
+#define KviTalMultiLineEdit Q3MultiLineEdit
+#define QTEXTEDIT_AUTO_ALL Q3TextEdit::AutoAll
+#define QTEXTEDIT_AUTO_NONE Q3TextEdit::AutoNone
+#define QTEXTEDIT_AUTO_BULLET_LIST Q3TextEdit::AutoBulletList
+
+#else
+ #include <qtextstream.h>
+
+ #include <qmultilineedit.h>
+ #define KviTalMultiLineEdit QMultiLineEdit
+ #define QTEXTEDIT_AUTO_ALL QTextEdit::AutoAll
+ #define QTEXTEDIT_AUTO_NONE QTextEdit::AutoNone
+ #define QTEXTEDIT_AUTO_BULLET_LIST QTextEdit::AutoBulletList
+
+#endif
+
+
+#include "class_multilineedit.h"
+
+
+//->Tables for Text Format
+static char * const mod_tbl[] = {
+ "PlainText",
+ "RichText",
+ "AutoText",
+ "LogText"
+ };
+
+static int mod_cod[] = {
+ Qt::PlainText,
+ Qt::RichText,
+ Qt::AutoText,
+ Qt::LogText
+ };
+
+#define mod_num (sizeof(mod_tbl) / sizeof(mod_tbl[0]))
+
+
+
+/*
+ @doc: multilineedit
+ @keyterms:
+ multilineedit object class, line editor, input
+ @title:
+ multilineedit class
+ @type:
+ class
+ @short:
+ An editor for inputting larger portions of text
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This is class an editor for inputting larger portions of text.
+ Besides that, it has unfinished docs.
+ @functions:
+ !fn: <string> $textLine(<line:integer>)
+ Returns the string at line <line>. Note that it can be an empty
+ string.
+ !fn: $insertLine(<text:string>, <line:integer>)
+ Inserts <text> at line number <line>. If line is less than
+ zero, or larger than the number of rows, the new text is
+ put at the end. If txt contains newline characters, several
+ lines are inserted. The <line> parameter is optional. If it is
+ ommited, the line is put at end.
+ !fn: $removeLine(<line:integer>)
+ Removes line number <line>.
+ !fn: $insertAt(<txt:string>, <line:uinteger>, <col:uinteger>)
+ Inserts txt at line number line, after character number col in
+ the line. If txt contains newline characters, new lines are
+ inserted.
+ !fn: <integer> $numLines()
+ Returns number of lines in the widget.
+ !fn: $setCursorPosition(<line:integer>, <col:uinteger>, <mark:boolean>)
+ Sets the cursor position to character number col in line
+ number line. The parameters are adjusted to lie within the
+ legal range.[br]
+ If mark is 1, the selection is cleared. otherwise it
+ is extended
+ !fn: <line,col:integer> $cursorPosition()
+ Returns current cursor position in "<line:uinteger>, <col:uinteger>" format.
+ !fn: $setReadOnly(<bReadOnly:boolean>)
+ Sets the editor to be read-only if bReadOnly is 1 or
+ removes the read-only status is ReadOnly is 0
+ !fn: <boolean> $atBeginning()
+ Returns 1(TRUE) if the cursor is placed at the beginning of the text; otherwise returns 0(FALSE).
+ !fn: <boolean> $atEnd()
+ Returns 1(TRUE) if the cursor is placed at the end of the text; otherwise returns 0(FALSE).
+ !fn: $setWordWrap(<wrap_mode:string>)
+ Sets the word wrap mode to mode. Valid Values are:[br]
+ - NoWrap - Do not wrap the text.[br]
+ - WidgetWidth - Wrap the text at the current width of the widget.[br]
+ - FixedPixelWidth - Wrap the text at a fixed number of pixels from the widget's left side.[br]
+ - FixedColumnWidth - Wrap the text at a fixed number of character columns from the widget's left side.
+ !fn: <string> $wordWrap()
+ Returns the word wrap mode. NoWrap, WidgetWidth, FixedPixelWidth, FixedColumnWidth.
+ !fn: <string> $text()
+ Returns the multiline edit's text.
+ !fn: <integer> $length()
+ Returns the number of characters in the text This function ignores newlines.
+ !fn: $setMaxLines(<mac_lines:integer>)
+ Sets the max number of the lines to <a>
+ !fn: <integer> $maxLines()
+ Returns the max number of the lines in the multiline edit.
+ !fn: $insert(<text:string>)
+ Inserts text at the current cursor position.
+ !fn: $append(<text:string>)
+ Appends a new paragraph with text to the end of the multiline edit.
+ !fn: $copy()
+ Copies any selected text from selection to the clipboard.
+ !fn: $cut()
+ Copies the selected text from selection to the clipboard and deletes it from the multiline edit.
+ !fn: $paste()
+ Pastes the text from the clipboard into the multiline edit at the current cursor position.
+ !fn: $setFamily(<font_family:string>)
+ Sets the font family of the current format to fontFamily.
+ !fn: $setItalic(<bItalic:boolean>)
+ If the bool value is 1 sets the current format to italic; otherwise, if it's 0 sets the current format to no-italic.
+ !fn: $setBold(<bBold:boolean>)
+ If the bool value is 1 sets the current format to bold; otherwise, if it's 0 sets the current format to no-bold.
+ !fn: $setUnderline(<bUnderline:boolean>)
+ If the bool value is 1 sets the current format to underline; otherwise, if it's 0 sets the current format to no-underline.
+ !fn: <boolean> $italic()
+ Returns 1(TRUE) if the current format is italic; otherwise returns 0(FALSE).
+ !fn: <boolean> $bold()
+ Returns 1(TRUE) if the current format is bold; otherwise returns 0(FALSE).
+ !fn: <boolean> $underline()
+ Returns 1(TRUE) if the current format is underline; otherwise returns 0(FALSE).
+ !fn: $zoomIn(<zoom_range:integer>)
+ Zooms in on the text by making the base font size range points larger.
+ !fn: $zoomOut(<zoom_range:integer>)
+ Zooms out on the text by making the base font size range points smaller.
+ !fn: $zoomTo(<zoom_size:integer>)
+ Zooms the text by making the base font size <size> points.
+ !fn: $undo()
+ Undoes the last operation.
+ !fn: $redo()
+ Redoes the last operation.
+ !fn: $clear()
+ Deletes all the text in the multiline edit.
+ !fn: $setUndoRedoEnabled(<bUndoRedo:boolean>)
+ Sets whether undo/redo is enabled to the bool value.
+ !fn: $setUndoDepth(<undo_depth:integer>)
+ Sets the depth of the undo history to x.
+ !fn: <boolean> $isUndoRedoEnabled()
+ Returns 1 (TRUE) if undo/redo is enabled; otherwise returns 0 (FALSE).
+ !fn: <integer> $undoDepth()
+ Returns the depth of the undo history.
+ !fn: $indent()
+ Re-indents the current paragraph.
+ !fn: $setText(<txt:string>)
+ Sets the text edit's text to txt.
+ !fn: $setPointSize(<point_size:integer))
+ Sets the point size of the font.
+ // findme
+ !fn: $setColor(<rgb_value>)
+ Sets the foreground color of this widget to <rgb_value>:valid values are:
+ - hex string: must be a string with 6 hexadecimal digits (like the ones used to
+ specify colors in html pages). The first two digits specify
+ the RED component, the third and fourth digit specify the GREEN component
+ and the last two specify the BLUE component.
+ For example "FFFF00" means full red, full green and no blue that gives
+ a yellow color, "808000" designates a brown color (dark yellow),
+ "A000A0" is a kind of violet.
+ - array(red:integer,green:integer,blue:integer)
+ - red:integer,green:integer,blue:integer.
+ !fn: $setModified(<bModified:boolean>)
+ Sets whether the document has been modified by the user. Valid Values are 1(TRUE) or 0(FALSE)
+ !fn: $insertParagraph(<text:string>,<paragraph:integer>)
+ Inserts text as a new paragraph at position <paragraph>.
+ !fn: $removeParagraph(<paragraph:integer>)
+ Removes the paragraph <paragraph>.
+ !fn: $setLinkUnderline(<bLinkUnderline:boolean>)
+ Sets to 1 if you want that hypertext links will be underlined; otherwise sets to 0.
+ !fn: $setOverwriteMode(<bOverwrite:boolean>)
+ Sets the Multilineedit edit's overwrite mode to b (1=Enabled or 0=Disabled) .
+ !fn: $setTextFormat(<textformat:string>)
+ Sets the text format. Correct values are RichText, PlainText, LogText or AutoText.
+ !fn: <string> $textFormat()
+ Returns the text format: rich text, plain text, log text or auto text.
+ // findme
+ !fn: $setParagraphBackgroundColor(<paragraph:integer>,<exadecimal color value>)
+ Sets the background color of the paragraph <paragraph> to color value specified.[br]
+ Example: %mymultiline->$setParagraphBackgroundColor(2,0C686F)
+ !fn: $clearParagraphBackground(<paragraph:integer>)
+ Clear the background color of the paragraph <paragraph>.
+ !fn: $loadFile(<path:string>)
+ Load the file specified in the <path>, also html files.
+ !fn: <boolean> $isUndoAvailable ()
+ Returns 1(TRUE) if undo is available; otherwise returns 0(FALSE).
+ !fn: <boolean> $isRedoAvailable ()
+ Returns 1(TRUE) if redo is available; otherwise returns 0(FALSE).
+ !fn: $setAlignment(<alignment:string>)
+ Sets the alignment of the current paragraph to <alignment>. Valid values are:[br]
+ - AlignAuto - Aligns according to the language.[br]
+ - Qt::AlignLeft - Aligns with the left edge.[br]
+ - Qt::AlignRight - Aligns with the right edge.[br]
+ - Qt::AlignCenter - Centers in both dimensions.
+ !fn: $setVerticalAlignment(<vertical_alignment:string>)
+ Sets the vertical alignment of the current format to <Valignemnt>. Valid Values are:[br]
+ - AlignNormal - Normal alignment.[br]
+ - AlignSuperScript - Superscript.[br]
+ - AlignSubScript - Subscript.
+ !fn: $setAutoFormatting(<afvalue:string>)
+ Sets the enabled set of auto formatting features to afvalue. Valid values are: [br]
+ - AutoNone - Do not perform any automatic formatting[br]
+ - AutoBulletList - Only automatically format bulletted lists[br]
+ - AutoAll - Apply all available autoformatting
+ !fn: $setWrapPolicy(<wraph_policy:string>)
+ Sets the word wrap policy, at <wrpl>. Valid values are:[br]
+ - AtWhiteSpace - Don't use this deprecated value (it is a synonym for AtWordBoundary which you should use instead).[br]
+ - Anywhere - Break anywhere, including within words.[br]
+ - AtWordBoundary - Break lines at word boundaries, e.g. spaces or newlines[br]
+ - AtWordOrDocumentBoundary - Break lines at whitespace, e.g. spaces or newlines if possible. Break it anywhere otherwise.[br]
+ !fn: <integer> $paragraphs()
+ Returns the number of paragraphs in the text.
+ !fn: <integer> $lines()
+ Returns the number of lines in the multilineedit.
+ !fn: <integer> $linesOfParagraph(<paragraph:integer>)
+ Returns the number of lines in paragraph <paragraph>, or -1 if there is no paragraph with index <paragraph>.
+ !fn: <integer> $lineOfChar(<paragraph:integer>,<index:integer>)
+ Returns the line number of the line in paragraph par in which the character at position index appears.[br]
+ If there is no such paragraph or no such character at the index position -1 is returned.
+ !fn: <integer> $paragraphLenght(<paragraph:integer>)
+ Returns the length of the paragraph par, or -1 if there is no paragraph with index par.
+
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_mledit,"multilineedit","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"textLine", functionTextLine)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"insertLine", functionInsertLine)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"removeLine", functionRemoveLine)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"insertAt", functionInsertAt)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"numLines", functionNumLines)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setCursorPosition", functionSetCursorPosition)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"cursorPosition", functionCursorPosition)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"atBeginning", functionAtBeginning)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"atEnd", functionAtEnd)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setWordWrap", functionSetWordWrap)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"wordWrap", functionWordWrap)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"text", functionText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"length", functionLength);
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setMaxLines", functionSetMaxLines)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"maxLines", functionMaxLines)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"insert", functionInsert)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"append", functionAppend)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"copy", functionCopy)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"cut", functionCut)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"paste", functionPaste)
+
+//->Set Style
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setFamily" , functionsetFamily)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setItalic", functionsetItalic)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setBold", functionsetBold)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setUnderline", functionsetUnderline)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"italic", functionitalic)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"bold", functionbold)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"underline", functionunderline)
+//->Zoom In, Out, To
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"zoomIn", functionzoomIn)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"zoomOut", functionzoomOut)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"zoomTo", functionzoomTo)
+//->Undo & Redo
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"undo", functionundo)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"redo", functionredo)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"del", functiondel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"clear", functionclear)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setUndoRedoEnabled", functionsetUndoRedoEnabled)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setUndoDepth", functionsetUndoDepth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"isUndoRedoEnabled", functionsetUndoRedoEnabled)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"undoDepth", functionundoDepth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"indent", functionundoDepth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"isUndoAvailable", functionisUndoAvailable)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"isUndoRedoAvailable", functionisRedoAvailable)
+//->Text color & others
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setText", functionsetText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setPointSize", functionsetPointSize)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setColor", functionsetColor)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setModified" , functionsetModified)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setLinkUnderline" , functionsetLinkUnderline)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setOverwriteMode" , functionsetOverwriteMode)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setReadOnly",functionSetReadOnly)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setTextFormat" , functionsetTextFormat)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"textFormat" , functiontextFormat)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setParagraphBackgroundColor", functionsetParagraphBackgroundColor)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"clearParagraphBackgroundColor", functionsetParagraphBackgroundColor)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"loadFile" , functionloadFile); // let's fantasy
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setAlignment" , functionsetAlignment)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setAutoFormatting" , functionsetAutoFormatting)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setVerticalAlignment" , functionsetVerticalAlignment)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"setWrapPolicy" , functionsetWrapPolicy)
+//->Paragraph & line
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"paragraphs" , functionparagraphs)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"paragraphLength" , functionparagraphLength)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"insertParagraph" , functioninsertParagraph)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"removeParagraph" , functionremoveParagraph)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"lines" , functionlines)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"lineOfChar" , functionlineOfChar)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"linesOfParagraph" , functionlinesOfParagraph)
+ KVSO_REGISTER_HANDLER(KviKvsObject_mledit,"selectAll" , functionselectAll)
+
+
+KVSO_END_REGISTERCLASS(KviKvsObject_mledit)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_mledit,KviKvsObject_widget)
+
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_mledit)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_mledit)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_mledit)
+
+bool KviKvsObject_mledit::init(KviKvsRunTimeContext * pContext,KviKvsVariantList * pParams)
+{
+ setObject(new KviTalMultiLineEdit(parentScriptWidget(),getName()),true);
+ return true;
+}
+
+
+bool KviKvsObject_mledit::functionSetReadOnly(KviKvsObjectFunctionCall *c)
+
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->setReadOnly(bEnabled);
+ return true;
+}
+
+
+bool KviKvsObject_mledit::functionTextLine(KviKvsObjectFunctionCall *c)
+
+{
+ kvs_int_t iLine;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("line",KVS_PT_INT,0,iLine)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(iLine > ((KviTalMultiLineEdit *)widget())->numLines() || iLine < 0) c->warning(__tr2qs("No such line number"));
+ else
+ c->returnValue()->setString(((KviTalMultiLineEdit *)widget())->textLine(iLine));
+ return true;
+}
+
+bool KviKvsObject_mledit::functionInsertLine(KviKvsObjectFunctionCall *c)
+
+{
+ kvs_int_t iLine;
+ QString szInsert;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szInsert)
+ KVSO_PARAMETER("line",KVS_PT_INT,KVS_PF_OPTIONAL,iLine)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ ((KviTalMultiLineEdit *)widget())->insertLine(szInsert,iLine);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionRemoveLine(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iLine;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("line",KVS_PT_INT,0,iLine)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(iLine > ((KviTalMultiLineEdit *)widget())->numLines() || iLine < 0)
+ c->warning("No such line number");
+ else ((KviTalMultiLineEdit *)widget())->removeLine(iLine);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionInsertAt(KviKvsObjectFunctionCall *c)
+
+{
+ kvs_uint_t iLine,iCol;
+ QString szInsert;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szInsert)
+ KVSO_PARAMETER("line",KVS_PT_UNSIGNEDINTEGER,0,iLine)
+ KVSO_PARAMETER("col",KVS_PT_UNSIGNEDINTEGER,0,iCol)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(iLine < 0 || iCol < 0 || iLine > ((KviTalMultiLineEdit *)widget())->numLines())
+ c->warning("No such line number");
+ else
+ ((KviTalMultiLineEdit *)widget())->insertAt(szInsert,iLine,iCol);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionNumLines(KviKvsObjectFunctionCall *c)
+
+{
+ if(widget()) c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->numLines());
+ return true;
+}
+
+bool KviKvsObject_mledit::functionSetCursorPosition(KviKvsObjectFunctionCall *c)
+{
+
+ bool bFlag;
+ kvs_uint_t iLine,iCol;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("line",KVS_PT_UNSIGNEDINTEGER,0,iLine)
+ KVSO_PARAMETER("col",KVS_PT_UNSIGNEDINTEGER,0,iCol)
+ KVSO_PARAMETER("mark",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->setCursorPosition(iLine, iCol, bFlag);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionCursorPosition(KviKvsObjectFunctionCall *c)
+{
+ if(!widget()) return true;
+ int line, col;
+ #if QT_VERSION >= 300
+ ((KviTalMultiLineEdit *)widget())->getCursorPosition(&line, &col);
+ #else
+ ((KviTalMultiLineEdit *)widget())->cursorPosition(&line, &col);
+ #endif
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)line));
+ a->set(1,new KviKvsVariant((kvs_int_t)col));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionAtBeginning(KviKvsObjectFunctionCall *c)
+{
+ if(!widget()) return true;
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->atBeginning());
+ return true;
+}
+
+bool KviKvsObject_mledit::functionAtEnd(KviKvsObjectFunctionCall *c)
+{
+ if(!widget()) return true;
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->atEnd());
+ return true;
+}
+
+bool KviKvsObject_mledit::functionSetWordWrap(KviKvsObjectFunctionCall *c)
+{
+ if(!widget())return true;
+ QString szWrap;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("word_wrap",KVS_PT_STRING,0,szWrap)
+ KVSO_PARAMETERS_END(c)
+ if(KviQString::equalCI(szWrap,"NoWrap"))
+ ((KviTalMultiLineEdit *)widget())->setWordWrap(KviTalMultiLineEdit::NoWrap);
+ else if(KviQString::equalCI(szWrap,"WidgetWidth"))
+ ((KviTalMultiLineEdit *)widget())->setWordWrap(KviTalMultiLineEdit::WidgetWidth);
+ else if(KviQString::equalCI(szWrap,"FixedPixelWidth"))
+ ((KviTalMultiLineEdit *)widget())->setWordWrap(KviTalMultiLineEdit::FixedPixelWidth);
+ else if(KviQString::equalCI(szWrap,"FixedColumnWidth"))
+ ((KviTalMultiLineEdit *)widget())->setWordWrap(KviTalMultiLineEdit::FixedColumnWidth);
+ else c->warning(__tr2qs("Unknown word wrap '%Q'"),&szWrap);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetWrapPolicy(KviKvsObjectFunctionCall *c)
+{
+ if(!widget())return true;
+ QString szPolicy;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("wrap_policy",KVS_PT_STRING,0,szPolicy)
+ KVSO_PARAMETERS_END(c)
+ if(KviQString::equalCI(szPolicy,"AtWhiteSpace)"))
+ ((KviTalMultiLineEdit *)widget())->setWrapPolicy(KviTalMultiLineEdit::AtWhiteSpace);
+ else if(KviQString::equalCI(szPolicy,"Anywhere"))
+ ((KviTalMultiLineEdit *)widget())->setWrapPolicy(KviTalMultiLineEdit::Anywhere);
+ else if(KviQString::equalCI(szPolicy,"AtWordBoundary"))
+ ((KviTalMultiLineEdit *)widget())->setWrapPolicy(KviTalMultiLineEdit::AtWordBoundary);
+ else if(KviQString::equalCI(szPolicy,"AtWordOrDocumentBoundary"))
+ ((KviTalMultiLineEdit *)widget())->setWrapPolicy(KviTalMultiLineEdit::AtWordOrDocumentBoundary);
+ else c->warning(__tr2qs("Unknown wrap policy'%Q'"),&szPolicy);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionWordWrap(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->wordWrap() & KviTalMultiLineEdit::WidgetWidth);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionText(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setString(((KviTalMultiLineEdit *)widget())->text());
+ return true;
+}
+
+bool KviKvsObject_mledit::functionLength(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->length());
+ return true;
+}
+
+bool KviKvsObject_mledit::functionSetMaxLines(KviKvsObjectFunctionCall *c)
+{
+
+ kvs_uint_t imaxLines;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("max_lines",KVS_PT_UNSIGNEDINTEGER,0,imaxLines)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->setMaxLines(imaxLines);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionMaxLines(KviKvsObjectFunctionCall *c)
+
+{
+ if(widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->maxLines());
+ return true;
+}
+
+bool KviKvsObject_mledit::functionInsert(KviKvsObjectFunctionCall *c)
+
+{
+ QString szInsert;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szInsert)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->insert(szInsert);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionAppend(KviKvsObjectFunctionCall *c)
+
+{
+ QString szAppend;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szAppend)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->append(szAppend);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionCopy(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->copy();
+ return true;
+}
+
+bool KviKvsObject_mledit::functionCut(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->cut();
+ return true;
+}
+
+bool KviKvsObject_mledit::functionPaste(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->paste();
+ return true;
+}
+//->Set Bold, Italic, Underline
+bool KviKvsObject_mledit::functionsetBold(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bBold",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setBold(bFlag);
+ return true;
+}
+bool KviKvsObject_mledit::functionsetUnderline(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bUnderline",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setUnderline(bFlag);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetItalic(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bItalic",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setItalic(bFlag);
+ return true;
+}
+
+
+//-->Returns Italic , Bold, Underline.
+bool KviKvsObject_mledit::functionbold(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->bold());
+ return true;
+}
+bool KviKvsObject_mledit::functionitalic(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->italic());
+ return true;
+}
+bool KviKvsObject_mledit::functionunderline(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->underline());
+ return true;
+}
+//->Zoom In, out at
+bool KviKvsObject_mledit::functionzoomIn(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iZoom;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("zoom_value",KVS_PT_INT,KVS_PF_OPTIONAL,iZoom)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ if (!iZoom)
+ ((KviTalMultiLineEdit *)object())->zoomIn();
+ else
+ ((KviTalMultiLineEdit *)object())->zoomIn(iZoom);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionzoomOut(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iZoom;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("zoom_value",KVS_PT_INT,KVS_PF_OPTIONAL,iZoom)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ if (!iZoom)
+ ((KviTalMultiLineEdit *)object())->zoomOut();
+ else
+ ((KviTalMultiLineEdit *)object())->zoomOut(iZoom);
+ return true;
+}
+bool KviKvsObject_mledit::functionzoomTo(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iZoom;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("zoom_size",KVS_PT_INT,0,iZoom)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)object())->zoomTo(iZoom);
+ return true;
+}
+//-> Undo & Redo functions
+
+bool KviKvsObject_mledit::functionundo(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->undo();
+ return true;
+}
+bool KviKvsObject_mledit::functionredo(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->redo();
+ return true;
+}
+bool KviKvsObject_mledit::functionclear(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->clear();
+ return true;
+}
+bool KviKvsObject_mledit::functiondel(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->del();
+ return true;
+}
+bool KviKvsObject_mledit::functionindent(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->indent();
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetUndoRedoEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bUndoredo",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setUndoRedoEnabled(bFlag);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionisUndoRedoEnabled(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->isUndoRedoEnabled());
+ return true;
+}
+bool KviKvsObject_mledit::functionisUndoAvailable(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->isUndoAvailable());
+ return true;
+}
+bool KviKvsObject_mledit::functionisRedoAvailable(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((KviTalMultiLineEdit *)widget())->isRedoAvailable());
+ return true;
+}
+bool KviKvsObject_mledit::functionsetUndoDepth(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iDepth;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("undo_depth",KVS_PT_UNSIGNEDINTEGER,0,iDepth)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)object())->setUndoDepth(iDepth);
+ return true;
+
+}
+bool KviKvsObject_mledit::functionundoDepth(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->undoDepth());
+ return true;
+}
+
+//-->Text & Color & Family
+// Findme
+bool KviKvsObject_mledit::functionsetText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setText(szText);
+ return true;
+}
+bool KviKvsObject_mledit::functionsetColor(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pColArray;
+ kvs_int_t iColR,iColG,iColB;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("red_or_array",KVS_PT_VARIANT,0,pColArray)
+ KVSO_PARAMETER("green",KVS_PT_INT,KVS_PF_OPTIONAL,iColG)
+ KVSO_PARAMETER("blue",KVS_PT_INT,KVS_PF_OPTIONAL,iColB)
+ KVSO_PARAMETERS_END(c)
+ if(pColArray->isArray())
+ {
+ if(pColArray->array()->size() < 3)
+ {
+ c->error(__tr2qs("The array passed as parameter must contain at least 3 elements"));
+ return false;
+ }
+ KviKvsVariant * pColR = pColArray->array()->at(0);
+ KviKvsVariant * pColG = pColArray->array()->at(1);
+ KviKvsVariant * pColB = pColArray->array()->at(2);
+
+ if(!(pColR && pColG && pColB))
+ {
+ c->error(__tr2qs("One of the colors array parameters is empty"));
+ return false;
+ }
+ if(!(pColR->asInteger(iColR) && pColG->asInteger(iColG) && pColB->asInteger(iColB)))
+ {
+ c->error(__tr2qs("One of the colors array parameters didn't evaluate to an integer"));
+ return false;
+ }
+
+ } else {
+ if (c->params()->count()==1)
+ {
+ bool bOk,bOk1,bOk2;
+ QString value;
+ pColArray->asString(value);
+ int i=0;
+ if (value.length()!=6)
+ {
+ c->warning(__tr2qs("A string of 6 digits hex is required"));
+ return true;
+ }
+ QString buffer(value.mid(0,2));
+ iColR=buffer.toInt(&bOk,16);
+ buffer=value.mid(2,2);
+ iColG=buffer.toInt(&bOk1,16);
+ buffer=value.mid(4,2);
+ iColB=buffer.toInt(&bOk2,16);
+ if (!bOk || !bOk1 || !bOk2)
+ {
+ c->warning(__tr2qs("Not an hex digits"));
+ return true;
+ }
+ if (widget()) ((KviTalMultiLineEdit *)widget())->setColor(QColor(iColR,iColG,iColB));
+ return true;
+ }
+ if(c->params()->count() < 3)
+ {
+ c->error(__tr2qs("$setColor requires either an array as first parameter or three integers"));
+ return false;
+ }
+ if(!pColArray->asInteger(iColR))
+ {
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));
+ return false;
+ }
+ }
+ if (widget()) ((KviTalMultiLineEdit *)widget())->setColor(QColor(iColR,iColG,iColB));
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetPointSize(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uPointSize;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("point_size",KVS_PT_UNSIGNEDINTEGER,0,uPointSize)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setPointSize(uPointSize);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetLinkUnderline(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bLinkunderline",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setLinkUnderline(bFlag);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetFamily(KviKvsObjectFunctionCall *c)
+{
+ QString szFamily;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("family",KVS_PT_STRING,0,szFamily)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setFamily(szFamily);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetModified(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bModified",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setModified(bFlag);
+ return true;
+}
+
+bool KviKvsObject_mledit::functioninsertParagraph(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iParagraph;
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETER("paragraph",KVS_PT_INT,0,iParagraph)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalMultiLineEdit *)widget())->insertParagraph(szText,iParagraph);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionremoveParagraph(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iParagraph;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("paragraph",KVS_PT_INT,0,iParagraph)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalMultiLineEdit*)widget())->removeParagraph(iParagraph);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetOverwriteMode(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bOverwritemode",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->setOverwriteMode(bFlag);
+ return true;
+}
+
+bool KviKvsObject_mledit::functiontextFormat(KviKvsObjectFunctionCall *c)
+
+{
+ if(!widget())return true;
+ int fstyle = ((KviTalMultiLineEdit *)widget())->textFormat();
+ QString format="";
+ for(unsigned int i = 0; i < mod_num; i++)
+ {
+ if(fstyle & mod_cod[i])
+ {
+ format=mod_tbl[i];
+ }
+ }
+ c->returnValue()->setString(format);
+ return true;
+
+}
+bool KviKvsObject_mledit::functionsetTextFormat(KviKvsObjectFunctionCall *c)
+
+{
+ QString szFormat;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("textformat",KVS_PT_STRING,0,szFormat)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(KviQString::equalCI(szFormat,"PlainText"))
+ ((KviTalMultiLineEdit *)widget())->setTextFormat(Qt::PlainText);
+ else if(KviQString::equalCI(szFormat,"RichText"))
+ ((KviTalMultiLineEdit *)widget())->setTextFormat(Qt::RichText);
+ else if(KviQString::equalCI(szFormat,"LogText"))
+ ((KviTalMultiLineEdit *)widget())->setTextFormat(Qt::LogText);
+ else if(KviQString::equalCI(szFormat,"AutoText"))
+ ((KviTalMultiLineEdit *)widget())->setTextFormat(Qt::AutoText);
+ else c->warning(__tr2qs("Unknown text format '%Q'"),&szFormat);
+ return true;
+}
+// findme
+bool KviKvsObject_mledit::functionsetParagraphBackgroundColor(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pColArray;
+ kvs_int_t iParagraph,iColR,iColG,iColB;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("paragraph",KVS_PT_INT,0,iParagraph)
+ KVSO_PARAMETER("red_or_array",KVS_PT_VARIANT,0,pColArray)
+ KVSO_PARAMETER("green",KVS_PT_INT,KVS_PF_OPTIONAL,iColG)
+ KVSO_PARAMETER("blue",KVS_PT_INT,KVS_PF_OPTIONAL,iColB)
+ KVSO_PARAMETERS_END(c)
+ if(pColArray->isArray())
+ {
+ if(pColArray->array()->size() < 3)
+ {
+ c->error(__tr2qs("The array passed as parameter must contain at least 3 elements"));
+ return false;
+ }
+ KviKvsVariant * pColR = pColArray->array()->at(0);
+ KviKvsVariant * pColG = pColArray->array()->at(1);
+ KviKvsVariant * pColB = pColArray->array()->at(2);
+
+ if(!(pColR && pColG && pColB))
+ {
+ c->error(__tr2qs("One of the colors array parameters is empty"));
+ return false;
+ }
+ if(!(pColR->asInteger(iColR) && pColG->asInteger(iColG) && pColB->asInteger(iColB)))
+ {
+ c->error(__tr2qs("One of the colors array parameters didn't evaluate to an integer"));
+ return false;
+ }
+
+ } else {
+ if (c->params()->count()==1)
+ {
+ bool bOk,bOk1,bOk2;
+ QString value;
+ pColArray->asString(value);
+ int i=0;
+ if (value.length()!=6)
+ {
+ c->warning(__tr2qs("A string of 6 digits hex is required"));
+ return true;
+ }
+ QString buffer(value.mid(0,2));
+ iColR=buffer.toInt(&bOk,16);
+ buffer=value.mid(2,2);
+ iColG=buffer.toInt(&bOk1,16);
+ buffer=value.mid(4,2);
+ iColB=buffer.toInt(&bOk2,16);
+ if (!bOk || !bOk1 || !bOk2)
+ {
+ c->warning(__tr2qs("Not an hex digits"));
+ return true;
+ }
+ if (widget()) ((KviTalMultiLineEdit *)widget())->setParagraphBackgroundColor(iParagraph,QColor(iColR,iColG,iColB));
+ return true;
+ }
+ if(c->params()->count() < 3)
+ {
+ c->error(__tr2qs("$setColor requires either an array as first parameter or three integers"));
+ return false;
+ }
+ if(!pColArray->asInteger(iColR))
+ {
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));
+ return false;
+ }
+ }
+ if (widget()) ((KviTalMultiLineEdit *)widget())->setParagraphBackgroundColor(iParagraph,QColor(iColR,iColG,iColB));
+ return true;
+}
+
+bool KviKvsObject_mledit::functionclearParagraphBackground(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iParagraph;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("paragraph",KVS_PT_INT,0,iParagraph)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviTalMultiLineEdit*)widget())->clearParagraphBackground(iParagraph);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionloadFile(KviKvsObjectFunctionCall *c)
+{
+ QString szFile;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("file_name",KVS_PT_STRING,0,szFile)
+ KVSO_PARAMETERS_END(c)
+ if ( !QFile::exists(szFile))
+ {
+ c->warning(__tr2qs(" I can't find the specified file '%Q'."),&szFile);
+ return true;
+ }
+
+ QFile file( szFile );
+ if ( !file.open( IO_ReadOnly ) )
+ {
+ c->warning(__tr2qs(" I cannot read the file %Q'."),&szFile);
+ return true;
+ }
+
+ QTextStream ts( &file );
+ QString txt = ts.read();
+#ifdef COMPILE_USE_QT4
+ if ( !Q3StyleSheet::mightBeRichText( txt ) )
+ txt = Q3StyleSheet::convertFromPlainText( txt, Q3StyleSheetItem::WhiteSpacePre );
+#else
+ if ( !QStyleSheet::mightBeRichText( txt ) )
+ txt = QStyleSheet::convertFromPlainText( txt, QStyleSheetItem::WhiteSpacePre );
+#endif
+ ((KviTalMultiLineEdit *)widget())->setText( txt );
+
+ file.close();
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetAlignment(KviKvsObjectFunctionCall *c)
+
+{
+ QString szAlignment;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("alignment",KVS_PT_STRING,0,szAlignment)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(KviQString::equalCI(szAlignment,"Left"))
+ ((KviTalMultiLineEdit *)widget())->setAlignment(Qt::AlignLeft);
+ else if(KviQString::equalCI(szAlignment,"Right"))
+ ((KviTalMultiLineEdit *)widget())->setAlignment(Qt::AlignRight);
+ else if(KviQString::equalCI(szAlignment,"Center"))
+ ((KviTalMultiLineEdit *)widget())->setAlignment(Qt::AlignCenter);
+ else if(KviQString::equalCI(szAlignment,"Justify"))
+ ((KviTalMultiLineEdit *)widget())->setAlignment(Qt::AlignJustify);
+ else c->warning(__tr2qs("Unknown alignment '%Q'"),&szAlignment);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetAutoFormatting(KviKvsObjectFunctionCall *c)
+
+{
+ QString szAutoformatting;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("autoformatting",KVS_PT_STRING,0,szAutoformatting)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(KviQString::equalCI(szAutoformatting,"AutoNone"))
+ ((KviTalMultiLineEdit *)widget())->setAutoFormatting(QTEXTEDIT_AUTO_NONE);
+ else if(KviQString::equalCI(szAutoformatting,"BulletList"))
+ ((KviTalMultiLineEdit *)widget())->setAutoFormatting(QTEXTEDIT_AUTO_BULLET_LIST);
+ else if(KviQString::equalCI(szAutoformatting,"AutoAll"))
+ ((KviTalMultiLineEdit *)widget())->setAutoFormatting(QTEXTEDIT_AUTO_ALL);
+ else c->warning(__tr2qs("Unknown auto formatting mode '%Q'"),&szAutoformatting);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionsetVerticalAlignment(KviKvsObjectFunctionCall *c)
+
+{
+ QString szValignment;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("alignment",KVS_PT_STRING,0,szValignment)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(KviQString::equalCI(szValignment,"Normal"))
+ ((KviTalMultiLineEdit *)widget())->setVerticalAlignment(KviTalMultiLineEdit::AlignNormal);
+ else if(KviQString::equalCI(szValignment,"SuperScript"))
+ ((KviTalMultiLineEdit *)widget())->setVerticalAlignment(KviTalMultiLineEdit::AlignSuperScript);
+ else if(KviQString::equalCI(szValignment,"SubScript"))
+ ((KviTalMultiLineEdit *)widget())->setVerticalAlignment(KviTalMultiLineEdit::AlignSubScript);
+ else c->warning(__tr2qs("Unknown vertical alignment '%Q'"),&szValignment);
+ return true;
+}
+
+bool KviKvsObject_mledit::functionparagraphs(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->paragraphs());
+ return true;
+
+}
+
+bool KviKvsObject_mledit::functionlines(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->lines());
+ return true;
+}
+
+bool KviKvsObject_mledit::functionlineOfChar(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iPara,iIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("paragraph",KVS_PT_INT,0,iPara)
+ KVSO_PARAMETER("index",KVS_PT_INT,0,iIndex)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->lineOfChar(iPara,iIndex));
+ return true;
+}
+
+bool KviKvsObject_mledit::functionlinesOfParagraph(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iLine;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("paragraph",KVS_PT_INT,0,iLine)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->linesOfParagraph(iLine));
+ return true;
+}
+
+
+bool KviKvsObject_mledit::functionparagraphLength(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iParagraph;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("paragraph",KVS_PT_INT,0,iParagraph)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ c->returnValue()->setInteger(((KviTalMultiLineEdit *)widget())->paragraphLength(iParagraph));
+ return true;
+
+}
+
+bool KviKvsObject_mledit::functionselectAll(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bSelectall",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalMultiLineEdit *)widget())->selectAll(bFlag);
+ return true;
+}
+
+
+
+#include "m_class_multilineedit.moc"
diff --git a/src/modules/objects/class_multilineedit.h b/src/modules/objects/class_multilineedit.h
new file mode 100644
index 00000000..8639266e
--- /dev/null
+++ b/src/modules/objects/class_multilineedit.h
@@ -0,0 +1,110 @@
+#ifndef _CLASS_MULTILINEEDIT_H_
+#define _CLASS_MULTILINEEDIT_H_
+//vim: ts=8
+// File : class_multilineedit.cpp
+// Creation date : Mon Feb 19 00:45:34 CET by Krzysztof Godlewski
+//
+// Modification date: Thu 15 Feb 2005 22:00 :00
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_mledit : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_mledit)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+ bool functionTextLine(KviKvsObjectFunctionCall *c);
+ bool functionInsertLine(KviKvsObjectFunctionCall *c);
+ bool functionRemoveLine(KviKvsObjectFunctionCall *c);
+ bool functionInsertAt(KviKvsObjectFunctionCall *c);
+ bool functionNumLines(KviKvsObjectFunctionCall *c);
+ bool functionSetCursorPosition(KviKvsObjectFunctionCall *c);
+ bool functionAtBeginning(KviKvsObjectFunctionCall *c);
+ bool functionAtEnd(KviKvsObjectFunctionCall *c);
+ bool functionSetWordWrap(KviKvsObjectFunctionCall *c);
+ bool functionWordWrap(KviKvsObjectFunctionCall *c);
+ bool functionCursorPosition(KviKvsObjectFunctionCall *c);
+ bool functionText(KviKvsObjectFunctionCall *c);
+ bool functionLength(KviKvsObjectFunctionCall *c);
+ bool functionSetMaxLines(KviKvsObjectFunctionCall *c);
+ bool functionMaxLines(KviKvsObjectFunctionCall *c);
+ bool functionSetReadOnly(KviKvsObjectFunctionCall *c);
+ bool functionInsert(KviKvsObjectFunctionCall *c);
+ bool functionAppend(KviKvsObjectFunctionCall *c);
+ bool functionCopy(KviKvsObjectFunctionCall *c);
+ bool functionPaste(KviKvsObjectFunctionCall *c);
+ bool functionCut(KviKvsObjectFunctionCall *c);
+// |-G&N add-|
+ bool functionsetItalic(KviKvsObjectFunctionCall *c);
+ bool functionitalic(KviKvsObjectFunctionCall *c);
+ bool functionsetBold(KviKvsObjectFunctionCall *c);
+ bool functionbold(KviKvsObjectFunctionCall *c);
+ bool functionsetUnderline(KviKvsObjectFunctionCall *c);
+ bool functionunderline(KviKvsObjectFunctionCall *c);
+ bool functionzoomIn(KviKvsObjectFunctionCall *c);
+ bool functionzoomOut(KviKvsObjectFunctionCall *c);
+ bool functionzoomTo(KviKvsObjectFunctionCall *c);
+ bool functionundo(KviKvsObjectFunctionCall *c);
+ bool functionredo(KviKvsObjectFunctionCall *c);
+ bool functiondel(KviKvsObjectFunctionCall *c);
+ bool functionclear(KviKvsObjectFunctionCall *c);
+ bool functionindent(KviKvsObjectFunctionCall *c);
+ bool functionsetUndoRedoEnabled(KviKvsObjectFunctionCall *c);
+ bool functionsetUndoDepth(KviKvsObjectFunctionCall *c);
+ bool functionisUndoRedoEnabled(KviKvsObjectFunctionCall *c);
+ bool functionundoDepth(KviKvsObjectFunctionCall *c);
+ bool functionsetText(KviKvsObjectFunctionCall *c);
+ bool functionsetPointSize(KviKvsObjectFunctionCall *c);
+ bool functionsetColor(KviKvsObjectFunctionCall *c);
+ bool functionisUndoAvailable(KviKvsObjectFunctionCall *c);
+ bool functionisRedoAvailable(KviKvsObjectFunctionCall *c);
+ bool functionsetLinkUnderline(KviKvsObjectFunctionCall *c);
+ bool functionsetFamily(KviKvsObjectFunctionCall *c);
+ bool functionsetModified(KviKvsObjectFunctionCall *c);
+ bool functioninsertParagraph(KviKvsObjectFunctionCall *c);
+ bool functionremoveParagraph(KviKvsObjectFunctionCall *c);
+ bool functionsetOverwriteMode(KviKvsObjectFunctionCall *c);
+ bool functionsetTextFormat(KviKvsObjectFunctionCall *c);
+ bool functiontextFormat(KviKvsObjectFunctionCall *c);
+ bool functionsetParagraphBackgroundColor(KviKvsObjectFunctionCall *c);
+ bool functionclearParagraphBackground(KviKvsObjectFunctionCall *c);
+ bool functionloadFile(KviKvsObjectFunctionCall *c);
+ bool functionsetAlignment(KviKvsObjectFunctionCall *c);
+ bool functionsetAutoFormatting(KviKvsObjectFunctionCall *c);
+ bool functionsetVerticalAlignment(KviKvsObjectFunctionCall *c);
+ bool functionsetWrapPolicy(KviKvsObjectFunctionCall *c);
+ bool functionparagraphs(KviKvsObjectFunctionCall *c);
+ bool functionparagraphLength(KviKvsObjectFunctionCall *c);
+ bool functionlines(KviKvsObjectFunctionCall *c);
+ bool functionlineOfChar(KviKvsObjectFunctionCall *c);
+ bool functionlinesOfParagraph(KviKvsObjectFunctionCall *c);
+ bool functionselectAll(KviKvsObjectFunctionCall *c);
+
+};
+
+#endif //!_CLASS_MULTILINEEDIT_H_
diff --git a/src/modules/objects/class_painter.cpp b/src/modules/objects/class_painter.cpp
new file mode 100644
index 00000000..b27a24a3
--- /dev/null
+++ b/src/modules/objects/class_painter.cpp
@@ -0,0 +1,1007 @@
+//mdm:
+// Painter : class_painter.cpp
+// Creation date : Fri Mar 18 14:30:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+// Lucia Papini (^ashura^) English Translation.
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_painter.h"
+#include "class_pixmap.h"
+#include "class_widget.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_error.h"
+#include "kvi_iconmanager.h"
+#include "kvi_malloc.h"
+
+
+/*
+ @doc: painter
+ @keyterms:
+ painter object class, line editor, input
+ @title:
+ painter class
+ @type:
+ class
+ @short:
+ This class provide a painter to paint line and shapes.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ With this class you can draw many graphics objects from simple lines to complex shapes like pies and chords.[br]
+ It can also draw aligned text and pixmaps. Normally, it draws in a "natural" coordinate system, but it can also do view and world transformation.[br]
+ The class need to be implemented into a [classfnc]$paintEvent[/classfnc]();
+ @functions:
+ !fn: $drawLine(<x1:integer>,<y1_integer>,<x2:integer>,<y2:integer>)
+ Draws a line from (x1, y1) to (x2, y2) and sets the current pen position to (x2, y2).
+ !fn: $begin(<paint_device:object>)
+ Begins painting the paint device <paint_device>: the parameter MUST be a widget or a pixmap.[br]
+ Warning: A paint device can only be painted by one painter at a time.
+ !fn: $end()
+ Ends painting. Any resources used while painting are released.
+ !fn: $setPen(<rgb or hsv array value or [<red>,<green>,<blue>][<hue>,<saturation>,<value>],[system color:RGB or HSV)
+ The pen defines the lines or text, color. You can set it with Red,Green,Blue, or H,S,V value[br]
+ All parameters are in integer form.
+ The HSV system, like RGB, has three components:[br]
+ * H, for hue, is either 0-359 if the color is chromatic (not gray), or meaningless if it is gray.[br]
+ It represents degrees on the color wheel familiar to most people. Red is 0 (degrees), green is 120 and blue is 240.[br]
+ * S, for saturation, is 0-255, and the bigger it is, the stronger the color is. Grayish colors have saturation near 0; very strong colors have saturation near 255.[br]
+ * V, for value, is 0-255 and represents lightness or brightness of the color. 0 is black; 255 is as far from black as possible.[br]
+ Examples: RED is H=0, S=255, V=255.[br]
+ Light RED could have H about 0, S about 50-100, and S=255.
+ ES: $setPen(00,00,00) for black;[br]
+ Default color mode is RGB;
+ !fn: $setBrush(<rgb or hsv array value or [<red>,<green>,<blue>][<hue>,<saturation>,<value>],[system color:RGB or HSV)
+ Sets the painter's brush to have the specified color.[br]
+ Example:[br]
+ class (wdg,widget)[br]
+ {[br]
+ paintevent()[br]
+ {[br]
+ %b=$new(painter)[br]
+ %b->$setBackgroundMode(Opaque)[br]
+ %b->$setBrush(0,250,250)[br]
+ %b->$begin($$)[br]
+ %b->$drawEllipse(50,50,100,50)[br]
+ }[br]
+ }[br]
+ %aa=$new(wdg)[br]
+ %aa->$show()[br]
+ !fn: $drawRect(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>)
+ Draws a rectangle with upper left corner at (x, y) and with width w and height h.
+ !fn: $drawWinFocusRect(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>)
+ Draws a Windows focus rectangle with upper left corner at (x, y) and with width w and height h.[br]
+ This function draws nothing if the coordinate system has been rotated or sheared.
+ !fn: $drawRoundRect(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>,<xCor:integer>,<yCor:integer>)
+ Draws a rectangle with rounded corners at (x, y), with width w and height h.[rb]
+ The xCor and yCor arguments specify how rounded the corners should be (range is 0->99).
+ !fn: $drawPie(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>,<angle:integer>,<alen:integer>)
+ Draws a pie defined by the rectangle (x, y, w, h), the start angle a and the arc length alen.[br]
+ The angles <angle> and <alen> are 1/16th of a degree, i.e. a full circle equals 5760 (16*360).
+ !fn: $drawArc(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>,<angle:integer>,<alen:integer>)
+ Draws an arc defined by the rectangle (x, y, w, h), the start angle a and the arc length alen.[br]
+ The angles <angle> and <alen> are 1/16th of a degree, i.e. a full circle equals 5760 (16*360).
+ !fn: $drawPoint(<x:integer>,<y:integer>)
+ Draws a point at x and y coordinates.
+ !fn: $drawEllipse(<x:integer>,<y:integer>,<sizew:unsigned integer>,<sizeh:unsigned integer>)
+ Draws an ellipse with center at (x + w/2, y + h/2) and size (w, h).
+ !fn: $drawChord(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>,<angle:integer>,<alen:integer>)
+ Draws a chord defined by the rectangle (x, y, w, h), the start angle a and the arc length alen.[br]
+ The angles <angle> and <alen> are 1/16th of a degree, i.e. a full circle equals 5760 (16*360).
+ !fn: $drawText(<x:integer>,<y:integer>,<text:string>,<nr chars:integer>,<dir:enum>)
+ Draws the given <text> at position <x>, <y>.[br]
+ If <len> is -1 (the default) all the text is drawn, otherwise the first <len> characters are drawn.
+ The text's direction is given by <dir>, valid flag are:[br]
+ [pre]
+ Auto [br]
+ RTL (right to left) [br]
+ LTR (left to right) [br]
+ [/pre]
+ !fn: $drawPixmap(<x:integer>,<y:integer>,<pixmap:hobject>,<sx:integer>,<sy:integer>,<ex:integer>,<ey:integer>)
+ Draws a pixmap at x,y coordinates[br]
+ !fn: $setFont(<size:unsigned integer>,<family:string>,<style:enum>)[br]
+ Set the font's size, family and stile, valid flag for style are:[br]
+ [pre]
+ italic [br]
+ bold [br]
+ underline [br]
+ overline [br]
+ strikeout [br]
+ fixedpitch [br]
+ [/pre]
+ !fn: $setFontSize(<size:unsigned integer>)[br]
+ Set the current painter font's size.[br]
+ !fn: <integer>$fontAscent()
+ Return the distance from the baseline to the highest position characters extend to.
+ !fn: <integer>$fontDescent()
+ Return the distance from the baseline to the lowest point characters extend to.
+ !fn: <integer>$fontMetricsWidth(<text:string>)
+ Returns the font metrics width for the painter's current font.
+ !fn: <integer>$fontMetricsHeight()
+ Returns the font metrics height for the painter's current font.
+ !fn: $rotate(<angle:real>)
+ Rotates the coordinate system a degrees counterclockwise.
+ !fn: $translate(<dx:real>,<dy:real>)
+ Translates the coordinate system by <dx>, <dy>.
+ !fn: $shear(<dh:real>,<dv:real>)
+ Shears the coordinate system by <dh>, <dv>.
+ !fn: $scale(<dh:real>,<dw:real>)
+ Scales the coordinate system by <dh>, <dv>.
+ !fn: $setBackgroundMode(<bgMode:enum>)
+ Sets the background mode of the painter to <bgMode>: valid values are:[br]
+ - Transparent (that is the default value);[br]
+ - Opaque.[br]
+ !fn: $setOpacity(<opacity_factor:real>) [QT4 ONLY]
+ Sets the painter opacity that affects all painter operations (drawpixmap, drawtext...). Valid values range are from 0 (total transparency) to 1 (total opacity)[br]
+ You must invoke the [classfnc]$begin[/classfnc] before using it.
+ !fn: $setTextAntialiasing(<boolean>) [QT4 ONLY]
+ Enable/disable antialias in text if possible.
+ You must call the [classfnc]$begin[/classfnc] before using it.
+ !fn: $setAntialiasing(<boolean>) [QT4 ONLY]
+ Enable/disable antialias in edges of primitives if possible.
+ You must call the [classfnc]$begin[/classfnc] before using it.
+ !fn: $setSmoothPixmapTransform(<boolean>) [QT4 ONLY]
+ Enable/disable smooth bilinear pixmap transformation algorithm (such as bilinear).
+ You must call the [classfnc]$begin[/classfnc] before using it.
+ Example:[br]
+ [br]
+ class (hello,widget)[br]
+ {[br]
+ constructor()[br]
+ {[br]
+ $$->%sintbl[]= $array( 0, 38, 71, 92, 100, 92, 71, 38,0, -38, -71, -92, -100, -92, -71, -38);[br]
+ $$->%index=0[br]
+ $$->$starttimer( 30 );[br]
+ $$->$resize(800,600 );[br]
+ $$->%string=$0[br]
+ $$->%waitfor=1;[br]
+ $$->%nextanim=0[br]
+ [br]
+ #zoom and rotation anim[br]
+ $$->%Zoomindex=11[br]
+ $$->%degree=0[br]
+ $$->%Noanim=0[br]
+ $$->%scrollright=-450[br]
+ [br]
+ #anim effect init[br]
+ $$->%xoffset=4[br]
+ $$->%yoffset=3[br]
+ $$->%xstart=270[br]
+ $$->%ystart=200[br]
+ $$->%b=0[br]
+ $$->%yoffs=400[br]
+ [br]
+ #parallax parameter[br]
+ $$->%Off=400[br]
+ $$->%roll=1[br]
+ }[br]
+ timerevent()[br]
+ {[br]
+ $$->%b = $(($$->%b + 1) & 15);[br]
+ if ($$->%nextanim == 1) $$->$repaint(1);[br]
+ $$->$repaint(0);[br]
+ }[br]
+ drawAnim()[br]
+ {[br]
+ %P->$setFont(32,"times",bold);[br]
+ %w=$(%P->$fontMetricsWidth($$->%string[$$->%index]) + 20);[br]
+ %h=$(%P->$fontMetricsHeight * 2);[br]
+ %pmx = $(($$->$width/2) -%w/2);[br]
+ %pmy = $(($$->$height()/2) - %h/2);[br]
+ %x = 10;[br]
+ %y= $((%h/2) + $$->$fontDescent());[br]
+ %i=0[br]
+ while ( $str.mid("Grifisx/Noldor",%i,1) != "") [br]
+ {[br]
+ %i16 = $(($$->%b+%i) & 15);[br]
+ %char=$str.mid("Grifisx/Noldor",%i,1)[br]
+ %P->$setPen($((15-%i16)*16),$((15-%i16)*16),$((15-%i16)*16) );[br]
+ %P->$drawText( $(%x+$$->%xstart),$($$->%ystart+%y-$$->%sintbl[%i16]*%h/800),%char,1,Auto);[br]
+ %x += %P->$fontMetricsWidth(%char);[br]
+ %i++;[br]
+ }[br]
+ }[br]
+ matrixeffect()[br]
+ {[br]
+ if (($$->%Zoomindex == 99) && ($$->%degree==360)) return %P->$drawPixmap($(400-32),$(300-32),"kvirc.png",0,0,-1,-1)[br]
+ %P->$scale(0.$$->%Zoomindex,0.$$->%Zoomindex)[br]
+ if ($$->%Zoomindex != 99) $$->%Zoomindex++;[br]
+ %P->$rotate($$->%degree)[br]
+ %P->$translate(400,300)[br]
+ %P->$drawPixmap(-32,-32,"kvirc.png",0,0,-1,-1)[br]
+ %P->$setFont(28,"times",bold);[br]
+ %P->$reset()[br]
+ if ($$->%scrollright >= 550) return[br]
+ %P->$scale(0.$$->%Zoomindex,0.$$->%Zoomindex)[br]
+ %P->$translate(400,350)[br]
+ %P->$drawText($$->%scrollright,10,"Another cool class brought to you by...",-1,Auto) [br]
+ $$->%scrollright += 3;[br]
+ %P->$reset()[br]
+ }[br]
+ nextanim()[br]
+ {[br]
+ %p=$new(painter)[br]
+ %p->$setBackgroundMode(Opaque)[br]
+ %p->$setBrush($rand(255),$rand(255),$rand(255))[br]
+ %p->$begin($$)[br]
+ %rand=$rand(5)[br]
+ %p->$drawrect($rand(800),$rand(400),120,200)[br]
+ %p->$drawArc($rand(800),$rand(400),120,200,20,$(16*20))[br]
+ %p->$drawPie($rand(800),$rand(400),120,200,20,$(16*20))[br]
+ %p->$drawChord($rand(800),$rand(400),120,200,20,$(16*20))[br]
+ %p->$drawEllipse($rand(800),$rand(400),100,30)[br]
+ %p->$end()[br]
+ delete %p[br]
+ }[br]
+ paintEvent()[br]
+ {[br]
+ if ($$->%nextanim ==1) return $$->$nextanim()[br]
+ # pixmap creation: every effect will be painted on it then copied on widget[br]
+ %pixmap=$new(pixmap)[br]
+ %pixmap->$resize($$->$width(),$$->$height())[br]
+ [br]
+ # painter creation [br]
+ %P=$new(painter);[br]
+ %P->$begin(%pixmap);[br]
+ $$->$drawanim[br]
+ $$->$matrixeffect[br]
+ %i=0[br]
+ while (%i != 100)[br]
+ {[br]
+ %i16 = $(($$->%b+%i) & 15);[br]
+ %P->$setPen($((15-%i16)*16),$((15-%i16)*16),$((15-%i16)*16) );[br]
+ %P->$drawpoint($rand(800),$rand(600))[br]
+ %i++[br]
+ }[br]
+ [br]
+ # sets the animations order to manage the parallax effect[br]
+ %P->$end[br]
+ objects.bitBlt $$ 0 0 %pixmap[br]
+ delete %pixmap[br]
+ delete %P[br]
+ if (%Pauseflag == 1) return[br]
+ [br]
+ # manage the animations parameters[br]
+ if (($$->%Off<=60) && ($$->%roll<182)) $$->%roll += 2;[br]
+ if ($$->%roll>182) $$->%waitfor=0[br]
+ if ($$->%Noanim != 1) $$->%degree += 16;[br]
+ if ($$->%degree >= 360)[br]
+ {[br]
+ $$->%degree=0;[br]
+ if ($$->%Zoomindex == 99) $$->%Noanim=1[br]
+ } [br]
+ if ($$->%Noanim != 1) return[br]
+ [br]
+ #sinusoid animation[br]
+ if (($$->%xstart <1) && ($$->%xoffset == -4)) $$->%xoffset=4;[br]
+ if (($$->%xstart >$($$->$width()-%P->$fontMetricsWidth("Grifisx/Noldor"))) && ($$->%xoffset == 4)) $$->%xoffset=-4;[br]
+ if (($$->%ystart <1) && ($$->%yoffset == -3)) $$->%yoffset=3;[br]
+ if (($$->%ystart >$($$->$height()-60)) && ($$->%yoffset == 3)) $$->%yoffset=-3;[br]
+ $$->%xstart += $$->%xoffset;[br]
+ $$->%ystart += $$->%yoffset;[br]
+ }[br]
+ }[br]
+ [br]
+ %Hello=$new(hello)[br]
+ %Hello->$setcaption("Painter effects" );[br]
+ %Hello->$setFont(28,"times",bold);[br]
+ %Btn=$new(button,%Hello)[br]
+ %Btn->$setmaximumwidth(80)[br]
+ %Btn->$setmaximumheight(30)[br]
+ %Btn->$setFont(8,"times",bold);[br]
+ %Btn->$settext(Next)[br]
+ [br]
+ privateimpl(%Btn,mousepressevent)[br]
+ {[br]
+ if ($$->$parent->%nextanim==0) [br]
+ {[br]
+ $$->$parent->%nextanim=1[br]
+ $$->$settext(Prev)[br]
+ } [br]
+ else[br]
+ {[br]
+ $$->$parent->%nextanim=0[br]
+ $$->$settext(Next)[br]
+ }[br]
+ }[br]
+ [br]
+ %lay=$new(layout,%Hello)[br]
+ %lay->$addwidget(%Btn,4,0)[br]
+ %Hello->$setBackgroundColor("000000");[br]
+ %Hello->$setmaximumwidth(800)[br]
+ %Hello->$setminimumwidth(780)[br]
+ %Hello->$setmaximumheight(600)[br]
+ %Hello->$setminimumheight(600)[br]
+ %Hello->$move(10,10)[br]
+ %Hello->$show();[br] [br]
+
+*/
+
+// ========================================================================
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_painter,"painter","object")
+
+ // Fonts
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setFont",functionSetFont)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setFontSize",functionSetFontSize)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setBrush",functionsetBrush)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setPen",functionsetPen)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"fontAscent",functionfontAscent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"fontDescent",functionfontDescent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"fontMetricsHeight",functionfontMetricsHeight)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"fontMetricsWidth",functionfontMetricsWidth)
+ // Draws
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setBackGroundMode",functionsetBackGroundMode)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawRect",functiondrawRect)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawLine",functiondrawLine)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawRoundRect",functiondrawRoundRect)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawWinFocusRect",functiondrawWinFocusRect)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawPoint",functiondrawPoint)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawArc",functiondrawArc)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawEllipse",functiondrawEllipse)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawPie",functiondrawPie)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawChord",functiondrawChord)
+ // Text & Pixmap
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawText",functiondrawText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawPixmap",functiondrawPixmap)
+
+
+ // MAtrix Operation
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"rotate",functionrotateMatrix)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"shear",functionshearMatrix)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"scale",functionscaleMatrix)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"translate",functiontranslateMatrix)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"reset",functionresetMatrix)
+
+#ifdef COMPILE_USE_QT4
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setOpacity",functionsetOpacity)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setTextAntialiasing",functionsetTextAntialiasing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setAntialiasing",functionsetAntialiasing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setSmoothPixmapTransform",functionsetSmoothPixmapTransform)
+#endif
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"begin",functionbegin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"end",functionend)
+
+
+KVSO_END_REGISTERCLASS(KviKvsObject_painter)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_painter,KviKvsObject)
+
+ m_pPainter = new QPainter();
+
+ m_pDeviceObject=0;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_painter)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_painter)
+
+ if (m_pPainter) delete m_pPainter;
+ m_pPainter = 0;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_painter)
+
+#define KVSO_PARAMETERS_PAINTER(__pXOrArray,__iY,__iW,__iH)\
+if(__pXOrArray->isArray())\
+ {\
+ if(__pXOrArray->array()->size() < 4)\
+ {\
+ c->error(__tr2qs("The array passed as parameter must contain at least 4 elements"));\
+ return false;\
+ }\
+ KviKvsVariant * pX = __pXOrArray->array()->at(0);\
+ KviKvsVariant * pY = __pXOrArray->array()->at(1);\
+ KviKvsVariant * pW = __pXOrArray->array()->at(2);\
+ KviKvsVariant * pH = __pXOrArray->array()->at(3);\
+ if(!(pX && pY && pW && pH))\
+ {\
+ c->error(__tr2qs("One of the geometry array parameters is empty"));\
+ return false;\
+ }\
+ if(!(pX->asInteger(iX) && pY->asInteger(__iY) && pW->asInteger(__iW) && pH->asInteger(__iH)))\
+ {\
+ c->error(__tr2qs("One of the geometry array parameters didn't evaluate to an integer"));\
+ return false;\
+ }\
+ } else {\
+ if(c->params()->count() < 4)\
+ {\
+ QString error=function+" requires either an array as first parameter or four integers";\
+ c->error(__tr2qs(error));\
+ return false;\
+ }\
+ if(!__pXOrArray->asInteger(iX))\
+ {\
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));\
+ return false;\
+ }\
+ }\
+
+#define KVSO_2ARRAYPARAMETERS(__pXOrArray,__iY)\
+if(__pXOrArray->isArray())\
+ {\
+ if(__pXOrArray->array()->size() < 2)\
+ {\
+ c->error(__tr2qs("The array passed as parameter must contain at least 2 elements"));\
+ return false;\
+ }\
+ KviKvsVariant * pX = __pXOrArray->array()->at(0);\
+ KviKvsVariant * pY = __pXOrArray->array()->at(1);\
+ if(!(pX && pY ))\
+ {\
+ c->error(__tr2qs("One of the array parameters is empty"));\
+ return false;\
+ }\
+ if(!(pX->asInteger(iX) && pY->asInteger(__iY)))\
+ {\
+ c->error(__tr2qs("One of the array parameters didn't evaluate to an integer"));\
+ return false;\
+ }\
+ } else {\
+ if(c->params()->count() < 2)\
+ {\
+ QString error=function+" requires either an array as first parameter or two integers";\
+ c->error(__tr2qs(error));\
+ return false;\
+ }\
+ if(!__pXOrArray->asInteger(iX))\
+ {\
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));\
+ return false;\
+ }\
+ }\
+
+#define KVSO_3ARRAYPARAMETERS(__pCol1OrArray,__iCol2,__iCol3)\
+if(__pCol1OrArray->isArray())\
+ {\
+ if(__pCol1OrArray->array()->size() < 3)\
+ {\
+ c->error(__tr2qs("The array passed as parameter must contain at least 3 elements"));\
+ return false;\
+ }\
+ KviKvsVariant * c1 = __pCol1OrArray->array()->at(0);\
+ KviKvsVariant * c2 = __pCol1OrArray->array()->at(1);\
+ KviKvsVariant * c3 = __pCol1OrArray->array()->at(2);\
+ if(!(c1 && c2 && c3))\
+ {\
+ c->error(__tr2qs("One of the array parameters is empty"));\
+ return false;\
+ }\
+ if(!(c1->asInteger(iCol1) && c2->asInteger(__iCol2) && c3->asInteger(__iCol3)))\
+ {\
+ c->error(__tr2qs("One of the array parameters didn't evaluate to an integer"));\
+ return false;\
+ }\
+ } else {\
+ if(c->params()->count() < 3)\
+ {\
+ QString error=function+" requires either an array as first parameter or 3 integers";\
+ c->error(__tr2qs(error));\
+ return false;\
+ }\
+ if(!__pCol1OrArray->asInteger(iCol1))\
+ {\
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));\
+ return false;\
+ }\
+ }\
+
+bool KviKvsObject_painter::functionSetFont(KviKvsObjectFunctionCall *c)
+{
+ QString szFamily,szStyle;
+ kvs_int_t uSize;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("size",KVS_PT_UNSIGNEDINTEGER,0,uSize)
+ KVSO_PARAMETER("family",KVS_PT_STRING,0,szFamily)
+ KVSO_PARAMETER("style",KVS_PT_STRING,0,szStyle)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ QFont font=m_pPainter->font();
+ font.setFamily(szFamily);
+ font.setPointSize(uSize);
+ if(KviQString::equalCI(szStyle,"italic")) font.setItalic(TRUE);
+ if(KviQString::equalCI(szStyle,"bold")) font.setBold(TRUE);
+ if(KviQString::equalCI(szStyle,"underline"))font.setUnderline(TRUE);
+ if(KviQString::equalCI(szStyle,"overline")) font.setOverline(TRUE);
+ if(KviQString::equalCI(szStyle,"strikeout"))font.setStrikeOut(TRUE);
+ if(KviQString::equalCI(szStyle,"fixedpitch")) font.setFixedPitch(TRUE);
+ m_pPainter->setFont(font);
+ return true;
+}
+bool KviKvsObject_painter::functionSetFontSize(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uSize;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("size",KVS_PT_UNSIGNEDINTEGER,0,uSize)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ QFont font=m_pPainter->font();
+ font.setPointSize(uSize);
+ m_pPainter->setFont(font);
+ return true;
+}
+bool KviKvsObject_painter::functionsetBackGroundMode(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("background mode",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ if(KviQString::equalCI(szMode,"Transparent")) m_pPainter->setBackgroundMode(Qt::TransparentMode);
+ else if(KviQString::equalCI(szMode,"Opaque")) m_pPainter->setBackgroundMode(Qt::OpaqueMode);
+ else c->warning( __tr2qs("Unknown orientation"));
+ return true;
+
+}
+
+bool KviKvsObject_painter::functiondrawLine(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawLine";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+ if(m_pPainter) m_pPainter->drawLine(iX,iY,iW,iH);
+ return true;
+}
+bool KviKvsObject_painter::functiondrawRect(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawRect";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+ if(m_pPainter) m_pPainter->drawRect(iX,iY,iW,iH);
+ return true;
+}
+// FIX ME: REMOVE functiondrawWinFocusRect
+bool KviKvsObject_painter::functiondrawWinFocusRect(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawWinFocusRect";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+#ifndef COMPILE_USE_QT4
+ if(m_pPainter) m_pPainter->drawWinFocusRect(iX,iY,iW,iH);
+#endif
+ return true;
+}
+bool KviKvsObject_painter::functiondrawEllipse(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawEllipse";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+ if(m_pPainter) m_pPainter->drawEllipse(iX,iY,iW,iH);
+ return true;
+}
+bool KviKvsObject_painter::functiondrawRoundRect(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iXrnd,iYrnd,iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_round",KVS_PT_INT,0,iXrnd)
+ KVSO_PARAMETER("y_round",KVS_PT_INT,0,iYrnd)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawRoundRect";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+ if(m_pPainter)
+ m_pPainter->drawRoundRect(iX,iY,iW,iH,iXrnd,iYrnd);
+ return true;
+}
+bool KviKvsObject_painter::functiondrawArc(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iSangle,iLena,iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("start_angle",KVS_PT_INT,0,iSangle)
+ KVSO_PARAMETER("a_lenght",KVS_PT_INT,0,iLena)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawArc";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+ if(m_pPainter)
+ m_pPainter->drawArc(iX,iY,iW,iH,iSangle,iLena);
+ return true;
+}
+bool KviKvsObject_painter::functiondrawChord(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iSangle,iLena,iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("start_angle",KVS_PT_INT,0,iSangle)
+ KVSO_PARAMETER("a_lenght",KVS_PT_INT,0,iLena)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawChord";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+ if(m_pPainter)
+ m_pPainter->drawChord(iX,iY,iW,iH,iSangle,iLena);
+ return true;
+}
+bool KviKvsObject_painter::functionsetBrush(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pCol1OrArray;
+ kvs_int_t iCol1,iCol2,iCol3;
+ QString szColorMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("Col1_or_array",KVS_PT_VARIANT,0,pCol1OrArray)
+ KVSO_PARAMETER("Color_2",KVS_PT_INT,KVS_PF_OPTIONAL,iCol2)
+ KVSO_PARAMETER("Colo3_3",KVS_PT_INT,KVS_PF_OPTIONAL,iCol3)
+ KVSO_PARAMETER("color_mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szColorMode)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawChord";
+ KVSO_3ARRAYPARAMETERS(pCol1OrArray,iCol2,iCol3)
+ if(!m_pPainter) return true;
+ if(KviQString::equalCI(szColorMode, "HSV"))
+ m_pPainter->setBrush(QColor(iCol1,iCol2,iCol3,QColor::Hsv));
+ else
+ m_pPainter->setBrush(QColor(iCol1,iCol2,iCol3,QColor::Rgb));
+ return true;
+}
+bool KviKvsObject_painter::functionsetPen(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pCol1OrArray;
+ kvs_int_t iCol1,iCol2,iCol3;
+ QString szColorMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("Col1_or_array",KVS_PT_VARIANT,0,pCol1OrArray)
+ KVSO_PARAMETER("Color_2",KVS_PT_INT,KVS_PF_OPTIONAL,iCol2)
+ KVSO_PARAMETER("Colo3_3",KVS_PT_INT,KVS_PF_OPTIONAL,iCol3)
+ KVSO_PARAMETER("color_mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szColorMode)
+ KVSO_PARAMETERS_END(c)
+ QString function="$setPen";
+ KVSO_3ARRAYPARAMETERS(pCol1OrArray,iCol2,iCol3)
+ if(!m_pPainter) return true;
+ if(KviQString::equalCI(szColorMode, "HSV"))
+ m_pPainter->setPen(QColor(iCol1,iCol2,iCol3,QColor::Hsv));
+ else
+ m_pPainter->setPen(QColor(iCol1,iCol2,iCol3,QColor::Rgb));
+
+ return true;
+}
+bool KviKvsObject_painter::functiondrawPie(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iSangle,iLena,iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("start_angle",KVS_PT_INT,0,iSangle)
+ KVSO_PARAMETER("a_lenght",KVS_PT_INT,0,iLena)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawPie";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iW,iH)
+ if(m_pPainter)
+ m_pPainter->drawPie(iX,iY,iW,iH,iSangle,iLena);
+ return true;
+}
+bool KviKvsObject_painter::functiondrawPoint(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iX,iY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawPoint";
+ KVSO_2ARRAYPARAMETERS(pXOrArray,iY)
+ if(m_pPainter)
+ m_pPainter->drawPoint(iX,iY);
+ return true;
+}
+bool KviKvsObject_painter::functionfontDescent(KviKvsObjectFunctionCall * c)
+{
+ if(m_pPainter)
+ c->returnValue()->setInteger(m_pPainter->fontMetrics().descent());
+ return true;
+}
+
+bool KviKvsObject_painter::functionfontAscent(KviKvsObjectFunctionCall * c)
+{
+ if(m_pPainter)
+ c->returnValue()->setInteger(m_pPainter->fontMetrics().ascent());
+ return true;
+
+}
+
+bool KviKvsObject_painter::functionfontMetricsWidth(KviKvsObjectFunctionCall * c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if(m_pPainter)
+ c->returnValue()->setInteger(m_pPainter->fontMetrics().width(szText));
+ return true;
+}
+
+bool KviKvsObject_painter::functionfontMetricsHeight(KviKvsObjectFunctionCall * c)
+{
+ if(m_pPainter)
+ c->returnValue()->setInteger(m_pPainter->fontMetrics().height());
+ return true;
+}
+bool KviKvsObject_painter::functionbegin(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject * pObject;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("paint_device",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!m_pPainter)return true;
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Pixmap or Widget parameter is not an object"));
+ return true;
+ }
+
+ QPaintDevice * pd = 0;
+ if(pObject->inherits("KviKvsObject_pixmap"))pd =((KviKvsObject_pixmap *)pObject)->getPixmap();
+ else if (pObject->inherits("KviKvsObject_widget")) pd=((KviKvsObject_widget *)pObject)->widget();
+
+ if (!pd)
+ c->warning(__tr2qs("Widget or Pixmap required "));
+ else {
+ attachDevice(pObject,pd);
+ // m_pPainter->setOpacity(0.4);
+ if (pObject->inherits("KviKvsObject_pixmap")) ((KviKvsObject_pixmap *)pObject)->pixmapChanged();
+ }
+ return true;
+}
+void KviKvsObject_painter::attachDevice(KviKvsObject * o,QPaintDevice * p)
+{
+ if(!m_pPainter)return;
+ if(m_pDeviceObject)detachDevice();
+ m_pDeviceObject = o;
+ // KviKvsObject_pixmap and KviKvsObject_widget object have this signal
+ // it is emitted BEFORE the real QPaintDevice is deleted, so we can eventually
+ // call m_pPainter->end() in time
+
+ QObject::connect(m_pDeviceObject,SIGNAL(aboutToDie()),this,SLOT(detachDevice()));
+ m_pPainter->begin(p);
+}
+
+void KviKvsObject_painter::detachDevice()
+{
+ if(!m_pDeviceObject)return;
+ if(!m_pPainter)return;
+ disconnect(m_pDeviceObject,SIGNAL(aboutToDie()),this,SLOT(detachDevice()));
+ m_pPainter->end();
+ m_pDeviceObject = 0;
+}
+
+bool KviKvsObject_painter::functionend(KviKvsObjectFunctionCall *c)
+{
+ detachDevice();
+ return true;
+}
+
+bool KviKvsObject_painter::functiondrawText(KviKvsObjectFunctionCall *c)
+{
+ QString szText,szMode;
+ kvs_int_t iX,iY,iLen;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETER("length",KVS_PT_INT,0,iLen)
+ KVSO_PARAMETER("mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+#ifdef COMPILE_USE_QT4
+ if (!szMode.isEmpty()){
+ if(KviQString::equalCI(szMode,"RTL"))m_pPainter->setLayoutDirection(Qt::RightToLeft);
+ else if(KviQString::equalCI(szMode,"LTR"))m_pPainter->setLayoutDirection(Qt::LeftToRight);
+ else
+ {
+ c->warning(__tr2qs("Invalid mode '%Q'"),&szMode);
+ return true;
+ }
+ }
+
+ m_pPainter->drawText(iX,iY,szText);
+#else
+ if(KviQString::equalCI(szMode,"Auto")) m_pPainter->drawText(iX,iY,szText,iLen,QPainter::Auto);
+ else if(KviQString::equalCI(szMode,"RTL")) m_pPainter->drawText(iX,iY,szText,iLen,QPainter::RTL);
+ else if(KviQString::equalCI(szMode,"LTR"))m_pPainter->drawText(iX,iY,szText,iLen,QPainter::LTR);
+ else c->warning(__tr2qs("Invalid mode '%Q'"),&szMode);
+
+#endif
+ return true;
+}
+
+bool KviKvsObject_painter::functiondrawPixmap(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iX,iY,iStartx,iStarty,iEndx,iEndy;
+ KviKvsObject *obj;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
+ KVSO_PARAMETER("pixmap",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("start_x",KVS_PT_INT,0,iStartx)
+ KVSO_PARAMETER("start_y",KVS_PT_INT,0,iStarty)
+ KVSO_PARAMETER("end_x",KVS_PT_INT,0,iEndx)
+ KVSO_PARAMETER("end_y",KVS_PT_INT,0,iEndy)
+ KVSO_PARAMETERS_END(c)
+ obj=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!m_pPainter)return true;
+ if (!obj)
+ {
+ c->warning(__tr2qs("Pixmap parameter is not an object"));
+ return true;
+ }
+ if (!obj->inherits("KviKvsObject_pixmap"))
+ {
+ c->warning(__tr2qs("Pixmap object required"));
+ return true;
+ }
+ QPixmap * pm=((KviKvsObject_pixmap *)obj)->getPixmap();
+ m_pPainter->drawPixmap(iX,iY,*((KviKvsObject_pixmap *)obj)->getPixmap(),iStartx,iStarty,iEndx,iEndy);
+ return true;
+}
+
+bool KviKvsObject_painter::functionrotateMatrix(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dAngle;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("angle",KVS_PT_DOUBLE,0,dAngle)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ m_pMatrix.rotate(dAngle);
+ m_pPainter->setWorldMatrix( m_pMatrix,false );
+ return true;
+}
+bool KviKvsObject_painter::functiontranslateMatrix(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dXtrasl,dYtrasl;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("trasl_x",KVS_PT_DOUBLE,0,dXtrasl)
+ KVSO_PARAMETER("trasl_y",KVS_PT_DOUBLE,0,dYtrasl)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ QWMatrix tmpMatrix;
+ tmpMatrix.translate(dXtrasl,dYtrasl);
+ tmpMatrix = m_pMatrix * tmpMatrix;
+ m_pPainter->setWorldMatrix( tmpMatrix );
+ m_pMatrix=tmpMatrix;
+ return true;
+}
+bool KviKvsObject_painter::functionshearMatrix(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dShearh,dShearv;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("shear_h",KVS_PT_DOUBLE,0,dShearh)
+ KVSO_PARAMETER("shear_v",KVS_PT_DOUBLE,0,dShearv)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ m_pMatrix.shear(dShearh,dShearv);
+ m_pPainter->setWorldMatrix(m_pMatrix);
+ return true;
+}
+bool KviKvsObject_painter::functionscaleMatrix(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dScalex,dScaley;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("scale_x",KVS_PT_DOUBLE,0,dScalex)
+ KVSO_PARAMETER("scale_y",KVS_PT_DOUBLE,0,dScaley)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ m_pMatrix.scale(dScalex,dScaley);
+ m_pPainter->setWorldMatrix(m_pMatrix);
+ return true;
+}
+bool KviKvsObject_painter::functionresetMatrix(KviKvsObjectFunctionCall *c)
+
+{
+ if(!m_pPainter)return true;
+ m_pMatrix.reset();
+ m_pPainter->setWorldMatrix( m_pMatrix );
+ return true;
+}
+
+#ifdef COMPILE_USE_QT4
+bool KviKvsObject_painter::functionsetOpacity(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pPainter)return true;
+ kvs_real_t dOpacity;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("opacity_factor",KVS_PT_DOUBLE,0,dOpacity)
+ KVSO_PARAMETERS_END(c)
+ m_pPainter->setOpacity(dOpacity);
+ return true;
+}
+bool KviKvsObject_painter::functionsetTextAntialiasing(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pPainter)return true;
+
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ m_pPainter->setRenderHint(QPainter::TextAntialiasing,bEnabled);
+ return true;
+}
+bool KviKvsObject_painter::functionsetAntialiasing(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pPainter)return true;
+
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ m_pPainter->setRenderHint(QPainter::Antialiasing,bEnabled);
+ return true;
+}
+bool KviKvsObject_painter::functionsetSmoothPixmapTransform(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pPainter)return true;
+
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ m_pPainter->setRenderHint(QPainter::SmoothPixmapTransform,bEnabled);
+ return true;
+}
+#endif
+
+
+
+#include "m_class_painter.moc"
diff --git a/src/modules/objects/class_painter.h b/src/modules/objects/class_painter.h
new file mode 100644
index 00000000..2ee8a5bb
--- /dev/null
+++ b/src/modules/objects/class_painter.h
@@ -0,0 +1,96 @@
+#ifndef _CLASS_PAINTER_H_
+#define _CLASS_PAINTER_H_
+//mdm:
+// Painter : class_painter.h
+// Creation date : Fri Mar 18 14:30:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include <qpainter.h>
+#include <qpaintdevice.h>
+#include "kvi_string.h"
+
+
+#include "object_macros.h"
+
+
+class KviKvsObject_painter : public KviKvsObject
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_painter)
+protected:
+ QPainter * m_pPainter;
+ QWMatrix m_pMatrix;
+public:
+ bool functionSetFont(KviKvsObjectFunctionCall *c);
+ bool functionSetFontSize(KviKvsObjectFunctionCall *c);
+
+ bool functionfontAscent(KviKvsObjectFunctionCall *c);
+ bool functionfontDescent(KviKvsObjectFunctionCall *c);
+ bool functionfontMetricsWidth(KviKvsObjectFunctionCall *c);
+ bool functionfontMetricsHeight(KviKvsObjectFunctionCall *c);
+ bool functionsetBrush(KviKvsObjectFunctionCall *c);
+ bool functionsetPen(KviKvsObjectFunctionCall *c);
+ bool functionsetBackGroundMode(KviKvsObjectFunctionCall *c);
+
+ bool functiondrawRect(KviKvsObjectFunctionCall *c);
+ bool functiondrawWinFocusRect(KviKvsObjectFunctionCall *c);
+ bool functiondrawLine(KviKvsObjectFunctionCall *c);
+ bool functiondrawRoundRect(KviKvsObjectFunctionCall *c);
+ bool functiondrawPoint(KviKvsObjectFunctionCall *c);
+ bool functiondrawArc(KviKvsObjectFunctionCall *c);
+ bool functiondrawChord(KviKvsObjectFunctionCall *c);
+ bool functiondrawPie(KviKvsObjectFunctionCall *c);
+ bool functiondrawEllipse(KviKvsObjectFunctionCall *c);
+
+ bool functiondrawText(KviKvsObjectFunctionCall *c);
+ bool functiondrawPixmap(KviKvsObjectFunctionCall *c);
+
+
+ bool functionbegin(KviKvsObjectFunctionCall *c);
+ bool functionend(KviKvsObjectFunctionCall *c);
+
+ bool functionscaleMatrix(KviKvsObjectFunctionCall *c);
+ bool functionshearMatrix(KviKvsObjectFunctionCall *c);
+ bool functionrotateMatrix(KviKvsObjectFunctionCall *c);
+ bool functionresetMatrix(KviKvsObjectFunctionCall *c);
+ bool functiontranslateMatrix(KviKvsObjectFunctionCall *c);
+
+#ifdef COMPILE_USE_QT4
+ bool functionsetOpacity(KviKvsObjectFunctionCall *c);
+ bool functionsetSmoothPixmapTransform(KviKvsObjectFunctionCall *c);
+ bool functionsetTextAntialiasing(KviKvsObjectFunctionCall *c);
+ bool functionsetAntialiasing(KviKvsObjectFunctionCall *c);
+#endif
+
+
+
+protected:
+ void attachDevice(KviKvsObject * o,QPaintDevice * p);
+protected slots:
+ void detachDevice();
+private:
+ KviKvsObject * m_pDeviceObject;
+};
+#endif // !_CLASS_PAINTER_H_
+
+
+
diff --git a/src/modules/objects/class_pixmap.cpp b/src/modules/objects/class_pixmap.cpp
new file mode 100644
index 00000000..48aeb1e8
--- /dev/null
+++ b/src/modules/objects/class_pixmap.cpp
@@ -0,0 +1,317 @@
+//mdm:
+// Painter : class_pixmap.h
+// Creation date : Fri Mar 18 14:30:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+// Lucia Papini (^ashura^) English Translation.
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_pixmap.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include <qfile.h>
+
+/*
+ @doc: pixmap
+ @keyterms:
+ pixmap object class
+ @title:
+ pixmap class
+ @type:
+ class
+ @short:
+ This class provide a pixmap.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ The pixmap class is an off-screen, pixel-based paint device.
+ @functions:
+ !fn: $fill(<widget:object>,<x_offset:integer>,<y:offset>)
+ Fills the pixmap with the widget's background color or pixmap.[br]
+ Note that x_offset, y_offest are offsets in the widget.
+ !fn: $resize(<width:integer>,<height:integer>)
+ Resizes the pixmap to w width and h height. Set wh or hg to 0, to have a null pixmap.
+ !fn: $scale(<sx:real>,<sy:real>)
+ Scales the pixmap by sx horizontally and sy vertically.
+ !fn: $rotate(<a:real>)
+ Rotates the pixmap by a degrees.
+ !fn: $load(<file_name:string>)
+ Load a pixmap from the <file>.
+ !fn: <integer> $height()
+ Return the height of the pixmap.
+ !fn: <integer> $width()
+ Return the width of the pixmap.
+
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_pixmap,"pixmap","object")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"fill",functionfill)
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"resize",functionresize)
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"load",functionload)
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"height",functionheight)
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"width",functionwidth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"setOpacity",functionsetOpacity)
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"scale",functionscale)
+ KVSO_REGISTER_HANDLER(KviKvsObject_pixmap,"rotate",functionrotate)
+
+KVSO_END_REGISTERCLASS(KviKvsObject_pixmap)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_pixmap,KviKvsObject)
+ m_pPixmap=new QPixmap();
+ m_pImage=new QImage();
+ bPixmapModified=false;
+ bImageModified=false;
+KVSO_END_CONSTRUCTOR(KviKvsObject_pixmap)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_pixmap)
+
+ emit aboutToDie();
+ delete m_pPixmap;
+ if (m_pImage) delete m_pImage;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_pixmap)
+
+
+bool KviKvsObject_pixmap::functionfill(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_int_t iXoffset,iYoffset;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("x_offset",KVS_PT_INT,0,iXoffset)
+ KVSO_PARAMETER("y_offset",KVS_PT_INT,0,iYoffset)
+ KVSO_PARAMETERS_END(c)
+
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return true;
+ }
+ bPixmapModified=true;
+ m_pPixmap->fill(((QWidget *)(ob->object())),iXoffset,iYoffset);
+ return true;
+}
+
+bool KviKvsObject_pixmap::functionscale(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t uScaleX,uScaleY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("sx",KVS_PT_REAL,0,uScaleX)
+ KVSO_PARAMETER("sy",KVS_PT_REAL,0,uScaleY)
+ KVSO_PARAMETERS_END(c)
+ #ifdef COMPILE_USE_QT4
+ *m_pPixmap = m_pPixmap->scaled((m_pPixmap->width() * uScaleX), (m_pPixmap->height() * uScaleX));
+ #else
+ QWMatrix wm;
+ wm.scale(uScaleX, uScaleY);
+ *m_pPixmap = m_pPixmap->xForm(wm);
+ #endif
+ bPixmapModified=true;
+ return true;
+}
+
+bool KviKvsObject_pixmap::functionrotate(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t uDegrees;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("a",KVS_PT_REAL,0,uDegrees)
+ KVSO_PARAMETERS_END(c)
+ #ifdef COMPILE_USE_QT4
+ QMatrix m;
+ m.rotate(uDegrees);
+ *m_pPixmap = m_pPixmap->transformed(m);
+ #else
+ QWMatrix wm;
+ wm.rotate(uDegrees);
+ *m_pPixmap = m_pPixmap->xForm(wm);
+ #endif
+ bPixmapModified=true;
+ return true;
+}
+
+bool KviKvsObject_pixmap::functionresize(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t uWidth,uHeight;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("width",KVS_PT_UNSIGNEDINTEGER,0,uWidth)
+ KVSO_PARAMETER("height",KVS_PT_UNSIGNEDINTEGER,0,uHeight)
+ KVSO_PARAMETERS_END(c)
+ m_pPixmap->resize(uWidth,uHeight);
+ bPixmapModified=true;
+ return true;
+}
+
+
+bool KviKvsObject_pixmap::functionload(KviKvsObjectFunctionCall *c)
+{
+ QString szFile;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("file",KVS_PT_STRING,0,szFile)
+ KVSO_PARAMETERS_END(c)
+
+ if(!QFile::exists(szFile))
+ {
+ c->warning(__tr2qs("I can't find the specified file %Q."),&szFile);
+ return true;
+ }
+ m_pPixmap->load(szFile);
+ bPixmapModified=true;
+ return true;
+}
+bool KviKvsObject_pixmap::functionheight(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setInteger(m_pPixmap->height());
+ return true;
+}
+bool KviKvsObject_pixmap::functionwidth(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setInteger(m_pPixmap->width());
+ return true;
+}
+bool KviKvsObject_pixmap::functionsetOpacity(KviKvsObjectFunctionCall *c)
+{
+ if(!m_pPixmap)return true;
+ kvs_real_t dOpacity;
+ kvs_uint_t uXoffset,uYoffset;
+ kvs_uint_t uWidth,uHeight;
+
+ KviKvsObject * pObDest;
+ kvs_hobject_t hObject;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("opacity_factor",KVS_PT_DOUBLE,0,dOpacity)
+ KVSO_PARAMETER("destination",KVS_PT_HOBJECT,0,hObject)
+
+ KVSO_PARAMETER("x_offset",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uXoffset)
+ KVSO_PARAMETER("y_offset",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uYoffset)
+ KVSO_PARAMETER("width",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uWidth)
+ KVSO_PARAMETER("height",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uHeight)
+ KVSO_PARAMETERS_END(c)
+ pObDest=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+
+ if (!pObDest)
+ {
+ c->warning(__tr2qs("Destination parameter is not an object"));
+ return true;
+ }
+
+ if(!pObDest->inherits("KviKvsObject_pixmap"))
+ {
+ c->warning(__tr2qs("Destination must be a pixmap object"));
+ return true;
+ }
+ QImage *buffer=((KviKvsObject_pixmap *)pObDest)->getImage();
+ ((KviKvsObject_pixmap *)pObDest)->imageChanged();
+ if (bPixmapModified) {
+ *m_pImage=m_pPixmap->convertToImage();
+ }
+ if (uWidth>buffer->width() || uHeight>buffer->height())
+ {
+ c->warning(__tr2qs("Area dimensions are out of destination size "));
+ return true;
+ }
+ if (!uWidth){
+ if(m_pImage->width()>buffer->width())
+ {
+ c->warning(__tr2qs("Pixmap dimensions are out of destination size "));
+ return true;
+ }
+ }
+
+ if (!uHeight)
+ {
+ if(m_pImage->height()>buffer->height())
+ {
+ c->warning(__tr2qs("Pixmap dimensions are out of destination size "));
+ return true;
+ }
+ }
+
+
+if(uXoffset+uWidth>m_pImage->width())
+ {
+ c->warning(__tr2qs("Offset width area is out of pixmap size "));
+ return true;
+ }
+ if( uYoffset+uHeight>m_pImage->height())
+ {
+ c->warning(__tr2qs("Offset height area is out of pixmap size "));
+ return true;
+ }
+
+ buffer->setAlphaBuffer(true);
+ int iHedge=uHeight?uHeight:m_pImage->height();
+ int iWedge=uWidth?uWidth:m_pImage->width();
+
+ for(int y = uYoffset;y<iHedge;y++)
+ {
+ QRgb * dst = (QRgb *)buffer->scanLine(y);
+ QRgb * src = (QRgb *)m_pImage->scanLine(y);
+ src += uXoffset;
+ QRgb * end;
+ end = src + iWedge;
+ while(src < end)
+ {
+ *dst = qRgba(
+ (int)(qRed(*src)),
+ (int)(qGreen(*src)),
+ (int)(qBlue(*src)),
+ (int)(qAlpha(*src)*dOpacity)
+ );
+ src++;
+ dst++;
+ }
+ }
+ return true;
+}
+
+
+QPixmap * KviKvsObject_pixmap::getPixmap()
+{
+ if (bImageModified) {
+ m_pPixmap->convertFromImage(*m_pImage);
+ bImageModified=false;
+ }
+ return m_pPixmap;
+}
+QImage * KviKvsObject_pixmap::getImage()
+{
+ if (bPixmapModified) {
+ *m_pImage=m_pPixmap->convertToImage();
+ //debug ("image info2 %d and %d",test.width(),test.height());
+
+ bPixmapModified=false;
+ }
+
+ return m_pImage;
+}
+
+#include "m_class_pixmap.moc"
diff --git a/src/modules/objects/class_pixmap.h b/src/modules/objects/class_pixmap.h
new file mode 100644
index 00000000..22d1b95d
--- /dev/null
+++ b/src/modules/objects/class_pixmap.h
@@ -0,0 +1,72 @@
+#ifndef _CLASS_PIXMAP_H_
+#define _CLASS_PIXMAP_H_
+//vim: ts=8
+// Pixmap : class_pixmap.h
+// Creation date : Thu Sep 21 04:43:01 CEST 2000 by Krzysztof Godlewski
+//
+// This pixmap is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qpixmap.h>
+#include <qimage.h>
+#ifdef COMPILE_USE_QT4
+ #include <QMatrix>
+#else
+ #include <qwmatrix.h>
+#endif
+#include "kvi_string.h"
+
+
+#include "object_macros.h"
+
+
+class KviKvsObject_pixmap : public KviKvsObject
+{
+ Q_OBJECT
+// Q_PROPERTY(QPixmap pixmap READ getPixmap)
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_pixmap);
+ QPixmap * getPixmap();
+ QImage * getImage();
+ void pixmapChanged(){bPixmapModified=true;}
+ void imageChanged(){bImageModified=true;}
+
+ QPixmap * pixmap(){ return m_pPixmap; }
+protected:
+ QPixmap * m_pPixmap;
+ QImage * m_pImage;
+ bool bImageModified;
+ bool bPixmapModified;
+signals:
+ void aboutToDie();
+
+protected:
+ bool functionfill(KviKvsObjectFunctionCall *c);
+ bool functionresize(KviKvsObjectFunctionCall *c);
+ bool functionscale(KviKvsObjectFunctionCall *c);
+ bool functionrotate(KviKvsObjectFunctionCall *c);
+ bool functionload(KviKvsObjectFunctionCall *c);
+ bool functionheight(KviKvsObjectFunctionCall *c);
+ bool functionwidth(KviKvsObjectFunctionCall *c);
+ bool functionsetOpacity(KviKvsObjectFunctionCall *c);
+
+ };
+
+#endif // !_CLASS_PIXMAP_H_
diff --git a/src/modules/objects/class_popupmenu.cpp b/src/modules/objects/class_popupmenu.cpp
new file mode 100644
index 00000000..a3db5339
--- /dev/null
+++ b/src/modules/objects/class_popupmenu.cpp
@@ -0,0 +1,361 @@
+//mdm :
+// File : class_popupmenu.cpp
+// Creation date : Mon Feb 01 21:30:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+// Lucia Papini (^ashura^) English Translation.
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "class_popupmenu.h"
+#include "kvi_error.h"
+
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+
+/*
+ @doc: popupmenu
+ @keyterms:
+ popupmenu object class,
+ @title:
+ popupmenu class
+ @type:
+ class
+ @short:
+ Provides a popup menu.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This widget can be used to display a popup menu.Technically, a popup menu consists of a list of menu items.[br]
+ You add items with insertItem(). An item is either a string. In addition, items can have an optional icon drawn on the very left side.[br]
+ @functions:
+ !fn: $insertItem(<text:string>,[icon_id:string])
+ Inserts menu items into a popup menu with optional icon and return the popup identifier.
+ !fn: $insertWidget(<widget:object>)[br]
+ Inserts widget items int a popup menu and return the popup identifier.[br]
+ The widget is treats as a separator; this means that the item is not selectable and you can, for example, simply insert a label if you need a popup menu with a title.
+ !fn: $insertHandle(<text_label:string>,<popupmenu:object>,[icon])
+ Inserts a submenu with optional icon into the popup menu.
+ !fn: $exec([<widget:objects>,<x:uinteger>,<y:integer>])
+ If called without paramaters show the popup menu at the current pointer position.[br]
+ With the optional parameters show the popup menu at the coordinate x,y widget parameter relative.
+ !fn: $removeItem(<popup_id:Uinteger>)
+ Removes the menu item that has the identifier id.
+ !fn: $removeItemAt(<index:uinteger>)
+ Removes the menu item at position index.
+ !fn: $insertSeparator(<index:uinteger>)
+ Inserts a separator at position index.[br]
+ If the index is negative the separator becomes the last menu item.
+ !fn: $activatedEvent(<popup_id:uinteger>)
+ This function is called when a menu item and return the the item id.[br]
+ The default implementation emits the [classfnc]$activated[/classfnc]() signal.
+ !fn: $highligthtedEvent(<popup_id:uinteger>)
+ This function is called when a menu item is highlighted and return the item id.[br]
+ The default implementation emits the [classfnc]$highlighted[/classfnc]() signal.
+ @signals:
+ !sg: $activated()
+ This signal is emitted by the default implementation of [classfnc]$activatedEvent[/classfnc]().
+ !sg: $highlighted()
+ This signal is emitted by the default implementation of [classfnc]$highlightedEvent[/classfnc]().
+ [br]
+ |-EXAMPLE POPUP MENU-|[br]
+ |--Start:
+ # First of all we create an array wich will be used to create random colors.[br]
+ %Hex[]=$array(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)[br]
+ [br]
+ class (ws,widget)[br]
+ {[br]
+ #In the constructor we create everything that belong to the single widget.[br]
+ constructor[br]
+ {[br]
+ #Geometry of the widget and setting-up of popupmenu [br]
+ $$->$setGeometry(%X,%Y,100,100)[br]
+ $$->%lay=$new(layout,$$)[br]
+ #Here we generate a cicle to create our labels inside the widget.[br]
+ %i=0[br]
+ while (%i<10)[br]
+ {[br]
+ $$->%label=$new(label,$$)[br]
+ $$->%label->$settext("Another class by N\&G")[br]
+ #We set our foreground's coulor using the hex arrey in random way.[br]
+ %color=%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)]%Hex[$rand(14)][br]
+ $$->%label->$setforegroundcolor(%color)[br]
+ $$->%label->$setautoresize(1)[br]
+ #We add the label to the widget's popupmenu.[br]
+ $$->%lay->$addwidget($$->%label,%i,0)[br]
+ %i++;[br]
+ }[br]
+ #We make the popupmenu relative to this widget: this is merely demonstrative.[br]
+ #because it creates 25 identical popups.[br]
+ $$->%Popupmenu=$new(popupmenu,$$)[br]
+ #we create the label widget wich will be used as popup's title[br]
+ $$->%Popuptitle=$new(label)[br]
+ $$->%Popuptitle->$settext(<B><U>"Windows Options"</B></U>)[br]
+ $$->%Popuptitle->$setAlignment(Center)[br]
+ #and we add it.[br]
+ %A=$$->%Popuptitle[br]
+ $$->%Popupmenu->$insertwidget(%A)[br]
+ #Here we keep the various IDs in the arrays[br]
+ %Tile[%I]=$$->%Popupmenu->$insertItem("Tile",118)[br]
+ %Cascade[%I]=$$->%Popupmenu->$insertItem("Cascade",115)[br]
+ $$->%Popupmenu->$insertSeparator(3)[br]
+ %Closeactw[%I]=$$->%Popupmenu->$insertItem("Close Active Window",08)[br]
+ %Closeallw[%I]=$$->%Popupmenu->$insertItem("Close All Window",58)[br]
+ $$->$show()[br]
+ privateimpl($$->%Popupmenu,activatedEvent)[br]
+ {[br]
+ %id=$0[br]
+ %i = 0[br]
+ #with this cicle we control wich of the items has been called comparing the id given back by the event with our arrays created before;[br]
+ while (%i<20)[br]
+ {[br]
+ if (%id == %Tile[%i]) return %Workspace->$tile()[br]
+ if (%id == %Cascade[%i]) return %Workspace->$cascade()[br]
+ if (%id == %Closeactw[%i]) return %Workspace->$closeactivewindow()[br]
+ if (%id == %Closeallw[%i]) return %Workspace->$closeallwindows()[br]
+ %i ++[br]
+ }[br]
+ }[br]
+ }[br]
+ #we activate the popup pushing the right mouse button on the widget[br]
+ mousepressevent[br]
+ {[br]
+ if ($0 == 1) $$->%Popupmenu->$exec()[br]
+ }[br]
+ }[br]
+ %Workspace=$new(workspace)[br]
+ %Workspace->$resize(640,480)[br]
+ %I=0[br]
+ %Cicle=1[br]
+ while (%I<20)[br]
+ {[br]
+ %X=$rand(500)[br]
+ %Y=$rand(480)[br]
+ %Widget=$new(ws,%Workspace)[br]
+ %I++[br]
+ }[br]
+ #Let's show!
+ %Workspace->$show[br]
+ |--End.[br][br]
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_popupmenu,"popupmenu","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"insertItem", functioninsertItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"insertWidget", functioninsertWidget)
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"insertHandle", functioninsertHandle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"exec", functionexec)
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"insertSeparator", functioninsertSeparator)
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"removeItem", functionremoveItem)
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"removeItemAt", functionremoveItemAt)
+
+ // events
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"highlightedEvent", functionhighlightedEvent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_popupmenu,"activatedEvent", functionactivatedEvent)
+
+KVSO_END_REGISTERCLASS(KviKvsObject_popupmenu)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_popupmenu,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_popupmenu)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_popupmenu)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_popupmenu)
+
+bool KviKvsObject_popupmenu::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new KviTalPopupMenu(parentScriptWidget(), name()), true);
+ connect(widget(),SIGNAL(activated(int)),this,SLOT(slotactivated(int)));
+ connect(widget(),SIGNAL(highlighted(int)),this,SLOT(slothighlighted(int)));
+ return true;
+}
+
+bool KviKvsObject_popupmenu::functioninsertItem(KviKvsObjectFunctionCall *c)
+{
+ QString szItem,szIcon;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szItem)
+ KVSO_PARAMETER("icon_id",KVS_PT_STRING,KVS_PF_OPTIONAL,szIcon)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ QPixmap *pix = 0;
+ int id=0;
+ if(!szIcon.isEmpty())
+ {
+ pix = g_pIconManager->getImage(szIcon);
+ if (pix) id=((KviTalPopupMenu *)widget())->insertItem(*pix,szItem);
+ else c->warning(__tr2qs("pix '%Q' doesn't exists"),&szIcon);
+
+ }
+ else
+ id=((KviTalPopupMenu *)widget())->insertItem(szItem);
+ c->returnValue()->setInteger(id);
+ return true;
+}
+bool KviKvsObject_popupmenu::functioninsertWidget(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *pObject;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!pObject->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!pObject->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return TRUE;
+ }
+ if (widget()) ((KviTalPopupMenu *)widget())->insertItem(((KviTalPopupMenu *)(pObject->object())));
+ return true;
+}
+bool KviKvsObject_popupmenu::functioninsertHandle(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szLabel,szIcon;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text_label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("icon_id",KVS_PT_STRING,KVS_PF_OPTIONAL,szIcon)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!ob->object()->inherits("KviKvsObject_popupmenu"))
+ {
+ c->warning(__tr2qs("Can't add a non - popupmenu object"));
+ return TRUE;
+ }
+ if(!widget())return true;
+ QPixmap *pix = 0;
+ int id=0;
+ if(!szIcon.isEmpty())
+ {
+ pix = g_pIconManager->getImage(szIcon);
+ if (pix) id=((KviTalPopupMenu *)widget())->insertItem(*pix,szLabel,((KviTalPopupMenu *)(ob->object())));
+ else c->warning(__tr2qs("pix '%Q' doesn't exists"),&szIcon);
+
+ }
+ else
+ id=((KviTalPopupMenu *)widget())->insertItem(szLabel,((KviTalPopupMenu *)(ob->object())));
+ c->returnValue()->setInteger(id);
+ return true;
+}
+bool KviKvsObject_popupmenu::functionexec(KviKvsObjectFunctionCall *c)
+{
+ if(!c->params()->count())
+ {
+ ((KviTalPopupMenu *)widget())->exec(QCursor::pos());
+ return true;
+ }
+
+ KviKvsObject *pObject;
+ kvs_uint_t iX,iY;
+ QString szLabel,szIcon;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("x",KVS_PT_UNSIGNEDINTEGER,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_UNSIGNEDINTEGER,0,iY)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!pObject->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!pObject->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Doesn't a widget object"));
+ return true;
+ }
+
+ ((KviTalPopupMenu *)widget())->exec(((QWidget *)(pObject->object()))->mapToGlobal(QPoint(iX,iY)) );
+
+ return true;
+}
+bool KviKvsObject_popupmenu::functionremoveItem(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uItem;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("item_id",KVS_PT_UNSIGNEDINTEGER,0,uItem)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((KviTalPopupMenu *)widget())->removeItem(uItem);
+ return true;
+}
+bool KviKvsObject_popupmenu::functionremoveItemAt(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())((KviTalPopupMenu *)widget())->removeItemAt(uIndex);
+ return true;
+}
+
+bool KviKvsObject_popupmenu::functioninsertSeparator(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())((KviTalPopupMenu *)widget())->insertSeparator(uIndex);
+ return true;
+}
+
+void KviKvsObject_popupmenu::slothighlighted(int i)
+{
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)i));
+ callFunction(this,"highlightedEvent",&params);
+}
+bool KviKvsObject_popupmenu::functionhighlightedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("highlighted",c,c->params());
+ return true;
+}
+void KviKvsObject_popupmenu::slotactivated(int i)
+{
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)i));
+ callFunction(this,"activatedEvent",&params);
+}
+bool KviKvsObject_popupmenu::functionactivatedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("activated",c,c->params());
+ return true;
+}
+
+
+#include "m_class_popupmenu.moc"
diff --git a/src/modules/objects/class_popupmenu.h b/src/modules/objects/class_popupmenu.h
new file mode 100644
index 00000000..e5960119
--- /dev/null
+++ b/src/modules/objects/class_popupmenu.h
@@ -0,0 +1,58 @@
+#ifndef _CLASS_POPUPMENU_H_
+#define _CLASS_POPUPMENU_H_
+//mdm:
+// File : class_popupMenu.h
+// Creation date : Mon Gen 27 14:30:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "kvi_tal_popupmenu.h"
+#include <qcursor.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_popupmenu : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_popupmenu)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functioninsertItem(KviKvsObjectFunctionCall *c);
+ bool functioninsertWidget(KviKvsObjectFunctionCall *c);
+ bool functioninsertHandle(KviKvsObjectFunctionCall *c);
+ bool functionexec(KviKvsObjectFunctionCall *c);
+ bool functionremoveItem(KviKvsObjectFunctionCall *c);
+ bool functionremoveItemAt(KviKvsObjectFunctionCall *c);
+ bool functioninsertSeparator(KviKvsObjectFunctionCall *c);
+ bool functionactivatedEvent(KviKvsObjectFunctionCall *c);
+ bool functionhighlightedEvent(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void slotactivated(int);
+ void slothighlighted(int);
+};
+
+#endif // !_CLASS_POPUPMENU_H_
+
diff --git a/src/modules/objects/class_process.cpp b/src/modules/objects/class_process.cpp
new file mode 100644
index 00000000..81efaae4
--- /dev/null
+++ b/src/modules/objects/class_process.cpp
@@ -0,0 +1,317 @@
+//mdm:
+// File : class_process.h
+// Creation date : Thu Feb 1 14:39:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+#include "class_process.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+#include "kvi_settings.h"
+#include "kvi_locale.h"
+#include <qtimer.h>
+#ifdef COMPILE_USE_QT4
+#include <q3process.h>
+#else
+#include <qprocess.h>
+#endif
+
+/*
+ @doc: process
+ @keyterms:
+ process object class, process
+ @title:
+ process class
+ @type:
+ class
+ @short:
+ A class to manage process.
+ @inherits:
+ [class]object[/class]
+ @description:
+ The Process class is used to start external programs and to communicate with them.[br]
+ !WARNING AT LAST YOU HAVE TO CLOSE THE PROCESS!
+ @functions:
+ !fn: $addArg(<process-name:string>)
+ With this command you give the process name (or more arguments) for comunication.
+ Es: see the next example.
+ !fn: $start()
+ Tries to run the process.[br]
+ Es: [br]
+ %process=$new(process);[br]
+ %process->$addArg("cmd.exe");[br]
+ %process->$start();[br]
+ !fn: <string> $readStdout()
+ Reads the data that the process has written to standard output.
+ !fn: <string> $readStderr()
+ Reads the data that the process has written to standard error.
+ Es:[br]
+ -------------------Start:[br]
+ class (test,object)[br]
+ {[br]
+ slotReadStdout()[br]
+ {[br]
+ %stdo = %Process->$readStdout()[br]
+ #%Aoutput->$append(%stdo);// coming soon in the new texteditor class[br]
+ %Aoutput->$settext(%stdo);[br]
+ }[br]
+ slotReadStderr()[br]
+ {[br]
+ %stderr= %Process->$readStderr()[br]
+ #%Aoutput->$append(%stderr);// coming soon in the new texteditor class[br]
+ %Aoutput->$settext(%stderr);[br]
+ }[br]
+ }[br]
+
+ %tt=$new(test)[br]
+ %A=$new(widget)[br]
+ %A->$setGeometry(100,100,400,300)[br]
+ %layoutA=$new(layout,%A)[br]
+ %Ainput=$new(lineedit,%A)[br]
+ #%Aoutput=$new(textedit,%A)// coming soon in the new texteditor class[br]
+ %Aoutput=$new(label,%A)[br]
+ %bclosekill=$new(button,%A)[br]
+ %bclosekill->$settext("&CloseKill ")[br]
+ %bkill=$new(button,%A)[br]
+ %bkill->$settext("&Kill ")[br]
+ %bterminate=$new(button,%A)[br]
+ %bterminate->$settext("&Ask to Terminate ")[br]
+ %layoutA->$addwidget(%Ainput,0,0)[br]
+ %layoutA->$addwidget(%Aoutput,1,0)[br]
+ %layoutA->$addwidget(%bclosekill,3,0)[br]
+ %layoutA->$addwidget(%bkill,4,0,)[br]
+ %layoutA->$addwidget(%bterminate,5,0)[br]
+
+ %Process=$new(process)[br]
+ %Process->$addArg("cmd.exe")[br]
+ %Process->$start();[br]
+
+ connect %Process readyReadStdout %tt slotReadStdout[br]
+ connect %Process readyReadStderr %tt slotReadStderr[br]
+ privateimpl(%Ainput,returnPressedEvent)[br]
+ {
+ %command=%Ainput->$text() "\r\n"[br]
+ %Process->$writeToStdin(%command);[br]
+ %Ainput->$setText("");[br]
+ }[br]
+
+ privateimpl(%bclosekill,mousepressevent)[br]
+ {[br]
+ %Process->$closekill();[br]
+ delete %A;[br]
+ }[br]
+ privateimpl(%bkill,mousepressevent)[br]
+ {[br]
+ %Process->$kill();[br]
+ delete %A;[br]
+ }[br]
+ privateimpl(%bterminate,mousepressevent)[br]
+ {[br]
+ %Process->$tryTerminate();[br]
+ delete %A;[br]
+ }[br]
+ %A->$show();[br]
+ --------------------End.[br]
+ !fn: $writeToStdin(<command:string>)
+ Whit this command you send a command to the process:
+ !fn: $closekill()
+ This tries to terminate the process the nice way.[br]
+ If the process is still running after 5 seconds, it terminates the process the hard way.[br]
+ (I think that this is the better way.)[br]
+ Es:
+ %Process->close_kill();
+ !fn: $kill()
+ Kill the process in hard way.(Bad Idea)
+ !fn: $tryTerminate()
+ Tries to terminate the process.(It could be well but...)
+ !fn: $closeStdin()
+ Close the standard Input.
+ !fn: <boolean> $isRunning()
+ Return 1 if the process is running, else return 0.
+ !fn: <boolean> $normalExit()
+ Returns TRUE if the process has exited normally; otherwise returns FALSE.
+ !fn: $readyReadStdoutEvent()
+ This function is invoched by the process when there are new datas.[br]
+ The default implementation emits the [classfnc]$readyReadStdout[/classfnc]() signal.
+ !fn: $readyReadStderrEvent()
+ This function is invoched by the process when there are new error messages.[br]
+ The default implementation emits the [classfnc]$readyReadStderr[/classfnc]() signal.
+
+ @signals:
+ !sg: $readyReadStdout()
+ This signal is emitted by the default implementation of [classfnc]$readyReadStdoutEvent[/classfnc]().[br]
+ If you reimplement that function you will have to emit the signal manually (if you still need it).
+ !sg: $readyReadStderr()
+ This signal is emitted by the default implementation of [classfnc]$readyReadStderrEvent[/classfnc]().
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_process,"process","object")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"addArg", functionaddArgument);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"start", functionstartProcess);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"readStdout", functionreadStdout);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"readStderr", functionreadStderr);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"writeToStdin", functionwriteToStdin);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"closekill", functionclosekill);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"kill", functionkill);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"tryTerminate", functiontryTerminate);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"closeStdin", functioncloseStdin);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"isRunning",functionisRunning);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"normalExit",functionnormalExit);
+
+ // Events
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"readyReadStdoutEvent",functionreadyReadStdoutEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_process,"readyReadStderrEvent",functionreadyReadStderrEvent);
+
+ KVSO_END_REGISTERCLASS(KviKvsObject_process)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_process,KviKvsObject)
+
+#ifdef COMPILE_USE_QT4
+ m_pProcess = new Q3Process();
+#else
+ m_pProcess = new QProcess();
+#endif
+ connect(m_pProcess,SIGNAL(readyReadStdout()),this,SLOT(slotReadStdout()));
+ connect(m_pProcess,SIGNAL(readyReadStderr()),this,SLOT(slotReadStderr()));
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_process)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_process)
+
+ delete m_pProcess;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_process)
+
+
+
+bool KviKvsObject_process::functionaddArgument(KviKvsObjectFunctionCall *c)
+{
+
+ QString szArgument;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("argument",KVS_PT_NONEMPTYSTRING,0,szArgument)
+ KVSO_PARAMETERS_END(c)
+ if (m_pProcess) m_pProcess->addArgument(szArgument);
+ return true;
+}
+
+//->Start the process.
+bool KviKvsObject_process::functionstartProcess(KviKvsObjectFunctionCall *c)
+{
+
+ if(!(m_pProcess->start()))
+ c->warning( __tr2qs("Process could not be starded."));
+ return true;
+}
+//-->Read the standard output.
+bool KviKvsObject_process::functionreadStderr(KviKvsObjectFunctionCall *c)
+{
+ QString ng_Process =m_pProcess->readStderr();
+ c->returnValue()->setString(ng_Process);
+ return true;
+}
+
+//-->Read the standard error.
+bool KviKvsObject_process::functionreadStdout(KviKvsObjectFunctionCall *c)
+{
+ QString ng_Process =m_pProcess->readStdout();
+ c->returnValue()->setString(ng_Process);
+ return true;
+}
+//-->Signals and slot to manage reading output and error from the process.
+bool KviKvsObject_process::functionreadyReadStdoutEvent(KviKvsObjectFunctionCall *c)
+{
+
+ emitSignal("readyReadStdout",c);
+ return true;
+
+}
+
+bool KviKvsObject_process::functionreadyReadStderrEvent(KviKvsObjectFunctionCall *c)
+{
+
+ emitSignal("readyReadStderr",c);
+ return true;
+
+}
+bool KviKvsObject_process::functionwriteToStdin(KviKvsObjectFunctionCall *c)
+{
+
+ QString szCommand;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("command",KVS_PT_STRING,0,szCommand)
+ KVSO_PARAMETERS_END(c)
+ if (m_pProcess) m_pProcess->writeToStdin(szCommand);
+
+ return true;
+}
+//-->The 3 Closing process functions
+bool KviKvsObject_process::functionclosekill(KviKvsObjectFunctionCall *c)
+{
+ //I try to to terminate the process the nice way....
+ m_pProcess->tryTerminate();
+ //If the process is still running after 5 seconds, I'll terminate the process in the hard way.
+ QTimer::singleShot( 5000, m_pProcess, SLOT( kill() ) );
+ return true;
+}
+bool KviKvsObject_process::functionkill(KviKvsObjectFunctionCall *c)
+{
+ m_pProcess->kill();
+ return true;
+}
+bool KviKvsObject_process::functiontryTerminate(KviKvsObjectFunctionCall *c)
+{
+ m_pProcess->tryTerminate();
+ return true;
+}
+//-->Close the standard input.
+bool KviKvsObject_process::functioncloseStdin(KviKvsObjectFunctionCall *c)
+{
+
+ m_pProcess->closeStdin();
+ return true;
+}
+//->Returns if the process still runnig
+bool KviKvsObject_process::functionisRunning(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setBoolean(m_pProcess->isRunning());
+ return true;
+}
+//->Returns if the process exited.
+bool KviKvsObject_process::functionnormalExit(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setBoolean(m_pProcess->normalExit());
+ return true;
+}
+
+void KviKvsObject_process::slotReadStdout()
+{
+ KviKvsVariantList *params=0;
+ callFunction(this,"readyReadStdoutEvent",params);
+}
+
+void KviKvsObject_process::slotReadStderr()
+{
+ KviKvsVariantList *params=0;
+ callFunction(this,"readyReadStderrEvent",params);
+}
+
+#include "m_class_process.moc"
diff --git a/src/modules/objects/class_process.h b/src/modules/objects/class_process.h
new file mode 100644
index 00000000..70842950
--- /dev/null
+++ b/src/modules/objects/class_process.h
@@ -0,0 +1,74 @@
+#ifndef _CLASS_PROCESS_H_
+#define _CLASS_PROCESS_H_
+//mdm:
+// File : class_process.h
+// Creation date : Thu Feb 1 14:39:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+#include <qtimer.h>
+#include "class_widget.h"
+
+
+#include "object_macros.h"
+#ifdef COMPILE_USE_QT4
+#include <q3process.h>
+#else
+#include <qprocess.h>
+#endif
+
+
+class KviKvsObject_process : public KviKvsObject
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_process)
+protected:
+
+#ifdef COMPILE_USE_QT4
+ Q3Process * m_pProcess;
+#else
+ QProcess * m_pProcess;
+#endif
+
+public:
+
+ bool functionaddArgument(KviKvsObjectFunctionCall *c);
+ bool functionstartProcess(KviKvsObjectFunctionCall *c);
+ bool functionreadStdout(KviKvsObjectFunctionCall *c);
+ bool functionreadStderr(KviKvsObjectFunctionCall *c);
+ bool functionwriteToStdin(KviKvsObjectFunctionCall *c);
+ bool functionclosekill(KviKvsObjectFunctionCall *c);
+ bool functioncloseStdin(KviKvsObjectFunctionCall *c);
+ bool functionkill(KviKvsObjectFunctionCall *c);
+ bool functiontryTerminate(KviKvsObjectFunctionCall *c);
+ bool functionnormalExit(KviKvsObjectFunctionCall *c);
+ bool functionisRunning(KviKvsObjectFunctionCall *c);
+
+ bool functionreadyReadStdoutEvent(KviKvsObjectFunctionCall *c);
+ bool functionreadyReadStderrEvent(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void slotReadStdout();
+ void slotReadStderr();
+};
+
+
+#endif // !_CLASS_PROCESS_H_
diff --git a/src/modules/objects/class_progressbar.cpp b/src/modules/objects/class_progressbar.cpp
new file mode 100644
index 00000000..12fc5b39
--- /dev/null
+++ b/src/modules/objects/class_progressbar.cpp
@@ -0,0 +1,162 @@
+//
+// File : class_progressbar.cpp
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_progressbar.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+#ifdef COMPILE_USE_QT4
+#include <q3progressbar.h>
+#define KVI_PROGRESS_BAR Q3ProgressBar
+#else
+#include <qprogressbar.h>
+#define KVI_PROGRESS_BAR QProgressBar
+#endif
+
+/*
+ @doc: progressbar
+ @keyterms:
+ progressbar object class,
+ @title:
+ progressbar class
+ @type:
+ class
+ @short:
+ Provides a horizontal progress bar.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This widget can be used to display a horizontal progress bar.
+ @functions:
+ !fn: $setProgress(<steps_value:uinteger>)
+ Set the amount of steps completed.
+ See also [classfnc]$settotalSteps[/classfnc]()
+ !fn: $settotalSteps(<total_steps:uinteger>)
+ The progress bar uses the concept of steps; you give it the total number of steps
+ and the number of steps completed so far and it will display the percentage of steps that have been completed.
+ See also [classfnc]$setProgress[/classfnc]()
+ !fn: $reset()
+ Reset the progress bar.
+ !fn: $setCenterIndicator(<bEnabled:boolean>)
+ Sets whether the indicator string should be centered to on.
+ See also [classfnc]$isCenterIndicator[/classfnc]()
+ !fn: <boolean> $isCenterIndicator()
+ This property holds whether the indicator string should be centered.
+ See also [classfnc]$setCenterIndicator[/classfnc]()
+ !fn: $setPercentageVisible(<bVisible,boolean>)
+ Sets whether the current progress value is displayed.
+ See also [classfnc]$isPercentageVisible[/classfnc]()
+ !fn: <boolean> $ispercentageVisible()
+ This property holds whether the current progress value is displayed.
+ See also [classfnc]$setPercentageVisible[/classfnc]()
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_progressbar,"progressbar","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_progressbar,"setProgress", functionSetProgress)
+ KVSO_REGISTER_HANDLER(KviKvsObject_progressbar,"setTotalSteps", functionSetTotalSteps)
+ KVSO_REGISTER_HANDLER(KviKvsObject_progressbar,"reset", functionReset)
+ KVSO_REGISTER_HANDLER(KviKvsObject_progressbar,"setCenterIndicator", functionSetCenterIndicator)
+ KVSO_REGISTER_HANDLER(KviKvsObject_progressbar,"setPercentageVisible", functionSetPercentageVisible)
+ KVSO_REGISTER_HANDLER(KviKvsObject_progressbar,"isCenterIndicator", functionCenterIndicator)
+ KVSO_REGISTER_HANDLER(KviKvsObject_progressbar,"isPercentageVisible", functionPercentageVisible)
+KVSO_END_REGISTERCLASS(KviKvsObject_progressbar)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_progressbar,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_progressbar)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_progressbar)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_progressbar)
+
+bool KviKvsObject_progressbar::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ #ifdef COMPILE_USE_QT4
+ Q3ProgressBar *pbar=new Q3ProgressBar(parentScriptWidget());
+ pbar->setObjectName(name());
+ setObject(pbar,true);
+ #else
+ setObject(new QProgressBar(parentScriptWidget(), name()), true);
+ #endif
+return true;
+}
+
+bool KviKvsObject_progressbar::functionSetProgress(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t iProgress;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("step_value",KVS_PT_UNSIGNEDINTEGER,0,iProgress)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KVI_PROGRESS_BAR *)widget())->setProgress(iProgress);
+ return true;
+}
+bool KviKvsObject_progressbar::functionSetTotalSteps(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t iSteps;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("total_steps",KVS_PT_UNSIGNEDINTEGER,0,iSteps)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KVI_PROGRESS_BAR *)widget())->setTotalSteps(iSteps);
+ return true;
+}
+
+bool KviKvsObject_progressbar::functionReset(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) ((KVI_PROGRESS_BAR *)widget())->reset();
+ return true;
+}
+
+bool KviKvsObject_progressbar::functionSetCenterIndicator(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((KVI_PROGRESS_BAR *)widget())->setCenterIndicator(bFlag);
+ return true;
+}
+bool KviKvsObject_progressbar::functionCenterIndicator(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setBoolean(((KVI_PROGRESS_BAR *)widget())->centerIndicator());
+ return true;
+}
+
+bool KviKvsObject_progressbar::functionSetPercentageVisible(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KVI_PROGRESS_BAR *)widget())->setPercentageVisible(bEnabled);
+ return true;
+}
+bool KviKvsObject_progressbar::functionPercentageVisible(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setBoolean(((KVI_PROGRESS_BAR *)widget())->percentageVisible());
+ return true;
+}
diff --git a/src/modules/objects/class_progressbar.h b/src/modules/objects/class_progressbar.h
new file mode 100644
index 00000000..44c4eac8
--- /dev/null
+++ b/src/modules/objects/class_progressbar.h
@@ -0,0 +1,51 @@
+#ifndef _CLASS_PROGRESSBAR_H_
+
+#define _CLASS_PROGRESSBAR_H_
+//
+// File : class_progressbar.h
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+//#include <qprogressbar.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_progressbar : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_progressbar)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionSetProgress(KviKvsObjectFunctionCall *c);
+ bool functionSetTotalSteps(KviKvsObjectFunctionCall *c);
+ bool functionReset(KviKvsObjectFunctionCall *c);
+ bool functionSetPercentageVisible(KviKvsObjectFunctionCall *c);
+ bool functionSetCenterIndicator(KviKvsObjectFunctionCall *c);
+ bool functionCenterIndicator(KviKvsObjectFunctionCall *c);
+ bool functionPercentageVisible(KviKvsObjectFunctionCall *c);
+};
+
+
+#endif //!_CLASS_PROGRESSBAR_H_
+
diff --git a/src/modules/objects/class_radiobutton.cpp b/src/modules/objects/class_radiobutton.cpp
new file mode 100644
index 00000000..08211e12
--- /dev/null
+++ b/src/modules/objects/class_radiobutton.cpp
@@ -0,0 +1,138 @@
+//
+// File : class_radiobutton.cpp
+// Creation date : Thu Feb 08 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include "class_radiobutton.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+/*
+ @doc: radiobutton
+ @keyterms:
+ radiobutton widget class
+ @title:
+ radiobutton class
+ @type:
+ class
+ @short:
+ A radiobutton class
+ @inherits:
+ [class]widget[/class]
+ @description:
+ The RadioButton widget provides a radio button with a text or pixmap label.
+ @functions:
+ !fn: $settext(<text:string>)
+ Sets the text that will appear in the radiobutton.
+ !fn: <boolean> $isChecked()
+ Returns 1 (TRUE) if the radio button is checked; otherwise returns 0 (FALSE).
+ !fn: $setChecked(<bChecked:boolean>)
+ Sets whether the radio button is checked to check.
+ !fn: $setPixmap(<image_id>)
+ Sets the pixmap shown on the radiobutton..See the [doc:image_id]image identifier[/doc] documentation for the explaination
+ of the <image_id> parameter.
+ !fn: <bool>$toggleEvent()
+ Called by KVIrc when the radibutton state is toggled.
+ The default implementation emits the toggled(<bool>) signal.
+ !sg: $toggled()
+ This signal is emitted by the default implementation of [classfnc]$toggleEvent[/classfnc]().[br]
+
+
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_radiobutton,"radiobutton","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_radiobutton,"setText", functionSetText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_radiobutton,"setChecked", functionSetChecked)
+ KVSO_REGISTER_HANDLER(KviKvsObject_radiobutton,"isChecked", functionIsChecked)
+ KVSO_REGISTER_HANDLER(KviKvsObject_radiobutton,"setImage", functionSetImage)
+ KVSO_REGISTER_HANDLER(KviKvsObject_radiobutton,"toggleEvent",function_toggleEvent)
+
+KVSO_END_REGISTERCLASS(KviKvsObject_radiobutton)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_radiobutton,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_radiobutton)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_radiobutton)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_radiobutton)
+
+bool KviKvsObject_radiobutton::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QRadioButton(parentScriptWidget(),name()),true);
+ connect(widget(),SIGNAL(toggled(bool)),this,SLOT(toggled(bool)));
+ return true;
+}
+bool KviKvsObject_radiobutton::functionSetText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QRadioButton *)widget())->setText(szText);
+ return true;
+}
+bool KviKvsObject_radiobutton::functionIsChecked(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setBoolean(((QRadioButton *)widget())->isChecked());
+ return true;
+}
+
+bool KviKvsObject_radiobutton::functionSetChecked(KviKvsObjectFunctionCall *c)
+{
+ bool bChecked;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bChecked",KVS_PT_BOOL,0,bChecked)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) ((QRadioButton *)widget())->setChecked(bChecked);
+ return true;
+}
+bool KviKvsObject_radiobutton::functionSetImage(KviKvsObjectFunctionCall *c)
+{
+ QString icon;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("icon_id",KVS_PT_STRING,0,icon)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ QPixmap * pix = g_pIconManager->getImage(icon);
+ if(pix)widget()->setIcon(*pix);
+ return true;
+}
+bool KviKvsObject_radiobutton::function_toggleEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("toggled",c,c->params());
+ return true;
+}
+
+void KviKvsObject_radiobutton::toggled(bool b)
+{
+ KviKvsVariantList params(new KviKvsVariant(b));
+ callFunction(this,"toggleEvent",&params);
+}
+
+
+#include "m_class_radiobutton.moc"
diff --git a/src/modules/objects/class_radiobutton.h b/src/modules/objects/class_radiobutton.h
new file mode 100644
index 00000000..127af8cd
--- /dev/null
+++ b/src/modules/objects/class_radiobutton.h
@@ -0,0 +1,51 @@
+#ifndef _CLASS_RADIOBUTTON_H_
+#define _CLASS_RADIOBUTTON_H_
+//mdm:
+// File : class_radiobutton.h
+// Creation date :Thu Feb 08 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include <qradiobutton.h>
+#include "class_widget.h"
+
+
+#include "object_macros.h"
+
+class KviKvsObject_radiobutton : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_radiobutton)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionSetText(KviKvsObjectFunctionCall *c);
+ bool functionIsChecked(KviKvsObjectFunctionCall *c);
+ bool functionSetChecked(KviKvsObjectFunctionCall *c);
+ bool functionSetImage(KviKvsObjectFunctionCall *c);
+ bool function_toggleEvent(KviKvsObjectFunctionCall *c);
+protected slots:
+ void toggled(bool b);
+
+};
+
+#endif //!_CLASS_RADIOBUTTON_H_
diff --git a/src/modules/objects/class_slider.cpp b/src/modules/objects/class_slider.cpp
new file mode 100644
index 00000000..603e4c9a
--- /dev/null
+++ b/src/modules/objects/class_slider.cpp
@@ -0,0 +1,287 @@
+//mdm :
+// File : class_Slider.cpp
+// Creation date : Mon Gen 27 21:30:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include "class_slider.h"
+#include "kvi_error.h"
+
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+
+/*
+@doc: slider
+ @keyterms:
+ slider object class
+ @title:
+ slider class
+ @type:
+ class
+ @short:
+ The slider widget provides a vertical or horizontal slider.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ The slider is the classic widget for controlling a bounded value.[br]
+ It lets the user move a slider along a horizontal or vertical groove [br]
+ and translates the slider's position into an integer value within the legal range.[/classfnc]()
+ @functions:
+ !fn: $setOrientation(<orientation:string>)
+ Sets the slider's orientation.[br]
+ Orientation value can be "Horizontal" or "Vertical".
+ !fn: $setTracking(<bTracking:boolean>)
+ Sets whether slider tracking is enabled to enable.[br]
+ Value can be 1 or 0.
+ !fn: $setMaxValue(<value:integer>)
+ Sets maximum value for slider's range.
+ !fn: $setMinValue(<minv_value:integer>)
+ Sets minimum value for slider's range.
+ !fn: $setLineStep(<line_step:integer>)
+ Sets the line step to <line_step>.
+ !fn: $setPageStep(<page_step:integer>)
+ Sets the page step to <page_step>.
+ !fn: $setTickmarks(<tick_marks:string>)
+ Sets the tickmark settings for this slider.[br]
+ Values are:[br]
+ NoMarks - do not draw any tickmarks.[br]
+ Both - draw tickmarks on both sides of the groove.[br]
+ Above - draw tickmarks above the (horizontal) slider[br]
+ Below - draw tickmarks below the (horizontal) slider[br]
+ Left - draw tickmarks to the left of the (vertical) slider[br]
+ Right - draw tickmarks to the right of the (vertical) slider
+ !fn: $setTickInterval(<value>)
+ Sets the interval between tickmarks.
+ !fn: <integer> $value()
+ Returns slider value.
+ !fn: <integer> $minValue()
+ Returns slider minValue.
+ !fn: <integer> $maxValue()
+ Returns slider maxValue.
+ !fn: <integer> $lineStep()
+ Returns slider lineStep value.
+ !fn: <integer>$pageStep()
+ Returns slider pageStep value.
+ !fn: $valueChangedEvent(<new slider value:integer>)
+ This function is called by the framework when the slider value is changed and return the new slider value as its argument.[br]
+ The default implementation emits the [classfnc]$valueChanged[/classfnc]() signal,
+ so it is easy to handle the values from many sliders without reimplementing
+ the [classfnc]$valueChangedEvent[/classfnc]() for every one.[br]
+ Note: If you reimplement this function to catch the slider value, you will have to emit the signal by yourself (if you still need it, obviously).
+ @signals:
+ !sg: $valueChanged()
+ This signal is emitted by the default implementation of [classfnc]valueChangedEvent[/classfnc]().[br]
+ If you reimplement that function you will have to emit the signal manually (if you still need it).
+
+*/
+
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_slider,"slider","widget")
+
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setTracking", functionsetTracking);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setValue", functionsetValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setMinValue", functionsetMinValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setMaxValue", functionsetMaxValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setLineStep", functionsetLineStep);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setPageStep", functionsetPageStep);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setTickInterval", functionsetTickInterval);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"value",functionvalue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"minValue", functionminValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"maxValue", functionmaxValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"lineStep", functionlineStep);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"pageStep", functionpageStep);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setTickmarks", functionsetTickmarks);
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"setOrientation", functionsetOrientation);
+
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_slider,"valueChangedEvent", functionvalueChangedEvent);
+KVSO_END_REGISTERCLASS(KviKvsObject_slider)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_slider,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_slider)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_slider)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_slider)
+
+bool KviKvsObject_slider::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QSlider(parentScriptWidget(), name()), true);
+ connect(widget(),SIGNAL(valueChanged(int)),this,SLOT(valueChanged(int)));
+ return true;
+}
+
+bool KviKvsObject_slider::functionsetTracking(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QSlider *)widget())->setTracking(bEnabled);
+ return true;
+}
+
+
+bool KviKvsObject_slider::functionsetValue(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iValue;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("value",KVS_PT_INT,0,iValue)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSlider *)widget())->setValue(iValue);
+ return true;
+}
+bool KviKvsObject_slider::functionsetMinValue(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iMinvalue;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("minimum_value",KVS_PT_INT,0,iMinvalue)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSlider *)widget())->setMinValue(iMinvalue);
+ return true;
+}
+bool KviKvsObject_slider::functionsetMaxValue(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iMaxvalue;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("max_value",KVS_PT_INT,0,iMaxvalue)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSlider *)widget())->setMaxValue(iMaxvalue);
+ return true;
+}
+
+bool KviKvsObject_slider::functionsetLineStep(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iLinestep;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("line_step",KVS_PT_INT,0,iLinestep)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSlider *)widget())->setLineStep(iLinestep);
+ return true;
+}
+bool KviKvsObject_slider::functionsetPageStep(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iPagestep;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_step",KVS_PT_INT,0,iPagestep)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSlider *)widget())->setPageStep(iPagestep);
+ return true;
+}
+
+bool KviKvsObject_slider::functionsetTickInterval(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iInterval;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tick_interval",KVS_PT_INT,0,iInterval)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSlider *)widget())->setTickInterval(iInterval);
+ return true;
+}
+
+bool KviKvsObject_slider::functionvalue(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSlider *)widget())->value());
+ return true;
+}
+
+bool KviKvsObject_slider::functionminValue(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSlider *)widget())->minValue());
+ return true;
+}
+bool KviKvsObject_slider::functionmaxValue(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSlider *)widget())->maxValue());
+ return true;
+}
+bool KviKvsObject_slider::functionlineStep(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSlider *)widget())->lineStep());
+ return true;
+}
+
+bool KviKvsObject_slider::functionpageStep(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSlider *)widget())->pageStep());
+ return true;
+}
+
+
+bool KviKvsObject_slider::functionsetTickmarks(KviKvsObjectFunctionCall *c)
+{
+
+ QString szTick;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tick_marks",KVS_PT_STRING,0,szTick)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szTick,"NoMarks"))
+ ((QSlider *)widget())->setTickmarks(QSlider::NoMarks);
+ else if(KviQString::equalCI(szTick,"Both"))
+ ((QSlider *)widget())->setTickmarks(QSlider::Both);
+ else if(KviQString::equalCI(szTick,"Above"))
+ ((QSlider *)widget())->setTickmarks(QSlider::Above);
+ else if(KviQString::equalCI(szTick,"Below"))
+ ((QSlider *)widget())->setTickmarks(QSlider::Below);
+ else if(KviQString::equalCI(szTick,"Left"))
+ ((QSlider *)widget())->setTickmarks(QSlider::Left);
+ else if(KviQString::equalCI(szTick,"Right"))
+ ((QSlider *)widget())->setTickmarks(QSlider::Right);
+ else c->warning( __tr2qs("Unknown tickmark '%Q'"),&szTick);
+ return true;
+}
+bool KviKvsObject_slider::functionsetOrientation(KviKvsObjectFunctionCall *c)
+{
+
+ QString szOrientation;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("orientation",KVS_PT_STRING,0,szOrientation)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szOrientation,"Horizontal"))
+ ((QSlider *)widget())->setOrientation(Qt::Horizontal);
+ else if(KviQString::equalCI(szOrientation,"Vertical"))
+ ((QSlider *)widget())->setOrientation(Qt::Vertical);
+ else c->warning( __tr2qs("Unknown orientation '%Q'"),&szOrientation);
+ return true;
+}
+bool KviKvsObject_slider::functionvalueChangedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("valueChanged",c,c->params());
+ return true;
+}
+
+void KviKvsObject_slider::valueChanged(int value)
+{
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)value));
+ callFunction(this,"valueChangedEvent",&params);
+}
+
+
+#include "m_class_slider.moc"
diff --git a/src/modules/objects/class_slider.h b/src/modules/objects/class_slider.h
new file mode 100644
index 00000000..e2c8c397
--- /dev/null
+++ b/src/modules/objects/class_slider.h
@@ -0,0 +1,64 @@
+#ifndef _CLASS_SLIDER_H_
+#define _CLASS_SLIDER_H_
+//mdm:
+// File : class_Slider.h
+// Creation date : Mon Gen 27 14:30:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include <qslider.h>
+#include "class_widget.h"
+
+
+#include "object_macros.h"
+
+class KviKvsObject_slider : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_slider)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionsetTracking(KviKvsObjectFunctionCall *c);
+ bool functionsetValue(KviKvsObjectFunctionCall *c);
+ bool functionsetMinValue(KviKvsObjectFunctionCall *c);
+ bool functionsetMaxValue(KviKvsObjectFunctionCall *c);
+ bool functionsetLineStep(KviKvsObjectFunctionCall *c);
+ bool functionsetPageStep(KviKvsObjectFunctionCall *c);
+ bool functionsetTickInterval(KviKvsObjectFunctionCall *c);
+ bool functionvalue(KviKvsObjectFunctionCall *c);
+ bool functionminValue(KviKvsObjectFunctionCall *c);
+ bool functionmaxValue(KviKvsObjectFunctionCall *c);
+ bool functionlineStep(KviKvsObjectFunctionCall *c);
+ bool functionpageStep(KviKvsObjectFunctionCall *c);
+ bool functionsetTickmarks(KviKvsObjectFunctionCall *c);
+ bool functionsetOrientation(KviKvsObjectFunctionCall *c);
+ bool functionvalueChangedEvent(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void valueChanged(int);
+};
+
+
+
+#endif // !_CLASS_SLIDER_H_
+
diff --git a/src/modules/objects/class_socket.cpp b/src/modules/objects/class_socket.cpp
new file mode 100644
index 00000000..f0afe3a5
--- /dev/null
+++ b/src/modules/objects/class_socket.cpp
@@ -0,0 +1,1331 @@
+//
+// File : class_socket.cpp
+// Creation date : Sun Nov 11 03:13:45 2001 GMT by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "kvi_settings.h"
+#include "kvi_qstring.h"
+
+#define _KVI_DEBUG_CHECK_RANGE_
+#include "kvi_debug.h"
+
+
+#include "kvi_locale.h"
+#include "kvi_error.h"
+#include "kvi_netutils.h"
+#include "kvi_dns.h"
+#include "kvi_error.h"
+#include "kvi_socket.h"
+#include "kvi_malloc.h"
+#include "kvi_memmove.h"
+#include "kvi_databuffer.h"
+#include "kvi_qcstring.h"
+
+#include "class_socket.h"
+
+//#include <stdlib.h>
+
+#define KVI_IN_BUFFER_ALLOC_CHUNK 4096
+#define KVI_READ_CHUNK 1024
+/*
+static KviScriptObjectClass * g_pSocketClass = 0;
+
+static KviScriptObject * socketClassCreateInstance(KviScriptObjectClass * cls,KviScriptObject *par,const char * nam)
+{
+ return new KviScriptSocketObject(cls,par,nam);
+}
+
+KviScriptSocketObject::KviScriptSocketObject(KviScriptObjectClass * cla,KviScriptObject * par,const char * nam)
+: KviScriptObject(cla,par,nam)
+{
+ m_uConnectionId = 0;
+ m_sock = KVI_INVALID_SOCKET;
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_DISCONNECTED;
+ m_uRemotePort = 0;
+ m_uSecondaryPort = 0;
+ m_pSn = 0;
+ m_pDns = 0;
+ m_pDelayTimer = 0;
+ m_uConnectTimeout = 60000;
+ m_pInBuffer = 0;
+ m_uInBufferLen = 0;
+ m_uInDataLen = 0;
+ m_pOutBuffer = new KviDataBuffer();
+ m_pFlushTimer = new QTimer();
+ m_bIpV6 = false;
+ m_uLocalPort = 0;
+ m_secondarySock = KVI_INVALID_SOCKET;
+ connect(m_pFlushTimer,SIGNAL(timeout()),this,SLOT(tryFlush()));
+}
+
+KviScriptSocketObject::~KviScriptSocketObject()
+{
+ delete m_pOutBuffer;
+ delete m_pFlushTimer;
+
+ if(m_pInBuffer)kvi_free(m_pInBuffer);
+ if(m_pDelayTimer)delete m_pDelayTimer;
+ if(m_pDns)delete m_pDns;
+ if(m_pSn)delete m_pSn;
+ if(m_sock != KVI_INVALID_SOCKET)kvi_socket_close(m_sock);
+ if(m_secondarySock != KVI_INVALID_SOCKET)kvi_socket_close(m_secondarySock);
+}
+
+void KviScriptSocketObject::reset()
+{
+ m_uConnectionId++; // this is the only place where this is incremented!
+ if(m_pDelayTimer)
+ {
+ delete m_pDelayTimer;
+ m_pDelayTimer = 0;
+ }
+ if(m_pDns)
+ {
+ delete m_pDns;
+ m_pDns = 0;
+ }
+ if(m_pSn)
+ {
+ delete m_pSn;
+ m_pSn = 0;
+ }
+ if(m_sock != KVI_INVALID_SOCKET)
+ {
+ kvi_socket_close(m_sock);
+ m_sock = KVI_INVALID_SOCKET;
+ }
+ if(m_pInBuffer)
+ {
+ kvi_free(m_pInBuffer);
+ m_pInBuffer = 0;
+ }
+ if(m_secondarySock)
+ {
+ kvi_socket_close(m_secondarySock);
+ m_secondarySock = KVI_INVALID_SOCKET;
+ }
+ m_uSecondaryPort = 0;
+ m_szSecondaryIp.clear();
+ delete m_pOutBuffer;
+ if(m_pFlushTimer->isActive())m_pFlushTimer->stop();
+ m_pOutBuffer = new KviDataBuffer();
+ m_uInBufferLen = 0;
+ m_uInDataLen = 0;
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_DISCONNECTED;
+ m_uRemotePort = 0;
+ m_szRemoteIp.clear();
+ m_uLocalPort = 0;
+ m_szLocalIp.clear();
+ m_bIpV6 = false;
+}
+
+/*
+ @doc: socket
+ @keyterms:
+ socket object class
+ @title:
+ socket class
+ @type:
+ class
+ @short:
+ A Ipv4/Ipv6 TCP socket
+ @inherits:
+ [class]object[/class]
+ @description:
+ This class provides a standard TCP/IP socket functionality.[br]
+ It can be used either for connecting to a remote host or to listening for incoming connections.[br]
+ If the KVIrc executable has been compiled with the IPV6 protocol support , this socket also supports it.[br]
+ @functions:
+ !fn: $status()
+ Returns the status of the socket :[br]
+ 4=connected[br]
+ 3=listening[br]
+ 2=connecting[br]
+ 1=in dns call[br]
+ 0=disconnected
+
+ !fn: $connectTimeout()
+ Returns the value of the connect attempt timeout in milliseconds.[br]
+ This is the timeout after that a connection attempt will be considered as failed if the remote
+ host is not responding. You can set it with [classfnc:socket]$setConnectTimeout[/classfnc]().
+
+ !fn: $setConnectTimeout(<timeout>)
+ Sets the connect timeout for this socket. <timeout> must be a positive value in milliseconds.[br]
+ The default timeout is 60000.
+
+ !fn: $connect(<host>,<port>)
+ Attempts a connection to <host> on port <port>.[br]
+ <host> can be a numeric internet address (either Ipv4 or Ipv6 (if supported)) or a hostname.[br]
+ If a hostname is used, a DNS lookup is performed (the socket enters the "dns call" state).[br]
+ This function returns 1 if the connect attempt can be succesfully initiated,
+ 0 otherwise.[br] In fact , this function returns 0 only if the supplied <port> parameter
+ is invalid or the socket is in an incoherent state (already connected or listening):
+ for a newly created socket and with a valid <port> number you can safely ignore
+ the return value.[br]
+ Please note that the connection is asynchronous: when this function returns
+ the socket is NOT connected: it has just initiated the connect attempt
+ and you will be notified of the attempt result by an asynchronous event call:
+ in case of failure , $connectFailedEvent() will be called , in case of
+ succes , $connectEvent() will be called.
+
+ !fn: $listen([<port>[,<interface>[,<force_ipv6>]]])
+ Attempts to listen on the specified <port> and <interface>.[br]
+ If <port> is not passed it is assumed to be 0 , if <interface> is not passed , it is assumed to be
+ "any interface" (INADDR_ANY).[br] Port 0 means that the kernel should choose a "random" port to listen on.[br]
+ If the <interface> is recognized as IPV6 address , and IPV6 is supported , the socket listens
+ in IPV6 mode. If <interface> is an empty string and <force_ipv6> is 1 the socket listens
+ on "any ipv6 interface".[br]
+ This function returns '1' in case of success and '0' in case of failure.[br]
+ On some systems listening in the IPV6 namespace allows to accept also IPV4 connections (this includes
+ linux but not windows afaik).[br]
+ When an incoming connection will arrive , $incomingConnectionEvent() will be called.
+
+ !fn: $accept(<socketId>)
+ This function can be called only from inside $incomingConnectionEvent().[br]
+ <socketId> must be a newly created socket sub-class instance object.[br]
+ The passed object will be set up to handle the incoming connection and this object
+ will remain in listening state (unless you explicitly close it).[br]
+ This function returns '1' in case of success and '0' in case of failure.
+
+ !fn: $connectEvent()
+ This function is called when a connection attempt has been succesfully completed.
+ The socket is actually connected to [classfnc:socket]$remoteIp[/classfnc]() on
+ [classfnc:socket]$remotePort[/classfnc](). You can start
+ writing data and you may expect [classfnc:socket]$dataAvailableEvent[/classfnc]() to be
+ triggered.
+
+ !fn: $incomingConnectionEvent()
+ This function is called when an incoming connection arrives over a socket in listening state.[br]
+ You must call [classfnc:socket]$accept[/classfnc]() passing a newly created socket object
+ to accept and handle the connection.[br] If you don't call [classfnc:socket]$accept[/classfnc]()
+ the incoming connection will be automatically terminated.
+
+ !fn: $connectFailedEvent(<reason>)
+ This function is called when a connection attempt fails for some reason. <reason> contains
+ the error string.[br]
+ This function may be called only between a call to [classfnc:socket]$connect[/classfnc]() and
+ the [classfnc:socket]$connectEvent[/classfnc]().
+
+ !fn: $disconnectEvent([error])
+ This function is called when a connection is terminated either cleanly or because of an error.[br]
+ [error] is an empty string in case of a "clean" termination (connection closed by the remote host)
+ or is a message describing the socket error that caused the connection to be interrupted.
+
+ !fn: $dataAvailableEvent(<data_length>)
+ This function is called when some data is available to be read: the <data_length> parameter specifies
+ the length of the available data in bytes.[br]
+ You can use one of the $read* functions to obtain the data.
+
+ !fn: $read(<length>)
+ Reads at most <length> bytes of data from the socket. If <length> is anything "outside" the
+ available data range (<length> < 0 or <length> > available_data_length), this function
+ returns all the available data.[br]
+ Please note that this function can't deal withi binary data: NULL characters are transformed to
+ ASCII characters 255.
+
+ !fn: $readHex(<length>)
+ Reads at most <length> bytes of data from the socket. If <length> is anything "outside" the
+ available data range (<length> < 0 or <length> > available_data_length), this function
+ returns all the available data.[br]
+ Returns the data encoded as hexadecimal digit string: this function can deal with binary data too.
+
+ !fn: $write(<data>)
+ Writes <data> to the socket.[br]
+ This function can't deal with binary data (you can't send a NULL character)[br]
+ Please note that when this function finishes it does not mean that the data has reached the remote end.[br]
+ Basically it does not even mean that the data has been sent to the remote host.[br]
+ The data is enqueued for sending and will be sent as soon as possible.[br]
+ If you're going to [cmd]delete[/cmd] this object just after the $write call, you should
+ call [classfnc:socket]$close[/classfnc]() just before [cmd]delete[/cmd] to ensure the data delivery.
+
+ !fn: $writeHex(<hex_data>)
+ Writes <data> to the socket.[br]
+ <data> is expected to be a hexadecimal rappresentation of the bytes to be sent (two HEX characters
+ for each byte). This means that the length of <hex_data> string must be a multiple of 2.[br]
+ Returns the length of the actually decoded and sent data in bytes or -1 in case of error (the string
+ was not a valid hexadecimla rappresentation).[br]
+ Please note that when this function finishes it does not mean that the data has reached the remote end.[br]
+ Basically it does not even mean that the data has been sent to the remote host.[br]
+ The data is enqueued for sending and will be sent as soon as possible.[br]
+ If you're going to [cmd]delete[/cmd] this object just after the $writeHex call, you should
+ call [classfnc:socket]$close[/classfnc]() just before [cmd]delete[/cmd] to ensure the data delivery.
+
+ !fn: $close()
+ Resets this socket state: kills any pending or active connection. After a close() call
+ the socket may be used for a new connection.[br]
+ If there is an active connection, there is a last attempt to flush the pending outgoing data.[br]
+ You don't need to call $close() if you [cmd]delete[/cmd] the socket: KVIrc will
+ reset the socket state automatically and free the memory. But if you want to ensure data delivery
+ after a $write call sequece and just before a [cmd]delete[/cmd], $close() is the only chance to do it.
+
+ !fn: $remoteIp()
+ Returns the IP address of the remote end of this socket.[br]
+ The return value is meaningful only if the socket is in connected or connecting state.
+
+ !fn: $setProtocol(<protocol>)
+ Let KVIrc use TCP jr UDP protocol
+
+ !fn: $remotePort()
+ Returns the port of the remote end of this socket.[br]
+ The return value is meaningful only if the socket is in connected or connecting state.
+
+ !fn: $localIp()
+ Returns the IP address of the local end of this socket.[br]
+ The return value is meaningful only if the socket is in connected , listening or connecting state.
+
+ !fn: $localPort()
+ Returns the port of the local end of this socket.[br]
+ The return value is meaningful only if the socket is in connected , listening or connecting state.
+
+@examples:
+ [example]
+ #Server socket: listen 80 port and answer to requests (multi-threaded)[br]
+[br]
+ class (webserver,socket) {[br]
+ constructor () {[br]
+ $$->$listen(80, "127.0.0.1")[br]
+ }[br]
+ incomingConnectionEvent()[br]
+ {[br]
+ %tmp = $new(socket)[br]
+ $$->$accept(%tmp)[br]
+ echo "Webserver incoming Conection from: %tmp->$remoteIp : %tmp->$remotePort"[br]
+ %tmp->$write("HTTP/1.1 200 OK\n\n<html><head></head><body><h1>KVIrc Webserver</h1></body></html>\n")[br]
+ %tmp->$close()[br]
+ delete %tmp[br]
+ }[br]
+ }[br]
+ [br]
+ #finally start webserver[br]
+ %WebS = $new(webserver)[br]
+ [br]
+ [/example]
+ [example]
+ #Client socket - go to google and grab request header[br]
+ class (httprequest,socket) {[br]
+ constructor () [br]
+ {[br]
+ # connect to the server[br]
+ $$->$connect("www.google.de",80)[br]
+ }[br]
+ destructor()[br]
+ {[br]
+ # if the socket is still open close it[br]
+ if($$->$status() == 4) $$->$close()[br]
+ }[br]
+ connectFailedEvent() [br]
+ {[br]
+ # the connection to the server failed[br]
+ echo "Connection failed: "$0[br]
+ delete $$[br]
+ }[br]
+ connectEvent() [br]
+ {[br]
+ # connection is complete[br]
+ # send a request to receive the headers only from http://www.google.de/[br]
+ $$->$write("HEAD / HTTP/1.1\r\nHost: www.google.de\r\nConnction: Close\r\nUser-Agent: KVIrc socket\r\n\r\n");[br]
+ }[br]
+ dataAvailableEvent() [br]
+ {[br]
+ # reading the received data[br]
+ %newdata = $$->$read($0)[br]
+ echo %newdata[br]
+ #close and delete the socket[br]
+ $$->$close()[br]
+ delete $$[br]
+ }[br]
+ disconnectEvent() [br]
+ {[br]
+ # connection has been closed[br]
+ echo "Connection closed"[br]
+ delete $$[br]
+ }[br]
+}[br]
+
+#Creating the socket[br]
+%Temp = $new(httprequest)[br]
+ [/example]
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_socket,"socket","object")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"status",functionStatus)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"remotePort",functionRemotePort)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"remoteIp",functionRemoteIp)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"localIp",functionLocalIp)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"localPort",functionLocalPort)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"connect",functionConnect)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"connectTimeout",functionConnectTimeout)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"setConnectTimeout",functionSetConnectTimeout)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"close",functionClose)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"read",functionRead)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"readHex",functionReadHex)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"write",functionWrite)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"writeHex",functionWriteHex)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"setProtocol",functionSetProtocol)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"listen",functionListen)
+ KVSO_REGISTER_HANDLER(KviKvsObject_socket,"accept",functionAccept)
+
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_socket,"connectEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_socket,"connectFailedEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_socket,"disconnectEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_socket,"dataAvailableEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_socket,"incomingConnectionEvent")
+
+KVSO_END_REGISTERCLASS(KviKvsObject_socket)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_socket,KviKvsObject)
+
+
+ m_bUdp = false;
+ m_uConnectionId = 0;
+ m_sock = KVI_INVALID_SOCKET;
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_DISCONNECTED;
+ m_uRemotePort = 0;
+ m_uSecondaryPort = 0;
+ m_pSn = 0;
+ m_pDns = 0;
+ m_pDelayTimer = 0;
+ m_uConnectTimeout = 60000;
+ m_pInBuffer = 0;
+ m_uInBufferLen = 0;
+ m_uInDataLen = 0;
+ m_pOutBuffer = new KviDataBuffer();
+ m_pFlushTimer = new QTimer();
+ m_bIpV6 = false;
+ m_uLocalPort = 0;
+ m_secondarySock = KVI_INVALID_SOCKET;
+ connect(m_pFlushTimer,SIGNAL(timeout()),this,SLOT(tryFlush()));
+KVSO_END_CONSTRUCTOR(KviKvsObject_socket)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_socket)
+ delete m_pOutBuffer;
+ delete m_pFlushTimer;
+
+ if(m_pInBuffer)kvi_free(m_pInBuffer);
+ if(m_pDelayTimer)delete m_pDelayTimer;
+ if(m_pDns)delete m_pDns;
+ if(m_pSn)delete m_pSn;
+ if(m_sock != KVI_INVALID_SOCKET)kvi_socket_close(m_sock);
+ if(m_secondarySock != KVI_INVALID_SOCKET)kvi_socket_close(m_secondarySock);
+KVSO_END_DESTRUCTOR(KviKvsObject_socket)
+//----------------------
+
+
+bool KviKvsObject_socket::functionStatus(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setInteger(m_iStatus);
+ return true;
+}
+
+bool KviKvsObject_socket::functionClose(KviKvsObjectFunctionCall *c)
+{
+ if((m_pOutBuffer->size() != 0) && (m_iStatus == KVI_SCRIPT_SOCKET_STATUS_CONNECTED))
+ tryFlush();
+
+ reset();
+ return true;
+}
+
+bool KviKvsObject_socket::functionConnectTimeout(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setInteger(m_uConnectTimeout);
+ return true;
+}
+
+bool KviKvsObject_socket::functionSetConnectTimeout(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uTimeout;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("time_out",KVS_PT_UNSIGNEDINTEGER,0,uTimeout)
+ KVSO_PARAMETERS_END(c)
+ m_uConnectTimeout = uTimeout;
+ return true;
+}
+
+bool KviKvsObject_socket::functionRemotePort(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setInteger(m_uRemotePort);
+ return true;
+}
+
+bool KviKvsObject_socket::functionRemoteIp(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setString(m_szRemoteIp);
+ return true;
+}
+
+bool KviKvsObject_socket::functionLocalPort(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setInteger(m_uLocalPort);
+ return true;
+}
+
+bool KviKvsObject_socket::functionLocalIp(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setString(m_szLocalIp);
+ return true;
+}
+
+bool KviKvsObject_socket::functionAccept(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject * pObject;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("object_socket",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+
+ pObject = KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+
+ if(!pObject)
+ {
+ c->warning(__tr2qs("No socket object specified"));
+ return true;
+ }
+
+ if(!pObject->inherits("KviKvsObject_socket"))
+ {
+ c->warning(__tr2qs("Invalid socket object specified (it doesn't inherit from socket)"));
+ return true;
+ }
+
+ if(m_secondarySock != KVI_INVALID_SOCKET)
+ {
+ ((KviKvsObject_socket *)pObject)->acceptConnection(m_secondarySock,m_uSecondaryPort,m_szSecondaryIp);
+
+ m_secondarySock = KVI_INVALID_SOCKET;
+ m_uSecondaryPort = 0;
+ m_szSecondaryIp="";
+ } else {
+ c->warning(__tr2qs("There is no connection to accept!"));
+ }
+ return true;
+}
+
+
+bool KviKvsObject_socket::functionSetProtocol(KviKvsObjectFunctionCall *c)
+{
+ QString m_szHex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("hex_string",KVS_PT_STRING,0,m_szHex)
+ KVSO_PARAMETERS_END(c)
+
+ m_bUdp=KviQString::equalCI(m_szHex,"udp");
+ return false;
+}
+
+bool KviKvsObject_socket::functionWriteHex(KviKvsObjectFunctionCall *c)
+{
+ QString m_szHex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("hex_string",KVS_PT_STRING,0,m_szHex)
+ KVSO_PARAMETERS_END(c)
+
+ if(m_szHex.length() > 0)
+ {
+ bool bOk;
+ QString szTmp;
+ szTmp=m_szHex.setNum(m_szHex.toInt(&bOk,16),16);
+ if(szTmp.length()>0)
+ {
+ KviQCString szData8 = szTmp.utf8();
+ m_pOutBuffer->append((const unsigned char *)(szData8.data()),szData8.length());
+ delayedFlush(0);
+ c->returnValue()->setInteger(szData8.length());
+ }
+ }
+
+ /*
+ if(pszData)
+ {
+ if(pszData->len() > 0)
+ {
+ char * ptr;
+ len = pszData->hexToBuffer(&ptr);
+ if(len > 0)
+ {
+ m_pOutBuffer->append((const unsigned char *)(ptr),len);
+ delayedFlush(0);
+ KviStr::freeBuffer(ptr);
+ }
+ }
+ }
+ buffer.append(KviStr::Format,"%d",len);
+*/
+ return true;
+}
+
+
+
+
+
+bool KviKvsObject_socket::functionConnect(KviKvsObjectFunctionCall *c)
+{
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("remote_ip",KVS_PT_STRING,0,m_szRemoteIp)
+ KVSO_PARAMETER("remote_port",KVS_PT_UNSIGNEDINTEGER,0,m_uRemotePort)
+ KVSO_PARAMETERS_END(c)
+ debug ("Function connect");
+
+
+ if (m_uRemotePort>65535)
+ {
+ c->warning(__tr2qs("Value %d for port is out of range (values allowed are from 0 to 65535"),m_uRemotePort);
+ return true;
+ }
+ if((m_sock != KVI_INVALID_SOCKET) || (m_iStatus != KVI_SCRIPT_SOCKET_STATUS_DISCONNECTED))
+ {
+ c->warning(__tr2qs("Another connection in progress"));
+ c->returnValue()->setBoolean(true);
+ return true;
+ }
+
+
+#ifdef COMPILE_IPV6_SUPPORT
+ if(kvi_isValidStringIp(m_szRemoteIp) || kvi_isValidStringIp_V6(m_szRemoteIp))
+#else
+ if(kvi_isValidStringIp(m_szRemoteIp))
+#endif
+ {
+ debug ("ok connecting");
+ debug ("connectinhg on ip %s ",m_szRemoteIp.latin1());
+ debug ("non so ip");
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_CONNECTING;
+ delayedConnect();
+ } else {
+ debug ("connectinhg on ip %s port %d",m_szRemoteIp.latin1(),m_uRemotePort);
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_DNS;
+ delayedLookupRemoteIp();
+ }
+ c->returnValue()->setBoolean(true);
+ return true;
+}
+
+
+
+
+
+
+bool KviKvsObject_socket::functionListen(KviKvsObjectFunctionCall *c)
+{
+ if((m_sock != KVI_INVALID_SOCKET) || (m_iStatus != KVI_SCRIPT_SOCKET_STATUS_DISCONNECTED))
+ {
+ c->warning(__tr2qs("Another connection in progress"));
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ kvs_uint_t uLocalPort;
+ QString m_szLocalIp;
+ bool m_bIpV6;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("local_port",KVS_PT_UNSIGNEDINTEGER,0,uLocalPort)
+ KVSO_PARAMETER("local_ip",KVS_PT_STRING,KVS_PF_OPTIONAL,m_szLocalIp)
+ KVSO_PARAMETER("bool_ipV6",KVS_PT_BOOLEAN,KVS_PF_OPTIONAL,m_bIpV6)
+ KVSO_PARAMETERS_END(c)
+ m_uLocalPort=uLocalPort;
+
+#ifndef COMPILE_IPV6_SUPPORT
+ if(m_bIpV6)
+ {
+ c->warning(__tr2qs("No IPV6 support in this executable"));
+ c->returnValue()->setBoolean(false);
+ reset();
+ return true;
+ }
+#endif
+
+ bool bGotIp = false;
+
+ if(!m_szLocalIp.isEmpty())
+ {
+
+ // Check the address type
+ if(kvi_isValidStringIp(m_szLocalIp))bGotIp = true;
+ else {
+#ifdef COMPILE_IPV6_SUPPORT
+ if(kvi_isValidStringIp_V6(m_szLocalIp))
+ {
+ bGotIp = true;
+ m_bIpV6 = true;
+ } else {
+#else
+ c->warning(__tr2qs("Invalid IP address specified ('%Q')"),&m_szLocalIp);
+ c->returnValue()->setBoolean(false);
+ reset();
+ return true;
+#endif
+#ifdef COMPILE_IPV6_SUPPORT
+ }
+#endif
+ }
+ }
+
+
+#ifdef COMPILE_IPV6_SUPPORT
+ m_sock = kvi_socket_create(m_bIpV6 ? KVI_SOCKET_PF_INET6 : KVI_SOCKET_PF_INET,
+ m_bUdp ? KVI_SOCKET_TYPE_DGRAM : KVI_SOCKET_TYPE_STREAM,KVI_SOCKET_PROTO_TCP);
+#else
+ m_sock = kvi_socket_create(KVI_SOCKET_PF_INET,m_bUdp ? KVI_SOCKET_TYPE_DGRAM : KVI_SOCKET_TYPE_STREAM,KVI_SOCKET_PROTO_TCP);
+#endif
+
+ if(m_sock == KVI_INVALID_SOCKET)
+ {
+ c->warning(__tr2qs("Socket creation failed"));
+ c->returnValue()->setBoolean(false);
+ reset();
+ return true;
+ }
+
+ if(!m_szLocalIp.isEmpty())
+ {
+#ifdef COMPILE_IPV6_SUPPORT
+ KviSockaddr sa(m_szLocalIp,m_uLocalPort,m_bIpV6,m_bUdp);
+#else
+ KviSockaddr sa(m_szLocalIp,m_uLocalPort,false,m_bUdp);
+#endif
+ if(!sa.socketAddress())
+ {
+ c->warning(__tr2qs("Invalid socket address"));
+ reset();
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+
+ if(!kvi_socket_bind(m_sock,sa.socketAddress(),((int)(sa.addressLength()))))
+ {
+ c->warning(__tr2qs("Bind failure"));
+ reset();
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ } else {
+#ifdef COMPILE_IPV6_SUPPORT
+ KviSockaddr sa(m_uLocalPort,m_bIpV6,m_bUdp);
+#else
+ KviSockaddr sa(m_uLocalPort,false,m_bUdp);
+#endif
+ if(!sa.socketAddress())
+ {
+ c->warning(__tr2qs("Invalid socket address"));
+ reset();
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+
+ if(!kvi_socket_bind(m_sock,sa.socketAddress(),((int)(sa.addressLength()))))
+ {
+ c->warning(__tr2qs("Bind failure"));
+ reset();
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+ }
+
+
+ if(!kvi_socket_listen(m_sock,5))
+ {
+ c->warning(__tr2qs("Listen failure"));
+ reset();
+ c->returnValue()->setBoolean(false);
+ return true;
+ }
+
+
+ // Reread the port in case we're binding to a random one (0)
+
+#ifdef COMPILE_IPV6_SUPPORT
+ KviSockaddr sareal(0,m_bIpV6,m_bUdp);
+#else
+ KviSockaddr sareal(0,false,m_bUdp);
+#endif
+
+ int size = (int)sareal.addressLength();
+
+ if(kvi_socket_getsockname(m_sock,sareal.socketAddress(),&size))
+ {
+ m_uLocalPort = sareal.port();
+ sareal.getStringAddress(m_szLocalIp);
+ }
+
+ // and setup the READ notifier...
+ m_pSn = new QSocketNotifier(m_sock,QSocketNotifier::Read);
+ QObject::connect(m_pSn,SIGNAL(activated(int)),this,SLOT(incomingConnection(int)));
+ m_pSn->setEnabled(true);
+
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_LISTENING;
+
+ c->returnValue()->setBoolean(true);
+ return true;
+}
+
+void KviKvsObject_socket::incomingConnection(int)
+{
+#ifdef COMPILE_IPV6_SUPPORT
+ struct sockaddr_in6 hostSockAddr6;
+#endif
+ struct sockaddr_in hostSockAddr;
+
+ int size = sizeof(hostSockAddr);
+ struct sockaddr * addr = (struct sockaddr *)&hostSockAddr;
+
+#ifdef COMPILE_IPV6_SUPPORT
+ if(m_bIpV6)
+ {
+ addr = (struct sockaddr *)&hostSockAddr6;
+ size = sizeof(hostSockAddr6);
+ }
+#endif
+
+ // Incoming connection
+ m_secondarySock = kvi_socket_accept(m_sock,addr,&size);
+ if(m_secondarySock != KVI_INVALID_SOCKET)
+ {
+ // Connected
+#ifdef COMPILE_IPV6_SUPPORT
+ if(m_bIpV6)
+ {
+ m_uSecondaryPort = ntohs(((struct sockaddr_in6 *)addr)->sin6_port);
+ if(!kvi_binaryIpToStringIp_V6(((struct sockaddr_in6 *)addr)->sin6_addr,m_szSecondaryIp))
+ m_szSecondaryIp = __tr("unknown");
+ } else {
+#endif
+ m_uSecondaryPort = ntohs(((struct sockaddr_in *)addr)->sin_port);
+ if(!kvi_binaryIpToStringIp(((struct sockaddr_in *)addr)->sin_addr,m_szSecondaryIp))
+ m_szSecondaryIp = __tr("unknown");
+#ifdef COMPILE_IPV6_SUPPORT
+ }
+#endif
+ KviKvsVariantList *params=0;
+ callFunction(this,"incomingConnectionEvent",params);
+ if(m_secondarySock != KVI_INVALID_SOCKET)
+ {
+ kvi_socket_close(m_secondarySock);
+ m_secondarySock = KVI_INVALID_SOCKET;
+ m_uSecondaryPort = 0;
+ m_szSecondaryIp="";
+ }
+
+ } // else..huh ?... wait for the next notifier call
+}
+
+void KviKvsObject_socket::acceptConnection(kvi_socket_t s,kvi_u32_t uPort,const char * szIp)
+{
+ reset();
+ m_sock = s;
+ m_uRemotePort = uPort;
+ m_szRemoteIp = szIp;
+#ifdef COMPILE_IPV6_SUPPORT
+ KviSockaddr sareal(0,m_bIpV6,m_bUdp);
+#else
+ KviSockaddr sareal(0,false,m_bUdp);
+#endif
+
+ int size = (int)sareal.addressLength();
+
+ if(kvi_socket_getsockname(m_sock,sareal.socketAddress(),&size))
+ {
+ m_uLocalPort = sareal.port();
+ sareal.getStringAddress(m_szLocalIp);
+ }
+
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_CONNECTED;
+
+ m_pSn = new QSocketNotifier((int)m_sock,QSocketNotifier::Read);
+ QObject::connect(m_pSn,SIGNAL(activated(int)),this,SLOT(readNotifierFired(int)));
+ m_pSn->setEnabled(true);
+}
+
+void KviKvsObject_socket::delayedConnect()
+{
+ if(m_pDelayTimer)delete m_pDelayTimer;
+ m_pDelayTimer = new QTimer();
+ connect(m_pDelayTimer,SIGNAL(timeout()),this,SLOT(doConnect()));
+ m_pDelayTimer->start(0,true);
+}
+
+void KviKvsObject_socket::doConnect()
+{
+ debug ("doConnect function");
+ if(m_pDelayTimer)delete m_pDelayTimer;
+ m_pDelayTimer = 0;
+
+
+ KviSockaddr sa(m_szRemoteIp,m_uRemotePort,!kvi_isValidStringIp(m_szRemoteIp),m_bUdp);
+
+ if(!sa.socketAddress())
+ {
+ unsigned int uOldConnectionId = m_uConnectionId;
+ QString ipAddressError=__tr2qs("Invalid ip address ");
+
+ ipAddressError.append(m_szRemoteIp);
+
+ KviKvsVariantList params;
+ QString tmp;
+ KviQString::sprintf(tmp,__tr2qs("Invalid ip address (%Q)"),&m_szRemoteIp);
+ params.append(new KviKvsVariant(tmp));
+ callFunction(this,"connectFailedEvent",&params);
+ /* callEventFunction("connectFailedEvent",0,new KviParameterList(
+ new KviStr(KviStr::Format,__tr("Invalid ip address (%s)"),m_szRemoteIp.ptr())));
+ */ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ }
+debug ("Socket created");
+
+ // create the socket
+#ifdef COMPILE_IPV6_SUPPORT
+ m_bIpV6 = sa.isIpV6();
+ m_sock = kvi_socket_create(sa.isIpV6() ? KVI_SOCKET_PF_INET6 : KVI_SOCKET_PF_INET,m_bUdp ? KVI_SOCKET_TYPE_DGRAM : KVI_SOCKET_TYPE_STREAM,KVI_SOCKET_PROTO_TCP);
+#else
+ m_bIpV6 = false;
+ m_sock = kvi_socket_create(KVI_SOCKET_PF_INET,m_bUdp ? KVI_SOCKET_TYPE_DGRAM : KVI_SOCKET_TYPE_STREAM,KVI_SOCKET_PROTO_TCP);
+#endif
+
+ if(m_sock == KVI_INVALID_SOCKET)
+ {
+ unsigned int uOldConnectionId = m_uConnectionId;
+ callFunction(this,"connectFailedEvent",new KviKvsVariantList(
+ new KviKvsVariant(__tr2qs("Failed to create the socket"))));
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ }
+ debug ("Valid socket");
+
+ if(!kvi_socket_setNonBlocking(m_sock))
+ {
+ unsigned int uOldConnectionId = m_uConnectionId;
+
+ callFunction(this,"connectFailedEvent",new KviKvsVariantList(
+ new KviKvsVariant(__tr2qs("Failed to setup a nonblocking socket"))));
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ }
+
+ if(!kvi_socket_connect(m_sock,sa.socketAddress(),((int)(sa.addressLength()))))
+ {
+ int err = kvi_socket_error();
+ if(!kvi_socket_recoverableConnectError(err))
+ {
+ // Ops...
+ int sockError=err;
+ if(sockError==0)
+ {
+ // Zero error ?...let's look closer
+ int iSize=sizeof(int);
+ if(!kvi_socket_getsockopt(m_sock,SOL_SOCKET,SO_ERROR,
+ (void *)&sockError,&iSize))sockError=0;
+ }
+ unsigned int uOldConnectionId = m_uConnectionId;
+ QString callBackError=__tr2qs("Connect failure: ");
+
+ callBackError.append((KviError::getDescription(KviError::translateSystemError(sockError)).utf8().data()));
+ callFunction(this,"connectFailedEvent",new KviKvsVariantList(
+ new KviKvsVariant(callBackError)));
+
+/* callEventFunction("connectFailedEvent",0,new KviParameterList(
+ new KviStr(KviStr::Format,__tr("Connect failure: %s"),KviError::getDescription(KviError::translateSystemError(sockError)).utf8().data())));
+*/ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ }
+ }
+ debug ("Socket connected");
+ m_pDelayTimer = new QTimer();
+ connect(m_pDelayTimer,SIGNAL(timeout()),this,SLOT(connectTimeout()));
+ m_pDelayTimer->start(m_uConnectTimeout,true);
+
+ m_pSn = new QSocketNotifier((int)m_sock,QSocketNotifier::Write);
+ QObject::connect(m_pSn,SIGNAL(activated(int)),this,SLOT(writeNotifierFired(int)));
+ m_pSn->setEnabled(true);
+}
+
+void KviKvsObject_socket::connectTimeout()
+{
+ unsigned int uOldConnectionId = m_uConnectionId;
+
+ callFunction(this,"connectFailedEvent",new KviKvsVariantList(
+ new KviKvsVariant(__tr2qs("Connect attempt timed out"))));
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+}
+
+void KviKvsObject_socket::delayedLookupRemoteIp()
+{
+ if(m_pDelayTimer)delete m_pDelayTimer;
+ m_pDelayTimer = new QTimer();
+ connect(m_pDelayTimer,SIGNAL(timeout()),this,SLOT(lookupRemoteIp()));
+ m_pDelayTimer->start(0,true);
+}
+
+void KviKvsObject_socket::lookupRemoteIp()
+{
+ debug ("Resolve dns");
+ if(m_pDelayTimer)delete m_pDelayTimer;
+ m_pDelayTimer = 0;
+ if(m_pDns)delete m_pDns;
+ m_pDns = new KviDns();
+ connect(m_pDns,SIGNAL(lookupDone(KviDns *)),this,SLOT(lookupDone(KviDns *)));
+ if(!m_pDns->lookup(m_szRemoteIp,KviDns::Any))
+ {
+ unsigned int uOldConnectionId = m_uConnectionId;
+
+ callFunction(this,"connectFailedEvent",new KviKvsVariantList(
+ new KviKvsVariant(__tr2qs("Can't start the DNS thread"))));
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ }
+}
+
+void KviKvsObject_socket::lookupDone(KviDns *pDns)
+{
+
+ if(pDns->state() != KviDns::Success)
+ {
+ unsigned int uOldConnectionId = m_uConnectionId;
+
+ callFunction(this,"connectFailedEvent",new KviKvsVariantList(
+ new KviKvsVariant(KviError::getDescription(pDns->error()))));
+
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ }
+ m_szRemoteIp = pDns->firstIpAddress();
+ debug ("Dns resolved in %s",m_szRemoteIp.latin1());
+
+ delete m_pDns;
+ m_pDns = 0;
+ doConnect();
+}
+
+void KviKvsObject_socket::writeNotifierFired(int)
+{
+ debug ("Here in the writeNotifierFired");
+ if(m_pSn)
+ {
+ delete m_pSn;
+ m_pSn = 0;
+ }
+ if(m_pDelayTimer)
+ {
+ delete m_pDelayTimer;
+ m_pDelayTimer = 0;
+ }
+
+ // Check for errors...
+ int sockError;
+ int iSize=sizeof(int);
+ if(!kvi_socket_getsockopt(m_sock,SOL_SOCKET,SO_ERROR,(void *)&sockError,&iSize))sockError = -1;
+ //sockError = 0;
+ if(sockError != 0)
+ {
+ //debug("Failed here %d",sockError);
+ //failed
+ if(sockError > 0)sockError = KviError::translateSystemError(sockError);
+ else sockError = KviError_unknownError; //Error 0 ?
+ unsigned int uOldConnectionId = m_uConnectionId;
+ callFunction(this,"connectFailedEvent",new KviKvsVariantList(
+ new KviKvsVariant(KviError::getDescription(sockError))));
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ } else {
+ // Succesfully connected
+ // create the correct read notifier now...
+ m_pSn = new QSocketNotifier((int)m_sock,QSocketNotifier::Read);
+ QObject::connect(m_pSn,SIGNAL(activated(int)),this,SLOT(readNotifierFired(int)));
+ m_pSn->setEnabled(true);
+
+#ifdef COMPILE_IPV6_SUPPORT
+ KviSockaddr sareal(0,m_bIpV6,m_bUdp);
+#else
+ KviSockaddr sareal(0,false,m_bUdp);
+#endif
+ int size = (int)sareal.addressLength();
+ if(kvi_socket_getsockname(m_sock,sareal.socketAddress(),&size))
+ {
+ m_uLocalPort = sareal.port();
+ sareal.getStringAddress(m_szLocalIp);
+ }
+ unsigned int uOldConnectionId = m_uConnectionId;
+ KviKvsVariantList *params=0;
+ callFunction(this,"connectEvent",params);
+ if(m_uConnectionId == uOldConnectionId)
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_CONNECTED;
+ // else the connection has been already changed!
+ }
+}
+
+void KviKvsObject_socket::readNotifierFired(int)
+{
+ debug ("here in the readNotifierFired");
+ //read data
+ if((m_uInBufferLen - m_uInDataLen) < KVI_READ_CHUNK)
+ {
+ m_uInBufferLen += KVI_IN_BUFFER_ALLOC_CHUNK;
+ m_pInBuffer = (char *)kvi_realloc(m_pInBuffer,m_uInBufferLen);
+ }
+
+ int readLength = kvi_socket_recv(m_sock,m_pInBuffer + m_uInDataLen,KVI_READ_CHUNK);
+
+ if(readLength <= 0)
+ {
+ if(readLength==0)
+ {
+ unsigned int uOldConnectionId = m_uConnectionId;
+ KviKvsVariantList *params=0;
+ callFunction(this,"disconnectEvent",params);
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ } else {
+ //check for transmission errors
+ int err = kvi_socket_error();
+#ifdef COMPILE_ON_WINDOWS
+ if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK))
+#else
+ if((err != EAGAIN) && (err != EINTR))
+#endif
+ {
+ unsigned int uOldConnectionId = m_uConnectionId;
+ if(err > 0)
+
+ {
+ // QString error=KviError::translateSystemError(err);
+ callFunction(this,"disconnectEvent",new KviKvsVariantList(
+ new KviKvsVariant((kvs_int_t)KviError::translateSystemError(err))));
+ } else {
+ callFunction(this,"disconnectEvent",new KviKvsVariantList(
+ new KviKvsVariant(KviError::getDescription(KviError_remoteEndClosedConnection))));
+
+ }
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ } //else transient error...wait again...
+ }
+ return; // can do nothing
+ }
+ // readLength > 0
+ m_uInDataLen += readLength;
+
+ //KviStr * s = new KviStr();
+ QString s;
+ s.setNum(m_uInDataLen);
+
+
+ unsigned int uOldConnectionId = m_uConnectionId;
+ callFunction(this,"dataAvailableEvent",new KviKvsVariantList(new KviKvsVariant(s)));
+ if(m_uConnectionId == uOldConnectionId)
+ {
+ if(m_uInDataLen > (4096 * 1024)) // too much data in buffer (not reading)
+ {
+ callFunction(this,"disconnectEvent",new KviKvsVariantList(
+ new KviKvsVariant(__tr2qs("Too much unprocessed incoming data (you've left this socket unmanaged ?)"))));
+ reset();
+ }
+ }
+}
+
+void KviKvsObject_socket::eatInData(unsigned int uLen)
+{
+ if(uLen > m_uInDataLen)uLen = m_uInDataLen;
+
+ m_uInDataLen -= uLen;
+
+ if(m_uInDataLen > 0)
+ {
+ kvi_memmove(m_pInBuffer,m_pInBuffer + uLen,m_uInDataLen);
+ }
+
+ unsigned int uSpace = m_uInBufferLen - m_uInDataLen;
+
+ if(uSpace > KVI_IN_BUFFER_ALLOC_CHUNK)
+ {
+ m_uInBufferLen -= KVI_IN_BUFFER_ALLOC_CHUNK;
+ m_pInBuffer = (char *)kvi_realloc(m_pInBuffer,m_uInBufferLen);
+ }
+}
+
+void KviKvsObject_socket::delayedFlush(unsigned int uTimeout)
+{
+ if(m_pFlushTimer->isActive())m_pFlushTimer->stop();
+ m_pFlushTimer->start(uTimeout);
+}
+
+void KviKvsObject_socket::tryFlush()
+{
+ if(m_pFlushTimer->isActive())m_pFlushTimer->stop();
+
+ if(m_pOutBuffer->size() == 0)
+ {
+ return;
+ }
+
+ int result = kvi_socket_send(m_sock,m_pOutBuffer->data(),m_pOutBuffer->size());
+
+ if(result >= 0)
+ {
+ if(result == m_pOutBuffer->size())
+ {
+ m_pOutBuffer->clear();
+ } else {
+ if(result > 0)m_pOutBuffer->remove(result);
+ delayedFlush(500);
+ }
+ } else {
+ // Oops...error ?
+ int err = kvi_socket_error();
+#ifdef COMPILE_ON_WINDOWS
+ if((err == EAGAIN) || (err == EINTR) || (err = WSAEWOULDBLOCK))
+#else
+ if((err == EAGAIN)||(err == EINTR))
+#endif
+ {
+ // Transient error...partial send as before...
+ // Async continue...
+ delayedFlush(500);
+ return;
+ } else {
+ // Disconnected... :(
+ unsigned int uOldConnectionId = m_uConnectionId;
+ callFunction(this,"disconnectEvent",0,new KviKvsVariantList(
+ new KviKvsVariant(KviError::getDescription(KviError::translateSystemError(err)))));
+ if(m_uConnectionId == uOldConnectionId)reset();
+ // else it has already been called!
+ return;
+ }
+ }
+}
+void KviKvsObject_socket::reset()
+{
+ m_uConnectionId++; // this is the only place where this is incremented!
+ if(m_pDelayTimer)
+ {
+ delete m_pDelayTimer;
+ m_pDelayTimer = 0;
+ }
+ if(m_pDns)
+ {
+ delete m_pDns;
+ m_pDns = 0;
+ }
+ if(m_pSn)
+ {
+ delete m_pSn;
+ m_pSn = 0;
+ }
+ if(m_sock != KVI_INVALID_SOCKET)
+ {
+ kvi_socket_close(m_sock);
+ m_sock = KVI_INVALID_SOCKET;
+ }
+ if(m_pInBuffer)
+ {
+ kvi_free(m_pInBuffer);
+ m_pInBuffer = 0;
+ }
+ if(m_secondarySock)
+ {
+ kvi_socket_close(m_secondarySock);
+ m_secondarySock = KVI_INVALID_SOCKET;
+ }
+ m_uSecondaryPort = 0;
+ m_szSecondaryIp="";
+ delete m_pOutBuffer;
+ if(m_pFlushTimer->isActive())m_pFlushTimer->stop();
+ m_pOutBuffer = new KviDataBuffer();
+ m_uInBufferLen = 0;
+ m_uInDataLen = 0;
+ m_iStatus = KVI_SCRIPT_SOCKET_STATUS_DISCONNECTED;
+ m_uRemotePort = 0;
+ m_szRemoteIp="";
+ m_uLocalPort = 0;
+ m_szLocalIp="";
+ m_bIpV6 = false;
+}
+unsigned int KviKvsObject_socket::readGetLength(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uLen;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("length",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uLen)
+ KVSO_PARAMETERS_END(c)
+ if (uLen>m_uInDataLen || !uLen) return m_uInDataLen;
+ else return uLen;
+ }
+
+bool KviKvsObject_socket::functionRead(KviKvsObjectFunctionCall *c)
+{
+ unsigned int uLen = readGetLength(c);
+
+ if(uLen > 0)
+ {
+ // convert NULLS to char 255
+ for(unsigned int i = 0;i < uLen;i++)
+ {
+ if(!m_pInBuffer[i])m_pInBuffer[i] = (char)(255);
+ }
+ QString tmpBuffer = QString::fromUtf8(m_pInBuffer,uLen);
+ c->returnValue()->setString(tmpBuffer);
+
+ eatInData(uLen);
+ }
+ return true;
+}
+
+bool KviKvsObject_socket::functionReadHex(KviKvsObjectFunctionCall *c)
+{
+ //??? funzioner�
+ unsigned int uLen = readGetLength(c);
+ bool bOk;
+ if(uLen > 0)
+ {
+ QString szTmp;
+ szTmp =m_pInBuffer;
+ szTmp.toInt(&bOk,16);
+ c->returnValue()->setString(szTmp);
+ eatInData(uLen);
+ }
+ return true;
+}
+
+bool KviKvsObject_socket::functionWrite(KviKvsObjectFunctionCall *c)
+{
+ QString szData;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("szData",KVS_PT_STRING,0,szData)
+ KVSO_PARAMETERS_END(c)
+
+KviQCString szData8 = szData.utf8();
+ if(szData8.length() > 0)
+ {
+ m_pOutBuffer->append((const unsigned char*)szData8.data(),szData8.length());
+ delayedFlush(0);
+ }
+ return true;
+}
+
+
+
+//--------------
+
+#include "m_class_socket.moc"
diff --git a/src/modules/objects/class_socket.h b/src/modules/objects/class_socket.h
new file mode 100644
index 00000000..7ed2e421
--- /dev/null
+++ b/src/modules/objects/class_socket.h
@@ -0,0 +1,185 @@
+#ifndef _CLASS_SOCKET_H_
+#define _CLASS_SOCKET_H_
+//
+// File : class_socket.h
+// Creation date : Sun Nov 11 03:13:46 2001 GMT by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include "kvi_socket.h"
+
+
+
+#include "kvi_pointerlist.h"
+#include <qsocketnotifier.h>
+#include <qtimer.h>
+
+#define KVI_SCRIPT_SOCKET_STATUS_DISCONNECTED 0
+#define KVI_SCRIPT_SOCKET_STATUS_DNS 1
+#define KVI_SCRIPT_SOCKET_STATUS_CONNECTING 2
+#define KVI_SCRIPT_SOCKET_STATUS_LISTENING 3
+#define KVI_SCRIPT_SOCKET_STATUS_CONNECTED 4
+
+class KviDns;
+class KviDataBuffer;
+/*
+class KviScriptSocketObject : public KviScriptObject
+{
+ Q_OBJECT
+public:
+ KviScriptSocketObject(KviScriptObjectClass * cla,KviScriptObject * par,const char * nam);
+ virtual ~KviScriptSocketObject();
+protected:
+ kvi_socket_t m_sock;
+ int m_iStatus;
+ KviStr m_szRemoteIp;
+ unsigned short int m_uRemotePort;
+ KviStr m_szLocalIp;
+ unsigned short int m_uLocalPort;
+ unsigned int m_uConnectTimeout;
+ QSocketNotifier * m_pSn;
+ KviDns * m_pDns;
+ QTimer * m_pDelayTimer;
+ char * m_pInBuffer;
+ unsigned int m_uInBufferLen;
+ unsigned int m_uInDataLen;
+ bool m_bIpV6;
+ unsigned int m_uConnectionId;
+
+ KviDataBuffer * m_pOutBuffer;
+ QTimer * m_pFlushTimer;
+
+ kvi_socket_t m_secondarySock;
+ unsigned short int m_uSecondaryPort;
+ KviStr m_szSecondaryIp;
+protected:
+ bool functionStatus(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionRemotePort(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionRemoteIp(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionLocalPort(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionLocalIp(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionConnect(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionSetConnectTimeout(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionConnectTimeout(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionClose(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionRead(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionReadHex(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionWrite(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionWriteHex(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionListen(KviCommand *c,KviParameterList * params,KviStr &buffer);
+ bool functionAccept(KviCommand *c,KviParameterList * params,KviStr &buffer);
+
+ void delayedConnect();
+ void delayedLookupRemoteIp();
+ void delayedFlush(unsigned int uTimeout);
+
+ void eatInData(unsigned int uLen);
+ unsigned int readGetLength(KviParameterList * params);
+
+ void acceptConnection(kvi_socket_t s,unsigned short int uPort,const char * szIp);
+
+ void reset();
+protected slots:
+ void doConnect();
+ void lookupRemoteIp();
+ void lookupDone(KviDns * pDns);
+ void connectTimeout();
+ void writeNotifierFired(int);
+ void readNotifierFired(int);
+ void tryFlush();
+ void incomingConnection(int);
+public:
+ static void registerSelf();
+ static void unregisterSelf();
+};
+*/
+//===============================================================
+#include "object_macros.h"
+
+
+class KviKvsObject_socket : public KviKvsObject
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_socket)
+protected:
+ bool m_bUdp;
+ kvi_socket_t m_sock;
+ int m_iStatus;
+ QString m_szRemoteIp;
+// unsigned short int m_uRemotePort;
+ QString m_szLocalIp;
+ kvi_u32_t m_uLocalPort;
+ unsigned int m_uConnectTimeout;
+ QSocketNotifier * m_pSn;
+ KviDns * m_pDns;
+ QTimer * m_pDelayTimer;
+ char * m_pInBuffer;
+ unsigned int m_uInBufferLen;
+ unsigned int m_uInDataLen;
+ bool m_bIpV6;
+ unsigned int m_uConnectionId;
+ kvs_uint_t m_uRemotePort;
+ KviDataBuffer * m_pOutBuffer;
+ QTimer * m_pFlushTimer;
+
+ kvi_socket_t m_secondarySock;
+ kvi_u32_t m_uSecondaryPort;
+ QString m_szSecondaryIp;
+protected:
+ bool functionStatus(KviKvsObjectFunctionCall *c);
+ bool functionRemotePort(KviKvsObjectFunctionCall *c);
+ bool functionRemoteIp(KviKvsObjectFunctionCall *c);
+ bool functionLocalPort(KviKvsObjectFunctionCall *c);
+ bool functionLocalIp(KviKvsObjectFunctionCall *c);
+ bool functionConnect(KviKvsObjectFunctionCall *c);
+ bool functionSetConnectTimeout(KviKvsObjectFunctionCall *c);
+ bool functionConnectTimeout(KviKvsObjectFunctionCall *c);
+
+ bool functionClose(KviKvsObjectFunctionCall *c);
+ bool functionRead(KviKvsObjectFunctionCall *c);
+ bool functionReadHex(KviKvsObjectFunctionCall *c);
+ bool functionWrite(KviKvsObjectFunctionCall *c);
+ bool functionWriteHex(KviKvsObjectFunctionCall *c);
+
+ bool functionSetProtocol(KviKvsObjectFunctionCall *c);
+
+ bool functionListen(KviKvsObjectFunctionCall *c);
+ bool functionAccept(KviKvsObjectFunctionCall *c);
+
+ void delayedConnect();
+ void delayedLookupRemoteIp();
+ void delayedFlush(unsigned int uTimeout);
+
+ void eatInData(unsigned int uLen);
+ unsigned int readGetLength(KviKvsObjectFunctionCall * params);
+
+ void acceptConnection(kvi_socket_t s,kvi_u32_t uPort,const char * szIp);
+
+ void reset();
+protected slots:
+ void doConnect();
+ void lookupRemoteIp();
+ void lookupDone(KviDns * pDns);
+ void connectTimeout();
+ void writeNotifierFired(int);
+ void readNotifierFired(int);
+ void tryFlush();
+ void incomingConnection(int);
+};
+#endif //_CLASS_SOCKET_H_
diff --git a/src/modules/objects/class_spinbox.cpp b/src/modules/objects/class_spinbox.cpp
new file mode 100644
index 00000000..f87a3a51
--- /dev/null
+++ b/src/modules/objects/class_spinbox.cpp
@@ -0,0 +1,265 @@
+//
+// File : class_progressbar.cpp
+// Creation date : Fri Jan 30 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <qspinbox.h>
+#include "class_spinbox.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+/*
+ @doc: spinbox
+ @keyterms:
+ spinbox object class,
+ @title:
+ spinbox class
+ @type:
+ class
+ @short:
+ Provides a simple spin button.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This widget allows the user to choose a value either by clicking the up/down buttons
+ to increase/decrease the value currently displayed or by typing the value directly into the spin box.
+ @functions:
+ !fn: $setValue(<value:integer>)
+ Sets the value of the spin box.[br]
+ See also [classfnc]$value[/classfnc]()
+ !fn: $setMinValue(<min_value:integer>)
+ Sets the minimum value of the spin box.
+ See also [classfnc]$MinValue[/classfnc]()
+ !fn: $setMaxValue(<max_value:integer>)
+ Sets the maximum value of the spin box.[br]
+ See also [classfnc]$maxValue[/classfnc]()
+ !fn: $setLineStep(<line_step:integer>)
+ Sets the line step: when the user uses the arrows to change the spin box's value the value will be
+ incremented/decremented by the amount of the line step.
+ See also [classfnc]$lineStep[/classfnc]()
+ !fn: $setSpecialValueText(<text:string>)
+ Sets the special-value text.
+ If set, the spin box will display this text instead of a numeric value whenever the current value is equal to [classfnc]$minValue[/classfnc]().
+ See also [classfnc]$setSpecialValueText[/classfnc]()
+ !fn: $setPrefix(<text:string>)
+ This property holds the spin box's prefix.[br]
+ The prefix is prepended to the start of the displayed value.[br]
+ Typical use is to display a unit of measurement or a currency symbol.
+ See also [classfnc]$setSuffix[/classfnc]()
+ !fn: $setSuffix(<text:string>);
+ This property holds the suffix of the spin box.[br]
+ The suffix is appended to the end of the displayed value.[br]
+ See also [classfnc]$setPrefix[/classfnc]()
+ !fn: <integer> $value()
+ Returns the value of the spin box.
+ See also [classfnc]$setValue[/classfnc]()
+ !fn: <integer> $minValue
+ Returns the minimum value of the spin box.
+ See also [classfnc]$setMinValue[/classfnc]()
+ !fn: <integer> $maxValue
+ Returns the maximum value of the spin box.
+ See also [classfnc]$setMaxValue[/classfnc]()
+ !fn: <integer> $lineStep()
+ Return the linestep.
+ !fn: <string> $specialValueText()
+ Returns the special-value text.
+ See also [classfnc]$setSpecialValueText[/classfnc]()
+ !fn: $valueChangedEvent(<new value:integer>)
+ This function is called by the framework when the spinbox value is changed and return the new slider value as its argument.[br]
+ The default implementation emits the [classfnc]$valueChanged[/classfnc]() signal,
+ so it is easy to handle the values from many spinboxes without reimplementing
+ the [classfnc]$valueChangedEvent[/classfnc]() for every one.[br]
+ Note: If you reimplement this function to catch the spinbox value, you will have to emit the signal by yourself (if you still need it, obviously).
+ @signals:
+ !sg: $valueChanged()
+ This signal is emitted by the default implementation of [classfnc]valueChangedEvent[/classfnc]().[br]
+ If you reimplement that function you will have to emit the signal manually (if you still need it).
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_spinbox,"spinbox","widget")
+
+
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"setValue", functionsetValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"setMinValue", functionsetMinValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"setMaxValue", functionsetMaxValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"setLineStep", functionsetLineStep);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"setSpecialValueText", functionsetSpecialValueText);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"value",functionvalue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"minValue", functionminValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"maxValue", functionmaxValue);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"lineStep", functionlineStep);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"specialValueText", functionspecialValueText);
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"setPrefix", functionsetPrefix);
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"setSuffix", functionsetSuffix);
+
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_spinbox,"valueChangedEvent", functionvalueChangedEvent);
+KVSO_END_REGISTERCLASS(KviKvsObject_spinbox)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_spinbox,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_spinbox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_spinbox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_spinbox)
+
+bool KviKvsObject_spinbox::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QSpinBox(parentScriptWidget(), name()), true);
+ connect(widget(),SIGNAL(valueChanged(int)),this,SLOT(valueChanged(int)));
+ return true;
+}
+
+
+
+bool KviKvsObject_spinbox::functionsetValue(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iValue;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("value",KVS_PT_INT,0,iValue)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSpinBox *)widget())->setValue(iValue);
+ return true;
+}
+bool KviKvsObject_spinbox::functionsetMinValue(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iMinvalue;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("min_value",KVS_PT_INT,0,iMinvalue)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSpinBox *)widget())->setMinValue(iMinvalue);
+ return true;
+}
+bool KviKvsObject_spinbox::functionsetMaxValue(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iMaxvalue;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("max_value",KVS_PT_INT,0,iMaxvalue)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSpinBox *)widget())->setMaxValue(iMaxvalue);
+ return true;
+}
+
+bool KviKvsObject_spinbox::functionsetLineStep(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iLinestep;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("line_step",KVS_PT_INT,0,iLinestep)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QSpinBox *)widget())->setLineStep(iLinestep);
+ return true;
+}
+
+
+bool KviKvsObject_spinbox::functionvalue(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSpinBox *)widget())->value());
+ return true;
+}
+
+bool KviKvsObject_spinbox::functionminValue(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSpinBox *)widget())->minValue());
+ return true;
+}
+bool KviKvsObject_spinbox::functionmaxValue(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setInteger(((QSpinBox *)widget())->maxValue());
+ return true;
+}
+bool KviKvsObject_spinbox::functionlineStep(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ {
+ #ifdef COMPILE_USE_QT4
+ c->returnValue()->setInteger(((QSpinBox *)widget())->singleStep());
+ #else
+ c->returnValue()->setInteger(((QSpinBox *)widget())->lineStep());
+ #endif
+ }
+
+ return true;
+}
+
+
+bool KviKvsObject_spinbox::functionspecialValueText(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setString(((QSpinBox *)widget())->specialValueText());
+ return true;
+}
+
+
+bool KviKvsObject_spinbox::functionsetSpecialValueText(KviKvsObjectFunctionCall *c)
+{
+
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QSpinBox *)widget())->setSpecialValueText(szText);
+ return true;
+}
+bool KviKvsObject_spinbox::functionsetPrefix(KviKvsObjectFunctionCall *c)
+{
+
+ QString szPrefix;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szPrefix)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QSpinBox *)widget())->setPrefix(szPrefix);
+ return true;
+}
+bool KviKvsObject_spinbox::functionsetSuffix(KviKvsObjectFunctionCall *c)
+{
+
+ QString szSuffix;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szSuffix)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QSpinBox *)widget())->setSuffix(szSuffix);
+ return true;
+}
+
+bool KviKvsObject_spinbox::functionvalueChangedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("valueChanged",c,c->params());
+ return true;
+}
+
+void KviKvsObject_spinbox::valueChanged(int value)
+{
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)value));
+ callFunction(this,"valueChangedEvent",&params);
+}
+
+#include "m_class_spinbox.moc"
diff --git a/src/modules/objects/class_spinbox.h b/src/modules/objects/class_spinbox.h
new file mode 100644
index 00000000..d5a6ee94
--- /dev/null
+++ b/src/modules/objects/class_spinbox.h
@@ -0,0 +1,64 @@
+#ifndef _CLASS_SPINBOX_H_
+#define _CLASS_SPINBOX_H_
+//
+// File : class_progressbar.h
+// Creation date : Fri Jan 30 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qspinbox.h>
+#include "class_widget.h"
+
+#include "object_macros.h"
+
+class KviKvsObject_spinbox : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_spinbox)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionsetTracking(KviKvsObjectFunctionCall *c);
+
+ bool functionsetValue(KviKvsObjectFunctionCall *c);
+ bool functionsetMinValue(KviKvsObjectFunctionCall *c);
+ bool functionsetMaxValue(KviKvsObjectFunctionCall *c);
+ bool functionsetLineStep(KviKvsObjectFunctionCall *c);
+ bool functionsetPrefix(KviKvsObjectFunctionCall *c);
+ bool functionsetSuffix(KviKvsObjectFunctionCall *c);
+ bool functionvalue(KviKvsObjectFunctionCall *c);
+ bool functionminValue(KviKvsObjectFunctionCall *c);
+ bool functionmaxValue(KviKvsObjectFunctionCall *c);
+ bool functionlineStep(KviKvsObjectFunctionCall *c);
+ bool functionsetSpecialValueText(KviKvsObjectFunctionCall *c);
+ bool functionspecialValueText(KviKvsObjectFunctionCall *c);
+
+ bool functionvalueChangedEvent(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void valueChanged(int);
+};
+
+#endif //!_CLASS_SPINBOX_H_
diff --git a/src/modules/objects/class_tabwidget.cpp b/src/modules/objects/class_tabwidget.cpp
new file mode 100644
index 00000000..c5e97b60
--- /dev/null
+++ b/src/modules/objects/class_tabwidget.cpp
@@ -0,0 +1,541 @@
+//mdm:
+// File : class_tabwidget.cpp
+// Creation date : Fri Feb 11 10:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include "class_tabwidget.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+/*
+ @doc: tabwidget
+ @keyterms:
+ tabwidget object class,
+ @title:
+ tabwidget class
+ @type:
+ class
+ @short:
+ Provides a Tab Widget.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ The tabwidget class provides a stack of tabbed widgets.[br]
+ Each tab is associated with a different widget (called a `page').[br]
+ Only the current tab's page is shown in the page area; all the others tabs pages are hidden.[br]
+ The user can show a different page by clicking on its tab.[br]
+ @functions:
+ !fn: $addTab(<widget:object>,<text_label:string>,[<icon_id>])
+ Adds another page to the tab view with the text label and optional icon.
+ !fn: $insertTab(<widget:object>,<tex_label:string>,<index:uinteger>)
+ Inserts another tab and page to the tab view with name and label-text specified.[br]
+ If index is not specified, the tab is simply appended.[br]
+ Otherwise the new tab is inserted at the specified position.
+ !fn: $setTabToolTip(<tab_widget:object>,<tooltip:string>)
+ Sets the tab tool tip for the tabwidget to <tooltip>.
+ !fn: $removeTabToolTip(<tab_widget:object>)
+ Removes the tab tool tip for the tab. If the page does not have a tip, nothing happens.
+ !fn: $setTabLabel(<tab_widget>, <label:string>)
+ Sets the tab label for <tab_widget> to label.
+ !fn: $changeTab(<tab_widget:object>,<label:text>,[<icon_id>])
+ Defines a new label, and optional icon, for the tab .
+ !fn: $setCurrentPage(<index:uinteger>)
+ Sets the index position of the current tab page to <index>.
+ !fn: <integer> $currentPageIndex()
+ Returns the current page index.
+ !fn: <string> $label(<index:uinteger>)
+ Retunrs the label to the <index>.
+ !fn: <string> $currentTabLabel()
+ Returns the label of the current tab.
+ !fn: $setMargin(<margin:integer>)
+ Sets the margin in this tab widget to <margin>.
+ !fn: <integer> $margin()
+ Returns the margin in this tab widget.
+ !fn: $removePage(<tab_widget:object>)
+ Remove the page <tab_widget>.
+ !fn: $setTabPosition(<tab_position:string>)
+ Sets TabPosition. Valid parameters are : Top, Bottom.
+ !fn: <integer> $count()
+ This property holds the number of tabs in the tab bar.
+ !fn: $currentChangedEvent()
+ This function is invoched when the current tab was changed.[br]
+ The default implementation emits the [classfnc]$currentChange[/classfnc]() signal.
+ @examples:
+ [example]
+ # First we'll create the main tabwidget.
+ %Tabwidget=$new(tabwidget)
+ %Tabwidget->$setToolTip("Example of TabWidget class")
+ %Tabwidget->$setMargin(30)
+ %Tabwidget->$setTabPosition(Top)
+
+ # Now we'll create the new widgets and put they in to the main tabwidget.
+ %firsttab=$new(widget,%Tabwidget)
+ %secondtab=$new(widget,%Tabwidget)
+
+ # Now we'll create the item to put in to tab's pages.
+ %layoutfirsttab=$new(layout,%firsttab)
+ %labelbt=$new(label,%firsttab)
+ %labelbt->$settext(Botton Tab)
+ %labeltt=$new(label,%firsttab)
+ %labeltt->$settext(Top Tab)
+ %buttontb=$new(button,%firsttab)
+ %buttontb->$settext("To &Botton")
+ %buttontt=$new(button,%firsttab)
+ %buttontt->$settext("To &Top")
+
+ # Now we'll give a layout to all items.
+ # This also allows to use privateimpl without making buttons global variables
+ %layoutfirsttab->$addwidget(%labelbt,0,0)
+ %layoutfirsttab->$addwidget(%labeltt,0,1)
+ %layoutfirsttab->$addwidget(%buttontb,1,0)
+ %layoutfirsttab->$addwidget(%buttontt,1,1)
+
+ # Add the page to the main tab.
+ %Tabwidget->$addTab(%firsttab,Top&Button,33)
+
+ # Implementing the action to do when the user click the buttons.
+ privateimpl(%buttontb,mousepressevent)
+ {
+ %Tabwidget->$setTabPosition(Bottom)
+ }
+ privateimpl(%buttontt,mousepressevent)
+ {
+ %Tabwidget->$setTabPosition(Top)
+ }
+
+ # We do the same work with the second tab's page.
+ %layoutsecondtab=$new(layout,%secondtab)
+ %labelwp=$new(label,%secondtab)
+ %labelwp->$settext("Enjoy the new Class provided by")
+ %layoutsecondtab->$addwidget(%labelwp,0,0)
+ %labelwp->$setalignment("Center")
+ %labelgen=$new(label,%secondtab)
+ %labelgen->$settext(Grifisx \& Noldor)
+ %labelgen->$setalignment("Center")
+ %layoutsecondtab->$addwidget(%labelgen,1,0)
+ %Tabwidget->$addTab(%secondtab,&About,50)
+
+ # Let's show our example.
+ %Tabwidget->$show()
+ [/example]
+ @signals:
+ !sg: $currentChange()
+ This signal is emitted by the default implementation of [classfnc]$currentChangedEvent[/classfnc]().[br]
+ If you reimplement that function you will have to emit the signal manually (if you still need it).[br]
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_tabwidget,"tabwidget","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"addTab", functionaddTab)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"insertTab", functioninsertTab)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"setTabToolTip", functionsetTabToolTip)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"removeTabToolTip", functionremoveTabToolTip)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"setTabLabel", functionsetTabLabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"changeTab", functionchangeTab)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"setCurrentPage", functionsetCurrentPage)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"currentPageIndex", functioncurrentPageIndex)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"label", functiontabLabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"currentTabLabel", functioncurrentTabLabel)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"setMargin", functionsetMargin);
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"margin", functionmargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"count", functioncount)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"removePage", functionremovePage)
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"setTabPosition", functionsetTabPosition)
+
+ // events
+ KVSO_REGISTER_HANDLER(KviKvsObject_tabwidget,"currentChangedEvent", functionCurrentChangedEvent)
+
+
+
+KVSO_END_REGISTERCLASS(KviKvsObject_tabwidget)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_tabwidget,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_tabwidget)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_tabwidget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_tabwidget)
+
+bool KviKvsObject_tabwidget::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QTabWidget(parentScriptWidget(), name()), true);
+ connect(widget(),SIGNAL(currentChanged(int)),this,SLOT(slotcurrentChanged(int)));
+ return true;
+}
+bool KviKvsObject_tabwidget::functionaddTab(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szLabel,szIcon;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETER("icon_id",KVS_PT_STRING,KVS_PF_OPTIONAL,szIcon)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ QPixmap * pix = g_pIconManager->getImage(szIcon);
+
+ if(pix){
+#ifdef COMPILE_USE_QT4
+ ((QTabWidget *)widget())->addTab(((QWidget *)(ob->object())),QIconSet(*pix),szLabel);
+#else
+ ((QTabWidget *)widget())->addTab(((QWidget *)(ob->object())),QIconSet(*pix,QIconSet::Small),szLabel);
+#endif
+ }
+ else((QTabWidget *)widget())->addTab(((QWidget *)(ob->object())),szLabel);
+ return true;
+}
+
+bool KviKvsObject_tabwidget::functioninsertTab(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szLabel,szIcon;
+ kvs_uint_t uIndex;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tab_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETER("icon_id",KVS_PT_STRING,KVS_PF_OPTIONAL,szIcon)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ QPixmap * pix = g_pIconManager->getImage(szIcon);
+ if(pix){
+ #ifdef COMPILE_USE_QT4
+ ((QTabWidget *)widget())->insertTab( ((QWidget *)(ob->object())),QIconSet(*pix),szLabel,uIndex);
+ #else
+ ((QTabWidget *)widget())->insertTab(((QWidget *)(ob->object())),QIconSet(*pix,QIconSet::Small),szLabel,uIndex);
+ #endif
+ }
+ else ((QTabWidget *)widget())->insertTab(((QWidget *)(ob->object())),szLabel,uIndex);
+ return true;
+}
+
+bool KviKvsObject_tabwidget::functionsetCurrentPage(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QTabWidget *)widget())->setCurrentPage(uIndex);
+ return true;
+}
+bool KviKvsObject_tabwidget::functionsetTabToolTip(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szTooltip;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tab_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("tooltip",KVS_PT_STRING,0,szTooltip)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Not a widget object"));
+ return true;
+ }
+ int ctrl = ((QTabWidget *)widget())->indexOf (((QWidget *)(ob->object())));
+ if (ctrl == -1)
+ {
+ c->warning(__tr2qs("Can't find the tab "));
+ return true;
+ }
+ ((QTabWidget *)widget())->setTabToolTip(((QWidget *)(ob->object())),szTooltip);
+ return true;
+}
+bool KviKvsObject_tabwidget::functionremoveTabToolTip(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tab_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!widget()) return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Not a widget object"));
+ return true;
+ }
+ if (((QTabWidget *)widget())->indexOf (((QWidget *)(ob->object()))) == -1)
+ {
+ c->warning(__tr2qs("Can't find the tab "));
+ return true;
+ }
+ ((QTabWidget *)widget())->removeTabToolTip(((QWidget *)(ob->object())));
+ return true;
+}
+
+bool KviKvsObject_tabwidget::functionsetTabLabel(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szLabel;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tab_widget",KVS_PT_HOBJECT,0, hObject)
+ KVSO_PARAMETER("tooltip",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Not a widget object"));
+ return true;
+ }
+ int ctrl = ((QTabWidget *)widget())->indexOf (((QWidget *)(ob->object())));
+ if (ctrl == -1)
+ {
+ c->warning(__tr2qs("Can't find the tab "));
+ return true;
+ }
+ ((QTabWidget *)widget())->setTabLabel(((QWidget *)(ob->object())),szLabel);
+ return true;
+}
+bool KviKvsObject_tabwidget::functioncurrentPageIndex(KviKvsObjectFunctionCall *c)
+{
+ int index=((QTabWidget *)widget())->currentPageIndex();
+ if (widget()) c->returnValue()->setInteger(index);
+ return true;
+}
+bool KviKvsObject_tabwidget::functiontabLabel(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("index",KVS_PT_INT,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ QString label=((QTabWidget *)widget())->label(uIndex);
+ c->returnValue()->setString(label);
+ return true;
+}
+bool KviKvsObject_tabwidget::functionsetMargin(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iMargin;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("margin",KVS_PT_INT,0,iMargin)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((QTabWidget *)widget())->setMargin(iMargin);
+ return true;
+}
+bool KviKvsObject_tabwidget::functionmargin(KviKvsObjectFunctionCall *c)
+{
+
+ if (widget()) c->returnValue()->setInteger(((QTabWidget *)widget())->margin());
+ return true;
+}
+
+bool KviKvsObject_tabwidget::functioncount(KviKvsObjectFunctionCall *c)
+{
+ if (!widget()) return true;
+ int count = ((QTabWidget *)widget())->count();
+ c->returnValue()->setInteger(count);
+ return true;
+}
+
+bool KviKvsObject_tabwidget::functioncurrentTabLabel(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ {
+ int i= ((QTabWidget *)widget())->currentPageIndex();
+ QString label=((QTabWidget *)widget())->label(i);
+ c->returnValue()->setString(label);
+ }
+ return true;
+}
+bool KviKvsObject_tabwidget::functionremovePage(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tab_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Not a widget object"));
+ return true;
+ }
+ int ctrl = ((QTabWidget *)widget())->indexOf (((QWidget *)(ob->object())));
+ if (ctrl == -1)
+ {
+ c->warning(__tr2qs("Can't find the tab "));
+ return true;
+ }
+ ((QTabWidget *)widget())->removePage(((QWidget *)(ob->object())));
+ return true;
+}
+
+bool KviKvsObject_tabwidget::functionchangeTab(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szLabel,szIcon;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tab_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETER("icon_id",KVS_PT_STRING,KVS_PF_OPTIONAL,szIcon)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Not a widget object"));
+ return true;
+ }
+ int ctrl = ((QTabWidget *)widget())->indexOf (((QWidget *)(ob->object())));
+ if (ctrl == -1)
+ {
+ c->warning(__tr2qs("Can't find the tab "));
+ return true;
+ }
+ QPixmap * pix = g_pIconManager->getImage(szIcon);
+ if(pix){
+ #ifdef COMPILE_USE_QT4
+ ((QTabWidget *)widget())->changeTab(((QWidget *)(ob->object())),QIconSet(*pix),szLabel);
+ #else
+ ((QTabWidget *)widget())->changeTab(((QWidget *)(ob->object())),QIconSet(*pix,QIconSet::Small),szLabel);
+ #endif
+ }
+ else ((QTabWidget *)widget())->changeTab(((QWidget *)(ob->object())),szLabel);
+ return true;
+}
+bool KviKvsObject_tabwidget::functionsetTabPosition(KviKvsObjectFunctionCall *c)
+{
+ QString szPos;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tab_position",KVS_PT_STRING,0,szPos)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szPos,"Top"))
+ ((QTabWidget *)widget())->setTabPosition(QTabWidget::Top);
+ else if(KviQString::equalCI(szPos,"Bottom"))
+ ((QTabWidget *)widget())->setTabPosition(QTabWidget::Bottom);
+ else c->warning( __tr2qs("Unknown position 'Q%'"),&szPos);
+ return true;
+}
+
+
+
+bool KviKvsObject_tabwidget::functionCurrentChangedEvent(KviKvsObjectFunctionCall *c)
+{
+
+ emitSignal("valueChanged",c,c->params());
+ return true;
+}
+
+void KviKvsObject_tabwidget::slotCurrentChanged(int value)
+{
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)value));
+ callFunction(this,"currentChangedEvent",&params);
+}
+
+#include "m_class_tabwidget.moc"
diff --git a/src/modules/objects/class_tabwidget.h b/src/modules/objects/class_tabwidget.h
new file mode 100644
index 00000000..acc76d36
--- /dev/null
+++ b/src/modules/objects/class_tabwidget.h
@@ -0,0 +1,61 @@
+#ifndef _CLASS_TABWIDGET_H_
+#define _CLASS_TABWIDGET_H_
+//mdm:
+// File : class_tabwidget.h
+// Creation date : Fri Feb 11 10:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include <qtabwidget.h>
+#include "class_widget.h"
+
+#include "object_macros.h"
+
+class KviKvsObject_tabwidget : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_tabwidget)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionaddTab(KviKvsObjectFunctionCall *c);
+ bool functioninsertTab(KviKvsObjectFunctionCall *c);
+ bool functionsetTabToolTip(KviKvsObjectFunctionCall *c);
+ bool functionremoveTabToolTip(KviKvsObjectFunctionCall *c);
+ bool functionsetTabLabel(KviKvsObjectFunctionCall *c);
+ bool functionsetCurrentPage(KviKvsObjectFunctionCall *c);
+ bool functioncurrentPageIndex(KviKvsObjectFunctionCall *c);
+ bool functiontabLabel(KviKvsObjectFunctionCall *c);
+ bool functioncurrentTabLabel(KviKvsObjectFunctionCall *c);
+ bool functionsetMargin(KviKvsObjectFunctionCall *c);
+ bool functionmargin(KviKvsObjectFunctionCall *c);
+ bool functioncount(KviKvsObjectFunctionCall *c);
+ bool functionchangeTab(KviKvsObjectFunctionCall *c);
+ bool functionCurrentChangedEvent(KviKvsObjectFunctionCall *c);
+ bool functionremovePage(KviKvsObjectFunctionCall *c);
+ bool functionsetTabPosition(KviKvsObjectFunctionCall *c);
+
+protected slots:
+ void slotCurrentChanged(int);
+};
+
+#endif //!_CLASS_TABWIDGET_H_
diff --git a/src/modules/objects/class_tbrowser.cpp b/src/modules/objects/class_tbrowser.cpp
new file mode 100644
index 00000000..67dce8cb
--- /dev/null
+++ b/src/modules/objects/class_tbrowser.cpp
@@ -0,0 +1,143 @@
+//mdm:
+// File : class_tbrowser.cpp
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <qtextbrowser.h>
+#include "class_tbrowser.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+/*
+ @doc: textbrowser
+ @keyterms:
+ textbrowser browser widget class,
+ @title:
+ textbrowser class
+ @type:
+ class
+ @short:
+ Provides a class that can display html pages.
+ @inherits:
+ [class]widget[/class]
+ @description:
+ Provides a class that can display html pages with hypertext navigation.
+ @functions:
+ !fn: $setSource(<file_name:string>)
+ With this you can display the page at szFile location (szFile include the path).
+ !fn: $backward()
+ Changes the document displayed to the previous document in the list of documents built by navigating links.
+ !fn: $forward()
+ Changes the document displayed to the next document in the list of documents built by navigating links.
+ !fn: $home()
+ Changes the document displayed to be the first document the browser displayed.
+ !fn: $reload()
+ Reloads the current set source.
+ !fn: $linkClickedEvent(<link_href:string>)
+ Triggered when a link is clicked by the user. The default implementation of this function
+ emits the "linkClicked" signal.
+ @signals:
+ !sg: $linkClicked(<link_href:string>)
+ This signal is emitted by the default implementation of the [classfnc]$linkClickedEvent[/classfnc]() function.
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_textbrowser,"textbrowser","multilineedit")
+ KVSO_REGISTER_HANDLER(KviKvsObject_textbrowser,"setSource",function_setSource)
+ KVSO_REGISTER_HANDLER(KviKvsObject_textbrowser,"forward",function_forward)
+ KVSO_REGISTER_HANDLER(KviKvsObject_textbrowser,"backward",function_backward)
+ KVSO_REGISTER_HANDLER(KviKvsObject_textbrowser,"home",function_home)
+ KVSO_REGISTER_HANDLER(KviKvsObject_textbrowser,"reload",function_reload)
+ KVSO_REGISTER_HANDLER(KviKvsObject_textbrowser,"linkClickedEvent",function_linkClickedEvent)
+KVSO_END_REGISTERCLASS(KviKvsObject_textbrowser)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_textbrowser,KviKvsObject_mledit)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_textbrowser)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_textbrowser)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_textbrowser)
+
+bool KviKvsObject_textbrowser::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ QTextBrowser * tb = new QTextBrowser(parentScriptWidget(), name());
+ setObject(tb, true);
+ connect(tb,SIGNAL(anchorClicked(const QString &,const QString &)),this,SLOT(anchorClicked(const QString &,const QString &)));
+ return true;
+}
+
+bool KviKvsObject_textbrowser::function_setSource(KviKvsObjectFunctionCall *c)
+{
+ QString szFile;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("file_name",KVS_PT_STRING,0,szFile)
+ KVSO_PARAMETERS_END(c)
+ if(!QFile::exists(szFile))
+ {
+ c->warning(__tr2qs("I can't find the specified file '%Q'."),&szFile);
+ return true;
+ }
+
+ if (widget()) ((QTextBrowser *)widget())->setSource(szFile);
+ return true;
+}
+
+bool KviKvsObject_textbrowser::function_forward(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) ((QTextBrowser *)widget())->forward();
+ return true;
+}
+
+bool KviKvsObject_textbrowser::function_backward(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) ((QTextBrowser *)widget())->backward();
+ return true;
+}
+
+bool KviKvsObject_textbrowser::function_home(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) ((QTextBrowser *)widget())->home();
+ return true;
+}
+
+bool KviKvsObject_textbrowser::function_reload(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) ((QTextBrowser *)widget())->reload();
+ return true;
+}
+
+void KviKvsObject_textbrowser::anchorClicked(const QString &szName,const QString &szLink)
+{
+ KviKvsVariantList parms(new KviKvsVariant(szLink));
+ callFunction(this,"linkClickedEvent",0,&parms);
+}
+
+bool KviKvsObject_textbrowser::function_linkClickedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("linkClicked",c,c->params());
+ return true;
+}
+
+#include "m_class_tbrowser.moc"
diff --git a/src/modules/objects/class_tbrowser.h b/src/modules/objects/class_tbrowser.h
new file mode 100644
index 00000000..980bdc28
--- /dev/null
+++ b/src/modules/objects/class_tbrowser.h
@@ -0,0 +1,52 @@
+#ifndef _CLASS_TBROWSER_H_
+#define _CLASS_TBROWSER_H_
+//mdm:
+// File : class_tbrowser.h
+// Creation date : Fri Feb 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <qtextbrowser.h>
+#include "class_widget.h"
+#include <qfile.h>
+#include "class_multilineedit.h"
+#include "object_macros.h"
+
+class KviKvsObject_textbrowser : public KviKvsObject_mledit
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_textbrowser)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool function_setSource(KviKvsObjectFunctionCall *c);
+ bool function_forward(KviKvsObjectFunctionCall *c);
+ bool function_backward(KviKvsObjectFunctionCall *c);
+ bool function_home(KviKvsObjectFunctionCall *c);
+ bool function_reload(KviKvsObjectFunctionCall *c);
+ bool function_linkClickedEvent(KviKvsObjectFunctionCall *c);
+protected slots:
+ void anchorClicked(const QString &szName,const QString &szLink);
+};
+
+#endif //!_CLASS_TBROWSER_H_
diff --git a/src/modules/objects/class_toolbar.cpp b/src/modules/objects/class_toolbar.cpp
new file mode 100644
index 00000000..ed280bd0
--- /dev/null
+++ b/src/modules/objects/class_toolbar.cpp
@@ -0,0 +1,156 @@
+//mdm:
+// File : class_toolbar.cpp
+// Creation date : Tue Feb 22 22:12:55 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_toolbar.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+#include "kvi_tal_toolbar.h"
+#include "kvi_tal_mainwindow.h"
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+#include "class_mainwindow.h"
+
+/*
+ @doc: toolbar
+ @keyterms:
+ toolbar object class,
+ @title:
+ toolbar class
+ @type:
+ class
+ @short:
+ Provides a toolbar for mainwindow widget.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ The toolbar class provides a movable panel containing widgets such as tool buttons.
+ @functions:
+ !fn: $addSeparator()
+ Adds a separator to the right/bottom of the toolbar.
+ !fn: $setLabel(<text:string>)
+ Sets the toolbar's label.
+ !fn: <string> $label()
+ Returns the toolbar's label.
+ !fn: $setStretchableWidget(<widget:object>)
+ Sets the <widget> to be expanded.
+ !fn: $clear()
+ Deletes all the toolbar's child widgets.
+
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_toolbar,"toolbar","object")
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbar,"addSeparator", functionaddSeparator)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbar,"setLabel", functionsetLabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbar,"label", functionlabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbar,"setStretchableWidget", functionsetStretchableWidget)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbar,"clear", functionclear)
+KVSO_END_REGISTERCLASS(KviKvsObject_toolbar)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_toolbar,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_toolbar)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_toolbar)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_toolbar)
+
+bool KviKvsObject_toolbar::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ if (!parentObject())
+ {
+ pContext->warning(__tr2qs("the toolbar cannot be a parent-widget!"));
+ return true;
+ }
+ if(parentObject()->inherits("KviKvsObject_mainwindow"))
+ {
+ setObject(new KviTalToolBar(name(), ((KviTalMainWindow *)parentScriptWidget())), true);
+ }
+ else
+ {
+ pContext->warning(__tr2qs("The parent-widget isn't a MainWindow."));
+ }
+
+ return true;
+}
+
+bool KviKvsObject_toolbar::functionaddSeparator(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) ((KviTalToolBar *)widget())->addSeparator();
+ return true;
+}
+bool KviKvsObject_toolbar::functionsetLabel(KviKvsObjectFunctionCall *c)
+{
+ QString szLabel;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalToolBar *)widget())->setLabel(szLabel);
+ return true;
+}
+bool KviKvsObject_toolbar::functionlabel(KviKvsObjectFunctionCall *c)
+{
+ if (widget()) c->returnValue()->setString(((KviTalToolBar *)widget())->label());
+ return true;
+}
+bool KviKvsObject_toolbar::functionsetStretchableWidget(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!widget()) return true;
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!ob->object()->inherits("KviKvsObject_widget"))
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return TRUE;
+ }
+#ifndef COMPILE_USE_QT4
+ // FIXME: no support for this in Qt4 ?
+ if(widget()) ((KviTalToolBar *)widget())->setStretchableWidget(((QWidget *)(ob->object())));
+#endif //!COMPILE_USE_QT4
+ return true;
+}
+bool KviKvsObject_toolbar::functionclear(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ ((KviTalToolBar *)object())->clear();
+ return true;
+}
+
+#include "m_class_toolbar.moc"
+
diff --git a/src/modules/objects/class_toolbar.h b/src/modules/objects/class_toolbar.h
new file mode 100644
index 00000000..1912e639
--- /dev/null
+++ b/src/modules/objects/class_toolbar.h
@@ -0,0 +1,50 @@
+#ifndef _CLASS_TOOLBAR_H_
+#define _CLASS_TOOLBAR_H_
+//mdm:
+// File : class_toolbar.h
+// Creation date : Tue Feb 22 22:12:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_toolbar : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_toolbar)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionaddSeparator(KviKvsObjectFunctionCall *c);
+ bool functionsetLabel(KviKvsObjectFunctionCall *c);
+ bool functionlabel(KviKvsObjectFunctionCall *c);
+ bool functionsetStretchableWidget(KviKvsObjectFunctionCall *c);
+ bool functionclear(KviKvsObjectFunctionCall *c);
+};
+
+
+#endif //!_CLASS_TOOLBAR_H_
diff --git a/src/modules/objects/class_toolbutton.cpp b/src/modules/objects/class_toolbutton.cpp
new file mode 100644
index 00000000..032b0c60
--- /dev/null
+++ b/src/modules/objects/class_toolbutton.cpp
@@ -0,0 +1,341 @@
+//mdm:
+// File : class_toolbutton.cpp
+// Creation date : Wed Feb 23 16:39:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_toolbutton.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+#include "kvi_tal_popupmenu.h"
+/*
+ @doc: toolbutton
+ @keyterms:
+ toolbutton object class,
+ @title:
+ toolbutton class
+ @type:
+ class
+ @short:
+ Provides a toolbutton for toolbar widget.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ The toolbutton class provides a quick-access button to commands or options, usually used inside a ToolBar.
+ @functions:
+ !fn:$setImage(<icon_id:string>)
+ Sets the image for this button.
+ !fn:$setUsesBigPixmap(<bEnabled:boolean>)
+ Sets whether this toolbutton uses big pixmaps to enable.
+ !fn:$usesBigPixmap(<bEnabled:boolean>)
+ This property holds whether this toolbutton uses big pixmaps.
+ !fn:setUsesTextLabel(<bEnabled:boolean>)
+ Sets whether the toolbutton show a texlabel below the pixmap of the button.
+ !fn:$usesTextLabel()
+ Return 1 if the setUsesTextLabel is enabled, otherwise return 0.
+ !fn:$setTextLabel(<text:String>,[tooltip:string])
+ Sets the label of this button to <text> and automatically sets it as a tool tip if <tip> is TRUE.
+ !fn:<string> $textLabel()
+ Returns the label of tthe button.
+ !fn:$setAutoRaise(<bAutoraise:boolean>)
+ Sets whether auto-raising is enabled.
+ !fn:<boolean> $autoRaise()
+ Returns 1 if autoRaise is enabled, otherwise returns 0.
+ !fn:$setToggleButton(<bToggle:boolean>)
+ Sets whether the tool button is a toggle button 1 enable, 0 disable.
+ !fn:<boolean> $toggle()
+ Toggles the state of the tool button.
+ !fn:$setOn(<bEnabled:boolean>)
+ Sets whether the tool button is on to the bool value: 1 enable, 0 disable.
+ // findme
+ !fn:$setPopup (<toolbutton:object>)
+ !fn:$setPopupDelay (<int delay>)
+ Sets the time delay between pressing the button and the appearance of the associated popup menu in milliseconds to delay.[br]
+ A good value is 100.
+ !fn:<integer> $pupupDelay()
+ Returns the time delay between pressing the button and the appearance of the associated popup menu in milliseconds.
+ !fn:$openPopup()
+ Opens the associated popup menu. If there is no such menu, this function does nothing.
+ !fn:setTextPosition(<text_position:string>)
+ Sets the position of the tool button's textLabel in relation to the tool button's icon.[br]
+ Valid texpos values are:[br]
+ - BesideIcon : The text appears beside the icon.[br]
+ - BelowIcon : The text appears below the icon.
+ !fn:<string> $textPosition()
+ Returns the position of the text label of this button.
+ !fn: $clickEvent()
+ This function is called when the toolbutton is clicked.[br]
+ You can reimplement it to handle the user click events.[br]
+ The default implementation emits the [classfnc]$clicked[/classfnc]() signal.
+ @signals:
+ !sg: $clicked()
+ This signal is emitted by the default implementation of [classfnc]$clickEvent[/classfnc]().[br]
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_toolbutton,"toolbutton","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setImage", functionsetImage)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setUsesBigPixmap", functionsetUsesBigPixmap)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"usesBigPixmap", functionusesBigPixmap)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setUsesTextLabel", functionsetUsesTextLabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"usesTextLabel", functionusesTextLabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setAutoRaise", function_setAutoRaise)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"autoRaise", function_autoRaise)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setTextLabel", functionsetTextLabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"textLabel", functiontextLabel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setPopup", functionsetPopup)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"openPopup", functionopenPopup)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setToggleButton", functionsetToggleButton)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"toggle", functiontoggle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setOn", functionsetOn)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setPopupDelay", functionsetPopupDelay)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"popupDelay", functionpopupDelay)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"setTextPosition", functionsetTextPosition)
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"textPosition", functiontextPosition)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_toolbutton,"clickEvent",function_clickEvent)
+KVSO_END_REGISTERCLASS(KviKvsObject_toolbutton)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_toolbutton,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_toolbutton)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_toolbutton)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_toolbutton)
+
+bool KviKvsObject_toolbutton::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QToolButton(parentScriptWidget(), name()), true);
+ connect(widget(),SIGNAL(clicked()),this,SLOT(slotClicked()));
+ return true;
+}
+
+bool KviKvsObject_toolbutton::functionsetImage(KviKvsObjectFunctionCall *c)
+{
+ QString icon;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("icon_id",KVS_PT_STRING,0,icon)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ QPixmap * pix = g_pIconManager->getImage(icon);
+ if(pix){
+ #ifdef COMPILE_USE_QT4
+ ((QToolButton *)widget())->setIconSet(QIconSet(*pix));
+ #else
+ ((QToolButton *)widget())->setIconSet(QIconSet(*pix,QIconSet::Small));
+ #endif
+ }
+ else
+ ((QToolButton *)widget())->setIconSet(QIconSet());
+ return true;
+}
+bool KviKvsObject_toolbutton::functionsetUsesBigPixmap(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QToolButton *)widget())->setUsesBigPixmap(bEnabled);
+ return true;
+}
+bool KviKvsObject_toolbutton::functionusesBigPixmap(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ c->returnValue()->setBoolean(((QToolButton *)widget())->usesBigPixmap());
+ return true;
+}
+bool KviKvsObject_toolbutton::functionsetUsesTextLabel(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QToolButton *)widget())->setUsesTextLabel(bEnabled);
+ return true;
+}
+bool KviKvsObject_toolbutton::functionusesTextLabel(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ c->returnValue()->setBoolean(((QToolButton *)widget())->usesTextLabel());
+ return true;
+}
+bool KviKvsObject_toolbutton::function_setAutoRaise(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QToolButton *)widget())->setAutoRaise(bEnabled);
+ return true;
+}
+bool KviKvsObject_toolbutton::function_autoRaise(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((QToolButton *)widget())->autoRaise());
+ return true;
+}
+bool KviKvsObject_toolbutton::functionsetOn(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QToolButton *)widget())->setOn(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_toolbutton::functionsetToggleButton(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QToolButton *)widget())->setToggleButton(bEnabled);
+ return true;
+}
+bool KviKvsObject_toolbutton::functiontoggle(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ ((QToolButton *)widget())->toggle();
+ return true;
+}
+
+bool KviKvsObject_toolbutton::functionsetTextLabel(KviKvsObjectFunctionCall *c)
+{
+ QString szLabel,szTip;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETER("tooltip",KVS_PT_STRING,KVS_PF_OPTIONAL,szTip)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+
+ #ifdef COMPILE_USE_QT4
+ ((QToolButton *)widget())->setText(szLabel);
+ if (!szTip.isEmpty()) ((QToolButton *)widget())->setToolTip(szTip);
+ #else
+ if (szTip.isEmpty()) ((QToolButton *)widget())->setTextLabel(szLabel);
+ else ((QToolButton *)widget())->setTextLabel(szLabel,szTip);
+ #endif
+ return true;
+}
+bool KviKvsObject_toolbutton::functiontextLabel(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ c->returnValue()->setString(((QToolButton *)widget())->textLabel());
+ return true;
+}
+bool KviKvsObject_toolbutton::functionsetPopup(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!ob->object()->inherits("KviKvsObject_popupmenu"))
+ {
+ c->warning(__tr2qs("Can't add a non - popupmenu object"));
+ return TRUE;
+ }
+ if(widget())
+ ((QToolButton *)widget())->setPopup(((KviTalPopupMenu *)(ob->object())));
+ return true;
+}
+bool KviKvsObject_toolbutton::functionopenPopup(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QToolButton *)widget())->openPopup();
+ return true;
+}
+bool KviKvsObject_toolbutton::functionsetPopupDelay(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t uDelay;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("delay",KVS_PT_UNSIGNEDINTEGER,0,uDelay)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((QToolButton *)widget())->setPopupDelay(uDelay);
+ return true;
+}
+bool KviKvsObject_toolbutton::functionpopupDelay(KviKvsObjectFunctionCall *c)
+{
+ if (widget())
+ c->returnValue()->setInteger(((QToolButton *)widget())->popupDelay());
+ return true;
+}
+bool KviKvsObject_toolbutton::functionsetTextPosition(KviKvsObjectFunctionCall *c)
+{
+ QString szPos;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("position",KVS_PT_STRING,0,szPos)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szPos,"BesideIcon"))
+ ((QToolButton *)widget())->setTextPosition(QToolButton::BesideIcon);
+ else if(KviQString::equalCI(szPos,"BelowIcon"))
+ ((QToolButton *)widget())->setTextPosition(QToolButton::BelowIcon);
+ else c->warning(__tr2qs("Unknown text position '%Q'"),&szPos);
+ return true;
+}
+bool KviKvsObject_toolbutton::functiontextPosition(KviKvsObjectFunctionCall *c)
+{
+ if(!widget()) return true;
+ QString szPos="BelowIcon";
+ if ((((QToolButton *)widget())->textPosition())==(QToolButton::BesideIcon))
+ szPos="BesideIcon";
+ c->returnValue()->setString(szPos);
+ return true;
+}
+bool KviKvsObject_toolbutton::function_clickEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("clicked",c);
+ return true;
+}
+
+void KviKvsObject_toolbutton::slotClicked()
+{
+ KviKvsVariantList *params=0;
+ callFunction(this,"clickEvent",params);
+}
+
+#include "m_class_toolbutton.moc"
+
diff --git a/src/modules/objects/class_toolbutton.h b/src/modules/objects/class_toolbutton.h
new file mode 100644
index 00000000..2cd4dfec
--- /dev/null
+++ b/src/modules/objects/class_toolbutton.h
@@ -0,0 +1,69 @@
+#ifndef _CLASS_TOOLBUTTON_H_
+#define _CLASS_TOOLBUTTON_H_
+
+//mdm:
+// File : class_toolbutton.h
+// Creation date : Wed Feb 23 16:39:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include <qtoolbutton.h>
+#include "class_widget.h"
+#include "object_macros.h"
+
+class KviKvsObject_toolbutton : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_toolbutton)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionsetImage(KviKvsObjectFunctionCall *c);
+ bool functionsetUsesBigPixmap(KviKvsObjectFunctionCall *c);
+ bool functionusesBigPixmap(KviKvsObjectFunctionCall *c);
+ bool functionsetUsesTextLabel(KviKvsObjectFunctionCall *c);
+ bool functionusesTextLabel(KviKvsObjectFunctionCall *c);
+ bool functionsetTextLabel(KviKvsObjectFunctionCall *c);
+ bool functiontextLabel(KviKvsObjectFunctionCall *c);
+ bool functionsetPopup(KviKvsObjectFunctionCall *c);
+ bool functionopenPopup(KviKvsObjectFunctionCall *c);
+ bool functionsetOn(KviKvsObjectFunctionCall *c);
+ bool functionsetToggleButton(KviKvsObjectFunctionCall *c);
+ bool functiontoggle(KviKvsObjectFunctionCall *c);
+ bool functionsetPopupDelay(KviKvsObjectFunctionCall *c);
+ bool functionpopupDelay(KviKvsObjectFunctionCall *c);
+ bool functionsetTextPosition(KviKvsObjectFunctionCall *c);
+ bool functiontextPosition(KviKvsObjectFunctionCall *c);
+
+ bool function_setAutoRaise(KviKvsObjectFunctionCall *c);
+ bool function_autoRaise(KviKvsObjectFunctionCall *c);
+ bool function_clickEvent(KviKvsObjectFunctionCall *c);
+signals:
+ void clicked();
+protected slots:
+ void slotClicked();
+};
+
+
+#endif //!_CLASS_TOOLBUTTON_H_
diff --git a/src/modules/objects/class_urllabel.cpp b/src/modules/objects/class_urllabel.cpp
new file mode 100644
index 00000000..544153c2
--- /dev/null
+++ b/src/modules/objects/class_urllabel.cpp
@@ -0,0 +1,330 @@
+//vim: ts=8
+// File : class_urllabel.cpp
+// Creation date : Thu Feb 18 1:27:44 CEST 2001 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Krzysztof Godlewski
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "class_urllabel.h"
+
+#include "kvi_debug.h"
+#include "kvi_locale.h"
+#include "kvi_error.h"
+
+#include "kvi_app.h"
+
+#include "kvi_window.h"
+#include "kvi_kvs_script.h"
+#ifdef COMPILE_USE_QT4
+#include <QMouseEvent>
+#define QT_LEFT_BUTTON Qt::LeftButton
+#else
+#define QT_LEFT_BUTTON QEvent::LeftButton
+#endif
+//#warning "Functions to change colors for different states"
+//#warning "$setUnderline(), $underline()"
+
+//extern KviApp * g_pApp;
+/*static KviScriptObjectClass * g_pUrlLabelClass = 0;
+
+static KviScriptObject * urlLabelClassCreateInstance(KviScriptObjectClass * c,
+ KviScriptObject * p, const char * n)
+{
+ return new KviScriptUrlLabelObject(c, p, n);
+}
+
+KviScriptUrlLabelObject::KviScriptUrlLabelObject(KviScriptObjectClass * c, \
+KviScriptObject * p, const char *n) : KviScriptLabelObject(c, p, n)
+{
+ m_normalClr = QColor("black");
+ m_enterClr = QColor("blue");
+ m_activeClr = QColor("red");
+ m_useSingleClick = true;
+// ((QLabel *)widget())->setAutoResize(true);
+ //widget()->setCursor(Qt::pointingHandCursor);
+ //((KviScriptWidgetObject: * )p)->widget()->setCursor(Qt::pointingHandCursor);
+}
+
+KviScriptUrlLabelObject::~KviScriptUrlLabelObject()
+{
+}
+
+bool KviScriptUrlLabelObject::eventFilter(QObject * o, QEvent * e)
+{
+ QPalette pal = ((QLabel *)widget())->palette();
+
+ switch(e->type())
+ {
+ case QEvent::Enter:
+ pal.setColor(QColorGroup::Foreground, m_enterClr);
+ break;
+ case QEvent::Leave:
+ // this doesn't work...
+ if(((QMouseEvent *)e)->state() & QEvent::LeftButton)
+ pal.setColor(QColorGroup::Foreground, \
+ m_activeClr);
+ else
+ pal.setColor(QColorGroup::Foreground, \
+ m_normalClr);
+ break;
+ case QEvent::MouseButtonRelease:
+ pal.setColor(QColorGroup::Foreground, m_enterClr);
+ // perform actions here
+ if(!m_lastClickWasDbl && !m_useSingleClick)
+ break;
+ if(!m_action.isEmpty())
+ {
+
+ }
+ break;
+ case QEvent::MouseButtonPress:
+ m_lastClickWasDbl = false;
+ if(!((QMouseEvent * )e)->button() & \
+ QEvent::LeftButton || !m_useSingleClick)
+ break;
+ pal.setColor(QColorGroup::Foreground, m_activeClr);
+ break;
+ case QEvent::MouseButtonDblClick:
+ m_lastClickWasDbl = true;
+ if(m_useSingleClick)
+ break;
+ pal.setColor(QColorGroup::Foreground, m_activeClr);
+ break;
+ default: // make gcc happy
+ break;
+ }
+
+ ((QLabel *)widget())->setPalette(pal);
+
+ return false;
+}
+*/
+//#warning "Docs for urllabel"
+
+/*
+ @doc: urllabel
+ @keyterms:
+ display url, link
+ @title:
+ urllabel class
+ @type:
+ class
+ @short:
+ Displays an URI allowing to perform actions on click
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ [class]label[/class]
+ @description:
+ This widget allows you to bind specific action on click. It can
+ open an url, or execute any KVI++ code. The text color reacts on
+ cursor movements and clicks.
+ @functions:
+ !fn: $setUrl(<text:string>)
+ Sets the url to be opened when the links is activated. The way
+ the label opens the url is defined in KVirc config dialog.
+ !fn: <string> $url()
+ Returns the currently set url.
+ !fn: $setAction(<text:string>)
+ Sets the action to be performed when the link is triggered. It
+ can be any valid KVI++ code. Note that all KVirc commands must
+ be prefixed with a '/', just as if you typed them in the input
+ widget.
+ !fn: <string> $action()
+ Returns currently set action string.
+ !fn: $setText(<text>)
+ Sets the label's text. Reimplemented from internal reasons.
+ !fn: $setCursorChange(<bEnabled:boolean>)
+ Tells the label wheather to change or not the shape of cursor,
+ when it is above the widget. Default is false.
+ !fn: <boolean> $cursorChange()
+ Returns true if the cursor changes over the label, false if not.
+ !fn: $setUseSingleClick(<bEnabled:boolean>)
+ If <bEnabled> is true, the label will react on single clicks,
+ otherwise only double clicks will trigger the link.
+ !fn: <boolean> $useSingleClick()
+ Returns true if the label reacts on single clicks, false if it
+ reacts only on double clicks.
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_urlabel,"urllabel","label")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"setUrl",functionsetUrl)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"url",functionurl)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"setAction",functionsetAction)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"action",functionaction)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"setText",functionsetText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"setCursorChange",functionsetCursorChange)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"cursorChange",functioncursorChange)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"setUseSingleClick",functionsetUseSingleClick)
+ KVSO_REGISTER_HANDLER(KviKvsObject_urlabel,"useSingleClick",functionuseSingleClick)
+
+KVSO_END_REGISTERCLASS(KviKvsObject_urlabel)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_urlabel,KviKvsObject_label)
+
+ m_normalClr = QColor("black");
+ m_enterClr = QColor("blue");
+ m_activeClr = QColor("red");
+ m_useSingleClick = true;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_urlabel)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_urlabel)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_urlabel)
+
+bool KviKvsObject_urlabel::eventFilter(QObject * o, QEvent * e)
+{
+ QPalette pal = ((QLabel *)widget())->palette();
+
+ switch(e->type())
+ {
+ case QEvent::Enter:
+ pal.setColor(QColorGroup::Foreground, m_enterClr);
+ break;
+ case QEvent::Leave:
+ // this doesn't work...
+ if(((QMouseEvent *)e)->state() & QT_LEFT_BUTTON)
+ pal.setColor(QColorGroup::Foreground, \
+ m_activeClr);
+ else
+ pal.setColor(QColorGroup::Foreground, \
+ m_normalClr);
+ break;
+ case QEvent::MouseButtonRelease:
+ pal.setColor(QColorGroup::Foreground, m_enterClr);
+ // perform actions here
+ if(!m_lastClickWasDbl && !m_useSingleClick)
+ break;
+ if(!m_action.isEmpty())
+ {
+ KviKvsScript kvs("commandline",m_action);
+ kvs.run(g_pActiveWindow,0,0/*,KviKvsScript::AssumeLocals*/);
+
+ } else if(!m_url.isEmpty()) {
+ KviKvsScript kvs("commandline","openurl "+m_url);
+ kvs.run(g_pActiveWindow,0,0/*,KviKvsScript::AssumeLocals*/);
+ }
+ break;
+ case QEvent::MouseButtonPress:
+ m_lastClickWasDbl = false;
+ if(!((QMouseEvent * )e)->button() & \
+ QT_LEFT_BUTTON || !m_useSingleClick)
+ break;
+ pal.setColor(QColorGroup::Foreground, m_activeClr);
+ break;
+ case QEvent::MouseButtonDblClick:
+ m_lastClickWasDbl = true;
+ if(m_useSingleClick)
+ break;
+ pal.setColor(QColorGroup::Foreground, m_activeClr);
+ break;
+ default: // make gcc happy
+ break;
+ }
+
+ ((QLabel *)widget())->setPalette(pal);
+
+ return false;
+}
+bool KviKvsObject_urlabel::functionsetUrl(KviKvsObjectFunctionCall *c)
+{
+ QString szUrl;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("url",KVS_PT_STRING,0,szUrl)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(szUrl.isEmpty()){
+ c->error(__tr2qs("Not Enough Parameters"));
+ return false;
+ }
+ m_url = szUrl;
+ return true;
+}
+bool KviKvsObject_urlabel::functionurl(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setString(m_url);
+ return true;
+}
+bool KviKvsObject_urlabel::functionsetAction(KviKvsObjectFunctionCall *c)
+{
+ QString szAction;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("action",KVS_PT_STRING,0,szAction)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ if(szAction.isEmpty()){
+ c->error(__tr2qs("Not Enough Parameters"));
+ return false;
+ }
+ m_action = szAction;
+ return true;
+}
+bool KviKvsObject_urlabel::functionsetText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ ((QLabel *)widget())->setText(szText);
+ ((QLabel *)widget())->setFixedSize(((QLabel *)widget())->sizeHint());
+ return true;
+}
+bool KviKvsObject_urlabel::functionaction(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setString(m_action);
+ return true;
+}
+bool KviKvsObject_urlabel::functionsetCursorChange(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOLEAN,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())
+ return true;
+ if(m_changeCursor = bFlag)
+ widget()->setCursor(Qt::pointingHandCursor);
+ else
+ widget()->setCursor(Qt::arrowCursor);
+ return true;
+}
+bool KviKvsObject_urlabel::functionsetUseSingleClick(KviKvsObjectFunctionCall *c)
+{
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOLEAN,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ m_useSingleClick = bFlag;
+ return true;
+}
+bool KviKvsObject_urlabel::functionuseSingleClick(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setBoolean(m_useSingleClick);
+ return true;
+}
+bool KviKvsObject_urlabel::functioncursorChange(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setBoolean(m_changeCursor);
+ return true;
+}
diff --git a/src/modules/objects/class_urllabel.h b/src/modules/objects/class_urllabel.h
new file mode 100644
index 00000000..b9ee35d6
--- /dev/null
+++ b/src/modules/objects/class_urllabel.h
@@ -0,0 +1,64 @@
+#ifndef _CLASS_URLLABEL_H_
+#define _CLASS_URLLABEL_H_
+//vim: ts=8
+// File : class_urllabel.h
+// Creation date : Thu Feb 18 1:28:23 CEST 2001 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Krzysztof Godlewski
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include "class_label.h"
+#include "object_macros.h"
+
+class KviKvsObject_urlabel : public KviKvsObject_label
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_urlabel)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool eventFilter(QObject *, QEvent *);
+
+ bool functionsetUrl(KviKvsObjectFunctionCall *c);
+ bool functionsetAction(KviKvsObjectFunctionCall *c);
+ bool functionurl(KviKvsObjectFunctionCall *c);
+ bool functionaction(KviKvsObjectFunctionCall *c);
+ bool functionsetText(KviKvsObjectFunctionCall *c);
+ bool functionsetCursorChange(KviKvsObjectFunctionCall *c);
+ bool functioncursorChange(KviKvsObjectFunctionCall *c);
+ bool functionsetUseSingleClick(KviKvsObjectFunctionCall *c);
+ bool functionuseSingleClick(KviKvsObjectFunctionCall *c);
+
+ QString m_url;
+ QString m_action;
+
+ QColor m_normalClr;
+ QColor m_enterClr;
+ QColor m_activeClr;
+
+ bool m_changeCursor;
+ bool m_useSingleClick;
+
+ bool m_lastClickWasDbl;
+
+};
+
+#endif // !_CLASS_URLLABEL_H_
diff --git a/src/modules/objects/class_vbox.cpp b/src/modules/objects/class_vbox.cpp
new file mode 100644
index 00000000..477a5b69
--- /dev/null
+++ b/src/modules/objects/class_vbox.cpp
@@ -0,0 +1,128 @@
+//
+// File : class_vbox.cpp
+// Creation date : Wed Mar 01 2005 23:00:01 by Alessandro Carbone & Tonino Imbesi
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002-2006 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#define _KVI_DEBUG_CHECK_RANGE_
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+
+#include "class_vbox.h"
+
+/*
+ @doc: vbox
+ @keyterms:
+ vbox object class, child widgets
+ @title:
+ vbox class
+ @type:
+ class
+ @short:
+ Manages child widget vertical geometry
+ @inherits:
+ [class]object[/class]
+ @description:
+ The vbox class widget provides vertical geometry management for its child widgets.
+ @functions:
+ !fn: $setSpacing(<spacing:int>)
+ Sets the default spacing of the widgets in pixels
+ !fn: $setMargin(<margin:int>)
+ Sets the dimension of the layout margin : the distance from the border to the outermost child widget edges.
+ !fn: $setStretchFactor(<widget:hobject>,<stretch:uint>)
+ Sets the stretch factor of widget to stretch.
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_vbox,"vbox","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_vbox,"setMargin", functionsetMargin)
+ KVSO_REGISTER_HANDLER(KviKvsObject_vbox,"setSpacing", functionsetSpacing)
+ KVSO_REGISTER_HANDLER(KviKvsObject_vbox,"setStretchFactor", functionsetStretchFactor )
+KVSO_END_REGISTERCLASS(KviKvsObject_vbox)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_vbox,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_vbox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_vbox)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_vbox)
+
+bool KviKvsObject_vbox::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new KviTalVBox(parentScriptWidget()), true);
+ return true;
+}
+
+bool KviKvsObject_vbox::functionsetMargin(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iMargin;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("margin",KVS_PT_INT,0,iMargin)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalVBox *)widget())->setMargin(iMargin);
+ return true;
+}
+
+bool KviKvsObject_vbox::functionsetSpacing(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iSpacing;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("spacing",KVS_PT_INT,0,iSpacing)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) ((KviTalVBox *)widget())->setSpacing(iSpacing);
+ return true;
+}
+
+bool KviKvsObject_vbox::functionsetStretchFactor(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject * pObject;
+ kvs_hobject_t hObject;
+ kvs_uint_t uStretch;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("stretch",KVS_PT_UNSIGNEDINTEGER,0,uStretch)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!pObject->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ if(!pObject->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+
+ if(((KviKvsObject_widget *)pObject)->widget()->parentWidget() != widget())
+ {
+ c->warning(__tr2qs("The widget must be a child of this vbox"));
+ return true;
+ }
+ ((KviTalVBox *)widget())->setStretchFactor(((QWidget *)(pObject->object())),uStretch);
+ return true;
+} \ No newline at end of file
diff --git a/src/modules/objects/class_vbox.h b/src/modules/objects/class_vbox.h
new file mode 100644
index 00000000..d6b9d1cf
--- /dev/null
+++ b/src/modules/objects/class_vbox.h
@@ -0,0 +1,45 @@
+#ifndef _CLASS_VBOX_H_
+#define _CLASS_VBOX_H_
+//
+// File : class_vbox.h
+// Creation date : Wed Mar 01 2005 23:00:01 by Alessandro Carbone & Tonino Imbesi
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002-2006 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include "kvi_string.h"
+
+#include "class_widget.h"
+#include "kvi_tal_vbox.h"
+#include "object_macros.h"
+
+class KviKvsObject_vbox : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_vbox)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+ bool functionsetMargin(KviKvsObjectFunctionCall *c);
+ bool functionsetSpacing(KviKvsObjectFunctionCall *c);
+ bool functionsetStretchFactor(KviKvsObjectFunctionCall *c);
+
+};
+
+
+#endif //_CLASS_HBOX_H_
diff --git a/src/modules/objects/class_widget.cpp b/src/modules/objects/class_widget.cpp
new file mode 100644
index 00000000..d248c98b
--- /dev/null
+++ b/src/modules/objects/class_widget.cpp
@@ -0,0 +1,1745 @@
+//=============================================================================
+//
+// File : class_widget.cpp
+// Creation date : Mon Sep 11 16:35:32 CET 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "kvi_malloc.h"
+#include "kvi_debug.h"
+
+#include "kvi_error.h"
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+#include "kvi_window.h"
+#include "kvi_out.h"
+#include "kvi_mirccntrl.h"
+#include "kvi_app.h"
+#include "kvi_string.h"
+#include <qcursor.h>
+#include <qiconset.h>
+#include <qcolor.h>
+#include <qlayout.h>
+#include <qbitmap.h>
+#include <qmetaobject.h>
+#include "class_widget.h"
+#include "class_pixmap.h"
+
+#ifdef COMPILE_USE_QT4
+ #include <QKeyEvent>
+ #include <QDesktopWidget>
+#else
+ #include <qwidgetlist.h>
+#endif
+
+#include <qwidget.h>
+#include <qtooltip.h>
+#include <qfont.h>
+#include <qvariant.h>
+
+// FIX ME: WFLAGS
+const char * const widgettypes_tbl[] = {
+ "TopLevel",
+ "Dialog",
+ "Popup",
+ "Desktop",
+ "Customize",
+ "Title",
+ "StaysOnTop",
+ "SysMenu",
+ "Minimize",
+ "Maximize",
+ "NoAutoErase"
+ };
+#ifdef COMPILE_USE_QT4
+const Qt::WidgetAttribute widgetattributes_cod[]= {
+ Qt::WA_OpaquePaintEvent,
+ Qt::WA_NoSystemBackground,
+ Qt::WA_PaintOnScreen,
+ Qt::WA_NoMousePropagation,
+};
+
+const char * const widgetattributes_tbl[] = {
+ "opaquePaintEvent",
+ "noSystemBackground",
+ "paintOnScreen",
+ "noMousePropagation",
+};
+#define widgetattributes_num (sizeof(widgetattributes_tbl) / sizeof(widgetattributes_tbl[0]))
+
+
+const Qt::WindowType widgettypes_cod[] = {
+#else
+const int widgettypes_cod[] = {
+#endif
+ Qt::WType_TopLevel,
+ Qt::WType_Dialog,
+ Qt::WType_Popup,
+ Qt::WType_Desktop,
+ Qt::WStyle_Customize,
+ Qt::WStyle_Title,
+ Qt::WStyle_StaysOnTop,
+ Qt::WStyle_SysMenu,
+ Qt::WStyle_Minimize,
+ Qt::WStyle_Maximize,
+ Qt::WNoAutoErase
+};
+
+
+#ifdef COMPILE_USE_QT4
+
+ #define QT_WIDGET_TABFOCUS Qt::TabFocus
+ #define QT_WIDGET_CLICKFOCUS Qt::ClickFocus
+ #define QT_WIDGET_STRONGFOCUS Qt::StrongFocus
+ #define QT_WIDGET_NOFOCUS Qt::NoFocus
+
+#else
+ #define QT_WIDGET_TABFOCUS QWidget::TabFocus
+ #define QT_WIDGET_CLICKFOCUS QWidget::ClickFocus
+ #define QT_WIDGET_STRONGFOCUS QWidget::StrongFocus
+ #define QT_WIDGET_NOFOCUS QWidget::NoFocus
+#endif
+
+
+#define widgettypes_num (sizeof(widgettypes_tbl) / sizeof(widgettypes_tbl[0]))
+
+/*
+ @doc: widget
+ @keyterms:
+ widget object class
+ @title:
+ widget class
+ @type:
+ class
+ @short:
+ Base class for all widgets
+ @inherits:
+ [class]object[/class]
+ @description:
+ This object class is the rappresentation of a widget.
+ All the other widget-type classes inherit from this one.
+ @functions:
+ !fn: $show()
+ Shows this widget and the children.
+ See also [classfnc]$hide[/classfnc]() and [classfnc]$isVisible[/classfnc].
+ !fn: $hide()
+ Hides this widget (and conseguently all the children).
+ See also [classfnc]$show[/classfnc]() and [classfnc]$isVisible[/classfnc].
+ !fn: $repaint(<bool erase>)
+ Repaints the widget directly by calling [classfnc]$paintEvent[/classfnc]() immediately.[br]
+ If erase is TRUE, erases the widget before the $paintEvent() call.
+ !fn: $x()
+ Returns the x coordinate of the upper-left corner
+ of this widget relative to the parent widget,
+ or to the desktop if this widget is a toplevel one.
+ !fn: $y()
+ Returns the y coordinate of the uspper-left corner
+ of this widget relative to the parent widget,
+ or to the desktop if this widget is a toplevel one.
+ !fn: $width()
+ Returns the width of this widget in pixels.
+ !fn: $height()
+ Returns the height of this widget in pixels.
+ !fn: $geometry()
+ Returns the widget geometry in this form:[br]
+ x, y, width, height.
+ !fn: $setGeometry(<x_or_array>,[<y>,<width>,<heigth>])
+ Sets the geometry of this widget. <x> and <y> are relative
+ to the parent widget or to the desktop (if this widget is
+ a toplevel one). All the parameters are in pixels.
+ !fn: $setMinimumWidth(<value>)
+ Sets the minimum width of this widget to <value>.
+ The user will not be able to resize the widget to a smaller
+ value. This value is also used by the [class:layout]layout class[/class].
+ !fn: $setMinimumHeight(<value>)
+ Sets the minimum height of this widget to <value>.
+ The user will not be able to resize the widget to a smaller
+ value. This value is also used by the [class:layout]layout class[/class].
+ !fn: $setMaximumWidth(<value>)
+ Sets the maximum width of this widget to <value>.
+ The user will not be able to resize the widget to a bigger
+ value. This value is also used by the [class:layout]layout class[/class].
+ !fn: $setMaximumHeight(<value>)
+ Sets the maximum height of this widget to <value>.
+ The user will not be able to resize the widget to a bigger
+ value. This value is also used by the [class:layout]layout class[/class].
+ !fn: $move(<x_or_array>[,<y>])
+ Moves this widget to the coordinate <x> and <y> relative to its
+ parent widget (or the desktop if this widget is a toplevel one).
+ This is equivalent to [classfnc]$setGeometry[/classfnc](<x>,<y>,
+ [classfnc]$width[/classfnc](),[classfnc]$height[/classfnc]()).
+ !fn: $resize(<w_or_array>,[height])
+ Changes the widget's width to <width> and height to <height>.
+ See also [classfnc]$setGeometry[/classfnc]().
+ !fn: $isEnabled()
+ Returns '1' if the widget is enabled , '0' otherwise.
+ See also [classfnc:widget]$setEnabled[/classfnc]().
+ !fn: $setEnabled(<bool>)
+ Sets the widget state to enabled or disabled if <bool> is 1 or 0 respectively.
+ A disabled widget does not receive keyboard nor mouse input.
+ !fn: $setCaption(<text>)
+ Sets the caption of this widget to <text>.
+ This is meaningful for toplevel widgets only.
+ !fn: $setToolTip(<tooltip_text>)
+ Set the tooltip of this widget; the text can contain HTML formatting.
+ !fn: $window.caption()
+ Returns the caption text of this widget.
+ !fn: $isTopLevel()
+ Returns '1' if this widget is a toplevel (parentless) one,
+ '0' otherwise.
+ !fn: $isVisible()
+ Returns '1' if this widget is currently visible (read: is managed
+ by the window manager and displayed by the X server; the widget
+ may be hidden behind other widgets). If the widget is not visible
+ this function returns '0'.
+ See also [classfnc]$show[/classfnc]() and [classfnc]$hide[/classfnc]().
+ !fn: $raise()
+ Moves this widget to the top of the stack of the widgets relative
+ to its parent. See also [classfnc]$lower[/classfnc].
+ !fn: $lower()
+ Moves this widget to the bottom of the stack of the widgets relative
+ to its parent. See also [classfnc]$raise[/classfnc]
+ !fn: $hasFocus()
+ Returns '1' if this widget has the keyboard focus.
+ See also [classfnc]$setFocus[/classfnc].
+ !fn: $setFocus()
+ Sets this widget to be the one that receives keyboard events.
+ See also [classfnc]$hasFocus[/classfnc]
+ !fn: $parentWidget()
+ Returns the object id of the parent widget, or '0' if this
+ widget is a toplevel one.
+ !fn: $backgroundColor()
+ Returns the background color of this widget in hexadecimal
+ html-like format. For example , for a black bacground you will get
+ the string "000000" , for a red one , "FF0000", for a white one
+ "FFFFFF". See also [classfnc]$setBackgroundColor[/classfnc]()
+ !fn: $setBackgroundColor(<rgb(hex string)_array(red:integer,green:integer,blue_integer)_or_red>,[geen:integer],[blue:integer])
+ Sets the background color of this widget to <rgb_value>:valid values are:
+ - hex string: must be a string with 6 hexadecimal digits (like the ones used to
+ specify colors in html pages). The first two digits specify
+ the RED component, the third and fourth digit specify the GREEN component
+ and the last two specify the BLUE component.
+ For example "FFFF00" means full red, full green and no blue that gives
+ a yellow color, "808000" designates a brown color (dark yellow),
+ "A000A0" is a kind of violet.
+ - array(red:integer,green:integer,blue:integer)
+ - red:integer,green:integer,blue:integer.
+ See also [classfnc]$foregroundColor[/classfnc].
+ !fn: $setForegroundColor(<rgb(hex string)_array(red:integer,green:integer,blue_integer)_or_red>,[geen:integer],[blue:integer])
+ Sets the foreground color of this widget to <rgb_value>:valid values are:
+ - hex string: must be a string with 6 hexadecimal digits (like the ones used to
+ specify colors in html pages). The first two digits specify
+ the RED component, the third and fourth digit specify the GREEN component
+ and the last two specify the BLUE component.
+ For example "FFFF00" means full red, full green and no blue that gives
+ a yellow color, "808000" designates a brown color (dark yellow),
+ "A000A0" is a kind of violet.
+ - array(red:integer,green:integer,blue:integer)
+ - red:integer,green:integer,blue:integer.
+ See also [classfnc]$foregroundColor[/classfnc].
+ !fn: $foregroundColor()
+ Returns the foreground color of this widget in hexadecimal
+ html-like format.
+ See also [classfnc]$setForegroundColor[/classfnc].
+ !fn: $setMouseTracking(<bool>)
+ Enables or disables the mouse tracking if <bool> is '1' or '0' respectively.
+ When mouse tracking is enabled you will receive mouse move events
+ even if no button is pressed, otherwise you will receive it only
+ when a mouse button is being pressed (so after a mousePressEvent).
+ !fn: $mousePressEvent(<button>,<x>,<y>)
+ This function is called when a mouse button is pressed while
+ the cursor is in this widget. <button> is 0 if the pressed button
+ is the left one, 1 if the button is the right one and 2 if it is the middle one.
+ The <x> and <y> coordinates are relative to this widget upper-left corner
+ and are expressed in pixels.
+ If you call "[cmd]setreturn[/cmd] 1" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $mouseReleaseEvent(<button>,<x>,<y>)
+ This function is called when a mouse button is released while
+ the cursor is in this widget. <button> is 0 if the released button
+ is the left one, 1 if the button is the right one and 2 if it is the middle one.
+ The <x> and <y> coordinates are relative to this widget upper-left corner
+ and are expressed in pixels.
+ If you call "[cmd]setreturn[/cmd] 1" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $mouseDoubleClickEvent(<button>,<x>,<y>)
+ This function is called when a mouse button is double clicked while
+ the cursor is in this widget. <button> is 0 if the double clicked button
+ is the left one, 1 if the button is the right one and 2 if it is the middle one.
+ The <x> and <y> coordinates are relative to this widget upper-left corner
+ and are expressed in pixels.
+ If you call "[cmd]setreturn[/cmd] 1" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $mouseMoveEvent(<button>,<x>,<y>)
+ This function is called when the mouse cursor moves inside this widget.
+ <button> is 0 if the pressed button
+ is the left one, 1 if the button is the right one and 2 if it is the middle one.
+ The special value of -1 indicates that no button is being pressed.
+ The <x> and <y> coordinates are relative to this widget upper-left corner
+ and are expressed in pixels.
+ Normally you will receive this event only if a mouse button is being pressed
+ while moving. If you want to receive it also when the mouse buttons are not
+ pressed, call [classfnc]$setMouseTracking[/classfnc]().
+ If you call "[cmd]return[/cmd]$true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $focusInEvent()
+ This function is called when this widget gains keyboard focus.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $focusOutEvent()
+ This function is called when this widget looses keyboard focus.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $mouseLeaveEvent()
+ This function is called when the mouse leaves this widget.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $mouseEnterEvent()
+ This function is called when the mouse enters this widget.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $showEvent()
+ This function is called when this widget is being shown.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $hideEvent()
+ This function is called when this widget is being hidden.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $closeEvent()
+ This function is called when this widget is going to be closed.
+ If you call "[cmd]return[/cmd] $true" you will ignore the close event.
+ The default implementation does nothing.
+ !fn: $resizeEvent()
+ This function is called immediately after this widget has been resized.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: $moveEvent()
+ This function is called immediately after this widget has been moved.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event. The default implementation does nothing.
+ !fn: <tip:string> $maybeTipEvent(<x_tip_pos:integer>,<y_tip_pos:integer>)[QT4 only]
+ This event handler is called when a eventualy tip is going to be show.
+ You can be reimplement this event and set a dynamic tool tip by using "[cmd]return[/cmd] <tooltip_string>".
+ If a tooltip has setted with [classfnc]$setTooltip[/classfnc] the dynamic tooltip will be ignored.
+ The default implementation does nothing.
+ !fn: $paintEvent()
+ This event handler can be reimplemented to repaint all or part of the widget.
+ It's needed by the Painter class.
+ It's very useful for drawing flicker free animations or low level special graphic effects.
+ If you call "[cmd]return[/cmd] $true" you will stop the internal processing
+ of this event.
+ The default implementation does nothing.
+ !fn: $setIcon(<image_id>)
+ Sets the icon for this widget. This is meaningful only for toplevel widgets.
+ See the [doc:image_id]image identifier[/doc] documentation for the explaination
+ of the <image_id> parameter.
+ !fn: $setBackgroundImage(<image_id>)
+ Sets the background image for this widget.
+ See the [doc:image_id]image identifier[/doc] documentation for the explaination
+ of the <image_id> parameter.
+ For some kind of widgets, setting a background pixmap may have no effect or
+ have strange results. Experiment with it.
+ To unset the background image call [classfnc]$setBackgroundColor[/classfnc]
+ !fn: $setFont(<size>,<family>,<style>)[br]
+ Set the font's size, family and stile, valid flag for style are:[br]
+ [pre]
+ italic [br]
+ bold [br]
+ underline [br]
+ overline [br]
+ strikeout [br]
+ fixedpitch [br]
+ [/pre]
+ !fn: $setWFlags(<flag1>, <flag2>, ...)
+ This function sets widget flags, given as parameters.
+ Valid flags are:
+ [pre]
+ TopLevel - indicates that this widget is a top-level widget[br]
+ Dialog - indicates that this widget is a top-level window that should be decorated as a dialog[br]
+ Desktop - indicates that this widget is the desktop[br]
+ Popup - indicates that this widget is a popup top-level window[br]
+ NoAutoErase - indicates that this widget paints all its pixels. Updating, resizing, scrolling and focus changes should therefore not erase the widget.
+ Customize - let's the user to customize the style of the widget.[br]
+ [br]
+ Valid parameter for a customized widget are:[br]
+ Title - gives the window a title bar[br]
+ StaysOnTop - window stays on top [br]
+ SysMenu - add a windows system menu[br]
+ Minimize - add a minimize button for the sysmenu style[br]
+ Maximize - add a maximixe button for the sysmenu style[br]
+ [/pre]
+ !fn: $centerToScreen()
+ Centers the window on the screen (useful only for toplevel widgets).[br]
+ The best place to call this function is in $showEvent()
+ !fn: $setFocusPolicy(<key focus>)
+ Sets the way the widget accepts keyboard focus.[br]
+ Valid parameters are:
+ [pre]
+ - TabFocus; (widget accepts keyboard focus by tabbing)[br]
+ - ClickFocus; (widget accepts keyboard focus by clicking)[br]
+ - StrongFocus; (widget accepts both tabbing/clicking)[br]
+ - No Focus; (widget does not accept focus at all; this is the default value)[br]
+ [/pre]
+ !fn: $keyPressEvent(<key>)
+ If widget accepts keyboard focus (see [classfnc]$setFocusPolicy[/classfnc] ) this function handles for keys;
+ In its argument the key pressed.[br]
+ Special keys are:
+ [pre]
+ - Return [br]
+ - Enter [br]
+ - Down (cursor arrow down) [br]
+ - Up (cursor arrow up) [br]
+ - Left (cursor arrow left) [br]
+ - Right (cursor arrow right) [br]
+ - Shift [br]
+ - Ctrl [br]
+ - Alt [br]
+ - CapsLock [br]
+ - Backspace [br]
+ - Del [br]
+ - Esc [br]
+ - 0 [br]
+ - 1 [br]
+ - 2 [br]
+ - 3 [br]
+ - 4 [br]
+ - 5 [br]
+ - 6 [br]
+ - 7 [br]
+ - 8 [br]
+ - 9 [br]
+ - + [br]
+ - - [br]
+ - * [br]
+ - / [br]
+ - ( [br]
+ - ) [br]
+ - = [br]
+ - . [br]
+ - ^ [br]
+
+ [/pre]
+ !fn: $mapFromGlobal(<x>,<y>)
+ Translates the global screen coordinate pos to widget coordinates.
+ !fn: $mapToGlobal(<x>,<y>)
+ Translates widget coordinates into the global screen coordinate pos.
+ !fn: integer $globalCursorX()
+ Return the x coordinate of mouse pointer global position.
+ !fn: integer $globalCursorY()
+ Return the y coordinate of the mo>use pointer global position.
+ @examples:
+ [example]
+ %Widget = $new(widget)
+ # This is the main container for other elements.
+
+ %Widget->$setCaption("This is the widget title")
+
+ %Widget->$setGeometry(100,200,170,290)
+ # 100 and 200 are distance (pixel) from the left and the top of father widget (in this case the KVIrc window)
+ # 300 and 400 are the weight and the height of the widget
+
+ %Widget->%label = $new(label,%Widget)
+ %Widget->%label->$setText("This is a text label")
+ %Widget->%label->$setGeometry(10,10,150,20)
+
+ %Widget->%lineedit = $new(lineedit,%Widget)
+ %Widget->%lineedit->$setText("This is a lineedit")
+ %Widget->%lineedit->$setGeometry(10,40,150,20)
+
+ %Widget->%multilineedit = $new(multilineedit,%Widget)
+ %Widget->%multilineedit->$setText("This is a multilineedit")
+ %Widget->%multilineedit->$setGeometry(10,70,150,40)
+
+ %Widget->%checkbox = $new(checkbox,%Widget)
+ %Widget->%checkbox->$setText("This is a checkbox")
+ %Widget->%checkbox->$setGeometry(10,120,150,20)
+
+ %Widget->%combobox = $new(combobox,%Widget)
+ %Widget->%combobox->$setGeometry(10,150,150,20)
+ %Widget->%combobox->$insertItem("This is a combobox")
+ %Widget->%combobox->$insertItem("This is a combobox's item")
+
+ %Widget->%listbox = $new(listbox,%Widget)
+ %Widget->%listbox->$setGeometry(10,180,150,40)
+ %Widget->%listbox->$insertItem("This is another item")
+ %Widget->%listbox->$insertItem("This is a listbox's item")
+ %Widget->%listbox->$insertItem("This is a listbox")
+
+ %Widget->%radiobutton = $new(radiobutton,%Widget)
+ %Widget->%radiobutton->$setGeometry(10,230,150,20)
+ %Widget->%radiobutton->$setText("This is a radiobutton")
+
+ %Widget->%button = $new(button, %Widget)
+ %Widget->%button->$setText("Close me")
+ %Widget->%button->$setGeometry(10,260,150,20)
+
+ %Widget->$show()
+ # This shows the widget
+
+ privateimpl(%Widget->%button, mousePressEvent) {
+ delete %Widget
+ # This closes the widget automatically
+ }
+ # privateimpl is triggered when user press the button.
+ # To do that, widget must be a global variable.
+ [/example]
+
+*/
+
+
+
+
+//
+// If you never call c->error() , c->warning() (your function never fails)
+// and never call a function that can call c->error() or c->warning()
+// you can avoid ENTER_STACK_FRAME and c->leaveStackFrame()
+// Just return true.
+// c->error() should be called only in really critical situations
+// (we have to define better "critical situation")
+// if possible , leave the things go after just a c->warning()
+//
+
+ // widget() will be never 0 in THIS class
+ // but in derived classes WILL be
+ // ... now that I think about it , it
+ // may happen that widget() will be zero here too:
+ // If the Qt "physical" widget gets destroyed
+ // by some external factor (for example when children
+ // of a wrapper widget destroyed by KVIrc).
+ //
+ // as a convention:
+ // if widget() can be 0 in a class
+ // the user must have a function to check it
+ // (sth as object::$hasObject() could do the trick)
+ // obviously this will happen only in well defined cases
+ // as in a qtwrapper not yet wrapped or failed to wrap (so
+ // qtwrapper::$wrap() returned '0' for example)
+ // or after the widget has been destroyed...
+ // if widget() is 0 , the functions perform no actions
+ // return no errors and results that have to be assumed
+ // as invalid (this allows the minimum overhead: if widget()
+
+//=============================================================================================================
+
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_widget,"widget","object")
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"reparent",function_reparent)
+ // apparence
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"show",function_show)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"hide",function_hide)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"repaint",function_repaint)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"isTopLevel",function_isTopLevel)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"isVisible",function_isVisible)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"raise",function_raise)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"lower",function_lower)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setEnabled",function_setEnabled)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"isEnabled",function_isEnabled)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setMouseTracking",function_setMouseTracking)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setCaption",function_setCaption)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"caption",function_caption)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"hasFocus",function_hasFocus)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setFocus",function_setFocus)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setToolTip",function_setToolTip)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setWFlags",function_setWFlags)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setIcon",function_setIcon)
+ // fonts
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"fontDescent",function_fontDescent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"fontAscent",function_fontAscent)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"fontMetricsWidth",function_fontMetricsWidth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"fontMetricsHeight",function_fontMetricsHeight)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setFont",function_setFont)
+ // geometry
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"screenResolution",function_screenResolution)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"centerToScreen",function_centerToScreen)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"geometry",function_geometry)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setGeometry",function_setGeometry)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"mapToGlobal",function_mapToGlobal)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"mapFromGlobal",function_mapFromGlobal)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"y",function_y)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"x",function_x)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"globalCursorX",function_globalCursorX)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"globalCursorY",function_globalCursorY)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"width",function_width)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"height",function_height)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setMinimumWidth",function_setMinimumWidth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setMinimumHeight",function_setMinimumHeight)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setMaximumWidth",function_setMaximumWidth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setMaximumHeight",function_setMaximumHeight)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"move",function_move)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"sizeHint",function_sizeHint)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"resize",function_resize)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setFocusPolicy",function_setFocusPolicy)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"addWidgetToWrappedLayout",function_addWidgetToWrappedLayout)
+
+ // colors and image
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setForegroundColor",function_setPaletteForeground)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setBackgroundColor",function_setBackgroundColor)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setBackgroundImage",function_setBackgroundImage)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"backgroundColor",function_backgroundColor)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"foregroundColor",function_foregroundColor)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setMask",function_setMask)
+
+ // QT4 only
+#ifdef COMPILE_USE_QT4
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setAttribute",function_setAttribute)
+#endif
+
+ // events
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"mousePressEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"mouseReleaseEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"mouseDoubleClickEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"mouseMoveEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"focusInEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"focusOutEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"mouseLeaveEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"mouseEnterEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"showEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"hideEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"closeEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"resizeEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"moveEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"paintEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"keyPressEvent")
+#ifdef COMPILE_USE_QT4
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"maybeTipEvent")
+#endif
+
+
+KVSO_END_REGISTERCLASS(KviKvsObject_widget)
+
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_widget,KviKvsObject)
+KVSO_END_CONSTRUCTOR(KviKvsObject_widget)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_widget)
+ emit aboutToDie();
+KVSO_END_CONSTRUCTOR(KviKvsObject_widget)
+
+bool KviKvsObject_widget::init(KviKvsRunTimeContext * pContext,KviKvsVariantList * pParams)
+{
+ setObject(new QWidget(parentScriptWidget(),getName()),true);
+ return true;
+}
+
+bool KviKvsObject_widget::eventFilter(QObject *o,QEvent *e)
+{
+ if(o == object())
+ {
+ bool ret=false;
+ int aparam;
+ bool brokenhandler=false;
+ KviKvsVariant *retv=new KviKvsVariant(ret);
+
+ switch(e->type())
+ {
+ #ifdef COMPILE_USE_QT4
+ case QEvent::ToolTip:
+ {
+ QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
+ QPoint point=helpEvent->pos();
+ QString szTooltip;
+ KviKvsVariant *tipret=new KviKvsVariant(szTooltip);
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)point.x()),new KviKvsVariant((kvs_int_t)point.y()));
+ callFunction(this,"maybeTipEvent",tipret,&params);
+ tipret->asString(szTooltip);
+ QToolTip::showText(helpEvent->globalPos(),szTooltip);
+ break;
+ }
+ #endif
+ case QEvent::Paint:
+ {
+ QRect rect=((QPaintEvent *)e)->rect();
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)rect.x()),new KviKvsVariant((kvs_int_t)rect.y()),new KviKvsVariant((kvs_int_t)rect.width()),new KviKvsVariant((kvs_int_t)rect.height()));
+ callFunction(this,"paintEvent",retv,&params);
+ break;
+ }
+
+ case QEvent::KeyPress:
+ {
+ QString tmp="";
+ switch(((QKeyEvent *)e)->key())
+ {
+ case Qt::Key_Return:
+ tmp="Return";
+ break;
+ case Qt::Key_Down:
+ tmp="Down";
+ break;
+ case Qt::Key_Up:
+ tmp="Up";
+ break;
+ case Qt::Key_Left:
+ tmp="Left";
+ break;
+ case Qt::Key_Right:
+ tmp="Right";
+ break;
+ case Qt::Key_Shift:
+ tmp="Shift";
+ break;
+ case Qt::Key_Control:
+ tmp="Ctrl";
+ break;
+ case Qt::Key_Alt:
+ tmp="Alt";
+ break;
+ case Qt::Key_CapsLock:
+ tmp="CapsLock";
+ break;
+ case Qt::Key_Backspace:
+ tmp="Backspace";
+ break;
+ case Qt::Key_Delete:
+ tmp="Del";
+ break;
+
+ case Qt::Key_Enter:
+ tmp="Enter";
+ break;
+ case Qt::Key_Escape:
+ tmp="Esc";
+ break;
+ case Qt::Key_0:
+ tmp="0";
+ case Qt::Key_1:
+ tmp="1";
+ break;
+ case Qt::Key_2:
+ tmp="2";
+ break;
+ case Qt::Key_3:
+ tmp="3";
+ break;
+ case Qt::Key_4:
+ tmp="4";
+ break;
+ case Qt::Key_5:
+ tmp="5";
+ break;
+ case Qt::Key_6:
+ tmp="6";
+ break;
+ case Qt::Key_7:
+ tmp="7";
+ break;
+ case Qt::Key_8:
+ tmp="8";
+ break;
+ case Qt::Key_9:
+ tmp="9";
+ break;
+ case Qt::Key_Plus:
+ tmp="+";
+ break;
+ case Qt::Key_Minus:
+ tmp="-";
+ break;
+ case Qt::Key_Slash:
+ tmp="/";
+ break;
+ case Qt::Key_Asterisk:
+ tmp="*";
+ break;
+ case Qt::Key_Period:
+ tmp=".";
+ break;
+ case Qt::Key_ParenLeft:
+ tmp="(";
+ break;
+ case Qt::Key_ParenRight:
+ tmp=")";
+ break;
+ case Qt::Key_Equal:
+ tmp="=";
+ break;
+ case Qt::Key_AsciiCircum:
+ tmp="^";
+ break;
+ default:
+ if (!((QKeyEvent *)e)->text().isEmpty()) tmp = ((QKeyEvent *)e)->text();
+ }
+
+ KviKvsVariantList params(new KviKvsVariant(tmp));
+ callFunction(this,"keyPressEvent",0,&params);
+ }
+ break;
+ case QEvent::MouseButtonPress:
+ if(((QMouseEvent *)e)->button() & Qt::LeftButton)aparam = 0;
+ else {
+ if(((QMouseEvent *)e)->button() & Qt::RightButton)aparam = 1;
+ else aparam = 2;
+ }
+ if(!callFunction(this,"mousePressEvent",retv,new KviKvsVariantList(new KviKvsVariant((kvs_int_t)aparam),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().x()),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().y())
+ ))) brokenhandler = true; // ignore results of a broken event handler
+ break;
+ case QEvent::MouseButtonRelease:
+ if(((QMouseEvent *)e)->button() & Qt::LeftButton)aparam = 0;
+ else {
+ if(((QMouseEvent *)e)->button() & Qt::RightButton)aparam = 1;
+ else aparam = 2;
+ }
+ if(!callFunction(this,"mouseReleaseEvent",retv,new KviKvsVariantList(new KviKvsVariant((kvs_int_t)aparam),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().x()),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().y())
+ ))) brokenhandler = true; // ignore results of a broken event handler
+ break;
+ case QEvent::MouseButtonDblClick:
+ if(( (QMouseEvent *)e)->button() & Qt::LeftButton)aparam = 0;
+ else {
+ if(((QMouseEvent *)e)->button() & Qt::RightButton)aparam = 1;
+ else aparam = 2;
+ }
+ if(!callFunction(this,"mouseDoubleClickEvent",retv,new KviKvsVariantList(new KviKvsVariant((kvs_int_t)aparam),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().x()),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().y())
+ ))) brokenhandler = true; // ignore results of a broken event handler
+
+ break;
+ case QEvent::MouseMove:
+ if( (((QMouseEvent *)e)->state()) & Qt::LeftButton) aparam = 0;
+ else
+ {
+ if(((QMouseEvent *)e)->state() & Qt::RightButton)aparam = 1;
+ else
+ {
+ if(((QMouseEvent *)e)->state() & Qt::MidButton)aparam = 2;
+ else aparam = -1;
+ }
+ }
+ if(!callFunction(this,"mouseMoveEvent",retv,new KviKvsVariantList(new KviKvsVariant((kvs_int_t)aparam),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().x()),new KviKvsVariant((kvs_int_t)((QMouseEvent *)e)->pos().y())
+ ))) brokenhandler = true; // ignore results of a broken event handler
+ break;
+ case QEvent::FocusIn:
+ if(!callFunction(this,"focusInEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::FocusOut:
+ if(!callFunction(this,"focusOutEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::Resize:
+ if(!callFunction(this,"resizeEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::Move:
+ if(!callFunction(this,"moveEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::Close:
+ if(!callFunction(this,"closeEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::Enter:
+ if(!callFunction(this,"mouseEnterEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::Leave:
+ if(!callFunction(this,"mouseLeaveEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::Show:
+ if(!callFunction(this,"showEvent",retv,0))brokenhandler = true;
+ break;
+ case QEvent::Hide:
+ if(!callFunction(this,"hideEvent",retv,0))ret =false;
+ break;
+ default:
+ return KviKvsObject::eventFilter(o,e);
+ break;
+
+ }
+ if (!brokenhandler) ret=retv->asBoolean();
+ delete retv;
+ return ret;
+ /*
+ if(ret.length() == 1)
+ {
+ if(KviQString::equalCI("1",ret))return true;
+ }
+ */
+ }
+
+ return KviKvsObject::eventFilter(o,e);
+}
+
+
+bool KviKvsObject_widget::function_show(KviKvsObjectFunctionCall *c)
+{
+ if(!widget())return true; // should we warn here ?
+ widget()->show();
+ return true;
+}
+
+bool KviKvsObject_widget::function_setEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ widget()->setEnabled(bEnabled);
+ return true;
+}
+bool KviKvsObject_widget::function_isEnabled(KviKvsObjectFunctionCall *c)
+{
+ if(!widget()) return true;
+ c->returnValue()->setBoolean(widget()->isEnabled());
+ return true;
+}
+bool KviKvsObject_widget::function_fontDescent(KviKvsObjectFunctionCall * c)
+{
+ if(!widget()) return true;
+ QFontMetrics fm = widget()->fontMetrics();
+ int d = fm.descent();
+ c->returnValue()->setInteger(d);
+ return true;
+}
+
+bool KviKvsObject_widget::function_fontAscent(KviKvsObjectFunctionCall * c)
+{
+ if(!widget()) return true;
+ QFontMetrics fm = widget()->fontMetrics();
+ int d = fm.ascent();
+ c->returnValue()->setInteger(d);
+ return true;
+
+}
+
+bool KviKvsObject_widget::function_repaint(KviKvsObjectFunctionCall * c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+ widget()->repaint(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_widget::function_fontMetricsWidth(KviKvsObjectFunctionCall * c)
+{
+ QString m_szStr;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("string",KVS_PT_STRING,0,m_szStr)
+ KVSO_PARAMETERS_END(c)
+ if(!widget()) return true;
+// int fm = widget()->fontMetrics().width(m_szStr);
+ c->returnValue()->setInteger(widget()->fontMetrics().width(m_szStr));
+ return true;
+}
+
+bool KviKvsObject_widget::function_fontMetricsHeight(KviKvsObjectFunctionCall * c)
+{
+ if(!widget())return true;
+ int fm = widget()->fontMetrics().height();
+ c->returnValue()->setInteger(fm);
+ return true;
+}
+bool KviKvsObject_widget::function_screenResolution(KviKvsObjectFunctionCall * c)
+{
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)g_pApp->desktop()->width()));
+ a->set(1,new KviKvsVariant((kvs_int_t)g_pApp->desktop()->height()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+bool KviKvsObject_widget::function_geometry(KviKvsObjectFunctionCall *c)
+{
+ QRect r = widget() ? widget()->geometry() : QRect(0,0,0,0);
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)r.x()));
+ a->set(1,new KviKvsVariant((kvs_int_t)r.y()));
+ a->set(2,new KviKvsVariant((kvs_int_t)r.width()));
+ a->set(3,new KviKvsVariant((kvs_int_t)r.height()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+bool KviKvsObject_widget::function_setGeometry(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pXOrArray;
+ kvs_int_t iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+
+ // this is a little bit tricky: we accept two syntax versions
+ // (this is something like a C++ overload)
+ // $setGeometry(x,y,w,h) OR $setGeometry($array(x,y,w,h))
+
+ // For this purpose we ask the parameter processing engine
+ // to return the first parameter as variant and we manually check its data typoe
+ // We also set the following three parameters as optional
+ // so the user can either pass one or four parameters.
+
+ // Because of this trick, we must check the parameter consistency
+ // manually.
+
+ if(pXOrArray->isArray())
+ {
+ // the user has passed a complete geometry array as first parameter
+ // make sure it has at least 4 elements
+ if(pXOrArray->array()->size() < 4)
+ {
+ c->error(__tr2qs("The array passed as parameter must contain at least 4 elements"));
+ return false;
+ }
+ // we must also manually extract the data from the array
+ KviKvsVariant * pX = pXOrArray->array()->at(0);
+ KviKvsVariant * pY = pXOrArray->array()->at(1);
+ KviKvsVariant * pW = pXOrArray->array()->at(2);
+ KviKvsVariant * pH = pXOrArray->array()->at(3);
+ // note that some of the array elements may be empty in fact
+ // a null value returned by KviKvsArray::at() means that
+ // no parameter was set in that place
+ if(!(pX && pY && pW && pH))
+ {
+ c->error(__tr2qs("One of the geometry array parameters is empty"));
+ return false;
+ }
+ if(!(pX->asInteger(iX) && pY->asInteger(iY) && pW->asInteger(iW) && pH->asInteger(iH)))
+ {
+ c->error(__tr2qs("One of the geometry array parameters didn't evaluate to an integer"));
+ return false;
+ }
+ // ok: the params are correct
+ } else {
+ // The user passed something else as first parameter
+ // make sure that it is an integer.
+ // Also make sure that we really have 4 parameters
+ if(c->params()->count() < 4)
+ {
+ c->error(__tr2qs("$setGeometry() requires either an array as first parameter or four integers"));
+ return false;
+ }
+ if(!pXOrArray->asInteger(iX))
+ {
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));
+ return false;
+ }
+ // ok: the params are correct
+ }
+
+ if(widget())
+ widget()->setGeometry(iX,iY,iW,iH);
+
+ return true;
+}
+bool KviKvsObject_widget::function_mapToGlobal(KviKvsObjectFunctionCall *c)
+
+{
+ if(!widget())return true;
+ kvs_int_t iX,iY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
+ KVSO_PARAMETERS_END(c)
+ QPoint point=widget()->mapToGlobal(QPoint(iX,iY));
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)point.x()));
+ a->set(1,new KviKvsVariant((kvs_int_t)point.y()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+bool KviKvsObject_widget::function_mapFromGlobal(KviKvsObjectFunctionCall *c)
+
+{
+ if(!widget())return true;
+ kvs_int_t iX,iY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
+ KVSO_PARAMETERS_END(c)
+ QPoint point=widget()->mapFromGlobal(QPoint(iX,iY));
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)point.x()));
+ a->set(1,new KviKvsVariant((kvs_int_t)point.y()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+bool KviKvsObject_widget::function_centerToScreen(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) widget()->move((g_pApp->desktop()->width() - widget()->width())/2,(g_pApp->desktop()->height() - widget()->height())/2);
+ return true;
+}
+
+bool KviKvsObject_widget::function_setPaletteForeground(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pColArray;
+ kvs_int_t iColR,iColG,iColB;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("hex_rgb_array_or_red",KVS_PT_VARIANT,0,pColArray)
+ KVSO_PARAMETER("green",KVS_PT_INT,KVS_PF_OPTIONAL,iColG)
+ KVSO_PARAMETER("blue",KVS_PT_INT,KVS_PF_OPTIONAL,iColB)
+ KVSO_PARAMETERS_END(c)
+
+ if(pColArray->isArray())
+ {
+ if(pColArray->array()->size() < 3)
+ {
+ c->error(__tr2qs("The array passed as parameter must contain at least 3 elements"));
+ return false;
+ }
+ KviKvsVariant * pColR = pColArray->array()->at(0);
+ KviKvsVariant * pColG = pColArray->array()->at(1);
+ KviKvsVariant * pColB = pColArray->array()->at(2);
+
+ if(!(pColR && pColG && pColB))
+ {
+ c->error(__tr2qs("One of the colors array parameters is empty"));
+ return false;
+ }
+ if(!(pColR->asInteger(iColR) && pColG->asInteger(iColG) && pColB->asInteger(iColB)))
+ {
+ c->error(__tr2qs("One of the colors array parameters didn't evaluate to an integer"));
+ return false;
+ }
+
+ } else {
+ if (c->params()->count()==1)
+ {
+ bool bOk,bOk1,bOk2;
+ QString value;
+ pColArray->asString(value);
+ int i=0;
+ if (value.length()!=6)
+ {
+ c->warning(__tr2qs("A string of 6 digits hex is required"));
+ return true;
+ }
+ QString buffer(value.mid(0,2));
+ iColR=buffer.toInt(&bOk,16);
+ buffer=value.mid(2,2);
+ iColG=buffer.toInt(&bOk1,16);
+ buffer=value.mid(4,2);
+ iColB=buffer.toInt(&bOk2,16);
+ if (!bOk || !bOk1 || !bOk2)
+ {
+ c->warning(__tr2qs("Not an hex digits"));
+ return true;
+ }
+ if (widget()) widget()->setPaletteForegroundColor(QColor(iColR,iColG,iColB));
+ return true;
+ }
+
+ if(c->params()->count() < 3)
+ {
+
+ c->error(__tr2qs("$setForegroundColor requires either an array as first parameter, one hex string or three integers"));
+ return false;
+ }
+ if(!pColArray->asInteger(iColR))
+ {
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));
+ return false;
+ }
+ }
+ if (widget()) widget()->setPaletteForegroundColor(QColor(iColR,iColG,iColB));
+ return true;
+}
+
+bool KviKvsObject_widget::function_setBackgroundColor(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pColArray;
+ kvs_int_t iColR,iColG,iColB;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("hex_rgb_array_or_red",KVS_PT_VARIANT,0,pColArray)
+ KVSO_PARAMETER("green",KVS_PT_INT,KVS_PF_OPTIONAL,iColG)
+ KVSO_PARAMETER("blue",KVS_PT_INT,KVS_PF_OPTIONAL,iColB)
+ KVSO_PARAMETERS_END(c)
+
+ if(pColArray->isArray())
+ {
+ if(pColArray->array()->size() < 3)
+ {
+ c->error(__tr2qs("The array passed as parameter must contain at least 3 elements"));
+ return false;
+ }
+ KviKvsVariant * pColR = pColArray->array()->at(0);
+ KviKvsVariant * pColG = pColArray->array()->at(1);
+ KviKvsVariant * pColB = pColArray->array()->at(2);
+
+ if(!(pColR && pColG && pColB))
+ {
+ c->error(__tr2qs("One of the colors array parameters is empty"));
+ return false;
+ }
+ if(!(pColR->asInteger(iColR) && pColG->asInteger(iColG) && pColB->asInteger(iColB)))
+ {
+ c->error(__tr2qs("One of the colors array parameters didn't evaluate to an integer"));
+ return false;
+ }
+
+ } else {
+ if (c->params()->count()==1)
+ {
+ bool bOk,bOk1,bOk2;
+ QString value;
+ pColArray->asString(value);
+ int i=0;
+ if (value.length()!=6)
+ {
+ c->warning(__tr2qs("A string of 6 digits hex is required"));
+ return true;
+ }
+ QString buffer(value.mid(0,2));
+ iColR=buffer.toInt(&bOk,16);
+ buffer=value.mid(2,2);
+ iColG=buffer.toInt(&bOk1,16);
+ buffer=value.mid(4,2);
+ iColB=buffer.toInt(&bOk2,16);
+ if (!bOk || !bOk1 || !bOk2)
+ {
+ c->warning(__tr2qs("Not an hex digits"));
+ return true;
+ }
+ if (widget()) widget()->setBackgroundColor(QColor(iColR,iColG,iColB));
+ return true;
+ }
+
+ if(c->params()->count() < 3)
+ {
+
+ c->error(__tr2qs("$setBackgroundColor requires either an array as first parameter, one hex string or three integers"));
+ return false;
+ }
+ if(!pColArray->asInteger(iColR))
+ {
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));
+ return false;
+ }
+ }
+ if (widget()) widget()->setBackgroundColor(QColor(iColR,iColG,iColB));
+ return true;
+}
+
+bool KviKvsObject_widget::function_backgroundColor(KviKvsObjectFunctionCall *c)
+{
+ if(!widget())return true;
+ QColor col = widget()->backgroundColor();
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)col.red()));
+ a->set(1,new KviKvsVariant((kvs_int_t)col.green()));
+ a->set(2,new KviKvsVariant((kvs_int_t)col.blue()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+bool KviKvsObject_widget::function_foregroundColor(KviKvsObjectFunctionCall *c)
+{
+ if(!widget())return true;
+ QColor col = widget()->foregroundColor();
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)col.red()));
+ a->set(1,new KviKvsVariant((kvs_int_t)col.green()));
+ a->set(2,new KviKvsVariant((kvs_int_t)col.blue()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+bool KviKvsObject_widget::function_parentWidget(KviKvsObjectFunctionCall *c)
+{
+ if(!widget())return true;
+ if(parentScriptWidget()) c->returnValue()->setHObject(parentObject()->handle());
+ else
+ c->returnValue()->setHObject((kvs_hobject_t)0);
+ return true;
+
+}
+bool KviKvsObject_widget::function_setMouseTracking(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) widget()->setMouseTracking(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_widget::function_setCaption(KviKvsObjectFunctionCall *c)
+{
+ QString szCaption;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("caption",KVS_PT_STRING,0,szCaption)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) widget()->setCaption(szCaption);
+ return true;
+}
+
+bool KviKvsObject_widget::function_caption(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setString(widget()->caption().utf8().data());
+ return true;
+}
+
+bool KviKvsObject_widget::function_isTopLevel(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setBoolean(widget()->isTopLevel());
+ return true;
+}
+
+bool KviKvsObject_widget::function_isVisible(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setBoolean(widget()->isVisible());
+ return true;
+}
+
+bool KviKvsObject_widget::function_raise(KviKvsObjectFunctionCall *)
+{
+ if(widget()) widget()->raise();
+ return true;
+}
+
+bool KviKvsObject_widget::function_lower(KviKvsObjectFunctionCall *)
+{
+ if(widget())widget()->lower();
+ return true;
+}
+
+bool KviKvsObject_widget::function_hasFocus(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setBoolean(widget()->hasFocus());
+ return true;
+}
+
+bool KviKvsObject_widget::function_setFocus(KviKvsObjectFunctionCall *c)
+{
+ if (widget())widget()->setFocus();
+ return true;
+}
+bool KviKvsObject_widget::function_hide(KviKvsObjectFunctionCall *)
+{
+ if(widget())widget()->hide();
+ return true;
+}
+
+bool KviKvsObject_widget::function_setToolTip(KviKvsObjectFunctionCall *c)
+{
+ QString szTooltip;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("tooltip",KVS_PT_STRING,0,szTooltip)
+ KVSO_PARAMETERS_END(c)
+ if(widget())QToolTip::add( widget(), szTooltip );
+ return true;
+}
+
+bool KviKvsObject_widget::function_x(KviKvsObjectFunctionCall *c)
+{
+ if(widget()) c->returnValue()->setInteger(widget()->x());
+ return true;
+}
+
+bool KviKvsObject_widget::function_y(KviKvsObjectFunctionCall *c)
+{
+ if(widget())c->returnValue()->setInteger(widget()->y());
+ return true;
+}
+
+bool KviKvsObject_widget::function_width(KviKvsObjectFunctionCall *c)
+{
+ if(widget())c->returnValue()->setInteger(widget()->width());
+ return true;
+}
+
+bool KviKvsObject_widget::function_height(KviKvsObjectFunctionCall *c)
+{
+ if(widget())c->returnValue()->setInteger(widget()->height());
+ return true;
+}
+
+bool KviKvsObject_widget::function_setMinimumWidth(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iW;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("w",KVS_PT_INT,0,iW)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) widget()->setMinimumWidth(iW);
+ return true;
+}
+
+bool KviKvsObject_widget::function_setMinimumHeight(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("h",KVS_PT_INT,0,iH)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) widget()->setMinimumHeight(iH);
+ return true;
+}
+
+bool KviKvsObject_widget::function_setMaximumWidth(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iW;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("w",KVS_PT_INT,0,iW)
+ KVSO_PARAMETERS_END(c)
+ if (widget()) widget()->setMaximumWidth(iW);
+ return true;
+}
+
+bool KviKvsObject_widget::function_setMaximumHeight(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("h",KVS_PT_INT,0,iH)
+ KVSO_PARAMETERS_END(c)
+ if(widget()) widget()->setMaximumHeight(iH);
+ return true;
+}
+
+bool KviKvsObject_widget::function_move(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iX,iY;
+
+ KviKvsVariant * pXOrArray;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_or_array",KVS_PT_VARIANT,0,pXOrArray)
+ KVSO_PARAMETER("y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
+ KVSO_PARAMETERS_END(c)
+ if(pXOrArray->isArray())
+ {
+ if(pXOrArray->array()->size() < 2)
+ {
+ c->error(__tr2qs("The array passed as parameter must contain at least 2 elements"));
+ return false;
+ }
+ KviKvsVariant * pX = pXOrArray->array()->at(0);
+ KviKvsVariant * pY = pXOrArray->array()->at(1);
+ if(!(pX && pY))
+ {
+ c->error(__tr2qs("One of the move array parameters is empty"));
+ return false;
+ }
+ if(!(pX->asInteger(iX) && pY->asInteger(iY)))
+ {
+ c->error(__tr2qs("One of the move array parameters didn't evaluate to an integer"));
+ return false;
+ }
+ // ok: the params are correct
+ } else {
+ if(c->params()->count() < 2)
+ {
+ c->error(__tr2qs("$move() requires either an array as first parameter or two integers"));
+ return false;
+ }
+ if(!pXOrArray->asInteger(iX))
+ {
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));
+ return false;
+ }
+ // ok: the params are correct
+ }
+
+ if(!widget())return true;
+ widget()->move(QPoint(iX,iY));
+ return true;
+}
+bool KviKvsObject_widget::function_sizeHint(KviKvsObjectFunctionCall *c)
+{
+ if(!widget())return true;
+ QSize sizehint = widget()->sizeHint();
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)sizehint.width()));
+ a->set(1,new KviKvsVariant((kvs_int_t)sizehint.height()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+bool KviKvsObject_widget::function_resize(KviKvsObjectFunctionCall *c)
+{
+ KviKvsVariant * pWOrArray;
+ kvs_int_t iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("width_or_array",KVS_PT_VARIANT,0,pWOrArray)
+ KVSO_PARAMETER("height",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+ KVSO_PARAMETERS_END(c)
+ if(pWOrArray->isArray())
+ {
+ if(pWOrArray->array()->size() < 2)
+ {
+ c->error(__tr2qs("The array passed as parameter must contain at least 2 elements"));
+ return false;
+ }
+ KviKvsVariant * pW = pWOrArray->array()->at(0);
+ KviKvsVariant * pH = pWOrArray->array()->at(1);
+ if(!(pW && pH))
+ {
+ c->error(__tr2qs("One of the resize array parameters is empty"));
+ return false;
+ }
+ if(!(pW->asInteger(iW) && pH->asInteger(iH)))
+ {
+ c->error(__tr2qs("One of the resize array parameters didn't evaluate to an integer"));
+ return false;
+ }
+ // ok: the params are correct
+ } else {
+ if(c->params()->count() < 2)
+ {
+ c->error(__tr2qs("$resize() requires either an array as first parameter or two integers"));
+ return false;
+ }
+ if(!pWOrArray->asInteger(iW))
+ {
+ c->error(__tr2qs("The first parameter didn't evaluate to an array nor an integer"));
+ return false;
+ }
+ // ok: the params are correct
+ }
+
+ if(!widget())return true;
+ widget()->resize(QSize(iW,iH));
+ return true;
+}
+bool KviKvsObject_widget::function_setFocusPolicy(KviKvsObjectFunctionCall *c)
+{
+ QString szMode;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("focus",KVS_PT_STRING,0,szMode)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ if(KviQString::equalCI(szMode, "TabFocus"))
+ widget()->setFocusPolicy(QT_WIDGET_TABFOCUS);
+ else
+ if(KviQString::equalCI(szMode, "ClickFocus"))
+ widget()->setFocusPolicy(QT_WIDGET_CLICKFOCUS);
+ else
+ if(KviQString::equalCI(szMode, "StrongFocus"))
+ widget()->setFocusPolicy(QT_WIDGET_STRONGFOCUS);
+ else
+ if(KviQString::equalCI(szMode, "NoFocus"))
+ widget()->setFocusPolicy(QT_WIDGET_NOFOCUS);
+ else c->warning(__tr2qs("Invalid parameters"));
+ return true;
+}
+
+bool KviKvsObject_widget::function_setWFlags(KviKvsObjectFunctionCall *c)
+{
+ QStringList wflags;
+ //Qt::WindowType sum;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget_flags",KVS_PT_STRINGLIST,KVS_PF_OPTIONAL,wflags)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ #ifdef COMPILE_USE_QT4
+ Qt::WindowFlags flag,sum=0;
+ #else
+ int flag,sum=0;
+ #endif
+ for ( QStringList::Iterator it = wflags.begin(); it != wflags.end(); ++it )
+ {
+
+ flag=0;
+ for(unsigned int j = 0; j < widgettypes_num; j++)
+ {
+ if(KviQString::equalCI((*it), widgettypes_tbl[j]))
+ {
+ flag=widgettypes_cod[j];
+ break;
+ }
+ }
+ if(flag)
+ sum = sum | flag;
+ else
+ c->warning(__tr2qs("Unknown widget flag '%Q'"),&(*it));
+
+ }
+
+#ifdef COMPILE_USE_QT4
+ widget()->setWindowFlags(sum);
+#else
+ widget()->reparent(widget()->parentWidget(),sum,QPoint(widget()->x(),widget()->y()));
+#endif
+ return true;
+}
+
+bool KviKvsObject_widget::function_setFont(KviKvsObjectFunctionCall *c)
+{
+
+ QString szFamily,szStyle;
+ kvs_int_t uSize;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("size",KVS_PT_UNSIGNEDINTEGER,0,uSize)
+ KVSO_PARAMETER("family",KVS_PT_STRING,0,szFamily)
+ KVSO_PARAMETER("style",KVS_PT_STRING,0,szStyle)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ QFont font=widget()->font();
+ font.setFamily(szFamily);
+ font.setPointSize(uSize);
+ if(KviQString::equalCI(szStyle,"italic")) font.setItalic(TRUE);
+ else if(KviQString::equalCI(szStyle,"bold")) font.setBold(TRUE);
+ else if(KviQString::equalCI(szStyle,"underline"))font.setUnderline(TRUE);
+ else if(KviQString::equalCI(szStyle,"overline")) font.setOverline(TRUE);
+ else if(KviQString::equalCI(szStyle,"strikeout"))font.setStrikeOut(TRUE);
+ else if(KviQString::equalCI(szStyle,"fixedpitch")) font.setFixedPitch(TRUE);
+ else c->warning(__tr2qs("Unknown style '%Q'"),&szStyle);
+ widget()->setFont(font);
+ return true;
+}
+
+bool KviKvsObject_widget::function_addWidgetToWrappedLayout(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_int_t uCol,uRow;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("col",KVS_PT_UNSIGNEDINTEGER,0,uCol)
+ KVSO_PARAMETER("row",KVS_PT_UNSIGNEDINTEGER,0,uRow)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!ob)
+ {
+ c->warning(__tr2qs("Widget parameter is not an object"));
+ return true;
+ }
+ if (!ob->object())
+ {
+ c->warning(__tr2qs("Widget parameter is not a valid object"));
+ return true;
+ }
+ QLayout *lay=widget()->layout();
+ if (!lay)
+ {
+ c->warning(__tr2qs("No Layout associated to the widget "));
+ return true;
+ }
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ lay->add(((QWidget *)(ob->object())));
+ return true;
+}
+bool KviKvsObject_widget::function_reparent(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,KVS_PF_OPTIONAL,hObject)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget()) return true;
+ if(!ob)
+ {
+ widget()->reparent(0,QPoint(widget()->x(),widget()->y()));
+ return true;
+ }
+ else
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr("Parent must be a widget object"));
+ return true;
+ }
+ widget()->reparent(((QWidget *)(ob->object())),QPoint(((QWidget *)(ob->object()))->x(),((QWidget *)(ob->object()))->y()));
+ return true;
+}
+bool KviKvsObject_widget::function_setIcon(KviKvsObjectFunctionCall *c)
+{
+
+ QString icon;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("icon",KVS_PT_STRING,0,icon)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ QPixmap * pix = g_pIconManager->getImage(icon);
+ if(pix)widget()->setIcon(*pix);
+ return true;
+}
+
+bool KviKvsObject_widget::function_setBackgroundImage(KviKvsObjectFunctionCall *c)
+{
+ QString image;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("image",KVS_PT_STRING,0,image)
+ KVSO_PARAMETERS_END(c)
+ if(!widget())return true;
+ QPixmap * pix = g_pIconManager->getImage(image);
+ if(pix)widget()->setPaletteBackgroundPixmap(*pix);
+ return true;
+}
+bool KviKvsObject_widget::function_globalCursorX(KviKvsObjectFunctionCall *c)
+{
+ if(widget())c->returnValue()->setInteger(QCursor::pos().x());
+ return true;
+}
+bool KviKvsObject_widget::function_globalCursorY(KviKvsObjectFunctionCall *c)
+{
+ if(widget())c->returnValue()->setInteger(QCursor::pos().y());
+ return true;
+}
+bool KviKvsObject_widget::function_setMask(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *obj;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("pixmap",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ obj=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if (!obj)
+ {
+ c->warning(__tr2qs("Pixmap parameter is not an object"));
+ return true;
+ }
+ if (!obj->inherits("KviKvsObject_pixmap"))
+ {
+ c->warning(__tr2qs("Pixmap object required"));
+ return true;
+ }
+ QPixmap * pm=((KviKvsObject_pixmap *)obj)->getPixmap();
+#ifdef COMPILE_USE_QT4
+ QBitmap mask(pm->mask());
+#else
+ QBitmap mask(*pm->mask());
+#endif
+ if (mask.isNull()) c->warning(__tr2qs("Null mask"));
+ widget()->setMask(mask);
+ return true;
+}
+#ifdef COMPILE_USE_QT4
+bool KviKvsObject_widget::function_setAttribute(KviKvsObjectFunctionCall *c)
+{
+ QString attribute;
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget_atribute",KVS_PT_STRING,0,attribute)
+ KVSO_PARAMETER("bool_flag",KVS_PT_BOOLEAN,0,bFlag)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ bool found=false;
+ unsigned int j = 0;
+ for(; j < widgetattributes_num; j++)
+ {
+ if(KviQString::equalCI(attribute, widgetattributes_tbl[j]))
+ {
+ found=true;
+ break;
+ }
+ }
+ if(found)widget()->setAttribute(widgetattributes_cod[j],bFlag);
+ else c->warning(__tr2qs("Unknown widget attribute '%Q'"),&attribute);
+ return true;
+}
+#endif
+
+#include "m_class_widget.moc"
diff --git a/src/modules/objects/class_widget.h b/src/modules/objects/class_widget.h
new file mode 100644
index 00000000..ecd87bba
--- /dev/null
+++ b/src/modules/objects/class_widget.h
@@ -0,0 +1,113 @@
+#ifndef _CLASS_WIDGET_H_
+#define _CLASS_WIDGET_H_
+//vim: ts=8
+// File : class_widget.h
+// Creation date : Mon 11 Sep 16:34:36 CET 2000 by Krzysztof Godlewski
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include <kvi_tal_tooltip.h>
+#include "kvi_string.h"
+#include "qtooltip.h"
+#include "object_macros.h"
+
+
+class KviKvsObject_widget : public KviKvsObject
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_widget)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ virtual bool eventFilter(QObject *o,QEvent *e);
+
+ // ok, it is clear that we're messing with the naming conventions for the
+ // object classes :D
+ // let's try to use this one:
+ // function_isEnabled
+ // function_setEnabled..
+ // ... etc
+ // so the name of the C++ function matches exactly the name of the KVS function at this point
+
+ // let's also try to keep alphabetic order for the functions here.. so one can find them quickly
+
+ bool function_addWidgetToWrappedLayout(KviKvsObjectFunctionCall *c);
+ bool function_backgroundColor(KviKvsObjectFunctionCall *c);
+ bool function_caption(KviKvsObjectFunctionCall *c);
+ bool function_centerToScreen(KviKvsObjectFunctionCall *c);
+ bool function_fontAscent(KviKvsObjectFunctionCall * c);
+ bool function_fontDescent(KviKvsObjectFunctionCall * c);
+ bool function_fontMetricsHeight(KviKvsObjectFunctionCall * c);
+ bool function_fontMetricsWidth(KviKvsObjectFunctionCall * c);
+ bool function_foregroundColor(KviKvsObjectFunctionCall *c);
+ bool function_geometry(KviKvsObjectFunctionCall *c);
+ bool function_globalCursorX(KviKvsObjectFunctionCall *c);
+ bool function_globalCursorY(KviKvsObjectFunctionCall *c);
+ bool function_hasFocus(KviKvsObjectFunctionCall *c);
+ bool function_height(KviKvsObjectFunctionCall *);
+ bool function_hide(KviKvsObjectFunctionCall *);
+ bool function_isEnabled(KviKvsObjectFunctionCall *c);
+ bool function_isTopLevel(KviKvsObjectFunctionCall *c);
+ bool function_isVisible(KviKvsObjectFunctionCall *c);
+ bool function_lower(KviKvsObjectFunctionCall *);
+ bool function_mapFromGlobal(KviKvsObjectFunctionCall *c);
+ bool function_mapToGlobal(KviKvsObjectFunctionCall *c);
+ bool function_move(KviKvsObjectFunctionCall *c);
+ bool function_parentWidget(KviKvsObjectFunctionCall *c);
+ bool function_raise(KviKvsObjectFunctionCall *);
+ bool function_repaint(KviKvsObjectFunctionCall *c);
+ bool function_reparent(KviKvsObjectFunctionCall *c);
+ bool function_resize(KviKvsObjectFunctionCall *c);
+ bool function_screenResolution(KviKvsObjectFunctionCall * c);
+ bool function_setBackgroundColor(KviKvsObjectFunctionCall *c);
+ bool function_setBackgroundImage(KviKvsObjectFunctionCall *c);
+ bool function_setCaption(KviKvsObjectFunctionCall *c);
+ bool function_setEnabled(KviKvsObjectFunctionCall *c);
+ bool function_setFocus(KviKvsObjectFunctionCall *c);
+ bool function_setFocusPolicy(KviKvsObjectFunctionCall *c);
+ bool function_setFont(KviKvsObjectFunctionCall *c);
+ bool function_setIcon(KviKvsObjectFunctionCall *c);
+ bool function_setMaximumWidth(KviKvsObjectFunctionCall *c);
+ bool function_setMaximumHeight(KviKvsObjectFunctionCall *c);
+ bool function_setMinimumWidth(KviKvsObjectFunctionCall *c);
+ bool function_setMinimumHeight(KviKvsObjectFunctionCall *c);
+ bool function_setMouseTracking(KviKvsObjectFunctionCall *c);
+ bool function_setPaletteForeground(KviKvsObjectFunctionCall *c);
+ bool function_setToolTip(KviKvsObjectFunctionCall *);
+ bool function_setGeometry(KviKvsObjectFunctionCall *c);
+ bool function_setWFlags(KviKvsObjectFunctionCall *c);
+ bool function_show(KviKvsObjectFunctionCall *c);
+ bool function_sizeHint(KviKvsObjectFunctionCall *c);
+ bool function_width(KviKvsObjectFunctionCall *);
+ bool function_x(KviKvsObjectFunctionCall *);
+ bool function_y(KviKvsObjectFunctionCall *);
+ bool function_setMask(KviKvsObjectFunctionCall *c);
+
+
+#ifdef COMPILE_USE_QT4
+bool function_setAttribute(KviKvsObjectFunctionCall *c);
+#endif
+
+signals:
+ void aboutToDie();
+};
+
+#endif // !_CLASS_WIDGET_H_
diff --git a/src/modules/objects/class_window.cpp b/src/modules/objects/class_window.cpp
new file mode 100644
index 00000000..9218cb8f
--- /dev/null
+++ b/src/modules/objects/class_window.cpp
@@ -0,0 +1,158 @@
+//
+// File : class_window.cpp
+// Creation date : Tue Now 26 21:39:59 CEST 2002 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include "class_window.h"
+
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_frame.h"
+
+
+
+KviKvsScriptWindowWindow::KviKvsScriptWindowWindow(KviFrame * pParent,const QString &szName)
+: KviWindow(KVI_WINDOW_TYPE_SCRIPTOBJECT,pParent,szName)
+{
+ m_pCentralWidget = 0;
+ #ifdef COMPILE_USE_QT4
+ setBackgroundMode(Qt::NoBackground);
+ #else
+ setBackgroundMode(QWidget::NoBackground);
+ #endif
+}
+
+KviKvsScriptWindowWindow::~KviKvsScriptWindowWindow()
+{
+}
+
+void KviKvsScriptWindowWindow::setCentralWidget(KviKvsObject_widget *o,QWidget * w)
+{
+ m_pCentralWidgetObject = o;
+ m_pCentralWidget = w;
+}
+
+void KviKvsScriptWindowWindow::resizeEvent(QResizeEvent *e)
+{
+ if(m_pCentralWidget)
+ m_pCentralWidget->setGeometry(0,0,width(),height());
+}
+
+void KviKvsScriptWindowWindow::centralWidgetObjectDestroyed()
+{
+ m_pCentralWidget = 0;
+ m_pCentralWidgetObject = 0;
+}
+
+void KviKvsScriptWindowWindow::centralWidgetDestroyed()
+{
+ m_pCentralWidget = 0;
+ m_pCentralWidgetObject = 0;
+}
+
+
+
+
+/*
+ @doc: window
+ @title:
+ window class
+ @type:
+ class
+ @short:
+ A MDI window object
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This class rappresents a MDI window in a KVIrc frame.
+ Regardless of the parent object passed, the window will be always
+ a "physical" child of the frame window: you can't embed a window object
+ inside a widget or another window. The parent object will just "own" this
+ window object and eventually destroy it when it dies.
+ This class can manage only a single central child widget that must
+ be set with $setCentralWidget().
+ The central widget MUST be set before you initially call show()
+ @functions:
+*/
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_window,"window","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_window,"setCaption", functionsetCaption)
+ KVSO_REGISTER_HANDLER(KviKvsObject_window,"setCentralWidget", functionsetCentralWidget)
+// KVSO_REGISTER_HANDLER(KviKvsObject_window,"setIcon", functionsetIcon)
+KVSO_END_REGISTERCLASS(KviKvsObject_window)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_window,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_window)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_window)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_window)
+
+bool KviKvsObject_window::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ KviWindow * w = new KviKvsScriptWindowWindow(pContext->window()->frame(),name());
+ setObject(w);
+ pContext->window()->frame()->addWindow(w,false);
+ w->minimize(); // must be minimized before children are added, otherwise the focus handling goes nuts...
+
+ return true;
+}
+bool KviKvsObject_window::functionsetCaption(KviKvsObjectFunctionCall *c)
+{
+ QString szCaption;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("caption",KVS_PT_STRING,0,szCaption)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((KviKvsScriptWindowWindow *)widget())->setCaptionString(szCaption);
+ return true;
+}
+bool KviKvsObject_window::functionsetCentralWidget(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ if(!ob->inherits("KviKvsObject_widget"))
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ ((KviKvsScriptWindowWindow *)widget())->setCentralWidget((KviKvsObject_widget *)ob,((KviKvsObject_widget *)ob)->widget());
+ return true;
+}
+#include "m_class_window.moc"
diff --git a/src/modules/objects/class_window.h b/src/modules/objects/class_window.h
new file mode 100644
index 00000000..1f2ae482
--- /dev/null
+++ b/src/modules/objects/class_window.h
@@ -0,0 +1,64 @@
+#ifndef _CLASS_WINDOW_H_
+#define _CLASS_WINDOW_H_
+//
+// File : class_window.h
+// Creation date : Tue Nov 26 21:37:48 CEST 2002 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_widget.h"
+#include "kvi_window.h"
+
+#include "object_macros.h"
+
+class KviKvsObject_window : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_window)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionsetCaption(KviKvsObjectFunctionCall *c);
+ bool functionsetCentralWidget(KviKvsObjectFunctionCall *c);
+
+};
+
+
+class KviKvsScriptWindowWindow : public KviWindow
+{
+ Q_OBJECT
+public:
+ KviKvsScriptWindowWindow(KviFrame * pParent,const QString &szName);
+ ~KviKvsScriptWindowWindow();
+protected:
+ KviKvsObject_widget * m_pCentralWidgetObject;
+ QWidget * m_pCentralWidget;
+public:
+ void setCentralWidget(KviKvsObject_widget *o,QWidget * w);
+ void setCaptionString(const QString &s){ setFixedCaption(s); };
+ virtual void resizeEvent(QResizeEvent *e);
+protected slots:
+ void centralWidgetObjectDestroyed();
+ void centralWidgetDestroyed();
+};
+
+#endif // !_CLASS_WINDOW_H_
diff --git a/src/modules/objects/class_wizard.cpp b/src/modules/objects/class_wizard.cpp
new file mode 100644
index 00000000..091b3065
--- /dev/null
+++ b/src/modules/objects/class_wizard.cpp
@@ -0,0 +1,371 @@
+//mdm:
+// File : class_wizard.cpp
+// Creation date : Mon Apr 10 19:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include <kvi_tal_wizard.h>
+#include <qpushbutton.h>
+#include "class_wizard.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+
+
+
+/*
+ @doc: wizard
+ @keyterms:
+ wizard object class,
+ @title:
+ wizard class
+ @type:
+ class
+ @short:
+ The wizard class provides a framework for wizard dialogs.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ A wizard is an input dialog that consists of a sequence of dialog pages.It walks the user through a process step by step.[br]
+ @functions:
+ !fn: $addPage(<page_widget:object>,<title:string>)
+ Add a page with title.<page_widget> must be a widget's object.
+ !fn: $insertPage(<page_widget>,<title:string>,<index:integer>)
+ Inserts a page at the position <index>. If index is -1, page will appended to the end of the wizard's page sequenze.
+ !fn: $setTitle(<page>,<title:string>)
+ Sets the title for page page to title text.
+ !fn: $setBackEnabled(<page_widget>,<bEnabled:boolean>)
+ If enable is set to 1, page page has a Back button; otherwise page has no Back button.[br]
+ By default all pages have this button.
+ !fn: $setNextEnabled(<page_widget>,<bEnabled:boolean>)
+ If enable is set to 1, page page has a Next button; otherwise the Next button on page is disabled.[br]
+ By default all pages have this button.
+ !fn: $setFinishEnabled(<page_widget>,<bEnabled:boolean>)
+ If enable is set to 1, page page has a Finish button; otherwise the Finish button on page is disabled.[br]
+ By default NO pages have this button.
+ !fn: $setHelpEnabled(<page_widget>,<bEnabled:boolean>)
+ If enable is set to 1, page page has a Help button; otherwise the Help button on page is disabled.[br]
+ By default all pages have this button.
+ !fn: $setNextBtnText(<text:string>)
+ Set the text for button Next.
+ !fn: $setBackBtnText(<text:string>)
+ Set the text for button Back.
+ !fn: $setFinishBtnText(<text:string>)
+ Set the text for button Finish.
+ !fn: $setHelpBtnText(<text:string>)
+ Set the text for button Help.
+ !fn: $acceptEvent()
+ This function is called when the user click on the Finish button.
+ !fn: $rejectEvent()
+ This function is called when thie user click on the Reject button.
+ !fn: $nextClickedEvent()
+ This function is called when the user click on the Next button.
+ !fn: $backClickedEvent()
+ This function is called when thie user click on the Back button.
+ @signals:
+ !sg: $nextClicked()
+ This signal is emitted by the default implementation of [classfnc]$nextClickedEvent[/classfnc]().
+ !sg: $backClicked()
+ This signal is emitted by the default implementation of [classfnc]$backClickedEvent[/classfnc]().
+
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_wizard,"wizard","widget")
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"addPage", functionaddPage)
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"insertPage", functioninsertPage)
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setTitle", functionsetTitle)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setBackEnabled", functionsetBackEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setNextEnabled", functionsetNextEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setFinishEnabled", functionsetFinishEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setHelpEnabled", functionsetHelpEnabled);
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setBackBtnText", functionsetBackBtnText);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setNextBtnText", functionsetNextBtnText);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setFinishBtnText", functionsetFinishBtnText);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"setHelpBtnText", functionsetHelpBtnText);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"nextClickedEvent", functionnextClickedEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_wizard,"backClickedEvent", functionbackClickedEvent);
+
+
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_wizard,"acceptEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_wizard,"rejectEvent")
+
+KVSO_END_REGISTERCLASS(KviKvsObject_wizard)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_wizard,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_wizard)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_wizard)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_wizard)
+
+bool KviKvsObject_wizard::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new KviKvsMdmWizard(parentScriptWidget(), name(),this), true);
+
+ return true;
+}
+bool KviKvsObject_wizard::functionaddPage(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szLabel;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ ((KviTalWizard *)widget())->addPage(((QWidget *)(ob->object())),szLabel);
+ return true;
+}
+bool KviKvsObject_wizard::functioninsertPage(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szLabel;
+ kvs_int_t uIndex;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Can't add a non-widget object"));
+ return true;
+ }
+ ((KviTalWizard *)widget())->insertPage(((QWidget *)(ob->object())),szLabel,uIndex);
+ return true;
+}
+
+
+bool KviKvsObject_wizard::functionsetTitle(KviKvsObjectFunctionCall *c)
+{
+ KviKvsObject *ob;
+ QString szTitle;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("title",KVS_PT_STRING,0,szTitle)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return true;
+ }
+ ((KviTalWizard *)widget())->setPageTitle(((QWidget *)(ob->object())),szTitle);
+ return true;
+}
+bool KviKvsObject_wizard::functionsetBackEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return true;
+ }
+ ((KviTalWizard *)widget())->setBackEnabled(((QWidget *)(ob->object())),bEnabled);
+ return true;
+}
+
+bool KviKvsObject_wizard::functionsetNextEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return true;
+ }
+ ((KviTalWizard *)widget())->setNextEnabled(((QWidget *)(ob->object())),bEnabled);
+ return true;
+}
+bool KviKvsObject_wizard::functionsetFinishEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return true;
+ }
+ ((KviTalWizard *)widget())->setFinishEnabled(((QWidget *)(ob->object())),bEnabled);
+ return true;
+}
+bool KviKvsObject_wizard::functionsetHelpEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KviKvsObject *ob;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if(!widget())return true;
+ if(!ob->object()->isWidgetType())
+ {
+ c->warning(__tr2qs("Widget object required"));
+ return true;
+ }
+ ((KviTalWizard *)widget())->setHelpEnabled(((QWidget *)(ob->object())),bEnabled);
+ return true;
+}
+bool KviKvsObject_wizard::functionsetBackBtnText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalWizard *)widget())->KviTalWizard::backButton()->setText(szText);
+ return true;
+}
+bool KviKvsObject_wizard::functionsetNextBtnText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalWizard *)widget())->KviTalWizard::nextButton()->setText(szText);
+ return true;
+}
+bool KviKvsObject_wizard::functionsetHelpBtnText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalWizard *)widget())->KviTalWizard::helpButton()->setText(szText);
+ return true;
+}
+bool KviKvsObject_wizard::functionsetFinishBtnText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (widget())
+ ((KviTalWizard *)widget())->KviTalWizard::finishButton()->setText(szText);
+ return true;
+}
+bool KviKvsObject_wizard::accept()
+{
+ KviKvsVariantList * pParams = 0;
+ callFunction(this,"acceptEvent",0,pParams);
+ return true;
+}
+bool KviKvsObject_wizard::reject()
+{
+ KviKvsVariantList * pParams = 0;
+ callFunction(this,"rejectEvent",0,pParams);
+ return true;
+}
+bool KviKvsObject_wizard::functionnextClickedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("nextClicked",c);
+ return true;
+}
+
+void KviKvsObject_wizard::nextClicked()
+{
+ KviKvsVariantList *params=0;
+ callFunction(this,"nextClickedEvent",params);
+}
+bool KviKvsObject_wizard::functionbackClickedEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("backClicked",c);
+ return true;
+}
+
+void KviKvsObject_wizard::backClicked()
+{
+ KviKvsVariantList *params=0;
+ callFunction(this,"backClickedEvent",params);
+}
+KviKvsMdmWizard::KviKvsMdmWizard(QWidget * par,const char * name,KviKvsObject_wizard * parent)
+:KviTalWizard(par)
+{
+ m_pParentScript=parent;
+ connect (this->backButton(),SIGNAL(clicked()),this,SLOT(slotBackClicked()));
+ connect (this->nextButton(),SIGNAL(clicked()),this,SLOT(slotNextClicked()));
+}
+void KviKvsMdmWizard::accept()
+{
+ if(m_pParentScript->accept())KviTalWizard::accept();
+
+}
+void KviKvsMdmWizard::reject()
+{
+ if(m_pParentScript->reject())KviTalWizard::reject();
+
+}
+void KviKvsMdmWizard::slotNextClicked()
+{
+ m_pParentScript->nextClicked();
+}
+void KviKvsMdmWizard::slotBackClicked()
+{
+ m_pParentScript->backClicked();
+}
+KviKvsMdmWizard::~KviKvsMdmWizard()
+{
+}
+#include "m_class_wizard.moc"
diff --git a/src/modules/objects/class_wizard.h b/src/modules/objects/class_wizard.h
new file mode 100644
index 00000000..0c605efe
--- /dev/null
+++ b/src/modules/objects/class_wizard.h
@@ -0,0 +1,79 @@
+#ifndef _CLASS_WIZARD_H_
+#define _CLASS_WIZARD_H_
+//
+// File : class_wizard.h
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+#include <kvi_tal_wizard.h>
+#include "class_widget.h"
+
+
+#include "object_macros.h"
+
+class KviKvsObject_wizard : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_wizard)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+ bool accept();
+ bool reject();
+ void nextClicked();
+ void backClicked();
+
+
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionaddPage(KviKvsObjectFunctionCall *c);
+ bool functioninsertPage(KviKvsObjectFunctionCall *c);
+ bool functionremovePage(KviKvsObjectFunctionCall *c);
+ bool functionsetTitle(KviKvsObjectFunctionCall *c);
+ bool functionsetBackEnabled(KviKvsObjectFunctionCall *c);
+ bool functionsetNextEnabled(KviKvsObjectFunctionCall *c);
+ bool functionsetFinishEnabled(KviKvsObjectFunctionCall *c);
+ bool functionsetHelpEnabled(KviKvsObjectFunctionCall *c);
+
+ bool functionsetBackBtnText(KviKvsObjectFunctionCall *c);
+ bool functionsetNextBtnText(KviKvsObjectFunctionCall *c);
+ bool functionsetFinishBtnText(KviKvsObjectFunctionCall *c);
+ bool functionsetHelpBtnText(KviKvsObjectFunctionCall *c);
+
+ bool functionnextClickedEvent(KviKvsObjectFunctionCall *c);
+ bool functionbackClickedEvent(KviKvsObjectFunctionCall *c);
+
+};
+class KviKvsMdmWizard : public KviTalWizard
+
+{
+ Q_OBJECT
+public:
+ KviKvsMdmWizard(QWidget * par,const char * name,KviKvsObject_wizard *);
+ void accept();
+ void reject();
+ virtual ~KviKvsMdmWizard();
+protected:
+ KviKvsObject_wizard *m_pParentScript;
+protected slots:
+ void slotNextClicked();
+ void slotBackClicked();
+};
+#endif //!_CLASS_WIZARD_H_
diff --git a/src/modules/objects/class_workspace.cpp b/src/modules/objects/class_workspace.cpp
new file mode 100644
index 00000000..1f6d8a3e
--- /dev/null
+++ b/src/modules/objects/class_workspace.cpp
@@ -0,0 +1,262 @@
+//mdm:
+// File : class_workspace.cpp
+// Creation date : Sat Feb 12 23:01:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor).
+// Thanks to Lucia Papini (^ashura^) for English help.
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+#include <qworkspace.h>
+#include "class_workspace.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+/*
+ @doc: workspace
+ @keyterms:
+ workspace object class,
+ @title:
+ workspace class
+ @type:
+ class
+ @short:
+ Provides a MDI workspace object
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This widget provides a workspace window that can contain decorated window.
+ @functions:
+ !fn: <object> $activeWindow()
+ Returns the active window, or 0 if no window is active.
+ !fn: <boolean> $scrollBarsEnabled()
+ Returns TRUE if the workspace provides scrollbars; otherwise returns FALSE.
+ !fn: $setscrollBarsEnabled(<bEnabled:boolean>)
+ Sets whether the workspace provides scrollbars to enable. (bEnabled 1 or 0)
+ !fn: $cascade()
+ Arranges all the child windows in a cascade pattern.
+ !fn: $tile()
+ Arranges all child windows in a tile pattern.
+ !fn: $closeActiveWindow()
+ Closes the child window that is currently active.
+ !fn: $closeAllWindows()
+ Closes all child windows.
+ !fn: $activateNextWindow()
+ Activates the next window in the child window chain.
+ !fn: $activatePrevWindow()
+ Activates the prev window in the child window chain.[br]
+
+ |----CLASS EXAMPLE----|[br]
+ |-Start:[br]
+ #Let's start.[br]
+ #We start the main class creation, in the constructor we do the[br]
+ #widget's showing, to give a particular pop-up[br]
+ #creation appearance.[br]
+ class (ws,widget)[br]
+ {[br]
+ constructor[br]
+ {[br]
+ $$->$setGeometry(%X,%Y,100,100)[br]
+ $$->%label=$new(label,$$)[br]
+ $$->%label->$settext("Another class by N\&G")[br]
+ $$->%label->$setautoresize(1)[br]
+ $$->$show()[br]
+ }[br]
+ }[br]
+ #We create the new workspace, and we set a 640x480 size with widget $resize[br]
+ #command.[br]
+ %Workspace=$new(workspace)[br]
+ %Workspace->$resize(640,480)[br]
+ #Now we make a cycling costruction of the widgets(look at the class),[br]
+ #and give to the widgets a random X and Y coordinates.[br]
+ #It takes few seconds to show the effects, be patient.[br]
+ %I=0[br]
+ while (%I<100)[br]
+ {[br]
+ %X=$rand(500)[br]
+ %Y=$rand(480)[br]
+ %Widget=$new(ws,%Workspace)[br]
+ %I++[br]
+ }[br]
+ #Let's show the fireworks! EnJoY![br]
+ %Workspace->$show()[br]
+ |-Start:[br]
+ |-|EXAMPLE n2:[br]
+ #This is like the first example but it has a particular animation effect.[br]
+ %Hex[]=$array(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)[br]
+ class (ws,widget)[br]
+ {[br]
+ constructor[br]
+ {[br]
+ $$->$setGeometry(%X,%Y,100,100)[br]
+ $$->%lay=$new(layout,$$)[br]
+ %i=0[br]
+ while (%i<10)[br]
+ {[br]
+ $$->%label=$new(label,$$)[br]
+ $$->%label->$settext("Another class by N\&G")[br]
+ %color=%Hex[$rand(15)]%Hex[$rand(15)]%Hex[$rand(15)]%Hex[$rand(15)]%Hex[$rand(15)]%Hex[$rand(15)][br]
+ $$->%label->$setforegroundcolor(%color)[br]
+ $$->%label->$setautoresize(1)[br]
+ $$->%lay->$addwidget($$->%label,%i,0)[br]
+ %i++;[br]
+ }[br]
+ $$->$show()[br]
+ }[br]
+ mousepressevent[br]
+ {[br]
+ if ($istimer(cycle) == 1) killtimer cycle[br]
+ }[br]
+ }[br]
+ %Workspace=$new(workspace)[br]
+ %Workspace->$resize(640,480)[br]
+ %Workspace->$setCaption("Hit the mouse to stop cycling windows....")[br]
+ %I=0[br]
+ %Cicle=1[br]
+ while (%I<20)[br]
+ {[br]
+ %X=$rand(500)[br]
+ %Y=$rand(480)[br]
+ %Widget=$new(ws,%Workspace)[br]
+ %I++[br]
+ }[br]
+ %Workspace->$show[br]
+ timer (cycle,3000)[br]
+ {[br]
+ if (%Cicle==1) %Workspace->$tile()[br]
+ if (%Cicle==2)[br]
+ {[br]
+ %Workspace->$cascade()[br]
+ %Cicle=1[br]
+ return[br]
+ }[br]
+ %Cicle++[br]
+ }[br]
+ privateimpl(%Workspace,mousepressevent)[br]
+ {[br]
+ if ($istimer(cycle) == 1) killtimer cycle[br]
+ }[br]
+ #-|End.[br]
+
+*/
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_workspace,"workspace","widget")
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"activeWindow", functionactiveWindow);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"scrollBarsEnabled", functionscrollBarsEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"setscrollBarsEnabled", functionsetscrollBarsEnabled);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"cascade", functioncascade);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"tile", functiontile);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"closeActiveWindow", functioncloseActiveWindow);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"closeAllWindows", functioncloseAllWindows);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"activateNextWindow", functionactivateNextWindow);
+ KVSO_REGISTER_HANDLER(KviKvsObject_workspace,"activatePrevWindow", functionactivatePrevWindow);
+KVSO_END_REGISTERCLASS(KviKvsObject_workspace)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_workspace,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_workspace)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_workspace)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_workspace)
+
+bool KviKvsObject_workspace::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ setObject(new QWorkspace(parentScriptWidget(), name()), true);
+ return true;
+}
+
+bool KviKvsObject_workspace::functionactiveWindow(KviKvsObjectFunctionCall *c)
+{
+ //if(widget()) c->returnValue()->setHObject((unsigned long)(((QWorkspace *)widget())->activeWindow()));
+ // FIXME!
+ c->returnValue()->setHObject(0);
+ return true; //?pFIX ME?
+}
+
+bool KviKvsObject_workspace::functionscrollBarsEnabled(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ c->returnValue()->setBoolean(((QWorkspace *)widget())->scrollBarsEnabled());
+ return true;
+}
+
+bool KviKvsObject_workspace::functionsetscrollBarsEnabled(KviKvsObjectFunctionCall *c)
+{
+ bool bEnabled;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ ((QWorkspace *)widget())->setScrollBarsEnabled(bEnabled);
+ return true;
+}
+
+bool KviKvsObject_workspace::functioncascade(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QWorkspace *)widget())->cascade();
+ return true;
+}
+
+bool KviKvsObject_workspace::functiontile(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QWorkspace *)widget())->tile();
+ return true;
+}
+
+bool KviKvsObject_workspace::functioncloseActiveWindow(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QWorkspace *)widget())->closeActiveWindow();
+ return true;
+}
+
+bool KviKvsObject_workspace::functioncloseAllWindows(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QWorkspace *)widget())->closeAllWindows();
+ return true;
+}
+
+bool KviKvsObject_workspace::functionactivateNextWindow(KviKvsObjectFunctionCall *c)
+{
+ if(widget())
+ ((QWorkspace *)widget())->activateNextWindow();
+ return true;
+}
+
+bool KviKvsObject_workspace::functionactivatePrevWindow(KviKvsObjectFunctionCall *c)
+{
+ if(widget()){
+ #ifdef COMPILE_USE_QT4
+ ((QWorkspace *)widget())->activatePreviousWindow();
+ #else
+ ((QWorkspace *)widget())->activatePrevWindow();
+ #endif
+ }
+ return true;
+}
diff --git a/src/modules/objects/class_workspace.h b/src/modules/objects/class_workspace.h
new file mode 100644
index 00000000..c18264df
--- /dev/null
+++ b/src/modules/objects/class_workspace.h
@@ -0,0 +1,53 @@
+#ifndef _CLASS_WORKSPACE_H_
+#define _CLASS_WORKSPACE_H_
+//mdm:
+// File : class_workspace.h
+// Creation date : Sat Feb 12 23:05:58 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+
+#include <qworkspace.h>
+#include "class_widget.h"
+
+class KviKvsObject_workspace : public KviKvsObject_widget
+{
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_workspace)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+
+ bool functionactiveWindow(KviKvsObjectFunctionCall *c);
+ bool functionscrollBarsEnabled(KviKvsObjectFunctionCall *c);
+ bool functionsetscrollBarsEnabled(KviKvsObjectFunctionCall *c);
+ bool functioncascade(KviKvsObjectFunctionCall *c);
+ bool functiontile(KviKvsObjectFunctionCall *c);
+ bool functioncloseActiveWindow(KviKvsObjectFunctionCall *c);
+ bool functioncloseAllWindows(KviKvsObjectFunctionCall *c);
+ bool functionactivateNextWindow(KviKvsObjectFunctionCall *c);
+ bool functionactivatePrevWindow(KviKvsObjectFunctionCall *c);
+};
+
+#endif //!_CLASS_WORKSPACE_H_
diff --git a/src/modules/objects/class_wrapper.cpp b/src/modules/objects/class_wrapper.cpp
new file mode 100644
index 00000000..02ff632c
--- /dev/null
+++ b/src/modules/objects/class_wrapper.cpp
@@ -0,0 +1,269 @@
+//mdm:
+// File : class_wrapper.cpp
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "class_wrapper.h"
+#include "kvi_error.h"
+#include "kvi_debug.h"
+
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+#include "class_widget.h"
+#include <qwidget.h>
+#ifndef COMPILE_USE_QT4
+ #include <qobjectlist.h>
+ #include <qwidgetlist.h>
+#endif
+#include "kvi_app.h"
+#include "kvi_frame.h"
+
+
+/*
+ @doc: wrapper
+ @keyterms:
+ wrapper object class,
+ @title:
+ wrapper class
+ @type:
+ class
+ @short:
+ Provides a wrapper class that hooks to an existing Qt graphic object modifying it.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This is a class for advanced KVIrc scripting.[br]
+ It can wrap any existing KVIrc widget.[br]
+ This class allows some unbelievable changes to the whole graphic environment of the kvirc,[br]
+ in fact, could hook every widget, you can modify the property or you can be inserted other widget as child of this...[br]
+ in short you have absolute liberty. [br]
+ The power of this class is fantastic, because it allows the change at "run time" of almost all the elements of the Kvirc.[br]
+ But to use this class in optimal way and to exploit its power, you have to know the Qt.... so you won't have limits [br]
+ The KVIrc Qt widgets are arranged in trees (just as the objects).[br]
+ The difference is that there are more toplevel widgets (and so more than one tree).[br]
+ You can use [fnc]$objects.dump()[/fnc] to take a look at the KVIrc Qt objects tree.[br]
+ Here is a part of the tree:[br][br]
+ Ptr 14332520: top level object: kvirc_frame, class KviFrame, visible, rect = -4, -4, 1024, 708
+ Ptr 17296024: object: qt_top_dock, class QDockArea
+ Ptr 14882136: object: qt_custom_toolbar, class KviCustomToolBar
+ Ptr 18143368: object: qt_dockwidget_internal, class QDockWindowTitleBar
+ [br][br]
+ Every listed widget has a "name", a "class" and a set of properties.[br]
+ The first entry in this example is a KVIrc server window, class "KviFrame" and name "kvirc_frame":
+ it is a toplevel widget.[br]
+ The "qt_top_dock", "qt_custom_toolbar" and the "qt_dockwidget_internal" are
+ direct children of that widget.[br]
+ To indicate a specific widget we will use the "class::name" form.[br]
+ So to indicate the main KVIrc frame you will use "KviFrame::kvirc_main_frame".
+ Look at this example:[br]
+ %A=$new(wrapper,0,test,KviFrame::kvirc_frame,KviStatusBar::unnamed)[br]
+ %A->$setBackGroundColor(FFFFFF)[br]
+ For first thing we create an object type wrapper,then we flow the tree that there from the command /object.dump and we will have:[br]
+ . [br]
+ . [br]
+ Ptr 14196288: top level object: kvirc_frame, class KviFrame, visible, rect = -4, -4, 1024, 712 [br]
+. [br]
+ Ptr 17197360: object: unnamed, class KviStatusBar [br]
+ . [br]
+ . [br]
+ in this way we can follow the order, father->child from the top-level widget(KviFrame::kvirc_frame)[br]
+ to reach the child that interests us (KviStatusBar::unnamed)[br]
+ Then, following the syntax we will have:
+ %A=$new(wrapper,0,test,KviFrame::kvirc_frame,KviStatusBar::unnamed)
+ Now %A. will be point to the wrapped object, therefore we could modify its property or to consider it as if it were an object created by us in scripting. [br]
+ Obviously, deleting the created object (for example %A) you don't will delete the object of Kvirc (in this case the statusbar). [br]
+ Another example could be this:[br]
+ %A=$new(wrapper,0,test,KviFrame::kvirc_frame,QToolButton::kvirc.identityoptions)[br]
+ %A->$setProperty(usesBigPixmap,0)[br]
+ In this fool example with the function $setProperty, we has setted the property usesBigPixmap to False, making to become the small icons of the ToolBar.[br]
+ [br]
+ The wrapping object search can optionally start with a window
+ identifier with the following syntax: WinId::<window_id>.
+
+*/
+
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_wrapper,"wrapper","widget")
+
+KVSO_END_REGISTERCLASS(KviKvsObject_wrapper)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_wrapper,KviKvsObject_widget)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_wrapper)
+
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_wrapper)
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_wrapper)
+
+bool KviKvsObject_wrapper::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams)
+{
+ if( !pParams ) return false;
+
+ debug ("ci sono i parametri");
+ QWidget *pWidget = 0;
+ int i=0;
+ while(i!=pParams->count())
+ {
+ QString szClass;
+ QString szName;
+ QString s=0;
+ pParams->at(i)->asString(s);
+ if (!s.isEmpty())
+ {
+ int idx = s.find("::");
+ if( idx != -1 ) {
+ szClass = s.left(idx);
+ szName = s.right(s.length() - idx - 2);
+ } else {
+ szClass = s;
+ szName = "";
+ }
+ debug ("szClass %s",szClass.latin1());
+ debug ("szName %s",szName.latin1());
+ debug ("s %s",s.latin1());
+
+ if(KviQString::equalCI(szClass,"WinId"))
+ {
+ if(pWidget)
+ {
+ pContext->warning(__tr2qs("The window identifier preceeded by WinId must be the first object in the search path"));
+ return false;
+ } else {
+ pWidget = g_pApp->findWindow(szName);
+ }
+ } else {
+ if(pWidget) {
+ pWidget = findWidgetToWrap(
+ !szClass.isEmpty() ? szClass : KviQString::empty, !szName.isEmpty() ? szName : KviQString::empty, pWidget
+ );
+ } else {
+ pWidget = findTopLevelWidgetToWrap(szClass.isEmpty() ? szClass : KviQString::empty, !szName.isEmpty() ? szName : KviQString::empty);
+ }
+ }
+ if( !pWidget )
+ {
+ pContext->warning(__tr2qs("Failed to find one of the wrap path widgets (%Q::%Q)"),&szClass,&szName);
+ return false;
+ }
+ }
+ i++;
+
+ }
+ if( !pWidget )
+ {
+ pContext->warning(__tr2qs("Failed to find the widget to wrap"));
+ return false;
+ }
+ setObject(pWidget,false);
+
+ return true;
+}
+QWidget *KviKvsObject_wrapper::findTopLevelWidgetToWrap(const QString szClass, const QString szName)
+{
+#ifdef COMPILE_USE_QT4
+ QWidgetList list = g_pApp->topLevelWidgets();
+ if( !list.count() ) return 0;
+ for(int idx=0;idx<list.count();idx++)
+ {
+ bool bNameMatch = false;
+ bool bClassMatch = false;
+ if( !szName.isEmpty() )
+ bNameMatch = KviQString::equalCI(list.at(idx)->name(), szName);
+ else
+ bNameMatch = true;
+ if( !szClass.isEmpty())
+ bClassMatch = KviQString::equalCI(list.at(idx)->className(), szClass);
+ else
+ bClassMatch = true;
+ if( bNameMatch && bClassMatch ) {
+ QWidget *w = list.at(idx);
+ return w;
+ }
+ }
+ return 0;
+#else
+
+ QWidgetList *list = g_pApp->topLevelWidgets();
+ if( !list ) return 0;
+
+ QWidgetListIt it(*list);
+ while( it.current() ) {
+ bool bNameMatch = false;
+ bool bClassMatch = false;
+ if( szName )
+ bNameMatch = KviQString::equalCI(it.current()->name(), szName);
+ else
+ bNameMatch = true;
+ if( szClass )
+ bClassMatch = KviQString::equalCI(it.current()->className(), szClass);
+ else
+ bClassMatch = true;
+ if( bNameMatch && bClassMatch ) {
+ QWidget *w = it.current();
+ delete list;
+ return w;
+ }
+ ++it;
+ }
+ delete list;
+
+ return 0;
+#endif
+}
+
+QWidget *KviKvsObject_wrapper::findWidgetToWrap(const char *szClass, const char *szName, QWidget *childOf)
+{
+#ifdef COMPILE_USE_QT4
+ QObjectList list = childOf->queryList(szClass ? szClass : 0, szName ? szName : 0, false, true);
+ if( !list.count() ) return 0;
+ for(int idx=0;idx<list.count();idx++)
+ {
+ if( list.at(idx)->isWidgetType() ) {
+ QWidget *w = (QWidget *)list.at(idx);
+ return w;
+ }
+
+ }
+ return 0;
+#else
+
+ QObjectList *list = childOf->queryList(szClass ? szClass : 0, szName ? szName : 0, false, true);
+ if( !list ) return 0;
+
+ QObjectListIt it(*list);
+ while( it.current() ) {
+ if( it.current()->isWidgetType() ) {
+ QWidget *w = (QWidget *) it.current();
+ delete list;
+ return w;
+ }
+ ++it;
+ }
+ delete list;
+ return 0;
+#endif
+}
+
+#include "m_class_wrapper.moc"
diff --git a/src/modules/objects/class_wrapper.h b/src/modules/objects/class_wrapper.h
new file mode 100644
index 00000000..900b0672
--- /dev/null
+++ b/src/modules/objects/class_wrapper.h
@@ -0,0 +1,53 @@
+#ifndef _CLASS_WRAPPER_H_
+#define _CLASS_WRAPPER_H_
+//
+// File : class_wrapper.h
+// Creation date : Fri Jan 28 14:21:48 CEST 2005
+// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+
+
+#include "class_widget.h"
+#include "qlistview.h"
+
+
+
+
+#include "object_macros.h"
+
+class KviKvsObject_wrapper : public KviKvsObject_widget
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_wrapper)
+public:
+ QWidget * widget() { return (QWidget *)object(); };
+protected:
+ virtual bool init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams);
+ QWidget * findTopLevelWidgetToWrap(const QString szClass, const QString szName);
+ QWidget * findWidgetToWrap(const char *szClass, const char *szName, QWidget *childOf);
+
+};
+
+
+
+#endif //!_CLASS_WRAPPER_H_
diff --git a/src/modules/objects/class_xmlreader.cpp b/src/modules/objects/class_xmlreader.cpp
new file mode 100644
index 00000000..f4bccc8f
--- /dev/null
+++ b/src/modules/objects/class_xmlreader.cpp
@@ -0,0 +1,343 @@
+//=============================================================================
+//
+// File : class_xmlreader.cpp
+// Created on Tue 27 Dec 2005 00:14:09 by Szymon Stefanek
+//
+// This file is part of the KVIrc IRC Client distribution
+// Copyright (C) 2005 Szymon Stefanek <pragma at kvirc dot net>
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "class_xmlreader.h"
+
+#include "kvi_locale.h"
+
+#include "kvi_kvs_variantlist.h"
+#include "kvi_kvs_hash.h"
+
+#include "kvi_qstring.h"
+
+
+/*
+ @doc: xmlreader
+ @keyterms:
+ xml
+ @title:
+ xmlreader class
+ @type:
+ class
+ @short:
+ A simple xml document parser
+ @inherits:
+ [class]object[/class]
+ @description:
+ This class implements a really simple xml document parser.
+ You will usually derive your own class from this one and reimplement
+ some of the events that it triggers.
+ You will typically reimplement [classfnc:xmlparser]onElementStart[/classfnc]()
+ and [classfnc:xmlparser]onElementEnd[/classfnc]() that will be called
+ during the execution of [classfnc:xmlparser]$parse[/classfnc]() in an order
+ reflecting the order of elements in the parsed document.
+ @functions:
+ !fn: <boolean> $parse(<xml_data:string>)
+ Call this function to parse a string that contains an XML document.
+ A typical call for this method will look like:
+ [example]
+ %x = [fnc]$new[/fnc](xmlparser)
+ %x->$parse([fnc]$file.read[/fnc]("/home/somefile.xml"))
+ [/example]
+ During the call the <xml_data> string will be parsed and the
+ relevant on* events (see below) will be triggered.
+ $parse will return $true when the parsing terminates succesfully
+ or $false if it aborts for some reason (unrecoverable error
+ in the document, user abort etc...).
+ If this function return $false then you can call $lastError() to
+ obtain a descriptive error message.
+
+ !fn: <string> $lastError()
+ Returns the last error occured inside the parser.
+ You will typically call this function when $parse() above returns $false.
+
+ !fn: <boolean> $onDocumentStart()
+ This function is called when the document parsing starts.
+ You can reimplement it in order to handle this notification.
+ You should return $true if you want document parsing to continue
+ and $false if you want it to be aborted.
+ The default implementation does nothing besides returning $true.
+
+ !fn: <boolean> $onDocumentEnd()
+ This function is called when the document parsing terminates succesfully.
+ You can reimplement it in order to handle this notification.
+ You should return $true if you want document parsing to continue
+ and $false if you want it to be aborted.
+ The default implementation does nothing besides returning $true.
+
+ !fn: <boolean> $onElementStart(<qualified_name:string>,<attributes:hash>,<namespace:string>,<local_name:string>)
+ This function is called when an element opening tag is encountered.
+ The <qualified_name> of the tag is passed as the first parameter.
+ The <attributes> are passed in the form of a hash with attribute
+ values indexed by their names.
+ When the <qualified_name> contains a namespace then it is also reported
+ in the splitted <namespace> <local_name> pair.
+ You should return $true if you want document parsing to continue
+ and $false if you want it to be aborted.
+ The default implementation does nothing besides returning $true.
+
+ !fn: <boolean> $onElementEnd(<qualified_name:string>,<namespace:string>,<local_name:string>)
+ This function is called when an element closing tag is encountered.
+ The <qualified_name> of the tag is passed as the first parameter.
+ When the <qualified_name> contains a namespace then it is also reported
+ in the splitted <namespace> <local_name> pair.
+ You should return $true if you want document parsing to continue
+ and $false if you want it to be aborted.
+ The default implementation does nothing besides returning $true.
+
+ !fn: <boolean> $onText($0 = <text:string>)
+ This function is called when a chunk of text is encountered inside the document.
+ The parsed <text> chunk is passed as the first parameter.
+ You should return $true if you want document parsing to continue
+ and $false if you want it to be aborted.
+ The default implementation does nothing besides returning $true.
+
+ !fn: <boolean> $onWarning(<message:string>)
+ This function is called when the parser generates a recoverable error.
+ The error <message> is passed as the first parameter.
+ You should return $true if you want document parsing to continue
+ and $false if you want it to be aborted.
+ The default implementation does nothing besides returning $true.
+
+ !fn: <boolean> $onError(<message:string>)
+ This function is called when the parser generates an unrecoverable error.
+ The error <message> is passed as the first parameter.
+ The document parsing can't continue.
+ The default implementation does nothing besides returning $true.
+*/
+
+
+#ifndef QT_NO_XML
+
+#include <qxml.h>
+
+class KviXmlHandler : public QXmlDefaultHandler
+{
+protected:
+ KviKvsObject_xmlreader * m_pReader;
+ QString m_szErrorString;
+public:
+ KviXmlHandler(KviKvsObject_xmlreader * pReader)
+ {
+ m_pReader = pReader;
+ }
+ ~KviXmlHandler()
+ {
+ }
+private:
+ bool kvsCodeFailure()
+ {
+ m_szErrorString = __tr2qs("Error in KVS class implementation: processing aborted");
+ return false;
+ }
+ bool kvsCodeAbort()
+ {
+ m_szErrorString = __tr2qs("Processing aborted");
+ return false;
+ }
+ void decodeException(QString &szMsg,bool bError,const QXmlParseException &exception)
+ {
+ if(bError)
+ KviQString::sprintf(szMsg,__tr2qs("Error near line %d, column %d"),exception.lineNumber(),exception.columnNumber());
+ else
+ KviQString::sprintf(szMsg,__tr2qs("Warning near line %d, column %d"),exception.lineNumber(),exception.columnNumber());
+ szMsg += ": ";
+ szMsg += exception.message();
+ }
+ bool handleKvsCallReturnValue(KviKvsVariant * pRetVal)
+ {
+ if(!pRetVal->asBoolean())return kvsCodeAbort();
+ return true;
+ }
+public:
+ virtual bool startDocument()
+ {
+ KviKvsVariant ret;
+ if(!m_pReader->callFunction(m_pReader,"onDocumentStart",&ret))
+ return kvsCodeFailure();
+ return handleKvsCallReturnValue(&ret);
+ }
+
+ virtual bool endDocument()
+ {
+ KviKvsVariant ret;
+ if(!m_pReader->callFunction(m_pReader,"onDocumentEnd",&ret))
+ return kvsCodeFailure();
+ return handleKvsCallReturnValue(&ret);
+ }
+
+ virtual bool startElement(const QString &szNamespaceUri,const QString &szLocalName,const QString &szQualifiedName,const QXmlAttributes &attrs)
+ {
+ KviKvsVariant ret;
+ KviKvsVariantList par;
+ par.setAutoDelete(true);
+ par.append(new KviKvsVariant(szQualifiedName));
+ KviKvsHash * pHash = new KviKvsHash();
+ par.append(new KviKvsVariant(pHash));
+ par.append(new KviKvsVariant(szNamespaceUri));
+ par.append(new KviKvsVariant(szLocalName));
+ int c = attrs.count();
+ for(int i=0;i<c;i++)
+ pHash->set(attrs.qName(i),new KviKvsVariant(attrs.value(i)));
+ if(!m_pReader->callFunction(m_pReader,"onElementStart",&ret,&par))
+ return kvsCodeFailure();
+ return handleKvsCallReturnValue(&ret);
+ }
+
+ virtual bool endElement(const QString &szNamespaceUri,const QString &szLocalName,const QString &szQualifiedName)
+ {
+ KviKvsVariant ret;
+ KviKvsVariantList par;
+ par.setAutoDelete(true);
+ par.append(new KviKvsVariant(szQualifiedName));
+ par.append(new KviKvsVariant(szNamespaceUri));
+ par.append(new KviKvsVariant(szLocalName));
+ if(!m_pReader->callFunction(m_pReader,"onElementEnd",&ret,&par))
+ return kvsCodeFailure();
+ return handleKvsCallReturnValue(&ret);
+ }
+
+ virtual bool characters(const QString &szChars)
+ {
+ KviKvsVariant ret;
+ KviKvsVariantList par;
+ par.setAutoDelete(true);
+ par.append(new KviKvsVariant(szChars));
+ if(!m_pReader->callFunction(m_pReader,"onText",&ret,&par))
+ return kvsCodeFailure();
+ return handleKvsCallReturnValue(&ret);
+ }
+
+ virtual bool warning(const QXmlParseException &exception)
+ {
+ // recoverable
+ QString szMsg;
+ decodeException(szMsg,false,exception);
+
+ KviKvsVariant ret;
+ KviKvsVariantList par;
+ par.setAutoDelete(true);
+ par.append(new KviKvsVariant(szMsg));
+ if(!m_pReader->callFunction(m_pReader,"onWarning",&ret,&par))
+ return kvsCodeFailure();
+ return handleKvsCallReturnValue(&ret);
+ }
+
+ virtual bool error(const QXmlParseException &exception)
+ {
+ // recoverable
+ QString szMsg;
+ decodeException(szMsg,false,exception);
+
+ KviKvsVariant ret;
+ KviKvsVariantList par;
+ par.setAutoDelete(true);
+ par.append(new KviKvsVariant(szMsg));
+ if(!m_pReader->callFunction(m_pReader,"onWarning",&ret,&par))
+ return kvsCodeFailure();
+ return handleKvsCallReturnValue(&ret);
+ }
+
+ virtual bool fatalError(const QXmlParseException &exception)
+ {
+ QString szMsg;
+ decodeException(szMsg,true,exception);
+ m_pReader->fatalError(szMsg);
+ return true;
+ }
+
+ virtual QString errorString()
+ {
+ return m_szErrorString;
+ }
+};
+
+#endif // !QT_NO_XML
+
+
+KVSO_BEGIN_REGISTERCLASS(KviKvsObject_xmlreader,"xmlreader","object")
+ KVSO_REGISTER_HANDLER(KviKvsObject_xmlreader,"lastError",function_lastError)
+ KVSO_REGISTER_HANDLER(KviKvsObject_xmlreader,"parse",function_parse)
+
+ KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(KviKvsObject_xmlreader,"onDocumentStart")
+ KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(KviKvsObject_xmlreader,"onDocumentEnd")
+ KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(KviKvsObject_xmlreader,"onElementStart")
+ KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(KviKvsObject_xmlreader,"onElementEnd")
+ KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(KviKvsObject_xmlreader,"onText")
+ KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(KviKvsObject_xmlreader,"onWarning")
+ KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(KviKvsObject_xmlreader,"onError")
+KVSO_END_REGISTERCLASS(KviKvsObject_xmlreader)
+
+KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_xmlreader,KviKvsObject)
+KVSO_END_CONSTRUCTOR(KviKvsObject_xmlreader)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_xmlreader)
+KVSO_END_DESTRUCTOR(KviKvsObject_xmlreader)
+
+void KviKvsObject_xmlreader::fatalError(const QString &szError)
+{
+ m_szLastError = szError;
+
+ KviKvsVariantList vArgs;
+ vArgs.append(new KviKvsVariant(m_szLastError));
+ callFunction(this,"onError",&vArgs);
+}
+
+bool KviKvsObject_xmlreader::function_parse(KviKvsObjectFunctionCall *c)
+{
+ QString szString;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("string",KVS_PT_STRING,0,szString)
+ KVSO_PARAMETERS_END(c)
+
+#ifdef QT_NO_XML
+ fatalError(__tr2qs("XML support not available in the Qt library"));
+ c->returnValue()->setBoolean(false);
+#else
+ m_szLastError = "";
+ KviXmlHandler handler(this);
+ QXmlInputSource source;
+ // We have a problem here.. most kvirc functions already interpret the data
+ // read from files. We should have binary data handling features to get this to work correctly.
+ // The following snippet of code tries to provide a best-effort workaround.
+ KviQCString utf8data = KviQString::toUtf8(szString);
+ QByteArray data = utf8data;
+ data.truncate(utf8data.length()); // don't include the null terminator in data
+ source.setData(data);
+ //debug("PARSING(%s) LEN(%d)",szString.utf8().data(),szString.utf8().length());
+ QXmlSimpleReader reader;
+ reader.setContentHandler(&handler);
+ reader.setErrorHandler(&handler);
+ c->returnValue()->setBoolean(reader.parse(source));
+#endif
+ return true;
+}
+
+bool KviKvsObject_xmlreader::function_lastError(KviKvsObjectFunctionCall *c)
+{
+ c->returnValue()->setString(m_szLastError);
+ return true;
+}
+
+#include "m_class_xmlreader.moc"
diff --git a/src/modules/objects/class_xmlreader.h b/src/modules/objects/class_xmlreader.h
new file mode 100644
index 00000000..dca69333
--- /dev/null
+++ b/src/modules/objects/class_xmlreader.h
@@ -0,0 +1,46 @@
+#ifndef _CLASS_XMLREADER_H_
+#define _CLASS_XMLREADER_H_
+//=============================================================================
+//
+// File : class_xmlreader.h
+// Created on Tue 27 Dec 2005 00:14:09 by Szymon Stefanek
+//
+// This file is part of the KVIrc IRC Client distribution
+// Copyright (C) 2005 Szymon Stefanek <pragma at kvirc dot net>
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "kvi_settings.h"
+#include "kvi_qstring.h"
+
+#include "object_macros.h"
+
+class KviKvsObject_xmlreader : public KviKvsObject
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_xmlreader)
+public:
+ bool function_parse(KviKvsObjectFunctionCall *c);
+ bool function_lastError(KviKvsObjectFunctionCall *c);
+
+ void fatalError(const QString &szError);
+protected:
+ QString m_szLastError;
+};
+
+#endif //!_CLASS_XMLREADER_H_
diff --git a/src/modules/objects/libkviobjects.cpp b/src/modules/objects/libkviobjects.cpp
new file mode 100644
index 00000000..73eacace
--- /dev/null
+++ b/src/modules/objects/libkviobjects.cpp
@@ -0,0 +1,1066 @@
+//=============================================================================
+//
+// File : libkviobjects.cpp
+// Creation date : Wed Sep 09 2000 20:59:01 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2000-2006 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "kvi_tal_listview.h"
+#include <qimage.h>
+#include "kvi_iconmanager.h"
+#include "kvi_window.h"
+#include "kvi_out.h"
+#include "kvi_mirccntrl.h"
+
+#include "kvi_app.h"
+
+#include "kvi_module.h"
+
+#include "kvi_locale.h"
+#include "kvi_error.h"
+#include "kvi_cmdformatter.h"
+#include "kvi_out.h"
+#include "kvi_app.h"
+#include "kvi_fileutils.h"
+#ifndef COMPILE_USE_QT4
+ #include <qwidgetlist.h>
+ #include <qobjectlist.h>
+#endif
+
+#include <qdir.h>
+
+#include "class_button.h"
+#include "class_checkbox.h"
+#include "class_urllabel.h"
+#include "class_lineedit.h"
+#include "class_multilineedit.h"
+#include "class_combobox.h"
+#include "class_widget.h"
+#include "class_list.h"
+#include "class_file.h"
+#include "class_socket.h"
+#include "class_layout.h"
+#include "class_menubar.h"
+#include "class_window.h"
+#include "class_listbox.h"
+#include "class_progressbar.h"
+#include "class_slider.h"
+#include "class_spinbox.h"
+#include "class_lcd.h"
+#include "class_radiobutton.h"
+#include "class_process.h"
+#include "class_groupbox.h"
+#include "class_buttongroup.h"
+#include "class_tabwidget.h"
+#include "class_workspace.h"
+#include "class_popupmenu.h"
+#include "class_listview.h"
+#include "class_listviewitem.h"
+#include "class_toolbar.h"
+#include "class_mainwindow.h"
+#include "class_toolbutton.h"
+#include "class_wizard.h"
+#include "class_tbrowser.h"
+#include "class_painter.h"
+#include "class_pixmap.h"
+#include "class_wrapper.h"
+#include "class_dialog.h"
+#include "class_xmlreader.h"
+#include "class_dockwindow.h"
+#include "class_vbox.h"
+#include "class_hbox.h"
+static void dumpChildObjects(KviWindow *pWnd, QObject *parent, const char *spacing, bool bWidgetsOnly, KviKvsArray *n, int &idx);
+
+static bool objects_module_cleanup(KviModule *m)
+{
+ KviKvsObject_process::unregisterSelf();
+ KviKvsObject_socket::unregisterSelf();
+ KviKvsObject_xmlreader::unregisterSelf();
+ KviKvsObject_wrapper::unregisterSelf();
+ KviKvsObject_file::unregisterSelf();
+ KviKvsObject_progressbar::unregisterSelf();
+ KviKvsObject_dockwindow::unregisterSelf();
+ KviKvsObject_wizard::unregisterSelf();
+ KviKvsObject_window::unregisterSelf();
+ KviKvsObject_urlabel::unregisterSelf();
+ KviKvsObject_toolbutton::unregisterSelf();
+ KviKvsObject_toolbar::unregisterSelf();
+ KviKvsObject_tabwidget::unregisterSelf();
+ KviKvsObject_spinbox::unregisterSelf();
+ KviKvsObject_slider::unregisterSelf();
+ KviKvsObject_radiobutton::unregisterSelf();
+ KviKvsObject_popupmenu::unregisterSelf();
+ KviKvsObject_pixmap::unregisterSelf();
+ KviKvsObject_painter::unregisterSelf();
+ KviKvsObject_mainwindow::unregisterSelf();
+ KviKvsObject_listviewitem::unregisterSelf();
+ KviKvsObject_listview::unregisterSelf();
+ KviKvsObject_listbox::unregisterSelf();
+ KviKvsObject_combobox::unregisterSelf();
+ KviKvsObject_workspace::unregisterSelf();
+ KviKvsObject_menubar::unregisterSelf();
+ KviKvsObject_lineedit::unregisterSelf();
+ KviKvsObject_lcd::unregisterSelf();
+ KviKvsObject_layout::unregisterSelf();
+ KviKvsObject_hbox::unregisterSelf();
+ KviKvsObject_vbox::unregisterSelf();
+ KviKvsObject_label::unregisterSelf();
+ KviKvsObject_buttongroup::unregisterSelf();
+ KviKvsObject_groupbox::unregisterSelf();
+ KviKvsObject_dialog::unregisterSelf();
+ KviKvsObject_checkbox::unregisterSelf();
+ KviKvsObject_textbrowser::unregisterSelf();
+ KviKvsObject_mledit::unregisterSelf();
+ KviKvsObject_button::unregisterSelf();
+ KviKvsObject_widget::unregisterSelf();
+ KviKvsObject_list::unregisterSelf();
+
+ return true;
+}
+
+
+static bool objects_kvs_cmd_killClass(KviKvsModuleCommandCall * c)
+{
+ /*
+ @doc: objects.killclass
+ @title:
+ objects.killclass
+ @type:
+ command
+ @short:
+ Removes a class definition
+ @syntax:
+ objects.killclass [-q] <classname:string>
+ @switches:
+ !sw: -q | --quiet
+ Suppresses any warning message
+ @description:
+ Removes the definition of the class <class_name>.[br]
+ All the instances of the class are killed (thus children objects are killed too).[br]
+ All the derived class definitions are removed as well.[br]
+ Builtin class definitions cannot be removed and this commands
+ kills only all the instances of that class (derived class definitions
+ and instances in this case are NOT killed).[br]
+ @seealso:
+ [cmd]class[/cmd], [cmd]objects.clear[/cmd], [fnc]$classDefined[/fnc](),
+ [doc:objects]Objects documentation[/doc]
+ */
+
+
+ QString szClass;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("class",KVS_PT_NONEMPTYSTRING,0,szClass)
+ KVSM_PARAMETERS_END(c)
+ KviKvsObjectClass * pClass=KviKvsKernel::instance()->objectController()->lookupClass(szClass);
+ if(pClass)
+ {
+ if(pClass->isBuiltin())
+ {
+ KviKvsKernel::instance()->objectController()->killAllObjectsWithClass(pClass);
+ } else {
+ KviKvsKernel::instance()->objectController()->deleteClass(pClass); //Yahoo!!
+ }
+ }
+ else if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("Class '%Q' is not definited"),&szClass);
+ return true;
+}
+
+
+static bool objects_kvs_cmd_clearObjects(KviKvsModuleCommandCall * c)
+{
+ /*
+ @doc: objects.clear
+ @title:
+ objects.clear
+ @type:
+ command
+ @short:
+ Removes all the user class definitions
+ @syntax:
+ objects.clear [-i]
+ @description:
+ Removes the definition of all the user classes and kill all the object
+ instances (also instances of the builtin classes).[br]
+ If the -i switch is used, only the object instances are cleared
+ but the class definitions are left unchanged.[br]
+ This command should be used only for debugging & testing purposes
+ and in particular should be NEVER used from inside an object
+ function handler (leads to SIGSEGV :).[br]
+ @seealso:
+ [cmd]class[/cmd], [cmd]objects.killclass[/cmd],
+ [doc:objects]Objects documentation[/doc]
+ */
+
+ KviKvsKernel::instance()->objectController()->clearInstances();
+ if(!c->switches()->find('i',"ii")) KviKvsKernel::instance()->objectController()->clearUserClasses();
+ return true;
+}
+
+
+static bool objects_kvs_cmd_connect(KviKvsModuleCommandCall * c)
+{
+
+ /*
+ @doc: objects.connect
+ @title:
+ objects.connect
+ @type:
+ command
+ @short:
+ Connects a signal to a slot
+ @syntax:
+ objects.connect <source_object:hobject> <signal_name:string> <target_object:hobject> <slot_name:string>
+ @description:
+ Connects the <source_object>'s signal <signal_name> to the
+ <target_object>'s slot <slot_name>.
+ When one of the two objects is destroyed, the signal/slot
+ connection is automatically removed.[br]
+ WARNING: This command name collides with the [doc:rfc2812]RFC2812[/doc]
+ CONNECT IRC Op command: this IRC command is available to operators only
+ and is rather rarely used: you can use it by the means of [doc:raw]raw[/doc].
+ @seealso:
+ [cmd]class[/cmd], [cmd]object.disconnect[/cmd], [doc:objects]objects documentation[/doc]
+ */
+
+
+ KviKvsObject *obSrc;
+ KviKvsObject *obTrg;
+ QString szSignal,szSlot;
+ kvs_hobject_t hSrc,hTrg;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("object source",KVS_PT_HOBJECT,0,hSrc)
+ KVSM_PARAMETER("signal name",KVS_PT_NONEMPTYSTRING,0,szSignal)
+ KVSO_PARAMETER("object target",KVS_PT_HOBJECT,0,hTrg)
+ KVSM_PARAMETER("slot",KVS_PT_NONEMPTYSTRING,0,szSlot)
+ KVSM_PARAMETERS_END(c)
+ obTrg=KviKvsKernel::instance()->objectController()->lookupObject(hTrg);
+ obSrc=KviKvsKernel::instance()->objectController()->lookupObject(hSrc);
+ if(!obTrg)
+ {
+ c->warning(__tr2qs("Inexisting target object for objects.connect"));
+ return true;
+ }
+ if(!obSrc)
+ {
+ c->warning(__tr2qs("Inexisting source object for objects.connect"));
+ return true;
+ }
+ obSrc->connectSignal(szSignal,obTrg,szSlot);
+ return true;
+}
+
+
+static bool objects_kvs_fnc_exists(KviKvsModuleFunctionCall * c)
+{
+ /*
+ @doc: objects.exists
+ @title:
+ objects.exists
+ @type:
+ command
+ @short:
+ Check if an object exists.
+ @syntax:
+ <boolean> $object.exists(<obejct id:hobject>)
+ @description:
+ Check if an objects exists and return a boolean value.
+ @seealso:
+ [doc:objects]objects documentation[/doc]
+ */
+
+
+ kvs_hobject_t hObj;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("object",KVS_PT_HOBJECT,0,hObj)
+ KVSM_PARAMETERS_END(c)
+ KviKvsObject *ob=KviKvsKernel::instance()->objectController()->lookupObject(hObj);
+ c->returnValue()->setBoolean(ob ? true : false);
+ return true;
+}
+
+static bool objects_kvs_fnc_instances(KviKvsModuleFunctionCall * c)
+{
+ /*
+ @doc: objects.instances
+ @title:
+ objects.instances
+ @type:
+ command
+ @short:
+ List object instances
+ @syntax:
+ <array> $object.instances(<class name:string>[,<flags:string>])
+ @description:
+ Returns an array with the instance handles of
+ of objects of the specified class. <flags> is a
+ string containing modifiers for the function behaviour.[br]
+ If <flags> contains the letter "s" then
+ only unsubclassed instances of the specified
+ class are returned. This means that if B is
+ a subclass of A then when asked for instances
+ of A without the flag "s" this function will return
+ both instances of A and B, and with the flag "s"
+ this function will return only instances of A (and not B).
+ If the class name does not define a valid class
+ then an empty array is returned and a warning is
+ printed unless the "q" flag is used.
+ @examples:
+ [example]
+ foreach(%x,$objects.instances(object))
+ {
+ echo "OBJECT WITH CLASS" %x->$className() "AND NAME \""%x->$name()"\""
+ }
+ [/example]
+ @seealso:
+ [doc:objects]objects documentation[/doc]
+ */
+
+ QString szClassName;
+ QString szFlags;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("class name",KVS_PT_NONEMPTYSTRING,0,szClassName)
+ KVSO_PARAMETER("flags",KVS_PT_STRING,KVS_PF_OPTIONAL,szFlags)
+ KVSM_PARAMETERS_END(c)
+
+ KviKvsArray * pArry = new KviKvsArray();
+ c->returnValue()->setArray(pArry);
+
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName);
+ if(!pClass)
+ {
+ if(!szFlags.contains(QChar('q')))
+ c->warning(__tr2qs("The class '%Q' does not exist"),&szClassName);
+ return true;
+ }
+ KviPointerHashTable<void *,KviKvsObject> * od = KviKvsKernel::instance()->objectController()->objectDict();
+
+ KviPointerHashTableIterator<void *,KviKvsObject> it(*od);
+ kvs_uint_t uIdx = 0;
+ if(szFlags.contains(QChar('s')))
+ {
+ while(KviKvsObject * ob = it.current())
+ {
+ if(ob->getExactClass() == pClass)
+ {
+ pArry->set(uIdx,new KviKvsVariant(ob->handle()));
+ uIdx++;
+ }
+ ++it;
+ }
+ } else {
+ while(KviKvsObject * ob = it.current())
+ {
+ if(ob->inheritsClass(pClass))
+ {
+ pArry->set(uIdx,new KviKvsVariant(ob->handle()));
+ uIdx++;
+ }
+ ++it;
+ }
+ }
+ return true;
+}
+/*
+ @doc: objects.variables
+ @title:
+ objects.variables
+ @type:
+ command
+ @short:
+ List object's variables.
+ @syntax:
+ <hash> objects.variables(<hobject>)
+ @description:
+ Returns an hash with the object's variables(useful only for debugging).
+ @seealso:
+ [doc:objects]objects documentation[/doc]
+ */
+static bool objects_kvs_fnc_variables(KviKvsModuleFunctionCall * c)
+{
+ kvs_hobject_t hObj;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("object",KVS_PT_HOBJECT,0,hObj)
+ KVSM_PARAMETERS_END(c)
+ KviKvsObject *ob=KviKvsKernel::instance()->objectController()->lookupObject(hObj);
+ if (!ob)
+ {
+ c->warning(__tr2qs("Object does not exists"));
+ return true;
+ }
+ KviPointerHashTableIterator<QString,KviKvsVariant> it(* ob->dataContainer()->dict());
+ KviKvsHash* pHash = new KviKvsHash();
+ c->returnValue()->setHash(pHash);
+ while(KviKvsVariant * t = it.current())
+ {
+ pHash->set(it.currentKey(),new KviKvsVariant(*t));
+ ++it;
+ }
+ return true;
+
+
+
+}
+/*
+ @doc: objects.classAllHandlers
+ @title:
+ objects.classAllHandlers
+ @type:
+ function
+ @short:
+ List all the functions .
+ @syntax:
+ <hash> objects.classAllHandlers(<class name:string>)
+ @description:
+ Returns an hash with the class's functions(useful only for debugging).
+ @seealso:
+ [doc:objects]objects documentation[/doc]
+ */
+static bool objects_kvs_fnc_classAllHandlers(KviKvsModuleFunctionCall * c)
+{
+ QString szClassName;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("class name",KVS_PT_NONEMPTYSTRING,0,szClassName)
+ KVSM_PARAMETERS_END(c)
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName);
+ if(!pClass)
+ {
+ c->warning(__tr2qs("The class '%Q' does not exist"),&szClassName);
+ return true;
+ }
+
+ KviPointerHashTableIterator<QString,KviKvsObjectFunctionHandler> it(* pClass->getHandlers());
+ KviKvsHash* pHash = new KviKvsHash();
+ c->returnValue()->setHash(pHash);
+ while(KviKvsObjectFunctionHandler * t = it.current())
+ {
+ QString szCode;
+ KviKvsObjectFunctionHandler *handler=pClass->lookupFunctionHandler(it.currentKey());
+ pClass->getFunctionCode(szCode,*handler);
+ pHash->set(it.currentKey(),new KviKvsVariant(szCode));
+ ++it;
+ }
+
+ return true;
+}
+static bool objects_kvs_fnc_classes(KviKvsModuleFunctionCall * c)
+{
+
+ /*
+ @doc: objects.classes
+ @title:
+ objects.classes
+ @type:
+ command
+ @short:
+ List user defined classes
+ @syntax:
+ <array> $object.classes()
+ @description:
+ Returns an array with the user defined classes.
+ @seealso:
+ [doc:objects]objects documentation[/doc]
+ */
+
+ KviKvsArray * pArry = new KviKvsArray();
+ c->returnValue()->setArray(pArry);
+ int uIdx=0;
+ KviPointerHashTableIterator<QString,KviKvsObjectClass> it(*KviKvsKernel::instance()->objectController()->classDict());
+ KviPointerHashTable<QString,bool> *classdict=new KviPointerHashTable<QString,bool>;
+ classdict->setAutoDelete(false);
+ bool bFake=true;
+ while(KviKvsObjectClass * pClass=it.current())
+ {
+ if (!pClass->isBuiltin())classdict->insert(it.currentKey(),&bFake);
+ ++it;
+ }
+ QString szPath;
+ g_pApp->getLocalKvircDirectory(szPath,KviApp::Classes);
+ QDir d(szPath);
+ QStringList sl;
+ sl = d.entryList(QDir::Files);
+ for(QStringList::Iterator it2 = sl.begin();it2 != sl.end();++it2)
+ {
+ QString szName=*it2;
+ szName.replace("--","::");
+ if (szName!=".." && szName!=".") classdict->insert(szName.left(szName.length()-4),&bFake);
+ }
+ KviKvsArray* pArray = new KviKvsArray();
+ c->returnValue()->setArray(pArray);
+ int idx=0;
+ KviPointerHashTableIterator<QString,bool> strIt(*classdict);
+ while(strIt.current())
+ {
+ pArray->set(idx,new KviKvsVariant(strIt.currentKey()));
+ idx++;
+ ++strIt;
+ }
+ delete classdict;
+ return true;
+
+}
+
+static bool objects_kvs_cmd_disconnect(KviKvsModuleCommandCall * c)
+{
+ /*
+ @doc: objects.disconnect
+ @title:
+ objects.disconnect
+ @type:
+ command
+ @short:
+ Disconnects a signal from a slot
+ @syntax:
+ disconnect <source_object:hobject> <signal_name:string> <target_object:hobject> <slot_name:string>
+ @description:
+ Disconnects the <source_object>'s signal <signal_name> from the
+ <target_object>'s slot <slot_name>.
+ When one of the two objects is destroyed, the signal/slot
+ connection is automatically removed.
+ @seealso:
+ [cmd]class[/cmd], [cmd]objects.connect[/cmd], [doc:objects]objects documentation[/doc]
+ */
+
+
+
+
+ KviKvsObject *obSrc;
+ KviKvsObject *obTrg;
+ QString szSignal,szSlot;
+ kvs_hobject_t hSrc,hTrg;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("object source",KVS_PT_HOBJECT,0,hSrc)
+ KVSM_PARAMETER("signal name",KVS_PT_NONEMPTYSTRING,0,szSignal)
+ KVSO_PARAMETER("object target",KVS_PT_HOBJECT,0,hTrg)
+ KVSM_PARAMETER("slot",KVS_PT_NONEMPTYSTRING,0,szSlot)
+ KVSM_PARAMETERS_END(c)
+ obTrg=KviKvsKernel::instance()->objectController()->lookupObject(hTrg);
+ obSrc=KviKvsKernel::instance()->objectController()->lookupObject(hSrc);
+ if(!obTrg)
+ {
+ c->warning(__tr2qs("Inexisting target object for objects.disconnect"));
+ return true;
+ }
+ if(!obSrc)
+ {
+ c->warning(__tr2qs("Inexisting source object for objects.disconnect"));
+ return true;
+ }
+ obSrc->disconnectSignal(szSignal,obTrg,szSlot);
+ return true;
+}
+
+
+
+static bool objects_kvs_cmd_bitBlt(KviKvsModuleCommandCall * c)
+{
+ /*
+ @doc: objects.bitblt
+ @type:
+ command
+ @title:
+ objects.bitblt
+ @keyterms:
+ widget pixmap painter
+ @short:
+ Copies a block of pixels from a source to a destination.
+ @syntax:
+ objects.bitblt <source> <x> <y> <destination>
+ @description:
+ Copies a block of pixels from <source> to <destination> at the coordinates <x>,<y> .[br]
+ Source and destination must be a widget or pixmap.[br]
+
+ */
+
+ KviKvsObject *obSrc;
+ KviKvsObject *obDst;
+ kvs_int_t iXdst,iYdst,iXsrc,iYsrc,uW,uH;
+ kvs_hobject_t hDst,hSrc;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("destination",KVS_PT_HOBJECT,0,hDst)
+ KVSO_PARAMETER("x offset dest",KVS_PT_INT,0,iXdst)
+ KVSO_PARAMETER("y offset dest",KVS_PT_INT,0,iYdst)
+ KVSO_PARAMETER("source",KVS_PT_HOBJECT,0,hSrc)
+ KVSO_PARAMETER("x offset source",KVS_PT_INT,0,iXsrc)
+ KVSO_PARAMETER("y offset source",KVS_PT_INT,0,iYsrc)
+ KVSO_PARAMETER("width",KVS_PT_UNSIGNEDINTEGER,0,uW)
+ KVSO_PARAMETER("height",KVS_PT_UNSIGNEDINTEGER,0,uH)
+ KVSO_PARAMETERS_END(c)
+ obSrc=KviKvsKernel::instance()->objectController()->lookupObject(hSrc);
+ if (!obSrc)
+ {
+ c->warning(__tr2qs("Source is not an object"));
+ return true;
+ }
+ obDst=KviKvsKernel::instance()->objectController()->lookupObject(hDst);
+ if (!obDst)
+ {
+ c->warning(__tr2qs("Destination is not an object"));
+ return true;
+ }
+
+ QImage * imgSource=0;
+ QPaintDevice * pdSource = 0;
+
+ if(obSrc->inherits("KviKvsObject_pixmap")) pdSource =((KviKvsObject_pixmap *)obSrc)->getPixmap();
+ else if (obSrc->inherits("KviKvsObject_widget")) pdSource=((KviKvsObject_widget *)obSrc)->widget();
+ if (!pdSource)
+ {
+ c->warning(__tr2qs("Widget, Image or Pixmap required "));
+ return true;
+ }
+ QPaintDevice * pdDest = 0;
+ if(obDst->inherits("KviKvsObject_pixmap")){
+ pdDest= ((KviKvsObject_pixmap *)obDst)->getPixmap();
+ }
+ else if (obDst->inherits("KviKvsObject_widget")) pdDest=((KviKvsObject_widget *)obDst)->widget();
+ if (!pdDest)
+ {
+ c->warning(__tr2qs("Widget or Pixmap required"));
+ return true;
+ }
+ if(obDst->inherits("KviKvsObject_pixmap")){
+ ((KviKvsObject_pixmap *)obDst)->pixmapChanged();
+ }
+#ifdef COMPILE_USE_QT4
+ /*QPainter p(pdDest);
+ QRect rectdest(iXdst,iYdst,uW,uH);
+ QRect rectsrc(iXsrc,iYsrc,uW,uH);
+
+ p.drawPixmap(rectdest,pdSource,rectsrc);
+*/
+ #else
+ bitBlt(pdDest,iXdst,iYdst,pdSource,iXsrc,iYsrc,uW,uH);
+#endif
+ return true;
+}
+ /*
+ @doc: objects.blend
+ @type:
+ command
+ @title:
+ objects.blend
+ @keyterms:
+ widget pixmap image
+ @short:
+ Blends two images to a destination.
+ @syntax:
+ objects.blend <background: image hobject> <x_offset_bkg:unsigned integer> <y_offset_bkg:unsigned integer>
+ <foreground: image hobject> <x_offset_fgr:unsigned integer> <y_offset_fgr:unsigned integer>
+ <destination: image, pixmap. widget hobject> <x_offset_dest:unsigned integer> <y_offset_dest:unsigned integer> <width:unsigned integer> <height:unsigned integer> <blend_factor>
+ @description:
+ Blends two images <background> and <foreground> and copy the result to <destination> at the coordinates <x_offset>,<y_offset> with a <blend_factor> value .[br]
+ Destination must be a widget or pixmap.[br]
+
+ */
+
+static bool objects_kvs_cmd_blend(KviKvsModuleCommandCall * c)
+{
+
+ KviKvsObject *obFor;
+ KviKvsObject *obBck;
+ KviKvsObject *obDest;
+
+ kvs_int_t iBkX,iBkY;
+ kvs_int_t iFoX,iFoY;
+ kvs_int_t iDesX,iDesY,uW,uH;
+ kvs_real_t dBlend;
+
+ kvs_hobject_t hBk,hFo,hDest;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("destination",KVS_PT_HOBJECT,0,hDest)
+ KVSO_PARAMETER("x_offset_dest",KVS_PT_INT,0,iDesX)
+ KVSO_PARAMETER("y_offset_dest",KVS_PT_INT,0,iDesY)
+
+ KVSO_PARAMETER("image_background",KVS_PT_HOBJECT,0,hBk)
+ KVSO_PARAMETER("x_offset_background",KVS_PT_UNSIGNEDINTEGER,0,iBkX)
+ KVSO_PARAMETER("y_offset_background",KVS_PT_UNSIGNEDINTEGER,0,iBkY)
+ KVSO_PARAMETER("image_foreground",KVS_PT_HOBJECT,0,hFo)
+ KVSO_PARAMETER("x_offset_foreground",KVS_PT_UNSIGNEDINTEGER,0,iFoX)
+ KVSO_PARAMETER("y_offset_foreground",KVS_PT_UNSIGNEDINTEGER,0,iFoY)
+ KVSO_PARAMETER("width",KVS_PT_UNSIGNEDINTEGER,0,uW)
+ KVSO_PARAMETER("height",KVS_PT_UNSIGNEDINTEGER,0,uH)
+
+ KVSO_PARAMETER("blend_value",KVS_PT_REAL,0,dBlend)
+
+
+
+ KVSO_PARAMETERS_END(c)
+
+ obFor=KviKvsKernel::instance()->objectController()->lookupObject(hFo);
+
+
+ obBck=KviKvsKernel::instance()->objectController()->lookupObject(hBk);
+ obDest=KviKvsKernel::instance()->objectController()->lookupObject(hDest);
+ if (!obFor || !obBck || !obDest)
+ {
+ c->warning(__tr2qs("One o more of background, foreground or destination aren't objects"));
+ return true;
+ }
+
+ if (!obBck->inherits("KviKvsObject_pixmap") || !obFor->inherits("KviKvsObject_pixmap"))
+ {
+ c->warning(__tr2qs("Pixmap objects required"));
+ return true;
+ }
+
+ QPaintDevice * pdDest = 0;
+ if(obDest->inherits("KviKvsObject_pixmap")) pdDest = ((KviKvsObject_pixmap *)obDest)->getPixmap();
+ else if (obDest->inherits("KviKvsObject_widget")) pdDest=((KviKvsObject_widget *)obDest)->widget();
+
+ if (!pdDest)
+ {
+ c->warning(__tr2qs("Widget or Pixmap required "));
+ return true;
+ }
+
+ if(obDest->inherits("KviKvsObject_pixmap")) ((KviKvsObject_pixmap *)obDest)->pixmapChanged();
+
+
+ QImage *img_back=((KviKvsObject_pixmap *)obBck)->getImage();
+ QImage *img_fore=((KviKvsObject_pixmap *)obFor)->getImage();
+
+ // check size
+ if ((iBkX+uW>img_back->width())||(iBkY+uH>img_back->height()))
+ {
+ c->warning(__tr2qs("Values for background are out of image size "));
+ return true;
+ }
+ if ((iFoX+uW>img_fore->width())||(iFoY+uH>img_fore->height()))
+ {
+ c->warning(__tr2qs("Values for foreground are out of image size "));
+ return true;
+ }
+ QImage buffer;
+ buffer.create(uW,uH,32);
+ buffer.setAlphaBuffer(true);
+ for(int y = 0;y < buffer.height();y++)
+ {
+ QRgb * dst = (QRgb *)buffer.scanLine(y);
+ QRgb * end = dst + buffer.width();
+ QRgb * bkg = (QRgb *)img_back->scanLine(y+iBkY);
+ bkg += iBkX;
+ QRgb * fgn = (QRgb *)img_fore->scanLine(y+iFoY);
+ fgn += iFoX;
+ double dRemaining = 1.0 - dBlend;
+ int a=0;
+ while(dst < end)
+ {
+
+
+ *dst = qRgba(
+ (int)((qRed(*bkg) * dRemaining) + (qRed(*fgn) * dBlend)),
+ (int)((qGreen(*bkg) * dRemaining) + (qGreen(*fgn) * dBlend)),
+ (int)((qBlue(*bkg) * dRemaining) + (qBlue(*fgn) * dBlend)),
+ (int)((qAlpha(*bkg) * dRemaining) + (qAlpha(*fgn) * dBlend))
+ );
+
+ dst++;
+ bkg++;
+ fgn++;
+ }
+
+
+ }
+#ifdef COMPILE_USE_QT4
+ QPainter p(pdDest);
+ QRect rect(iDesX,iDesY,buffer.width(),buffer.height());
+ p.drawImage(rect,buffer);
+#else
+ bitBlt(pdDest,iDesX,iDesY,&buffer,0,0,buffer.width(),buffer.height());
+#endif
+ return true;
+
+}
+
+// ASSASSINI! LA DOVETE INDENTARE PER BENE :D
+
+
+static bool objects_kvs_fnc_listObjects(KviKvsModuleFunctionCall * cmd)
+{
+/*
+ @doc: objects.dump
+ @type:
+ function
+ @title:
+ $objects.dump
+ @keyterms:
+ dump objects
+ @short:
+ Dump the kvirc widgets.
+ @syntax:
+ $objects.dump(<flag b>)
+ @description:
+ This function returns the tree of the widgets of the kvirc, if the flag <b> is planned to 1,[br]
+ will return it on the currente window, if it' is planned to 0 instead it will return it as a string.[br]
+ ES:
+ %A[]=$str.split("\|",$objects.dump(0))
+ %i=0
+ while (%i != %A[]#)
+ {
+ echo %A[%i]
+ %i++
+ }
+*/
+
+
+ bool bFlag;
+ KVSO_PARAMETERS_BEGIN(cmd)
+ KVSO_PARAMETER("flag on video",KVS_PT_BOOL,0,bFlag)
+ KVSO_PARAMETERS_END(cmd)
+ if (bFlag) cmd->window()->output(80, "Objects dump:");
+ #ifdef COMPILE_USE_QT4
+ QWidgetList list = g_pApp->topLevelWidgets();
+
+ KviStr spacing = ">";
+ QString szTemp;
+ KviKvsArray * n = new KviKvsArray();
+ int idx=0;
+ for(int i=0;i<list.count();i++)
+ {
+ if( list.at(i)->isWidgetType())
+ {
+ if (bFlag)
+ {
+ cmd->window()->output(80, "Ptr %u: top level object: %c%s%c, class %s, %s, rect = %d, %d, %d, %d",
+ list.at(i),
+ KVI_TEXT_BOLD, list.at(i)->name(), KVI_TEXT_BOLD,
+ list.at(i)->className(),
+ list.at(i)->isVisible() ? "visible" : "hidden",
+ list.at(i)->x(), list.at(i)->y(), list.at(i)->width(), list.at(i)->height());
+ }
+ QString szClass=list.at(i)->className();
+ QString szObj=list.at(i)->name();
+ QString szTemp;
+ szTemp = szClass + "::" + szObj;
+ KviKvsVariant v;
+ v.setString(szTemp);
+ n->set(idx,new KviKvsVariant(v));
+ debug ("string %s",szTemp.latin1());
+ debug ("class %s",szClass.latin1());
+ debug ("Obj %s",szObj.latin1());
+
+ idx++;
+
+ dumpChildObjects(cmd->window(), list.at(i), spacing.ptr(), bFlag,n,idx);
+ }
+ //++it;
+ }
+
+#else
+ QWidgetList *l = g_pApp->topLevelWidgets();
+ l->setAutoDelete(false);
+ QWidgetListIt it(*l);
+ KviStr spacing = ">";
+ QString szTemp;
+ KviKvsArray * n = new KviKvsArray();
+ int idx=0;
+ while( it.current() )
+ {
+ if( it.current()->isWidgetType())
+ {
+ if (bFlag)
+ {
+ cmd->window()->output(80, "Ptr %u: top level object: %c%s%c, class %s, %s, rect = %d, %d, %d, %d",
+ it.current(),
+ KVI_TEXT_BOLD, it.current()->name(), KVI_TEXT_BOLD,
+ it.current()->className(),
+ it.current()->isVisible() ? "visible" : "hidden",
+ it.current()->x(), it.current()->y(), it.current()->width(), it.current()->height());
+ }
+ QString szClass=it.current()->className();
+ QString szObj=it.current()->name();
+ QString szTemp;
+ szTemp = szClass + "::" + szObj;
+ KviKvsVariant v;
+ v.setString(szTemp);
+ n->set(idx,new KviKvsVariant(v));
+ debug ("string %s",szTemp.latin1());
+ debug ("class %s",szClass.latin1());
+ debug ("Obj %s",szObj.latin1());
+
+ idx++;
+
+ dumpChildObjects(cmd->window(), it.current(), spacing.ptr(), bFlag,n,idx);
+
+
+ }
+ ++it;
+ }
+
+#endif
+ cmd->returnValue()->setArray(n);
+ return true;
+}
+
+static void dumpChildObjects(KviWindow *pWnd, QObject *parent, const char *spacing, bool bFlag, KviKvsArray *n, int &idx)
+{
+#ifdef COMPILE_USE_QT4
+ const QObjectList list = parent->children();
+ if( !list.count() ) return;
+ QString sp(spacing);
+ sp.append(">");
+ for(int i=0;i<list.count();i++)
+ {
+ if( list.at(i)->isWidgetType() )
+ {
+ if (bFlag)
+ {
+ pWnd->output(80, "%sPtr %u: object: %c%s%c, class %s",
+ spacing, list.at(i), KVI_TEXT_BOLD,
+ list.at(i)->name(), KVI_TEXT_BOLD, list.at(i)->className()
+ );
+ }
+ QString szClass=list.at(i)->className();
+ QString szObj=list.at(i)->name();
+ QString szTemp;
+ szTemp=spacing+szClass+"::"+szObj;
+ KviKvsVariant v;
+ v.setString(szTemp);
+ n->set(idx,new KviKvsVariant(v));
+ debug ("string %s",szTemp.latin1());
+ idx++;
+ dumpChildObjects(pWnd, list.at(i), sp, bFlag, n, idx );
+ }
+ }
+
+#else
+ const QObjectList *l = parent->children();
+ if( !l ) return;
+ if( l->isEmpty() ) return;
+ QObjectListIt it(*l);
+ QString sp(spacing);
+ sp.append(">");
+ while( it.current() )
+ {
+ if( it.current()->isWidgetType() )
+ {
+ if (bFlag)
+ {
+ pWnd->output(80, "%sPtr %u: object: %c%s%c, class %s",
+ spacing, it.current(), KVI_TEXT_BOLD,
+ it.current()->name(), KVI_TEXT_BOLD, it.current()->className()
+ );
+ }
+ QString szClass=it.current()->className();
+ QString szObj=it.current()->name();
+ QString szTemp;
+ szTemp=spacing+szClass+"::"+szObj;
+ KviKvsVariant v;
+ v.setString(szTemp);
+ n->set(idx,new KviKvsVariant(v));
+ debug ("string %s",szTemp.latin1());
+ idx++;
+ dumpChildObjects(pWnd, it.current(), sp, bFlag, n, idx );
+ }
+ ++it;
+ }
+#endif
+}
+
+static bool objects_module_can_unload(KviModule *m)
+{
+ // Actually this object remains locked in memory
+ // FIXME: unlock when no more instances & derived classes!
+ return false;
+}
+static bool objects_module_init(KviModule * m)
+{
+ // functions
+ KVSM_REGISTER_FUNCTION(m,"exists",objects_kvs_fnc_exists);
+ KVSM_REGISTER_FUNCTION(m,"instances",objects_kvs_fnc_instances);
+ KVSM_REGISTER_FUNCTION(m,"classes",objects_kvs_fnc_classes);
+ KVSM_REGISTER_FUNCTION(m,"dump",objects_kvs_fnc_listObjects);
+ KVSM_REGISTER_FUNCTION(m,"variables",objects_kvs_fnc_variables);
+ KVSM_REGISTER_FUNCTION(m,"classAllHandlers",objects_kvs_fnc_classAllHandlers);
+
+ // commands
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"connect",objects_kvs_cmd_connect);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"disconnect",objects_kvs_cmd_disconnect);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"killClass",objects_kvs_cmd_killClass);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"bitblt",objects_kvs_cmd_bitBlt);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"blend",objects_kvs_cmd_blend);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"clearObjects",objects_kvs_cmd_clearObjects);
+
+ KviKvsObject_list::registerSelf();
+
+ KviKvsObject_widget::registerSelf();
+ KviKvsObject_button::registerSelf();
+ KviKvsObject_mledit::registerSelf();
+
+ KviKvsObject_textbrowser::registerSelf();
+ KviKvsObject_checkbox::registerSelf();
+ KviKvsObject_dialog::registerSelf();
+ KviKvsObject_groupbox::registerSelf();
+ KviKvsObject_buttongroup::registerSelf();
+ KviKvsObject_label::registerSelf();
+ KviKvsObject_vbox::registerSelf();
+ KviKvsObject_hbox::registerSelf();
+ KviKvsObject_layout::registerSelf();
+ KviKvsObject_lcd::registerSelf();
+ KviKvsObject_lineedit::registerSelf();
+ KviKvsObject_menubar::registerSelf();
+ KviKvsObject_workspace::registerSelf();
+
+
+
+ KviKvsObject_combobox::registerSelf();
+ KviKvsObject_listbox::registerSelf();
+ KviKvsObject_listview::registerSelf();
+ KviKvsObject_listviewitem::registerSelf();
+ KviKvsObject_mainwindow::registerSelf();
+ KviKvsObject_painter::registerSelf();
+ KviKvsObject_pixmap::registerSelf();
+ KviKvsObject_popupmenu::registerSelf();
+ KviKvsObject_radiobutton::registerSelf();
+ KviKvsObject_slider::registerSelf();
+ KviKvsObject_spinbox::registerSelf();
+ KviKvsObject_tabwidget::registerSelf();
+ KviKvsObject_toolbar::registerSelf();
+ KviKvsObject_toolbutton::registerSelf();
+ KviKvsObject_urlabel::registerSelf();
+ KviKvsObject_window::registerSelf();
+ KviKvsObject_wizard::registerSelf();
+ KviKvsObject_dockwindow::registerSelf();
+ KviKvsObject_progressbar::registerSelf();
+ KviKvsObject_file::registerSelf();
+ KviKvsObject_wrapper::registerSelf();
+ KviKvsObject_xmlreader::registerSelf();
+ KviKvsObject_socket::registerSelf();
+ KviKvsObject_process::registerSelf();
+
+
+ return true;
+}
+
+KVIRC_MODULE(
+ "Objects",
+ "2.0.0",
+ "Copyright (C) 2000-2006:\n" \
+ " Szymon Stefanek (pragma at kvirc dot net)\n" \
+ " Krzysztof Godlewski (kristoff at poczta dot wprost dot pl)\n" \
+ " Tonino Imbesi (grifisx at barmes dot org)\n" \
+ " Alessandro Carbone (noldor at barmes dot org)",
+ "Object classes for KVIrc scripting language\n",
+ objects_module_init,
+ objects_module_can_unload,
+ 0,
+ objects_module_cleanup
+)
diff --git a/src/modules/objects/object_macros.h b/src/modules/objects/object_macros.h
new file mode 100644
index 00000000..9c0360b2
--- /dev/null
+++ b/src/modules/objects/object_macros.h
@@ -0,0 +1,90 @@
+#ifndef _OBJECT_MACROS_H_
+#define _OBJECT_MACROS_H_
+//=========================================================================================
+//
+// File : object_macros.h
+// Creation date : Sat Jun 18 2005 15:32:01 by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=========================================================================================
+
+#include "kvi_kvs_object.h"
+#include "kvi_kvs_object_class.h"
+#include "kvi_kvs_kernel.h"
+#include "kvi_kvs_object_controller.h"
+#include "kvi_kvs_object_functioncall.h"
+
+#define KVSO_DECLARE_OBJECT(__className) \
+ __className(KviKvsObjectClass * pClass,KviKvsObject * pParent,const QString &szName); \
+ ~__className(); \
+ static void registerSelf(); \
+ static void unregisterSelf();
+
+
+#define KVSO_REGISTER_HANDLER(__className,__szName,__proc) \
+ g_pKvs##__className##Class->registerFunctionHandler(__szName,(KviKvsObjectFunctionHandlerProc)(KVI_PTR2MEMBER(__className::__proc)));
+
+#define KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(__className,__szName) \
+ g_pKvs##__className##Class->registerStandardNothingReturnFunctionHandler(__szName);
+
+#define KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(__className,__szName) \
+ g_pKvs##__className##Class->registerStandardTrueReturnFunctionHandler(__szName);
+
+#define KVSO_REGISTER_STANDARD_FALSERETURN_HANDLER(__className,__szName) \
+ g_pKvs##__className##Class->registerStandardFalseReturnFunctionHandler(__szName);
+
+#define KVSO_BEGIN_REGISTERCLASS(__className,__stringName,__baseClass) \
+ static KviKvsObjectClass * g_pKvs##__className##Class = 0; \
+ static KviKvsObject * kvs_##__className##_createInstance(KviKvsObjectClass * pClass,KviKvsObject * pParent,const QString &szName) \
+ { \
+ return new __className(pClass,pParent,szName); \
+ } \
+ void __className::unregisterSelf() \
+ { \
+ delete g_pKvs##__className##Class; \
+ g_pKvs##__className##Class = 0; \
+ } \
+ void __className::registerSelf() \
+ { \
+ KviKvsObjectClass * base = KviKvsKernel::instance()->objectController()->lookupClass(__baseClass); \
+ g_pKvs##__className##Class = new KviKvsObjectClass(base,__stringName,kvs_##__className##_createInstance,true);
+
+
+
+#define KVSO_END_REGISTERCLASS(__className) \
+ }
+
+
+#define KVSO_BEGIN_CONSTRUCTOR(__className,__baseClass) \
+ __className::__className(KviKvsObjectClass * pClass,KviKvsObject * pParent,const QString &szName) \
+ : __baseClass(pClass,pParent,szName) \
+ {
+
+#define KVSO_END_CONSTRUCTOR(__className) \
+ }
+
+#define KVSO_BEGIN_DESTRUCTOR(__className) \
+ __className::~__className() \
+ {
+
+#define KVSO_END_DESTRUCTOR(__className) \
+ }
+
+
+#endif