Ejemplo n.º 1
0
    def on_button_choose_font(self,
                              event):  # wxGlade: TextProperty.<event_handler>
        font_data = wx.FontData()
        try:
            font_data.SetInitialFont(self.node.wxfont)
            font_data.SetColour(wx.Colour(swizzlecolor(self.node.fill)))
            dialog = wx.FontDialog(None, font_data)
        except AttributeError:
            dialog = wx.FontDialog(None, font_data)
        if dialog.ShowModal() == wx.ID_OK:
            data = dialog.GetFontData()
            font = data.GetChosenFont()
            try:
                color = data.GetColour()
                rgb = color.GetRGB()
                color = swizzlecolor(rgb)
                color = Color(color, 1.0)
                self.node.fill = color
                # Translate wxFont to SVG font....
                self.node.wxfont = font
                wxfont_to_svg(self.node)
                self.node.modified()
            except AttributeError:  # rgb get failed.
                pass

            self.update_label()
            self.refresh()
        dialog.Destroy()
        event.Skip()
Ejemplo n.º 2
0
 def on_button_underline(self, event):
     button = event.EventObject
     state = button.GetValue()
     self.node.wxfont.SetUnderlined(state)
     wxfont_to_svg(self.node)
     self.update_label()
     self.refresh()
     event.Skip()
Ejemplo n.º 3
0
 def on_button_strikethrough(self, event):
     button = event.EventObject
     state = button.GetValue()
     self.node.wxfont.SetStrikethrough(state)
     wxfont_to_svg(self.node)
     self.update_label()
     self.refresh()
     event.Skip()
Ejemplo n.º 4
0
 def on_font_choice(self, event):
     lastfont = self.node.wxfont.GetFaceName()
     fface = self.combo_font.GetValue()
     self.node.wxfont.SetFaceName(fface)
     if not self.node.wxfont.IsOk():
         self.node.wxfont.SetFaceName(lastfont)
     wxfont_to_svg(self.node)
     self.update_label()
     self.refresh()
     event.Skip()
Ejemplo n.º 5
0
 def on_button_italic(self, event):
     button = event.EventObject
     state = button.GetValue()
     if state:
         self.node.wxfont.SetStyle(wx.FONTSTYLE_ITALIC)
     else:
         self.node.wxfont.SetStyle(wx.FONTSTYLE_NORMAL)
     wxfont_to_svg(self.node)
     self.update_label()
     self.refresh()
     event.Skip()
Ejemplo n.º 6
0
    def on_button_larger(self, event):
        try:
            size = self.node.wxfont.GetFractionalPointSize()
        except AttributeError:
            size = self.node.wxfont.GetPointSize()
        size *= 1.2

        try:
            self.node.wxfont.SetFractionalPointSize(size)
        except AttributeError:
            self.node.wxfont.SetPointSize(int(size))

        wxfont_to_svg(self.node)
        self.update_label()
        self.refresh()
        event.Skip()
Ejemplo n.º 7
0
 def on_button_bold(self, event):
     button = event.EventObject
     state = button.GetValue()
     if state:
         try:
             self.node.wxfont.SetNumericWeight(700)
         except AttributeError:
             self.node.wxfont.SetWeight(wx.FONTWEIGHT_BOLD)
     else:
         try:
             self.node.wxfont.SetNumericWeight(400)
         except AttributeError:
             self.node.wxfont.SetWeight(wx.FONTWEIGHT_NORMAL)
     wxfont_to_svg(self.node)
     self.update_label()
     self.refresh()
     event.Skip()
Ejemplo n.º 8
0
 def event(
     self, window_pos=None, space_pos=None, event_type=None, nearest_snap=None
 ):
     response = RESPONSE_CHAIN
     if event_type == "leftdown":
         self.p1 = complex(space_pos[0], space_pos[1])
         _ = self.scene.context._
         self.text = SVGText("")
         if nearest_snap is None:
             x = space_pos[0]
             y = space_pos[1]
         else:
             x = nearest_snap[0]
             y = nearest_snap[1]
         self.x = x
         self.y = y
         self.text *= "translate({x}, {y}) scale({scale})".format(
             x=x, y=y, scale=UNITS_PER_PIXEL
         )
         dlg = TextEntry(self.scene.context, "", None, wx.ID_ANY, "")
         if dlg.ShowModal() == wx.ID_OK:
             self.text.text = dlg.result_text
             if dlg.result_anchor == 1:
                 self.text.anchor = "middle"
             elif dlg.result_anchor == 2:
                 self.text.anchor = "end"
             else:
                 self.text.anchor = "start"
             elements = self.scene.context.elements
             node = elements.elem_branch.add(text=self.text, type="elem text")
             color = dlg.result_colour
             rgb = color.GetRGB()
             color = swizzlecolor(rgb)
             color = Color(color, 1.0)
             node.fill = color
             # Translate wxFont to SVG font....
             node.wxfont = dlg.result_font
             dlg.store_font_history()
             wxfont_to_svg(node)
             if elements.classify_new:
                 elements.classify([node])
             self.notify_created(node)
         dlg.Destroy()
         response = RESPONSE_CONSUME
     return response