Class: JLDrill::Gtk::ProblemView

Inherits:
DisplayProblemContext::ProblemView show all
Defined in:
lib/jldrill/views/gtk/ProblemView.rb

Instance Attribute Summary collapse

Attributes inherited from DisplayProblemContext::ProblemView

#itemHints

Attributes inherited from Context::View

#context

Instance Method Summary collapse

Methods inherited from DisplayProblemContext::ProblemView

#removingViewFrom, #viewAddedTo

Methods inherited from Context::View

#addView, #removeView, #removingViewFrom, #viewAddedTo

Constructor Details

#initialize(context) ⇒ ProblemView

Returns a new instance of ProblemView.



12
13
14
15
16
17
18
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 12

def initialize(context)
	super(context)
	@problemDisplay = ProblemDisplay.new(self)
	@problemDisplay.expandWidgetWidth
	@problemDisplay.expandWidgetHeight
          @timeoutID = nil
end

Instance Attribute Details

#problemDisplayObject (readonly)

Returns the value of attribute problemDisplay.



10
11
12
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 10

def problemDisplay
  @problemDisplay
end

Instance Method Details

#expireObject



59
60
61
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 59

def expire
    @problemDisplay.expire
end

#getWidgetObject



20
21
22
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 20

def getWidget
	@problemDisplay
end

#mainWindowObject



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

def mainWindow
    getWidget.gtkWidgetMainWindow
end

#newProblem(problem) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 45

def newProblem(problem)
          super(problem)
    @problemDisplay.newProblem(problem)
          stopTimer
          if !problem.nil?
              startTimer(problem.item.itemStats.timeLimit)
          end
end

#showAnswerObject



54
55
56
57
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 54

def showAnswer
    @problemDisplay.showAnswer
          stopTimer
end

#showBusy(bool) ⇒ Object



72
73
74
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 72

def showBusy(bool)
    @problemDisplay.showBusy(bool)
end

#startTimer(timeLimit) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 35

def startTimer(timeLimit)
    if timeLimit != 0.0 && @timeoutID.nil?
        @timeoutID = Gtk.timeout_add((timeLimit * 1000).to_i) do
            @timeoutID = nil
            expire
            false
        end
    end
end

#stopTimerObject



28
29
30
31
32
33
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 28

def stopTimer
    if !@timeoutID.nil?
        Gtk.timeout_remove(@timeoutID)
        @timeoutID = nil
    end
end

#updateProblem(problem) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/jldrill/views/gtk/ProblemView.rb', line 63

def updateProblem(problem)
    super(problem)
    @problemDisplay.updateProblem(problem)
    stopTimer
    if !problem.nil?
        startTimer(problem.item.itemStats.timeLimit)
    end
end