#ruby require 'tk' class MasterFrame < TkFrame attr_reader :back_button, :forw_button, :ok_button, :back_label, :forw_label, :ok_label, :back_label2, :forw_label2, :master_top, :crt, :screen, :leds, :title_label, :help_button, :mute_button, :stop_button, :error_check, :error_msg SCREEN_WIDTH=320 SCREEN_HEIGHT=240 NAV_HEIGHT=50 PAD = 10 def initialize(parent=nil, keys=nil) super(parent,keys) @master_top = TkFrame.new(self).pack('side'=>'top','fill'=>'x') @leds = TkLabel.new(@master_top, 'text'=>'XXX').pack master_left = TkFrame.new(master_top).pack('side'=>'left','fill'=>'y') TkButton.new(master_left,'text'=>'I/O', 'command'=>proc{exit}).pack TkLabel.new(master_left,'height'=>5).pack('side'=>'bottom') @stop_button = TkButton.new(master_left) { image TkPhotoImage.new('file'=> "images/stop_sign.gif") pack 'side'=>'bottom' } user_pane = TkFrame.new(master_top, 'relief'=>'raised').pack('side'=>'right') @crt = TkFrame.new(user_pane, 'width'=>SCREEN_WIDTH, 'height'=>SCREEN_HEIGHT, 'relief'=>'sunken', 'bd'=>3) . grid('row'=>0,'col'=>0, 'padx'=>PAD, 'pady'=>PAD) @crt.grid_propagate(0) @crt.pack_propagate(0) right_pane = TkFrame.new(user_pane). grid('row'=>0,'col'=>1, 'sticky'=>'ns', 'padx'=>PAD, 'pady'=>PAD) @help_button = TkButton.new(right_pane,'text'=>'Help').pack('side'=>'top') @mute_button = TkButton.new(right_pane,'text'=>'Mute').pack('side'=>'bottom') bottom_pane = TkFrame.new(user_pane) . grid('row'=>1,'col'=>0, 'sticky'=>'ew', 'padx'=>PAD, 'pady'=>PAD) @back_button= TkButton.new(bottom_pane,'text'=>'<--').pack('side'=>'left') @forw_button= TkButton.new(bottom_pane,'text'=>'-->').pack('side'=>'right') @ok_button = TkButton.new(bottom_pane,'text'=>'OK').pack() nav_pane = TkFrame.new(@crt,'height'=>NAV_HEIGHT).pack('side'=>'bottom','fill'=>'x') nav_pane.grid_propagate(0) nav_pane.pack_propagate(0) back_frame = TkFrame.new(nav_pane).pack('side'=>'left') forw_frame = TkFrame.new(nav_pane).pack('side'=>'right') ok_frame = TkFrame.new(nav_pane).pack('anchor'=>'center').grid @back_label = TkLabel.new(back_frame,'text'=>'Back').pack('side'=>'bottom','padx'=>2,'pady'=>2) @back_label2= TkLabel.new(back_frame,'text'=>'Back').pack('side'=>'top' ,'padx'=>2,'pady'=>2) @forw_label = TkLabel.new(forw_frame,'text'=>'Forw').pack('side'=>'bottom','padx'=>2,'pady'=>2) @forw_label2= TkLabel.new(forw_frame,'text'=>'Forw').pack('side'=>'top' ,'padx'=>2,'pady'=>2) @ok_label = TkLabel.new(ok_frame,'text'=>'OK','padx'=>2,'pady'=>2).pack('anchor'=>'center').grid @title_label= TkLabel.new(@crt).pack('side'=>'top','fill'=>'x') @screen = TkFrame.new(@crt).pack('side'=>'top','fill'=>'both','expand'=>'on') @screen.grid_propagate(0) @screen.pack_propagate(0) error_pane = TkFrame.new(self, 'relief'=>'raised').pack('side'=>'bottom') @error_check= TkCheckButton.new(error_pane,'text'=>'Generate Error').pack('side'=>'left') @error_msg = TkEntry.new(error_pane).pack('side'=>'left', 'fill'=>'x') end def clear_buttons navigation_actions = [ proc{ p "Back - Do nothing" }, proc{ p "OK - Do nothing" }, proc{ p "Forw - Do nothing" } ] end def clear_nav_labels navigation_labels = ['','',''] end def navigation_labels=(labels) back,ok,forw = *labels @back_label .configure('text'=>back) @ok_label .configure('text'=>ok) @forw_label .configure('text'=>forw) end def navigation_actions=(actions) back,ok,forw = *actions @back_button.configure('command'=>back) @ok_button .configure('command'=>ok) @forw_button.configure('command'=>forw) end end