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 _SVX_CHARMAP_HXX
20 : #define _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, const ResId& rResId );
47 : SvxShowCharSet( Window* pParent );
48 : ~SvxShowCharSet();
49 :
50 : void SetFont( const Font& rFont );
51 :
52 : void SelectCharacter( sal_uInt32 cNew, sal_Bool bFocus = sal_False );
53 : sal_UCS4 GetSelectCharacter() const;
54 :
55 : Link GetDoubleClickHdl() const { return aDoubleClkHdl; }
56 0 : void SetDoubleClickHdl( const Link& rLink ) { aDoubleClkHdl = rLink; }
57 : Link GetSelectHdl() const { return aSelectHdl; }
58 0 : void SetSelectHdl( const Link& rHdl ) { aSelectHdl = rHdl; }
59 : Link GetHighlightHdl() const { return aHighHdl; }
60 0 : void SetHighlightHdl( const Link& rHdl ) { aHighHdl = rHdl; }
61 : Link GetPreSelectHdl() const { return aHighHdl; }
62 0 : void SetPreSelectHdl( const Link& rHdl ) { aPreSelectHdl = rHdl; }
63 : static sal_uInt32& getSelectedChar();
64 :
65 : ::svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
66 : int FirstInView( void) const;
67 : int LastInView( void) const;
68 : int PixelToMapIndex( const Point&) const;
69 : void SelectIndex( int index, sal_Bool bFocus = sal_False );
70 : void DeSelect();
71 0 : inline sal_Bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; }
72 0 : inline sal_uInt16 GetSelectIndexId() const { return sal::static_int_cast<sal_uInt16>(nSelectedIndex); }
73 : sal_uInt16 GetRowPos(sal_uInt16 _nPos) const;
74 : sal_uInt16 GetColumnPos(sal_uInt16 _nPos) const;
75 :
76 : ScrollBar* getScrollBar();
77 : void ReleaseAccessible();
78 : sal_Int32 getMaxCharCount() const;
79 :
80 : virtual void Resize();
81 :
82 : protected:
83 : virtual void Paint( const Rectangle& );
84 : virtual void MouseButtonDown( const MouseEvent& rMEvt );
85 : virtual void MouseButtonUp( const MouseEvent& rMEvt );
86 : virtual void MouseMove( const MouseEvent& rMEvt );
87 : virtual void Command( const CommandEvent& rCEvt );
88 : virtual void KeyInput( const KeyEvent& rKEvt );
89 : virtual void GetFocus();
90 : virtual void LoseFocus();
91 : virtual void StateChanged( StateChangedType nStateChange );
92 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
93 :
94 :
95 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
96 :
97 :
98 :
99 : private:
100 : typedef ::std::map<sal_Int32, boost::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
101 : ItemsMap m_aItems;
102 : Link aDoubleClkHdl;
103 : Link aSelectHdl;
104 : Link aHighHdl;
105 : Link aPreSelectHdl;
106 : ::svx::SvxShowCharSetVirtualAcc* m_pAccessible;
107 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccessible;
108 : long nX;
109 : long nY;
110 : long m_nXGap;
111 : long m_nYGap;
112 : sal_Bool bDrag;
113 :
114 : sal_Int32 nSelectedIndex;
115 :
116 : FontCharMap maFontCharMap;
117 : ScrollBar aVscrollSB;
118 :
119 : private:
120 : void DrawChars_Impl( int n1, int n2);
121 : void InitSettings( sal_Bool bForeground, sal_Bool bBackground);
122 : // abstraction layers are: Unicode<->MapIndex<->Pixel
123 : Point MapIndexToPixel( int) const;
124 : DECL_LINK(VscrollHdl, void *);
125 :
126 : void init();
127 : Rectangle getGridRectangle(const Point &rPointUL, const Size &rOutputSize);
128 : };
129 :
130 : #endif
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|