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
25 #include <sal/types.h>
26 #include <rtl/ref.hxx>
27 #include <svx/svxdllapi.h>
28 #include <tools/gen.hxx>
29 #include <tools/link.hxx>
30 #include <vcl/ctrl.hxx>
31 #include <vcl/event.hxx>
32 #include <vcl/outdev.hxx>
33 #include <vcl/metric.hxx>
34 #include <vcl/vclptr.hxx>
35 #include <vcl/window.hxx>
37 namespace com
{ namespace sun
{ namespace star
{
38 namespace accessibility
{ class XAccessible
; }
41 namespace vcl
{ class Font
; }
43 #define COLUMN_COUNT 16
51 struct SvxShowCharSetItem
;
52 class SvxShowCharSetVirtualAcc
;
55 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxShowCharSet
: public Control
58 SvxShowCharSet( vcl::Window
* pParent
);
59 virtual ~SvxShowCharSet() override
;
60 virtual void dispose() override
;
61 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
63 void RecalculateFont(vcl::RenderContext
& rRenderContext
);
65 void SelectCharacter( sal_uInt32 cNew
);
66 sal_UCS4
GetSelectCharacter() const;
68 void SetDoubleClickHdl( const Link
<SvxShowCharSet
*,void>& rLink
) { aDoubleClkHdl
= rLink
; }
69 void SetSelectHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aSelectHdl
= rHdl
; }
70 void SetHighlightHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aHighHdl
= rHdl
; }
71 void SetPreSelectHdl( const Link
<SvxShowCharSet
*,void>& rHdl
) { aPreSelectHdl
= rHdl
; }
72 static sal_uInt32
& getSelectedChar();
73 void SetFont( const vcl::Font
& rFont
);
75 svx::SvxShowCharSetItem
* ImplGetItem( int _nPos
);
76 int FirstInView() const;
77 int LastInView() const;
78 int PixelToMapIndex( const Point
&) const;
79 void SelectIndex( int index
, bool bFocus
= false );
80 void OutputIndex( int index
);
82 bool IsSelected(sal_uInt16 _nPos
) const { return _nPos
== nSelectedIndex
; }
83 sal_uInt16
GetSelectIndexId() const { return sal::static_int_cast
<sal_uInt16
>(nSelectedIndex
); }
84 static sal_uInt16
GetRowPos(sal_uInt16 _nPos
);
85 static sal_uInt16
GetColumnPos(sal_uInt16 _nPos
);
87 ScrollBar
& getScrollBar() { return *aVscrollSB
.get();}
88 void ReleaseAccessible();
89 sal_Int32
getMaxCharCount() const;
91 virtual void Resize() override
;
93 virtual FactoryFunction
GetUITestFactory() const override
;
96 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& ) override
;
97 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
98 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
99 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
100 virtual void Command( const CommandEvent
& rCEvt
) override
;
101 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
102 virtual void GetFocus() override
;
103 virtual void LoseFocus() override
;
104 virtual void StateChanged( StateChangedType nStateChange
) override
;
105 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
107 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
110 typedef std::map
<sal_Int32
, std::shared_ptr
<svx::SvxShowCharSetItem
> > ItemsMap
;
112 Link
<SvxShowCharSet
*,void> aDoubleClkHdl
;
113 Link
<SvxShowCharSet
*,void> aSelectHdl
;
114 Link
<SvxShowCharSet
*,void> aHighHdl
;
115 Link
<SvxShowCharSet
*,void> aPreSelectHdl
;
116 rtl::Reference
<svx::SvxShowCharSetVirtualAcc
> m_xAccessible
;
123 sal_Int32 nSelectedIndex
;
125 FontCharMapRef mxFontCharMap
;
127 VclPtr
<ScrollBar
> aVscrollSB
;
129 bool mbRecalculateFont
: 1;
130 bool mbUpdateForeground
: 1;
131 bool mbUpdateBackground
: 1;
135 void DrawChars_Impl(vcl::RenderContext
& rRenderContext
, int n1
, int n2
);
136 void InitSettings(vcl::RenderContext
& rRenderContext
);
137 // abstraction layers are: Unicode<->MapIndex<->Pixel
138 Point
MapIndexToPixel( int) const;
139 DECL_LINK(VscrollHdl
, ScrollBar
*, void);
142 tools::Rectangle
getGridRectangle(const Point
&rPointUL
, const Size
&rOutputSize
);
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */