# ---------------------------------------------------------------------- # COMPONENT: mainwin - main application window for Rappture # # This widget acts as the main window for a Rappture application. # It can be configured to run in two modes: 1) normal desktop # application, and 2) web-based application. In web-based mode, # the application window runs inside a VNC window, and it takes # the full screen and blends in with the web page. # ====================================================================== # AUTHOR: Michael McLennan, Purdue University # Copyright (c) 2004-2005 # Purdue Research Foundation, West Lafayette, IN # ====================================================================== package require Itk option add *MainWin.mode desktop widgetDefault option add *MainWin.borderWidth 0 widgetDefault option add *MainWin.relief raised widgetDefault option add *MainWin.anchor center widgetDefault option add *MainWin.titleFont \ -*-helvetica-bold-o-normal-*-*-140-* widgetDefault itcl::class Rappture::MainWin { inherit itk::Toplevel itk_option define -mode mode Mode "" itk_option define -anchor anchor Anchor "center" itk_option define -bgscript bgScript BgScript "" constructor {args} { # defined below } public method draw {option args} protected method _redraw {} private variable _contents "" ;# frame containing app private variable _bgscript "" ;# script of background drawing cmds private variable _bgparser "" ;# parser for bgscript } itk::usual MainWin { keep -background -cursor foreground -font } # ---------------------------------------------------------------------- # CONSTRUCTOR # ---------------------------------------------------------------------- itcl::body Rappture::MainWin::constructor {args} { itk_component add area { canvas $itk_interior.area } { usual rename -background -bgcolor bgColor Background } pack $itk_component(area) -expand yes -fill both bind $itk_component(area) [itcl::code $this _redraw] itk_component add app { frame $itk_component(area).app } { usual keep -borderwidth -relief } bind $itk_component(app) " after cancel [itcl::code $this _redraw] after idle [itcl::code $this _redraw] " itk_component add menu { menu $itk_interior.menu } itk_component add filemenu { menu $itk_component(menu).file } $itk_component(menu) add cascade -label "File" -underline 0 \ -menu $itk_component(filemenu) $itk_component(filemenu) add command -label "Exit" -underline 1 \ -command exit # # Create a parser for the -bgscript option that can # execute drawing commands on the canvas. This allows # us to draw a background that blends in with web pages. # set _bgparser [interp create -safe] $_bgparser alias rectangle [itcl::code $this draw rectangle] $_bgparser alias oval [itcl::code $this draw oval] $_bgparser alias line [itcl::code $this draw line] $_bgparser alias polygon [itcl::code $this draw polygon] $_bgparser alias text [itcl::code $this draw text] $_bgparser alias image [itcl::code $this draw image] eval itk_initialize $args bind RapptureMainWin { exit } set btags [bindtags $itk_component(hull)] bindtags $itk_component(hull) [lappend btags RapptureMainWin] } # ---------------------------------------------------------------------- # USAGE: draw