From 14d0fbe96c6abdb9da80e99953aec672f999948c Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 13 Dec 2020 19:22:19 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- ksvg/test/external/CMakeLists.txt | 2 +- ksvg/test/external/Makefile.am | 2 +- ksvg/test/external/SVGTestWidget.cc | 204 ----------------------------------- ksvg/test/external/SVGTestWidget.cpp | 204 +++++++++++++++++++++++++++++++++++ ksvg/test/external/svgdisplay.cc | 32 ------ ksvg/test/external/svgdisplay.cpp | 32 ++++++ 6 files changed, 238 insertions(+), 238 deletions(-) delete mode 100644 ksvg/test/external/SVGTestWidget.cc create mode 100644 ksvg/test/external/SVGTestWidget.cpp delete mode 100644 ksvg/test/external/svgdisplay.cc create mode 100644 ksvg/test/external/svgdisplay.cpp (limited to 'ksvg/test') diff --git a/ksvg/test/external/CMakeLists.txt b/ksvg/test/external/CMakeLists.txt index 60c588a3..a07e0406 100644 --- a/ksvg/test/external/CMakeLists.txt +++ b/ksvg/test/external/CMakeLists.txt @@ -32,7 +32,7 @@ link_directories( ##### svgdisplay (executable) ################### tde_add_executable( svgdisplay AUTOMOC - SOURCES SVGTestWidget.cc svgdisplay.cc + SOURCES SVGTestWidget.cpp svgdisplay.cpp LINK ksvg-shared DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/ksvg/test/external/Makefile.am b/ksvg/test/external/Makefile.am index 9a624667..b2b8c494 100644 --- a/ksvg/test/external/Makefile.am +++ b/ksvg/test/external/Makefile.am @@ -4,7 +4,7 @@ KDE_CXXFLAGS = $(USE_EXCEPTIONS) bin_PROGRAMS = svgdisplay printnodetest -svgdisplay_SOURCES = SVGTestWidget.cc svgdisplay.cc +svgdisplay_SOURCES = SVGTestWidget.cpp svgdisplay.cpp svgdisplay_LDADD = $(LIB_TDECORE) ../../libksvg.la svgdisplay_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor diff --git a/ksvg/test/external/SVGTestWidget.cc b/ksvg/test/external/SVGTestWidget.cc deleted file mode 100644 index 895b5357..00000000 --- a/ksvg/test/external/SVGTestWidget.cc +++ /dev/null @@ -1,204 +0,0 @@ -// Very small test app to look at ksvg performance without konqueror overhead (Rob) - -#include "SVGTestWidget.moc" -#include "DocumentFactory.h" -#include "CanvasFactory.h" -#include "SVGCircleElement.h" -#include "SVGAnimatedLength.h" -#include "SVGLength.h" -#include "SVGSVGElement.h" -#include "SVGEventImpl.h" -#include "KSVGCanvas.h" -#include "CanvasItem.h" -#include - -using namespace KSVG; - -SVGTestWidget::SVGTestWidget(const KURL &url) -{ - setBackgroundColor(TQt::white); - setMouseTracking(true); - setFocusPolicy(TQ_WheelFocus); - - m_doc = DocumentFactory::self()->requestDocument(TQT_TQOBJECT(this), TQT_SLOT(slotRenderingFinished())); - if(!m_doc) - return; - - resize(450, 450); - m_canvas = CanvasFactory::self()->loadCanvas(450, 450); - if(!m_canvas) - return; - - m_canvas->setup(TQT_TQPAINTDEVICE(this), TQT_TQPAINTDEVICE(this)); - - if(!DocumentFactory::self()->attachCanvas(m_canvas, m_doc)) - return; - - if(!DocumentFactory::self()->startParsing(m_doc, url)) - return; -} - -SVGTestWidget::~SVGTestWidget() -{ - delete m_canvas; - delete m_doc; -} - -void SVGTestWidget::slotRenderingFinished() -{ - TQRect rect(0, 0, width(), height()); - m_canvas->blit(rect, true); - - SVGElement test = m_doc->rootElement().getElementById("test"); - if(test.nodeName() == "circle") - { - SVGCircleElement c = dom_cast(SVGCircleElement, test); - c.r().baseVal().setValue(150); - c.setAttribute("fill", "blue"); - } -} - -void SVGTestWidget::paintEvent(TQPaintEvent *event) -{ - m_canvas->update(); - m_canvas->blit(event->rect(), true); -} - -void SVGTestWidget::resizeEvent(TQResizeEvent *event) -{ - int w = event->size().width(); - int h = event->size().height(); - - m_canvas->resize(w, h); - resize(w, h); - m_canvas->blit(); -} -/* -KSVG::SVGMouseEventImpl *newMouseEvent(SVGDocument *doc, KSVG::SVGEventImpl::EventId id, TQMouseEvent *event) -{ - DOM::AbstractView temp; - - int clientX = event->x(); - int clientY = event->y(); - - if(doc && doc->rootElement()) - { - clientX = int(clientX / doc->rootElement()->currentScale()); - clientY = int(clientY / doc->rootElement()->currentScale()); - } - - int button = 0; - if(event->stateAfter() & Qt::LeftButton) - button = 1; - else if(event->stateAfter() & Qt::MidButton) - button = 2; - else if(event->stateAfter() & Qt::RightButton) - button = 3; - - KSVG::SVGMouseEventImpl *mev = new KSVG::SVGMouseEventImpl(id, // type - true, // canBubbleArg - true, // cancelableArg - temp, // view - 0, // detail - event->globalX(), //screenXArg - event->globalY(), // screenYArg, - clientX, // clientXArg - clientY, // clientYArg - (event->state() & TQt::ControlButton), // ctrlKeyArg - (event->state() & TQt::AltButton), // altKeyArg - (event->state() & TQt::ShiftButton), // shiftKeyArg - (event->state() & TQt::MetaButton), // metaKeyArg - button, // buttonArg - 0); - - mev->ref(); - - return mev; -} - -void SVGTestWidget::mouseMoveEvent(TQMouseEvent *event) -{ - if(event->state() & TQMouseEvent::ControlButton && event->state() & TQMouseEvent::LeftButton) - { - if(m_panningPos.isNull()) - m_panningPos = event->pos(); - else - { - TQPoint panPoint = m_oldPanningPos - (m_panningPos - event->pos()); - m_doc->rootElement()->setCurrentTranslate(panPoint); -// m_doc->syncCachedMatrices(); FIXME - m_canvas->update(panPoint); - } - return; - } - else if(event->state() & TQMouseEvent::ControlButton) - return; -} - -void SVGTestWidget::mousePressEvent(TQMouseEvent *event) -{ - if(event->state() & TQMouseEvent::ControlButton) - return; - - KSVG::SVGMouseEventImpl *mev = newMouseEvent(m_doc, KSVG::SVGEventImpl::MOUSEDOWN_EVENT, event); - - if(m_doc && m_doc->rootElement()) - m_doc->rootElement()->prepareMouseEvent(event->pos(), event->pos(), mev); - mev->deref(); -} - -void SVGTestWidget::mouseReleaseEvent(TQMouseEvent *event) -{ - if(!m_panningPos.isNull()) - { - m_oldPanningPos = m_oldPanningPos - (m_panningPos - event->pos()); - m_panningPos.setX(0); - m_panningPos.setY(0); - } - - if(event->state() & TQMouseEvent::ControlButton) - return; - - // only simulate mouse clicks for now - KSVG::SVGMouseEventImpl *mev = newMouseEvent(m_doc, KSVG::SVGEventImpl::MOUSEUP_EVENT, event); - - if(m_doc && m_doc->rootElement()) - m_doc->rootElement()->prepareMouseEvent(event->pos(), event->pos(), mev); - mev->deref(); -} - -void SVGTestWidget::keyPressEvent(TQKeyEvent *event) -{ - if(event->stateAfter() & TQMouseEvent::ControlButton) - { - setCursor(KCursor::sizeAllCursor()); - return; - } -} - -void SVGTestWidget::keyReleaseEvent(TQKeyEvent *event) -{ - if(event->state() & TQMouseEvent::ControlButton) - { - setCursor(KCursor::arrowCursor()); - return; - } - SVGSVGElementImpl *root = m_doc->rootElement(); - if(!root) return; - if(event->key() == TQt::Key_Minus) - { - erase(0, 0, m_canvas->width(), m_canvas->height()); - float zoomFactor = root->currentScale() / 1.2; - root->setCurrentScale(zoomFactor); - m_doc->syncCachedMatrices(); - m_canvas->update(zoomFactor); - } - else if(event->key() == TQt::Key_Plus) - { - float zoomFactor = root->currentScale() * 1.2; - root->setCurrentScale(zoomFactor); - m_doc->syncCachedMatrices(); - m_canvas->update(zoomFactor); - } -} -*/ diff --git a/ksvg/test/external/SVGTestWidget.cpp b/ksvg/test/external/SVGTestWidget.cpp new file mode 100644 index 00000000..895b5357 --- /dev/null +++ b/ksvg/test/external/SVGTestWidget.cpp @@ -0,0 +1,204 @@ +// Very small test app to look at ksvg performance without konqueror overhead (Rob) + +#include "SVGTestWidget.moc" +#include "DocumentFactory.h" +#include "CanvasFactory.h" +#include "SVGCircleElement.h" +#include "SVGAnimatedLength.h" +#include "SVGLength.h" +#include "SVGSVGElement.h" +#include "SVGEventImpl.h" +#include "KSVGCanvas.h" +#include "CanvasItem.h" +#include + +using namespace KSVG; + +SVGTestWidget::SVGTestWidget(const KURL &url) +{ + setBackgroundColor(TQt::white); + setMouseTracking(true); + setFocusPolicy(TQ_WheelFocus); + + m_doc = DocumentFactory::self()->requestDocument(TQT_TQOBJECT(this), TQT_SLOT(slotRenderingFinished())); + if(!m_doc) + return; + + resize(450, 450); + m_canvas = CanvasFactory::self()->loadCanvas(450, 450); + if(!m_canvas) + return; + + m_canvas->setup(TQT_TQPAINTDEVICE(this), TQT_TQPAINTDEVICE(this)); + + if(!DocumentFactory::self()->attachCanvas(m_canvas, m_doc)) + return; + + if(!DocumentFactory::self()->startParsing(m_doc, url)) + return; +} + +SVGTestWidget::~SVGTestWidget() +{ + delete m_canvas; + delete m_doc; +} + +void SVGTestWidget::slotRenderingFinished() +{ + TQRect rect(0, 0, width(), height()); + m_canvas->blit(rect, true); + + SVGElement test = m_doc->rootElement().getElementById("test"); + if(test.nodeName() == "circle") + { + SVGCircleElement c = dom_cast(SVGCircleElement, test); + c.r().baseVal().setValue(150); + c.setAttribute("fill", "blue"); + } +} + +void SVGTestWidget::paintEvent(TQPaintEvent *event) +{ + m_canvas->update(); + m_canvas->blit(event->rect(), true); +} + +void SVGTestWidget::resizeEvent(TQResizeEvent *event) +{ + int w = event->size().width(); + int h = event->size().height(); + + m_canvas->resize(w, h); + resize(w, h); + m_canvas->blit(); +} +/* +KSVG::SVGMouseEventImpl *newMouseEvent(SVGDocument *doc, KSVG::SVGEventImpl::EventId id, TQMouseEvent *event) +{ + DOM::AbstractView temp; + + int clientX = event->x(); + int clientY = event->y(); + + if(doc && doc->rootElement()) + { + clientX = int(clientX / doc->rootElement()->currentScale()); + clientY = int(clientY / doc->rootElement()->currentScale()); + } + + int button = 0; + if(event->stateAfter() & Qt::LeftButton) + button = 1; + else if(event->stateAfter() & Qt::MidButton) + button = 2; + else if(event->stateAfter() & Qt::RightButton) + button = 3; + + KSVG::SVGMouseEventImpl *mev = new KSVG::SVGMouseEventImpl(id, // type + true, // canBubbleArg + true, // cancelableArg + temp, // view + 0, // detail + event->globalX(), //screenXArg + event->globalY(), // screenYArg, + clientX, // clientXArg + clientY, // clientYArg + (event->state() & TQt::ControlButton), // ctrlKeyArg + (event->state() & TQt::AltButton), // altKeyArg + (event->state() & TQt::ShiftButton), // shiftKeyArg + (event->state() & TQt::MetaButton), // metaKeyArg + button, // buttonArg + 0); + + mev->ref(); + + return mev; +} + +void SVGTestWidget::mouseMoveEvent(TQMouseEvent *event) +{ + if(event->state() & TQMouseEvent::ControlButton && event->state() & TQMouseEvent::LeftButton) + { + if(m_panningPos.isNull()) + m_panningPos = event->pos(); + else + { + TQPoint panPoint = m_oldPanningPos - (m_panningPos - event->pos()); + m_doc->rootElement()->setCurrentTranslate(panPoint); +// m_doc->syncCachedMatrices(); FIXME + m_canvas->update(panPoint); + } + return; + } + else if(event->state() & TQMouseEvent::ControlButton) + return; +} + +void SVGTestWidget::mousePressEvent(TQMouseEvent *event) +{ + if(event->state() & TQMouseEvent::ControlButton) + return; + + KSVG::SVGMouseEventImpl *mev = newMouseEvent(m_doc, KSVG::SVGEventImpl::MOUSEDOWN_EVENT, event); + + if(m_doc && m_doc->rootElement()) + m_doc->rootElement()->prepareMouseEvent(event->pos(), event->pos(), mev); + mev->deref(); +} + +void SVGTestWidget::mouseReleaseEvent(TQMouseEvent *event) +{ + if(!m_panningPos.isNull()) + { + m_oldPanningPos = m_oldPanningPos - (m_panningPos - event->pos()); + m_panningPos.setX(0); + m_panningPos.setY(0); + } + + if(event->state() & TQMouseEvent::ControlButton) + return; + + // only simulate mouse clicks for now + KSVG::SVGMouseEventImpl *mev = newMouseEvent(m_doc, KSVG::SVGEventImpl::MOUSEUP_EVENT, event); + + if(m_doc && m_doc->rootElement()) + m_doc->rootElement()->prepareMouseEvent(event->pos(), event->pos(), mev); + mev->deref(); +} + +void SVGTestWidget::keyPressEvent(TQKeyEvent *event) +{ + if(event->stateAfter() & TQMouseEvent::ControlButton) + { + setCursor(KCursor::sizeAllCursor()); + return; + } +} + +void SVGTestWidget::keyReleaseEvent(TQKeyEvent *event) +{ + if(event->state() & TQMouseEvent::ControlButton) + { + setCursor(KCursor::arrowCursor()); + return; + } + SVGSVGElementImpl *root = m_doc->rootElement(); + if(!root) return; + if(event->key() == TQt::Key_Minus) + { + erase(0, 0, m_canvas->width(), m_canvas->height()); + float zoomFactor = root->currentScale() / 1.2; + root->setCurrentScale(zoomFactor); + m_doc->syncCachedMatrices(); + m_canvas->update(zoomFactor); + } + else if(event->key() == TQt::Key_Plus) + { + float zoomFactor = root->currentScale() * 1.2; + root->setCurrentScale(zoomFactor); + m_doc->syncCachedMatrices(); + m_canvas->update(zoomFactor); + } +} +*/ diff --git a/ksvg/test/external/svgdisplay.cc b/ksvg/test/external/svgdisplay.cc deleted file mode 100644 index de1172dc..00000000 --- a/ksvg/test/external/svgdisplay.cc +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include -#include "SVGTestWidget.h" - -static TDECmdLineOptions options[] = -{ - { "+URL", I18N_NOOP("SVG file to open"), 0 }, - TDECmdLineLastOption -}; - -int main(int argc, char **argv) -{ - - TDEAboutData *about = new TDEAboutData( "KSVG test app", I18N_NOOP("KSVG test"), "0.1", I18N_NOOP("KSVG standalone test app") ); - TDECmdLineArgs::init(argc, argv, about); - TDECmdLineArgs::addCmdLineOptions( options ); - TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - if(args->count() == 0) - { - args->usage(); - return 0; - } - KURL url = args->url(0); - TDEApplication a( argc, argv ); - SVGTestWidget *w = new SVGTestWidget(url); - a.setMainWidget(w); - w->show(); - - return a.exec(); -} diff --git a/ksvg/test/external/svgdisplay.cpp b/ksvg/test/external/svgdisplay.cpp new file mode 100644 index 00000000..de1172dc --- /dev/null +++ b/ksvg/test/external/svgdisplay.cpp @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include "SVGTestWidget.h" + +static TDECmdLineOptions options[] = +{ + { "+URL", I18N_NOOP("SVG file to open"), 0 }, + TDECmdLineLastOption +}; + +int main(int argc, char **argv) +{ + + TDEAboutData *about = new TDEAboutData( "KSVG test app", I18N_NOOP("KSVG test"), "0.1", I18N_NOOP("KSVG standalone test app") ); + TDECmdLineArgs::init(argc, argv, about); + TDECmdLineArgs::addCmdLineOptions( options ); + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + if(args->count() == 0) + { + args->usage(); + return 0; + } + KURL url = args->url(0); + TDEApplication a( argc, argv ); + SVGTestWidget *w = new SVGTestWidget(url); + a.setMainWidget(w); + w->show(); + + return a.exec(); +} -- cgit v1.2.1