Sha256: fc31cda51030929bd1dbf31ae791b40a81176fc0de25bcdbd4395d0f6f091509

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

# encoding: utf-8
require 'jldrill/views/gtk/widgets/KanjiPopup'
require 'gtk2'

module JLDrill::Gtk
    class MotionEvent
        attr_reader :widget, :motion

        def initialize(aWidget, aMotion)
            @widget = aWidget
            @motion = aMotion
        end
    end

    class PopupFactory
        def initialize(view)
            @view = view
            @context = @view.context
            @currentPopup = nil
            @blocked = false
            @lastEvent = nil
        end

        def block
            @blocked = true
        end

        def unblock
            @blocked = false
        end

        def closePopup
            if !@currentPopup.nil?
                @currentPopup.close
                @currentPopup = nil
            end
        end

        # Finds the string that should be displayed in the Popup
        # Please override this in the concrete class
        def getPopupString(searchString)
            return ""
        end
        
        def createPopup(searchString, x, y)
            closePopup
            @currentPopup = KanjiPopup.new(searchString, 
                                      getPopupString(searchString), 
                                      @view.mainWindow, x, y)
        end
        
        def belowRect(rect)
            x = rect[0]
            y = rect[1] + (rect[3])
            [x, y]
        end
        
        # Translates the x,y coordinates of the widget in this
        # window to absolute screen coordinates
        def toAbsPos(widget, x, y)
            origin = @view.mainWindow.window.position
            pos = [x + origin[0], y + origin[1]]
            widget.translate_coordinates(@view.mainWindow, pos[0], pos[1])
        end
        
        def showBusy(bool)
            if !@currentPopup.nil?
                @currentPopup.showBusy(bool)
            end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.6.0.1 lib/jldrill/views/gtk/widgets/PopupFactory.rb