Exemple #1
0
	def draw (self, context):
		self.recalc_edges ()
		ResizableThought.draw(self, context)
		if self.creating:
			return

		(textx, texty) = (self.min_x, self.min_y)
		if self.am_primary:
			r, g, b = utils.primary_colors["text"]
		elif (self.foreground_color):
			r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
		else:
			r, g ,b = utils.gtk_to_cairo_color(utils.default_colors["text"])
		context.set_source_rgb (r, g, b)
		self.layout.set_alignment(pango.ALIGN_CENTER)
		context.move_to (textx, texty)
		context.show_layout (self.layout)
		if self.editing:
			if self.preedit:
				(strong, weak) = self.layout.get_cursor_pos (self.index + self.preedit[2])
			else:
				(strong, weak) = self.layout.get_cursor_pos (self.index)
			(startx, starty, curx,cury) = strong
			startx /= pango.SCALE
			starty /= pango.SCALE
			curx /= pango.SCALE
			cury /= pango.SCALE
			context.move_to (textx + startx, texty + starty)
			context.line_to (textx + startx, texty + starty + cury)
			context.stroke ()
		context.set_source_rgb (0,0,0)
		context.stroke ()
    def draw(self, context):
        self.recalc_edges()
        ResizableThought.draw(self, context)
        if self.creating:
            return

        (textx, texty) = (self.min_x, self.min_y)
        if self.am_primary:
            r, g, b = utils.primary_colors["text"]
        elif (self.foreground_color):
            r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
        else:
            r, g, b = utils.gtk_to_cairo_color(utils.default_colors["text"])
        context.set_source_rgb(r, g, b)
        self.layout.set_alignment(pango.ALIGN_CENTER)
        context.move_to(textx, texty)
        context.show_layout(self.layout)
        if self.editing:
            if self.preedit:
                (strong, weak) = self.layout.get_cursor_pos(self.index +
                                                            self.preedit[2])
            else:
                (strong, weak) = self.layout.get_cursor_pos(self.index)
            (startx, starty, curx, cury) = strong
            startx /= pango.SCALE
            starty /= pango.SCALE
            curx /= pango.SCALE
            cury /= pango.SCALE
            context.move_to(textx + startx, texty + starty)
            context.line_to(textx + startx, texty + starty + cury)
            context.stroke()
        context.set_source_rgb(0, 0, 0)
        context.stroke()
    def draw (self, context):
        if not self.layout:
            self.recalc_edges ()
        if not self.editing:
            # We should draw the entire bounding box around ourselves
            # We should also have our coordinates figured out.      If not, scream!
            if not self.ul or not self.lr:
                print "Warning: Trying to draw unfinished box "+str(self.identity)+". Aborting."
                return
            style = utils.STYLE_EXTENDED_CONTENT
            if len (self.extended_buffer.get_text()) == 0:
                style = utils.STYLE_NORMAL
            utils.draw_thought_outline (context, self.ul, self.lr, self.background_color, self.am_selected, self.am_primary, style)
        else:
            ux, uy = self.ul
            if prefs.get_direction() == gtk.TEXT_DIR_LTR:
                context.move_to (ux, uy+5)
                context.line_to (ux, uy)
                context.line_to (ux+5, uy)
            else:
                lx = self.lr[0]
                context.move_to (lx, uy+5)
                context.line_to (lx, uy)
                context.line_to (lx-5, uy)
            context.stroke ()

        textx, texty = (self.text_location[0], self.text_location[1])
        if (self.foreground_color):
            r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
        else:
            r, g ,b = utils.gtk_to_cairo_color(utils.default_colors["text"])
        context.set_source_rgb (r, g, b)
        context.move_to (textx, texty)
        context.show_layout (self.layout)
        if self.editing:
            if self.preedit:
                strong, weak = self.layout.get_cursor_pos (self.index + self.preedit[2])
            else:
                strong, weak = self.layout.get_cursor_pos (self.index)
            (startx, starty, curx,cury) = strong
            startx /= pango.SCALE
            starty /= pango.SCALE
            curx /= pango.SCALE
            cury /= pango.SCALE
            context.move_to (textx + startx, texty + starty)
            context.line_to (textx + startx, texty + starty + cury)
            context.stroke ()
        context.set_source_rgb (0,0,0)
        context.stroke ()
    def draw(self, context):
        if len(self.extended_buffer.get_text()) == 0:
            utils.draw_thought_outline(
                context, self.ul, self.lr, self.background_color, self.am_selected, self.am_primary, utils.STYLE_NORMAL
            )
        else:
            utils.draw_thought_outline(
                context,
                self.ul,
                self.lr,
                self.background_color,
                self.am_selected,
                self.am_primary,
                utils.STYLE_EXTENDED_CONTENT,
            )
        cwidth = context.get_line_width()
        context.set_line_width(2)
        if len(self.points) > 0:
            for p in self.points:
                if p.style == STYLE_BEGIN:
                    context.move_to(p.x, p.y)
                    r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
                    context.set_source_rgb(r, g, b)
                elif p.style == STYLE_END:
                    context.line_to(p.x, p.y)
                    context.stroke()
                else:
                    context.line_to(p.x, p.y)

        context.set_line_width(cwidth)
        context.stroke()
        return
    def export(self, context, move_x, move_y):
        utils.export_thought_outline(
            context,
            self.ul,
            self.lr,
            self.background_color,
            self.am_selected,
            self.am_primary,
            utils.STYLE_NORMAL,
            (move_x, move_y),
        )
        cwidth = context.get_line_width()
        context.set_line_width(1)
        if len(self.points) > 0:
            for p in self.points:
                if p.style == STYLE_BEGIN:
                    context.move_to(p.x + move_x, p.y + move_y)
                else:
                    context.line_to(p.x + move_x, p.y + move_y)

        context.set_line_width(cwidth)
        r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
        context.set_source_rgb(r, g, b)
        context.stroke()
        return
