Exemplo n.º 1
0
    def __init__(self, parent):
        self.panel = wx.Panel(parent)
        super(PreviewWindow, self).__init__(self.panel)
        TooltipBaseMixin.__init__(self)

        # create button panel
        self.toolbarpanel = wx.Panel(self.panel, -1)
        self.buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
        self.toolbarpanel.SetSizer(self.buttonsizer)
        self.recreate_toolbar()
        self.toolbarpanel.Fit()

        # make sizer
        self.global_sizer = wx.BoxSizer(wx.VERTICAL)
        self.global_sizer.Add(self.toolbarpanel, flag=wx.GROW)
        self.global_sizer.Add(self, flag=wx.GROW, proportion=3)
        self.panel.SetSizer(self.global_sizer)

        self.html = self
        self.mod = None
        self.html.SetPage('<font color="#888888"><i>%s</i></font>' % _("Move over a link to see a preview for it"))

        # required to get fonts working
        self.book = biblemgr.bible

        self.colour, self.text_colour = guiconfig.get_window_colours()
Exemplo n.º 2
0
    def on_template_change(self, selection):
        enabled = not self.movable_list.template.readonly

        for item in self.template_panel.fields:
            item.set_text(self.movable_list.template[item.field])

            # make it a disabled field if necessary
            item.SetReadOnly(not enabled)

            # give it the right colour
            if enabled:
                colour, text_colour = guiconfig.get_window_colours()

            else:
                colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
                text_colour = wx.SystemSettings.GetColour(
                    wx.SYS_COLOUR_GRAYTEXT)

            for s in stc.STC_STYLE_DEFAULT, 0:
                item.StyleSetBackground(s, colour)
                item.StyleSetForeground(s, text_colour)

            item.SetCaretForeground(text_colour)

        self.update_preview()
Exemplo n.º 3
0
	def on_template_change(self, selection):
		enabled = not self.movable_list.template.readonly
		
		for item in self.template_panel.fields:
			item.set_text(self.movable_list.template[item.field])

			# make it a disabled field if necessary
			item.SetReadOnly(not enabled)

			# give it the right colour
			if enabled:
				colour, text_colour = guiconfig.get_window_colours()
			
			
			else:
				colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
				text_colour = wx.SystemSettings.GetColour(
								wx.SYS_COLOUR_GRAYTEXT
							)

			for s in stc.STC_STYLE_DEFAULT, 0:
				item.StyleSetBackground(s, colour)
				item.StyleSetForeground(s, text_colour)

			item.SetCaretForeground(text_colour)

		self.update_preview()
Exemplo n.º 4
0
    def __init__(self, parent):
        self.panel = wx.Panel(parent)
        super(PreviewWindow, self).__init__(self.panel)
        TooltipBaseMixin.__init__(self)

        # create button panel
        self.toolbarpanel = wx.Panel(self.panel, -1)
        self.buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
        self.toolbarpanel.SetSizer(self.buttonsizer)
        self.recreate_toolbar()
        self.toolbarpanel.Fit()

        # make sizer
        self.global_sizer = wx.BoxSizer(wx.VERTICAL)
        self.global_sizer.Add(self.toolbarpanel, flag=wx.GROW)
        self.global_sizer.Add(self, flag=wx.GROW, proportion=3)
        self.panel.SetSizer(self.global_sizer)

        self.html = self
        self.mod = None
        self.html.SetPage('<font color="#888888"><i>%s</i></font>' %
                          _("Move over a link to see a preview for it"))

        # required to get fonts working
        self.book = biblemgr.bible

        self.colour, self.text_colour = guiconfig.get_window_colours()
