Class: Okayu::MainPanel

Inherits:
Wx::Panel
  • Object
show all
Defined in:
lib/views/main_panel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frame, x, y, w, h) ⇒ MainPanel

Returns a new instance of MainPanel.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/views/main_panel.rb', line 4

def initialize(frame, x, y, w, h)
  super(frame, -1, Wx::Point.new(x, y), Wx::Size.new(w, h))
  @notebook = Wx::Notebook.new self,
                               :id =>ID_NOTEBOOK,
                               :pos => Wx::Point.new(x, y),
                               :size => Wx::Size.new(w, h)
  # panel = LivePanel.new(@notebook)
  # @notebook.add_page(panel, panel.title, TRUE)
  create_tab

  @timer = Wx::Timer.new(self, Wx::ID_ANY)
  @timer.start 100
  evt_timer(@timer.get_id) {|event| on_update}

  evt_size{|event| on_size(event)}
end

Instance Attribute Details

#timerObject (readonly)

Returns the value of attribute timer.



3
4
5
# File 'lib/views/main_panel.rb', line 3

def timer
  @timer
end

Instance Method Details

#close_tabObject



40
41
42
43
# File 'lib/views/main_panel.rb', line 40

def close_tab
  @notebook.get_current_page.close
  @notebook.delete_page(@notebook.get_selection)
end

#create_tabObject



34
35
36
37
38
# File 'lib/views/main_panel.rb', line 34

def create_tab
  panel = LivePanel.new(@notebook)
  @notebook.add_page(panel, panel.title, TRUE)
  @notebook.get_current_page.set_index(@notebook.get_selection)
end

#get_current_pageObject



45
46
47
# File 'lib/views/main_panel.rb', line 45

def get_current_page
  @notebook.get_current_page
end

#on_size(event) ⇒ Object



27
28
29
30
31
32
# File 'lib/views/main_panel.rb', line 27

def on_size event
  if @notebook
    size = get_client_size
    @notebook.set_dimensions(2, 2, (size.get_width - 4), (size.get_height - 4))
  end
end

#on_updateObject



21
22
23
24
25
# File 'lib/views/main_panel.rb', line 21

def on_update
  @notebook.each_page do |page|
    page.on_update
  end
end