Exemple #6
0
    def draw(self, context):
        if len(self.extended_buffer.get_text()) == 0:
            utils.draw_thought_outline(context, self.ul, self.lr,
                                       self.background_color, self.am_selected,
                                       self.am_primary, utils.STYLE_NORMAL)
        else:
            utils.draw_thought_outline(context, self.ul, self.lr,
                                       self.background_color, self.am_selected,
                                       self.am_primary,
                                       utils.STYLE_EXTENDED_CONTENT)
        cwidth = context.get_line_width()
        context.set_line_width(2)
        if len(self.points) > 0:
            for p in self.points:
                if p.style == STYLE_BEGIN:
                    context.move_to(p.x, p.y)
                    r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
                    context.set_source_rgb(r, g, b)
                elif p.style == STYLE_END:
                    context.line_to(p.x, p.y)
                    context.stroke()
                else:
                    context.line_to(p.x, p.y)

        context.set_line_width(cwidth)
        context.stroke()
        return
Exemple #7
0
    def __init__(self,
                 save,
                 parent=None,
                 child=None,
                 start_coords=None,
                 end_coords=None,
                 strength=2):
        super(Link, self).__init__()
        self.parent = parent
        self.child = child
        self.end = end_coords
        self.start = start_coords
        self.strength = strength
        self.element = save.createElement("link")
        self.selected = False
        self.color = utils.gtk_to_cairo_color(Gdk.color_parse('black'))
        self.model_iter = None
        self.text = None

        if not self.start and parent and parent.lr:
            self.start = (parent.ul[0]-((parent.ul[0]-parent.lr[0]) / 2.), \
                          parent.ul[1]-((parent.ul[1]-parent.lr[1]) / 2.))

        if parent and child:
            self.find_ends()
Exemple #8
0
	def export (self, context, move_x, move_y):
		utils.export_thought_outline (context, self.ul, self.lr, self.background_color, self.am_selected, self.am_primary, utils.STYLE_NORMAL,
									  (move_x, move_y))

		r,g,b = utils.gtk_to_cairo_color (self.foreground_color)
		context.set_source_rgb (r, g, b)
		context.move_to (self.min_x+move_x, self.min_y+move_y)
		context.show_layout (self.layout)
		context.set_source_rgb (0,0,0)
		context.stroke ()
Exemple #9
0
    def draw(self, context):
        if not self.layout:
            self.recalc_edges()
        if not self.editing:
            # We should draw the entire bounding box around ourselves
            # We should also have our coordinates figured out.      If not, scream!
            if not self.ul or not self.lr:
                print "Warning: Trying to draw unfinished box " + str(
                    self.identity) + ". Aborting."
                return
            style = utils.STYLE_EXTENDED_CONTENT
            if len(self.extended_buffer.get_text()) == 0:
                style = utils.STYLE_NORMAL
            utils.draw_thought_outline(context, self.ul, self.lr,
                                       self.background_color, self.am_selected,
                                       self.am_primary, style)
        else:
            ux, uy = self.ul
            if prefs.get_direction() == gtk.TEXT_DIR_LTR:
                context.move_to(ux, uy + 5)
                context.line_to(ux, uy)
                context.line_to(ux + 5, uy)
            else:
                lx = self.lr[0]
                context.move_to(lx, uy + 5)
                context.line_to(lx, uy)
                context.line_to(lx - 5, uy)
            context.stroke()

        textx, texty = (self.text_location[0], self.text_location[1])
        if (self.foreground_color):
            r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
        else:
            r, g, b = utils.default_colors["text"]
        context.set_source_rgb(r, g, b)
        context.move_to(textx, texty)
        context.show_layout(self.layout)
        if self.editing:
            if self.preedit:
                strong, weak = self.layout.get_cursor_pos(self.index +
                                                          self.preedit[2])
            else:
                strong, weak = self.layout.get_cursor_pos(self.index)
            (startx, starty, curx, cury) = strong
            startx /= pango.SCALE
            starty /= pango.SCALE
            curx /= pango.SCALE
            cury /= pango.SCALE
            context.move_to(textx + startx, texty + starty)
            context.line_to(textx + startx, texty + starty + cury)
            context.stroke()
        context.set_source_rgb(0, 0, 0)
        context.stroke()
    def export(self, context, move_x, move_y):
        utils.export_thought_outline(context, self.ul, self.lr,
                                     self.background_color, self.am_selected,
                                     self.am_primary, utils.STYLE_NORMAL,
                                     (move_x, move_y))

        r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
        context.set_source_rgb(r, g, b)
        context.move_to(self.min_x + move_x, self.min_y + move_y)
        ##context.show_layout (self.layout)
        context.set_source_rgb(0, 0, 0)
        context.stroke()
Exemple #11
0
	def export (self, context, move_x, move_y):
		utils.export_thought_outline (context, self.ul, self.lr, self.background_color, self.am_selected, self.am_primary, utils.STYLE_NORMAL,
									  (move_x, move_y))
		cwidth = context.get_line_width ()
		context.set_line_width (1)
		if len (self.points) > 0:
			for p in self.points:
				if p.style == STYLE_BEGIN:
					context.move_to (p.x+move_x, p.y+move_y)
				else:
					context.line_to (p.x+move_x,p.y+move_y)

		context.set_line_width (cwidth)
		r,g,b = utils.gtk_to_cairo_color(self.foreground_color)
		context.set_source_rgb (r, g, b)
		context.stroke ()
		return
Exemple #12
0
    def __init__ (self, save, parent = None, child = None, start_coords = None, end_coords = None, strength = 2):
        super (Link, self).__init__()
        self.parent = parent
        self.child = child
        self.end = end_coords
        self.start = start_coords
        self.strength = strength
        self.element = save.createElement ("link")
        self.selected = False
        self.color = utils.gtk_to_cairo_color(gtk.gdk.color_parse("black"))

        if not self.start and parent and parent.lr:
            self.start = (parent.ul[0]-((parent.ul[0]-parent.lr[0]) / 2.), \
                                      parent.ul[1]-((parent.ul[1]-parent.lr[1]) / 2.))

        if parent and child:
            self.find_ends ()
Exemple #13
0
    def draw(self, context):
        if not self.layout:
            self.recalc_edges()
        if not self.editing:
            if not self.ul or not self.lr:
                print "Warning: Trying to draw unfinished box " + str(
                    self.identity) + ". Aborting."
                return
            utils.draw_thought_extended (context, self.ul, self.lr, \
                    self.am_selected, self.am_primary, self.background_color, False, True)
        else:
            ux, uy = self.ul
            if prefs.get_direction() == gtk.TEXT_DIR_LTR:
                context.move_to(ux, uy + 5)
                context.line_to(ux, uy)
                context.line_to(ux + 5, uy)
            else:
                lx = self.lr[0]
                context.move_to(lx, uy + 5)
                context.line_to(lx, uy)
                context.line_to(lx - 5, uy)
            context.stroke()

        (textx, texty) = (self.text_location[0], self.text_location[1])
        r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
        context.set_source_rgb(r, g, b)
        context.move_to(textx, texty)
        context.show_layout(self.layout)
        if self.editing:
            if self.preedit:
                (strong, weak) = self.layout.get_cursor_pos(self.index +
                                                            self.preedit[2])
            else:
                (strong, weak) = self.layout.get_cursor_pos(self.index)
            (startx, starty, curx, cury) = strong
            startx /= pango.SCALE
            starty /= pango.SCALE
            curx /= pango.SCALE
            cury /= pango.SCALE
            context.move_to(textx + startx, texty + starty)
            context.line_to(textx + startx, texty + starty + cury)
            context.stroke()
        context.set_source_rgb(0, 0, 0)
        context.stroke()
Exemple #14
0
	def draw (self, context):
		if not self.layout:
			self.recalc_edges ()
		if not self.editing:
			if not self.ul or not self.lr:
				print "Warning: Trying to draw unfinished box "+str(self.identity)+". Aborting."
				return
			utils.draw_thought_extended (context, self.ul, self.lr, \
				self.am_selected, self.am_primary, self.background_color, False, True)
		else:
			ux, uy = self.ul
			if prefs.get_direction() == gtk.TEXT_DIR_LTR:
				context.move_to (ux, uy+5)
				context.line_to (ux, uy)
				context.line_to (ux+5, uy)
			else:
				lx = self.lr[0]
				context.move_to (lx, uy+5)
				context.line_to (lx, uy)
				context.line_to (lx-5, uy)
			context.stroke ()

		(textx, texty) = (self.text_location[0], self.text_location[1])
		r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
		context.set_source_rgb (r, g, b)
		context.move_to (textx, texty)
		context.show_layout (self.layout)
		if self.editing:
			if self.preedit:
				(strong, weak) = self.layout.get_cursor_pos (self.index + self.preedit[2])
			else:
				(strong, weak) = self.layout.get_cursor_pos (self.index)
			(startx, starty, curx,cury) = strong
			startx /= pango.SCALE
			starty /= pango.SCALE
			curx /= pango.SCALE
			cury /= pango.SCALE
			context.move_to (textx + startx, texty + starty)
			context.line_to (textx + startx, texty + starty + cury)
			context.stroke ()
		context.set_source_rgb (0,0,0)
		context.stroke ()
Exemple #15
0
	def draw (self, context):
		ResizableThought.draw(self, context)

		cwidth = context.get_line_width ()
		context.set_line_width (2)
		context.set_line_join(cairo.LINE_JOIN_BEVEL)
		context.set_line_cap(cairo.LINE_CAP_ROUND)
		if len (self.points) > 0:
			for p in self.points:
				if p.style == STYLE_BEGIN:
					context.move_to (p.x, p.y)
					r,g,b = utils.gtk_to_cairo_color(self.foreground_color)
					context.set_source_rgb (r, g, b)
				elif p.style == STYLE_END:
					context.line_to (p.x, p.y)
					context.stroke()
				else:
					context.line_to (p.x, p.y)

		context.set_line_width (cwidth)
		context.stroke ()
		return
Exemple #16
0
	def draw (self, context):
		ResizableThought.draw(self, context)

		cwidth = context.get_line_width ()
		context.set_line_width (2)
		context.set_line_join(cairo.LINE_JOIN_BEVEL)
		context.set_line_cap(cairo.LINE_CAP_ROUND)
		if len (self.points) > 0:
			for p in self.points:
				if p.style == STYLE_BEGIN:
					context.move_to (p.x, p.y)
					r,g,b = utils.gtk_to_cairo_color(self.foreground_color)
					context.set_source_rgb (r, g, b)
				elif p.style == STYLE_END:
					context.line_to (p.x, p.y)
					context.stroke()
				else:
					context.line_to (p.x, p.y)

		context.set_line_width (cwidth)
		context.stroke ()
		return
Exemple #17
0
	def __init__(self, undo):
		super (MMapArea, self).__init__()

		self.thoughts = []
		self.links = []
		self.selected = []
		self.num_selected = 0
		self.primary = None
		self.pango_context = self.create_pango_context()
		self.undo = undo
		self.scale_fac = 1.0
		self.translate = False
		self.translation = [0.0,0.0]
		self.timeout = -1
		self.current_cursor = None
		self.do_filter = True
		self.is_bbox_selecting = False

		self.nthoughts = 0

		impl = dom.getDOMImplementation()
		self.save = impl.createDocument("http://www.donscorgie.blueyonder.co.uk/labns", "MMap", None)
		self.element = self.save.documentElement
		self.im_context = gtk.IMMulticontext ()

		self.mode = MODE_NULL
		self.old_mode = MODE_NULL

		self.connect ("expose_event", self.expose)
		self.connect ("button_release_event", self.button_release)
		self.connect ("button_press_event", self.button_down)
		self.connect ("motion_notify_event", self.motion)
		self.connect ("key_press_event", self.key_press)
		self.connect ("key_release_event", self.key_release)
		self.connect ("scroll_event", self.scroll)
		self.commit_handler = None
		self.title_change_handler = None
		self.drag_mode = False
		self._dragging = False
		self.sw = None
		self.hadj = 0
		self.vadj = 0
		self.origin_x = None
		self.origin_y = None
		self.moving = False
		self.move_mode = False
		self.move_origin = None
		self.move_origin_new = None
		self.focus = None
		self.move_action = None
		self.current_root = []
		self.rotation = 0
		self.text_attributes = {}

		self.set_events (gtk.gdk.KEY_PRESS_MASK |
						 gtk.gdk.KEY_RELEASE_MASK |
						 gtk.gdk.BUTTON_PRESS_MASK |
						 gtk.gdk.BUTTON_RELEASE_MASK |
						 gtk.gdk.POINTER_MOTION_MASK |
						 gtk.gdk.SCROLL_MASK
						)

		self.set_flags (gtk.CAN_FOCUS)
		
		# set theme colors
		w = gtk.Window()
		w.realize()
		style = w.get_style()
		self.pango_context.set_font_description(style.font_desc)

		# FIXME: rude hack to remove fontsize from font name
		parts = style.font_desc.to_string().split()
		try:
			float(parts[-1])
			self.font_name = string.join(parts[0:-2])
		except ValueError:
			self.font_name = style.font_desc.to_string()

		utils.default_font = self.font_name
		self.font_size = utils.default_font_size
		utils.default_colors["text"] = utils.gtk_to_cairo_color(style.text[gtk.STATE_NORMAL])
		utils.default_colors["base"] = utils.gtk_to_cairo_color(style.base[gtk.STATE_NORMAL])
		# Match the fixed white canvas colour (makes thought focus visible)
		self.background_color = style.white
		self.foreground_color = style.black
		utils.default_colors["bg"] = utils.gtk_to_cairo_color(style.bg[gtk.STATE_NORMAL])
		utils.default_colors["fg"] = utils.gtk_to_cairo_color(style.fg[gtk.STATE_NORMAL])
		
		utils.selected_colors["text"] = utils.gtk_to_cairo_color(style.text[gtk.STATE_SELECTED])
		utils.selected_colors["bg"] = utils.gtk_to_cairo_color(style.bg[gtk.STATE_SELECTED])
		utils.selected_colors["fg"] = utils.gtk_to_cairo_color(style.fg[gtk.STATE_SELECTED])
		utils.selected_colors["fill"] = utils.gtk_to_cairo_color(style.base[gtk.STATE_SELECTED])