Exemplo n.º 5
0
    def draw(self):
        # create a memory dc
        dc = wx.MemoryDC()
        width, height = 1, 1
        bmp = wx.EmptyBitmap(width, height)
        dc.SelectObject(bmp)

        # set its font to the window font
        dc.SetFont(self.Font)

        # get the size of the text
        text = self.display
        text_width, text_height = dc.GetTextExtent(text)

        # and of the window
        width = text_width + self.border * 2
        height = text_height + self.border * 2

        # create a bitmap of the given size and select it into the DC
        bmp = wx.EmptyBitmap(width, height)
        dc.SelectObject(bmp)

        dc.Background = wx.Brush(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))

        dc.Clear()

        # set up the dc
        dc.Pen = wx.Pen(get_line_colour())

        if self.is_current:
            background, text_colour = guiconfig.get_window_colours(
                html_style=False)
            dc.SetBrush(wx.Brush(background))
            dc.SetTextForeground(text_colour)
            radius = self.border

            # this will be clipped so we will only see the top part
            dc.DrawRoundedRectangle(0, 0, width, height + radius, radius)

        else:
            # draw bottom border
            dc.DrawLine(0, height - 1, width, height - 1)

            dc.SetTextForeground(
                wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT))

        dc.DrawText(text, self.border, self.border)

        # assign the resultant bitmap
        del dc
        self.bmp = bmp

        # and set our size
        self.SetSize((width, height))
Exemplo n.º 6
0
    def __init__(self, parent):
        super(CopyVerseDialog, self).__init__(parent)
        self.tm = TemplateManager(self)
        self.is_custom = False
        self.based_on = ""

        # fill up the list of templates
        self.fill_templates()

        fields = None

        settings = config_manager["BPBible"]["copy_verse"]

        # if we are a tuple, we represent based_on, fields
        # otherwise we are a template name
        copy_formatted = False
        if isinstance(settings, tuple):
            if len(settings) == 2:
                # old style
                based_on, fields = settings
                self.is_custom = True
            else:
                based_on, fields, copy_formatted = settings
                self.is_custom = fields != None

        else:
            # old style
            based_on = settings

        if self.is_custom:
            self.make_custom(based_on)

        else:
            item_id = 0
            for idx, item in enumerate(self.tm.templates):
                if item.name == based_on:
                    item_id = idx
                    break

                # remember default, but keep on looking
                if item.name == "Default":
                    item_id = idx

            self.tm.change_template(item_id)
            self.gui_template_list.SetStringSelection(self.tm.template.name)

            fields = self.tm.template

        # put the template panel in
        self.template_panel = TemplatePanel(self.tp_holder, fields, False)
        self.tp_holder.Sizer.Add(self.template_panel, 1, wx.GROW)
        self.tp_holder.Fit()
        self.tp_holder.Parent.Parent.Label = _("Edit Template...")
        self.Fit()
        self.SetMinSize(self.Size)

        # do binding
        for event in [wx.EVT_KILL_FOCUS, wx.EVT_TEXT_ENTER]:
            self.reference.Bind(event, self.update)

        self.copy_formatted.SetValue(copy_formatted)
        self.copy_formatted.Bind(wx.EVT_CHECKBOX, self.update)

        for item in self.template_panel.fields:
            for event in [wx.EVT_KILL_FOCUS]:  #, stc.EVT_STC_MODIFIED]:
                item.Bind(event, self.update)
            item.Bind(stc.EVT_STC_MODIFIED, self.on_text_changed)

            colour, text_colour = guiconfig.get_window_colours()
            for style in stc.STC_STYLE_DEFAULT, 0:
                item.StyleSetBackground(style, colour)
                item.StyleSetForeground(style, text_colour)

            item.SetCaretForeground(text_colour)

        self.wxID_CANCEL.Bind(wx.EVT_BUTTON, lambda x: self.Destroy())
        self.wxID_OK.Bind(wx.EVT_BUTTON, self.ok_button_clicked)

        self.gui_save_template.Bind(wx.EVT_BUTTON, self.save_template)
        self.gui_load_template.Bind(wx.EVT_BUTTON, self.load_template)
        self.gui_template_list.Bind(wx.EVT_CHOICE, self.on_template_choice)

        self.preview.book = biblemgr.bible
        self.has_preview_been_loaded = False
