Commit 562f79a1 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

NativeControl with menu

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57475 954022d7-b5bf-4e40-9824-e11837661b57
parent 8d2007d8
...@@ -424,6 +424,67 @@ void COpenGLSceneCtrl::_native_OnResize(int X, int Y, int W, int H) ...@@ -424,6 +424,67 @@ void COpenGLSceneCtrl::_native_OnResize(int X, int Y, int W, int H)
} }
} }
void COpenGLSceneCtrl::_native_OnMouse(int type, int x, int y, int flags)
{
if (m_pWrapper == NULL)
return;
int m_fDeviceScale = 1;
m_pWrapper->m_oMouseController.X = (int)((x - m_nEditorX) * m_fDeviceScale);
m_pWrapper->m_oMouseController.Y = (int)((y - m_nEditorY) * m_fDeviceScale);
m_pWrapper->m_oKeyboardController.CtrlKey = ((flags & 0x01) == 0x01) ? true : false;
m_pWrapper->m_oKeyboardController.AltKey = ((flags & 0x02) == 0x02) ? true : false;
m_pWrapper->m_oKeyboardController.ShiftKey = ((flags & 0x04) == 0x04) ? true : false;
switch (type)
{
case 0:
{
m_pWrapper->m_oMouseController.Button = CMouseController::mbtLeft;
m_pWrapper->m_oMouseController.CheckDownCallback(true);
m_pWrapper->InternalOnMouseDown();
break;
}
case 1:
{
m_pWrapper->InternalOnMouseMove();
break;
}
case 2:
{
m_pWrapper->InternalOnMouseUp();
break;
}
}
}
void COpenGLSceneCtrl::_native_OnKeyboard(int type, int keycode, int charcode, int flags)
{
if (m_pWrapper == NULL)
return;
m_pWrapper->m_oKeyboardController.KeyCode = keycode;
m_pWrapper->m_oKeyboardController.CharCode = charcode;
m_pWrapper->m_oKeyboardController.CtrlKey = ((flags & 0x01) == 0x01) ? true : false;
m_pWrapper->m_oKeyboardController.AltKey = ((flags & 0x02) == 0x02) ? true : false;
m_pWrapper->m_oKeyboardController.ShiftKey = ((flags & 0x04) == 0x04) ? true : false;
switch (type)
{
case 0:
m_pWrapper->InternalOnKeyDown();
break;
case 1:
m_pWrapper->InternalOnKeyPress();
break;
case 2:
m_pWrapper->InternalOnKeyUp();
break;
}
}
void COpenGLSceneCtrl::slot_threadRepaint() void COpenGLSceneCtrl::slot_threadRepaint()
{ {
this->update(0, 0, this->width(), this->height()); this->update(0, 0, this->width(), this->height());
...@@ -445,10 +506,7 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect) ...@@ -445,10 +506,7 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect)
} }
/* /*
glClearColor(1, glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
0,
0,
1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glFlush(); glFlush();
return; return;
...@@ -468,7 +526,6 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect) ...@@ -468,7 +526,6 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect)
NSCriticalSection::CRITICAL_SECTION* pCS_GL = pVRAM_Worker->m_oFrame.GetLocker(); NSCriticalSection::CRITICAL_SECTION* pCS_GL = pVRAM_Worker->m_oFrame.GetLocker();
pCS_GL->Enter(); pCS_GL->Enter();
pVRAM_Worker->m_oFrame.SetCurrentCtx(); pVRAM_Worker->m_oFrame.SetCurrentCtx();
DWORD dwTime1 = NSTimers::GetTickCount(); DWORD dwTime1 = NSTimers::GetTickCount();
...@@ -501,6 +558,8 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect) ...@@ -501,6 +558,8 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect)
m_pCPlusPlusWrapper->m_oViewer.Width, m_pCPlusPlusWrapper->m_oViewer.Width,
m_pCPlusPlusWrapper->m_oViewer.Height); m_pCPlusPlusWrapper->m_oViewer.Height);
oClipRect.Offset(m_nEditorX, m_nEditorY);
if (m_pCPlusPlusWrapper->m_oDrawingDocument.m_lStartBlock >= 0) if (m_pCPlusPlusWrapper->m_oDrawingDocument.m_lStartBlock >= 0)
{ {
for (int i = (int)m_pCPlusPlusWrapper->m_oDrawingDocument.m_lStartBlock; for (int i = (int)m_pCPlusPlusWrapper->m_oDrawingDocument.m_lStartBlock;
...@@ -511,16 +570,17 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect) ...@@ -511,16 +570,17 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect)
{ {
Aggplus::Rect oRect = pBlock->m_arPages[j]->m_oGlobalBounds; Aggplus::Rect oRect = pBlock->m_arPages[j]->m_oGlobalBounds;
oRect.Offset(m_pCPlusPlusWrapper->m_oViewer.X, m_pCPlusPlusWrapper->m_oViewer.Y); oRect.Offset(m_pCPlusPlusWrapper->m_oViewer.X, m_pCPlusPlusWrapper->m_oViewer.Y);
oRect.Offset(m_nEditorX, m_nEditorY);
{ {
pVRAM_Worker->m_oFrame.UnSetCurrentCtx(); //pVRAM_Worker->m_oFrame.UnSetCurrentCtx();
pCS_GL->Leave(); pCS_GL->Leave();
m_pCPlusPlusWrapper->m_oCacheDocument.DrawGL(&m_pCPlusPlusWrapper->m_oDevicePainter, m_pCPlusPlusWrapper->m_oCacheDocument.DrawGL(&m_pCPlusPlusWrapper->m_oDevicePainter,
oClipRect, oClipRect,
oRect, oRect,
pBlock->m_arPages[j]->m_lPageIndex); pBlock->m_arPages[j]->m_lPageIndex);
pCS_GL->Enter(); pCS_GL->Enter();
pVRAM_Worker->m_oFrame.SetCurrentCtx(); //pVRAM_Worker->m_oFrame.SetCurrentCtx();
} }
} }
} }
...@@ -535,8 +595,8 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect) ...@@ -535,8 +595,8 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect)
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pOverlay, pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pOverlay,
m_pCPlusPlusWrapper->m_oViewer.X, m_pCPlusPlusWrapper->m_oViewer.X + m_nEditorX,
m_pCPlusPlusWrapper->m_oViewer.Y, m_pCPlusPlusWrapper->m_oViewer.Y + m_nEditorY,
true); true);
//glDisable(GL_BLEND); //glDisable(GL_BLEND);
...@@ -544,27 +604,27 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect) ...@@ -544,27 +604,27 @@ void COpenGLSceneCtrl::drawBackground(QPainter *painter, const QRectF &rect)
// buttons // buttons
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonRulers, pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonRulers,
m_pCPlusPlusWrapper->m_oButtonRulers.X, m_pCPlusPlusWrapper->m_oButtonRulers.X + m_nEditorX,
m_pCPlusPlusWrapper->m_oButtonRulers.Y, true); m_pCPlusPlusWrapper->m_oButtonRulers.Y + m_nEditorY, true);
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonNextPage, pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonNextPage,
m_pCPlusPlusWrapper->m_oNext.X, m_pCPlusPlusWrapper->m_oNext.X + m_nEditorX,
m_pCPlusPlusWrapper->m_oNext.Y, true); m_pCPlusPlusWrapper->m_oNext.Y + m_nEditorY, true);
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonPrevPage, pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pButtonPrevPage,
m_pCPlusPlusWrapper->m_oPrev.X, m_pCPlusPlusWrapper->m_oPrev.X + m_nEditorX,
m_pCPlusPlusWrapper->m_oPrev.Y, true); m_pCPlusPlusWrapper->m_oPrev.Y + m_nEditorY, true);
// scrolls // scrolls
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pVerScroll, pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pVerScroll,
m_pCPlusPlusWrapper->m_oVerScroll.X, m_pCPlusPlusWrapper->m_oVerScroll.X + m_nEditorX,
m_pCPlusPlusWrapper->m_oVerScroll.Y, true); m_pCPlusPlusWrapper->m_oVerScroll.Y + m_nEditorY, true);
if (m_pCPlusPlusWrapper->m_bIsHorScrollVisible) if (m_pCPlusPlusWrapper->m_bIsHorScrollVisible)
{ {
pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pHorScroll, pVRAM_Worker->m_oFrame.DrawTexture(pVRAM_Worker->m_pHorScroll,
m_pCPlusPlusWrapper->m_oHorScroll.X, m_pCPlusPlusWrapper->m_oHorScroll.X + m_nEditorX,
m_pCPlusPlusWrapper->m_oHorScroll.Y, true); m_pCPlusPlusWrapper->m_oHorScroll.Y + m_nEditorY, true);
} }
glDisable(GL_BLEND); glDisable(GL_BLEND);
......
...@@ -85,10 +85,16 @@ public: ...@@ -85,10 +85,16 @@ public:
signals: signals:
void native_OnResize(int X, int Y, int W, int H); void native_OnResize(int X, int Y, int W, int H);
void native_OnMouse(int type, int x, int y, int flags);
void native_OnKeyboard(int type, int keycode, int charcode, int flags);
void signal_threadRepaint(); void signal_threadRepaint();
public slots: public slots:
void _native_OnResize(int X, int Y, int W, int H); void _native_OnResize(int X, int Y, int W, int H);
void _native_OnMouse(int type, int x, int y, int flags);
void _native_OnKeyboard(int type, int keycode, int charcode, int flags);
void slot_threadRepaint(); void slot_threadRepaint();
void onWebViewFinishLoading(bool) void onWebViewFinishLoading(bool)
...@@ -152,13 +158,15 @@ public: ...@@ -152,13 +158,15 @@ public:
settings->setOfflineStorageDefaultQuota(5*1024*1024); settings->setOfflineStorageDefaultQuota(5*1024*1024);
settings->setOfflineWebApplicationCacheQuota(5*1024*1024); settings->setOfflineWebApplicationCacheQuota(5*1024*1024);
QString sMenu = "file:///E:/Office/Application/apps/api/documents/index.html"; QString sMenu = "file:///D:/Office/Application/apps/api/documents/index.html";
QString sFile = "?url=file:///E:/Office/Application/sdk/Word/document/"; QString sFile = "?url=file:///D:/Office/Application/sdk/Word/document/";
QString sFullUrl = sMenu + sFile; QString sFullUrl = sMenu + sFile;
QUrl url = sFullUrl; QUrl url = sFullUrl;
connect(m_pWebView, SIGNAL(loadFinished(bool)), SLOT(onWebViewFinishLoading(bool))); connect(m_pWebView, SIGNAL(loadFinished(bool)), SLOT(onWebViewFinishLoading(bool)));
connect(this, SIGNAL (native_OnResize(int, int, int, int)), SLOT (_native_OnResize(int, int, int, int))); connect(this, SIGNAL (native_OnResize(int, int, int, int)), SLOT (_native_OnResize(int, int, int, int)));
connect(this, SIGNAL (native_OnMouse(int, int, int, int)), SLOT (_native_OnMouse(int, int, int, int)));
connect(this, SIGNAL (native_OnKeyboard(int, int, int, int)), SLOT (_native_OnKeyboard(int, int, int, int)));
m_pWebView->load(url); m_pWebView->load(url);
...@@ -202,10 +210,12 @@ class CNativeCtrlWebMenu : public QGraphicsView ...@@ -202,10 +210,12 @@ class CNativeCtrlWebMenu : public QGraphicsView
{ {
private: private:
COpenGLSceneCtrl* m_pScene; COpenGLSceneCtrl* m_pScene;
QGLWidget* m_pWidget;
public: public:
CNativeCtrlWebMenu(QWidget *parent = 0) : QGraphicsView(parent) CNativeCtrlWebMenu(QWidget *parent = 0) : QGraphicsView(parent)
{ {
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); m_pWidget = new QGLWidget(QGLFormat(QGL::SampleBuffers));
setViewport(m_pWidget);
setViewportUpdateMode(QGraphicsView::FullViewportUpdate); setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
setStyleSheet("border-width: 0px; border-style: none;"); setStyleSheet("border-width: 0px; border-style: none;");
...@@ -244,6 +254,21 @@ public: ...@@ -244,6 +254,21 @@ public:
{ {
QGraphicsView::closeEvent(e); QGraphicsView::closeEvent(e);
} }
virtual void drawBackground(QPainter *painter, const QRectF &rect)
{
/*
m_pWidget->makeCurrent();
QGraphicsView::drawBackground(painter, rect);
m_pWidget->doneCurrent();
*/
m_pWidget->makeCurrent();
if (NULL != m_pScene)
{
m_pScene->drawBackground(painter, rect);
}
m_pWidget->doneCurrent();
}
}; };
#endif #endif
......
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