xref: /trunk/main/sd/source/ui/inc/tools/IdleDetection.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_IDLE_DETECTION_HXX
29 #define SD_IDLE_DETECTION_HXX
30 
31 #include <sal/types.h>
32 
33 class Window;
34 
35 namespace sd { namespace tools {
36 
37 /** Detect whether the system is idle and some time consuming operation may
38     be carried out.  This class ditinguishes between different states of
39     idle-ness.
40 */
41 class IdleDetection
42 {
43 public:
44     /** When GetIdleState() returns this value, then the system is idle.
45     */
46     static const sal_Int32 IDET_IDLE = 0x0000;
47 
48     /** There are system event pending.
49     */
50     static const sal_Int32 IDET_SYSTEM_EVENT_PENDING = 0x0001;
51 
52     /** A full screen slide show is running and is active.  In contrast
53         there may be a full screen show be running in an inactive window,
54         i.e. in the background.
55     */
56     static const sal_Int32 IDET_FULL_SCREEN_SHOW_ACTIVE = 0x0002;
57 
58     /** A slide show is running in a window.
59     */
60     static const sal_Int32 IDET_WINDOW_SHOW_ACTIVE = 0x0004;
61 
62     /** A window is being painted.
63     */
64     static const sal_Int32 IDET_WINDOW_PAINTING = 0x0008;
65 
66     /** Determine whether the system is idle.
67         @param pWindow
68             When a valid Window pointer is given then it is checked
69             whether the window is currently being painting.
70         @return
71             This method either returns IDET_IDLE or a combination of
72             IdleStates values or-ed together that describe what the system
73             is currently doing so that the caller can decide what to do.
74     */
75     static sal_Int32 GetIdleState (const ::Window* pWindow = NULL);
76 
77 private:
78     /** Check whether there are input events pending.
79     */
80     static sal_Int32 CheckInputPending (void);
81 
82     /** Check whether a slide show is running full screen or in a window.
83     */
84     static sal_Int32 CheckSlideShowRunning (void);
85 
86     static sal_Int32 CheckWindowPainting (const ::Window& rWindow);
87 };
88 
89 } } // end of namespace ::sd::tools
90 
91 #endif
92