Пример #1
0
    def set_commandlist(self, commandlist, context):
        self._activecmds[context] = {}
        if commandlist:
            for cmd in commandlist:
                self._activecmds[context][cmd.__class__] = cmd

        # enable/disable 'app' commands
        if context == 'app':
            entries = [usercmd.OPEN, usercmd.EXIT, usercmd.CHOOSESKIN]
            for cmdcl in entries:
                id = usercmdui.usercmd2id(cmdcl)
                self.EnableMenuItem(0, id,
                                    self._activecmds[context].has_key(cmdcl))

        # enable/disable 'document' commands
        if context == 'document':
            entries = [
                usercmd.CLOSE,
            ]
            for cmdcl in entries:
                id = usercmdui.usercmd2id(cmdcl)
                self.EnableMenuItem(0, id,
                                    self._activecmds[context].has_key(cmdcl))

        # enable/disable playback commands
        if context == 'pview_':
            entries = [
                usercmd.PLAY,
                usercmd.PAUSE,
                usercmd.STOP,
            ]
            for cmdcl in entries:
                id = usercmdui.usercmd2id(cmdcl)
                self.EnableMenuItem(1, id,
                                    self._activecmds[context].has_key(cmdcl))
Пример #2
0
 def setplayerstate(self, state):
     import Player
     self.__playerstate = state
     submenu = 1
     id_play = usercmdui.usercmd2id(usercmd.PLAY)
     id_pause = usercmdui.usercmd2id(usercmd.PAUSE)
     id_stop = usercmdui.usercmd2id(usercmd.STOP)
     if state == Player.PLAYING:
         self.EnableMenuItem(submenu, id_play, 0)
         self.EnableMenuItem(submenu, id_pause, 1)
         self.EnableMenuItem(submenu, id_stop, 1)
         self.CheckMenuItem(submenu, id_pause, 0)
     elif state == Player.PAUSING:
         self.EnableMenuItem(submenu, id_play, 1)
         self.EnableMenuItem(submenu, id_pause, 1)
         self.EnableMenuItem(submenu, id_stop, 1)
         self.CheckMenuItem(submenu, id_pause, 1)
     elif state == Player.STOPPED:
         self.CheckMenuItem(submenu, id_pause, 0)
         self.EnableMenuItem(submenu, id_play, 1)
         self.EnableMenuItem(submenu, id_pause, 0)
         self.EnableMenuItem(submenu, id_stop, 0)
     else:
         self.CheckMenuItem(submenu, id_pause, 0)
         self.EnableMenuItem(submenu, id_play, 0)
         self.EnableMenuItem(submenu, id_pause, 0)
         self.EnableMenuItem(submenu, id_stop, 0)
Пример #3
0
    def _setToolbarFromTemplate(self, template):
        # First count number of buttons
        name, tp, state, command, barid, resid, candrag, buttonlist = template

        # Create the toolbar
        cmdid = usercmdui.usercmd2id(command)
        if resid <= 0: return
        bar = GRiNSToolbar(self, name, barid, resid, candrag)
        self._bars[cmdid] = bar
        self.DockControlBar(bar)
        ##         self._DockControlBarNextPosition(bar)

        # Initialize it
        nbuttons = len(buttonlist)
        bar.SetButtons(nbuttons)
        buttonindex = 0
        for button in buttonlist:
            if button.type == 'button':
                id = usercmdui.usercmd2id(button.cmdid)
                bar.SetButtonInfo(buttonindex, id, afxexttb.TBBS_BUTTON,
                                  button.arg)
            elif button.type == 'separator':
                bar.SetButtonInfo(buttonindex, afxexttb.ID_SEPARATOR,
                                  afxexttb.TBBS_SEPARATOR, button.width)
            elif button.type == 'pulldown':
                self._createPulldown(bar, buttonindex, button.name)
            else:
                raise 'Unknown toolbar item type', button.type
            buttonindex = buttonindex + 1
