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 : #ifdef _SVX_CHARMAP_CXX_
66 : ::svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
67 : int FirstInView( void) const;
68 : int LastInView( void) const;
69 : int PixelToMapIndex( const Point&) const;
70 : void SelectIndex( int index, sal_Bool bFocus = sal_False );
71 : void DeSelect();
72 : inline sal_Bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; }
73 : inline sal_uInt16 GetSelectIndexId() const { return sal::static_int_cast<sal_uInt16>(nSelectedIndex); }
74 : sal_uInt16 GetRowPos(sal_uInt16 _nPos) const;
75 : sal_uInt16 GetColumnPos(sal_uInt16 _nPos) const;
76 :
77 : ScrollBar* getScrollBar();
78 : void ReleaseAccessible();
79 : sal_Int32 getMaxCharCount() const;
80 : #endif // _SVX_CHARMAP_CXX_
81 :
82 : virtual void Resize();
83 :
84 : protected:
85 : virtual void Paint( const Rectangle& );
86 : virtual void MouseButtonDown( const MouseEvent& rMEvt );
87 : virtual void MouseButtonUp( const MouseEvent& rMEvt );
88 : virtual void MouseMove( const MouseEvent& rMEvt );
89 : virtual void Command( const CommandEvent& rCEvt );
90 : virtual void KeyInput( const KeyEvent& rKEvt );
91 : virtual void GetFocus();
92 : virtual void LoseFocus();
93 : virtual void StateChanged( StateChangedType nStateChange );
94 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
95 :
96 :
97 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
98 :
99 :
100 :
101 : private:
102 : typedef ::std::map<sal_Int32, boost::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
103 : ItemsMap m_aItems;
104 : Link aDoubleClkHdl;
105 : Link aSelectHdl;
106 : Link aHighHdl;
107 : Link aPreSelectHdl;
108 : ::svx::SvxShowCharSetVirtualAcc* m_pAccessible;
109 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccessible;
110 : long nX;
111 : long nY;
112 : sal_Bool bDrag;
113 :
114 : sal_Int32 nSelectedIndex;
115 :
116 : FontCharMap maFontCharMap;
117 : ScrollBar aVscrollSB;
118 : Size aOrigSize;
119 : Point aOrigPos;
120 :
121 : private:
122 : void DrawChars_Impl( int n1, int n2);
123 : void InitSettings( sal_Bool bForeground, sal_Bool bBackground);
124 : // abstraction layers are: Unicode<->MapIndex<->Pixel
125 : Point MapIndexToPixel( int) const;
126 : DECL_LINK(VscrollHdl, void *);
127 :
128 : void init();
129 : };
130 :
131 : #endif
132 :
133 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|