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 <vcl/ctrl.hxx>
23 #include <vcl/metric.hxx>
24 #include <vcl/scrbar.hxx>
25 #include <vcl/vclptr.hxx>
28 #include <svx/svxdllapi.h>
30 #define COLUMN_COUNT 16
35 struct SvxShowCharSetItem
;
36 class SvxShowCharSetVirtualAcc
;
39 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxShowCharSet
: public Control
42 SvxShowCharSet( vcl::Window
* pParent
);
43 virtual ~SvxShowCharSet() override
;
44 virtual void dispose() override
;
45 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
47 void RecalculateFont(vcl::RenderContext
& rRenderContext
);
49 void SelectCharacter( sal_uInt32 cNew
);
50 sal_UCS4
GetSelectCharacter() const;
52 void SetDoubleClickHdl( const Link
<SvxShowCharSet
*,void>& rLink
) { aDoubleClkHdl
= rLink
; }
53 void SetSelectHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aSelectHdl
= rHdl
; }
54 void SetHighlightHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aHighHdl
= rHdl
; }
55 void SetPreSelectHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aPreSelectHdl
= rHdl
; }
56 static sal_uInt32
& getSelectedChar();
57 void SetFont( const vcl::Font
& rFont
);
59 svx::SvxShowCharSetItem
* ImplGetItem( int _nPos
);
60 int FirstInView() const;
61 int LastInView() const;
62 int PixelToMapIndex( const Point
&) const;
63 void SelectIndex( int index
, bool bFocus
= false );
64 void OutputIndex( int index
);
66 inline bool IsSelected(sal_uInt16 _nPos
) const { return _nPos
== nSelectedIndex
; }
67 inline sal_uInt16
GetSelectIndexId() const { return sal::static_int_cast
<sal_uInt16
>(nSelectedIndex
); }
68 static sal_uInt16
GetRowPos(sal_uInt16 _nPos
);
69 static sal_uInt16
GetColumnPos(sal_uInt16 _nPos
);
71 ScrollBar
& getScrollBar() { return *aVscrollSB
.get();}
72 void ReleaseAccessible();
73 sal_Int32
getMaxCharCount() const;
75 virtual void Resize() override
;
77 virtual FactoryFunction
GetUITestFactory() const override
;
80 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& ) override
;
81 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
82 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
83 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
84 virtual void Command( const CommandEvent
& rCEvt
) override
;
85 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
86 virtual void GetFocus() override
;
87 virtual void LoseFocus() override
;
88 virtual void StateChanged( StateChangedType nStateChange
) override
;
89 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
91 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
94 typedef std::map
<sal_Int32
, std::shared_ptr
<svx::SvxShowCharSetItem
> > ItemsMap
;
96 Link
<SvxShowCharSet
*,void> aDoubleClkHdl
;
97 Link
<SvxShowCharSet
*,void> aSelectHdl
;
98 Link
<SvxShowCharSet
*,void> aHighHdl
;
99 Link
<SvxShowCharSet
*,void> aPreSelectHdl
;
100 svx::SvxShowCharSetVirtualAcc
* m_pAccessible
;
101 css::uno::Reference
<css::accessibility::XAccessible
> m_xAccessible
;
108 sal_Int32 nSelectedIndex
;
110 FontCharMapRef mxFontCharMap
;
112 VclPtr
<ScrollBar
> aVscrollSB
;
114 bool mbRecalculateFont
: 1;
115 bool mbUpdateForeground
: 1;
116 bool mbUpdateBackground
: 1;
120 void DrawChars_Impl(vcl::RenderContext
& rRenderContext
, int n1
, int n2
);
121 void InitSettings(vcl::RenderContext
& rRenderContext
);
122 // abstraction layers are: Unicode<->MapIndex<->Pixel
123 Point
MapIndexToPixel( int) const;
124 DECL_LINK(VscrollHdl
, ScrollBar
*, void);
127 Rectangle
getGridRectangle(const Point
&rPointUL
, const Size
&rOutputSize
);
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */