|
From: <fu...@us...> - 2003-12-14 09:43:02
|
Update of /cvsroot/neelix/neelix/view
In directory sc8-pr-cvs1:/tmp/cvs-serv22078/view
Modified Files:
fox.rb
Log Message:
More GUI refactoring. Achieved recipe view. Now need to add recipe presenter,
and view updating (with observer pattern)
Index: fox.rb
===================================================================
RCS file: /cvsroot/neelix/neelix/view/fox.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fox.rb 13 Dec 2003 17:56:48 -0000 1.2
--- fox.rb 14 Dec 2003 04:54:05 -0000 1.3
***************
*** 2,26 ****
include Fox
class NeelixMainWindow < FXMainWindow
def initialize(app)
! super(app, 'Neelix',nil,nil,DECOR_ALL,0,0,800,600)
frame = FXHorizontalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
splitter = FXSplitter.new(frame,SPLITTER_HORIZONTAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
! groupbox = FXGroupBox.new(splitter,"Shelf",FRAME_GROOVE)
counter = FXGroupBox.new(splitter,"Counter",FRAME_GROOVE)
! frame = FXVerticalFrame.new(groupbox,LAYOUT_FILL_X|LAYOUT_FILL_Y)
! shelf = FXTreeList.new(frame,0,nil,0,TREELIST_SINGLESELECT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|LAYOUT_FILL_X|LAYOUT_FILL_Y)
$replicator.shelf.each do |cookbook|
! cookbook_item = shelf.addItemLast(nil, FXTreeItem.new(cookbook.name))
! cookbook_item.expanded = true
cookbook.categories.each do |category|
! category_item = shelf.addItemLast(cookbook_item, FXTreeItem.new(category.name))
category.recipes.each do |recipe|
! shelf.addItemLast(category_item, FXTreeItem.new(recipe.name))
end
end
end
end
end
--- 2,88 ----
include Fox
+ class RecipeForm < FXVerticalFrame
+ def initialize(parent,recipe)
+ super(parent)
+
+ FXLabel.new(self,"Name")
+ name = FXTextField.new(self, 80)
+ name.text = recipe.name
+
+ FXLabel.new(self,"Author")
+ author = FXTextField.new(self, 80)
+ author.text = recipe.author
+
+ FXLabel.new(self,"Oven Temp.")
+ temp = FXTextField.new(self, 80)
+ temp.text = recipe.temp
+
+ FXLabel.new(self,"Total Time")
+ tottime = FXTextField.new(self, 80)
+ tottime.text = recipe.tottime
+
+ FXLabel.new(self,"Yields")
+ yields = FXTextField.new(self, 80)
+ yields.text = recipe.yields
+
+ FXLabel.new(self,"Ingredients")
+ frame = FXHorizontalFrame.new(self,LAYOUT_FILL_X)
+ ingredientList = FXList.new(frame,recipe.ingredients.size,nil,0,LAYOUT_FILL_X)
+ frame = FXVerticalFrame.new(frame)
+ FXButton.new(frame,"Add Ingredient")
+ up = FXButton.new(frame,"Move Up")
+ down = FXButton.new(frame,"Move Down")
+ up.enabled = false
+ down.enabled = false
+ recipe.ingredients.each do |ingredient|
+ ingredientList.appendItem(ingredient.to_s)
+ end
+
+ FXLabel.new(self,"Directions")
+ directions = FXText.new(self)
+ directions.visCols=80
+ directions.text = recipe.directions
+
+ FXLabel.new(self,"Notes")
+ notes = FXText.new(self)
+ notes.visCols=80
+ notes.text = recipe.note
+ end
+ end
+
class NeelixMainWindow < FXMainWindow
def initialize(app)
! super(app, 'Neelix')
! resize(800,600)
frame = FXHorizontalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
splitter = FXSplitter.new(frame,SPLITTER_HORIZONTAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
! shelf = FXGroupBox.new(splitter,"Shelf",FRAME_GROOVE)
! shelf.width = 200
counter = FXGroupBox.new(splitter,"Counter",FRAME_GROOVE)
! shelfTree = FXTreeList.new(shelf,0,nil,0,TREELIST_SINGLESELECT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|LAYOUT_FILL_X|LAYOUT_FILL_Y)
$replicator.shelf.each do |cookbook|
! cookbook_item = shelfTree.addItemLast(nil, FXTreeItem.new(cookbook.name))
cookbook.categories.each do |category|
! category_item = shelfTree.addItemLast(cookbook_item, FXTreeItem.new(category.name))
category.recipes.each do |recipe|
! item = FXTreeItem.new(recipe.name)
! item.data = recipe
! shelfTree.addItemLast(category_item, item)
end
end
end
+ shelfTree.connect(SEL_SELECTED) do |sender,sel,ptr|
+ if Recipe === ptr.data
+ counter.children.each { |child| counter.removeChild(child) }
+ RecipeForm.new(counter,ptr.data).create
+ end
+ end
+
+ shelfTree.expandTree(shelfTree.firstItem)
+ shelfTree.expandTree(shelfTree.firstItem.first)
+ shelfTree.makeItemVisible(shelfTree.firstItem.first.first)
+
end
end
|