Exemplo n.º 1
0
    def GetSkinnedBitmap(
            textLines,
            textWidths,
            textHeights,
            textWidth,
            textHeight,
            memoryDC,
            textColour,
            skinName
    ):
        image = wx.Image(join(SKIN_DIR, skinName + ".png"))
        option = eg.Bunch()

        def Setup(minWidth, minHeight, xMargin, yMargin,
                  transparentColour=None):
            width = textWidth + 2 * xMargin
            if width < minWidth:
                width = minWidth
            height = textHeight + 2 * yMargin
            if height < minHeight:
                height = minHeight
            option.xMargin = xMargin
            option.yMargin = yMargin
            option.transparentColour = transparentColour
            bitmap = wx.EmptyBitmap(width, height)
            option.bitmap = bitmap
            memoryDC.SelectObject(bitmap)
            return width, height

        def Copy(x, y, width, height, toX, toY):
            bmp = wx.BitmapFromImage(image.GetSubImage((x, y, width, height)))
            memoryDC.DrawBitmap(bmp, toX, toY)

        def Scale(x, y, width, height, toX, toY, toWidth, toHeight):
            subImage = image.GetSubImage((x, y, width, height))
            subImage.Rescale(toWidth, toHeight, wx.IMAGE_QUALITY_HIGH)
            bmp = wx.BitmapFromImage(subImage)
            memoryDC.DrawBitmap(bmp, toX, toY)

        scriptGlobals = dict(Setup=Setup, Copy=Copy, Scale=Scale)
        eg.ExecFile(join(SKIN_DIR, skinName + ".py"), scriptGlobals)

        bitmap = option.bitmap
        memoryDC.SelectObject(wx.NullBitmap)
        bitmap.SetMask(wx.Mask(bitmap, option.transparentColour))
        memoryDC.SelectObject(bitmap)
        memoryDC.SetTextForeground(textColour)
        memoryDC.SetTextBackground(textColour)
        DrawTextLines(
            memoryDC, textLines, textHeights, option.xMargin, option.yMargin
        )
        memoryDC.SelectObject(wx.NullBitmap)
        return bitmap
Exemplo n.º 2
0
    "{A21F443B-221D-44E4-8596-E1ED7100E0A4}",  # "System"
    "{E974D074-B0A3-4D0C-BBD1-992475DDD69D}",  # "Window"
    "{6B1751BF-F94E-4260-AB7E-64C0693FD959}",  # "Mouse"
)

eg.ID_TEST = wx.NewId()
eg.mainDir = eg.Cli.mainDir

eg.revision = 2000  # Deprecated
eg.startupArguments = eg.Cli.args
eg.debugLevel = eg.startupArguments.debugLevel
eg.systemEncoding = locale.getdefaultlocale()[1]
eg.document = None
eg.mainFrame = None
eg.result = None
eg.plugins = eg.Bunch()
eg.globals = eg.Bunch()
eg.globals.eg = eg
eg.event = None
eg.eventTable = {}
eg.eventString = ""
eg.notificationHandlers = {}
eg.programCounter = None
eg.programReturnStack = []
eg.indent = 0
eg.pluginList = []
eg.mainThread = threading.currentThread()
eg.stopExecutionFlag = False
eg.lastFoundWindows = []
eg.currentItem = None
eg.actionGroup = eg.Bunch()
Exemplo n.º 3
0
    def Configure(self,
                  displayNum=None,
                  size=None,
                  frequency=None,
                  depth=None,
                  includeAll=False,
                  updateRegistry=False):
        text = self.text
        panel = eg.ConfigPanel()
        if displayNum is None:
            displayNum = 1
            size, frequency, depth = GetDisplay(0).GetCurrentMode()

        displayChoice = DisplayChoice(panel)
        if displayNum is not None and displayNum <= displayChoice.GetCount():
            displayChoice.SetSelection(displayNum - 1)

        resolutionChoice = wx.Choice(panel)
        frequencyChoice = wx.Choice(panel)
        depthChoice = wx.Choice(panel)
        includeAllCheckBox = panel.CheckBox(includeAll, text.includeAll)
        updateRegistryCheckBox = panel.CheckBox(updateRegistry,
                                                text.storeInRegistry)

        sizer = wx.GridBagSizer(6, 5)
        flag = wx.ALIGN_CENTER_VERTICAL
        sizer.Add(panel.StaticText(text.display), (0, 0), flag=flag)
        sizer.Add(panel.StaticText(text.resolution), (1, 0), flag=flag)
        sizer.Add(panel.StaticText(text.frequency), (2, 0), flag=flag)
        sizer.Add(panel.StaticText(text.colourDepth), (3, 0), flag=flag)
        sizer.Add(displayChoice, (0, 1), flag=flag)
        sizer.Add(resolutionChoice, (1, 1), flag=flag)
        sizer.Add(frequencyChoice, (2, 1), flag=flag)
        sizer.Add(depthChoice, (3, 1), flag=flag)

        panel.sizer.Add(sizer, 0, wx.EXPAND)
        flag = wx.ALIGN_CENTER_VERTICAL | wx.TOP
        panel.sizer.Add(includeAllCheckBox, 0, flag, 10)
        panel.sizer.Add(updateRegistryCheckBox, 0, flag, 10)

        settings = eg.Bunch()

        def GetClientData(ctrl):
            return ctrl.GetClientData(ctrl.GetSelection())

        def UpdateDeepth(event=None):
            resolution = GetClientData(resolutionChoice)
            settings.depthDict = depthDict = settings.modes[resolution]
            depthList = depthDict.keys()
            depthList.sort()
            depthChoice.Clear()
            sel = len(depthList) - 1
            for pos, bits in enumerate(depthList):
                depthChoice.Append("%d Bit" % bits)
                depthChoice.SetClientData(pos, bits)
                if bits == depth:
                    sel = pos
            depthChoice.Select(sel)
            UpdateFrequencies()
            if event:
                event.Skip()

        def UpdateFrequencies(event=None):
            depth = GetClientData(depthChoice)
            frequencyList = settings.depthDict[depth]
            frequencyChoice.Clear()
            sel = 0
            for pos, frequency in enumerate(frequencyList):
                frequencyChoice.Append("%d Hz" % frequency)
                frequencyChoice.SetClientData(pos, frequency)
                if frequency == frequency:
                    sel = pos
            frequencyChoice.Select(sel)
            if event:
                event.Skip()

        def UpdateResolutions(event=None):
            display = displayChoice.GetValue()
            modes = display.GetDisplayModes(includeAllCheckBox.GetValue())
            settings.modes = modes
            resolutions = modes.keys()
            resolutions.sort()
            resolutionChoice.Clear()
            sel = 0
            for pos, res in enumerate(resolutions):
                resolutionChoice.Append("%d x %d" % res)
                resolutionChoice.SetClientData(pos, res)
                if res == size:
                    sel = pos
            resolutionChoice.Select(sel)
            UpdateDeepth(None)
            if event:
                event.Skip()

        displayChoice.Bind(wx.EVT_CHOICE, UpdateResolutions)
        resolutionChoice.Bind(wx.EVT_CHOICE, UpdateDeepth)
        depthChoice.Bind(wx.EVT_CHOICE, UpdateFrequencies)
        includeAllCheckBox.Bind(wx.EVT_CHECKBOX, UpdateResolutions)

        UpdateResolutions()

        while panel.Affirmed():
            panel.SetResult(displayChoice.GetSelection() + 1,
                            GetClientData(resolutionChoice),
                            GetClientData(frequencyChoice),
                            GetClientData(depthChoice),
                            includeAllCheckBox.GetValue(),
                            updateRegistryCheckBox.GetValue())
Exemplo n.º 4
0
    def LoadLanguage(self, language):
        Config.language = language
        self.isDirty = False
        self.SetTitle("EventGhost Language Editor - %s [%s]" %
                      (eg.Translation.languageNames[language], language))
        tree = self.tree
        tree.Unbind(wx.EVT_TREE_SEL_CHANGING)
        tree.DeleteChildren(self.rootId)
        translation = eg.Bunch()
        languagePath = os.path.join(eg.languagesDir, "%s.py" % language)
        if os.path.exists(languagePath):
            eg.ExecFile(languagePath, {}, translation.__dict__)
        self.translationDict = translation.__dict__
        self.translationDict["__builtins__"] = {}

        for name in (
                "General",
                "MainFrame",
                "Error",
                "Exceptions",
                "CheckUpdate",
                "AddActionDialog",
                "AddPluginDialog",
                "AddActionGroupDialog",
                "EventItem",
                "OptionsDialog",
                "FindDialog",
                "AboutDialog",
                "WinUsb",
        ):
            newId = tree.AppendItem(self.rootId, name, 2)
            value = getattr(eg.text, name)
            tree.SetPyData(newId, [name, value, None])
            self.FillTree(newId, value, name)
            #tree.Expand(newId)

        plugins = [
            "EventGhost",
            "System",
            "Window",
            "Mouse",
        ]
        for name in dir(eg.text.Plugin):
            if name.startswith("__"):
                continue
            if name not in plugins:
                plugins.append(name)

        pluginId = tree.AppendItem(self.rootId, "Plugins", 2)
        tree.SetPyData(pluginId, ["Plugin", eg.text.Plugin, None])
        for name in plugins:
            newId = tree.AppendItem(pluginId, name, 2)
            value = getattr(eg.text.Plugin, name)
            evalPath = "Plugin." + name
            tree.SetPyData(newId, [evalPath, value, None])
            self.FillTree(newId, value, evalPath)

        tree.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelectionChanging)
        tree.Expand(self.rootId)
        tree.Expand(pluginId)
        tree.ScrollTo(self.rootId)
        self.OnCmdFindNext(currentId=self.rootId)