コード例 #1
0
ファイル: IconMixin.py プロジェクト: ystallonne/grins
    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)
コード例 #2
0
ファイル: components.py プロジェクト: ystallonne/grins
 def create(self):
     brush = Sdk.CreateBrush(win32con.BS_SOLID, win32mu.RGB(self._bgcolor),
                             0)
     strclass = win32ui.GetAfx().RegisterWndClass(0, 0, brush, 0)
     style = win32con.WS_POPUP
     self.CreateWindowEx(win32con.WS_EX_TOPMOST, strclass, '', style,
                         self._rect, self._parent, 0)
コード例 #3
0
ファイル: winlayout.py プロジェクト: ystallonne/grins
    def createWindow(self, parent, rc, bgcolor, canvas=None):
        self._parent = parent
        self._rectb = rc
        self._bgcolor = bgcolor
        self._rect = 0, 0, rc[2], rc[3]
        self._canvas = canvas

        if not self._cancroll:
            if canvas is None:
                self._canvas = self._rect
            self.OnPaint = self._OnPaint
            brush = Sdk.CreateBrush(win32con.BS_SOLID, win32mu.RGB(bgcolor), 0)
            cursor = Afx.GetApp().LoadStandardCursor(win32con.IDC_ARROW)
            icon = 0
            clstyle = win32con.CS_DBLCLKS
            style = win32con.WS_CHILD | win32con.WS_CLIPSIBLINGS
            exstyle = 0
            title = ''
            strclass = Afx.RegisterWndClass(clstyle, cursor, brush, icon)
            self.CreateWindowEx(exstyle, strclass, title, style,
                                (rc[0], rc[1], rc[0] + rc[2], rc[1] + rc[3]),
                                parent, 0)
            self.ShowWindow(win32con.SW_SHOW)
            self.UpdateWindow()
        else:
            if canvas is None:
                self._canvas = 0, 0, 1600, 1200
            self.CreateWindow(parent)
            self.SetWindowPos(self.GetSafeHwnd(), rc,
                              win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER)
            self.SetScrollSizes(win32con.MM_TEXT, self._canvas[2:])
            self.ShowWindow(win32con.SW_SHOW)
            self.UpdateWindow()
コード例 #4
0
ファイル: win32dlview.py プロジェクト: ystallonne/grins
 def drawxorline(self, pt0, pt1, color=(0, 0, 0)):
     Sdk = win32ui.GetWin32Sdk()
     dc = self.GetDC()
     oldrop = dc.SetROP2(win32con.R2_NOTXORPEN)
     pen = Sdk.CreatePen(win32con.PS_SOLID, 1, win32mu.RGB(color))
     oldpen = dc.SelectObjectFromHandle(pen)
     dc.MoveTo(pt0)
     dc.LineTo(pt1)
     dc.SelectObjectFromHandle(oldpen)
     Sdk.DeleteObject(pen)
     dc.SetROP2(oldrop)
コード例 #5
0
ファイル: components.py プロジェクト: ystallonne/grins
 def OnPaint(self):
     dc, paintStruct = self.BeginPaint()
     dc.SetBkMode(win32con.TRANSPARENT)
     l, t, r, b = self.GetClientRect()
     dc.FillSolidRect((l, t, r, b),
                      win32mu.RGB(self._bgcolor or (255, 255, 255)))
     if self._text is not None:
         dl, dt, dr, db = self._margins
         hf = dc.SelectObjectFromHandle(self._hsmallfont)
         dc.DrawText(self._text, (l + dl, t + dt, r - dr, b - db))
         dc.SelectObjectFromHandle(hf)
     dc.FrameRectFromHandle(self.GetClientRect(), self._blackbrush)
     self.EndPaint(paintStruct)
コード例 #6
0
    def PaintOn(self,dc):
        if self._isminimized:
            return

        # only paint the rect that needs repainting
        rect=win32mu.Rect(dc.GetClipBox())

        # draw to offscreen bitmap for fast looking repaints
        dcc = dc.CreateCompatibleDC()

        self.assertBmpHasMinSize(rect.width(), rect.height(), dc)
        if self._bmp is None:
            print 'failed to create offscreen bitmap'
            return

        # called by win32ui
        #self.OnPrepareDC(dcc)

        # offset origin more because bitmap is just piece of the whole drawing
        dcc.OffsetViewportOrg((-rect.left, -rect.top))
        oldBitmap = dcc.SelectObject(self._bmp)
        dcc.SetBrushOrg((rect.left % 8, rect.top % 8))
        dcc.IntersectClipRect(rect.ltrb_tuple())

        # background decoration on dcc
        if self._active_displist:color=self._active_displist._bgcolor
        else: color=self._bgcolor
        dcc.FillSolidRect(rect.ltrb_tuple(),win32mu.RGB(color))

        # draw objects on dcc
        if self._active_displist:
            self._active_displist._render(dcc, rect.ltrb_tuple())

        # copy bitmap
        dcc.SetViewportOrg((0, 0))
        dcc.SetWindowOrg((0,0))
        dcc.SetMapMode(win32con.MM_TEXT)
        dc.BitBlt(rect.pos(),rect.size(),dcc,(0, 0), win32con.SRCCOPY)

        # clean up
        dcc.SelectObject(oldBitmap)
        dcc.DeleteDC()
コード例 #7
0
ファイル: winlayout.py プロジェクト: ystallonne/grins
    def OffscreenPaintOn(self, dc):
        lc, tc, rc, bc = dc.GetClipBox()
        wc, hc = rc - lc, bc - tc

        # draw to offscreen bitmap for fast looking repaints

        dcc = dc.CreateCompatibleDC(dc)

        self.assertBmpHasMinSize(wc, hc, dc)
        if self._bmp is None:
            dc.FillSolidRect((lc, tc, rc, bc),
                             win32mu.RGB(self._bgcolor or (255, 255, 255)))
            print 'Create offscreen bitmap %d x %d failed' % (wc, hc)
            return

        # called by win32ui
        #self.OnPrepareDC(dcc)

        # offset origin more because bitmap is just piece of the whole drawing
        dcc.OffsetViewportOrg((-lc, -tc))
        dcc.SetWindowOrg((0, 0))
        oldBitmap = dcc.SelectObject(self._bmp)
        dcc.SetBrushOrg((lc % 8, tc % 8))
        dcc.IntersectClipRect((lc, tc, rc, bc))
        # dcc has now the same clip box as the original dc

        # draw objects on dcc
        self.paintOn(dcc)

        # copy bitmap
        dcc.SetViewportOrg((0, 0))
        dcc.SetWindowOrg((0, 0))
        dcc.SetMapMode(win32con.MM_TEXT)
        dc.BitBlt((lc, tc), (wc, hc), dcc, (0, 0), win32con.SRCCOPY)

        # clean up
        dcc.SelectObject(oldBitmap)
        dcc.DeleteDC()
コード例 #8
0
ファイル: winlayout.py プロジェクト: ystallonne/grins
 def paintOn(self, dc):
     lc, tc, rc, bc = dc.GetClipBox()
     dc.FillSolidRect((lc, tc, rc, bc),
                      win32mu.RGB(self._bgcolor or (255, 255, 255)))
コード例 #9
0
ファイル: win32dlview.py プロジェクト: ystallonne/grins
 def OnEraseBkgnd(self, dc):
     rc = dc.GetClipBox()
     if self._active_displist: color = self._active_displist._bgcolor
     else: color = self._bgcolor
     dc.FillSolidRect(rc, win32mu.RGB(color))
     return 1