|
From: <fu...@us...> - 2003-12-23 14:59:16
|
Update of /cvsroot/neelix/neelix/view
In directory sc8-pr-cvs1:/tmp/cvs-serv18551/view
Modified Files:
fox.rb
Log Message:
presenter - only whitespace.
model - mucked around with Replicator
view - Added a menu. The Add Cookbook option in the Action menu works, the other Action menu items need to be done. Then we need to add delete cookbook/category/recipe menu items.
Index: fox.rb
===================================================================
RCS file: /cvsroot/neelix/neelix/view/fox.rb,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- fox.rb 23 Dec 2003 02:45:53 -0000 1.15
+++ fox.rb 23 Dec 2003 14:59:13 -0000 1.16
@@ -112,7 +112,7 @@
end
@ingredientList.connect(SEL_SELECTED) do |sender,sel,data|
- @up.enabled = data unless data == 0
+ @up.enabled = (data != 0)
@delete.enabled = true
@ingredientList.setCurrentItem(data)
end
@@ -257,9 +257,34 @@
def initialize(app)
super(app, 'Neelix')
resize(800,600)
+
+ # Menu
+ menubar = FXMenubar.new(self)
+ filemenu = FXMenuPane.new(self)
+ FXMenuCommand.new(filemenu, "&Exit", nil, getApp(), FXApp::ID_QUIT)
+ FXMenuTitle.new(menubar,"&File",nil,filemenu)
+
+ actionmenu = FXMenuPane.new(self)
+ actions={}
+ actions['add_cookbook'] = FXMenuCommand.new(actionmenu, "Add Cook&book", nil)
+ actions['add_cookbook'].enable
+ actions['add_category'] = FXMenuCommand.new(actionmenu, "Add &Category", nil)
+ actions['add_category'].disable
+ actions['add_recipe'] = FXMenuCommand.new(actionmenu, "Add &Recipe", nil)
+ actions['add_recipe'].disable
+ FXMenuTitle.new(menubar,"&Action",nil,actionmenu)
+
+ helpmenu = FXMenuPane.new(self)
+ FXMenuCommand.new(helpmenu, "&About Neelix...").connect(SEL_COMMAND) {
+ FXMessageBox.information(self, MBOX_OK, "About Neelix",
+ "Neelix is cool.\nhttp://sf.net/projects/neelix\n\nDedicated to Erin Fugal")
+ }
+ FXMenuTitle.new(menubar, "&Help", nil, helpmenu, LAYOUT_RIGHT)
+
frame = FXHorizontalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
splitter = FXSplitter.new(frame,SPLITTER_HORIZONTAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
+ # Splitter
shelf = FXGroupBox.new(splitter,"Shelf",FRAME_GROOVE)
shelf.width=200
counter = FXGroupBox.new(splitter,"Counter",FRAME_GROOVE)
@@ -269,9 +294,10 @@
CategoryForm.new(counterSwitcher,nil)
RecipeForm.new(counterSwitcher,nil)
+ # Shelf
frame = FXVerticalFrame.new(shelf, FRAME_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0)
shelfTree = 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|
+ $replicator.cookbooks.each do |cookbook|
cookbook_item = shelfTree.addItemLast(nil, FXTreeItem.new(cookbook.name))
cookbook_item.data = cookbook
cookbook.add_observer { cookbook_item.text = cookbook.name; shelfTree.update }
@@ -292,18 +318,75 @@
when Cookbook
counterSwitcher.children[1].cookbook = ptr.data
counterSwitcher.current = 1
+ actions['add_cookbook'].enable
+ actions['add_category'].enable
+ actions['add_recipe'].disable
when Category
counterSwitcher.children[2].category = ptr.data
counterSwitcher.current = 2
+ actions['add_cookbook'].enable
+ actions['add_category'].disable
+ actions['add_recipe'].enable
when Recipe
counterSwitcher.children[3].recipe = ptr.data
counterSwitcher.current = 3
+ actions['add_cookbook'].enable
+ actions['add_category'].disable
+ actions['add_recipe'].disable
+ else
+ counterSwitcher.current = 0
+ actions['add_cookbook'].enable
+ actions['add_category'].disable
+ actions['add_recipe'].disable
end
end
shelfTree.expandTree(shelfTree.firstItem)
shelfTree.expandTree(shelfTree.firstItem.first)
shelfTree.makeItemVisible(shelfTree.firstItem.first.first)
+
+ # shelf observers
+ $replicator.cookbooks.add_observer {
+ ary = $replicator.cookbooks.to_a
+ data = ary.shift
+ shelfTree.each do |item|
+ if data == item.data
+ data = ary.shift
+ next
+ end
+
+ while data != nil and item.data != data
+ newitem = FXTreeItem.new(data.name)
+ newitem.data = data
+ data.add_observer {
+ newitem.text = data.name
+ }
+ shelfTree.addItemBefore(item,newitem)
+ shelfTree.selectItem(newitem,true)
+ data = ary.shift
+ end
+
+ shelfTree.removeItem(item) if data.nil?
+ end
+ ary << data
+ ary.each { |data|
+ newitem = FXTreeItem.new(data.name)
+ newitem.data = data
+ data.add_observer {
+ newitem.text = data.name
+ }
+ shelfTree.addItemLast(nil,newitem)
+ shelfTree.selectItem(newitem,true)
+ }
+ }
+ # TODO categories and recipes observers
+
+ # actions menu connections
+ actions['add_cookbook'].connect(SEL_COMMAND) {
+ c = $replicator.create('cookbook',{'name'=>"New Cookbook"})
+ }
+ actions['add_category'].connect(SEL_COMMAND) { puts "TODO: Add Category proc" }
+ actions['add_recipe'].connect(SEL_COMMAND) { puts "TODO: Add Recipe proc" }
end
end
|