Пример #1
0
	def on_leave(self, event=None):
		if event: event.Skip()
		if event and osutils.is_gtk():
			# Under GTK, we can get the notification of leave before the
			# enter! This used to cause really annoying header bar tooltips 
			# to pop up after moving diagonally across it quickly.
			wx.CallAfter(self.on_leave)
			return
	
		self.Parent.current_target = None
	
		self.Parent.tooltip.MouseOut(None)
Пример #2
0
    def on_leave(self, event=None):
        if event: event.Skip()
        if event and osutils.is_gtk():
            # Under GTK, we can get the notification of leave before the
            # enter! This used to cause really annoying header bar tooltips
            # to pop up after moving diagonally across it quickly.
            wx.CallAfter(self.on_leave)
            return

        self.Parent.current_target = None

        self.Parent.tooltip.MouseOut(None)
Пример #3
0
	def draw_combo(self, dc, window, rect, text, pane, clipping_rect=None):
		assert pane.IsShown(), "Trying to draw hidden combo!"
		active = bool(pane.state & pane.optionActive)
		
		self.setup_font(dc, active)
		
		
		cc = self.GetColour([
			aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR,
			aui.AUI_DOCKART_ACTIVE_CAPTION_COLOUR,			
		][active])
		
		dc.SetBrush(wx.Brush(wxAuiStepColour(cc, 120)))
		dc.SetPen(wx.Pen(wxAuiStepColour(cc, 
			70 + (pane.name not in mouse_over) * 25))
		)
		
		w, h = dc.GetTextExtent(text)
	
		dc.DrawRectangleRect(rect)
		
		dc.DrawText(text, rect[0] + self.text_padding, 
			rect.y+(rect.height/2)-(h/2))
		
		
		h = rect.height
		drop_arrow_rect = (
			rect[0] + w + self.text_padding,
			rect.y+(rect.height/2)-(h/2), 15, 15
		)

		# clipping doesn't seem to be done here. So draw all or nothing
		if clipping_rect and clipping_rect.ContainsRect(drop_arrow_rect):
			# bug under gtk:
			# window content doesn't fill maximized window when resizing if we
			# set the foreground colour for the mainframe. So change the
			# colour of our hidden text buffer instead and use it			
			if osutils.is_gtk():
				window = guiconfig.mainfrm.buffer

			fg_old = window.ForegroundColour

			window.SetForegroundColour(dc.GetTextForeground())
		
			wx.RendererNative.Get().DrawDropArrow(
				window, dc, drop_arrow_rect, 0
			)
			
			window.SetForegroundColour(fg_old)
Пример #4
0
    def draw_combo(self, dc, window, rect, text, pane, clipping_rect=None):
        assert pane.IsShown(), "Trying to draw hidden combo!"
        active = bool(pane.state & pane.optionActive)

        self.setup_font(dc, active)

        cc = self.GetColour([
            aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR,
            aui.AUI_DOCKART_ACTIVE_CAPTION_COLOUR,
        ][active])

        dc.SetBrush(wx.Brush(wxAuiStepColour(cc, 120)))
        dc.SetPen(
            wx.Pen(wxAuiStepColour(cc,
                                   70 + (pane.name not in mouse_over) * 25)))

        w, h = dc.GetTextExtent(text)

        dc.DrawRectangleRect(rect)

        dc.DrawText(text, rect[0] + self.text_padding,
                    rect.y + (rect.height / 2) - (h / 2))

        h = rect.height
        drop_arrow_rect = (rect[0] + w + self.text_padding,
                           rect.y + (rect.height / 2) - (h / 2), 15, 15)

        # clipping doesn't seem to be done here. So draw all or nothing
        if clipping_rect and clipping_rect.ContainsRect(drop_arrow_rect):
            # bug under gtk:
            # window content doesn't fill maximized window when resizing if we
            # set the foreground colour for the mainframe. So change the
            # colour of our hidden text buffer instead and use it
            if osutils.is_gtk():
                window = guiconfig.mainfrm.buffer

            fg_old = window.ForegroundColour

            window.SetForegroundColour(dc.GetTextForeground())

            wx.RendererNative.Get().DrawDropArrow(window, dc, drop_arrow_rect,
                                                  0)

            window.SetForegroundColour(fg_old)
