Class: Reactive::View::Wx::Helpers::ModelMainFrame

Inherits:
Wx::Frame
  • Object
show all
Defined in:
lib/helpers/model_main_frame_class.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ModelMainFrame

Returns a new instance of ModelMainFrame.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/helpers/model_main_frame_class.rb', line 19

def initialize(*args)
  super
  
  @manager = Wx::AuiManager.new
  @manager.set_managed_window(self)
  
  create_status_bar
  status_bar.set_status_text("Ready")
  set_min_size( Wx::Size.new(400,300) )
  
  pi = Wx::AuiPaneInfo.new
  pi.set_name('notebook').center_pane
  @manager.add_pane(create_notebook, pi)
  
  @manager.update
        
  evt_erase_background { | e | on_erase_background(e) }
  evt_size{ | e | on_size(e) }
  
  evt_auinotebook_page_changed(Wx::ID_ANY) { | e | on_page_changed(e) }
end

Instance Attribute Details

#managerObject (readonly)

Returns the value of attribute manager.



17
18
19
# File 'lib/helpers/model_main_frame_class.rb', line 17

def manager
  @manager
end

#notebookObject (readonly)

Returns the value of attribute notebook.



17
18
19
# File 'lib/helpers/model_main_frame_class.rb', line 17

def notebook
  @notebook
end

Instance Method Details

#add_page(options = {}) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/helpers/model_main_frame_class.rb', line 62

def add_page(options = {})
  # Handle default options
  options[:select] = default_page_select if options[:select].nil?
  options[:bitmap] = default_page_bitmap if options[:bitmap].nil?
  options[:caption] = default_page_caption if options[:caption].nil?
  
  if control = yield(@notebook)
    control.extend PageStatus
    @notebook.add_page(control, options[:caption], options[:select], options[:bitmap])
  end
end

#add_pane(options = {}) ⇒ Object



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

def add_pane(options = {})
  pi = Wx::AuiPaneInfo.new
  options.each {|setter, value| pi.send("set_#{setter}", value)}
  if control = yield(pi)
    @manager.add_pane(control, pi)
    @manager.update
  end
end

#art_providerObject



83
84
85
# File 'lib/helpers/model_main_frame_class.rb', line 83

def art_provider
  Wx::ArtProvider
end

#close_page(window) ⇒ Object



74
75
76
77
# File 'lib/helpers/model_main_frame_class.rb', line 74

def close_page(window)
  index = @notebook.get_page_index(window)
  @notebook.delete_page(index) if index
end

#current_pageObject



79
80
81
# File 'lib/helpers/model_main_frame_class.rb', line 79

def current_page
  @notebook.get_page(@notebook.get_selection)
end

#modelObject

get the model of the current page



48
49
50
51
# File 'lib/helpers/model_main_frame_class.rb', line 48

def model
  page = current_page
  page && page.model
end

#selected_recordsObject

get the selected records of the current page



42
43
44
45
# File 'lib/helpers/model_main_frame_class.rb', line 42

def selected_records
  page = current_page
  page ? page.selected_records : []
end