Class: Rabbit::Frame

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rabbit/frame.rb

Direct Known Subclasses

EmbedFrame

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, canvas) ⇒ Frame

Returns a new instance of Frame.

[View source]

53
54
55
56
57
58
59
60
# File 'lib/rabbit/frame.rb', line 53

def initialize(logger, canvas)
  @logger = logger
  @canvas = canvas
  @geometry = nil
  @notebook = nil
  @terminal = nil
  @running = true
end

Instance Attribute Details

#geometryObject

Returns the value of attribute geometry.


51
52
53
# File 'lib/rabbit/frame.rb', line 51

def geometry
  @geometry
end

#loggerObject (readonly)

Returns the value of attribute logger.


50
51
52
# File 'lib/rabbit/frame.rb', line 50

def logger
  @logger
end

#windowObject (readonly)

Returns the value of attribute window.


50
51
52
# File 'lib/rabbit/frame.rb', line 50

def window
  @window
end

Instance Method Details

#destroyed?Boolean

Returns:

  • (Boolean)
[View source]

62
63
64
# File 'lib/rabbit/frame.rb', line 62

def destroyed?
  @window.nil? or @window.destroyed?
end

#fullscreenObject

[View source]

85
86
87
# File 'lib/rabbit/frame.rb', line 85

def fullscreen
  @window.fullscreen
end

#fullscreen?Boolean

Returns:

  • (Boolean)
[View source]

101
102
103
# File 'lib/rabbit/frame.rb', line 101

def fullscreen?
  @fullscreen
end

#fullscreen_available?Boolean

Returns:

  • (Boolean)
[View source]

123
124
125
# File 'lib/rabbit/frame.rb', line 123

def fullscreen_available?
  true
end

#heightObject

[View source]

77
78
79
# File 'lib/rabbit/frame.rb', line 77

def height
  @window.size[1]
end

#iconify_available?Boolean

Returns:

  • (Boolean)
[View source]

127
128
129
# File 'lib/rabbit/frame.rb', line 127

def iconify_available?
  true
end

#in_terminal?Boolean

Returns:

  • (Boolean)
[View source]

141
142
143
144
# File 'lib/rabbit/frame.rb', line 141

def in_terminal?
  return false if @terminal.nil?
  @notebook.current_page == @notebook.page_num(@terminal)
end

#init_gui(width, height, main_window, window_type = nil) ⇒ Object

[View source]

113
114
115
116
117
118
119
120
121
# File 'lib/rabbit/frame.rb', line 113

def init_gui(width, height, main_window, window_type=nil)
  init_window(width, height, window_type)
  @fullscreen = false
  @main_window = main_window
  @terminal.show if @terminal
  @notebook.show if @notebook
  @window.show
  @canvas.post_init_gui
end

#main_window?Boolean

Returns:

  • (Boolean)
[View source]

105
106
107
# File 'lib/rabbit/frame.rb', line 105

def main_window?
  @main_window
end

#parse(source, callback = nil, &block) ⇒ Object

[View source]

81
82
83
# File 'lib/rabbit/frame.rb', line 81

def parse(source, callback=nil, &block)
  @canvas.parse(source, callback, &block)
end

#quitObject

[View source]

66
67
68
69
70
71
# File 'lib/rabbit/frame.rb', line 66

def quit
  @running = false
  @window.destroy unless destroyed?
  @window = nil
  true
end

#toggle_fullscreenObject

[View source]

93
94
95
96
97
98
99
# File 'lib/rabbit/frame.rb', line 93

def toggle_fullscreen
  if fullscreen?
    unfullscreen
  else
    fullscreen
  end
end

#toggle_terminalObject

[View source]

131
132
133
134
135
136
137
138
139
# File 'lib/rabbit/frame.rb', line 131

def toggle_terminal
  return if @terminal.nil?
  terminal_page = @notebook.page_num(@terminal)
  if @notebook.current_page == terminal_page
    @notebook.current_page = 0
  else
    @notebook.current_page = terminal_page
  end
end

#unfullscreenObject

[View source]

89
90
91
# File 'lib/rabbit/frame.rb', line 89

def unfullscreen
  @window.unfullscreen
end

#update_title(new_title) ⇒ Object

[View source]

109
110
111
# File 'lib/rabbit/frame.rb', line 109

def update_title(new_title)
  @window.title = Utils.unescape_title(new_title)
end

#widthObject

[View source]

73
74
75
# File 'lib/rabbit/frame.rb', line 73

def width
  @window.size[0]
end