Пример #5
0
def find_xulrunner_path():
    if osutils.is_mac():
        path = os.getcwd() + "/../MacOS/"
        if os.path.exists(path):
            return path
        else:
            return os.getcwd() + "/dist/BPBible.app/Contents/MacOS/"

    if osutils.is_gtk():
        xulrunner_path = (osutils.find_file_in_path("xulrunner")
                          or osutils.find_file_in_path("xulrunner-stub"))
        if xulrunner_path:
            return os.path.dirname(os.path.realpath(xulrunner_path))

    path = os.path.join(os.getcwd(), "xulrunner")
    if not os.path.isdir(path):
        # XXX: Perhaps we should make this error handling a little more friendly?
        sys.stderr.write("Unable to find XULRunner.\n")
        sys.exit(1)
    return path
Пример #6
0
def find_xulrunner_path():
	if osutils.is_mac():
		path = os.getcwd() + "/../MacOS/"
		if os.path.exists(path):
			return path
		else:
			return os.getcwd() + "/dist/BPBible.app/Contents/MacOS/"

	if osutils.is_gtk():
		xulrunner_path = (osutils.find_file_in_path("xulrunner") or
			osutils.find_file_in_path("xulrunner-stub"))
		if xulrunner_path:
			return os.path.dirname(os.path.realpath(xulrunner_path))

	path = os.path.join(os.getcwd(), "xulrunner")
	if not os.path.isdir(path):
		# XXX: Perhaps we should make this error handling a little more friendly?
		sys.stderr.write("Unable to find XULRunner.\n")
		sys.exit(1)
	return path
Пример #7
0
	def rebuild_tree(self, item=None):
		self.Unbind(wx.EVT_TREE_SEL_CHANGED)
	
		if osutils.is_gtk():
			freeze = None
		else:
			freeze = FreezeUI(self)
		self.DeleteAllItems()
		self.build_tree()
		root = self.GetRootItem()
		id, cookie = self.GetFirstChild(root)
		while id:
			self.ExpandAllChildren(id)
			id, cookie = self.GetNextChild(root, cookie)

		# Stop freezing the UI so that we can scroll to the current item.
		del freeze
		if self.current_tree_item:
			self.ScrollTo(self.current_tree_item)
		
		self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_tree_selected)
Пример #8
0
    def rebuild_tree(self, item=None):
        self.Unbind(wx.EVT_TREE_SEL_CHANGED)

        if osutils.is_gtk():
            freeze = None
        else:
            freeze = FreezeUI(self)
        self.DeleteAllItems()
        self.build_tree()
        root = self.GetRootItem()
        id, cookie = self.GetFirstChild(root)
        while id:
            self.ExpandAllChildren(id)
            id, cookie = self.GetNextChild(root, cookie)

        # Stop freezing the UI so that we can scroll to the current item.
        del freeze
        if self.current_tree_item:
            self.ScrollTo(self.current_tree_item)

        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_tree_selected)
Пример #9
0
    def Initialize(self):
        # for py2exe
        import mainframe

        was_restarted = self.restarting
        self.starting = self.restarting = False
        config_manager.load()
        util.i18n.initialize()
        gui.i18n.initialize()

        frame = self.res.LoadFrame(None, "MainFrame")
        if (frame == None):
            wx.MessageBox("Could not load MainFrame from auifrm.xrc", \
             "Fatal Error", style = wx.ICON_ERROR)
            return False

        frame.SetIcons(guiconfig.icons)

        self.SetTopWindow(frame)
        frame.Show(osutils.is_gtk())
        if was_restarted:
            frame.Raise()
Пример #10
0
	def Initialize(self):
		# for py2exe
		import mainframe
		
		was_restarted = self.restarting
		self.starting = self.restarting = False
		config_manager.load()
		util.i18n.initialize()
		gui.i18n.initialize()
		
		frame = self.res.LoadFrame(None,  "MainFrame" )
		if(frame == None):
			wx.MessageBox("Could not load MainFrame from auifrm.xrc", \
				"Fatal Error", style = wx.ICON_ERROR)
			return False


		frame.SetIcons(guiconfig.icons)

		self.SetTopWindow(frame)
		frame.Show(osutils.is_gtk())
		if was_restarted:
			frame.Raise()
