1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _SVX_CHARMAP_HXX 24 #define _SVX_CHARMAP_HXX 25 26 // include --------------------------------------------------------------- 27 28 #include <vcl/ctrl.hxx> 29 #include <vcl/metric.hxx> 30 #include <vcl/scrbar.hxx> 31 #include <map> 32 #include <tools/shl.hxx> //add CHINA001 33 #include <tools/debug.hxx> //add CHINA001 34 #include "svx/svxdllapi.h" 35 36 // define ---------------------------------------------------------------- 37 38 #define COLUMN_COUNT 16 39 #define ROW_COUNT 8 40 41 namespace svx 42 { 43 struct SvxShowCharSetItem; 44 class SvxShowCharSetVirtualAcc; 45 } 46 47 // class SvxShowCharSet -------------------------------------------------- 48 49 class SVX_DLLPUBLIC SvxShowCharSet : public Control 50 { 51 public: 52 SvxShowCharSet( Window* pParent, const ResId& rResId ); 53 ~SvxShowCharSet(); 54 55 void SetFont( const Font& rFont ); 56 57 void SelectCharacter( sal_uInt32 cNew, sal_Bool bFocus = sal_False ); 58 sal_UCS4 GetSelectCharacter() const; 59 GetDoubleClickHdl() const60 Link GetDoubleClickHdl() const { return aDoubleClkHdl; } SetDoubleClickHdl(const Link & rLink)61 void SetDoubleClickHdl( const Link& rLink ) { aDoubleClkHdl = rLink; } GetSelectHdl() const62 Link GetSelectHdl() const { return aSelectHdl; } SetSelectHdl(const Link & rHdl)63 void SetSelectHdl( const Link& rHdl ) { aSelectHdl = rHdl; } GetHighlightHdl() const64 Link GetHighlightHdl() const { return aHighHdl; } SetHighlightHdl(const Link & rHdl)65 void SetHighlightHdl( const Link& rHdl ) { aHighHdl = rHdl; } GetPreSelectHdl() const66 Link GetPreSelectHdl() const { return aHighHdl; } SetPreSelectHdl(const Link & rHdl)67 void SetPreSelectHdl( const Link& rHdl ) { aPreSelectHdl = rHdl; } 68 static sal_uInt32& getSelectedChar(); 69 70 #ifdef _SVX_CHARMAP_CXX_ 71 ::svx::SvxShowCharSetItem* ImplGetItem( int _nPos ); 72 int FirstInView( void) const; 73 int LastInView( void) const; 74 int PixelToMapIndex( const Point&) const; 75 void SelectIndex( int index, sal_Bool bFocus = sal_False ); 76 void DeSelect(); IsSelected(sal_uInt16 _nPos) const77 inline sal_Bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; } GetSelectIndexId() const78 inline sal_uInt16 GetSelectIndexId() const { return sal::static_int_cast<sal_uInt16>(nSelectedIndex); } 79 sal_uInt16 GetRowPos(sal_uInt16 _nPos) const; 80 sal_uInt16 GetColumnPos(sal_uInt16 _nPos) const; 81 82 void ImplFireAccessibleEvent( short nEventId, 83 const ::com::sun::star::uno::Any& rOldValue, 84 const ::com::sun::star::uno::Any& rNewValue ); 85 ScrollBar* getScrollBar(); 86 void ReleaseAccessible(); 87 sal_Int32 getMaxCharCount() const; 88 #endif // _SVX_CHARMAP_CXX_ 89 90 protected: 91 virtual void Paint( const Rectangle& ); 92 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 93 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 94 virtual void MouseMove( const MouseEvent& rMEvt ); 95 virtual void Command( const CommandEvent& rCEvt ); 96 virtual void KeyInput( const KeyEvent& rKEvt ); 97 virtual void GetFocus(); 98 virtual void LoseFocus(); 99 virtual void StateChanged( StateChangedType nStateChange ); 100 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 101 102 103 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 104 105 106 107 private: 108 typedef ::std::map<sal_Int32, ::svx::SvxShowCharSetItem*> ItemsMap; 109 ItemsMap m_aItems; 110 Link aDoubleClkHdl; 111 Link aSelectHdl; 112 Link aHighHdl; 113 Link aPreSelectHdl; 114 ::svx::SvxShowCharSetVirtualAcc* m_pAccessible; 115 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccessible; 116 long nX; 117 long nY; 118 sal_Bool bDrag; 119 120 sal_Int32 nSelectedIndex; 121 122 FontCharMap maFontCharMap; 123 ScrollBar aVscrollSB; 124 Size aOrigSize; 125 Point aOrigPos; 126 127 private: 128 void DrawChars_Impl( int n1, int n2); 129 void InitSettings( sal_Bool bForeground, sal_Bool bBackground); 130 // abstraction layers are: Unicode<->MapIndex<->Pixel 131 Point MapIndexToPixel( int) const; 132 DECL_LINK( VscrollHdl, ScrollBar* ); 133 }; 134 135 #endif 136 137