Class: PPCurses::Application
- Inherits:
-
ResponderManager
- Object
- Responder
- ResponderManager
- PPCurses::Application
- Defined in:
- lib/ppcurses/application.rb
Overview
noinspection RubyClassVariableUsageInspection
Instance Attribute Summary collapse
-
#content_view ⇒ Object
Any object of type PPCurses:View.
-
#main_menu ⇒ Object
Returns the value of attribute main_menu.
Attributes inherited from ResponderManager
Attributes inherited from Responder
Class Method Summary collapse
Instance Method Summary collapse
- #create_default_menubar ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #launch ⇒ Object
-
#set_delegate(delegate) ⇒ Object
Informal protocol A delegate receives notifications if and only if a method is defined.
- #terminate ⇒ Object
Methods inherited from ResponderManager
#accepts_first_responder, #make_first_responder
Methods inherited from Responder
#accepts_first_responder, #become_first_responder, isa, #key_down, #resign_first_responder
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
137 138 139 140 141 142 143 144 145 |
# File 'lib/ppcurses/application.rb', line 137 def initialize @screen = PPCurses::Screen.new @main_menu = @next_responder = @main_menu @@shared_app = self @terminated = false end |
Instance Attribute Details
#content_view ⇒ Object
Any object of type PPCurses:View
135 136 137 |
# File 'lib/ppcurses/application.rb', line 135 def content_view @content_view end |
#main_menu ⇒ Object
Returns the value of attribute main_menu.
132 133 134 |
# File 'lib/ppcurses/application.rb', line 132 def @main_menu end |
Class Method Details
.sharedApplication ⇒ Object
226 227 228 |
# File 'lib/ppcurses/application.rb', line 226 def Application.sharedApplication @@shared_app end |
Instance Method Details
#create_default_menubar ⇒ Object
168 169 170 171 172 173 174 175 176 |
# File 'lib/ppcurses/application.rb', line 168 def = PPCurses::MenuBar.new quit_item = PPCurses::MenuBarItem.new('q', 'Quit') quit_item.action = method(:terminate) .(quit_item) end |
#launch ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/ppcurses/application.rb', line 190 def launch @screen.setup_curses if @delegate.respond_to?(:applicationDidFinishLaunching) @delegate.applicationDidFinishLaunching(self) end until @terminated # TODO - switch show to display? @main_menu.show(@screen) unless @main_menu.nil? # TODO -- pass a subview of the screen. @content_view.display(@screen) unless @content_view.nil? c = @screen.get_ch key_down(c) end @screen.shutdown_curses end |
#set_delegate(delegate) ⇒ Object
Informal protocol A delegate receives notifications if and only if a method is defined
applicationDidFinishLaunching applicationShouldTerminate
185 186 187 |
# File 'lib/ppcurses/application.rb', line 185 def set_delegate (delegate) @delegate = delegate end |
#terminate ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/ppcurses/application.rb', line 211 def terminate # Cocoa returns an NSApplicationTerminateReply which can # be a cancel, now or later response. Simply support a boolean # for now. if @delegate.respond_to?(:applicationShouldTerminate) should_terminate = @delegate.applicationShouldTerminate(self) unless should_terminate return end end @terminated = true end |