bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sdext / source / presenter / PresenterButton.hxx
blob18a504c20d59c0224aca16978f56c7c9c714ecc1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERBUTTON_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERBUTTON_HXX
23 #include "PresenterBitmapContainer.hxx"
24 #include "PresenterTheme.hxx"
25 #include <com/sun/star/awt/Rectangle.hpp>
26 #include <com/sun/star/awt/XWindow.hpp>
27 #include <com/sun/star/awt/XWindowListener.hpp>
28 #include <com/sun/star/awt/XPaintListener.hpp>
29 #include <com/sun/star/awt/XMouseListener.hpp>
30 #include <com/sun/star/awt/XMouseMotionListener.hpp>
31 #include <com/sun/star/rendering/XCanvas.hpp>
32 #include <com/sun/star/rendering/XBitmap.hpp>
33 #include <cppuhelper/basemutex.hxx>
34 #include <cppuhelper/compbase.hxx>
35 #include <rtl/ref.hxx>
37 namespace sdext { namespace presenter {
39 class PresenterController;
41 typedef ::cppu::WeakComponentImplHelper <
42 css::awt::XWindowListener,
43 css::awt::XPaintListener,
44 css::awt::XMouseListener,
45 css::awt::XMouseMotionListener
46 > PresenterButtonInterfaceBase;
48 /** Button for the presenter screen. It displays a text surrounded by a
49 frame.
51 class PresenterButton
52 : private ::cppu::BaseMutex,
53 public PresenterButtonInterfaceBase
55 public:
56 static ::rtl::Reference<PresenterButton> Create (
57 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
58 const ::rtl::Reference<PresenterController>& rpPresenterController,
59 const std::shared_ptr<PresenterTheme>& rpTheme,
60 const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
61 const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas,
62 const OUString& rsConfigurationName);
63 virtual ~PresenterButton() override;
64 PresenterButton(const PresenterButton&) = delete;
65 PresenterButton& operator=(const PresenterButton&) = delete;
67 virtual void SAL_CALL disposing() override;
69 void SetCenter (const css::geometry::RealPoint2D& rLocation);
70 void SetCanvas (
71 const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas,
72 const css::uno::Reference<css::awt::XWindow>& rxParentWindow);
73 css::geometry::IntegerSize2D const & GetSize();
75 // XWindowListener
77 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) override;
79 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) override;
81 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) override;
83 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) override;
85 // XPaintListener
87 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
89 // XMouseListener
91 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) override;
93 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) override;
95 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) override;
97 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) override;
99 // XMouseMotionListener
101 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) override;
103 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) override;
105 // lang::XEventListener
106 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) override;
108 private:
109 ::rtl::Reference<PresenterController> mpPresenterController;
110 std::shared_ptr<PresenterTheme> mpTheme;
111 css::uno::Reference<css::awt::XWindow> mxWindow;
112 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
113 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
114 const OUString msText;
115 const PresenterTheme::SharedFontDescriptor mpFont;
116 const PresenterTheme::SharedFontDescriptor mpMouseOverFont;
117 const OUString msAction;
118 css::geometry::RealPoint2D maCenter;
119 css::geometry::IntegerSize2D maButtonSize;
120 PresenterBitmapDescriptor::Mode meState;
121 css::uno::Reference<css::rendering::XBitmap> mxNormalBitmap;
122 css::uno::Reference<css::rendering::XBitmap> mxMouseOverBitmap;
124 PresenterButton (
125 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
126 const ::rtl::Reference<PresenterController>& rpPresenterController,
127 const std::shared_ptr<PresenterTheme>& rpTheme,
128 const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
129 const PresenterTheme::SharedFontDescriptor& rFont,
130 const PresenterTheme::SharedFontDescriptor& rMouseOverFont,
131 const OUString& rxText,
132 const OUString& rxAction);
133 void RenderButton (
134 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
135 const css::geometry::IntegerSize2D& rSize,
136 const PresenterTheme::SharedFontDescriptor& rFont,
137 const PresenterBitmapDescriptor::Mode eMode,
138 const SharedBitmapDescriptor& rpLeft,
139 const SharedBitmapDescriptor& rpCenter,
140 const SharedBitmapDescriptor& rpRight);
141 css::geometry::IntegerSize2D CalculateButtonSize();
142 void Invalidate();
143 static css::uno::Reference<css::rendering::XBitmap> GetBitmap (
144 const SharedBitmapDescriptor& mpIcon,
145 const PresenterBitmapDescriptor::Mode eMode);
146 void SetupButtonBitmaps();
147 static css::uno::Reference<css::beans::XPropertySet> GetConfigurationProperties (
148 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
149 const OUString& rsConfgurationName);
151 /// @throws css::lang::DisposedException
152 void ThrowIfDisposed() const;
157 #endif
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */