"""
     qtgui/MGApplication.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC
     Copyright (C) 2009-2010 University of York
     Copyright (C) 2012 STFC

     This library is free software: you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public License
     version 3, modified in accordance with the provisions of the 
     license to address the requirements of UK law.
 
     You should have received a copy of the modified GNU Lesser General 
     Public License along with this library.  If not, copies may be 
     downloaded from http://www.ccp4.ac.uk/ccp4license.php
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU Lesser General Public License for more details.
"""
from PyQt4 import QtGui,QtCore
import sys

_dummyWindow = None
_mainWindow = None

def GetMainWindow():
    if _mainWindow and hasattr(_mainWindow,"rebuildGLDisplayObject"):
      return _mainWindow
    if hasattr(_dummyWindow,"rebuildGLDisplayObject"):
      return _dummyWindow
       
def GetDisplayTable():
  main = GetMainWindow()
  return main.MGDisplayTable

def QtApp():
  return QtGui.QApplication.instance()

class MGApplication(QtGui.QApplication):
    def __init__(self,args):
      QtGui.QApplication.__init__(self,args)