Exemple #18
0
	def __init__(self, undo):
		super (MMapArea, self).__init__()

		self.thoughts = []
		self.links = []
		self.selected = []
		self.num_selected = 0
		self.primary = None
		self.pango_context = self.create_pango_context()
		self.undo = undo
		self.scale_fac = 1.0
		self.translate = False
		self.translation = [0.0,0.0]
		self.timeout = -1
		self.current_cursor = None
		self.do_filter = True
		self.is_bbox_selecting = False

		self.nthoughts = 0

		impl = dom.getDOMImplementation()
		self.save = impl.createDocument("http://www.donscorgie.blueyonder.co.uk/labns", "MMap", None)
		self.element = self.save.documentElement
		self.im_context = gtk.IMMulticontext ()

		self.mode = MODE_NULL
		self.old_mode = MODE_NULL

		self.connect ("expose_event", self.expose)
		self.connect ("button_release_event", self.button_release)
		self.connect ("button_press_event", self.button_down)
		self.connect ("motion_notify_event", self.motion)
		self.connect ("key_press_event", self.key_press)
		self.connect ("key_release_event", self.key_release)
		self.connect ("scroll_event", self.scroll)
		self.commit_handler = None
		self.title_change_handler = None
		self.moving = False
		self.move_origin = None
		self.move_origin_new = None
		self.focus = None
		self.move_action = None
		self.current_root = []
		self.rotation = 0

		self.set_events (gtk.gdk.KEY_PRESS_MASK |
						 gtk.gdk.KEY_RELEASE_MASK |
						 gtk.gdk.BUTTON_PRESS_MASK |
						 gtk.gdk.BUTTON_RELEASE_MASK |
						 gtk.gdk.POINTER_MOTION_MASK |
						 gtk.gdk.SCROLL_MASK
						)

		self.set_flags (gtk.CAN_FOCUS)
		
		# set theme colors
		w = gtk.Window()
		w.realize()
		style = w.get_style()
		self.pango_context.set_font_description(style.font_desc)
		self.font_name = style.font_desc.to_string()
		utils.default_font = self.font_name
		
		utils.default_colors["text"] = utils.gtk_to_cairo_color(style.text[gtk.STATE_NORMAL])
		utils.default_colors["base"] = utils.gtk_to_cairo_color(style.base[gtk.STATE_NORMAL])
		# Match the fixed white canvas colour (makes thought focus visible)
		self.background_color = style.white
		self.foreground_color = style.text[gtk.STATE_NORMAL]
		utils.default_colors["bg"] = utils.gtk_to_cairo_color(style.bg[gtk.STATE_NORMAL])
		utils.default_colors["fg"] = utils.gtk_to_cairo_color(style.fg[gtk.STATE_NORMAL])
		
		utils.selected_colors["text"] = utils.gtk_to_cairo_color(style.text[gtk.STATE_SELECTED])
		utils.selected_colors["bg"] = utils.gtk_to_cairo_color(style.bg[gtk.STATE_SELECTED])
		utils.selected_colors["fg"] = utils.gtk_to_cairo_color(style.fg[gtk.STATE_SELECTED])
		utils.selected_colors["fill"] = utils.gtk_to_cairo_color(style.base[gtk.STATE_SELECTED])
Exemple #19
0
	def _create_textview(self):
		# When the button is pressed inside a text thought,
		# create a textview (necessary for invoking the
		# on-screen keyboard) instead of processing the text
		# by grabbing keyboard events.
		if self.textview is None:
			self.textview = gtk.TextView()
			margin = utils.margin_required (utils.STYLE_NORMAL)
			x, y, w, h = self.textview_rescale()
			self.textview.set_size_request(w, h)
			self._fixed.put(self.textview, x, y)
		self.textview.set_justification(gtk.JUSTIFY_CENTER)

		font, size = None, None
		bold, italic, underline = False, False, False
		# Get current attributes and set them here
		it = self.attributes.get_iterator()
		while (1):
			r = it.range()
			for x in it.get_attrs():
				if x.type == pango.ATTR_WEIGHT and x.value == pango.WEIGHT_BOLD:
					bold = True
				elif x.type == pango.ATTR_STYLE and x.value == pango.STYLE_ITALIC:
					italic = True
				elif x.type == pango.ATTR_UNDERLINE and x.value == pango.UNDERLINE_SINGLE:
					underline = True
				elif x.type == pango.ATTR_FONT_DESC:
					parts = x.desc.to_string ().split()
					font = string.join(parts[0:-2])
					size = parts[-1]

			if not it.next():
				break

		if font is None:
			font = 'Sans'
		if size is None:
			size = utils.default_font_size
                font_desc = pango.FontDescription(font)
                font_desc.set_size(
                    int(int(size) * pango.SCALE * self._parent.scale_fac))
		if bold:
			font_desc.set_weight(pango.WEIGHT_BOLD)
		if italic:
			font_desc.set_style(pango.STYLE_ITALIC)
		self.textview.modify_font(font_desc)

		r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
		rgba = gtk.gdk.Color(
			int(65535 * r), int(65535 * g), int(65535 * b))
		self.textview.modify_text(gtk.STATE_NORMAL, rgba)

		self.textview.get_buffer().set_text(self.text)
                self.textview.show()
		if self._textview_handler is None:
			self._textview_handler = self.textview.connect(
				'focus-out-event', self._textview_focus_out_cb)
			self.copy_handler = self.textview.connect(
				'copy-clipboard', self._textview_copy_cb)
			self.cut_handler = self.textview.connect(
				'cut-clipboard', self._textview_cut_cb)
			self.paste_handler = self.textview.connect(
				'paste-clipboard', self._textview_paste_cb)
			self.select_handler = self.textview.connect(
				'select-all', self._textview_select_cb)
		self.textview.grab_focus()
		self._fixed.show()
    def _create_textview(self):
        # When the button is pressed inside a text thought,
        # create a textview (necessary for invoking the
        # on-screen keyboard) instead of processing the text
        # by grabbing keyboard events.
        if self.textview is None:
            self.textview = Gtk.TextView()
            margin = utils.margin_required(utils.STYLE_NORMAL)
            x, y, w, h = self.textview_rescale()
            self.textview.set_size_request(w if w > 0 else 1,
                                           h if h > 0 else 1)
            self._fixed.put(self.textview, x, y)
        self.textview.set_justification(Gtk.Justification.CENTER)

        font, size = None, None
        bold, italic, underline = False, False, False
        # Get current attributes and set them here
        """
        while (1):
            r = it.range()
            for x in it.get_attrs():
                if x.type == Pango.Weight and x.value == Pango.Weight.BOLD:
                    bold = True
                elif x.type == Pango.Style and x.value == Pango.Style.ITALIC:
                    italic = True
                elif x.type == Pango.Underline and x.value == Pango.Underline.SINGLE:
                    underline = True
                elif x.type == Pango.ATTR_FONT_DESC:
                    parts = x.desc.to_string ().split()
                    font = string.join(parts[0:-2])
                    size = parts[-1]

            if not it.next():
                break

        if font is None:
            font = 'Sans'
        if size is None:
            size = utils.default_font_size
            font_desc = Pango.FontDescription(font)
            font_desc.set_size(
                int(int(size) * Pango.SCALE * self._parent.scale_fac))

        if bold:
            font_desc.set_weight(Pango.Weight.BOLD)
        if italic:
            font_desc.set_style(Pango.Style.ITALIC)
        self.textview.modify_font(font_desc)
        """

        r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
        rgba = Gdk.Color(int(65535 * r), int(65535 * g), int(65535 * b))
        self.textview.modify_text(Gtk.StateType.NORMAL, rgba)

        self.textview.get_buffer().set_text(self.text)
        self.textview.show()

        if self._textview_handler is None:
            self._textview_handler = self.textview.connect(
                'focus-out-event', self._textview_focus_out_cb)
            self.copy_handler = self.textview.connect('copy-clipboard',
                                                      self._textview_copy_cb)
            self.cut_handler = self.textview.connect('cut-clipboard',
                                                     self._textview_cut_cb)
            self.paste_handler = self.textview.connect('paste-clipboard',
                                                       self._textview_paste_cb)
            self.select_handler = self.textview.connect(
                'select-all', self._textview_select_cb)
        self.textview.grab_focus()
        self._fixed.show()
Exemple #21
0
    def color_selection_ok_cb(self, dialog, response_id):
        if response_id == Gtk.ResponseType.OK:
            self.color = utils.gtk_to_cairo_color(
                self.color_sel.get_current_color())

        dialog.destroy()
Exemple #22
0
 def color_selection_ok_cb(self, dialog, response_id):
     if response_id == gtk.RESPONSE_OK:
         self.color = utils.gtk_to_cairo_color(self.color_sel.get_current_color())
     dialog.destroy()