LibreOffice Module vcl (master)  1
osx/saltimer.h
Go to the documentation of this file.
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_INC_OSX_SALTIMER_H
21 #define INCLUDED_VCL_INC_OSX_SALTIMER_H
22 
23 #include <premac.h>
24 #include <Cocoa/Cocoa.h>
25 #include <postmac.h>
26 
27 #include <saltimer.hxx>
28 
33 void ImplNSAppPostEvent( short nEventId, BOOL bAtStart, int nUserData = 0 );
34 
36 {
37  NSAutoreleasePool* mpPool;
38 
39 public:
40  ReleasePoolHolder() : mpPool( [[NSAutoreleasePool alloc] init] ) {}
41  ~ReleasePoolHolder() { [mpPool release]; }
42 };
43 
44 class AquaSalTimer final : public SalTimer, protected VersionedEvent
45 {
46  NSTimer *m_pRunningTimer;
48 
49  void queueDispatchTimerEvent( bool bAtStart );
50  void callTimerCallback();
51 
52 public:
53  AquaSalTimer();
54  virtual ~AquaSalTimer() override;
55 
56  void Start( sal_uInt64 nMS ) override;
57  void Stop() override;
58 
59  void handleStartTimerEvent( NSEvent* pEvent );
60  bool handleDispatchTimerEvent( NSEvent* pEvent );
61  void handleTimerElapsed();
63 
64  bool IsTimerElapsed() const;
65  inline bool IsDirectTimeout() const;
66 };
67 
68 inline bool AquaSalTimer::IsDirectTimeout() const
69 {
70  return m_bDirectTimeout;
71 }
72 
73 #endif // INCLUDED_VCL_INC_OSX_SALTIMER_H
74 
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsTimerElapsed() const
void ImplNSAppPostEvent(short nEventId, BOOL bAtStart, int nUserData=0)
if NO == bAtStart, then it has to be run in the main thread, e.g.
bool IsDirectTimeout() const
Definition: osx/saltimer.h:68
NSTimer * m_pRunningTimer
Definition: osx/saltimer.h:46
const wchar_t *typedef BOOL
void queueDispatchTimerEvent(bool bAtStart)
bool handleDispatchTimerEvent(NSEvent *pEvent)
void Start(sal_uInt64 nMS) override
virtual ~AquaSalTimer() override
void Stop() override
bool m_bDirectTimeout
timeout can be processed directly
Definition: osx/saltimer.h:47
void handleWindowShouldClose()
void callTimerCallback()
void handleStartTimerEvent(NSEvent *pEvent)
void handleTimerElapsed()
FILE * init(int, char **)
NSAutoreleasePool * mpPool
Definition: osx/saltimer.h:37