Ejemplo n.º 1
0
    def setIconLists(self, normalList, normalSize, normalType, smallList,
                     smallSize, smallType):
        app = win32ui.GetApp()
        mask = 0

        # normal icons image list
        if normalList:
            initcount = len(normalList)
            growby = initcount
            normalImageList = win32ui.CreateImageList(normalSize, normalSize,
                                                      mask, initcount, growby)
            normalImageList.SetBkColor(win32mu.RGB((255, 255, 255)))
            # populate normal image list
            for id in normalList:
                normalImageList.Add(app.LoadIcon(id))

        # smal icons image list
        if smallList:
            initcount = len(smallList)
            growby = initcount
            smallImageList = win32ui.CreateImageList(smallSize, smallSize,
                                                     mask, initcount, growby)
            smallImageList.SetBkColor(win32mu.RGB((255, 255, 255)))
            # populate small image list
            for id in normalList:
                smallImageList.Add(app.LoadIcon(id))

        # finally set image list
        if normalList:
            self.SetImageList(normalImageList, normalType)
        if smallList:
            self.SetImageList(smallImageList, smallType)
Ejemplo n.º 2
0
	def HierInit(self, parent, listControl = None ):	# Used when window first exists.
		# this also calls "Create" on the listbox.
		# params - id of listbbox, ID of bitmap, size of bitmaps
		if self.bitmapMask is None:
			bitmapMask = RGB(0,0,255)
		else:
			bitmapMask = self.bitmapMask
		self.imageList = win32ui.CreateImageList(self.bitmapID, 16, 0, bitmapMask)
		if listControl is None:
			if self.listBoxId is None: self.listBoxId = win32ui.IDC_LIST1
			self.list = parent.GetDlgItem(self.listBoxId)
		else:
			self.list = listControl
			lbid = listControl.GetDlgCtrlID()
			assert self.listBoxId is None or self.listBoxId == lbid, "An invalid listbox control ID has been specified (specified as %s, but exists as %s)" % (self.listBoxId, lbid)
			self.listBoxId = lbid
		self.list.SetImageList(self.imageList, commctrl.LVSIL_NORMAL)
#		self.list.AttachObject(self)
		parent.HookNotify(self.OnTreeItemExpanding, commctrl.TVN_ITEMEXPANDING)
		parent.HookNotify(self.OnTreeItemSelChanged, commctrl.TVN_SELCHANGED)
		parent.HookNotify(self.OnTreeItemDoubleClick, commctrl.NM_DBLCLK)
		self.notify_parent = parent

		if self.root:
			self.AcceptRoot(self.root)
Ejemplo n.º 3
0
 def OnCreateClient(self, cp, context):
     splitter = win32ui.CreateSplitter()
     doc = context.doc
     frame_rect = self.GetWindowRect()
     size = ((frame_rect[2] - frame_rect[0]),
             (frame_rect[3] - frame_rect[1]) // 2)
     sub_size = (size[0] // 2, size[1])
     splitter.CreateStatic(self, 2, 1)
     self.v1 = win32ui.CreateEditView(doc)
     self.v2 = fontdemo.FontView(doc)
     # CListControl view
     self.v3 = win32ui.CreateListView(doc)
     sub_splitter = win32ui.CreateSplitter()
     # pass "splitter" so each view knows how to get to the others
     sub_splitter.CreateStatic(splitter, 1, 2)
     sub_splitter.CreateView(self.v1, 0, 0, (sub_size))
     sub_splitter.CreateView(self.v2, 0, 1, (0, 0))  # size ignored.
     splitter.SetRowInfo(0, size[1], 0)
     splitter.CreateView(self.v3, 1, 0, (0, 0))  # size ignored.
     # Setup items in the imagelist
     self.images = win32ui.CreateImageList(32, 32, 1, 5, 5)
     self.images.Add(win32ui.GetApp().LoadIcon(win32ui.IDR_MAINFRAME))
     self.images.Add(win32ui.GetApp().LoadIcon(win32ui.IDR_PYTHONCONTYPE))
     self.images.Add(win32ui.GetApp().LoadIcon(win32ui.IDR_TEXTTYPE))
     self.v3.SetImageList(self.images, commctrl.LVSIL_NORMAL)
     self.v3.InsertItem(0, "Icon 1", 0)
     self.v3.InsertItem(0, "Icon 2", 1)
     self.v3.InsertItem(0, "Icon 3", 2)
     #		self.v3.Arrange(commctrl.LVA_DEFAULT) Hmmm - win95 aligns left always???
     return 1
Ejemplo n.º 4
0
	def HierInit(self, parent, listControl = None ):	# Used when window first exists.
		# this also calls "Create" on the listbox.
		# params - id of listbbox, ID of bitmap, size of bitmaps
		if self.bitmapMask is None:
			bitmapMask = RGB(0,0,255)
		else:
			bitmapMask = self.bitmapMask
		self.imageList = win32ui.CreateImageList(self.bitmapID, 16, 0, bitmapMask)
		if listControl is None:
			if self.listBoxId is None: self.listBoxId = win32ui.IDC_LIST1
			self.listControl = parent.GetDlgItem(self.listBoxId)
		else:
			self.listControl = listControl
			lbid = listControl.GetDlgCtrlID()
			assert self.listBoxId is None or self.listBoxId == lbid, "An invalid listbox control ID has been specified (specified as %s, but exists as %s)" % (self.listBoxId, lbid)
			self.listBoxId = lbid
		self.listControl.SetImageList(self.imageList, commctrl.LVSIL_NORMAL)
#		self.list.AttachObject(self)

		## ??? Need a better way to do this - either some way to detect if it's compiled with UNICODE
		##  defined, and/or a way to switch the constants based on UNICODE ???
		if sys.version_info[0] < 3:
			parent.HookNotify(self.OnTreeItemExpanding, commctrl.TVN_ITEMEXPANDINGA)
			parent.HookNotify(self.OnTreeItemSelChanged, commctrl.TVN_SELCHANGEDA)
		else:
			parent.HookNotify(self.OnTreeItemExpanding, commctrl.TVN_ITEMEXPANDINGW)
			parent.HookNotify(self.OnTreeItemSelChanged, commctrl.TVN_SELCHANGEDW)
		parent.HookNotify(self.OnTreeItemDoubleClick, commctrl.NM_DBLCLK)
		self.notify_parent = parent

		if self.root:
			self.AcceptRoot(self.root)