|
From: <fu...@us...> - 2003-12-20 03:18:20
|
Update of /cvsroot/neelix/neelix/view
In directory sc8-pr-cvs1:/tmp/cvs-serv2867/view
Modified Files:
fox.rb
Log Message:
Refactored RecipeForm and the way the counter works in NeelixMainWindow.
Index: fox.rb
===================================================================
RCS file: /cvsroot/neelix/neelix/view/fox.rb,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** fox.rb 20 Dec 2003 02:03:00 -0000 1.6
--- fox.rb 20 Dec 2003 03:18:17 -0000 1.7
***************
*** 3,72 ****
class RecipeForm < FXVerticalFrame
! def initialize(parent,recipe)
super(parent)
FXLabel.new(self,"Name")
! name = FXTextField.new(self, 80)
! name.text = recipe.name
! name.connect(SEL_COMMAND) do |sender,sel,data|
! recipe.name = data
end
! FXLabel.new(self,"Author")
! author = FXTextField.new(self, 80)
! author.text = recipe.author
! author.connect(SEL_COMMAND) do |sender,sel,data|
! recipe.author = data
end
! FXLabel.new(self,"Oven Temp.")
! temp = FXTextField.new(self, 80)
! temp.text = recipe.temp
! temp.connect(SEL_COMMAND) do |sender,sel,data|
! recipe.temp = data
end
! FXLabel.new(self,"Total Time")
! tottime = FXTextField.new(self, 80)
! tottime.text = recipe.tottime
! tottime.connect(SEL_COMMAND) do |sender,sel,data|
! recipe.tottime = data
end
! FXLabel.new(self,"Yields")
! yields = FXTextField.new(self, 80)
! yields.text = recipe.yields
! yields.connect(SEL_COMMAND) do |sender,sel,data|
! recipe.yields = data
end
! 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")
! delete = FXButton.new(frame,"Delete")
! up.enabled = false
! delete.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
! directions.connect(SEL_CHANGED) do |sender,sel,data|
! recipe.directions = directions.text
end
! FXLabel.new(self,"Notes")
! notes = FXText.new(self)
! notes.visCols=80
! notes.text = recipe.note
! notes.connect(SEL_CHANGED) do |sender,sel,data|
! recipe.note = notes.text
end
end
end
--- 3,89 ----
class RecipeForm < FXVerticalFrame
! def initialize(parent,r)
super(parent)
+ @recipe = r
FXLabel.new(self,"Name")
! @name = FXTextField.new(self, 80)
! FXLabel.new(self,"Author")
! @author = FXTextField.new(self, 80)
! FXLabel.new(self,"Oven Temp.")
! @temp = FXTextField.new(self, 80)
! FXLabel.new(self,"Total Time")
! @tottime = FXTextField.new(self, 80)
! FXLabel.new(self,"Yields")
! @yields = FXTextField.new(self, 80)
!
! FXLabel.new(self,"Ingredients")
! frame = FXHorizontalFrame.new(self,LAYOUT_FILL_X)
! @ingredientList = FXList.new(frame,5,nil,0,LAYOUT_FILL_X)
! frame = FXVerticalFrame.new(frame)
! FXButton.new(frame,"Add Ingredient")
! @up = FXButton.new(frame,"Move Up")
! @delete = FXButton.new(frame,"Delete")
! @up.enabled = false
! @delete.enabled = false
!
! FXLabel.new(self,"Directions")
! @directions = FXText.new(self)
! @directions.visCols=80
!
! FXLabel.new(self,"Notes")
! @notes = FXText.new(self)
! @notes.visCols=80
!
! # connections
! @name.connect(SEL_COMMAND) do |sender,sel,data|
! @recipe.name = data
end
! @author.connect(SEL_COMMAND) do |sender,sel,data|
! @recipe.author = data
end
! @temp.connect(SEL_COMMAND) do |sender,sel,data|
! @recipe.temp = data
end
! @tottime.connect(SEL_COMMAND) do |sender,sel,data|
! @recipe.tottime = data
end
! @yields.connect(SEL_COMMAND) do |sender,sel,data|
! @recipe.yields = data
end
! @directions.connect(SEL_CHANGED) do |sender,sel,data|
! @recipe.directions = @directions.text
end
!
! @notes.connect(SEL_CHANGED) do |sender,sel,data|
! @recipe.note = @notes.text
end
! populate if @recipe
! end
!
! def populate
! @name.text = @recipe.name
! @author.text = @recipe.author
! @temp.text = @recipe.temp
! @tottime.text = @recipe.tottime
! @yields.text = @recipe.yields
! @ingredientList.clearItems
! @recipe.ingredients.each do |ingredient|
! @ingredientList.appendItem(ingredient.to_s)
end
+ @directions.text = @recipe.directions
+ @notes.text = @recipe.note
+ end
+
+ def recipe=(r)
+ @recipe = r
+ populate
+ update
end
end
***************
*** 82,85 ****
--- 99,105 ----
shelf.width=200
counter = FXGroupBox.new(splitter,"Counter",FRAME_GROOVE)
+ counterSwitcher = FXSwitcher.new(counter,LAYOUT_FILL_X|LAYOUT_FILL_Y)
+ FXWindow.new(counterSwitcher)
+ RecipeForm.new(counterSwitcher,nil)
shelfTree = FXTreeList.new(shelf,0,nil,0,TREELIST_SINGLESELECT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|LAYOUT_FILL_X|LAYOUT_FILL_Y)
***************
*** 98,103 ****
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
--- 118,123 ----
shelfTree.connect(SEL_SELECTED) do |sender,sel,ptr|
if Recipe === ptr.data
! counterSwitcher.children[1].recipe = ptr.data
! counterSwitcher.current = 1
end
end
***************
*** 118,120 ****
app.run
! # vim:nowrap
--- 138,140 ----
app.run
! # vim:nowrap:ts=8:sw=4
|