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 : vcl::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(
54 : sal_uInt16 nItemId,
55 : const vcl::KeyCode& rKeyCode,
56 : bool bEnable,
57 : Accelerator* pAutoAccel );
58 :
59 : SAL_DLLPRIVATE ImplAccelEntry*
60 : ImplGetAccelData( const vcl::KeyCode& rKeyCode ) const;
61 :
62 : protected:
63 : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
64 :
65 : public:
66 : Accelerator();
67 : Accelerator( const Accelerator& rAccel );
68 : Accelerator( const ResId& rResId );
69 : virtual ~Accelerator();
70 :
71 : void Activate();
72 : void Deactivate();
73 : void Select();
74 :
75 : void InsertItem( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode );
76 : void InsertItem( const ResId& rResId );
77 :
78 0 : sal_uInt16 GetCurItemId() const { return mnCurId; }
79 0 : const vcl::KeyCode& GetCurKeyCode() const { return maCurKeyCode; }
80 : sal_uInt16 GetCurRepeat() const { return mnCurRepeat; }
81 : bool IsCancel() const { return mbIsCancel; }
82 :
83 : sal_uInt16 GetItemCount() const;
84 : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
85 : vcl::KeyCode GetKeyCode( sal_uInt16 nItemId ) const;
86 :
87 : Accelerator* GetAccel( sal_uInt16 nItemId ) const;
88 :
89 : void SetHelpText( const OUString& rHelpText ) { maHelpStr = rHelpText; }
90 : const OUString& GetHelpText() const { return maHelpStr; }
91 :
92 0 : void SetActivateHdl( const Link<>& rLink ) { maActivateHdl = rLink; }
93 : const Link<>& GetActivateHdl() const { return maActivateHdl; }
94 : void SetDeactivateHdl( const Link<>& rLink ) { maDeactivateHdl = rLink; }
95 : const Link<>& GetDeactivateHdl() const { return maDeactivateHdl; }
96 3072 : void SetSelectHdl( const Link<>& rLink ) { maSelectHdl = rLink; }
97 : const Link<>& GetSelectHdl() const { return maSelectHdl; }
98 :
99 : Accelerator& operator=( const Accelerator& rAccel );
100 : };
101 :
102 : #endif // INCLUDED_VCL_ACCEL_HXX
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|