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 .
19 #ifndef INCLUDED_SVX_CHARMAP_HXX
20 #define INCLUDED_SVX_CHARMAP_HXX
22 #include <sal/config.h>
28 #include <sal/types.h>
29 #include <rtl/ref.hxx>
30 #include <svx/svxdllapi.h>
31 #include <tools/gen.hxx>
32 #include <tools/link.hxx>
33 #include <vcl/metric.hxx>
34 #include <vcl/vclptr.hxx>
35 #include <vcl/customweld.hxx>
36 #include <vcl/weld.hxx>
38 namespace com::sun::star
{
39 namespace accessibility
{ class XAccessible
; }
42 namespace com::sun::star::uno
{ class XComponentContext
; }
44 using namespace ::com::sun::star
;
46 #define COLUMN_COUNT 16
51 struct SvxShowCharSetItem
;
52 class SvxShowCharSetAcc
;
55 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI SvxShowCharSet
: public weld::CustomWidgetController
58 VclPtr
<VirtualDevice
> mxVirDev
;
60 std::unique_ptr
<weld::ScrolledWindow
> mxScrollArea
;
62 SVX_DLLPUBLIC
SvxShowCharSet(std::unique_ptr
<weld::ScrolledWindow
> pScrollArea
, const VclPtr
<VirtualDevice
>& rVirDev
);
63 virtual ~SvxShowCharSet() override
;
65 virtual void RecalculateFont(vcl::RenderContext
& rRenderContext
);
67 SVX_DLLPUBLIC
void SelectCharacter( sal_UCS4 cNew
);
68 virtual sal_UCS4
GetSelectCharacter() const;
69 virtual sal_UCS4
GetCharFromIndex(int index
) const;
70 void createContextMenu(const Point
& rPosition
);
72 void SetDoubleClickHdl( const Link
<SvxShowCharSet
*,void>& rLink
) { aDoubleClkHdl
= rLink
; }
73 void SetReturnKeyPressHdl( const Link
<SvxShowCharSet
*,void>& rLink
) { m_aReturnKeypressHdl
= rLink
; }
74 void SetSelectHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aSelectHdl
= rHdl
; }
75 void SetHighlightHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aHighHdl
= rHdl
; }
76 void SetPreSelectHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aPreSelectHdl
= rHdl
; }
77 void SetFavClickHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aFavClickHdl
= rHdl
; }
78 static sal_uInt32
& getSelectedChar();
79 SVX_DLLPUBLIC
void SetFont( const vcl::Font
& rFont
);
80 vcl::Font
const & GetFont() const { return maFont
; }
81 SVX_DLLPUBLIC FontCharMapRef
const & GetFontCharMap();
82 bool isFavChar(std::u16string_view sTitle
, std::u16string_view rFont
);
83 void getFavCharacterList(); //gets both Fav char and Fav char font list
84 void updateFavCharacterList(const OUString
& rChar
, const OUString
& rFont
);
86 virtual svx::SvxShowCharSetItem
* ImplGetItem( int _nPos
);
87 int FirstInView() const;
88 virtual int LastInView() const;
89 int PixelToMapIndex( const Point
&) const;
90 virtual void SelectIndex( int index
, bool bFocus
= false );
91 void OutputIndex( int index
);
93 static void CopyToClipboard(const OUString
& str
);
94 bool IsSelected(sal_uInt16 _nPos
) const { return _nPos
== nSelectedIndex
; }
95 sal_uInt16
GetSelectIndexId() const { return sal::static_int_cast
<sal_uInt16
>(nSelectedIndex
); }
96 static sal_uInt16
GetRowPos(sal_uInt16 _nPos
);
97 static sal_uInt16
GetColumnPos(sal_uInt16 _nPos
);
99 virtual sal_Int32
getMaxCharCount() const;
101 virtual void Show() override
{ mxScrollArea
->show(); }
102 virtual void Hide() override
{ mxScrollArea
->hide(); }
104 uno::Reference
<css::accessibility::XAccessible
> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
107 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
108 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
109 virtual void Resize() override
;
110 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
) override
;
111 virtual bool MouseMove(const MouseEvent
& rMEvt
) override
;
112 virtual bool MouseButtonUp(const MouseEvent
& rMEvt
) override
;
113 virtual void GetFocus() override
;
114 virtual void LoseFocus() override
;
115 virtual bool Command(const CommandEvent
& rCEvt
) override
;
117 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
118 virtual FactoryFunction
GetUITestFactory() const override
;
121 typedef std::map
<sal_Int32
, std::shared_ptr
<svx::SvxShowCharSetItem
> > ItemsMap
;
123 Link
<SvxShowCharSet
*,void> aDoubleClkHdl
;
124 Link
<SvxShowCharSet
*,void> m_aReturnKeypressHdl
;
125 Link
<SvxShowCharSet
*,void> aSelectHdl
;
126 Link
<SvxShowCharSet
*,void> aFavClickHdl
;
127 Link
<SvxShowCharSet
*,void> aHighHdl
;
128 Link
<SvxShowCharSet
*,void> aPreSelectHdl
;
130 std::deque
<OUString
> maFavCharList
;
131 std::deque
<OUString
> maFavCharFontList
;
133 rtl::Reference
<svx::SvxShowCharSetAcc
> m_xAccessible
;
140 sal_Int32 nSelectedIndex
;
142 FontCharMapRef mxFontCharMap
;
145 bool mbRecalculateFont
: 1;
146 bool mbUpdateForeground
: 1;
147 bool mbUpdateBackground
: 1;
151 virtual bool KeyInput(const KeyEvent
&) override
;
152 void DrawChars_Impl(vcl::RenderContext
& rRenderContext
, int n1
, int n2
);
153 void InitSettings(vcl::RenderContext
& rRenderContext
);
154 // abstraction layers are: Unicode<->MapIndex<->Pixel
155 Point
MapIndexToPixel( int) const;
156 DECL_LINK(VscrollHdl
, weld::ScrolledWindow
&, void);
157 void ContextMenuSelect(std::u16string_view rIdent
);
160 tools::Rectangle
getGridRectangle(const Point
&rPointUL
, const Size
&rOutputSize
) const;
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */