Class: Okayu::LivePanel
- Inherits:
-
Wx::Panel
- Object
- Wx::Panel
- Okayu::LivePanel
- Defined in:
- lib/views/live_panel.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(parent) ⇒ LivePanel
constructor
A new instance of LivePanel.
- #live_id_from_url(url) ⇒ Object
- #on_key_down(event) ⇒ Object
- #on_live_url_enter(event) ⇒ Object
- #on_new_url ⇒ Object
- #on_update ⇒ Object
- #pause ⇒ Object
- #redraw_list(selected_item_index) ⇒ Object
- #resume ⇒ Object
- #set_index(index) ⇒ Object
Constructor Details
#initialize(parent) ⇒ LivePanel
Returns a new instance of LivePanel.
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/views/live_panel.rb', line 389 def initialize parent super @title = 'live' @ready = false @live_url = Wx::TextCtrl.new(self, :id => Wx::ID_ANY, :style => Wx::TE_PROCESS_ENTER) @list = LiveListCtrl.new(self) sizer = Wx::BoxSizer.new(Wx::VERTICAL) sizer.add(@live_url, 0, Wx::ALL|Wx::EXPAND, 10) sizer.add(@list, 1, Wx::ALL|Wx::EXPAND, 10) set_sizer(sizer) sizer.set_size_hints(self) @live_url.set_focus evt_key_down(){|event| on_key_down(event)} @live_url.evt_text_enter(@live_url.get_id) {|event| on_live_url_enter(event)} end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
388 389 390 |
# File 'lib/views/live_panel.rb', line 388 def title @title end |
Instance Method Details
#close ⇒ Object
474 475 476 477 478 |
# File 'lib/views/live_panel.rb', line 474 def close if @live_controller @live_controller.close end end |
#live_id_from_url(url) ⇒ Object
451 452 453 454 455 456 457 458 459 |
# File 'lib/views/live_panel.rb', line 451 def live_id_from_url url if /^\d+$/ =~ url "lv#{url}" elsif /lv\d+/ =~ url $& else nil end end |
#on_key_down(event) ⇒ Object
461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/views/live_panel.rb', line 461 def on_key_down event case event.get_key_code when 0x16E # Ctrl+PageUp if event.control_down get_parent.advance_selection false end when 0x16F # Ctrl+PageDown if event.control_down get_parent.advance_selection true end end end |
#on_live_url_enter(event) ⇒ Object
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/views/live_panel.rb', line 422 def on_live_url_enter event close if live_id = live_id_from_url(@live_url.get_value) @ready = false @live_controller = LiveController.new(live_id) if @live_controller.valid? @list.base_time = @live_controller.base_time get_parent.set_page_text(@index, live_id) @list.delete_all_items @live_controller.comments.each do |comment| @list.insert_comment(comment) end @list.set_focus @ready = true end end end |
#on_new_url ⇒ Object
417 418 419 420 |
# File 'lib/views/live_panel.rb', line 417 def on_new_url @live_url.set_focus @live_url.set_selection(-1, -1) end |
#on_update ⇒ Object
488 489 490 491 492 493 494 495 |
# File 'lib/views/live_panel.rb', line 488 def on_update if @ready && @live_controller.live_now? comments = @live_controller.new_comments comments.each do |comment| @list.insert_comment(comment) end end end |
#pause ⇒ Object
480 481 482 |
# File 'lib/views/live_panel.rb', line 480 def pause @ready = false end |
#redraw_list(selected_item_index) ⇒ Object
443 444 445 446 447 448 449 |
# File 'lib/views/live_panel.rb', line 443 def redraw_list selected_item_index @list.delete_all_items @live_controller.reload_comments.each do |comment| @list.insert_comment(comment) end @list.get_item(selected_item_index).set_state(Wx::LIST_STATE_SELECTED) end |
#resume ⇒ Object
484 485 486 |
# File 'lib/views/live_panel.rb', line 484 def resume @ready = true end |
#set_index(index) ⇒ Object
413 414 415 |
# File 'lib/views/live_panel.rb', line 413 def set_index index @index = index end |