Class: Rabbit::Frame

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

Direct Known Subclasses

EmbedFrame

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ScreenInfo

default_screen, mm_to_inch, screen_depth, screen_height, screen_height_mm, screen_width, screen_width_mm, screen_x_resolution, screen_y_resolution

Constructor Details

#initialize(logger, canvas) ⇒ Frame

Returns a new instance of Frame.


33
34
35
36
37
38
39
40
# File 'lib/rabbit/frame.rb', line 33

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.


31
32
33
# File 'lib/rabbit/frame.rb', line 31

def geometry
  @geometry
end

#loggerObject (readonly)

Returns the value of attribute logger.


30
31
32
# File 'lib/rabbit/frame.rb', line 30

def logger
  @logger
end

#windowObject (readonly)

Returns the value of attribute window.


30
31
32
# File 'lib/rabbit/frame.rb', line 30

def window
  @window
end

Instance Method Details

#destroyed?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'lib/rabbit/frame.rb', line 42

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

#fullscreenObject


65
66
67
# File 'lib/rabbit/frame.rb', line 65

def fullscreen
  @window.fullscreen
end

#fullscreen?Boolean

Returns:

  • (Boolean)

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

def fullscreen?
  @fullscreen
end

#fullscreen_available?Boolean

Returns:

  • (Boolean)

103
104
105
# File 'lib/rabbit/frame.rb', line 103

def fullscreen_available?
  true
end

#heightObject


57
58
59
# File 'lib/rabbit/frame.rb', line 57

def height
  @window.size[1]
end

#iconify_available?Boolean

Returns:

  • (Boolean)

107
108
109
# File 'lib/rabbit/frame.rb', line 107

def iconify_available?
  true
end

#in_terminal?Boolean

Returns:

  • (Boolean)

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

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


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

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)

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

def main_window?
  @main_window
end

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


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

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

#quitObject


46
47
48
49
50
51
# File 'lib/rabbit/frame.rb', line 46

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

#toggle_fullscreenObject


73
74
75
76
77
78
79
# File 'lib/rabbit/frame.rb', line 73

def toggle_fullscreen
  if fullscreen?
    unfullscreen
  else
    fullscreen
  end
end

#toggle_terminalObject


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

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


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

def unfullscreen
  @window.unfullscreen
end

#update_title(new_title) ⇒ Object


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

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

#widthObject


53
54
55
# File 'lib/rabbit/frame.rb', line 53

def width
  @window.size[0]
end