1
# libavg - Media Playback Engine.
2
# Copyright (C) 2003-2008 Ulrich von Zadow
4
# This library is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU Lesser General Public
6
# License as published by the Free Software Foundation; either
7
# version 2 of the License, or (at your option) any later version.
9
# This library is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public
15
# License along with this library; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
# Current versions can be found at www.libavg.de
20
# Original author of this file is Martin Heistermann <mh at sponc dot de>
24
from libavg import avg
25
g_Player = avg.Player.get()
26
g_Log = avg.Logger.get()
29
from win32gui import *
30
from win32con import *
31
from win32api import *
38
fakeFullscreen = False
39
def __init__(self, parentNode):
40
"""initialization before Player.play()
41
Use this only when needed, e.g. for
42
WordsNode.addFontDir(). Do not forget to call
43
super(YourApp, self).__init__(parentNode)"""
44
self.__isRunning = False
45
self._parentNode = parentNode
47
avg.appInstance = self
49
if 'onKey' in dir(self):
50
raise DeprecationWarning, \
51
'AVGApp.onKey() has been renamed to AVGApp.onKeyDown().'
54
"""main initialization
55
build node hierarchy under self.__parentNode."""
60
Called after player.play() returns. End of program run."""
64
"""enter the application, internal interface.
65
override this and start all animations, intervals
70
"""leave the application, internal interface.
71
override this and stop all animations, intervals
72
etc. Take care your application does not use any
73
non-needed resources after this."""
76
def enter(self, onLeave = lambda: None):
77
"""enter the application, external interface.
78
Do not override this."""
79
self.__isRunning = True
80
self._onLeave = onLeave
84
"""leave the application, external interface.
85
Do not override this."""
86
self.__isRunning = False
90
def onKeyDown(self, event):
91
"""returns bool indicating if the event was handled
92
by the application """
95
def onKeyUp(self, event):
96
"""returns bool indicating if the event was handled
97
by the application """
101
return self.__isRunning
103
def setStarter(self, starter):
104
self._starter = starter
106
def getStarter(self):
110
def __findWindow(cls, title):
111
def enumWinProc(h, lparams):
114
EnumWindows(enumWinProc, winList)
116
curTitle = GetWindowText(hwnd)
117
if IsWindowVisible(hwnd) and title == curTitle:
122
def __fakeFullscreen(cls):
123
hDesk = GetDesktopWindow()
124
(DesktopLeft, DesktopTop, DesktopRight, DesktopBottom) = GetWindowRect(hDesk)
125
w = cls.__findWindow("AVG Renderer")
128
SetWindowPos(w, HWND_TOP, -(GetSystemMetrics(SM_CYBORDER)+offSetX),
129
-(GetSystemMetrics(SM_CYCAPTION)+offSetY),
130
DesktopRight, DesktopBottom+30, 0)
133
def start(cls, *args, **kwargs):
134
from AVGAppStarter import AVGAppStarter
135
from AVGMTAppStarter import AVGMTAppStarter
137
starter = AVGMTAppStarter
139
starter = AVGAppStarter
140
cls.avg_deploy = os.getenv("AVG_DEPLOY")
142
if cls.fakeFullscreen and cls.avg_deploy is not None:
144
g_Player.setTimeout(1000,cls.__fakeFullscreen)
146
g_Log.trace(g_Log.ERROR, 'fakeFullscreen works only on Windows')
147
starter(appClass = cls, *args, **kwargs)