Class: AimsProject::ProjectTree
- Inherits:
-
Wx::ScrolledWindow
- Object
- Wx::ScrolledWindow
- AimsProject::ProjectTree
- Includes:
- Wx
- Defined in:
- lib/aims_project/project_tree.rb
Constant Summary collapse
- ROOT =
"Root"
- GEOMETRY =
"Geometry"
- CONTROL =
"Control"
- CALCULATIONS =
"Calculations"
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#treeControl ⇒ Object
Returns the value of attribute treeControl.
Instance Method Summary collapse
- #init_project_tree ⇒ Object
-
#initialize(app, window) ⇒ ProjectTree
constructor
A new instance of ProjectTree.
Constructor Details
#initialize(app, window) ⇒ ProjectTree
Returns a new instance of ProjectTree.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aims_project/project_tree.rb', line 15 def initialize(app, window) super(window) self.app = app init_project_tree sizer = BoxSizer.new(VERTICAL) sizer.add(self.treeControl, 1, EXPAND | ALL, 5) set_auto_layout(true) set_sizer(sizer) end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
13 14 15 |
# File 'lib/aims_project/project_tree.rb', line 13 def app @app end |
#treeControl ⇒ Object
Returns the value of attribute treeControl.
13 14 15 |
# File 'lib/aims_project/project_tree.rb', line 13 def treeControl @treeControl end |
Instance Method Details
#init_project_tree ⇒ Object
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/project_tree.rb', line 28 def init_project_tree @treeControl = Wx::TreeCtrl.new(self) @tree_map = {} if self.app.project @tree_map[ROOT] = self.treeControl.add_root(self.app.project.name) @tree_map[GEOMETRY] = self.treeControl.append_item(@tree_map[ROOT], GEOMETRY) @tree_map[CONTROL] = self.treeControl.append_item(@tree_map[ROOT], CONTROL) @tree_map[CALCULATIONS] = self.treeControl.append_item(@tree_map[ROOT], CALCULATIONS) self.app.project.geometries.each{|geom| self.treeControl.append_item(@tree_map[GEOMETRY], geom) } self.app.project.calculations.each{|calc| calcid = self.treeControl.append_item(@tree_map[CALCULATIONS], calc.name) @tree_map[calcid] = calc } evt_tree_sel_changed(self.treeControl) {|evt| itemid = evt.get_item if @tree_map[GEOMETRY] == self.treeControl.get_item_parent(itemid) self.app.open_file(self.treeControl.get_item_text(itemid)) elsif @tree_map[CALCULATIONS] == self.treeControl.get_item_parent(itemid) calc = @tree_map[itemid] self.app.show_calculation(calc) end } else @tree_map[ROOT] = self.treeControl.add_root(ROOT) end @treeControl.(@tree_map[ROOT]) end |