Exemplo n.º 7
0
	def __init__(self, parent):
		super(CopyVerseDialog, self).__init__(parent)
		self.tm = TemplateManager(self)
		self.is_custom = False
		self.based_on = ""
		
		# fill up the list of templates
		self.fill_templates()
		
		fields = None

		settings = config_manager["BPBible"]["copy_verse"]

		# if we are a tuple, we represent based_on, fields
		# otherwise we are a template name
		copy_formatted = False
		if isinstance(settings, tuple):
			if len(settings) == 2:
				# old style
				based_on, fields = settings
				self.is_custom = True
			else:
				based_on, fields, copy_formatted = settings
				self.is_custom = fields != None

		else:
			# old style
			based_on = settings

		if self.is_custom:
			self.make_custom(based_on)

		else:
			item_id = 0
			for idx, item in enumerate(self.tm.templates):
				if item.name == based_on:
					item_id = idx
					break

				# remember default, but keep on looking
				if item.name == "Default":
					item_id = idx

			self.tm.change_template(item_id)
			self.gui_template_list.SetStringSelection(
				self.tm.template.name
			)
			
			fields = self.tm.template

		# put the template panel in
		self.template_panel = TemplatePanel(self.tp_holder, fields, False)
		self.tp_holder.Sizer.Add(self.template_panel, 1, wx.GROW)
		self.tp_holder.Fit()
		self.tp_holder.Parent.Parent.Label = _("Edit Template...")
		self.Fit()
		self.SetMinSize(self.Size)


		# do binding
		for event in [wx.EVT_KILL_FOCUS, wx.EVT_TEXT_ENTER]:
			self.reference.Bind(event, self.update)

		self.copy_formatted.SetValue(copy_formatted)
		self.copy_formatted.Bind(wx.EVT_CHECKBOX, self.update)

		for item in self.template_panel.fields:
			for event in [wx.EVT_KILL_FOCUS]:#, stc.EVT_STC_MODIFIED]:
				item.Bind(event, self.update)
			item.Bind(stc.EVT_STC_MODIFIED, self.on_text_changed)
			
			colour, text_colour = guiconfig.get_window_colours()
			for style in stc.STC_STYLE_DEFAULT, 0:
				item.StyleSetBackground(style, colour)
				item.StyleSetForeground(style, text_colour)
			
			item.SetCaretForeground(text_colour)

		self.wxID_CANCEL.Bind(wx.EVT_BUTTON, 
					lambda x:self.Destroy())
		self.wxID_OK.Bind(wx.EVT_BUTTON, self.ok_button_clicked)

		self.gui_save_template.Bind(wx.EVT_BUTTON, self.save_template)
		self.gui_load_template.Bind(wx.EVT_BUTTON, self.load_template)
		self.gui_template_list.Bind(wx.EVT_CHOICE, self.on_template_choice)

		self.preview.book = biblemgr.bible
		self.has_preview_been_loaded = False
Exemplo n.º 8
0
	def draw(self):
		# create a memory dc
		dc = wx.MemoryDC()
		width, height = 1, 1
		bmp = wx.EmptyBitmap(width, height)
		dc.SelectObject(bmp)

		# set its font to the window font
		dc.SetFont(self.Font)
		
		# get the size of the text
		text = self.display
		text_width, text_height = dc.GetTextExtent(text)

		# and of the window
		width = text_width + self.border * 2
		height = text_height + self.border * 2
		
		# create a bitmap of the given size and select it into the DC
		bmp = wx.EmptyBitmap(width, height)
		dc.SelectObject(bmp)
		
		dc.Background = wx.Brush(
						wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE)
					)

		dc.Clear()

		# set up the dc
		dc.Pen = wx.Pen(get_line_colour())
		
		if self.is_current:
			background, text_colour = guiconfig.get_window_colours(
										html_style=False
									)
			dc.SetBrush(wx.Brush(background))
			dc.SetTextForeground(text_colour)
			radius = self.border

			# this will be clipped so we will only see the top part
			dc.DrawRoundedRectangle(0, 0, width, height+radius, radius)
			
		else:
			# draw bottom border
			dc.DrawLine(0, height-1, width, height-1)
			
			dc.SetTextForeground(
				wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT)
			)

		dc.DrawText(text, self.border, self.border)
			
			

		
		# assign the resultant bitmap
		del dc
		self.bmp = bmp
		
		# and set our size
		self.SetSize((width, height))