Пример #4
0
    def set_commandlist(self, commandlist, context):
        menu = self.GetMenu()

        # disable previous if any
        prev_commandlist_dict = self._activecmds.get(context)
        if prev_commandlist_dict:
            prev_commandlist = prev_commandlist_dict.values()
            flags = win32con.MF_BYCOMMAND | win32con.MF_GRAYED
            for cmdinst in prev_commandlist:
                cmd = cmdinst.__class__
                id = usercmdui.usercmd2id(cmd)
                menu.EnableMenuItem(id, flags)

        # enable new
        self._activecmds[context] = {}
        if commandlist:
            flags = win32con.MF_BYCOMMAND | win32con.MF_ENABLED
            for cmdinst in commandlist:
                cmd = cmdinst.__class__
                self._activecmds[context][cmd] = cmdinst
                id = usercmdui.usercmd2id(cmd)
                menu.EnableMenuItem(id, flags)

        # exception
        if context == 'app':
            cmd = wndusercmd.ABOUT_GRINS
            id = usercmdui.usercmd2id(cmd)
            menu.EnableMenuItem(id, flags)
Пример #5
0
def EncodeDragData(name, args):
    if name == 'FileName':
        return CF_FILE, args
    if name == 'URL':
        return CF_URL, args
    if name == 'Node':
        return CF_NODE, "%d %d"%args
    if name == 'Tool':
        cmdid = usercmdui.usercmd2id(args)
        return CF_TOOL, "%d"%cmdid
    if name == 'NodeUID':
        if type(args) == type(()):
            uid, context = args
        else:
            # Convenience: we can pass a node itself
            node = args
            uid = node.GetUID()
            context = id(node.context)
        return CF_NODEUID, "%d %s"%(context, uid)
    if name == 'Region':
        if hasattr(args, 'GetUID'):
            args = args.GetUID()
            if args.isDefault():
                # in any case, you can't drag and drop the default region
                # XXX how avoid a source drag properly ???
                return 0, args
        return CF_REGION, args
    if name == 'Media':
        if hasattr(args, 'GetUID'):
            args = args.GetUID()
        return CF_MEDIA, args
    assert 0
Пример #6
0
 def set_toggle(self, cmdcl, onoff):
     id = usercmdui.usercmd2id(cmdcl)
     flags = win32con.MF_BYCOMMAND
     if onoff==0:
         flags = flags | win32con.MF_UNCHECKED
     else:
         flags = flags | win32con.MF_CHECKED
     self.GetMenu().CheckMenuItem(id, flags)
Пример #7
0
 def set_toggle(self, cmdcl, onoff):
     if cmdcl in (usercmd.PLAY, usercmd.PAUSE, usercmd.STOP):
         # managed by setplayerstate
         return
     hmenu = self.GetMenuHandle()
     menu = winuser.CreateMenuFromHandle(hmenu)
     flags = wincon.MF_BYCOMMAND
     if onoff: flags = flags | wincon.MF_CHECKED
     else: flags = flags | wincon.MF_UNCHECKED
     id = usercmdui.usercmd2id(cmdcl)
Пример #8
0
 def set_dynamiclist(self, command, list):
     submenu = self._mainmenu.get_cascade_menu(command)
     if not submenu:
         return
     cmd_instance = self.get_cmd_instance(command)
     if cmd_instance is None:
         return
     idstart = usercmdui.usercmd2id(command) + 1
     menuspec = []
     callback = cmd_instance.callback
     self._dyncmds[command] = {}
     for entry in list:
         entry = (entry[0], (callback, entry[1])) + entry[2:]
         menuspec.append(entry)
     self._mainmenu.clear_cascade(command)
     win32menu._create_menu(submenu, menuspec, idstart, self._dyncmds[command])
Пример #9
0
    def __init__(self):
        #
        # Toolbars. Indexed by PyCCmdUI identity,
        # values are GRiNSToolbar instances.
        #
        self._bars = {}
        PanelMixin.__init__(self)

        #
        # Pulldown adornments. Indexed by pulldown name,
        # values are (valuelist, callback, initialvalue).
        # The callback dict is indexed by combo id, values
        # are (combo, callback)
        self._pulldowndict = {}
        self._pulldowncallbackdict = {}
        #
        for template in ToolbarTemplate.TOOLBARS:
            name, tp, state, command, barid, resid, candrag, buttonlist = template
            cmdid = usercmdui.usercmd2id(command)
            self._bars[cmdid] = None
Пример #10
0
 def __init__(self):
     self._pbar = None
     self._pcmdid = usercmdui.usercmd2id(wndusercmd.PLAYER_PANEL)