Exemplo n.º 1
0
    def _zoom_labels(self, zoom):
        """Adjust grid label font to zoom factor"""

        labelfont = self.grid.GetLabelFont()
        default_fontsize = get_default_font().GetPointSize()
        labelfont.SetPointSize(max(1, int(round(default_fontsize * zoom))))
        self.grid.SetLabelFont(labelfont)
Exemplo n.º 2
0
    def OnDrawItem(self, dc, rect, item, flags):

        if item == wx.NOT_FOUND:
            return

        default_font_size = get_default_font().GetPointSize()

        context = wx.lib.wxcairo.ContextFromDC(dc)

        context.rectangle(*rect)
        context.clip()

        pangocairo_context = pangocairo.CairoContext(context)
        pangocairo_context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)

        layout = pangocairo_context.create_layout()
        fontname = self.GetString(item)
        font = pango.FontDescription("{} {}".format(fontname,
                                                    default_font_size))
        layout.set_font_description(font)

        layout.set_text(fontname)

        color = tuple(
            [c / 255.0 for c in get_color(config["text_color"]).Get()])
        context.set_source_rgb(*color)

        height = layout.get_pixel_extents()[1][3]

        y_adjust = int((rect.height - height) / 2.0)
        context.translate(rect.x + 3, rect.y + y_adjust)

        pangocairo_context.update_layout(layout)
        pangocairo_context.show_layout(layout)
Exemplo n.º 3
0
    def _zoom_labels(self, zoom):
        """Adjust grid label font to zoom factor"""

        labelfont = self.grid.GetLabelFont()
        default_fontsize = get_default_font().GetPointSize()
        labelfont.SetPointSize(max(1, int(round(default_fontsize * zoom))))
        self.grid.SetLabelFont(labelfont)
Exemplo n.º 4
0
    def OnDrawItem(self, dc, rect, item, flags):

        if item == wx.NOT_FOUND:
            return

        default_font_size = get_default_font().GetPointSize()

        context = wx.lib.wxcairo.ContextFromDC(dc)

        context.rectangle(*rect)
        context.clip()

        pangocairo_context = pangocairo.CairoContext(context)
        pangocairo_context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)

        layout = pangocairo_context.create_layout()
        fontname = self.GetString(item)
        font = pango.FontDescription("{} {}".format(fontname,
                                                    default_font_size))
        layout.set_font_description(font)

        layout.set_text(fontname)
        context.set_source_rgb(0, 0, 0)

        height = layout.get_pixel_extents()[1][3]

        y_adjust = int((rect.height - height) / 2.0)
        context.translate(rect.x + 3, rect.y + y_adjust)

        pangocairo_context.update_layout(layout)
        pangocairo_context.show_layout(layout)
Exemplo n.º 5
0
def get_font_from_data(fontdata):
    """Returns wx.Font from fontdata string"""

    textfont = get_default_font()

    if fontdata != "":
        nativefontinfo = wx.NativeFontInfo()
        nativefontinfo.FromString(fontdata)

        # OS X does not like a PointSize of 0
        # Therefore, it is explicitly set to the system default font point size

        if not nativefontinfo.GetPointSize():
            nativefontinfo.SetPointSize(get_default_font().GetPointSize())

        textfont.SetNativeFontInfo(nativefontinfo)

    return textfont
Exemplo n.º 6
0
def get_font_from_data(fontdata):
    """Returns wx.Font from fontdata string"""

    textfont = get_default_font()

    if fontdata != "":
        nativefontinfo = wx.NativeFontInfo()
        nativefontinfo.FromString(fontdata)

        # OS X does not like a PointSize of 0
        # Therefore, it is explicitly set to the system default font point size

        if not nativefontinfo.GetPointSize():
            nativefontinfo.SetPointSize(get_default_font().GetPointSize())

        textfont.SetNativeFontInfo(nativefontinfo)

    return textfont
Exemplo n.º 7
0
    def OnTextSize(self, event):
        """Text size combo text event handler"""

        try:
            size = int(event.GetString())

        except Exception:
            size = get_default_font().GetPointSize()

        post_command_event(self, self.FontSizeMsg, size=size)
Exemplo n.º 8
0
    def OnTextSize(self, event):
        """Text size combo text event handler"""

        try:
            size = int(event.GetString())

        except Exception:
            size = get_default_font().GetPointSize()

        post_command_event(self, self.FontSizeMsg, size=size)
