Package appModules :: Module msimn
[hide private]
[frames] | no frames]

Source Code for Module appModules.msimn

  1  #appModules/msimn.py - Outlook Express appModule 
  2  #A part of NonVisual Desktop Access (NVDA) 
  3  #Copyright (C) 2006-2010 NVDA Contributors <http://www.nvda-project.org/> 
  4  #This file is covered by the GNU General Public License. 
  5  #See the file COPYING for more details. 
  6   
  7  import winUser 
  8  import controlTypes 
  9  import displayModel 
 10  import textInfos 
 11  import api 
 12  import appModuleHandler 
 13  import speech 
 14  from keyboardHandler import KeyboardInputGesture 
 15  from NVDAObjects.IAccessible import sysListView32 
 16  import watchdog 
 17   
 18  #Labels for the header fields of an email, by control ID 
 19  envelopeNames={ 
 20          1000:_("Attachments"), 
 21          1001:_("To:"), 
 22          1002:_("Newsgroup:"), 
 23          1003:_("CC:"), 
 24          1004:_("Subject:"), 
 25          1005:_("From:"), 
 26          1016:_("Date:"), 
 27          1018:_("Forward to:"), 
 28          1019:_("Answer to:"), 
 29          1020:_("Organisation:"), 
 30          1021:_("Distribution:"), 
 31          1022:_("Key words:"), 
 32          1026:_("BCC:"), 
 33          1037:_("From:"), 
 34  } 
 35   
36 -class AppModule(appModuleHandler.AppModule):
37
38 - def event_NVDAObject_init(self,obj):
39 controlID=obj.windowControlID 40 windowHandle=obj.windowHandle 41 parentWindow=winUser.getAncestor(windowHandle,winUser.GA_PARENT) 42 parentClassName=winUser.getClassName(parentWindow) 43 #If this object is an email header field, and we have a custom label for it, 44 #Then set the object's name to the label 45 if parentClassName=="OE_Envelope" and obj.IAccessibleChildID==0 and envelopeNames.has_key(controlID): 46 obj.name=envelopeNames[controlID] 47 obj.useITextDocumentSupport=True 48 obj.editValueUnit=textInfos.UNIT_STORY
49
50 - def chooseNVDAObjectOverlayClasses(self,obj,clsList):
51 if obj.windowClassName=="SysListView32" and obj.windowControlID in (128,129,130) and obj.role==controlTypes.ROLE_LISTITEM: 52 clsList.insert(0,MessageRuleListItem) 53 elif "SysListView32" in obj.windowClassName and obj.role==controlTypes.ROLE_LISTITEM and obj.parent.name=="Outlook Express Message List": 54 clsList.insert(0,MessageListItem)
55
56 - def event_gainFocus(self,obj,nextHandler):
57 nextHandler() 58 #Force focus to move to something sane when landing on an outlook express message window 59 if obj.windowClassName=="ATH_Note" and obj.event_objectID==winUser.OBJID_CLIENT and obj.IAccessibleChildID==0: 60 api.processPendingEvents() 61 if obj==api.getFocusObject() and controlTypes.STATE_FOCUSED in obj.states: 62 return KeyboardInputGesture.fromName("shift+tab").send()
63
64 -class MessageRuleListItem(sysListView32.ListItem):
65 """Used for the checkbox list items used to select message rule types in in message filters""" 66 67 role=controlTypes.ROLE_CHECKBOX 68
69 - def _get_states(self):
70 states=super(MessageRuleListItem,self).states 71 if (watchdog.cancellableSendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12)==8: 72 states.add(controlTypes.STATE_CHECKED) 73 return states
74
75 -class MessageListItem(sysListView32.ListItem):
76
77 - def _get_isUnread(self):
78 info=displayModel.DisplayModelTextInfo(self,textInfos.POSITION_FIRST) 79 info.expand(textInfos.UNIT_CHARACTER) 80 fields=info.getTextWithFields() 81 try: 82 isUnread=fields[1].field['bold'] 83 except: 84 isUnread=False 85 return isUnread
86
87 - def _get_name(self):
88 nameList=[] 89 imageState=watchdog.cancellableSendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12 90 if imageState==5: 91 nameList.append(controlTypes.speechStateLabels[controlTypes.STATE_COLLAPSED]) 92 elif imageState==6: 93 nameList.append(controlTypes.speechStateLabels[controlTypes.STATE_EXPANDED]) 94 if self.isUnread: 95 nameList.append(_("unread")) 96 name=super(MessageListItem,self).name 97 if name: 98 nameList.append(name) 99 return " ".join(nameList)
100