Line data Source code
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 <vcl/ctrl.hxx>
23 : #include <vcl/metric.hxx>
24 : #include <vcl/scrbar.hxx>
25 : #include <vcl/vclptr.hxx>
26 : #include <boost/shared_ptr.hpp>
27 : #include <map>
28 : #include <memory>
29 : #include <svx/svxdllapi.h>
30 :
31 : #define COLUMN_COUNT 16
32 : #define ROW_COUNT 8
33 :
34 : namespace svx
35 : {
36 : struct SvxShowCharSetItem;
37 : class SvxShowCharSetVirtualAcc;
38 : }
39 :
40 : class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxShowCharSet : public Control
41 : {
42 : public:
43 : SvxShowCharSet( vcl::Window* pParent );
44 : virtual ~SvxShowCharSet();
45 : virtual void dispose() SAL_OVERRIDE;
46 :
47 : void RecalculateFont(vcl::RenderContext& rRenderContext);
48 :
49 : void SelectCharacter( sal_uInt32 cNew, bool bFocus = false );
50 : sal_UCS4 GetSelectCharacter() const;
51 :
52 : Link<> GetDoubleClickHdl() const { return aDoubleClkHdl; }
53 0 : void SetDoubleClickHdl( const Link<>& rLink ) { aDoubleClkHdl = rLink; }
54 : Link<> GetSelectHdl() const { return aSelectHdl; }
55 0 : void SetSelectHdl( const Link<>& rHdl ) { aSelectHdl = rHdl; }
56 : Link<> GetHighlightHdl() const { return aHighHdl; }
57 0 : void SetHighlightHdl( const Link<>& rHdl ) { aHighHdl = rHdl; }
58 : Link<> GetPreSelectHdl() const { return aHighHdl; }
59 0 : void SetPreSelectHdl( const Link<>& rHdl ) { aPreSelectHdl = rHdl; }
60 : static sal_uInt32& getSelectedChar();
61 :
62 : svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
63 : int FirstInView() const;
64 : int LastInView() const;
65 : int PixelToMapIndex( const Point&) const;
66 : void SelectIndex( int index, bool bFocus = false );
67 : void DeSelect();
68 0 : inline bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; }
69 0 : inline sal_uInt16 GetSelectIndexId() const { return sal::static_int_cast<sal_uInt16>(nSelectedIndex); }
70 : static sal_uInt16 GetRowPos(sal_uInt16 _nPos);
71 : static sal_uInt16 GetColumnPos(sal_uInt16 _nPos);
72 :
73 0 : ScrollBar& getScrollBar() { return *aVscrollSB.get();}
74 : void ReleaseAccessible();
75 : sal_Int32 getMaxCharCount() const;
76 :
77 : virtual void Resize() SAL_OVERRIDE;
78 :
79 : protected:
80 : virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) SAL_OVERRIDE;
81 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
82 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
83 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
84 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
85 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
86 : virtual void GetFocus() SAL_OVERRIDE;
87 : virtual void LoseFocus() SAL_OVERRIDE;
88 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
89 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
90 :
91 : virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
92 :
93 : private:
94 : typedef std::map<sal_Int32, std::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
95 : ItemsMap m_aItems;
96 : Link<> aDoubleClkHdl;
97 : Link<> aSelectHdl;
98 : Link<> aHighHdl;
99 : Link<> aPreSelectHdl;
100 : svx::SvxShowCharSetVirtualAcc* m_pAccessible;
101 : css::uno::Reference<css::accessibility::XAccessible> m_xAccessible;
102 : long nX;
103 : long nY;
104 : long m_nXGap;
105 : long m_nYGap;
106 : bool bDrag;
107 :
108 : sal_Int32 nSelectedIndex;
109 :
110 : FontCharMapPtr mpFontCharMap;
111 : VclPtr<ScrollBar> aVscrollSB;
112 :
113 : bool mbRecalculateFont : 1;
114 : bool mbUpdateForeground : 1;
115 : bool mbUpdateBackground : 1;
116 :
117 : private:
118 : void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2);
119 : void InitSettings(vcl::RenderContext& rRenderContext);
120 : // abstraction layers are: Unicode<->MapIndex<->Pixel
121 : Point MapIndexToPixel( int) const;
122 : DECL_LINK(VscrollHdl, void *);
123 :
124 : void init();
125 : Rectangle getGridRectangle(const Point &rPointUL, const Size &rOutputSize);
126 : };
127 :
128 : #endif
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|