Exemplo n.º 9
0
def get_font_from_data(fontdata):
    """Returns wx.Font from fontdata string"""

    textfont = get_default_font()

    if fontdata != "":
        nativefontinfo = wx.NativeFontInfo()
        nativefontinfo.FromString(fontdata)
        textfont.SetNativeFontInfo(nativefontinfo)

    return textfont
Exemplo n.º 10
0
    def _create_font_size_combo(self):
        """Creates font size combo box"""

        self.std_font_sizes = config["font_default_sizes"]
        font_size = str(get_default_font().GetPointSize())
        self.font_size_combo = wx.ComboBox(self, -1, value=font_size,
            size=(60, -1), choices=map(unicode, self.std_font_sizes),
            style=wx.CB_DROPDOWN | wx.TE_PROCESS_ENTER)
        self.AddControl(self.font_size_combo)
        self.Bind(wx.EVT_COMBOBOX, self.OnTextSize, self.font_size_combo)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnTextSize, self.font_size_combo)
Exemplo n.º 11
0
    def _create_font_size_combo(self):
        """Creates font size combo box"""

        self.std_font_sizes = config["font_default_sizes"]
        font_size = str(get_default_font().GetPointSize())
        self.font_size_combo = \
            wx.ComboBox(self, -1, value=font_size, size=(60, -1),
                        choices=map(unicode, self.std_font_sizes),
                        style=wx.CB_DROPDOWN | wx.TE_PROCESS_ENTER)

        self.font_size_combo.SetToolTipString(_(u"Text size\n(points)"))

        self.AddControl(self.font_size_combo)
        self.Bind(wx.EVT_COMBOBOX, self.OnTextSize, self.font_size_combo)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnTextSize, self.font_size_combo)
Exemplo n.º 12
0
    def test_get_font(self, pointsize, fontweight, fontstyle, easyxf):
        """Test _get_font method"""

        pys_style = {
            'textfont': get_default_font().GetFaceName(),
            'pointsize': pointsize,
            'fontweight': fontweight,
            'fontstyle': fontstyle,
        }
        font = self.xls_in._get_font(pys_style)

        style = xlwt.easyxf(easyxf)

        assert font.bold == style.font.bold
        assert font.italic == style.font.italic
        assert font.height == style.font.height
Exemplo n.º 13
0
    def test_get_font(self, pointsize, fontweight, fontstyle, easyxf):
        """Test _get_font method"""

        pys_style = {
            'textfont': get_default_font().GetFaceName(),
            'pointsize': pointsize,
            'fontweight': fontweight,
            'fontstyle': fontstyle,
        }
        font = self.xls_in._get_font(pys_style)

        style = xlwt.easyxf(easyxf)

        assert font.bold == style.font.bold
        assert font.italic == style.font.italic
        assert font.height == style.font.height
Exemplo n.º 14
0
    def OnDrawItem(self, dc, rect, item, flags):

        if item == wx.NOT_FOUND:
            return

        __rect = wx.Rect(*rect)  # make a copy
        __rect.Deflate(3, 5)

        font_string = self.GetString(item)

        font = get_default_font()
        font.SetFaceName(font_string)
        font.SetFamily(wx.FONTFAMILY_SWISS)
        dc.SetFont(font)

        text_width, text_height = dc.GetTextExtent(font_string)
        text_x = __rect.x
        text_y = __rect.y + int((__rect.height - text_height) / 2.0)

        # Draw the example text in the combobox
        dc.DrawText(font_string, text_x, text_y)
Exemplo n.º 15
0
    def OnDrawItem(self, dc, rect, item, flags):

        if item == wx.NOT_FOUND:
            return

        __rect = wx.Rect(*rect)  # make a copy
        __rect.Deflate(3, 5)

        font_string = self.GetString(item)

        font = get_default_font()
        font.SetFaceName(font_string)
        font.SetFamily(wx.FONTFAMILY_SWISS)
        dc.SetFont(font)

        text_width, text_height = dc.GetTextExtent(font_string)
        text_x = __rect.x
        text_y = __rect.y + int((__rect.height - text_height) / 2.0)

        # Draw the example text in the combobox
        dc.DrawText(font_string, text_x, text_y)