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 24 #ifndef _SV_ACCEL_HXX 25 #define _SV_ACCEL_HXX 26 27 #include <vcl/sv.h> 28 #include <vcl/dllapi.h> 29 #include <tools/resid.hxx> 30 #include <tools/rc.hxx> 31 #include <vcl/keycod.hxx> 32 33 class ImplAccelData; 34 class ImplAccelEntry; 35 36 // --------------- 37 // - Accelerator - 38 // --------------- 39 40 class VCL_DLLPUBLIC Accelerator : public Resource 41 { 42 friend class ImplAccelManager; 43 44 private: 45 ImplAccelData* mpData; 46 XubString maHelpStr; 47 Link maActivateHdl; 48 Link maDeactivateHdl; 49 Link maSelectHdl; 50 51 // Werden vom AcceleratorManager gesetzt 52 KeyCode maCurKeyCode; 53 sal_uInt16 mnCurId; 54 sal_uInt16 mnCurRepeat; 55 sal_Bool mbIsCancel; 56 sal_Bool* mpDel; 57 58 //#if 0 // _SOLAR__PRIVATE 59 SAL_DLLPRIVATE void ImplInit(); 60 SAL_DLLPRIVATE void ImplCopyData( ImplAccelData& rAccelData ); 61 SAL_DLLPRIVATE void ImplDeleteData(); 62 SAL_DLLPRIVATE void ImplInsertAccel( sal_uInt16 nItemId, const KeyCode& rKeyCode, 63 sal_Bool bEnable, Accelerator* pAutoAccel ); 64 65 SAL_DLLPRIVATE ImplAccelEntry* ImplGetAccelData( const KeyCode& rKeyCode ) const; 66 //#endif 67 68 protected: 69 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 70 71 public: 72 Accelerator(); 73 Accelerator( const Accelerator& rAccel ); 74 Accelerator( const ResId& rResId ); 75 virtual ~Accelerator(); 76 77 virtual void Activate(); 78 virtual void Deactivate(); 79 virtual void Select(); 80 81 void InsertItem( sal_uInt16 nItemId, const KeyCode& rKeyCode ); 82 void InsertItem( const ResId& rResId ); 83 void RemoveItem( sal_uInt16 nItemId ); 84 void RemoveItem( const KeyCode rKeyCode ); 85 void Clear(); 86 GetCurItemId() const87 sal_uInt16 GetCurItemId() const { return mnCurId; } GetCurKeyCode() const88 const KeyCode& GetCurKeyCode() const { return maCurKeyCode; } GetCurRepeat() const89 sal_uInt16 GetCurRepeat() const { return mnCurRepeat; } IsCancel() const90 sal_Bool IsCancel() const { return mbIsCancel; } 91 92 sal_uInt16 GetItemCount() const; 93 sal_uInt16 GetItemId( sal_uInt16 nPos ) const; 94 KeyCode GetItemKeyCode( sal_uInt16 nPos ) const; 95 sal_uInt16 GetItemId( const KeyCode& rKeyCode ) const; 96 KeyCode GetKeyCode( sal_uInt16 nItemId ) const; 97 sal_Bool IsIdValid( sal_uInt16 nItemId ) const; 98 sal_Bool IsKeyCodeValid( const KeyCode rKeyCode ) const; 99 sal_Bool Call( const KeyCode& rKeyCode, sal_uInt16 nRepeat = 0 ); 100 101 void SetAccel( sal_uInt16 nItemId, Accelerator* pAccel ); 102 Accelerator* GetAccel( sal_uInt16 nItemId ) const; 103 void SetAccel( const KeyCode rKeyCode, Accelerator* pAccel ); 104 Accelerator* GetAccel( const KeyCode rKeyCode ) const; 105 106 void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True ); 107 sal_Bool IsItemEnabled( sal_uInt16 nItemId ) const; 108 void EnableItem( const KeyCode rKeyCode, sal_Bool bEnable = sal_True ); 109 sal_Bool IsItemEnabled( const KeyCode rKeyCode ) const; 110 SetHelpText(const XubString & rHelpText)111 void SetHelpText( const XubString& rHelpText ) { maHelpStr = rHelpText; } GetHelpText() const112 const XubString& GetHelpText() const { return maHelpStr; } 113 SetActivateHdl(const Link & rLink)114 void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; } GetActivateHdl() const115 const Link& GetActivateHdl() const { return maActivateHdl; } SetDeactivateHdl(const Link & rLink)116 void SetDeactivateHdl( const Link& rLink ) { maDeactivateHdl = rLink; } GetDeactivateHdl() const117 const Link& GetDeactivateHdl() const { return maDeactivateHdl; } SetSelectHdl(const Link & rLink)118 void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } GetSelectHdl() const119 const Link& GetSelectHdl() const { return maSelectHdl; } 120 121 Accelerator& operator=( const Accelerator& rAccel ); 122 }; 123 124 #endif // _SV_ACCEL_HXX 125