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 <tools/shl.hxx>
28 : #include <svx/svxdllapi.h>
29 :
30 : // define ----------------------------------------------------------------
31 :
32 : #define COLUMN_COUNT 16
33 : #define ROW_COUNT 8
34 :
35 : namespace svx
36 : {
37 : struct SvxShowCharSetItem;
38 : class SvxShowCharSetVirtualAcc;
39 : }
40 :
41 : // class SvxShowCharSet --------------------------------------------------
42 :
43 : class SVX_DLLPUBLIC SvxShowCharSet : public Control
44 : {
45 : public:
46 : SvxShowCharSet( Window* pParent );
47 : virtual ~SvxShowCharSet();
48 :
49 : void SetFont( const Font& rFont );
50 :
51 : void SelectCharacter( sal_uInt32 cNew, bool bFocus = false );
52 : sal_UCS4 GetSelectCharacter() const;
53 :
54 : Link GetDoubleClickHdl() const { return aDoubleClkHdl; }
55 0 : void SetDoubleClickHdl( const Link& rLink ) { aDoubleClkHdl = rLink; }
56 : Link GetSelectHdl() const { return aSelectHdl; }
57 0 : void SetSelectHdl( const Link& rHdl ) { aSelectHdl = rHdl; }
58 : Link GetHighlightHdl() const { return aHighHdl; }
59 0 : void SetHighlightHdl( const Link& rHdl ) { aHighHdl = rHdl; }
60 : Link GetPreSelectHdl() const { return aHighHdl; }
61 0 : void SetPreSelectHdl( const Link& rHdl ) { aPreSelectHdl = rHdl; }
62 : static sal_uInt32& getSelectedChar();
63 :
64 : ::svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
65 : int FirstInView( void) const;
66 : int LastInView( void) const;
67 : int PixelToMapIndex( const Point&) const;
68 : void SelectIndex( int index, bool bFocus = false );
69 : void DeSelect();
70 0 : inline bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; }
71 0 : inline sal_uInt16 GetSelectIndexId() const { return sal::static_int_cast<sal_uInt16>(nSelectedIndex); }
72 : sal_uInt16 GetRowPos(sal_uInt16 _nPos) const;
73 : sal_uInt16 GetColumnPos(sal_uInt16 _nPos) const;
74 :
75 : ScrollBar* getScrollBar();
76 : void ReleaseAccessible();
77 : sal_Int32 getMaxCharCount() const;
78 :
79 : virtual void Resize() SAL_OVERRIDE;
80 :
81 : protected:
82 : virtual void Paint( 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;
92 :
93 :
94 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
95 :
96 :
97 :
98 : private:
99 : typedef ::std::map<sal_Int32, boost::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
100 : ItemsMap m_aItems;
101 : Link aDoubleClkHdl;
102 : Link aSelectHdl;
103 : Link aHighHdl;
104 : Link aPreSelectHdl;
105 : ::svx::SvxShowCharSetVirtualAcc* m_pAccessible;
106 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccessible;
107 : long nX;
108 : long nY;
109 : long m_nXGap;
110 : long m_nYGap;
111 : bool bDrag;
112 :
113 : sal_Int32 nSelectedIndex;
114 :
115 : FontCharMap maFontCharMap;
116 : ScrollBar aVscrollSB;
117 :
118 : private:
119 : void DrawChars_Impl( int n1, int n2);
120 : void InitSettings( bool bForeground, bool bBackground);
121 : // abstraction layers are: Unicode<->MapIndex<->Pixel
122 : Point MapIndexToPixel( int) const;
123 : DECL_LINK(VscrollHdl, void *);
124 :
125 : void init();
126 : Rectangle getGridRectangle(const Point &rPointUL, const Size &rOutputSize);
127 : };
128 :
129 : #endif
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|