1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
21 #define INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
23 #include <sfx2/dockwin.hxx>
24 #include <vcl/customweld.hxx>
25 #include <vcl/weld.hxx>
31 #include "AccessibleSmElementsControl.hxx"
39 std::unique_ptr
<SmNode
> mpNode
;
47 SmElement(std::unique_ptr
<SmNode
>&& pNode
, const OUString
& aText
, const OUString
& aHelpText
);
50 const std::unique_ptr
<SmNode
>& getNode() const;
51 const OUString
& getText() const { return maText
; }
52 const OUString
& getHelpText() const { return maHelpText
; }
54 virtual bool isSeparator() const { return false; }
57 class SmElementSeparator final
: public SmElement
62 bool isSeparator() const override
{ return true; }
65 typedef std::pair
<const char*, const char*> SmElementDescr
;
67 class SmElementsControl
: public weld::CustomWidgetController
69 friend class ElementSelectorUIObject
;
70 friend class ElementUIObject
;
72 static const SmElementDescr m_aUnaryBinaryOperatorsList
[];
73 static const SmElementDescr m_aRelationsList
[];
74 static const SmElementDescr m_aSetOperationsList
[];
75 static const SmElementDescr m_aFunctionsList
[];
76 static const SmElementDescr m_aOperatorsList
[];
77 static const SmElementDescr m_aAttributesList
[];
78 static const SmElementDescr m_aBracketsList
[];
79 static const SmElementDescr m_aFormatsList
[];
80 static const SmElementDescr m_aOthersList
[];
81 static const SmElementDescr m_aExamplesList
[];
82 static const std::tuple
<const char*, const SmElementDescr
*, size_t> m_aCategories
[];
83 static const size_t m_aCategoriesSize
;
85 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
86 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
) override
;
87 virtual bool MouseMove(const MouseEvent
& rMEvt
) override
;
88 virtual OUString
RequestHelp(tools::Rectangle
& rRect
) override
;
89 virtual void Resize() override
;
90 virtual void GetFocus() override
;
91 virtual void LoseFocus() override
;
92 virtual bool KeyInput(const KeyEvent
& rKEvt
) override
;
93 css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
95 SmDocShell
* mpDocShell
;
97 OString msCurrentSetId
;
98 sal_uInt16 m_nCurrentElement
;
99 sal_uInt16 m_nCurrentRolloverElement
;
100 sal_uInt16 m_nCurrentOffset
;
101 Link
<SmElement
&,void> maSelectHdlLink
;
103 std::vector
< std::unique_ptr
<SmElement
> > maElementList
;
104 Size maMaxElementDimensions
;
106 std::unique_ptr
<weld::ScrolledWindow
> mxScroll
;
107 bool m_bFirstPaintAfterLayout
;
108 rtl::Reference
<AccessibleSmElementsControl
> m_xAccessible
;
110 void addElement(SmParser
&rParser
, const OUString
& aElementVisual
, const OUString
& aElementSource
, const OUString
& aHelpText
);
111 void addElements(const SmElementDescr aElementsArray
[], sal_uInt16 size
);
112 SmElement
* current() const;
113 void setCurrentElement(sal_uInt16
);
114 bool hasRollover() const { return m_nCurrentRolloverElement
!= SAL_MAX_UINT16
; }
116 void stepFocus(const bool bBackward
);
117 void pageFocus(const bool bBackward
);
118 // common code of page and step focus
119 inline void scrollToElement(const bool, const SmElement
*);
120 inline sal_uInt16
nextElement(const bool, const sal_uInt16
, const sal_uInt16
);
124 //if bDraw is true, then draw, otherwise just layout
125 void LayoutOrPaintContents(vcl::RenderContext
& rContext
, bool bDraw
);
128 explicit SmElementsControl(std::unique_ptr
<weld::ScrolledWindow
> xScrolledWindow
);
129 virtual ~SmElementsControl() override
;
131 static const auto& categories() { return m_aCategories
; }
132 static size_t categoriesSize() { return m_aCategoriesSize
; }
133 const OString
& elementSetId() const { return msCurrentSetId
; }
134 void setElementSetId(const char* pSetId
);
136 void setVerticalMode(bool bVertical
);
138 sal_uInt16
itemCount() const;
139 sal_uInt16
itemHighlighted() const;
140 sal_uInt16
itemAtPos(const Point
& rPos
) const;
141 tools::Rectangle
itemPosRect(sal_uInt16
) const;
142 bool itemIsSeparator(sal_uInt16
) const;
143 bool itemIsVisible(sal_uInt16
) const;
144 OUString
itemName(sal_uInt16
) const;
145 bool itemTrigger(sal_uInt16
);
146 void setItemHighlighted(sal_uInt16
);
147 sal_uInt16
itemOffset() const { return m_nCurrentOffset
; }
149 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
151 DECL_LINK( ScrollHdl
, weld::ScrolledWindow
&, void );
153 void SetSelectHdl(const Link
<SmElement
&,void>& rLink
) { maSelectHdlLink
= rLink
; }
155 rtl::Reference
<AccessibleSmElementsControl
> GetAccessible() const { return m_xAccessible
; }
156 static Color
GetTextColor();
157 static Color
GetControlBackground();
159 virtual FactoryFunction
GetUITestFactory() const override
;
162 class SmElementsDockingWindow final
: public SfxDockingWindow
164 std::unique_ptr
<SmElementsControl
> mxElementsControl
;
165 std::unique_ptr
<weld::CustomWeld
> mxElementsControlWin
;
166 std::unique_ptr
<weld::ComboBox
> mxElementListBox
;
168 virtual void Resize() override
;
169 SmViewShell
* GetView();
171 DECL_LINK(SelectClickHandler
, SmElement
&, void);
172 DECL_LINK(ElementSelectedHandle
, weld::ComboBox
&, void);
176 SmElementsDockingWindow( SfxBindings
* pBindings
,
177 SfxChildWindow
* pChildWindow
,
178 vcl::Window
* pParent
);
179 virtual ~SmElementsDockingWindow() override
;
180 virtual void dispose() override
;
182 virtual void EndDocking( const tools::Rectangle
& rReactangle
, bool bFloatMode
) override
;
183 virtual void ToggleFloatingMode() override
;
186 class SmElementsDockingWindowWrapper final
: public SfxChildWindow
188 SFX_DECL_CHILDWINDOW_WITHID(SmElementsDockingWindowWrapper
);
190 SmElementsDockingWindowWrapper( vcl::Window
* pParentWindow
,
192 SfxBindings
* pBindings
,
193 SfxChildWinInfo
* pInfo
);
194 virtual ~SmElementsDockingWindowWrapper() override
;
197 #endif // INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */