def __init__(self, obj=None): if obj is None: obj = win32ui.CreateControlBar() window.Wnd.__init__(self, obj) self.dialog = None self.nDockBarID = 0 self.sizeMin = 32, 32 self.sizeHorz = 200, 200 self.sizeVert = 200, 200 self.sizeFloat = 200, 200 self.bTracking = 0 self.bInRecalcNC = 0 self.cxEdge = 6 self.cxBorder = 3 self.cxGripper = 20 self.brushBkgd = win32ui.CreateBrush() self.brushBkgd.CreateSolidBrush( win32api.GetSysColor(win32con.COLOR_BTNFACE)) # Support for diagonal resizing self.cyBorder = 3 self.cCaptionSize = win32api.GetSystemMetrics(win32con.SM_CYSMCAPTION) self.cMinWidth = win32api.GetSystemMetrics(win32con.SM_CXMIN) self.cMinHeight = win32api.GetSystemMetrics(win32con.SM_CYMIN) self.rectUndock = (0, 0, 0, 0)
def drawstipplebox(self, color, coordinates, units=None): if units is None: units = self.__units if self._rendered: raise error, 'displaylist already rendered' x, y, w, h = self._convert_coordinates(coordinates, units=units) try: brush = win32ui.CreateBrush(win32con.BS_HATCHED, RGB(self._convert_color(color)), win32con.HS_DIAGCROSS) except win32ui.error, arg: print arg return
def draw_rectangle(x1, y1, x2, y2): width = 5 dc = win32gui.GetDC(0) hwnd = win32gui.WindowFromPoint((0, 0)) dcObj1 = win32ui.CreateDCFromHandle(dc) dcObj2 = win32ui.CreateDCFromHandle(dc) dcObj3 = win32ui.CreateDCFromHandle(dc) dcObj4 = win32ui.CreateDCFromHandle(dc) monitor = (0, 0, GetSystemMetrics(0), GetSystemMetrics(1)) brush = win32ui.CreateBrush(0, 0x00FF00, 0) start_time = time.time() # win32gui.InvalidateRect(hwnd, monitor, False) win32gui.InvalidateRect(None, monitor, True) while time.time() - start_time < 5: dcObj1.FillRect((x1, y1, x2, y1 + width), brush) dcObj2.FillRect((x1, y1, x1 + width, y2), brush) dcObj3.FillRect((x1, y2, x2, y2 - width), brush) dcObj4.FillRect((x2, y1, x2 - width, y2), brush) win32gui.InvalidateRect(hwnd, monitor, True)
win_dlog_class = "#32770" win_color3dhilight = api.GetSysColor(wc.COLOR_3DHILIGHT) win_color3dlight = api.GetSysColor(wc.COLOR_3DLIGHT) win_color3dface = api.GetSysColor(wc.COLOR_3DFACE) win_color3dshadow = api.GetSysColor(wc.COLOR_3DSHADOW) win_menubar_height = api.GetSystemMetrics(wc.SM_CYMENU) win_bg_color = api.GetSysColor(wc.COLOR_3DFACE) win_screen_width = api.GetSystemMetrics(wc.SM_CXFULLSCREEN) win_screen_height = api.GetSystemMetrics(wc.SM_CYFULLSCREEN) win_screen_rect = (0, 0, win_screen_width, win_screen_height) #win_bg_brush = ui.CreateBrush(wc.BS_SOLID, win_color3dface, 0) #win_bg_hbrush = win_bg_brush.GetSafeHandle() # An empty brush for not painting anything with win_null_brush = ui.CreateBrush(wc.BS_NULL, 0, 0) win_null_hbrush = win_null_brush.GetSafeHandle() # All components hook the following messages win_event_messages = ( wc.WM_KEYDOWN, wc.WM_KEYUP, wc.WM_SYSKEYDOWN, wc.WM_SYSKEYUP, wc.WM_MOUSEMOVE, wc.WM_LBUTTONDOWN, wc.WM_LBUTTONDBLCLK, wc.WM_LBUTTONUP, wc.WM_MBUTTONDOWN, wc.WM_MBUTTONDBLCLK,
def renderText(self, text, bg, fg, wrap=False, max_x=100, max_y=None): self.drawDC.SetTextColor(Wcolour(fg)) t = self.drawDC.GetSafeHdc() win32gui.SetBkMode(t, win32con.TRANSPARENT) #create the compatible bitmap: #w,h = self.drawDC.GetTextExtent(text) w, h = self.get_metrics(text, max_x, wrap) #print(self.drawDC.GetTextFace()) #w += 1 #if wrap: # h = int((w / max_x) * h) + h # w = max_x + 1 if max_y != None: h = max_y saveBitMap = win32ui.CreateBitmap() saveBitMap.CreateCompatibleBitmap(self.mfcDC, w, h) self.drawDC.SelectObject(saveBitMap) #draw it br = win32ui.CreateBrush(win32con.BS_SOLID, Wcolour(bg), 0) self.drawDC.FillRect((0, 0, w, h), br) #self.drawDC.DrawText(text, (0, 0, w, h), win32con.DT_LEFT) #windll.gdi32.TextOutW(t, 0, 0, "test", 5) if wrap: rect = RECT(0, 0, 0, 0) rect.left = 0 rect.right = round(max_x) rect.top = 0 rect.bottom = round(h) #windll.User32.DrawTextW(t, text, len(text)) #, rect, win32con.DT_WORDBREAK) windll.User32.DrawTextW(t, text, len(text), pointer(rect), win32con.DT_WORDBREAK) else: rect = RECT(0, 0, 0, 0) rect.left = 0 rect.right = round(max_x) rect.top = 0 rect.bottom = round(h) #windll.User32.DrawTextW(t, text, len(text)) #, rect, win32con.DT_WORDBREAK) windll.User32.DrawTextW(t, text, len(text), pointer(rect), win32con.DT_END_ELLIPSIS) #windll.gdi32.TextOutW(t, 0, 0, text, len(text)) # print(rects) #print(text) #windll.gdi32.ExtTextOutW(t, 0, 0, None, rect, text, len(text), None) #convert to SDL surface im, c_bits = native_bmp_to_sdl(self.drawDC.GetSafeHdc(), saveBitMap.GetHandle(), w, h) #clean-up win32gui.DeleteObject(saveBitMap.GetHandle()) return im, c_bits
import win32ui import win32con import win32api import docview import string import packobjects import basic3d def RGB(red, green, blue): return red + (256 * green) + (65536 * blue) CARDCOLOUR = RGB(192, 192, 0) CARDBRUSH = win32ui.CreateBrush(0, CARDCOLOUR, 0) class Controller: "holds the bookset, notifies the views of changes" def __init__(self): #self.BookSet = fastran.BookSet() self.views = [] def loadData(self): #self.BookSet.loadDbl(DATADIR + '\\' + DATAFILE) pass def makeView(self, viewClass): #adds a new one
def _get_win_brush(self): b = self._win_brush_cache if not b: b = ui.CreateBrush(wc.BS_SOLID, self._win_color, 0) self._win_brush_cache = b return b