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 :
20 : #ifndef _SV_ACCEL_HXX
21 : #define _SV_ACCEL_HXX
22 :
23 : #include <tools/solar.h>
24 : #include <vcl/dllapi.h>
25 : #include <tools/link.hxx>
26 : #include <tools/resid.hxx>
27 : #include <tools/rc.hxx>
28 : #include <vcl/keycod.hxx>
29 :
30 : class ImplAccelData;
31 : class ImplAccelEntry;
32 :
33 : // ---------------
34 : // - Accelerator -
35 : // ---------------
36 :
37 : class VCL_DLLPUBLIC Accelerator : public Resource
38 : {
39 : friend class ImplAccelManager;
40 :
41 : private:
42 : ImplAccelData* mpData;
43 : XubString maHelpStr;
44 : Link maActivateHdl;
45 : Link maDeactivateHdl;
46 : Link maSelectHdl;
47 :
48 : // Will be set by AcceleratorManager
49 : KeyCode maCurKeyCode;
50 : sal_uInt16 mnCurId;
51 : sal_uInt16 mnCurRepeat;
52 : sal_Bool mbIsCancel;
53 : sal_Bool* mpDel;
54 :
55 : SAL_DLLPRIVATE void ImplInit();
56 : SAL_DLLPRIVATE void ImplCopyData( ImplAccelData& rAccelData );
57 : SAL_DLLPRIVATE void ImplDeleteData();
58 : SAL_DLLPRIVATE void ImplInsertAccel( sal_uInt16 nItemId, const KeyCode& rKeyCode,
59 : sal_Bool bEnable, Accelerator* pAutoAccel );
60 :
61 : SAL_DLLPRIVATE ImplAccelEntry* ImplGetAccelData( const KeyCode& rKeyCode ) const;
62 :
63 : protected:
64 : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
65 :
66 : public:
67 : Accelerator();
68 : Accelerator( const Accelerator& rAccel );
69 : Accelerator( const ResId& rResId );
70 : virtual ~Accelerator();
71 :
72 : virtual void Activate();
73 : virtual void Deactivate();
74 : virtual void Select();
75 :
76 : void InsertItem( sal_uInt16 nItemId, const KeyCode& rKeyCode );
77 : void InsertItem( const ResId& rResId );
78 :
79 0 : sal_uInt16 GetCurItemId() const { return mnCurId; }
80 0 : const KeyCode& GetCurKeyCode() const { return maCurKeyCode; }
81 : sal_uInt16 GetCurRepeat() const { return mnCurRepeat; }
82 : sal_Bool IsCancel() const { return mbIsCancel; }
83 :
84 : sal_uInt16 GetItemCount() const;
85 : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
86 : KeyCode GetKeyCode( sal_uInt16 nItemId ) const;
87 :
88 : Accelerator* GetAccel( sal_uInt16 nItemId ) const;
89 :
90 : void SetHelpText( const XubString& rHelpText ) { maHelpStr = rHelpText; }
91 : const XubString& GetHelpText() const { return maHelpStr; }
92 :
93 0 : void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; }
94 : const Link& GetActivateHdl() const { return maActivateHdl; }
95 : void SetDeactivateHdl( const Link& rLink ) { maDeactivateHdl = rLink; }
96 : const Link& GetDeactivateHdl() const { return maDeactivateHdl; }
97 11 : void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
98 : const Link& GetSelectHdl() const { return maSelectHdl; }
99 :
100 : Accelerator& operator=( const Accelerator& rAccel );
101 : };
102 :
103 : #endif // _SV_ACCEL_HXX
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|