Method: AimsProject::GeometryEditor#initialize

Defined in:
lib/aims_project/geometry_editor.rb

#initialize(app, window) ⇒ GeometryEditor

Returns a new instance of GeometryEditor.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/aims_project/geometry_editor.rb', line 10

def initialize(app, window)
  
  super(window)

  @app = app
  
  sizer = BoxSizer.new(VERTICAL)

  @text_ctrl = StyledTextCtrl.new(self)
  # @text_ctrl.set_sel_background(true, Colour.new("wheat"))
  
  # Create the button panel (A toolbar for the top of this panel)
  @button_panel = HBoxSizer.new
  
  @toggle_source = CheckBox.new(self, ID_ANY, "Source")
  
  basedir = File.dirname(__FILE__)
  arrow_icon = Image.new(File.join(basedir,"green_arrow.jpg"), BITMAP_TYPE_JPEG)
  @eval_button = BitmapButton.new(self, :bitmap => arrow_icon.rescale(16,15).convert_to_bitmap,:style=>BU_EXACTFIT, :name => "evaluate")
  
  # error_icon = Image.new(File.join(basedir, "red_cross.jpeg"), BITMAP_TYPE_JPEG)
  # @clear_errors_button = BitmapButton.new(self, :bitmap => error_icon.rescale(16,15).convert_to_bitmap,:style=>BU_EXACTFIT, :name => "Clear Errors")
  
  @button_panel.add_item(@toggle_source,1)
  @button_panel.add_stretch_spacer
  @button_panel.add_item(@eval_button,3)
  
  evt_checkbox(@toggle_source) {|evt|
    if @toggle_source.is_checked
      @text_ctrl.set_read_only(false)
      @text_ctrl.set_text(@unit_cell.raw_input)
    else
      @text_ctrl.set_read_only(false)
      @text_ctrl.set_text(@unit_cell.input_geometry)
      @text_ctrl.set_read_only(true)
    end
  }
  
  sizer.add_item(@button_panel, :flag => EXPAND)
  sizer.add_item(@text_ctrl, :proportion => 1, :flag => EXPAND | ALL, :border => 5)

  set_auto_layout(true)
  set_sizer(sizer)

      
  evt_button(@eval_button) {|event|
      self.evaluate
  }

end