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 <boost/shared_ptr.hpp>
26 : #include <map>
27 : #include <svx/svxdllapi.h>
28 :
29 : // define ----------------------------------------------------------------
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 SvxShowCharSet --------------------------------------------------
41 :
42 : class SVX_DLLPUBLIC SvxShowCharSet : public Control
43 : {
44 : public:
45 : SvxShowCharSet( vcl::Window* pParent );
46 : virtual ~SvxShowCharSet();
47 :
48 : void SetFont( const vcl::Font& rFont );
49 :
50 : void SelectCharacter( sal_uInt32 cNew, bool bFocus = false );
51 : sal_UCS4 GetSelectCharacter() const;
52 :
53 : Link GetDoubleClickHdl() const { return aDoubleClkHdl; }
54 0 : void SetDoubleClickHdl( const Link& rLink ) { aDoubleClkHdl = rLink; }
55 : Link GetSelectHdl() const { return aSelectHdl; }
56 0 : void SetSelectHdl( const Link& rHdl ) { aSelectHdl = rHdl; }
57 : Link GetHighlightHdl() const { return aHighHdl; }
58 0 : void SetHighlightHdl( const Link& rHdl ) { aHighHdl = rHdl; }
59 : Link GetPreSelectHdl() const { return aHighHdl; }
60 0 : void SetPreSelectHdl( const Link& rHdl ) { aPreSelectHdl = rHdl; }
61 : static sal_uInt32& getSelectedChar();
62 :
63 : ::svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
64 : int FirstInView( void) const;
65 : int LastInView( void) const;
66 : int PixelToMapIndex( const Point&) const;
67 : void SelectIndex( int index, bool bFocus = false );
68 : void DeSelect();
69 0 : inline bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; }
70 0 : inline sal_uInt16 GetSelectIndexId() const { return sal::static_int_cast<sal_uInt16>(nSelectedIndex); }
71 : sal_uInt16 GetRowPos(sal_uInt16 _nPos) const;
72 : sal_uInt16 GetColumnPos(sal_uInt16 _nPos) const;
73 :
74 0 : ScrollBar& getScrollBar() { return aVscrollSB;}
75 : void ReleaseAccessible();
76 : sal_Int32 getMaxCharCount() const;
77 :
78 : virtual void Resize() SAL_OVERRIDE;
79 :
80 : protected:
81 : virtual void Paint( const Rectangle& ) SAL_OVERRIDE;
82 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
83 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
84 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
85 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
86 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
87 : virtual void GetFocus() SAL_OVERRIDE;
88 : virtual void LoseFocus() SAL_OVERRIDE;
89 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
90 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
91 :
92 :
93 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
94 :
95 :
96 :
97 : private:
98 : typedef ::std::map<sal_Int32, boost::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
99 : ItemsMap m_aItems;
100 : Link aDoubleClkHdl;
101 : Link aSelectHdl;
102 : Link aHighHdl;
103 : Link aPreSelectHdl;
104 : ::svx::SvxShowCharSetVirtualAcc* m_pAccessible;
105 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccessible;
106 : long nX;
107 : long nY;
108 : long m_nXGap;
109 : long m_nYGap;
110 : bool bDrag;
111 :
112 : sal_Int32 nSelectedIndex;
113 :
114 : FontCharMapPtr mpFontCharMap;
115 : ScrollBar aVscrollSB;
116 :
117 : private:
118 : void DrawChars_Impl( int n1, int n2);
119 : void InitSettings( bool bForeground, bool bBackground);
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: */
|