aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/objects')
-rw-r--r--src/modules/objects/class_button.cpp16
-rw-r--r--src/modules/objects/class_buttongroup.cpp12
-rw-r--r--src/modules/objects/class_dockwindow.cpp55
-rw-r--r--src/modules/objects/class_file.cpp37
-rw-r--r--src/modules/objects/class_groupbox.cpp4
-rw-r--r--src/modules/objects/class_label.cpp25
-rw-r--r--src/modules/objects/class_layout.cpp11
-rw-r--r--src/modules/objects/class_listview.cpp4
-rw-r--r--src/modules/objects/class_mainwindow.cpp35
-rw-r--r--src/modules/objects/class_multilineedit.cpp20
-rw-r--r--src/modules/objects/class_painter.cpp2566
-rw-r--r--src/modules/objects/class_painter.h214
-rw-r--r--src/modules/objects/class_pixmap.cpp20
-rw-r--r--src/modules/objects/class_pixmap.h6
-rw-r--r--src/modules/objects/class_process.cpp9
-rw-r--r--src/modules/objects/class_process.h10
-rw-r--r--src/modules/objects/class_progressbar.cpp17
-rw-r--r--src/modules/objects/class_spinbox.cpp4
-rw-r--r--src/modules/objects/class_tabwidget.cpp12
-rw-r--r--src/modules/objects/class_toolbar.cpp1
-rw-r--r--src/modules/objects/class_toolbutton.cpp14
-rw-r--r--src/modules/objects/class_urllabel.cpp4
-rw-r--r--src/modules/objects/class_widget.cpp3655
-rw-r--r--src/modules/objects/class_widget.h247
-rw-r--r--src/modules/objects/class_window.cpp6
-rw-r--r--src/modules/objects/class_workspace.cpp4
-rw-r--r--src/modules/objects/class_wrapper.cpp52
-rw-r--r--src/modules/objects/libkviobjects.cpp88
28 files changed, 3777 insertions, 3371 deletions
diff --git a/src/modules/objects/class_button.cpp b/src/modules/objects/class_button.cpp
index fd8a4b3b5..e49627c3d 100644
--- a/src/modules/objects/class_button.cpp
+++ b/src/modules/objects/class_button.cpp
@@ -146,20 +146,8 @@ bool KviKvsObject_button::functionSetImage(KviKvsObjectFunctionCall *c)
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
- }
+ if(pix) ((QPushButton *)widget())->setIconSet(*pix);
+ else((QPushButton *)widget())->setIcon(QIconSet());
return true;
}
bool KviKvsObject_button::functionclickEvent(KviKvsObjectFunctionCall *c)
diff --git a/src/modules/objects/class_buttongroup.cpp b/src/modules/objects/class_buttongroup.cpp
index 9cdfc82d2..9c0eb3423 100644
--- a/src/modules/objects/class_buttongroup.cpp
+++ b/src/modules/objects/class_buttongroup.cpp
@@ -72,15 +72,9 @@ 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
-
-
+ QButtonGroup *group=new QButtonGroup(parentScriptWidget());
+ group->setObjectName(name());
+ setObject(group,true);
return true;
}
diff --git a/src/modules/objects/class_dockwindow.cpp b/src/modules/objects/class_dockwindow.cpp
index 2a79d109b..762b217ad 100644
--- a/src/modules/objects/class_dockwindow.cpp
+++ b/src/modules/objects/class_dockwindow.cpp
@@ -27,13 +27,8 @@
#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 <QDockWidget>
+#define QT_DOCK_WINDOW QDockWidget
#include <qlayout.h>
/*
@@ -96,13 +91,9 @@ KVSO_END_DESTRUCTOR(KviKvsObject_dockwindow)
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;
}
@@ -146,23 +137,14 @@ bool KviKvsObject_dockwindow::function_addWidget(KviKvsObjectFunctionCall *c)
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;
}
@@ -179,30 +161,22 @@ bool KviKvsObject_dockwindow::function_setOrientation(KviKvsObjectFunctionCall *
#endif //!COMPILE_USE_QT4
return true;
}
-
+// Fix me
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;
}
+// Fix me
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;
}
@@ -215,7 +189,6 @@ bool KviKvsObject_dockwindow::function_setAllowedDockAreas(KviKvsObjectFunctionC
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;
@@ -229,14 +202,7 @@ bool KviKvsObject_dockwindow::function_setAllowedDockAreas(KviKvsObjectFunctionC
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;
}
@@ -250,7 +216,6 @@ bool KviKvsObject_dockwindow::function_dock(KviKvsObjectFunctionCall * c)
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);
@@ -260,16 +225,6 @@ bool KviKvsObject_dockwindow::function_dock(KviKvsObjectFunctionCall * c)
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;
}
diff --git a/src/modules/objects/class_file.cpp b/src/modules/objects/class_file.cpp
index 55bbd4f29..87ef39b74 100644
--- a/src/modules/objects/class_file.cpp
+++ b/src/modules/objects/class_file.cpp
@@ -40,7 +40,6 @@ const char * const mod_tbl[] = {
"Append",
"Truncate"
};
-#ifdef COMPILE_USE_QT4
#define IO_RAW QIODevice::Unbuffered
#define IO_READONLY QIODevice::ReadOnly
#define IO_WRITEONLY QIODevice::WriteOnly
@@ -48,19 +47,7 @@ const char * const mod_tbl[] = {
#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,
@@ -226,7 +213,6 @@ bool KviKvsObject_file::functionopen(KviKvsObjectFunctionCall *c)
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
@@ -248,30 +234,7 @@ bool KviKvsObject_file::functionopen(KviKvsObjectFunctionCall *c)
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;
}
diff --git a/src/modules/objects/class_groupbox.cpp b/src/modules/objects/class_groupbox.cpp
index ce1a4fdc9..74474cba9 100644
--- a/src/modules/objects/class_groupbox.cpp
+++ b/src/modules/objects/class_groupbox.cpp
@@ -184,13 +184,9 @@ 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;
}
diff --git a/src/modules/objects/class_label.cpp b/src/modules/objects/class_label.cpp
index 01ae24fe5..4c5b9480b 100644
--- a/src/modules/objects/class_label.cpp
+++ b/src/modules/objects/class_label.cpp
@@ -45,7 +45,6 @@ const char * const align_tbl[] = {
"Bottom",
"WordBreak"
};
-#ifdef COMPILE_USE_QT4
#define QT_LABEL_ALIGNLEFT Qt::AlignLeft
#define QT_LABEL_ALIGNRIGHT Qt::AlignRight
#define QT_LABEL_ALIGNHCENTER Qt::AlignHCenter
@@ -54,16 +53,7 @@ const char * const align_tbl[] = {
#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,
@@ -277,21 +267,14 @@ bool KviKvsObject_label::functionSetAutoResize(KviKvsObjectFunctionCall *c)
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
+
}
+
+// FIX ME
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;
}
//
diff --git a/src/modules/objects/class_layout.cpp b/src/modules/objects/class_layout.cpp
index 1420aab9b..a214a3e55 100644
--- a/src/modules/objects/class_layout.cpp
+++ b/src/modules/objects/class_layout.cpp
@@ -26,17 +26,10 @@
#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
/*
@@ -258,11 +251,7 @@ bool KviKvsObject_layout::functionSetResizeMode(KviKvsObjectFunctionCall *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;
diff --git a/src/modules/objects/class_listview.cpp b/src/modules/objects/class_listview.cpp
index a32b17067..d3b64fbfe 100644
--- a/src/modules/objects/class_listview.cpp
+++ b/src/modules/objects/class_listview.cpp
@@ -26,12 +26,8 @@
#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"
diff --git a/src/modules/objects/class_mainwindow.cpp b/src/modules/objects/class_mainwindow.cpp
index 7a215f7ba..4b672cfb3 100644
--- a/src/modules/objects/class_mainwindow.cpp
+++ b/src/modules/objects/class_mainwindow.cpp
@@ -98,6 +98,7 @@ bool KviKvsObject_mainwindow::functionsetCentralWidget(KviKvsObjectFunctionCall
if(widget()) ((KviTalMainWindow *)widget())->setCentralWidget(((QWidget *)(pObject->object())));
return true;
}
+//FIX ME
bool KviKvsObject_mainwindow::functionsetDockEnabled(KviKvsObjectFunctionCall *c)
{
QString szDockarea;
@@ -108,27 +109,13 @@ bool KviKvsObject_mainwindow::functionsetDockEnabled(KviKvsObjectFunctionCall *c
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;
}
+
+//FIX ME
bool KviKvsObject_mainwindow::functionisDockEnabled(KviKvsObjectFunctionCall *c)
{
@@ -138,20 +125,6 @@ bool KviKvsObject_mainwindow::functionisDockEnabled(KviKvsObjectFunctionCall *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_multilineedit.cpp b/src/modules/objects/class_multilineedit.cpp
index 8be51a018..2e4437e86 100644
--- a/src/modules/objects/class_multilineedit.cpp
+++ b/src/modules/objects/class_multilineedit.cpp
@@ -29,27 +29,14 @@
#include "kvi_locale.h"
#include "kvi_malloc.h"
#include <qfile.h>
-#ifdef COMPILE_USE_QT4
- #include <q3multilineedit.h>
+#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"
@@ -1081,13 +1068,8 @@ bool KviKvsObject_mledit::functionloadFile(KviKvsObjectFunctionCall *c)
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();
diff --git a/src/modules/objects/class_painter.cpp b/src/modules/objects/class_painter.cpp
index 5c45910d2..c43ce6020 100644
--- a/src/modules/objects/class_painter.cpp
+++ b/src/modules/objects/class_painter.cpp
@@ -1,961 +1,1253 @@
-//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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
+//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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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"
+
+#include <QTextDocument>
+const Qt::PenStyle penstyles_cod[]= {
+ Qt::NoPen,
+ Qt::SolidLine,
+ Qt::DashLine,
+ Qt::DotLine,
+ Qt::DashDotLine,
+ Qt::DashDotDotLine
+};
+
+const char * const penstyles_tbl[] = {
+ "noPen",
+ "solidLine",
+ "dashLine",
+ "dotLine",
+ "dashDotLine",
+ "dashDotDotLine"
+};
+#define penstyles_num (sizeof(penstyles_tbl) / sizeof(penstyles_tbl[0]))
+
+
+const Qt::BrushStyle brushstyles_cod[]= {
+ Qt::NoBrush,
+ Qt::SolidPattern,
+ Qt::Dense1Pattern,
+ Qt::Dense2Pattern,
+ Qt::Dense3Pattern,
+ Qt::Dense4Pattern,
+ Qt::Dense5Pattern,
+ Qt::Dense6Pattern,
+ Qt::Dense7Pattern,
+ Qt::HorPattern,
+ Qt::VerPattern,
+ Qt::CrossPattern,
+ Qt::BDiagPattern,
+ Qt::FDiagPattern,
+ Qt::DiagCrossPattern
+};
+
+const char * const brushstyles_tbl[] = {
+ "NoBrush",
+ "SolidPattern",
+ "Dense1Pattern",
+ "Dense2Pattern",
+ "Dense3Pattern",
+ "Dense4Pattern",
+ "Dense5Pattern",
+ "Dense6Pattern",
+ "Dense7Pattern",
+ "HorPattern",
+ "VerPattern",
+ "CrossPattern",
+ "BDiagPattern",
+ "FDiagPattern",
+ "DiagCrossPattern"
+};
+#define brushstyles_num (sizeof(brushstyles_tbl) / sizeof(brushstyles_tbl[0]))
+
+
+/*
+ @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.
+ !fn: $setPen(<rgb or hsv array value or [<red>,<green>,<blue>][<hue>,<saturation>,<value>],[opacity],[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,"setPenStyle",functionsetPenStyle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setBrushStyle",functionsetBrushStyle)
+
+ 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)
+
+ // painter state
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"save",functionsave)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"restore",functionrestore)
+
+//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)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setGradientStart",functionsetGradientStart)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setGradientFinalStop",functionsetGradientStop)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setGradientColor",functionsetGradientColor)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setGradientAsBrush",functionsetGradientAsBrush)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"clearGradient",functionclearGradient)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setPenWidth",functionsetPenWidth)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawIcon",functiondrawIcon)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawHtmlText",functiondrawHtmlText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"htmlTextSize",functionhtmlTextSize)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"fillRect",functionfillRect)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"colorNames",functioncolorNames)
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"drawPath",functiondrawPath)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"resetPath",functionresetPath)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"pathAddText",functionpathAddText)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"pathMoveTo",functionpathMoveTo)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"pathLineTo",functionpathLineTo)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setPenJoinStyle",functionsetPenJoinStyle)
+ KVSO_REGISTER_HANDLER(KviKvsObject_painter,"setPenCapStyle",functionsetPenCapStyle)
+
+
+//
+
+ 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;
+ m_pPainterPath=0;
+ m_pGradient=0;
+
+KVSO_END_CONSTRUCTOR(KviKvsObject_painter)
+
+KVSO_BEGIN_DESTRUCTOR(KviKvsObject_painter)
+
+if (m_pPainterPath) delete m_pPainterPath;
+ m_pPainterPath=0;
+if (m_pGradient) delete m_pGradient;
+ m_pGradient=0;
+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_3OR4ARRAYPARAMETERS(__pCol1OrArray,__iCol2,__iCol3,__iOpacity)\
+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;\
+ }\
+ if(__pCol1OrArray->array()->size() > 3)\
+ {\
+ KviKvsVariant * c4 = __pCol1OrArray->array()->at(3);\
+ if(!(c4->asInteger(__iOpacity)))\
+ {\
+ c->error(__tr2qs("The opacity value 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,iX1,iY1;
+ 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("x1",KVS_PT_INT,KVS_PF_OPTIONAL,iX1)
+ KVSO_PARAMETER("y1",KVS_PT_INT,KVS_PF_OPTIONAL,iY1)
+ KVSO_PARAMETERS_END(c)
+ QString function="$drawLine";
+ KVSO_PARAMETERS_PAINTER(pXOrArray,iY,iX1,iY1)
+ if(m_pPainter) m_pPainter->drawLine(iX,iY,iX1,iY1);
+ 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)
+
+ 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)
+{
+
+ kvs_int_t iCol1,iCol2,iCol3,iOpacity;
+
+ KviKvsVariant *var1,*var2,*var3;
+ QString szColorMode,szColor;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("Color_1_Or_Colorname_Or_Pixmap",KVS_PT_VARIANT,0,var1)
+ KVSO_PARAMETER("Color_2",KVS_PT_VARIANT,KVS_PF_OPTIONAL,var2)
+ KVSO_PARAMETER("Colo3_3",KVS_PT_VARIANT,KVS_PF_OPTIONAL,var3)
+ KVSO_PARAMETER("color_mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szColorMode)
+ KVSO_PARAMETER("opacity",KVS_PT_INT,KVS_PF_OPTIONAL,iOpacity)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter) return true;
+
+ if(var1->isHObject())
+ {
+ kvs_hobject_t hObj;
+ var1->asHObject(hObj);
+ KviKvsObject *pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObj);
+ if (!pObject)
+ {
+ c->warning(__tr2qs("Pixmap parameter is not an object!"));
+ return true;
+ }
+ if(pObject->inherits("KviKvsObject_pixmap"))
+ m_pPainter->setBrush(*((KviKvsObject_pixmap *)pObject)->getPixmap());
+ else c->warning(__tr2qs("Object Pixmap required!"));
+ return true;
+ }
+ if (!var1->asInteger(iCol1))
+ {
+ var1->asString(szColor);
+ if (c->paramCount()<2) iOpacity=255;
+ else
+ {
+ if (!var2->asInteger(iOpacity))
+ {
+ c->warning("The opacity parameter didn't evaluate to integer");
+ return true;
+ }
+ }
+ QColor col(szColor);
+ col.setAlpha(iOpacity);
+ m_pPainter->setBrush(col);
+ }
+ else
+ {
+ if(c->paramCount()<3)
+ {
+ c->error(__tr2qs("Color name or triplette rgb/hsv value required"));
+ return true;
+ }
+ if (!var2->asInteger(iCol2)||!var3->asInteger(iCol3))
+ {
+ c->error(__tr2qs("One of the triplette parameters didn't evaluate to an integer"));\
+ return true;
+ }
+ if (c->paramCount()<5) iOpacity=255;
+ QColor col;
+ if(KviQString::equalCI(szColorMode, "HSV"))
+ col.setHsv(iCol1,iCol2,iCol3,iOpacity);
+ else
+ col.setRgb(iCol1,iCol2,iCol3,iOpacity);
+ m_pPainter->setBrush(col);
+
+ }
+ return true;
+}
+
+bool KviKvsObject_painter::functionsetPen(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iCol1,iCol2,iCol3,iOpacity;
+
+
+ QString szColorMode,szColor;
+ KviKvsVariant *var1,*var2,*var3;
+KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("Color_1_Or_Colorname",KVS_PT_VARIANT,0,var1)
+ KVSO_PARAMETER("Color_2",KVS_PT_VARIANT,KVS_PF_OPTIONAL,var2)
+ KVSO_PARAMETER("Colo3_3",KVS_PT_VARIANT,KVS_PF_OPTIONAL,var3)
+ KVSO_PARAMETER("color_mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szColorMode)
+ KVSO_PARAMETER("opacity",KVS_PT_INT,KVS_PF_OPTIONAL,iOpacity)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter) return true;
+
+ if (!var1->asInteger(iCol1))
+ {
+ var1->asString(szColor);
+ if (c->paramCount()<2) iOpacity=255;
+ else
+ {
+ if (!var2->asInteger(iOpacity))
+ {
+ c->warning("The opacity parameter didn't evaluate to integer");
+ return true;
+ }
+ }
+ QColor col(szColor);
+ col.setAlpha(iOpacity);
+ m_pPainter->setPen(col);
+ }
+ else
+ {
+ if(c->paramCount()<3)
+ {
+ c->error(__tr2qs("Color name or triplette rgb/hsv value required"));
+ return true;
+ }
+ if (!var2->asInteger(iCol2)||!var3->asInteger(iCol3))
+ {
+ c->error(__tr2qs("One of the triplette parameters didn't evaluate to an integer"));\
+ return true;
+ }
+ if (c->paramCount()<5) iOpacity=255;
+ QColor col;
+ if(KviQString::equalCI(szColorMode, "HSV"))
+ col.setHsv(iCol1,iCol2,iCol3,iOpacity);
+ else
+ col.setRgb(iCol1,iCol2,iCol3,iOpacity);
+ m_pPainter->setPen(col);
+
+ }
+
+
+
+ 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)
+ {
+ if (m_pPainter->isActive())
+ c->returnValue()->setInteger(m_pPainter->fontMetrics().width(szText));
+ else c->warning("$fontMetricsWidth: the painter is not active!");
+ }
+ return true;
+}
+
+bool KviKvsObject_painter::functionfontMetricsHeight(KviKvsObjectFunctionCall * c)
+{
+ if(m_pPainter)
+ {
+ if (m_pPainter->isActive())
+ c->returnValue()->setInteger(m_pPainter->fontMetrics().height());
+ else c->warning("$fontMetricsHeight: the painter is not active!");
+ }
+ 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;
+ if(pObject->inherits("KviKvsObject_pixmap"))pd=((KviKvsObject_pixmap *)pObject)->getPixmap();
+
+ else if (pObject->inherits("KviKvsObject_widget")) pd=((KviKvsObject_widget *)pObject)->widget();
+ else{
+ c->warning(__tr2qs("Widget or Pixmap required "));
+ return true;
+ }
+ attachDevice(pObject,pd);
+ 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;
+ 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);
+ return true;
+}
+
+
+
+bool KviKvsObject_painter::functiondrawPixmap(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t iX,iY;
+ kvs_int_t iStartx,iStarty,iEndx,iEndy;
+ bool bTiled;
+ KviKvsObject *obj;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_REAL,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_REAL,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_PARAMETER("b_Tiled",KVS_PT_BOOLEAN,KVS_PF_OPTIONAL,bTiled)
+ 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();
+ //if (bTiled) m_pPainter->drawTiledPixmap(iX,iY,iEndx,iEndy,*((KviKvsObject_pixmap *)obj)->getPixmap(),iStartx,iStarty);
+ //else
+ m_pPainter->drawPixmap(QPointF(iX,iY),*((KviKvsObject_pixmap *)obj)->getPixmap(),QRect(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 );
+ m_pPainter->rotate(dAngle);
+ 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;
+ m_pPainter->translate(dXtrasl,dYtrasl);
+ 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);
+ m_pPainter->shear(dShearh,dShearv);
+ 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);
+ m_pPainter->scale(dScalex,dScaley);
+ return true;
+}
+bool KviKvsObject_painter::functionresetMatrix(KviKvsObjectFunctionCall *c)
+
+{
+ if(!m_pPainter)return true;
+ //m_pMatrix.reset();
+ //m_pPainter->setWorldMatrix( m_pMatrix );
+ m_pPainter->resetMatrix();
+ return true;
+}
+
+bool KviKvsObject_painter::functiondrawHtmlText(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ kvs_int_t iX,iY,iW,iH;
+ 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("w",KVS_PT_INT,0,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,0,iH)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter)return true;
+ QTextDocument doc;
+ doc.setHtml(szText);
+ doc.setDefaultFont(m_pPainter->font());
+ m_pPainter->save();
+ m_pPainter->translate(iX,iY);
+ doc.setPageSize(QSize(iW,iH));
+ doc.drawContents(m_pPainter);
+ m_pPainter->restore();
+ return true;
+}
+bool KviKvsObject_painter::functionhtmlTextSize(KviKvsObjectFunctionCall *c)
+{
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ QTextDocument doc;
+ doc.setHtml(szText);
+ doc.setDefaultFont(m_pPainter->font());
+ QSizeF size=doc.size();
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_real_t)size.width()));
+ a->set(1,new KviKvsVariant((kvs_real_t)size.height()));
+ c->returnValue()->setArray(a);
+ return true;
+}
+
+
+bool KviKvsObject_painter::functiondrawIcon(KviKvsObjectFunctionCall *c)
+{
+ QString szIcon,szState;
+ kvs_int_t iX,iY,iW,iH;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
+
+ KVSO_PARAMETER("icon",KVS_PT_STRING,0,szIcon)
+
+ KVSO_PARAMETER("w",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
+
+ KVSO_PARAMETER("state",KVS_PT_STRING,KVS_PF_OPTIONAL,szState)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainter) return true;
+ QPixmap *pix=g_pIconManager->getImage(szIcon);
+ if (!pix)
+ {
+ c->warning("The icon '%Q' does not exists",&szIcon);
+ return true;
+ }
+ QSize pixsize(pix->width(),pix->height());
+
+ QIcon ico(*pix);
+ QIcon::Mode mode=QIcon::Normal;
+ if(!ico.isNull())
+ {
+ if (KviQString::equalCI(szState,"Disabled"))mode=QIcon::Disabled;
+ else if (KviQString::equalCI(szState,"Active"))mode=QIcon::Active;
+ else if (KviQString::equalCI(szState,"Selected"))mode=QIcon::Selected;
+ if (c->parameterCount()<5)
+ m_pPainter->drawPixmap(iX,iY,ico.pixmap(pixsize,mode));
+ else
+ m_pPainter->drawPixmap(iX,iY,ico.pixmap(QSize(iW,iH),mode));
+ }
+ return true;
+}
+
+
bool KviKvsObject_painter::functionsetOpacity(KviKvsObjectFunctionCall *c)
{
if(!m_pPainter)return true;
@@ -967,41 +1259,339 @@ bool KviKvsObject_painter::functionsetOpacity(KviKvsObjectFunctionCall *c)
m_pPainter->setOpacity(dOpacity);
return true;
}
-bool KviKvsObject_painter::functionsetTextAntialiasing(KviKvsObjectFunctionCall *c)
-{
+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 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)
-{
+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 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)
-{
+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;
+
+ 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;
+}
+bool KviKvsObject_painter::functionsetPenJoinStyle(KviKvsObjectFunctionCall *c)
+{
+ QString szStyle;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("style",KVS_PT_STRING,0,szStyle)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainter) return true;
+ Qt::PenJoinStyle style=Qt::BevelJoin;
+ if(KviQString::equalCI(szStyle,"Milter"))style=Qt::MiterJoin;
+ else if (KviQString::equalCI(szStyle,"Round"))style=Qt::RoundJoin;
+ QPen pen=m_pPainter->pen();
+ pen.setJoinStyle(style);
+ m_pPainter->setPen(pen);
+ return true;
+}
+
+bool KviKvsObject_painter::functionsetPenCapStyle(KviKvsObjectFunctionCall *c)
+{
+ QString szStyle;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("style",KVS_PT_STRING,0,szStyle)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainter) return true;
+ Qt::PenCapStyle style=Qt::SquareCap;
+ if(KviQString::equalCI(szStyle,"Flat")) style=Qt::FlatCap;
+ else if (KviQString::equalCI(szStyle,"Round"))style=Qt::RoundCap;
+ QPen pen=m_pPainter->pen();
+ pen.setCapStyle(style);
+ m_pPainter->setPen(pen);
+ return true;
}
-#endif
-
-#include "m_class_painter.moc"
+bool KviKvsObject_painter::functionsave(KviKvsObjectFunctionCall * c)
+{
+ if(m_pPainter)
+ m_pPainter->save();
+ return true;
+}
+
+bool KviKvsObject_painter::functionrestore(KviKvsObjectFunctionCall * c)
+{
+ if(m_pPainter)
+ m_pPainter->restore();
+ return true;
+}
+
+bool KviKvsObject_painter::functionsetPenStyle(KviKvsObjectFunctionCall *c)
+{
+ QString szStyle;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("style",KVS_PT_STRING,0,szStyle)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainter) return true;
+ bool found=false;
+ unsigned int j = 0;
+ for(; j < penstyles_num; j++)
+ {
+ if(KviQString::equalCI(szStyle,penstyles_tbl[j]))
+ {
+ found=true;
+ break;
+ }
+ }
+ QPen pen=m_pPainter->pen();
+ if (found){
+ pen.setStyle(penstyles_cod[j]);
+ m_pPainter->setPen(pen);
+ }
+ else c->warning(__tr2qs("Unknown pen style %Q"),&szStyle);
+ return true;
+}
+
+bool KviKvsObject_painter::functionsetBrushStyle(KviKvsObjectFunctionCall *c)
+{
+ QString szStyle;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("style",KVS_PT_STRING,0,szStyle)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainter) return true;
+ bool found=false;
+ unsigned int j = 0;
+ for(; j < brushstyles_num; j++)
+ {
+ if(KviQString::equalCI(szStyle,brushstyles_tbl[j]))
+ {
+ found=true;
+ break;
+ }
+ }
+ QBrush brush=m_pPainter->brush();
+ if (found){
+ brush.setStyle(brushstyles_cod[j]);
+ m_pPainter->setBrush(brush);
+ }
+ else c->warning(__tr2qs("Unknown brushn style %Q"),&szStyle);
+ return true;
+}
+
+
+
+bool KviKvsObject_painter::functionsetGradientStart(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dX,dY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_Point",KVS_PT_DOUBLE,0,dX)
+ KVSO_PARAMETER("y_Point",KVS_PT_DOUBLE,0,dY)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pGradient) m_pGradient=new(QLinearGradient);
+ m_pGradient->setStart(dX,dY);
+ return true;
+}
+bool KviKvsObject_painter::functionsetGradientStop(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dX,dY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x_Point",KVS_PT_DOUBLE,0,dX)
+ KVSO_PARAMETER("y_Point",KVS_PT_DOUBLE,0,dY)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pGradient) m_pGradient=new(QLinearGradient);
+ m_pGradient->setFinalStop(dX,dY);
+ return true;
+}
+bool KviKvsObject_painter::functionsetGradientColor(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dAt;
+ kvs_int_t iCol1,iCol2,iCol3,iOpacity;
+ KviKvsVariant *var1,*var2,*var3;
+ QString szColorMode,szColor;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("at",KVS_PT_DOUBLE,0,dAt)
+ KVSO_PARAMETER("Color_1_Or_Colorname",KVS_PT_VARIANT,0,var1)
+ KVSO_PARAMETER("Color_2",KVS_PT_VARIANT,KVS_PF_OPTIONAL,var2)
+ KVSO_PARAMETER("Colo3_3",KVS_PT_VARIANT,KVS_PF_OPTIONAL,var3)
+ KVSO_PARAMETER("color_mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szColorMode)
+ KVSO_PARAMETER("opacity",KVS_PT_INT,KVS_PF_OPTIONAL,iOpacity)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter) return true;
+
+ if (!var1->asInteger(iCol1))
+ {
+ var1->asString(szColor);
+ if (c->paramCount()<3) iOpacity=255;
+ else
+ {
+ if (!var2->asInteger(iOpacity))
+ {
+ c->warning("The opacity parameter didn't evaluate to integer");
+ return true;
+ }
+ }
+ if (!m_pGradient) m_pGradient=new(QLinearGradient);
+ QColor col(szColor);
+ col.setAlpha(iOpacity);
+ m_pGradient->setColorAt(dAt,col);
+ }
+ else
+ {
+ if(c->paramCount()<4)
+ {
+ c->error(__tr2qs("Color name or triplette rgb/hsv values required"));
+ return true;
+ }
+ if ( !var2->asInteger(iCol2)||!var3->asInteger(iCol3))
+ {
+ c->error(__tr2qs("One of the triplette parameters didn't evaluate to an integer"));\
+ return true;
+ }
+ if (c->paramCount()<5) iOpacity=255;
+ QColor col;
+ if(KviQString::equalCI(szColorMode, "HSV"))
+ col.setHsv(iCol1,iCol2,iCol3,iOpacity);
+ else
+ col.setRgb(iCol1,iCol2,iCol3,iOpacity);
+ if (!m_pGradient) m_pGradient=new(QLinearGradient);
+ m_pGradient->setColorAt(dAt,col);
+
+ }
+
+ return true;
+}
+bool KviKvsObject_painter::functionsetGradientAsBrush(KviKvsObjectFunctionCall *c)
+{
+ if (!m_pPainter) return true;
+ if (!m_pGradient) m_pGradient=new(QLinearGradient);
+ m_pPainter->setBrush(*m_pGradient);
+ return true;
+}
+bool KviKvsObject_painter::functionclearGradient(KviKvsObjectFunctionCall *c)
+{
+ if (!m_pGradient) delete m_pGradient;
+ m_pGradient=0;
+ return true;
+}
+bool KviKvsObject_painter::functionsetPenWidth(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t iWidth;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("width",KVS_PT_REAL,0,iWidth)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainter) return true;
+ QPen pen=m_pPainter->pen();
+ pen.setWidthF(iWidth);
+ m_pPainter->setPen(pen);
+ return true;
+}
+bool KviKvsObject_painter::functionfillRect(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iX,iY,iW,iH;
+ kvs_int_t iCol1,iCol2,iCol3,iOpacity;
+ QString szColorMode;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
+ KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
+ KVSO_PARAMETER("w",KVS_PT_INT,0,iW)
+ KVSO_PARAMETER("h",KVS_PT_INT,0,iH)
+ KVSO_PARAMETER("Color_1",KVS_PT_INT,0,iCol1)
+ KVSO_PARAMETER("Color_2",KVS_PT_INT,0,iCol2)
+ KVSO_PARAMETER("Colo3_3",KVS_PT_INT,0,iCol3)
+ KVSO_PARAMETER("opacity",KVS_PT_INT,KVS_PF_OPTIONAL,iOpacity)
+ KVSO_PARAMETER("color_mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szColorMode)
+ KVSO_PARAMETERS_END(c)
+ if(!m_pPainter) return true;
+ if (c->paramCount()<8) iOpacity=255;
+
+ QColor col;
+ if(KviQString::equalCI(szColorMode, "HSV"))
+ col.setHsv(iCol1,iCol2,iCol3,iOpacity);
+ else
+ col.setRgb(iCol1,iCol2,iCol3,iOpacity);
+ m_pPainter->fillRect(iX,iY,iW,iH,col);
+ return true;
+}
+bool KviKvsObject_painter::functioncolorNames(KviKvsObjectFunctionCall *c)
+{
+ QStringList color=QColor::colorNames();
+ KviKvsArray * a = new KviKvsArray();
+ //a->set(0,new KviKvsVariant((kvs_int_t)col.red()));
+ for(int i=0;i<color.count();i++)
+ {
+ a->set(i,new KviKvsVariant(color.at(i)));
+ }
+ c->returnValue()->setArray(a);
+ return true;
+}
+bool KviKvsObject_painter::functionpathMoveTo(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dX,dY;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_REAL,0,dX)
+ KVSO_PARAMETER("y",KVS_PT_REAL,0,dY)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainterPath) m_pPainterPath=new QPainterPath(QPointF(0,0));
+ m_pPainterPath->moveTo(dX,dY);
+ return true;
+}
+bool KviKvsObject_painter::functionpathLineTo(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dX,dY;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_REAL,0,dX)
+ KVSO_PARAMETER("y",KVS_PT_REAL,0,dY)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainterPath) m_pPainterPath=new QPainterPath(QPointF(0,0));
+ m_pPainterPath->lineTo(dX,dY);
+ return true;
+}
+bool KviKvsObject_painter::functionpathAddText(KviKvsObjectFunctionCall *c)
+{
+ kvs_real_t dX,dY;
+ QString szText;
+
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_REAL,0,dX)
+ KVSO_PARAMETER("y",KVS_PT_REAL,0,dY)
+ KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ if (!m_pPainterPath) m_pPainterPath=new QPainterPath(QPointF(0,0));
+ m_pPainterPath->addText(dX,dY,m_pPainter->font(),szText);
+ return true;
+}
+bool KviKvsObject_painter::functiondrawPath(KviKvsObjectFunctionCall *c)
+{
+ if (m_pPainter) m_pPainter->drawPath(*m_pPainterPath);
+ //delete m_pPainterPath;
+ //m_pPainterPath=0;
+ return true;
+}
+bool KviKvsObject_painter::functionresetPath(KviKvsObjectFunctionCall *c)
+{
+ if (m_pPainterPath){
+ delete m_pPainterPath;
+ m_pPainterPath=0;
+ }
+ return true;
+}
+
+
+
+#include "m_class_painter.moc"
diff --git a/src/modules/objects/class_painter.h b/src/modules/objects/class_painter.h
index 44ceb1e41..067bc6097 100644
--- a/src/modules/objects/class_painter.h
+++ b/src/modules/objects/class_painter.h
@@ -1,96 +1,118 @@
-#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_
-
-
-
+#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+
+
+#include <qpainter.h>
+#include <qpaintdevice.h>
+#include "kvi_string.h"
+#include <QPainterPath>
+#include "object_macros.h"
+
+
+class KviKvsObject_painter : public KviKvsObject
+{
+ Q_OBJECT
+public:
+ KVSO_DECLARE_OBJECT(KviKvsObject_painter)
+protected:
+ QPainter * m_pPainter;
+ QWMatrix m_pMatrix;
+ QLinearGradient *m_pGradient;
+ QPainterPath *m_pPainterPath;
+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 functionsave(KviKvsObjectFunctionCall *c);
+ bool functionrestore(KviKvsObjectFunctionCall *c);
+
+
+ bool functionscaleMatrix(KviKvsObjectFunctionCall *c);
+ bool functionshearMatrix(KviKvsObjectFunctionCall *c);
+ bool functionrotateMatrix(KviKvsObjectFunctionCall *c);
+ bool functionresetMatrix(KviKvsObjectFunctionCall *c);
+ bool functiontranslateMatrix(KviKvsObjectFunctionCall *c);
+ bool functionsetPenStyle(KviKvsObjectFunctionCall *c);
+ bool functionsetBrushStyle(KviKvsObjectFunctionCall *c);
+
+// QT4
+ bool functionsetOpacity(KviKvsObjectFunctionCall *c);
+ bool functionsetSmoothPixmapTransform(KviKvsObjectFunctionCall *c);
+ bool functionsetTextAntialiasing(KviKvsObjectFunctionCall *c);
+ bool functionsetAntialiasing(KviKvsObjectFunctionCall *c);
+ bool functionsetGradientStart(KviKvsObjectFunctionCall *c);
+ bool functionsetGradientStop(KviKvsObjectFunctionCall *c);
+ bool functionsetGradientColor(KviKvsObjectFunctionCall *c);
+ bool functionsetGradientAsBrush(KviKvsObjectFunctionCall *c);
+ bool functionclearGradient(KviKvsObjectFunctionCall *c);
+
+ bool functiondrawIcon(KviKvsObjectFunctionCall *c);
+ bool functiondrawHtmlText(KviKvsObjectFunctionCall *c);
+ bool functionhtmlTextSize(KviKvsObjectFunctionCall *c);
+ bool functionfillRect(KviKvsObjectFunctionCall *c);
+ bool functionsetPenWidth(KviKvsObjectFunctionCall *c);
+ bool functioncolorNames(KviKvsObjectFunctionCall *c);
+ bool functionpathMoveTo(KviKvsObjectFunctionCall *c);
+ bool functionpathLineTo(KviKvsObjectFunctionCall *c);
+ bool functiondrawPath(KviKvsObjectFunctionCall *c);
+ bool functionsetPenJoinStyle(KviKvsObjectFunctionCall *c);
+ bool functionsetPenCapStyle(KviKvsObjectFunctionCall *c);
+ bool functionpathAddText(KviKvsObjectFunctionCall *c);
+ bool functionresetPath(KviKvsObjectFunctionCall *c);
+
+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
index c24ef09ab..1a73a2db3 100644
--- a/src/modules/objects/class_pixmap.cpp
+++ b/src/modules/objects/class_pixmap.cpp
@@ -127,13 +127,7 @@ bool KviKvsObject_pixmap::functionscale(KviKvsObjectFunctionCall *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
+ *m_pPixmap = m_pPixmap->scaled((m_pPixmap->width() * uScaleX), (m_pPixmap->height() * uScaleX));
bPixmapModified=true;
return true;
}
@@ -144,15 +138,9 @@ bool KviKvsObject_pixmap::functionrotate(KviKvsObjectFunctionCall *c)
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
+ QMatrix m;
+ m.rotate(uDegrees);
+ *m_pPixmap = m_pPixmap->transformed(m);
bPixmapModified=true;
return true;
}
diff --git a/src/modules/objects/class_pixmap.h b/src/modules/objects/class_pixmap.h
index ace74d59e..f79c29f86 100644
--- a/src/modules/objects/class_pixmap.h
+++ b/src/modules/objects/class_pixmap.h
@@ -26,11 +26,7 @@
#include <qpixmap.h>
#include <qimage.h>
-#ifdef COMPILE_USE_QT4
- #include <QMatrix>
-#else
- #include <qwmatrix.h>
-#endif
+#include <QMatrix>
#include "kvi_string.h"
diff --git a/src/modules/objects/class_process.cpp b/src/modules/objects/class_process.cpp
index e0951b14e..f0be51875 100644
--- a/src/modules/objects/class_process.cpp
+++ b/src/modules/objects/class_process.cpp
@@ -26,11 +26,8 @@
#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
@@ -184,11 +181,7 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_process,"process","object")
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()));
diff --git a/src/modules/objects/class_process.h b/src/modules/objects/class_process.h
index fe4be1c0e..09a584adb 100644
--- a/src/modules/objects/class_process.h
+++ b/src/modules/objects/class_process.h
@@ -28,11 +28,7 @@
#include "object_macros.h"
-#ifdef COMPILE_USE_QT4
#include <q3process.h>
-#else
-#include <qprocess.h>
-#endif
class KviKvsObject_process : public KviKvsObject
@@ -41,13 +37,7 @@ class KviKvsObject_process : public KviKvsObject
public:
KVSO_DECLARE_OBJECT(KviKvsObject_process)
protected:
-
-#ifdef COMPILE_USE_QT4
Q3Process * m_pProcess;
-#else
- QProcess * m_pProcess;
-#endif
-
public:
bool functionaddArgument(KviKvsObjectFunctionCall *c);
diff --git a/src/modules/objects/class_progressbar.cpp b/src/modules/objects/class_progressbar.cpp
index 7d106f4e2..f0363657e 100644
--- a/src/modules/objects/class_progressbar.cpp
+++ b/src/modules/objects/class_progressbar.cpp
@@ -27,13 +27,8 @@
#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
@@ -95,14 +90,10 @@ 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;
+ Q3ProgressBar *pbar=new Q3ProgressBar(parentScriptWidget());
+ pbar->setObjectName(name());
+ setObject(pbar,true);
+ return true;
}
bool KviKvsObject_progressbar::functionSetProgress(KviKvsObjectFunctionCall *c)
diff --git a/src/modules/objects/class_spinbox.cpp b/src/modules/objects/class_spinbox.cpp
index 6b0147f24..a4e34494b 100644
--- a/src/modules/objects/class_spinbox.cpp
+++ b/src/modules/objects/class_spinbox.cpp
@@ -198,11 +198,7 @@ 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;
diff --git a/src/modules/objects/class_tabwidget.cpp b/src/modules/objects/class_tabwidget.cpp
index 998bb3f44..7e0df3a74 100644
--- a/src/modules/objects/class_tabwidget.cpp
+++ b/src/modules/objects/class_tabwidget.cpp
@@ -216,11 +216,7 @@ bool KviKvsObject_tabwidget::functionaddTab(KviKvsObjectFunctionCall *c)
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;
@@ -257,11 +253,7 @@ bool KviKvsObject_tabwidget::functioninsertTab(KviKvsObjectFunctionCall *c)
}
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;
@@ -499,11 +491,7 @@ bool KviKvsObject_tabwidget::functionchangeTab(KviKvsObjectFunctionCall *c)
}
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;
diff --git a/src/modules/objects/class_toolbar.cpp b/src/modules/objects/class_toolbar.cpp
index a6cb24c99..72ff1513f 100644
--- a/src/modules/objects/class_toolbar.cpp
+++ b/src/modules/objects/class_toolbar.cpp
@@ -115,6 +115,7 @@ bool KviKvsObject_toolbar::functionlabel(KviKvsObjectFunctionCall *c)
if (widget()) c->returnValue()->setString(((KviTalToolBar *)widget())->label());
return true;
}
+//FIX ME
bool KviKvsObject_toolbar::functionsetStretchableWidget(KviKvsObjectFunctionCall *c)
{
KviKvsObject *ob;
diff --git a/src/modules/objects/class_toolbutton.cpp b/src/modules/objects/class_toolbutton.cpp
index 3a531da30..b2d3e651b 100644
--- a/src/modules/objects/class_toolbutton.cpp
+++ b/src/modules/objects/class_toolbutton.cpp
@@ -143,11 +143,7 @@ bool KviKvsObject_toolbutton::functionsetImage(KviKvsObjectFunctionCall *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());
@@ -237,14 +233,8 @@ bool KviKvsObject_toolbutton::functionsetTextLabel(KviKvsObjectFunctionCall *c)
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
+ ((QToolButton *)widget())->setText(szLabel);
+ if (!szTip.isEmpty()) ((QToolButton *)widget())->setToolTip(szTip);
return true;
}
bool KviKvsObject_toolbutton::functiontextLabel(KviKvsObjectFunctionCall *c)
diff --git a/src/modules/objects/class_urllabel.cpp b/src/modules/objects/class_urllabel.cpp
index da13c9891..7f4d672bc 100644
--- a/src/modules/objects/class_urllabel.cpp
+++ b/src/modules/objects/class_urllabel.cpp
@@ -32,12 +32,8 @@
#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()"
diff --git a/src/modules/objects/class_widget.cpp b/src/modules/objects/class_widget.cpp
index db3da521f..0a90181ec 100644
--- a/src/modules/objects/class_widget.cpp
+++ b/src/modules/objects/class_widget.cpp
@@ -1,1745 +1,1910 @@
-//=============================================================================
-//
-// 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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"
+//=============================================================================
+//
+// 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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"
+
+#include <QKeyEvent>
+#include <QDesktopWidget>
+
+#include <qwidget.h>
+#include <qtooltip.h>
+#include <qfont.h>
+#include <qvariant.h>
+
+KviKvsWidget::KviKvsWidget(KviKvsObject_widget * object,QWidget * par)
+:QWidget(par), m_pObject(object)
+{
+}
+KviKvsWidget::~KviKvsWidget()
+{
+}
+
+
+QSize KviKvsWidget::sizeHint() const
+{
+ QSize size=QWidget::sizeHint();
+ KviKvsVariant *tipret=new KviKvsVariant();
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)size.width()),new KviKvsVariant((kvs_int_t)size.height()));
+ m_pObject->callFunction(m_pObject,"sizeHintRequestEvent",tipret,&params);
+ if (tipret->isArray())
+ {
+ if (tipret->array()->size()==2)
+ {
+ kvs_int_t w,h;
+ if (tipret->array()->at(0)->asInteger(w) && tipret->array()->at(1)->asInteger(h))return QSize(w,h);
+ }
+ }
+ return QWidget::sizeHint();
+}
+
+
+// FIX ME: WFLAGS
+const char * const widgettypes_tbl[] = {
+ "TopLevel",
+ "Dialog",
+ "Popup",
+ "Desktop",
+ "Customize",
+ "Title",
+ "StaysOnTop",
+ "SysMenu",
+ "Minimize",
+ "Maximize",
+ "NoAutoErase"
+ };
+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 QPalette::ColorRole colorrole_cod[]= {
+ QPalette::Window,
+ QPalette::Background,
+ QPalette::WindowText,
+ QPalette::Foreground,
+ QPalette::Base,
+ QPalette::AlternateBase,
+ QPalette::Text,
+ QPalette::Button,
+ QPalette::ButtonText,
+ QPalette::BrightText,
+ QPalette::Highlight,
+ QPalette::HighlightedText,
+};
+
+const char * const colorrole_tbl[] = {
+ "Window",
+ "Background",
+ "WindowText",
+ "Foreground",
+ "Base",
+ "AlternateBase",
+ "Text",
+ "Button",
+ "ButtonText",
+ "BrightText",
+ "Highlight",
+ "HighlightedText"
+};
+#define colorrole_num (sizeof(colorrole_tbl) / sizeof(colorrole_tbl[0]))
+
+
+const Qt::WindowType widgettypes_cod[] = {
+ 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
+};
+
+
+
+ #define QT_WIDGET_TABFOCUS Qt::TabFocus
+ #define QT_WIDGET_CLICKFOCUS Qt::ClickFocus
+ #define QT_WIDGET_STRONGFOCUS Qt::StrongFocus
+ #define QT_WIDGET_NOFOCUS Qt::NoFocus
+
+
+
+#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: $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.
+ !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: integer $setAttribute(<string>,<bool_flag>)[QT4 only]
+ Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
+ Valid attributes are:
+ OpaquePaintEvent - Indicates that the widget paints all its pixels when it receives a paint event.
+ NoSystemBackground - Indicates that the widget has no background, i.e. when the widget receives paint events, the background is not automatically repainted.
+ PaintOnScreen - Indicates that the widget wants to draw directly onto the screen.
+ NoMousePropagation - Prohibits mouse events from being propagated to the widget's parent.
+ !fn: $setStyleSheet(<string>)[QT4 only]
+
+ !fn: $array(<red:integer,green:integer,blue:integer) $colorPalette(<color_role:string><color_group:string>)[QT4 only]
+ Returns the color in color_group(disabled, active or inactive), used for color_role.
+ Valid color role are:
+ Window - A general background color.
+ WindowText - A general foreground color.
+ Base - Used as the background color for text.
+ Text - Used as foreground color for the text.
+ Button - The general button background color.
+ ButtonText - A foreground color used with the Button color.
+ Highlight - A color to indicate a selected item or the current item.
+ HighlightedText - A text color that contrasts with Highlight.
+
+ !fn: <short_cut_id:integer> $setKeyShortCut(<key:char>)[QT4 only]
+ Adds a shortcut whith key. A [classfnc]$shortCutEvent[/classfnc] will be triggered when the user will press alt+key.
+ !fn: $shortCutEvent(<shortcut_id:integer>)[QT4 only]
+ This function will be called when a shortcut key has been triggered.
+ You must reimplement this event to manage a shortcut system in a custom widget.
+ The default implementation does nothing.
+ @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 $$->$parent()
+ # This closes the widget automatically
+ }
+
+ [/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,"update",function_update)
+
+ 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
+
+
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setAttribute",function_setAttribute)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"colorPalette",function_colorPalette)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setStyleSheet",function_setStyleSheet)
+ KVSO_REGISTER_HANDLER(KviKvsObject_widget,"setKeyShortcut",function_setKeyShortcut)
+
+ // 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")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"sizeHintRequestEvent")
+// QT4
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"maybeTipEvent")
+ KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_widget,"shortCutEvent")
+
+
+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)
+{
+ //QWidget *pis=new QWidget(parentScriptWidget(),getName()),true);
+ //setObject(new QWidget(parentScriptWidget(),getName()),true);
+ setObject(new KviKvsWidget(this,parentScriptWidget()));
+// setObject(new QWidget(parentScriptWidget()));
+
+ widget()->setObjectName(getName());
+ 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())
+ {
+
+ case QEvent::Shortcut:
+ {
+ KviKvsVariantList params(new KviKvsVariant((kvs_int_t)((QShortcutEvent *)e)->shortcutId()));
+ callFunction(this,"shortCutEvent",retv,&params);
+ break;
+ }
+ 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);
+ if (!szTooltip.isEmpty()) QToolTip::showText(helpEvent->globalPos(),szTooltip);
+ break;
+ }
+ 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_update(KviKvsObjectFunctionCall *c)
+{
+ kvs_int_t iX,iY,iW,iH;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("x",KVS_PT_INT,KVS_PF_OPTIONAL,iX)
+ 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)
+ if(!widget())return true; // should we warn here ?
+ if (iW || iH) widget()->update(QRect(iX,iY,iW,iH));
+ else
+ widget()->update();
+ 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)
+ widget()->setToolTip(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)
+{
+ debug ("Kvs WIDGET size hint");
+ if(!widget())return true;
+ //QVariant pro=widget()->property("sizeHint");
+ 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;
+ Qt::WindowFlags flag,sum=0;
+ 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));
+
+ }
+
+ widget()->setWindowFlags(sum);
+ 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){
+ QPalette palette=widget()->palette();
+ palette.setBrush(widget()->backgroundRole(), QBrush(*pix));
+ widget()->setPalette(palette);
+ }
+ else
+ {
+ c->warning("The pixmap is not valid");
+ return true;
+ }
+ 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();
+ QBitmap mask(pm->mask());
+ if (mask.isNull()) c->warning(__tr2qs("Null mask"));
+ widget()->setMask(mask);
+ return true;
+}
+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;
+}
+bool KviKvsObject_widget::function_colorPalette(KviKvsObjectFunctionCall *c)
+{
+ QString szColorRole,szColorGroup;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("color_role",KVS_PT_STRING,0,szColorRole)
+ KVSO_PARAMETER("color_group",KVS_PT_STRING,0,szColorGroup)
+ KVSO_PARAMETERS_END(c)
+ if (!widget()) return true;
+ bool found=false;
+ unsigned int j = 0;
+ for(; j < colorrole_num; j++)
+ {
+ if(KviQString::equalCI(szColorRole, colorrole_tbl[j]))
+ {
+ found=true;
+ break;
+ }
+ }
+ if(!found)
+ {
+ c->warning(__tr2qs("Unknown Color Role '%Q'"),&szColorRole);
+ return true;
+ }
+ QPalette::ColorGroup cg;
+ if (KviQString::equalCI(szColorGroup,"Disabled")) cg=QPalette::Disabled;
+ else if (KviQString::equalCI(szColorGroup,"Active")) cg=QPalette::Active;
+ else if (KviQString::equalCI(szColorGroup,"Inactive")) cg=QPalette::Inactive;
+ else
+ {
+ c->warning(__tr2qs("Unknown Color Group '%Q'"),&szColorGroup);
+ return true;
+ }
+ QColor col=widget()->palette().color(cg,colorrole_cod[j]);
+ 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_setStyleSheet(KviKvsObjectFunctionCall *c)
+{
+ QString szStyleSheet;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("style_sheet",KVS_PT_STRING,0,szStyleSheet)
+ KVSO_PARAMETERS_END(c)
+ if(widget())widget()->setStyleSheet(szStyleSheet);
+ return true;
+}
+bool KviKvsObject_widget::function_setKeyShortcut(KviKvsObjectFunctionCall *c)
+{
+ QString szKey;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("key",KVS_PT_STRING,0,szKey)
+ KVSO_PARAMETERS_END(c)
+ szKey.prepend("&");
+ if (widget())c->returnValue()->setInteger((kvs_int_t)widget()->grabShortcut(QKeySequence::mnemonic(szKey)));
+ return true;
+}
+
+#include "m_class_widget.moc"
diff --git a/src/modules/objects/class_widget.h b/src/modules/objects/class_widget.h
index d5c18e61a..33fbf9455 100644
--- a/src/modules/objects/class_widget.h
+++ b/src/modules/objects/class_widget.h
@@ -1,113 +1,134 @@
-#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_
+#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_update(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);
+
+
+
+//QT4
+bool function_setAttribute(KviKvsObjectFunctionCall *c);
+ bool function_colorPalette(KviKvsObjectFunctionCall *c);
+ bool function_setStyleSheet(KviKvsObjectFunctionCall *c);
+ bool function_setKeyShortcut(KviKvsObjectFunctionCall *c);
+
+signals:
+ void aboutToDie();
+};
+
+class KviKvsWidget : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QSize sizeHint READ sizeHint)
+public:
+ KviKvsWidget(KviKvsObject_widget * ob,QWidget * par);
+
+
+ virtual ~KviKvsWidget();
+protected:
+ KviKvsObject_widget * m_pObject;
+public:
+ QSize sizeHint() const;
+};
+#endif // !_CLASS_WIDGET_H_
diff --git a/src/modules/objects/class_window.cpp b/src/modules/objects/class_window.cpp
index 7bcbea852..46e6d37bf 100644
--- a/src/modules/objects/class_window.cpp
+++ b/src/modules/objects/class_window.cpp
@@ -36,12 +36,8 @@ KviKvsScriptWindowWindow::KviKvsScriptWindowWindow(KviFrame * pParent,const QStr
: KviWindow(KVI_WINDOW_TYPE_SCRIPTOBJECT,pParent,szName)
{
m_pCentralWidget = 0;
- #ifdef COMPILE_USE_QT4
setBackgroundMode(Qt::NoBackground);
- #else
- setBackgroundMode(QWidget::NoBackground);
- #endif
-}
+ }
KviKvsScriptWindowWindow::~KviKvsScriptWindowWindow()
{
diff --git a/src/modules/objects/class_workspace.cpp b/src/modules/objects/class_workspace.cpp
index 96e7d2f21..cb2adace8 100644
--- a/src/modules/objects/class_workspace.cpp
+++ b/src/modules/objects/class_workspace.cpp
@@ -252,11 +252,7 @@ bool KviKvsObject_workspace::functionactivateNextWindow(KviKvsObjectFunctionCall
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_wrapper.cpp b/src/modules/objects/class_wrapper.cpp
index 464f10f85..1eddbe73d 100644
--- a/src/modules/objects/class_wrapper.cpp
+++ b/src/modules/objects/class_wrapper.cpp
@@ -30,10 +30,6 @@
#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"
@@ -182,7 +178,6 @@ bool KviKvsObject_wrapper::init(KviKvsRunTimeContext * pContext,KviKvsVariantLis
}
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++)
@@ -203,39 +198,11 @@ QWidget *KviKvsObject_wrapper::findTopLevelWidgetToWrap(const QString szClass, c
}
}
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++)
@@ -247,23 +214,6 @@ QWidget *KviKvsObject_wrapper::findWidgetToWrap(const char *szClass, const char
}
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/libkviobjects.cpp b/src/modules/objects/libkviobjects.cpp
index d4806d91a..a0347db92 100644
--- a/src/modules/objects/libkviobjects.cpp
+++ b/src/modules/objects/libkviobjects.cpp
@@ -39,10 +39,6 @@
#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>
@@ -638,6 +634,8 @@ static bool objects_kvs_cmd_bitBlt(KviKvsModuleCommandCall * c)
if(obDst->inherits("KviKvsObject_pixmap")){
((KviKvsObject_pixmap *)obDst)->pixmapChanged();
}
+
+ //FIX ME
#ifdef COMPILE_USE_QT4
/*QPainter p(pdDest);
QRect rectdest(iXdst,iYdst,uW,uH);
@@ -779,13 +777,9 @@ static bool objects_kvs_cmd_blend(KviKvsModuleCommandCall * c)
}
-#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;
}
@@ -826,8 +820,7 @@ static bool objects_kvs_fnc_listObjects(KviKvsModuleFunctionCall * 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();
+ QWidgetList list = g_pApp->topLevelWidgets();
KviStr spacing = ">";
QString szTemp;
@@ -864,55 +857,12 @@ static bool objects_kvs_fnc_listObjects(KviKvsModuleFunctionCall * cmd)
//++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);
@@ -941,38 +891,6 @@ static void dumpChildObjects(KviWindow *pWnd, QObject *parent, const char *spaci
}
}
-#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)