Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / starmath / inc / ElementsDockingWindow.hxx
blobdbfb3734b8d8f727826ff64e6c541b910f47a463
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_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
21 #define INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
23 #include <sfx2/dockwin.hxx>
24 #include <vcl/scrbar.hxx>
26 #include "format.hxx"
27 #include <memory>
28 #include <tuple>
30 #include "AccessibleSmElementsControl.hxx"
32 class SmDocShell;
33 class SmNode;
34 class SmParser;
36 class SmElement
38 std::unique_ptr<SmNode> mpNode;
39 OUString const maText;
40 OUString const maHelpText;
42 public:
43 Point mBoxLocation;
44 Size mBoxSize;
46 SmElement(std::unique_ptr<SmNode>&& pNode, const OUString& aText, const OUString& aHelpText);
47 virtual ~SmElement();
49 const std::unique_ptr<SmNode>& getNode() const;
50 const OUString& getText() const { return maText; }
51 const OUString& getHelpText() const { return maHelpText; }
53 virtual bool isSeparator() const { return false; }
56 class SmElementSeparator : public SmElement
58 public:
59 SmElementSeparator();
61 bool isSeparator() const override { return true; }
64 typedef std::pair<const char*, const char*> SmElementDescr;
66 class SmElementsControl : public Control
68 friend class ElementSelectorUIObject;
69 friend class ElementUIObject;
71 static const SmElementDescr m_aUnaryBinaryOperatorsList[];
72 static const SmElementDescr m_aRelationsList[];
73 static const SmElementDescr m_aSetOperationsList[];
74 static const SmElementDescr m_aFunctionsList[];
75 static const SmElementDescr m_aOperatorsList[];
76 static const SmElementDescr m_aAttributesList[];
77 static const SmElementDescr m_aBracketsList[];
78 static const SmElementDescr m_aFormatsList[];
79 static const SmElementDescr m_aOthersList[];
80 static const SmElementDescr m_aExamplesList[];
81 static const std::tuple<const char*, const SmElementDescr*, size_t> m_aCategories[];
82 static const size_t m_aCategoriesSize;
84 virtual void ApplySettings(vcl::RenderContext&) override;
85 virtual void DataChanged(const DataChangedEvent&) override;
86 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
87 virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
88 virtual void MouseMove(const MouseEvent& rMEvt) override;
89 virtual void RequestHelp(const HelpEvent& rHEvt) override;
90 virtual void Resize() override;
91 virtual void GetFocus() override;
92 virtual void LoseFocus() override;
93 virtual void KeyInput(const KeyEvent& rKEvt) override;
94 css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
96 SmDocShell* mpDocShell;
97 SmFormat maFormat;
98 OString msCurrentSetId;
99 sal_uInt16 m_nCurrentElement;
100 sal_uInt16 m_nCurrentRolloverElement;
101 sal_uInt16 m_nCurrentOffset;
102 Link<SmElement&,void> maSelectHdlLink;
104 std::vector< std::unique_ptr<SmElement> > maElementList;
105 Size maMaxElementDimensions;
106 bool mbVerticalMode;
107 VclPtr< ScrollBar > mxScroll;
108 bool m_bFirstPaintAfterLayout;
109 rtl::Reference<AccessibleSmElementsControl> m_xAccessible;
111 void addElement(SmParser &rParser, const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText);
112 void addElements(const SmElementDescr aElementsArray[], sal_uInt16 size);
113 SmElement* current() const;
114 void setCurrentElement(sal_uInt16);
115 bool hasRollover() const { return m_nCurrentRolloverElement != SAL_MAX_UINT16; }
117 void stepFocus(const bool bBackward);
118 void pageFocus(const bool bBackward);
119 // common code of page and step focus
120 inline void scrollToElement(const bool, const SmElement*);
121 inline sal_uInt16 nextElement(const bool, const sal_uInt16, const sal_uInt16);
123 void build();
125 //if pContext is not NULL, then draw, otherwise
126 //just layout
127 void LayoutOrPaintContents(vcl::RenderContext *pContext = nullptr);
129 public:
130 explicit SmElementsControl(vcl::Window *pParent);
131 virtual ~SmElementsControl() override;
132 virtual void dispose() override;
134 static const auto& categories() { return m_aCategories; }
135 static size_t categoriesSize() { return m_aCategoriesSize; }
136 const OString& elementSetId() const { return msCurrentSetId; }
137 void setElementSetId(const char* pSetId);
139 void setVerticalMode(bool bVertical);
141 sal_uInt16 itemCount() const;
142 sal_uInt16 itemHighlighted() const;
143 sal_uInt16 itemAtPos(const Point& rPos) const;
144 tools::Rectangle itemPosRect(sal_uInt16) const;
145 bool itemIsSeparator(sal_uInt16) const;
146 bool itemIsVisible(sal_uInt16) const;
147 OUString itemName(sal_uInt16) const;
148 bool itemTrigger(sal_uInt16);
149 void setItemHighlighted(sal_uInt16);
150 sal_uInt16 itemOffset() const { return m_nCurrentOffset; }
151 css::uno::Reference<css::accessibility::XAccessible> scrollbarAccessible() const;
153 Size GetOptimalSize() const override;
155 DECL_LINK( ScrollHdl, ScrollBar*, void );
156 void DoScroll(long nDelta);
158 void SetSelectHdl(const Link<SmElement&,void>& rLink) { maSelectHdlLink = rLink; }
160 virtual FactoryFunction GetUITestFactory() const override;
163 class SmElementsDockingWindow : public SfxDockingWindow
165 VclPtr<SmElementsControl> mpElementsControl;
166 VclPtr<ListBox> mpElementListBox;
168 virtual void Resize() override;
169 SmViewShell* GetView();
171 DECL_LINK(SelectClickHandler, SmElement&, void);
172 DECL_LINK(ElementSelectedHandle, ListBox&, void);
174 public:
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,
191 sal_uInt16 nId,
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: */