2014-05-07 03:45:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vcl/openglwin.hxx>
|
2014-05-07 04:16:54 +02:00
|
|
|
#include <vcl/opengl/OpenGLContext.hxx>
|
2014-05-10 08:24:54 +02:00
|
|
|
#include <vcl/event.hxx>
|
2014-05-07 04:16:54 +02:00
|
|
|
|
|
|
|
class OpenGLWindowImpl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OpenGLWindowImpl(SystemChildWindow* pWindow);
|
|
|
|
OpenGLContext* getContext();
|
|
|
|
private:
|
|
|
|
OpenGLContext maContext;
|
|
|
|
};
|
|
|
|
|
|
|
|
OpenGLWindowImpl::OpenGLWindowImpl(SystemChildWindow* pWindow)
|
|
|
|
{
|
|
|
|
maContext.init(pWindow);
|
2014-05-15 10:55:02 +02:00
|
|
|
pWindow->SetMouseTransparent(false);
|
2014-05-07 04:16:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
OpenGLContext* OpenGLWindowImpl::getContext()
|
|
|
|
{
|
|
|
|
return &maContext;
|
|
|
|
}
|
2014-05-07 03:45:41 +02:00
|
|
|
|
|
|
|
OpenGLWindow::OpenGLWindow(Window* pParent):
|
2014-05-07 04:16:54 +02:00
|
|
|
SystemChildWindow(pParent, 0),
|
2014-05-13 05:12:55 +02:00
|
|
|
mpImpl(new OpenGLWindowImpl(this)),
|
|
|
|
mpRenderer(NULL)
|
2014-05-07 04:16:54 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenGLWindow::~OpenGLWindow()
|
2014-05-07 03:45:41 +02:00
|
|
|
{
|
2014-05-23 01:19:19 +02:00
|
|
|
if(mpRenderer)
|
|
|
|
mpRenderer->contextDestroyed();
|
2014-05-07 03:45:41 +02:00
|
|
|
}
|
|
|
|
|
2014-05-07 04:16:54 +02:00
|
|
|
OpenGLContext* OpenGLWindow::getContext()
|
2014-05-07 03:45:41 +02:00
|
|
|
{
|
2014-05-07 04:16:54 +02:00
|
|
|
return mpImpl->getContext();
|
2014-05-07 03:45:41 +02:00
|
|
|
}
|
|
|
|
|
2014-05-13 05:12:55 +02:00
|
|
|
void OpenGLWindow::Paint(const Rectangle&)
|
|
|
|
{
|
|
|
|
if(mpRenderer)
|
|
|
|
mpRenderer->update();
|
|
|
|
}
|
|
|
|
|
2014-05-10 08:24:54 +02:00
|
|
|
void OpenGLWindow::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
Point aPoint = rMEvt.GetPosPixel();
|
|
|
|
|
|
|
|
Color aColor = GetPixel(aPoint);
|
|
|
|
SAL_WARN("vcl.opengl", aColor.GetColor());
|
2014-05-14 16:11:14 +02:00
|
|
|
if(mpRenderer)
|
|
|
|
mpRenderer->clickedAt(aPoint);
|
2014-05-10 08:24:54 +02:00
|
|
|
}
|
|
|
|
|
2014-05-24 16:43:05 +01:00
|
|
|
void OpenGLWindow::MouseButtonUp( const MouseEvent& /* rMEvt */ )
|
|
|
|
{
|
|
|
|
// in case we need to track button state ourselves.
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLWindow::MouseMove( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
if(rMEvt.GetButtons())
|
|
|
|
mpRenderer->mouseDragMove(rMEvt.GetPosPixel(),
|
|
|
|
rMEvt.GetButtons());
|
|
|
|
}
|
|
|
|
|
2014-05-13 05:12:55 +02:00
|
|
|
void OpenGLWindow::setRenderer(IRenderer* pRenderer)
|
|
|
|
{
|
|
|
|
mpRenderer = pRenderer;
|
|
|
|
}
|
|
|
|
|
2014-05-07 03:45:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|