LibreOffice Module svx (master) 1
charmap.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SVX_CHARMAP_HXX
20#define INCLUDED_SVX_CHARMAP_HXX
21
22#include <sal/config.h>
23
24#include <deque>
25#include <map>
26#include <memory>
27
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>
37
38namespace com::sun::star {
39 namespace accessibility { class XAccessible; }
40}
41
42namespace com::sun::star::uno { class XComponentContext; }
43
44using namespace ::com::sun::star;
45
46#define COLUMN_COUNT 16
47#define ROW_COUNT 8
48
49namespace svx
50{
51 struct SvxShowCharSetItem;
52 class SvxShowCharSetAcc;
53}
54
56{
57protected:
60 std::unique_ptr<weld::ScrolledWindow> mxScrollArea;
61public:
62 SvxShowCharSet(std::unique_ptr<weld::ScrolledWindow> pScrollArea, const VclPtr<VirtualDevice>& rVirDev);
63 virtual ~SvxShowCharSet() override;
64
65 virtual void RecalculateFont(vcl::RenderContext& rRenderContext);
66
67 void SelectCharacter( sal_UCS4 cNew );
68 virtual sal_UCS4 GetSelectCharacter() const;
69 void createContextMenu(const Point& rPosition);
70
71 void SetDoubleClickHdl( const Link<SvxShowCharSet*,void>& rLink ) { aDoubleClkHdl = rLink; }
72 void SetReturnKeyPressHdl( const Link<SvxShowCharSet*,void>& rLink ) { m_aReturnKeypressHdl = rLink; }
73 void SetSelectHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aSelectHdl = rHdl; }
74 void SetHighlightHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aHighHdl = rHdl; }
75 void SetPreSelectHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aPreSelectHdl = rHdl; }
76 void SetFavClickHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aFavClickHdl = rHdl; }
77 static sal_uInt32& getSelectedChar();
78 void SetFont( const vcl::Font& rFont );
79 vcl::Font const & GetFont() const { return maFont; }
80 FontCharMapRef const & GetFontCharMap();
81 bool isFavChar(std::u16string_view sTitle, std::u16string_view rFont);
82 void getFavCharacterList(); //gets both Fav char and Fav char font list
83 void updateFavCharacterList(const OUString& rChar, const OUString& rFont);
84
85 virtual svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
86 int FirstInView() const;
87 virtual int LastInView() const;
88 int PixelToMapIndex( const Point&) const;
89 virtual void SelectIndex( int index, bool bFocus = false );
90 void OutputIndex( int index );
91 void DeSelect();
92 static void CopyToClipboard(const OUString& str);
93 bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; }
94 sal_uInt16 GetSelectIndexId() const { return sal::static_int_cast<sal_uInt16>(nSelectedIndex); }
95 static sal_uInt16 GetRowPos(sal_uInt16 _nPos);
96 static sal_uInt16 GetColumnPos(sal_uInt16 _nPos);
97
98 virtual sal_Int32 getMaxCharCount() const;
99
100 virtual void Show() override { mxScrollArea->show(); }
101 virtual void Hide() override { mxScrollArea->hide(); }
102
103 uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
104
105private:
106 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
107 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
108 virtual void Resize() override;
109 virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
110 virtual bool MouseMove(const MouseEvent& rMEvt) override;
111 virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
112 virtual void GetFocus() override;
113 virtual void LoseFocus() override;
114 virtual bool Command(const CommandEvent& rCEvt) override;
115
116 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
117 virtual FactoryFunction GetUITestFactory() const override;
118
119protected:
120 typedef std::map<sal_Int32, std::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
128
129 std::deque<OUString> maFavCharList;
130 std::deque<OUString> maFavCharFontList;
131
137 bool bDrag;
138
139 sal_Int32 nSelectedIndex;
140
143
147
148
149protected:
150 virtual bool KeyInput(const KeyEvent&) override;
151 virtual void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2);
152 void InitSettings(vcl::RenderContext& rRenderContext);
153 // abstraction layers are: Unicode<->MapIndex<->Pixel
154 Point MapIndexToPixel( int) const;
156 void ContextMenuSelect(std::u16string_view rIdent);
157
158 void init();
159 tools::Rectangle getGridRectangle(const Point &rPointUL, const Size &rOutputSize) const;
160};
161
162#endif
163
164/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FILE * init(int, char **)
void SetDoubleClickHdl(const Link< SvxShowCharSet *, void > &rLink)
Definition: charmap.hxx:71
void SetReturnKeyPressHdl(const Link< SvxShowCharSet *, void > &rLink)
Definition: charmap.hxx:72
std::deque< OUString > maFavCharFontList
Definition: charmap.hxx:130
bool mbUpdateBackground
Definition: charmap.hxx:146
FontCharMapRef mxFontCharMap
Definition: charmap.hxx:141
bool mbUpdateForeground
Definition: charmap.hxx:145
void SetHighlightHdl(const Link< SvxShowCharSet *, void > &rHdl)
Definition: charmap.hxx:74
VclPtr< VirtualDevice > mxVirDev
Definition: charmap.hxx:58
void SetSelectHdl(const Link< SvxShowCharSet *, void > &rHdl)
Definition: charmap.hxx:73
sal_Int32 nSelectedIndex
Definition: charmap.hxx:139
Link< SvxShowCharSet *, void > aFavClickHdl
Definition: charmap.hxx:125
Link< SvxShowCharSet *, void > aHighHdl
Definition: charmap.hxx:126
tools::Long nX
Definition: charmap.hxx:133
std::unique_ptr< weld::ScrolledWindow > mxScrollArea
Definition: charmap.hxx:60
vcl::Font maFont
Definition: charmap.hxx:59
Link< SvxShowCharSet *, void > aSelectHdl
Definition: charmap.hxx:124
sal_uInt16 GetSelectIndexId() const
Definition: charmap.hxx:94
tools::Long nY
Definition: charmap.hxx:134
tools::Long m_nYGap
Definition: charmap.hxx:136
DECL_DLLPRIVATE_LINK(VscrollHdl, weld::ScrolledWindow &, void)
vcl::Font const & GetFont() const
Definition: charmap.hxx:79
Link< SvxShowCharSet *, void > m_aReturnKeypressHdl
Definition: charmap.hxx:123
void SetFavClickHdl(const Link< SvxShowCharSet *, void > &rHdl)
Definition: charmap.hxx:76
Link< SvxShowCharSet *, void > aDoubleClkHdl
Definition: charmap.hxx:122
uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: charmap.hxx:103
std::deque< OUString > maFavCharList
Definition: charmap.hxx:129
Link< SvxShowCharSet *, void > aPreSelectHdl
Definition: charmap.hxx:127
bool mbRecalculateFont
Definition: charmap.hxx:144
bool IsSelected(sal_uInt16 _nPos) const
Definition: charmap.hxx:93
std::map< sal_Int32, std::shared_ptr< svx::SvxShowCharSetItem > > ItemsMap
Definition: charmap.hxx:120
tools::Long m_nXGap
Definition: charmap.hxx:135
virtual void Hide() override
Definition: charmap.hxx:101
ItemsMap m_aItems
Definition: charmap.hxx:121
rtl::Reference< svx::SvxShowCharSetAcc > m_xAccessible
Definition: charmap.hxx:132
virtual void Show() override
Definition: charmap.hxx:100
void SetPreSelectHdl(const Link< SvxShowCharSet *, void > &rHdl)
Definition: charmap.hxx:75
virtual bool KeyInput(const KeyEvent &)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
virtual bool MouseMove(const MouseEvent &)
virtual FactoryFunction GetUITestFactory() const
virtual bool MouseButtonDown(const MouseEvent &)
weld::DrawingArea * GetDrawingArea() const
virtual bool MouseButtonUp(const MouseEvent &)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
virtual bool Command(const CommandEvent &)
virtual a11yref get_accessible_parent()=0
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
long Long
Simple struct to hold some information about the single items of the table.
Definition: charmapacc.hxx:44
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
static bool SetFont(const SfxItemSet &rSet, sal_uInt16 nSlot, SvxFont &rFont)
Definition: tbcontrl.cxx:1302
#define SAL_WARN_UNUSED
sal_uInt32 sal_UCS4
sal_Int32 _nPos