Esempio n. 1
0
 def setcursor(self, strid):
     if strid == self._cursor:
         return
     App=win32ui.GetApp()
     import win32window
     cursor = win32window.getcursorhandle(strid)
     win32ui.GetWin32Sdk().SetCursor(cursor)
     self._cursor = strid
Esempio n. 2
0
 def createDDB(self, img, w=0, h=0):
     if img < 0: return
     if w == 0 or h == 0:
         w, h, d = self.size(img)
     hbmp, hpal = self.lib.image_create_ddb(img, w, h)
     import win32ui
     bmp = win32ui.CreateBitmapFromHandle(hbmp)
     win32ui.GetWin32Sdk().DeleteObject(hpal)
     return bmp
Esempio n. 3
0
 def createDDB(self,img, w = 0, h = 0):
     if img is None:
         return None
     if w==0 or h==0:
         w, h, d = img.image_dimensions_get()
     hbmp, hpal = img.image_create_ddb(w, h)
     import win32ui
     bmp = win32ui.CreateBitmapFromHandle(hbmp)
     win32ui.GetWin32Sdk().DeleteObject(hpal)
     return bmp
Esempio n. 4
0
    def chooseBgColor(self, currentBg):
        r, g, b = currentBg or (255, 255, 255)
        dlg = win32ui.CreateColorDialog(win32api.RGB(r, g, b),
                                        win32con.CC_ANYCOLOR, self.__window)
        if dlg.DoModal() == win32con.IDOK:
            newcol = dlg.GetColor()
            rgb = win32ui.GetWin32Sdk().GetRGBValues(newcol)
            return rgb

        return None
Esempio n. 5
0
def Boot( bEditor = 0 ):
    CMIFDIR = win32api.GetFullPathName(os.path.join(os.path.split(sys.argv[0])[0], "." ))

    # TEMP TEST FOLDER
    if bEditor:
        specificPath = "editor"
        os.environ['GRiNSApp']='GRiNSed'
    else:
        specificPath = "grins"
        os.environ['GRiNSApp']='GRiNS'

    CMIFPATH = [
            os.path.join(CMIFDIR, '%s\\win32' % specificPath),
            os.path.join(CMIFDIR, 'common\\win32'),
            os.path.join(CMIFDIR, 'lib\\win32'),
            os.path.join(CMIFDIR, '%s' % specificPath),
            os.path.join(CMIFDIR, 'common'),
            os.path.join(CMIFDIR, 'lib'),
            os.path.join(CMIFDIR, 'pylib'),
            os.path.join(CMIFDIR, 'pylib\\audio'),
            os.path.join(CMIFDIR, 'win32\\src\\Build'),
    ]
    CMIF_USE_WIN32="ON"
    #CHANNELDEBUG="ON"

    sys.path[0:0] = CMIFPATH

    os.environ["CMIF"] = CMIFDIR
    #os.environ["CHANNELDEBUG"] = "ON"
    os.environ["CMIF_USE_WIN32"] = "ON"

    # Locate the GRiNSRes.dll file.  This is presumably in the same directory as
    # the extensionmodules, or if frozen, in the main directory
    # This call allows Pythonwin to automatically find resources in it.
    import win32ui
    dllPath = os.path.split(win32ui.__file__)[0]
    win32ui.GetWin32Sdk().SetCurrentDirectory(dllPath)
    try:
        global resdll
        resdll = win32ui.LoadLibrary(os.path.join(dllPath, "GRiNSRes.dll"))
        resdll.AttachToMFC()
    except win32ui.error:
        win32ui.MessageBox("The application resource DLL 'GRiNSRes.dll' can not be located\r\n\r\nPlease correct this problem, and restart the application")
        # For now just continue!?!?!

    # set app registry root to GRiNS
    from version import registrykey, registryname
    win32ui.SetAppName(registryname)
    win32ui.SetRegistryKey(registrykey)

    # run the given cmif file
    if bEditor:
        import cmifed
    else:
        import grins
Esempio n. 6
0
 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)
Esempio n. 7
0
 def OnDrawItem(self, params):
     lParam = params[3]
     sdk = win32ui.GetWin32Sdk()
     hdc = sdk.ParseDrawItemStruct(lParam)
     dc = win32ui.CreateDCFromHandle(hdc)
     rct = self.__splash.GetClientRect()
     try:
         win32mu.BitBltBmp(dc, self.__bmp, rct)
     except:
         print dc, self.__bmp, rct
         return
     br = sdk.CreateBrush(win32con.BS_SOLID, 0, 0)
     dc.FrameRectFromHandle(rct, br)
     sdk.DeleteObject(br)
     dc.DeleteDC()
Esempio n. 8
0
__version__ = "$Id$"

import win32ui, win32api, win32con

afx = win32ui.GetAfx()
sdk = win32ui.GetWin32Sdk()

from appcon import UNIT_MM, UNIT_SCREEN, UNIT_PXL


def GetSystemMetrics():
    cxframe = win32api.GetSystemMetrics(win32con.SM_CXFRAME)
    cyframe = win32api.GetSystemMetrics(win32con.SM_CYFRAME)
    cxborder = win32api.GetSystemMetrics(win32con.SM_CXBORDER)
    cyborder = win32api.GetSystemMetrics(win32con.SM_CYBORDER)
    cycaption = win32api.GetSystemMetrics(win32con.SM_CYCAPTION)
    return cxframe, cyframe, cxborder, cyborder, cycaption


def GetDeviceCaps():
    wnd = sdk.GetDesktopWindow()
    dc = wnd.GetDC()
    width_pxl = dc.GetDeviceCaps(win32con.HORZRES)
    height_pxl = dc.GetDeviceCaps(win32con.VERTRES)

    #Number of pxl per logical inch
    dpi_x = dc.GetDeviceCaps(win32con.LOGPIXELSX)
    dpi_y = dc.GetDeviceCaps(win32con.LOGPIXELSY)

    #width_mm=dc.GetDeviceCaps(win32con.HORZSIZE)
    #height_mm=dc.GetDeviceCaps(win32con.VERTSIZE)