def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.showNavigationBar = settings.user.ui.Get('browserShowNavBar', True)
     self.showStatusBar = settings.user.ui.Get('browserShowStatusBar', True)
     self.SetCaption(localization.GetByLabel('UI/Browser/BrowserSettings/BrowserSettingsCaption'))
     self.SetButtons(uiconst.OKCLOSE, okLabel=localization.GetByLabel('UI/Browser/BrowserSettings/SaveChanges'), okFunc=self.Save, okModalResult=uiconst.ID_NONE)
     main = self.GetMainArea()
     main.clipChildren = 0
     main.padding = 6
     c = Container(name='homeCont', parent=main, align=uiconst.TOTOP, height=32)
     l = Container(name='left', parent=c, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
     r = Container(name='right', parent=c, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
     text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/Homepage'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=l, left=0, top=4, width=2)
     top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
     totalTop = top
     btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetHomepage'), func=self.ResetHomePage, pos=(0,
      top,
      0,
      0), align=uiconst.TOPRIGHT)
     if btn.width > 80:
         r.width = btn.width
     self.homeEdit = SinglelineEdit(name='homeEdit', setvalue=settings.user.ui.Get('HomePage2', browserutil.DefaultHomepage()), align=uiconst.TOTOP, pos=(0,
      top,
      0,
      0), parent=c)
     Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
     self.showHideContainer = Container(name='showHideContainer', parent=main, align=uiconst.TOTOP, height=35, top=0, state=uiconst.UI_PICKCHILDREN)
     self.showStatusBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowStatusBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showStatusBar)
     self.showNavBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowNavigationBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showNavigationBar)
     Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
     self.cacheContainer = Container(name='cacheContainer', parent=main, align=uiconst.TOTOP, height=26, top=8, state=uiconst.UI_PICKCHILDREN)
     l = Container(name='cacheLeft', parent=self.cacheContainer, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
     r = Container(name='cacheRight', parent=self.cacheContainer, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
     if not blue.win32.IsTransgaming():
         text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheLocation'), align=uiconst.TOLEFT, state=uiconst.UI_DISABLED, parent=l, padding=(2, 4, 2, 4))
         top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
         totalTop += top
         btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetCacheLocation'), func=self.ResetCacheLocation, pos=(0,
          top,
          0,
          0), align=uiconst.TOPRIGHT)
         if btn.width > r.width:
             r.width = btn.width
         if text.textwidth > l.width:
             l.width = text.textwidth + 4
         self.cacheEdit = SinglelineEdit(name='cacheEdit', setvalue=settings.public.generic.Get('BrowserCache', corebrowserutil.DefaultCachePath()), align=uiconst.TOTOP, pos=(0,
          top,
          0,
          0), parent=self.cacheContainer)
         explainContainer = Container(name='cacheExplainContainer', parent=main, align=uiconst.TOTOP, height=26)
         Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheCaption'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=explainContainer, padLeft=4, fontsize=10)
         totalTop += 26
         clearCacheContainer = Container(name='clearCacheContainer', parent=main, align=uiconst.TOTOP, height=14)
         btn = Button(parent=clearCacheContainer, label=localization.GetByLabel('UI/Browser/BrowserSettings/ClearCache'), func=self.ClearCache)
         btn.hint = (localization.GetByLabel('UI/Browser/BrowserSettings/ClearCacheHint'),)
         totalTop += 16
     else:
         totalTop -= 32
     self.SetMinSize((500, 204 + totalTop))
     sm.StartService('sites')
Example #2
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     if hasattr(self, 'SetTopparentHeight'):
         self.SetTopparentHeight(0)
         self.container = Container(parent=self.sr.main,
                                    align=uiconst.TOALL)
     else:
         self.container = Container(parent=self.sr.content,
                                    align=uiconst.TOALL)
     from carbonui.primitives.gridcontainer import GridContainer
     self.optionsContainer = Container(parent=self.container,
                                       align=uiconst.TOTOP,
                                       height=40)
     self.cppCaptureChk = Checkbox(
         parent=self.optionsContainer,
         text='C++ capture',
         checked=blue.statistics.isCppCaptureEnabled,
         callback=self._OnCppCaptureChk,
         align=uiconst.TOTOP)
     self.gpuCaptureChk = Checkbox(
         parent=self.optionsContainer,
         text='GPU capture',
         checked=trinity.settings.GetValue('gpuTelemetryEnabled'),
         callback=self._OnGpuCaptureChk,
         align=uiconst.TOTOP)
     self.buttonContainer = GridContainer(parent=self.container,
                                          align=uiconst.TOALL,
                                          columns=2,
                                          rows=2)
     self.startBtn = Button(parent=self.buttonContainer,
                            align=uiconst.TOALL,
                            label='Start',
                            func=self._Start)
     self.stopBtn = Button(parent=self.buttonContainer,
                           align=uiconst.TOALL,
                           label='Stop',
                           func=self._Stop)
     self.pauseBtn = Button(parent=self.buttonContainer,
                            align=uiconst.TOALL,
                            label='Pause',
                            func=self._Pause)
     self.resumeBtn = Button(parent=self.buttonContainer,
                             align=uiconst.TOALL,
                             label='Resume',
                             func=self._Resume)
     uthread.new(self._CheckStatus)
 def ApplyAttributes(self, attributes):
     super(CameraDebugWindow, self).ApplyAttributes(attributes)
     self.SetMinSize([self.default_width, self.default_height])
     self.SetCaption('Camera Debug Window')
     self.sr.content.padding = (5, 16, 5, 5)
     self.debugSelectionClient = sm.GetService('debugSelectionClient')
     self.cameraDebugClient = sm.GetService('cameraDebugClient')
     self.cameraClient = sm.GetService('cameraClient')
     self.cameraStack = Label(parent=self.sr.content, align=uiconst.TOPLEFT, text=self.PrintCameraStack())
     buttonContainer = Container(parent=self.sr.content, align=uiconst.TOBOTTOM, height=70, padding=(150, 0, 150, 0))
     self.toggleCamera = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Activate Normal Camera', func=self.OnToggleDebugCamera)
     self.toggleCamUpdate = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Toggle Camera Update', func=self.OnToggleDebugCameraUpdate, hint='Toggle between updating the debug, and normal camera.')
     self.showCamCheckBox = Checkbox(parent=buttonContainer, aligh=uiconst.TOBOTTOM, text='Show Normal Camera', checked=False, callback=self.OnSnowNormalCameraCheckbox)
     import cameras
     self.cameraClient.AddSharedCamera('Debug Camera', cameras.DebugCamera())
     if type(self.cameraClient.GetActiveCamera()) is cameras.DebugCamera:
         self.DisableDebugCamera()
     self.EnableDebugCamera()
     sm.GetService('navigation').hasControl = False
Example #4
0
 def ApplyAttributes(self, attributes):
     self._ready = False
     Window.ApplyAttributes(self, attributes)
     self.graphs = GraphManager()
     self.graphs.SetEnabled(True)
     if hasattr(self, 'SetTopparentHeight'):
         self.SetTopparentHeight(0)
         self.container = Container(parent=self.sr.main,
                                    align=uiconst.TOALL)
     else:
         self.container = Container(parent=self.sr.content,
                                    align=uiconst.TOALL)
     self.settingsContainer = Container(parent=self.container,
                                        align=uiconst.TOTOP,
                                        height=30)
     self.showTimersChk = Checkbox(parent=self.settingsContainer,
                                   align=uiconst.TOLEFT,
                                   text='Timers',
                                   checked=True,
                                   width=120,
                                   height=30,
                                   callback=self.PopulateScroll)
     self.showMemoryChk = Checkbox(parent=self.settingsContainer,
                                   align=uiconst.TOLEFT,
                                   text='Memory counters',
                                   checked=True,
                                   width=120,
                                   height=30,
                                   callback=self.PopulateScroll)
     self.showLowCountersChk = Checkbox(parent=self.settingsContainer,
                                        align=uiconst.TOLEFT,
                                        text='Low counters',
                                        checked=True,
                                        width=120,
                                        height=30,
                                        callback=self.PopulateScroll)
     self.showHighCountersChk = Checkbox(parent=self.settingsContainer,
                                         align=uiconst.TOLEFT,
                                         text='High counters',
                                         checked=True,
                                         width=120,
                                         height=30,
                                         callback=self.PopulateScroll)
     self.resetBtn = Button(parent=self.settingsContainer,
                            align=uiconst.TORIGHT,
                            label='Reset peaks',
                            width=120,
                            height=30,
                            func=self.PopulateScroll)
     self.refreshBtn = Button(parent=self.settingsContainer,
                              align=uiconst.TORIGHT,
                              label='Refresh',
                              width=120,
                              height=30,
                              func=self.PopulateScroll)
     self.scroll = Scroll(parent=self.container,
                          id='blueGraphsScroll',
                          align=uiconst.TOTOP,
                          height=200)
     self.graphsContainer = Container(parent=self.container,
                                      align=uiconst.TOALL)
     self._ready = True
     self.PopulateScroll()
Example #5
0
class GraphsWindow(Window):
    __guid__ = 'form.GraphsWindow'
    default_caption = 'Blue stats graphs'
    default_minSize = (600, 500)

    def ApplyAttributes(self, attributes):
        self._ready = False
        Window.ApplyAttributes(self, attributes)
        self.graphs = GraphManager()
        self.graphs.SetEnabled(True)
        if hasattr(self, 'SetTopparentHeight'):
            self.SetTopparentHeight(0)
            self.container = Container(parent=self.sr.main,
                                       align=uiconst.TOALL)
        else:
            self.container = Container(parent=self.sr.content,
                                       align=uiconst.TOALL)
        self.settingsContainer = Container(parent=self.container,
                                           align=uiconst.TOTOP,
                                           height=30)
        self.showTimersChk = Checkbox(parent=self.settingsContainer,
                                      align=uiconst.TOLEFT,
                                      text='Timers',
                                      checked=True,
                                      width=120,
                                      height=30,
                                      callback=self.PopulateScroll)
        self.showMemoryChk = Checkbox(parent=self.settingsContainer,
                                      align=uiconst.TOLEFT,
                                      text='Memory counters',
                                      checked=True,
                                      width=120,
                                      height=30,
                                      callback=self.PopulateScroll)
        self.showLowCountersChk = Checkbox(parent=self.settingsContainer,
                                           align=uiconst.TOLEFT,
                                           text='Low counters',
                                           checked=True,
                                           width=120,
                                           height=30,
                                           callback=self.PopulateScroll)
        self.showHighCountersChk = Checkbox(parent=self.settingsContainer,
                                            align=uiconst.TOLEFT,
                                            text='High counters',
                                            checked=True,
                                            width=120,
                                            height=30,
                                            callback=self.PopulateScroll)
        self.resetBtn = Button(parent=self.settingsContainer,
                               align=uiconst.TORIGHT,
                               label='Reset peaks',
                               width=120,
                               height=30,
                               func=self.PopulateScroll)
        self.refreshBtn = Button(parent=self.settingsContainer,
                                 align=uiconst.TORIGHT,
                                 label='Refresh',
                                 width=120,
                                 height=30,
                                 func=self.PopulateScroll)
        self.scroll = Scroll(parent=self.container,
                             id='blueGraphsScroll',
                             align=uiconst.TOTOP,
                             height=200)
        self.graphsContainer = Container(parent=self.container,
                                         align=uiconst.TOALL)
        self._ready = True
        self.PopulateScroll()

    def Close(self, *args, **kwargs):
        self.graphs.SetEnabled(False)
        Window.Close(self, *args, **kwargs)

    def DelayedRefresh_thread(self):
        blue.synchro.SleepWallclock(600)
        self.PopulateScroll()

    def DelayedRefresh(self):
        uthread.new(self.DelayedRefresh_thread)

    def ResetPeaks(self, *args):
        blue.statistics.ResetPeaks()
        self.DelayedRefresh()

    def PopulateScroll(self, *args):
        typesIncluded = []
        if self.showTimersChk.GetValue():
            typesIncluded.append('time')
        if self.showMemoryChk.GetValue():
            typesIncluded.append('memory')
        if self.showLowCountersChk.GetValue():
            typesIncluded.append('counterLow')
        if self.showHighCountersChk.GetValue():
            typesIncluded.append('counterHigh')
        stats = blue.statistics.GetValues()
        desc = blue.statistics.GetDescriptions()
        contentList = []
        for key, value in desc.iteritems():
            type = value[1]
            if type in typesIncluded:
                peak = stats[key][1]
                if type == 'memory':
                    label = '%s<t>%s<t>%s' % (key, FormatMemory(peak),
                                              value[0])
                elif type.startswith('counter'):
                    label = '%s<t>%s<t>%s' % (key, niceNum(peak, 1), value[0])
                elif type == 'time':
                    label = '%s<t>%s<t>%s' % (key, niceNum(peak,
                                                           1e-10), value[0])
                listEntry = ScrollEntryNode(
                    decoClass=SE_GenericCore,
                    id=id,
                    name=key,
                    peak=peak,
                    desc=value[0],
                    label=label,
                    GetMenu=self.GetListEntryMenu,
                    OnDblClick=self.OnListEntryDoubleClicked)
                contentList.append(listEntry)

        self.scroll.Load(contentList=contentList,
                         headers=['Name', 'Peak', 'Description'],
                         noContentHint='No Data available')

    def GetListEntryMenu(self, listEntry):
        return (('Right-click action 1', None), ('Right-click action 2', None))

    def OnListEntryDoubleClicked(self, listEntry):
        node = listEntry.sr.node
        if self.graphs.HasGraph(node.name):
            self.graphs.RemoveGraph(node.name)
        else:
            self.graphs.AddGraph(node.name)

    def _OnResize(self):
        if self._ready:
            l, t, w, h = self.graphsContainer.GetAbsolute()
            scaledAbs = (uicore.ScaleDpi(l), uicore.ScaleDpi(t),
                         uicore.ScaleDpi(w), uicore.ScaleDpi(h))
            self.graphs.AdjustViewports(scaledAbs)
Example #6
0
 def Create_checkbox(self, attrs):
     from carbonui.control.checkbox import CheckboxCoreOverride as Checkbox
     cbox = Checkbox(pos=(0, 0, 0, 0), align=uiconst.RELATIVE)
     cbox.data = {}
     attrs.vspace = 3
     return cbox
class TelemetryPanel(Window):
    __guid__ = 'form.TelemetryPanel'
    default_caption = 'Telemetry Panel'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        if hasattr(self, 'SetTopparentHeight'):
            self.SetTopparentHeight(0)
            self.container = Container(parent=self.sr.main,
                                       align=uiconst.TOALL)
        else:
            self.container = Container(parent=self.sr.content,
                                       align=uiconst.TOALL)
        self.optionsContainer = Container(parent=self.container,
                                          align=uiconst.TOTOP,
                                          height=32)
        self.cppCaptureChk = Checkbox(
            parent=self.optionsContainer,
            text='C++ capture',
            checked=blue.statistics.isCppCaptureEnabled,
            callback=self._OnCppCaptureChk,
            align=uiconst.TOTOP)
        from carbonui.primitives.gridcontainer import GridContainer
        self.buttonContainer = GridContainer(parent=self.container,
                                             align=uiconst.TOALL,
                                             columns=2,
                                             rows=2)
        self.startBtn = Button(parent=self.buttonContainer,
                               align=uiconst.TOALL,
                               label='Start',
                               func=self._Start)
        self.stopBtn = Button(parent=self.buttonContainer,
                              align=uiconst.TOALL,
                              label='Stop',
                              func=self._Stop)
        self.pauseBtn = Button(parent=self.buttonContainer,
                               align=uiconst.TOALL,
                               label='Pause',
                               func=self._Pause)
        self.resumeBtn = Button(parent=self.buttonContainer,
                                align=uiconst.TOALL,
                                label='Resume',
                                func=self._Resume)
        uthread.new(self._CheckStatus)

    def _OnCppCaptureChk(self, checkbox):
        blue.statistics.isCppCaptureEnabled = checkbox.GetValue()

    def _Start(self, args):
        print 'Starting Telemetry'
        blue.statistics.StartTelemetry('localhost')

    def _Stop(self, args):
        print 'Stopping Telemetry'
        blue.statistics.StopTelemetry()

    def _Pause(self, args):
        print 'Pausing Telemetry'
        blue.statistics.PauseTelemetry()

    def _Resume(self, args):
        print 'Resuming Telemetry'
        blue.statistics.ResumeTelemetry()

    def _CheckStatus(self):
        while not self.destroyed:
            self.cppCaptureChk.SetChecked(blue.statistics.isCppCaptureEnabled,
                                          report=False)
            if blue.statistics.isTelemetryConnected:
                self.startBtn.Disable()
                self.stopBtn.Enable()
                if blue.statistics.isTelemetryPaused:
                    self.pauseBtn.Disable()
                    self.resumeBtn.Enable()
                else:
                    self.pauseBtn.Enable()
                    self.resumeBtn.Disable()
            else:
                self.startBtn.Enable()
                self.stopBtn.Disable()
                self.pauseBtn.Disable()
                self.resumeBtn.Disable()
            blue.synchro.SleepWallclock(500)
    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.SetMinSize((500, 300))
        main = self.GetMainArea()
        main.clipChildren = True
        options = Container(parent=main, align=uiconst.TOLEFT, width=180, padTop=4, padLeft=5)
        fontsParent = Container(parent=options)
        flagsParent = Container(parent=options)
        tabs = uicontrols.TabGroup(parent=options, tabs=[('Fonts',
          fontsParent,
          self,
          'properties'), ('Load Flags',
          flagsParent,
          self,
          'flags')], padBottom=6, idx=0)
        for each in (STYLECLASSES, CLIENTFONTS, WINDOWSFONTS):
            Checkbox(parent=fontsParent, text='Browse ' + each, groupname='browseType', checked=each == STYLECLASSES, callback=self.OnBrowseTypeChange, retval=each)

        import uicls
        clientLabelClasses = []
        for className, cls in uicls.__dict__.iteritems():
            try:
                if issubclass(cls, LabelCore) and cls is not LabelCore and getattr(cls, '__guid__', None) is not None:
                    clientLabelClasses.append((className, (className, cls)))
            except:
                pass

        clientLabelClasses = SortListOfTuples(clientLabelClasses)
        self.styleClassesLabel = Label(parent=fontsParent, text='Style Classes', align=uiconst.TOTOP, padTop=10)
        self.styleClassesCombo = Combo(parent=fontsParent, align=uiconst.TOTOP, options=clientLabelClasses, callback=self.OnStyleClassChange)
        clientFaces = []
        clientFonts = os.listdir(blue.paths.ResolvePathForWriting(u'res:') + '\\UI\\Fonts')
        clientFonts.sort()
        for fontName in clientFonts:
            if fontName.lower().endswith('.ttf') or fontName.lower().endswith('.otf'):
                clientFaces.append((fontName, 'res:/UI/Fonts/' + fontName))

        self.clientFontsLabel = Label(parent=fontsParent, text='Client Fonts', align=uiconst.TOTOP, padTop=10)
        self.clientFontsCombo = typeFaceCombo = Combo(parent=fontsParent, align=uiconst.TOTOP, options=clientFaces, callback=self.OnTypeFaceChange)
        windowsFaces = []
        windowsFonts = os.listdir(blue.win32.SHGetFolderPath(blue.win32.CSIDL_FONTS))
        windowsFonts.sort()
        for fontName in windowsFonts:
            if fontName.lower().endswith('.ttf') or fontName.lower().endswith('.otf'):
                windowsFaces.append((fontName, blue.win32.SHGetFolderPath(blue.win32.CSIDL_FONTS) + '\\' + fontName))

        self.windowsFontsLabel = Label(parent=fontsParent, text='Windows Fonts', align=uiconst.TOTOP, padTop=10)
        self.windowsFontsCombo = typeFaceCombo = Combo(parent=fontsParent, align=uiconst.TOTOP, options=windowsFaces, callback=self.OnTypeFaceChange)
        Label(parent=fontsParent, text='Fontsize', align=uiconst.TOTOP, padTop=10)
        self.fontSizeEdit = SinglelineEdit(ints=(6, 128), parent=fontsParent, align=uiconst.TOTOP, OnChange=self.OnFontSizeChange, setvalue=unicode(Label.default_fontsize))
        Label(parent=fontsParent, text='Letterspace', align=uiconst.TOTOP, padTop=10)
        self.letterSpaceEdit = SinglelineEdit(ints=(-10, 10), parent=fontsParent, align=uiconst.TOTOP, OnChange=self.OnLetterSpaceChange, setvalue=unicode(Label.default_letterspace))
        Label(parent=fontsParent, text='LineSpacing', align=uiconst.TOTOP, padTop=10)
        self.lineSpacingEdit = SinglelineEdit(floats=(-1.0, 1.0, 2), parent=fontsParent, align=uiconst.TOTOP, OnChange=self.OnLineSpacingChange, setvalue=unicode(0.0))
        current = trinity.fontMan.loadFlag
        self.loadFlagCheckBoxes = []
        for flagName, flagValue in loadFlags:
            active = current & flagValue == flagValue
            cb = Checkbox(parent=flagsParent, align=uiconst.TOTOP, text=flagName.replace('FT_LOAD_', ''), callback=self.OnLoadFlagChange, retval=flagValue, checked=active)
            cb.flagName = flagName
            cb.flagValue = flagValue
            self.loadFlagCheckBoxes.append(cb)

        Label(parent=flagsParent, text='Render flags', align=uiconst.TOTOP, padTop=10)
        self.renderFlagCheckBoxes = []
        for flagName, flagValue in renderFlags:
            active = current & flagValue == flagValue
            cb = Checkbox(parent=flagsParent, align=uiconst.TOTOP, text=flagName.replace('FT_RENDER_MODE_', ''), groupname='renderFlag', callback=self.OnRenderFlagChange, retval=flagValue, checked=active)
            cb.flagName = flagName
            cb.flagValue = flagValue
            self.renderFlagCheckBoxes.append(cb)

        sampleSelectionParent = Container(parent=main, align=uiconst.TOTOP, height=38, padTop=20)
        Line(parent=main, align=uiconst.TOTOP, padTop=10, padRight=10, padLeft=10)
        self.sampleCombo = Combo(parent=sampleSelectionParent, align=uiconst.TOPLEFT, width=100, left=10, options=[('Lorem...', samplText), ('Ansi charset', ANSI), ('Cyrillic charset', CYRILLIC)], callback=self.OnSampleComboChange)
        orlabel = Label(parent=sampleSelectionParent, text='-or-', left=self.sampleCombo.left + self.sampleCombo.width + 5)
        self.sampleInput = EditPlainText(parent=sampleSelectionParent, align=uiconst.TOALL, padLeft=140, padRight=10, text='asdf sfdasfasfdasfd safd')
        self.sampleInput.OnChange = self.OnCustomTextChange
        self.samples = []
        for typeFace in clientFonts[:1]:
            sampl = Label(parent=main, align=uiconst.TOTOP, text=samplText, padding=10)
            self.samples.append(sampl)

        self.LoadBrowseType(STYLECLASSES)
class BrowserSettingsWindowCore(Window):
    __guid__ = 'uicls.BrowserSettingsWindowCore'
    default_windowID = 'BrowserSettingsWindow'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.showNavigationBar = settings.user.ui.Get('browserShowNavBar', True)
        self.showStatusBar = settings.user.ui.Get('browserShowStatusBar', True)
        self.SetCaption(localization.GetByLabel('UI/Browser/BrowserSettings/BrowserSettingsCaption'))
        self.SetButtons(uiconst.OKCLOSE, okLabel=localization.GetByLabel('UI/Browser/BrowserSettings/SaveChanges'), okFunc=self.Save, okModalResult=uiconst.ID_NONE)
        main = self.GetMainArea()
        main.clipChildren = 0
        main.padding = 6
        c = Container(name='homeCont', parent=main, align=uiconst.TOTOP, height=32)
        l = Container(name='left', parent=c, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
        r = Container(name='right', parent=c, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
        text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/Homepage'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=l, left=0, top=4, width=2)
        top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
        totalTop = top
        btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetHomepage'), func=self.ResetHomePage, pos=(0,
         top,
         0,
         0), align=uiconst.TOPRIGHT)
        if btn.width > 80:
            r.width = btn.width
        self.homeEdit = SinglelineEdit(name='homeEdit', setvalue=settings.user.ui.Get('HomePage2', browserutil.DefaultHomepage()), align=uiconst.TOTOP, pos=(0,
         top,
         0,
         0), parent=c)
        Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
        self.showHideContainer = Container(name='showHideContainer', parent=main, align=uiconst.TOTOP, height=35, top=0, state=uiconst.UI_PICKCHILDREN)
        self.showStatusBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowStatusBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showStatusBar)
        self.showNavBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowNavigationBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showNavigationBar)
        Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
        self.cacheContainer = Container(name='cacheContainer', parent=main, align=uiconst.TOTOP, height=26, top=8, state=uiconst.UI_PICKCHILDREN)
        l = Container(name='cacheLeft', parent=self.cacheContainer, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
        r = Container(name='cacheRight', parent=self.cacheContainer, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
        if not blue.win32.IsTransgaming():
            text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheLocation'), align=uiconst.TOLEFT, state=uiconst.UI_DISABLED, parent=l, padding=(2, 4, 2, 4))
            top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
            totalTop += top
            btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetCacheLocation'), func=self.ResetCacheLocation, pos=(0,
             top,
             0,
             0), align=uiconst.TOPRIGHT)
            if btn.width > r.width:
                r.width = btn.width
            if text.textwidth > l.width:
                l.width = text.textwidth + 4
            self.cacheEdit = SinglelineEdit(name='cacheEdit', setvalue=settings.public.generic.Get('BrowserCache', corebrowserutil.DefaultCachePath()), align=uiconst.TOTOP, pos=(0,
             top,
             0,
             0), parent=self.cacheContainer)
            explainContainer = Container(name='cacheExplainContainer', parent=main, align=uiconst.TOTOP, height=26)
            Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheCaption'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=explainContainer, padLeft=4, fontsize=10)
            totalTop += 26
            clearCacheContainer = Container(name='clearCacheContainer', parent=main, align=uiconst.TOTOP, height=14)
            btn = Button(parent=clearCacheContainer, label=localization.GetByLabel('UI/Browser/BrowserSettings/ClearCache'), func=self.ClearCache)
            btn.hint = (localization.GetByLabel('UI/Browser/BrowserSettings/ClearCacheHint'),)
            totalTop += 16
        else:
            totalTop -= 32
        self.SetMinSize((500, 204 + totalTop))
        sm.StartService('sites')

    def ResetHomePage(self, *args):
        settings.user.ui.Set('HomePage2', browserutil.DefaultHomepage())
        self.homeEdit.SetValue(settings.user.ui.Get('HomePage2', browserutil.DefaultHomepage()))

    def ResetCacheLocation(self, *args):
        settings.public.generic.Set('BrowserCache', corebrowserutil.DefaultCachePath())
        self.cacheEdit.SetValue(corebrowserutil.DefaultCachePath())

    def Save(self, *args):
        url = self.homeEdit.GetValue().strip()
        if url and url.find('://') < 0:
            url = 'http://' + url
            self.homeEdit.SetValue(url)
        settings.user.ui.Set('HomePage2', url)
        if not blue.win32.IsTransgaming():
            cachePath = self.cacheEdit.GetValue().strip()
            cachePath = blue.paths.ResolvePath(cachePath)
            if cachePath:
                self.cacheEdit.SetValue(cachePath)
            settings.public.generic.Set('BrowserCache', cachePath)
        show = bool(self.showStatusBarCbx.GetValue())
        if bool(self.showStatusBar) != show:
            self.showStatusBar = show
            settings.user.ui.Set('browserShowStatusBar', show)
            sm.ScatterEvent('OnBrowserShowStatusBarChange')
        show = bool(self.showNavBarCbx.GetValue())
        if bool(self.showNavigationBar) != show:
            self.showNavigationBar = show
            settings.user.ui.Set('browserShowNavBar', show)
            sm.ScatterEvent('OnBrowserShowNavigationBarChange')

    def ClearCache(self, *args):
        if uicore.Message('BrowserClearCache', {}, uiconst.YESNO) == uiconst.ID_YES:
            from carbonui.control.browser.browserWindow import BrowserWindowCore
            for wnd in uicore.registry.GetWindows()[:]:
                if issubclass(wnd.__class__, BrowserWindowCore):
                    wnd.Close()

            sm.GetService('browserHostManager').RestartBrowserHost(clearCache=True)
            self.CloseByUser()
class CameraDebugWindow(Window):
    """ Window for debug camera control and feedback """
    __guid__ = 'uicls.CameraDebugWindow'
    default_windowID = 'CameraDebugWindow'
    default_width = 500
    default_height = 200

    def ApplyAttributes(self, attributes):
        super(CameraDebugWindow, self).ApplyAttributes(attributes)
        self.SetMinSize([self.default_width, self.default_height])
        self.SetCaption('Camera Debug Window')
        self.sr.content.padding = (5, 16, 5, 5)
        self.debugSelectionClient = sm.GetService('debugSelectionClient')
        self.cameraDebugClient = sm.GetService('cameraDebugClient')
        self.cameraClient = sm.GetService('cameraClient')
        self.cameraStack = Label(parent=self.sr.content, align=uiconst.TOPLEFT, text=self.PrintCameraStack())
        buttonContainer = Container(parent=self.sr.content, align=uiconst.TOBOTTOM, height=70, padding=(150, 0, 150, 0))
        self.toggleCamera = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Activate Normal Camera', func=self.OnToggleDebugCamera)
        self.toggleCamUpdate = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Toggle Camera Update', func=self.OnToggleDebugCameraUpdate, hint='Toggle between updating the debug, and normal camera.')
        self.showCamCheckBox = Checkbox(parent=buttonContainer, aligh=uiconst.TOBOTTOM, text='Show Normal Camera', checked=False, callback=self.OnSnowNormalCameraCheckbox)
        import cameras
        self.cameraClient.AddSharedCamera('Debug Camera', cameras.DebugCamera())
        if type(self.cameraClient.GetActiveCamera()) is cameras.DebugCamera:
            self.DisableDebugCamera()
        self.EnableDebugCamera()
        sm.GetService('navigation').hasControl = False

    def OnSnowNormalCameraCheckbox(self, checkBox):
        debugCam = self.cameraClient.GetSharedCamera('Debug Camera')
        debugCam.SetShowNormalCamera(checkBox.GetValue())

    def OnToggleDebugCamera(self, *args):
        activeCam = self.cameraClient.GetActiveCamera()
        debugCam = self.cameraClient.GetSharedCamera('Debug Camera')
        if activeCam is debugCam:
            self.DisableDebugCamera()
        else:
            self.EnableDebugCamera()

    def EnableDebugCamera(self):
        debugCamera = self.cameraClient.GetSharedCamera('Debug Camera')
        entity = self.debugSelectionClient.GetSelectedEntity()
        if entity is None:
            self.debugSelectionClient.SelectPlayer()
            entity = self.debugSelectionClient.GetSelectedEntity()
        if entity is not None:
            entPos = entity.position.position
            position = (entPos[0], entPos[1] + DEFAULT_Y_OFFSET, entPos[2])
            debugCamera.SetPointOfInterest(position)
            debugCamera.distance = 0.0
            if debugCamera not in self.cameraClient.GetCameraStack():
                self.cameraClient.PushActiveCamera(debugCamera)
        self.cameraStack.SetText(self.PrintCameraStack())
        self.toggleCamera.SetLabel('Activate Normal Camera')
        self.toggleCamUpdate.Enable()
        self.showCamCheckBox.Show()
        sm.GetService('navigation').hasControl = debugCamera.IsControlEnabled()
        debugCamera.SetShowNormalCamera(self.showCamCheckBox.GetValue())

    def DisableDebugCamera(self):
        self.cameraClient.PopActiveCamera()
        self.cameraStack.SetText(self.PrintCameraStack())
        self.toggleCamera.SetLabel('Activate Debug Camera')
        self.toggleCamUpdate.Disable()
        self.showCamCheckBox.Hide()
        sm.GetService('navigation').hasControl = True
        debugCam = self.cameraClient.GetSharedCamera('Debug Camera')
        debugCam.SetShowNormalCamera(False)

    def OnToggleDebugCameraUpdate(self, *args):
        self.cameraDebugClient.ToggleDebugCameraUpdate()

    def PrintCameraStack(self):
        """
        Print out each camera in the stack along with all of their behaviors.
        """
        stack = self.cameraClient.GetCameraStack()
        stackStr = ''
        for i, cam in enumerate(stack):
            stackStr += str(i) + ': ' + str(cam) + '\n'
            for behavior in cam.cameraBehaviors:
                stackStr += '\t' + str(behavior) + '\n'

        stackStr = stackStr.replace('<', '').replace('>', '')
        return stackStr

    def Close(self, *args, **kwds):
        import cameras
        if type(self.cameraClient.GetActiveCamera()) is cameras.DebugCamera:
            self.DisableDebugCamera()
        Window.Close(self, *args, **kwds)
    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.SetMinSize((500, 300))
        main = self.GetMainArea()
        main.clipChildren = True
        options = Container(parent=main, align=uiconst.TOLEFT, width=180, padTop=4, padLeft=5)
        fontsParent = Container(parent=options)
        flagsParent = Container(parent=options)
        tabs = uicontrols.TabGroup(parent=options, tabs=[('Fonts',
          fontsParent,
          self,
          'properties'), ('Load Flags',
          flagsParent,
          self,
          'flags')], padBottom=6, idx=0)
        for each in (STYLECLASSES, CLIENTFONTS, WINDOWSFONTS):
            Checkbox(parent=fontsParent, text='Browse ' + each, groupname='browseType', checked=each == STYLECLASSES, callback=self.OnBrowseTypeChange, retval=each)

        import uicls
        clientLabelClasses = []
        for className, cls in uicls.__dict__.iteritems():
            try:
                if issubclass(cls, LabelCore) and cls is not LabelCore and getattr(cls, '__guid__', None) is not None:
                    clientLabelClasses.append((className, (className, cls)))
            except:
                pass

        clientLabelClasses = SortListOfTuples(clientLabelClasses)
        self.styleClassesLabel = Label(parent=fontsParent, text='Style Classes', align=uiconst.TOTOP, padTop=10)
        self.styleClassesCombo = Combo(parent=fontsParent, align=uiconst.TOTOP, options=clientLabelClasses, callback=self.OnStyleClassChange)
        clientFaces = []
        clientFonts = os.listdir(blue.paths.ResolvePathForWriting(u'res:') + '\\UI\\Fonts')
        clientFonts.sort()
        for fontName in clientFonts:
            if fontName.lower().endswith('.ttf') or fontName.lower().endswith('.otf'):
                clientFaces.append((fontName, 'res:/UI/Fonts/' + fontName))

        self.clientFontsLabel = Label(parent=fontsParent, text='Client Fonts', align=uiconst.TOTOP, padTop=10)
        self.clientFontsCombo = typeFaceCombo = Combo(parent=fontsParent, align=uiconst.TOTOP, options=clientFaces, callback=self.OnTypeFaceChange)
        windowsFaces = []
        windowsFonts = os.listdir(blue.sysinfo.GetSharedFontsDirectory())
        windowsFonts.sort()
        for fontName in windowsFonts:
            if fontName.lower().endswith('.ttf') or fontName.lower().endswith('.otf'):
                windowsFaces.append((fontName, os.path.join(blue.sysinfo.GetSharedFontsDirectory(), fontName)))

        self.windowsFontsLabel = Label(parent=fontsParent, text='Windows Fonts', align=uiconst.TOTOP, padTop=10)
        self.windowsFontsCombo = typeFaceCombo = Combo(parent=fontsParent, align=uiconst.TOTOP, options=windowsFaces, callback=self.OnTypeFaceChange)
        Label(parent=fontsParent, text='Fontsize', align=uiconst.TOTOP, padTop=10)
        self.fontSizeEdit = SinglelineEdit(ints=(6, 128), parent=fontsParent, align=uiconst.TOTOP, OnChange=self.OnFontSizeChange, setvalue=unicode(Label.default_fontsize))
        Label(parent=fontsParent, text='Letterspace', align=uiconst.TOTOP, padTop=10)
        self.letterSpaceEdit = SinglelineEdit(ints=(-10, 10), parent=fontsParent, align=uiconst.TOTOP, OnChange=self.OnLetterSpaceChange, setvalue=unicode(Label.default_letterspace))
        Label(parent=fontsParent, text='LineSpacing', align=uiconst.TOTOP, padTop=10)
        self.lineSpacingEdit = SinglelineEdit(floats=(-1.0, 1.0, 2), parent=fontsParent, align=uiconst.TOTOP, OnChange=self.OnLineSpacingChange, setvalue=unicode(0.0))
        current = trinity.fontMan.loadFlag
        self.loadFlagCheckBoxes = []
        for flagName, flagValue in loadFlags:
            active = current & flagValue == flagValue
            cb = Checkbox(parent=flagsParent, align=uiconst.TOTOP, text=flagName.replace('FT_LOAD_', ''), callback=self.OnLoadFlagChange, retval=flagValue, checked=active)
            cb.flagName = flagName
            cb.flagValue = flagValue
            self.loadFlagCheckBoxes.append(cb)

        Label(parent=flagsParent, text='Render flags', align=uiconst.TOTOP, padTop=10)
        self.renderFlagCheckBoxes = []
        for flagName, flagValue in renderFlags:
            active = current & flagValue == flagValue
            cb = Checkbox(parent=flagsParent, align=uiconst.TOTOP, text=flagName.replace('FT_RENDER_MODE_', ''), groupname='renderFlag', callback=self.OnRenderFlagChange, retval=flagValue, checked=active)
            cb.flagName = flagName
            cb.flagValue = flagValue
            self.renderFlagCheckBoxes.append(cb)

        sampleSelectionParent = Container(parent=main, align=uiconst.TOTOP, height=38, padTop=20)
        Line(parent=main, align=uiconst.TOTOP, padTop=10, padRight=10, padLeft=10)
        self.sampleCombo = Combo(parent=sampleSelectionParent, align=uiconst.TOPLEFT, width=100, left=10, options=[('Lorem...', samplText), ('Ansi charset', ANSI), ('Cyrillic charset', CYRILLIC)], callback=self.OnSampleComboChange)
        orlabel = Label(parent=sampleSelectionParent, text='-or-', left=self.sampleCombo.left + self.sampleCombo.width + 5)
        self.sampleInput = EditPlainText(parent=sampleSelectionParent, align=uiconst.TOALL, padLeft=140, padRight=10, text='asdf sfdasfasfdasfd safd')
        self.sampleInput.OnChange = self.OnCustomTextChange
        self.samples = []
        for typeFace in clientFonts[:1]:
            sampl = Label(parent=main, align=uiconst.TOTOP, text=samplText, padding=10)
            self.samples.append(sampl)

        self.LoadBrowseType(STYLECLASSES)
 def Create_checkbox(self, attrs):
     from carbonui.control.checkbox import CheckboxCoreOverride as Checkbox
     cbox = Checkbox(pos=(0, 0, 0, 0), align=uiconst.RELATIVE)
     cbox.data = {}
     attrs.vspace = 3
     return cbox