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>
26 #include <boost/shared_ptr.hpp>
29 #include <svx/svxdllapi.h>
31 #define COLUMN_COUNT 16
36 struct SvxShowCharSetItem
;
37 class SvxShowCharSetVirtualAcc
;
40 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxShowCharSet
: public Control
43 SvxShowCharSet( vcl::Window
* pParent
);
44 virtual ~SvxShowCharSet();
45 virtual void dispose() SAL_OVERRIDE
;
46 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) SAL_OVERRIDE
;
48 void RecalculateFont(vcl::RenderContext
& rRenderContext
);
50 void SelectCharacter( sal_uInt32 cNew
, bool bFocus
= false );
51 sal_UCS4
GetSelectCharacter() const;
53 Link
<> GetDoubleClickHdl() const { return aDoubleClkHdl
; }
54 void SetDoubleClickHdl( const Link
<>& rLink
) { aDoubleClkHdl
= rLink
; }
55 Link
<> GetSelectHdl() const { return aSelectHdl
; }
56 void SetSelectHdl( const Link
<>& rHdl
) { aSelectHdl
= rHdl
; }
57 Link
<> GetHighlightHdl() const { return aHighHdl
; }
58 void SetHighlightHdl( const Link
<>& rHdl
) { aHighHdl
= rHdl
; }
59 Link
<> GetPreSelectHdl() const { return aHighHdl
; }
60 void SetPreSelectHdl( const Link
<>& rHdl
) { aPreSelectHdl
= rHdl
; }
61 static sal_uInt32
& getSelectedChar();
62 void SetFont( const vcl::Font
& rFont
);
64 svx::SvxShowCharSetItem
* ImplGetItem( int _nPos
);
65 int FirstInView() const;
66 int LastInView() const;
67 int PixelToMapIndex( const Point
&) const;
68 void SelectIndex( int index
, bool bFocus
= false );
70 inline bool IsSelected(sal_uInt16 _nPos
) const { return _nPos
== nSelectedIndex
; }
71 inline sal_uInt16
GetSelectIndexId() const { return sal::static_int_cast
<sal_uInt16
>(nSelectedIndex
); }
72 static sal_uInt16
GetRowPos(sal_uInt16 _nPos
);
73 static sal_uInt16
GetColumnPos(sal_uInt16 _nPos
);
75 ScrollBar
& getScrollBar() { return *aVscrollSB
.get();}
76 void ReleaseAccessible();
77 sal_Int32
getMaxCharCount() const;
79 virtual void Resize() SAL_OVERRIDE
;
82 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& ) SAL_OVERRIDE
;
83 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
84 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
85 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
86 virtual void Command( const CommandEvent
& rCEvt
) SAL_OVERRIDE
;
87 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
88 virtual void GetFocus() SAL_OVERRIDE
;
89 virtual void LoseFocus() SAL_OVERRIDE
;
90 virtual void StateChanged( StateChangedType nStateChange
) SAL_OVERRIDE
;
91 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
93 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() SAL_OVERRIDE
;
96 typedef std::map
<sal_Int32
, std::shared_ptr
<svx::SvxShowCharSetItem
> > ItemsMap
;
101 Link
<> aPreSelectHdl
;
102 svx::SvxShowCharSetVirtualAcc
* m_pAccessible
;
103 css::uno::Reference
<css::accessibility::XAccessible
> m_xAccessible
;
110 sal_Int32 nSelectedIndex
;
112 FontCharMapPtr mpFontCharMap
;
114 VclPtr
<ScrollBar
> aVscrollSB
;
116 bool mbRecalculateFont
: 1;
117 bool mbUpdateForeground
: 1;
118 bool mbUpdateBackground
: 1;
122 void DrawChars_Impl(vcl::RenderContext
& rRenderContext
, int n1
, int n2
);
123 void InitSettings(vcl::RenderContext
& rRenderContext
);
124 // abstraction layers are: Unicode<->MapIndex<->Pixel
125 Point
MapIndexToPixel( int) const;
126 DECL_LINK(VscrollHdl
, void *);
129 Rectangle
getGridRectangle(const Point
&rPointUL
, const Size
&rOutputSize
);
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */