Class: JLDrill::Gtk::PopupFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/jldrill/views/gtk/widgets/PopupFactory.rb

Direct Known Subclasses

KanjiPopupFactory, VocabPopupFactory

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ PopupFactory

Returns a new instance of PopupFactory.



16
17
18
19
20
21
22
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 16

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

Instance Method Details

#belowRect(rect) ⇒ Object



52
53
54
55
56
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 52

def belowRect(rect)
    x = rect[0]
    y = rect[1] + (rect[3])
    [x, y]
end

#blockObject



24
25
26
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 24

def block
    @blocked = true
end

#closePopupObject



32
33
34
35
36
37
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 32

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

#createPopup(searchString, x, y) ⇒ Object



45
46
47
48
49
50
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 45

def createPopup(searchString, x, y)
    closePopup
    @currentPopup = KanjiPopup.new(searchString, 
                              getPopupString(searchString), 
                              @view.mainWindow, x, y)
end

#getPopupString(searchString) ⇒ Object

Finds the string that should be displayed in the Popup Please override this in the concrete class



41
42
43
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 41

def getPopupString(searchString)
    return ""
end

#showBusy(bool) ⇒ Object



66
67
68
69
70
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 66

def showBusy(bool)
    if !@currentPopup.nil?
        @currentPopup.showBusy(bool)
    end
end

#toAbsPos(widget, x, y) ⇒ Object

Translates the x,y coordinates of the widget in this window to absolute screen coordinates



60
61
62
63
64
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 60

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

#unblockObject



28
29
30
# File 'lib/jldrill/views/gtk/widgets/PopupFactory.rb', line 28

def unblock
    @blocked = false
end