Interactive/ResizeCustom.py

##
## (C) Copyright 2012 Autodesk, Inc.  All rights reserved.
##
## Use of this software is subject to the terms of the Autodesk license
## agreement provided at the time of installation or download, or which
## otherwise accompanies this software in either electronic or hard copy
## form.
##

#           module = __import__(custom)
#           instance = module.instantiate()
#           self.__myCustoms.append(instance)

__all__ = ['ResizeCustom', 'instantiate']

# Set the window to different locations and sizes
#

from MessageInterpreter  import MessageInterpreter
from UserCustomization   import UserCustomBase, CustomInfo

class ResizeCustom (UserCustomBase):
    def __init__(self):
        self.__mySingleId = None
        self.__myDoubleId = None
        self.__myInterpreter = LocalInterpreter()

    def getInterpreter(self,isInteractive):
        if isInteractive:
            return self.__myInterpreter
        return None

    def appendMenuItems(self,id,menu):
        if "Edit" == id:
            self.__my1Id = menu.appendItem(_( 'Window: 800x600' ),
                                                self.__on1 )
            self.__my2Id = menu.appendItem(_( 'Window: 400x400' ),
                                                self.__on2 )
            self.__my3Id = menu.appendItem(_( 'Window: 512x512' ),
                                                self.__on3 )

    def enableMenuStates(self,id,enableStates):
        if "Edit" == id:
            enableStates[self.__my1Id] = True
            enableStates[self.__my2Id] = True
            enableStates[self.__my3Id] = True

    # ------------------------------------------------
    def __on1( self, event ):
        if self.__myInterpreter:
            self.__myInterpreter.Resize(800,600)

    def __on2( self, event ):
        if self.__myInterpreter:
            self.__myInterpreter.Resize(400,400)

    def __on3( self, event ):
        if self.__myInterpreter:
            self.__myInterpreter.Resize(512,512)



# -----------------------------------------------------------------------

class LocalInterpreter( MessageInterpreter ):

    def Resize( self, width, height ):
        self.sendMessage( "WINDOW_SET_SIZE",
                          (width, height) )

# --------------------------------------------------------------------

def instantiate():
    # Are the relevant files elsewhere?
    # sys.path.append( "where the files are" )
    return ResizeCustom()


def info():
    customInfo = CustomInfo()
    customInfo.vendor = 'Autodesk'
    customInfo.version = '3.0'
    customInfo.api = '2013'
    customInfo.shortInfo = "Resize the main window."
    customInfo.longInfo = \
"""Add several menu items under "View" menu to resize the main window.
"""
    return customInfo