def set_fillcolor(self, c): state = self._state state.fillcolor = c if self.fillcolor.image: tb = gdip.TextureBrush(self.fillcolor.image) state.win_fill_brush = tb else: state.win_fill_brush = gdip.SolidBrush(c._win_argb)
def OnPaint(self): if not self._win_paint_broken: try: win = self._win dc, ps = win.BeginPaint() try: win_update_rect = ps[2] if not empty_rect(win_update_rect): #print "DrawableContainer.OnPaint: win_update_rect =", win_update_rect ### scroll_offset = self._win_scroll_offset() view_update_rect = offset_rect(win_update_rect, scroll_offset) if self._double_buffer: dx, dy = rect_topleft(view_update_rect) width, height = rect_size(view_update_rect) buffer = gdi.Bitmap(width, height) canvas = Canvas._from_win_image(buffer) canvas.translate(-dx, -dy) self.draw(canvas, view_update_rect) graphics = gdi.Graphics.from_dc(dc) src_rect = (0, 0, width, height) graphics.DrawImage_rr(buffer, win_update_rect, src_rect) else: self._win_prepare_dc(dc) canvas = Canvas._from_win_dc(dc) self.draw(canvas, view_update_rect) finally: win.EndPaint(ps) except Exception: self._win_paint_broken = True raise
def _win_update_metrics(self): dc = win_none.GetDC() dc.SelectObject(self._win_font) met = dc.GetTextMetrics() self._ascent = met['tmAscent'] self._descent = met['tmDescent'] self._internal_leading = met['tmInternalLeading'] self._leading = met['tmExternalLeading'] self._win_overhang = met['tmOverhang'] #print "Font: tmOverhang =", self._win_overhang ### logfont = gui.LOGFONT() logfont.lfHeight = win_height_sign * int(round(self._size)) logfont.lfWidth = wc.FW_BOLD if 'bold' in self._style else wc.FW_NORMAL logfont.lfEscapement = 0 logfont.lfOrientation = 0 logfont.lfWeight = 0 logfont.lfItalic = 1 if 'italic' in self._style else 0 logfont.lfUnderline = 1 if 'underline' in self._style else 0 logfont.lfStrikeOut = 1 if 'strikeout' in self._style else 0 logfont.lfCharSet = wc.DEFAULT_CHARSET logfont.lfOutPrecision = 0 logfont.lfClipPrecision = 0 logfont.lfQuality = wc.CLEARTYPE_QUALITY logfont.lfPitchAndFamily = 0 logfont.lfFaceName = self._win_family self._win_gdip_font = gdip.Font(self._win_family, self._size, self._style) #self._win_gdip_font = gdip.Font.from_logfont(dc.GetSafeHdc(), logfont) #self._win_gdip_font = gdip.Font.from_hdc(dc.GetSafeHdc()) win_none.ReleaseDC(dc)
class GState(object): pencolor = black fillcolor = black textcolor = black backcolor = white pensize = 1 font = application_font win_pen = gdip.Pen(pencolor._win_argb, 1) win_fill_brush = gdip.SolidBrush(fillcolor._win_argb) win_text_brush = gdip.SolidBrush(textcolor._win_argb) win_bg_brush = gdip.SolidBrush(backcolor._win_argb) def __init__(self, clone = None): if clone: self.__dict__.update(clone.__dict__)
def __init__(self, win_graphics, for_printing = False): self._win_graphics = win_graphics self._win_path = gdip.GraphicsPath() self._state = GState() self._stack = [] if for_printing: unit = gdip.UnitPoint win_graphics.SetPageUnit(unit)
def _win_update_metrics(self): dc = win_none.GetDC() dc.SelectObject(self._win_font) met = dc.GetTextMetrics() self._ascent = met['tmAscent'] self._descent = met['tmDescent'] self._internal_leading = met['tmInternalLeading'] self._leading = met['tmExternalLeading'] self._win_overhang = met['tmOverhang'] #print "Font: tmOverhang =", self._win_overhang ### win_none.ReleaseDC(dc) self._win_gdip_font = gdip.Font(self._win_family, self._size, self._style)
def __init__(self, width, height, config=None, share_group=None, **kwds): print("GLPixmap:", width, height, kwds) ### config = GLConfig._from_args(config, kwds) image = gdi.Bitmap(width, height) self._win_image = image graphics = gdi.Graphics.from_image(image) self._win_graphics = graphics hdc = graphics.GetHDC() self._win_hdc = hdc GLContext.__init__(self, share_group, config, hdc, 'pixmap') self._with_context(hdc, self._init_context) print("GLPixmap: done") ###
def __init__(self, win_graphics, for_printing = False): self._win_graphics = win_graphics self._win_path = gdip.GraphicsPath() self._state = GState() self._stack = [] #Setup DC for Text Output ## dc = ui.CreateDCFromHandle(win_graphics.GetHDC()) ## dc.SetBkMode(wc.TRANSPARENT) ## dc.SetTextAlign(wc.TA_LEFT | wc.TA_BASELINE | wc.TA_UPDATECP) ## self._win_dc = dc ## self._win_hdc = dc.GetSafeHdc()#HandleOutput() if for_printing: unit = gdip.UnitPoint win_graphics.SetPageUnit(unit)
def set_pensize(self, x): state = self._state state.pensize = x state.win_pen = gdip.Pen(state.pencolor._win_argb, x)
def set_backcolor(self, c): state = self._state state.backcolor = c state.win_bg_brush = gdip.SolidBrush(c._win_argb)
def set_textcolor(self, c): state = self._state state.textcolor = c state.win_text_brush = gdip.SolidBrush(c._win_argb)
def set_fillcolor(self, c): state = self._state state.fillcolor = c state.win_fill_brush = gdip.SolidBrush(c._win_argb)
def set_pencolor(self, c): state = self._state state.pencolor = c state.win_pen = gdip.Pen(c._win_argb, state.pensize)