Пример #11
0
        if not prevItem.IsOk() or prevItem == item:
            # there are no visible items before item
            return wx.TreeItemId()

    # from there we must be able to navigate until this item
    while (prevItem.IsOk()):
        nextItem = self.GetNextVisible(prevItem)
        if not nextItem.IsOk() or nextItem == item:
            break

        prevItem = nextItem

    return prevItem


if osutils.is_gtk() or osutils.is_mac():
    wx.TreeCtrl.GetPrevVisible = GetPrevVisible


class TreeItem(object):
    def __init__(self, text, data=None, filterable=True):
        self._children = []
        self._text = text
        self.data = data
        self.filterable = filterable

    @property
    def text(self):
        return self._text

    @property
Пример #12
0
	def __init__(self, parent, size=wx.DefaultSize, title="", style=0):
		super(QuickSelector, self).__init__(parent, size=size, 
			style=style
                         | wx.FRAME_SHAPED
                         | wx.NO_BORDER
                         | wx.FRAME_NO_TASKBAR
		)
		
		if not self.SetTransparent(opacity * 255):
			dprint(WARNING, "Transparency not supported")
			set_theme("white")

		self.SetBackgroundColour(back_colour)
		self.SetForegroundColour(text_colour)
		
		
		self.p = wx.Panel(self)
		self.p.SetBackgroundColour(back_colour)
		self.p.SetForegroundColour(text_colour)
		text = wx.StaticText(self.p, label=title, #pos=(0, radius + 10), 
			style=wx.ALIGN_CENTRE)

		text.SetBackgroundColour(back_colour)
		text.SetForegroundColour(text_colour)

		hrule = Line(self.p)
		hrule.SetSize((-1, 1))
		self.panel = TextPanel(self.p)
		self.panel.SetBackgroundColour(back_colour)
		self.panel.SetForegroundColour(text_colour)
		
		sizer = wx.BoxSizer(wx.VERTICAL)
		

		sizer.Add(text, 0, wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
		sizer.Add(hrule, 0, wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
		sizer.Add(self.panel, 1, wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT, 20)
		self.p.Sizer = sizer

		s1 = wx.BoxSizer(wx.HORIZONTAL)
		s1.Add(self.p, 1, wx.GROW|wx.ALL, 1)
		
		self.panel.ForegroundColour = text_colour
		f = text.Font
		f.SetWeight(wx.FONTWEIGHT_BOLD)
		f.SetPointSize(12)
		text.Font = f
		self.SetSizerAndFit(s1)
#		self.Size = self.p.BestSize
		if osutils.is_mac():
			# on mac it seems to make our textbox to small so descending
			# letters are chopped off
			self.SetSize((350, self.BestSize[1]+7))
		else:
			self.SetSize((350, self.BestSize[1]))

#		self.SetSize(self.p.BestSize)

		if osutils.is_gtk():
			self.Bind(wx.EVT_WINDOW_CREATE, lambda evt:self.set_shape())
		else:
			self.set_shape()
		if not parent:
			self.CentreOnScreen()
		else:
			self.CentreOnParent()
Пример #13
0
	def on_enter(self, event):
		# unbind the kill focus, or we will have cancelled it
		self.Unbind(wx.EVT_KILL_FOCUS)
		self.TopLevelParent.EndModal(wx.OK)

	def add_letter(self, event):
		if event.KeyCode == wx.WXK_ESCAPE:
			self.Unbind(wx.EVT_KILL_FOCUS)
			self.TopLevelParent.EndModal(wx.CANCEL)
		elif event.KeyCode == wx.WXK_RETURN:
			self.on_enter(event)
		else:
			event.Skip()
		
if osutils.is_gtk():
	# under wxGTK, the miniframe has a border around it which we don't want
	quick_selector_class = wx.Frame
else:
	quick_selector_class = wx.MiniFrame

class QuickSelector(quick_selector_class):
	def __init__(self, parent, size=wx.DefaultSize, title="", style=0):
		super(QuickSelector, self).__init__(parent, size=size, 
			style=style
                         | wx.FRAME_SHAPED
                         | wx.NO_BORDER
                         | wx.FRAME_NO_TASKBAR
		)
		
		if not self.SetTransparent(opacity * 255):