Commit cfc38567 authored by Sergey Luzyanin's avatar Sergey Luzyanin Committed by Alexander Trofimov

Presentation Editor

parent f6ea5628
#include "NativeControl.h"
#include "../../../DesktopEditor/presentation_editor/Control.h"
#include "../../../Word_Api/Editor_Api.h"
#include "../../../fontengine/ApplicationFontsWorker.h"
#include <QtOpenGL/QGLContext>
#include <QThread>
class CEditorCtrlWrapper : public CEditorCtrl
{
public:
CNativeCtrl* m_pCtrl;
public:
CEditorCtrlWrapper() : CEditorCtrl()
{
m_pCtrl = NULL;
}
virtual ~CEditorCtrlWrapper()
{
m_pCtrl = NULL;
}
virtual void InvalidateRectNative(int x, int y, int w, int h)
{
if (m_pCtrl != NULL)
m_pCtrl->InvalidateRectNative(x, y, w, h);
}
int GetCountThreadsUse()
{
return 3;
}
};
void CNativeCtrl::slot_threadRepaint()
{
repaint();
}
CNativeCtrl::CNativeCtrl(QWidget *parent, const char *name) : QGLWidget(parent)
{
connect(this, SIGNAL(signal_threadRepaint()), SLOT(slot_threadRepaint()), Qt::QueuedConnection);
setAttribute(Qt::WA_NoBackground);
setAttribute(Qt::WA_NoSystemBackground);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setMouseTracking(true);
grabKeyboard();
m_pWrapper = new CEditorCtrlWrapper();
m_pWrapper->m_pCtrl = this;
m_pWrapper->m_strFontsDirectory = L"";
}
CNativeCtrl::~CNativeCtrl()
{
}
void CNativeCtrl::InitSDK(const std::wstring& sFontsPath, const std::wstring& sSdkPath, CApplicationFontsWorker *pWorker)
{
m_pWrapper->SetFontsDirectory(sFontsPath);
unsigned char* pDataDst = NULL;
unsigned int nLenDst = 0;
std::vector<std::wstring> arrNames = pWorker->CheckApplication(true, NULL, 0, pDataDst, nLenDst);
int nLenAllFonts = 0;
memcpy(&nLenAllFonts, pDataDst, sizeof(int));
m_pWrapper->SetAllFontsJSData((char*)(pDataDst + 4), nLenAllFonts);
std::wstring sScriptPath = sSdkPath;
m_pWrapper->m_oWorkJS.m_oThreadJS.StartFromScript(sScriptPath);
}
void CNativeCtrl::OpenFile(const std::wstring& sFilePath)
{
m_pWrapper->InternalOpenFile(sFilePath);
}
void CNativeCtrl::SetZoom(double dZoom)
{
m_pWrapper->SetZoom(dZoom);
}
void CNativeCtrl::initializeGL()
{
m_pWrapper->m_bIsRetina = false;
m_pWrapper->m_oDevicePainter.m_oFrameControls.m_oFrame.Init(m_pWrapper->GetCountThreadsUse());
m_pWrapper->InternalInit();
m_pWrapper->Resize(600, 600);
m_pWrapper->m_oWorkJS.m_oThreadJS.SetMainCtrl((CEditorCtrl*)m_pWrapper);
}
void CNativeCtrl::paintGL()
{
CVideoFrameControls* pVRAM_Worker = &m_pWrapper->m_oDevicePainter.m_oFrameControls;
pVRAM_Worker->m_oFrame.SetCurrentCtx();
DWORD dwTime1 = NSTimers::GetTickCount();
CRgbColor3* pBackgroundColor = &(m_pWrapper->m_pSkin->BackgroundColor);
glClearColor(pBackgroundColor->R / 255.0,
pBackgroundColor->G / 255.0,
pBackgroundColor->B / 255.0,
1);
glClear(GL_COLOR_BUFFER_BIT);
GLfloat _width = this->width() * this->devicePixelRatio();
GLfloat _height = this->height() * this->devicePixelRatio();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, _width, 0.0, _height, -1.0, 1.0);
glEnable(GL_BLEND);
glColor3f(1,1,1);
glViewport(0, 0, _width, _height);
pVRAM_Worker->m_oFrame.UnSetCurrentCtx();
pVRAM_Worker->m_oFrame.SetSizes((int)_width, (int)_height);
m_pWrapper->m_oSlideDrawer.DrawGL();
m_pWrapper->m_oDevicePainter.LockPaint();
// buttons
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonNextPage,
m_pWrapper->m_oNext.X,
m_pWrapper->m_oNext.Y, true);
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonPrevPage,
m_pWrapper->m_oPrev.X,
m_pWrapper->m_oPrev.Y, true);
// scrolls
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pVerScroll,
m_pWrapper->m_oVerScroll.X,
m_pWrapper->m_oVerScroll.Y, true);
if (m_pWrapper->m_oHorScroll.IsDisplay)
{
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pHorScroll,
m_pWrapper->m_oHorScroll.X,
m_pWrapper->m_oHorScroll.Y, true);
}
pVRAM_Worker->m_oFrame.SetCurrentCtx();
glDisable(GL_BLEND);
glPopMatrix();
glFlush();
pVRAM_Worker->m_oFrame.UnSetCurrentCtx();
m_pWrapper->m_oDevicePainter.LeavePaint();
}
void CNativeCtrl::resizeGL(int width, int height)
{
int nDevicePixelRatio = this->devicePixelRatio();
m_pWrapper->Resize(this->width() * nDevicePixelRatio, this->height() * nDevicePixelRatio);
}
void CNativeCtrl::closeEvent(QCloseEvent* e)
{
}
void CNativeCtrl::mousePressEvent(QMouseEvent* e)
{
m_pWrapper->m_oMouseController.X = e->pos().x() * this->devicePixelRatio();
m_pWrapper->m_oMouseController.Y = e->pos().y() * this->devicePixelRatio();
Qt::MouseButton button = e->button();
if (button == Qt::LeftButton)
m_pWrapper->m_oMouseController.Button = CMouseController::mbtLeft;
else if (button == Qt::RightButton)
m_pWrapper->m_oMouseController.Button = CMouseController::mbtRight;
else
m_pWrapper->m_oMouseController.Button = CMouseController::mbtCenter;
Qt::KeyboardModifiers mods = e->modifiers();
m_pWrapper->m_oKeyboardController.ShiftKey = (0 != (mods & Qt::ShiftModifier)) ? true : false;
m_pWrapper->m_oKeyboardController.CtrlKey = (0 != (mods & Qt::ControlModifier)) ? true : false;
m_pWrapper->m_oKeyboardController.AltKey = (0 != (mods & Qt::AltModifier)) ? true : false;
m_pWrapper->m_oMouseController.CheckDownCallback(true);
m_pWrapper->InternalOnMouseDown();
}
void CNativeCtrl::mouseMoveEvent(QMouseEvent* e)
{
m_pWrapper->m_oMouseController.X = e->pos().x() * this->devicePixelRatio();
m_pWrapper->m_oMouseController.Y = e->pos().y() * this->devicePixelRatio();
Qt::KeyboardModifiers mods = e->modifiers();
m_pWrapper->m_oKeyboardController.ShiftKey = (0 != (mods & Qt::ShiftModifier)) ? true : false;
m_pWrapper->m_oKeyboardController.CtrlKey = (0 != (mods & Qt::ControlModifier)) ? true : false;
m_pWrapper->m_oKeyboardController.AltKey = (0 != (mods & Qt::AltModifier)) ? true : false;
m_pWrapper->m_oMouseController.CheckMoveCallback();
m_pWrapper->InternalOnMouseMove();
}
void CNativeCtrl::mouseReleaseEvent(QMouseEvent* e)
{
m_pWrapper->m_oMouseController.X = e->pos().x() * this->devicePixelRatio();
m_pWrapper->m_oMouseController.Y = e->pos().y() * this->devicePixelRatio();
Qt::MouseButton button = e->button();
if (button == Qt::LeftButton)
m_pWrapper->m_oMouseController.Button = CMouseController::mbtLeft;
else if (button == Qt::RightButton)
m_pWrapper->m_oMouseController.Button = CMouseController::mbtRight;
else
m_pWrapper->m_oMouseController.Button = CMouseController::mbtCenter;
Qt::KeyboardModifiers mods = e->modifiers();
m_pWrapper->m_oKeyboardController.ShiftKey = (0 != (mods & Qt::ShiftModifier)) ? true : false;
m_pWrapper->m_oKeyboardController.CtrlKey = (0 != (mods & Qt::ControlModifier)) ? true : false;
m_pWrapper->m_oKeyboardController.AltKey = (0 != (mods & Qt::AltModifier)) ? true : false;
m_pWrapper->InternalOnMouseUp();
}
void CNativeCtrl::wheelEvent(QWheelEvent* event)
{
}
void CNativeCtrl::keyPressEvent(QKeyEvent* e)
{
if (e->key()==Qt::Key_Left)
{
if(m_pWrapper->m_lCurSlide > 0)
{
m_pWrapper->GoToPage(m_pWrapper->m_lCurSlide - 1);
}
}
else if(e->key()==Qt::Key_Right)
{
if(m_pWrapper->m_lCurSlide < m_pWrapper->m_lSlidesCount - 1)
{
m_pWrapper->GoToPage(m_pWrapper->m_lCurSlide + 1);
}
}
}
void CNativeCtrl::keyReleaseEvent(QKeyEvent* e)
{
}
void CNativeCtrl::InvalidateRectNative(int x, int y, int w, int h)
{
emit signal_threadRepaint();
}
#ifndef NATIVECONTROLL_H
#define NATIVECONTROLL_H
#include <QWidget>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QKeyEvent>
#include <QPaintEvent>
#include <QtOpenGL/QGLWidget>
class CEditorCtrlWrapper;
class CApplicationFontsWorker;
class CNativeCtrl : public QGLWidget
{
Q_OBJECT
signals:
void signal_threadRepaint();
protected slots:
void slot_threadRepaint();
public:
CNativeCtrl(QWidget *parent = 0, const char *name = NULL);
virtual ~CNativeCtrl();
public:
virtual void initializeGL();
virtual void paintGL();
virtual void resizeGL(int width, int height);
virtual void closeEvent(QCloseEvent* e);
virtual void mousePressEvent(QMouseEvent* e);
virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
virtual void wheelEvent(QWheelEvent* event);
virtual void keyPressEvent(QKeyEvent* e);
virtual void keyReleaseEvent(QKeyEvent* e);
virtual void InvalidateRectNative(int x, int y, int w, int h);
public:
void InitSDK(const std::wstring& sFontsPath, const std::wstring& sSdkPath, CApplicationFontsWorker* pWorker);
void OpenFile(const std::wstring& sFilePath);
void SetZoom(double dZoom);
private:
CEditorCtrlWrapper* m_pWrapper;
};
#endif // NATIVECONTROLL_H
#-------------------------------------------------
#
# Project created by QtCreator 2016-01-19T14:56:40
#
#-------------------------------------------------
QT += core gui
QT += widgets opengl
TARGET = presentation_editor
TEMPLATE = lib
CONFIG += staticlib
CONFIG(debug, debug|release) {
DESTDIR = $$PWD/../Debug
}else {
DESTDIR = $$PWD/../Release
}
INCLUDEPATH += \
../../../agg-2.4/include \
../../../freetype-2.5.2/include \
../../../doctrenderer/v8_windows/v8/ \
../../../doctrenderer/v8_windows/v8/include \
../../../doctrenderer/v8_windows/v8/include/libplatform
DEFINES += \
_QT
DEFINES += \
WIN32
SOURCES += NativeControl.cpp \
../../../presentation_editor/Control.cpp \
../../../presentation_editor/DrawingDocument.cpp \
../../../presentation_editor/Overlay.cpp \
../../../presentation_editor/Viewer.cpp \
../../../presentation_editor/v8_core/HitControl.cpp \
../../../presentation_editor/v8_core/JSEngine2.cpp \
../../../presentation_editor/v8_core/TextMeasurer2.cpp \
../../../presentation_editor/v8_core/v8_jscore.cpp \
../../../editor/DibPainter.cpp \
../../../editor/OverlayBase.cpp \
../../../editor/JSEngine.cpp \
../../../presentation_editor/v8_core/DrawingDocumentWrapper.cpp \
../../../presentation_editor/v8_core/PageDrawer.cpp \
../../../presentation_editor/v8_core/OverlayTracker.cpp \
../../../editor/TextMeasurer.cpp \
../../../editor/Rulers.cpp \
../../../fontengine/ApplicationFonts.cpp \
../../../fontengine/ApplicationFontsWorker.cpp \
../../../fontengine/FontFile.cpp \
../../../fontengine/FontManager.cpp \
../../../fontengine/FontPath.cpp \
../../../fontengine/GlyphString.cpp
HEADERS += \
NativeControl.h \
../../../presentation_editor/Control.h \
../../../presentation_editor/DrawingDocument.h \
../../../presentation_editor/EditorCtrlWrapper.h \
../../../presentation_editor/Overlay.h \
../../../presentation_editor/VideoFrameBuffer.h \
../../../presentation_editor/Viewer.h \
../../../presentation_editor/v8_core/v8_jscore.h \
../../../editor/v8_classes.h \
../../../editor/DibPainter.h \
../../../editor/PageDrawer.h \
../../../presentation_editor/thumbnails.h \
../../../presentation_editor/notes.h \
../../../fontengine/FontManager.h
unix {
target.path = /usr/lib
INSTALLS += target
}
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::resizeEvent(QResizeEvent* e)
{
ui->widget->setGeometry(0, 0, this->width(), this->height() - 50);
}
void MainWindow::closeEvent(QCloseEvent* e)
{
ui->widget->closeEvent(e);
}
void MainWindow::keyPressEvent(QKeyEvent *e)
{
ui->widget->keyPressEvent(e);
}
void MainWindow::mousePressEvent(QMouseEvent *e)
{
ui->widget->mousePressEvent(e);
}
void MainWindow::mouseReleaseEvent(QMouseEvent *e)
{
ui->widget->mouseReleaseEvent(e);
}
void MainWindow:: mouseMoveEvent(QMouseEvent *e)
{
ui->widget->mouseMoveEvent(e);
}
/*void MainWindow::on_horizontalSlider_valueChanged(int value)
{
ui->widget->SetZoom((double)value / 100.0);
}
void MainWindow::on_pushButton_clicked()
{
}*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
protected:
virtual void resizeEvent(QResizeEvent* e);
virtual void closeEvent(QCloseEvent* e);
virtual void keyPressEvent(QKeyEvent *event);
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseReleaseEvent(QMouseEvent *);
virtual void mouseMoveEvent(QMouseEvent *);
/*private slots:
void on_horizontalSlider_valueChanged(int value);
void on_pushButton_clicked();*/
};
#endif // MAINWINDOW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>922</width>
<height>494</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="CNativeControl" name="widget" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>921</width>
<height>441</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>922</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>CNativeControl</class>
<extends>QWidget</extends>
<header location="global">nativecontrol.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
#ifndef NATIVECONTROL
#define NATIVECONTROL
#include "../../presentation_editor/project/NativeControl.h"
#include "../../../fontengine/ApplicationFontsWorker.h"
class CNativeControl : public CNativeCtrl
{
public:
CNativeControl(QWidget *parent = 0, const char *name = NULL) : CNativeCtrl(parent, name)
{
}
virtual ~CNativeControl()
{
}
public:
virtual void initializeGL()
{
CNativeCtrl::initializeGL();
QString qsBasePath = QApplication::applicationDirPath();
QString qsFontsPath = qsBasePath + "/../../../../fonts/owner";
QString qsSDKPath = qsBasePath + "/../../../../test_mobile/script.bin";
QString qsFilePath = qsBasePath + "/../../../../test_mobile/Editor2.bin";
CApplicationFontsWorker *pWorker = new CApplicationFontsWorker();
QString sqFreeFontsPath = qsBasePath + "/../../../../fonts/free";
QString sqOwnerFontsPath = qsBasePath + "/../../../../fonts/owner";
pWorker->m_arAdditionalFolders.push_back(sqFreeFontsPath.toStdWString());
pWorker->m_arAdditionalFolders.push_back(sqOwnerFontsPath.toStdWString());
InitSDK(qsFontsPath.toStdWString(), qsSDKPath.toStdWString(), pWorker);
OpenFile(qsFilePath.toStdWString());
}
};
#endif // NATIVECONTROL
#-------------------------------------------------
#
# Project created by QtCreator 2016-01-20T11:11:24
#
#-------------------------------------------------
QT += core gui opengl
TARGET = test_presentation
TEMPLATE = app
DEFINES += \
WIN32
DEFINES -= UNICODE
DEFINES += _NOT_DRAW_VISUAL_CONTROLS_GL_
LIBS += -lwinmm
LIBS += -ladvapi32
LIBS += -lopengl32
LIBS += -lgdi32
LIBS += -luser32
CONFIG(debug, debug|release) {
DESTDIR = $$PWD/../Debug
}else {
DESTDIR = $$PWD/../Release
}
CONFIG(debug, debug|release) {
LIBS += -L../../../../build/lib/win_64/DEBUG -lv8_base
LIBS += -L../../../../build/lib/win_64/DEBUG -lv8_libbase
LIBS += -L../../../../build/lib/win_64/DEBUG -lv8_libplatform
LIBS += -L../../../../build/lib/win_64/DEBUG -lv8_nosnapshot
LIBS += -L../../../../build/lib/win_64/DEBUG -lv8_snapshot
LIBS += -L../../../../build/lib/win_64/DEBUG -licui18n
LIBS += -L../../../../build/lib/win_64/DEBUG -licuuc
LIBS += -L../../../../build/lib/win_64/DEBUG -lgraphics
LIBS += -L../../../../build/lib/win_64/DEBUG -lOfficeUtils
LIBS += -L../../presentation_editor/Debug -lpresentation_editor
message("debug")
}else {
LIBS += -L../../../../build/lib/win_64 -lv8_base
LIBS += -L../../../../build/lib/win_64 -lv8_libbase
LIBS += -L../../../../build/lib/win_64 -lv8_libplatform
LIBS += -L../../../../build/lib/win_64 -lv8_nosnapshot
LIBS += -L../../../../build/lib/win_64 -lv8_snapshot
LIBS += -L../../../../build/lib/win_64 -licui18n
LIBS += -L../../../../build/lib/win_64 -licuuc
LIBS += -L../../../../build/lib/win_64 -lgraphics
LIBS += -L../../../../build/lib/win_64 -lOfficeUtils
LIBS += -L../../presentation_editor/Release -lpresentation_editor
message("release")
}
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h \
nativecontrol.h
FORMS += mainwindow.ui
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment