def ListenPadDevice(self, x, y, z): if x not in self.KeyBounded: keyb = self.IManager.GetAttachedDevice("Pad") self.IManager.SetInputActionsSet("Default") if keyb.IsBinded(x) or len(self.KeyBounded) >= 3: self.SetStatusText( MenuText.GetMenuText("The pad action <") + x + MenuText.GetMenuText("> is already used!")) pass else: self.IAction.AddEvent(keyb, x, 1) for k in self.Extras: if k[0] == "Press": self.IManager.GetInputActions().Find(k[1]).AddEvent( keyb, x, 1) elif k[0] == "Release": self.IManager.GetInputActions().Find(k[1]).AddEvent( keyb, x, 0) else: print "ERROR : '", k[0], "' is not defined yet!" self.KeyBounded.append(x) self.IManager.SetInputActionsSet("MenuRedefine") self.wActionKeys.SetText(str(self.KeyBounded)) self.RecalcLayout() self.EndDefineKey()
def ListenDevice(self, x, y, z): if z == 1.0: if x == "Esc": self.EndDefineKey() self.ReadyToEscape = 0 elif x not in self.KeyBounded: if x == "Delete": self.ReadyToEscape = 0 keyb = self.IManager.GetAttachedDevice("Keyboard") self.IManager.SetInputActionsSet("Default") if keyb.IsBinded(x): self.SetStatusText( MenuText.GetMenuText("The key <") + x + MenuText.GetMenuText("> is already used!")) elif len(self.KeyBounded) >= 3: self.SetStatusText( MenuText.GetMenuText( "You already have 3 keys assigned to that action")) else: self.IAction.AddEvent(keyb, x, 1) for k in self.Extras: if k[0] == "Press": self.IManager.GetInputActions().Find( k[1]).AddEvent(keyb, x, 1) elif k[0] == "Release": self.IManager.GetInputActions().Find( k[1]).AddEvent(keyb, x, 0) else: print "ERROR : '", k[0], "' is not defined yet!" self.KeyBounded.append(x) self.IManager.SetInputActionsSet("MenuRedefine") self.wActionKeys.SetText(str(self.KeyBounded)) self.RecalcLayout() self.EndDefineKey()
def ActivateItem(self, act): if not act: if self.ReadyToEscape: B_ControlItemTexts.ActivateItem(self, act) self.ReadyToEscape = 1 return if len(self.KeyBounded) >= 3: self.SetStatusText( MenuText.GetMenuText( "Maximun number of key bindings reached.")) return self.SetStatusText( MenuText.GetMenuText("Press desired key, Escape to end")) keyb = self.IManager.GetAttachedDevice("Keyboard") if keyb.this != "NULL": keyb.AddListener(self.Listener) keyb = self.IManager.GetAttachedDevice("Mouse") if keyb.this != "NULL": keyb.AddListener(self.MouseListener) keyb = self.IManager.GetAttachedDevice("Pad") if keyb.this != "NULL": keyb.AddListener(self.PadListener) self.oldInputActionsSet = self.IManager.GetInputActionsSet() self.IManager.SetInputActionsSet("MenuRedefine") self.wActionName.ChangingKey = 1 self.wActionKeys.ChangingKey = 1
def ActivateItem(self,activate): check_pass = None val = 1 if self.MenuDescr.has_key("CheckPass"): check_pass=self.MenuDescr["CheckPass"] val = check_pass() if ((activate==1) and (val==1)): self.SelOption=self.SelOption+1 self.SelOption=self.SelOption% len(self.Options) OptionText=self.OptionText+" < "+self.Options[self.SelOption]+" >" self.SetText(OptionText) nvda.SpeakText(OptionText) try: # Puede que Parent no herede de Frame self.Parent.RecalcLayout() except: pass try: command=self.MenuDescr["Command"] command(MenuText.GetInverseMenuText(self.Options[self.SelOption])) except KeyError: pass elif activate==0: self.StackMenu.Pop()
def SetFocus(self,menu_element): accepts_focus=0 try: accepts_focus=menu_element.AcceptsFocus() except: pass if accepts_focus==1: old_foc=self.GetFocus() if menu_element==old_foc: return 1 if old_foc: old_foc.SetHasFocus(0) menu_element.SetHasFocus(1) self.Focus=menu_element nvda.SpeakText(MenuText.GetInverseMenuText(menu_element.Name())) return 1 return 0
def __init__(self, Parent, Menudesc, StackMenu, VertPos=0): ListWidget.B_ListWidget.__init__(self, Parent, Menudesc, StackMenu, VertPos) self.StatusText = BUIx.B_TextWidget( self, "Status", MenuText.GetMenuText(DefInfoText), ScorerWidgets.font_server, "..\\..\\Data\\Letras menu peq.bmp") self.StatusText.SetColor(252, 247, 167) self.StatusText.SetAlpha(1) self.AddLabel(self.StatusText, 0.5, 25, BUIx.B_Widget.B_LAB_HCenter, BUIx.B_Widget.B_LAB_Bottom, BUIx.B_Widget.B_FR_HRelative, BUIx.B_Widget.B_LAB_HCenter, BUIx.B_Widget.B_FR_AbsoluteTop, BUIx.B_Widget.B_FR_Top) self.DownArrow.SetAlpha( 1 ) # Parche, no funciona la llamada a AdjustScrollArrows() en AddMenuElement(), # hasta que lo averige. self.SetClipDraw(1) self.SetDrawFunc(self.Draw)
def EndDefineKey(self): self.SetStatusText(MenuText.GetMenuText(DefInfoText)) self.IManager.SetInputActionsSet(self.oldInputActionsSet) keyb = self.IManager.GetAttachedDevice("Keyboard") if keyb.this != "NULL": keyb.RemoveListener(self.ListenerName) keyb = self.IManager.GetAttachedDevice("Mouse") if keyb.this != "NULL": keyb.RemoveListener(self.MouseListenerName) keyb = self.IManager.GetAttachedDevice("Pad") if keyb.this != "NULL": keyb.RemoveListener(self.PadListenerName) self.wActionName.ChangingKey = 0 self.wActionName.SelectionFilterUpdated = 0 self.wActionName.FilterUpdated = 0 self.wActionKeys.ChangingKey = 0 self.wActionKeys.SelectionFilterUpdated = 0 self.wActionKeys.FilterUpdated = 0
def DecMenuItem(self): check_pass = None val = 1 if self.MenuDescr.has_key("CheckPass"): check_pass=self.MenuDescr["CheckPass"] val = check_pass() if (val==1): self.SelOption=self.SelOption+len(self.Options)-1 self.SelOption=self.SelOption% len(self.Options) OptionText=self.OptionText+" < "+self.Options[self.SelOption]+" >" self.SetText(OptionText) try: # Puede que Parent no herede de Frame self.Parent.RecalcLayout() except: pass try: command=self.MenuDescr["Command"] command(MenuText.GetInverseMenuText(self.Options[self.SelOption])) except KeyError: pass
def Draw(self, x, y, time): if self.GetVisible() == 0: return #self.SetAlpha(0.5) foc = self.GetHasFocus() if foc != self._foc: self.SelectionFilterUpdated = 0 self.FilterIncX = 0 self.FilterUpdated = 0 self._foc = foc w, h = self.GetSize() if foc: if self.ActionName: if ActionDescriptor.has_key(self.ActionName): netwidgets.LabelName = MenuText.GetMenuText( ActionDescriptor[self.ActionName]) else: netwidgets.LabelName = " " if self.ChangingKey: mult = math.cos(time * 2) self.SetColor(80 * mult + 150, 80 * mult + 150, 45 * mult + 105) self.DefDraw(x, y, time) return elif self.SelectionFilterUpdated: Raster.SetPosition(x - self.FilterIncX, y - self.FilterIncY) Raster.DrawImage(w + 2 * self.FilterIncX, h + 2 * self.FilterIncY, "RGB", "Native", self.SelectionFilter.GetImageBuffer()) self.SetColor(252, 247, 167) self.DefDraw(x, y, time) self.SetColor(207, 144, 49) return else: ## if self.Filter is None: ## self.CreateBlur(x,y,time) ## Raster.SetPosition(x-2,y-2) ## Raster.DrawImage(w+4,h+4,"RGB","Native",self.Filter.GetImageBuffer()) ## if Raster.GetClipActive(): ## print self.Name(),"ClipActive:",Raster.GetClipWindow() ## else: ## print self.Name(),"ClipNoActive:" self.DefDraw(x, y, time) return if foc: #self.CreateDistorsion(x,y,time) #if self.Filter is None: # self.CreateBlur(x,y,time) # self.FilterUpdated=1 #sfw,sfh=self.Filter.GetDimension() #self.SelectionFilter.CopySubBuffer(self.FilterIncX-2,0,sfw,sfh,self.Filter.GetImageBuffer(),"AddInc") #self.SelectionFilter.GetFromBuffer2("Substract") #Raster.SetPosition(x-self.FilterIncX,y-self.FilterIncY) #Raster.DrawImage(w+2*self.FilterIncX,h+2*self.FilterIncY,"RGB","Native",self.SelectionFilter.GetImageBuffer()) self.SetColor(252, 247, 167) self.DefDraw(x, y, time) self.SetColor(207, 144, 49) if self.FilterIncX > 25: self.SelectionFilterUpdated = 1 else: self.SelectionFilterUpdated = 0