Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_ACCEL_HXX
30 : : #define _SV_ACCEL_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <tools/link.hxx>
35 : : #include <tools/resid.hxx>
36 : : #include <tools/rc.hxx>
37 : : #include <vcl/keycod.hxx>
38 : :
39 : : class ImplAccelData;
40 : : class ImplAccelEntry;
41 : :
42 : : // ---------------
43 : : // - Accelerator -
44 : : // ---------------
45 : :
46 : : class VCL_DLLPUBLIC Accelerator : public Resource
47 : : {
48 : : friend class ImplAccelManager;
49 : :
50 : : private:
51 : : ImplAccelData* mpData;
52 : : XubString maHelpStr;
53 : : Link maActivateHdl;
54 : : Link maDeactivateHdl;
55 : : Link maSelectHdl;
56 : :
57 : : // Will be set by AcceleratorManager
58 : : KeyCode maCurKeyCode;
59 : : sal_uInt16 mnCurId;
60 : : sal_uInt16 mnCurRepeat;
61 : : sal_Bool mbIsCancel;
62 : : sal_Bool* mpDel;
63 : :
64 : : SAL_DLLPRIVATE void ImplInit();
65 : : SAL_DLLPRIVATE void ImplCopyData( ImplAccelData& rAccelData );
66 : : SAL_DLLPRIVATE void ImplDeleteData();
67 : : SAL_DLLPRIVATE void ImplInsertAccel( sal_uInt16 nItemId, const KeyCode& rKeyCode,
68 : : sal_Bool bEnable, Accelerator* pAutoAccel );
69 : :
70 : : SAL_DLLPRIVATE ImplAccelEntry* ImplGetAccelData( const KeyCode& rKeyCode ) const;
71 : :
72 : : protected:
73 : : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
74 : :
75 : : public:
76 : : Accelerator();
77 : : Accelerator( const Accelerator& rAccel );
78 : : Accelerator( const ResId& rResId );
79 : : virtual ~Accelerator();
80 : :
81 : : virtual void Activate();
82 : : virtual void Deactivate();
83 : : virtual void Select();
84 : :
85 : : void InsertItem( sal_uInt16 nItemId, const KeyCode& rKeyCode );
86 : : void InsertItem( const ResId& rResId );
87 : :
88 : 0 : sal_uInt16 GetCurItemId() const { return mnCurId; }
89 : 0 : const KeyCode& GetCurKeyCode() const { return maCurKeyCode; }
90 : : sal_uInt16 GetCurRepeat() const { return mnCurRepeat; }
91 : : sal_Bool IsCancel() const { return mbIsCancel; }
92 : :
93 : : sal_uInt16 GetItemCount() const;
94 : : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
95 : : KeyCode GetKeyCode( sal_uInt16 nItemId ) const;
96 : :
97 : : Accelerator* GetAccel( sal_uInt16 nItemId ) const;
98 : :
99 : : void SetHelpText( const XubString& rHelpText ) { maHelpStr = rHelpText; }
100 : : const XubString& GetHelpText() const { return maHelpStr; }
101 : :
102 : 0 : void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; }
103 : : const Link& GetActivateHdl() const { return maActivateHdl; }
104 : : void SetDeactivateHdl( const Link& rLink ) { maDeactivateHdl = rLink; }
105 : : const Link& GetDeactivateHdl() const { return maDeactivateHdl; }
106 : 1466 : void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
107 : : const Link& GetSelectHdl() const { return maSelectHdl; }
108 : :
109 : : Accelerator& operator=( const Accelerator& rAccel );
110 : : };
111 : :
112 : : #endif // _SV_ACCEL_HXX
113 : :
114 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|