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