# -*- mode: tcl; indent-tabs-mode: nil -*- # ---------------------------------------------------------------------- # COMPONENT: pager - notebook for displaying pages of widgets # # This widget is something like a tabbed notebook, but with a little # more flexibility. Pages can be inserted and deleted, and then shown # in various arrangements. # ====================================================================== # AUTHOR: Michael McLennan, Purdue University # Copyright (c) 2004-2012 HUBzero Foundation, LLC # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ====================================================================== package require Itk package require BLT option add *Pager.arrangement "pages" widgetDefault option add *Pager.width 0 widgetDefault option add *Pager.height 0 widgetDefault option add *Pager.padding 8 widgetDefault option add *Pager.crumbColor black widgetDefault option add *Pager.crumbNumberColor white widgetDefault option add *Pager.dimCrumbColor gray70 widgetDefault option add *Pager.activeCrumbColor blue widgetDefault option add *Pager.crumbFont \ -*-helvetica-bold-r-normal-*-12-* widgetDefault blt::bitmap define Pager-arrow { #define arrow_width 9 #define arrow_height 9 static unsigned char arrow_bits[] = { 0x10, 0x00, 0x30, 0x00, 0x70, 0x00, 0xff, 0x00, 0xff, 0x01, 0xff, 0x00, 0x70, 0x00, 0x30, 0x00, 0x10, 0x00}; } itcl::class Rappture::Pager { inherit itk::Widget itk_option define -width width Width 0 itk_option define -height height Height 0 itk_option define -padding padding Padding 0 itk_option define -crumbcolor crumbColor Foreground "" itk_option define -crumbnumbercolor crumbNumberColor Foreground "" itk_option define -crumbfont crumbFont Font "" itk_option define -dimcrumbcolor dimCrumbColor DimForeground "" itk_option define -activecrumbcolor activeCrumbColor ActiveForeground "" itk_option define -arrangement arrangement Arrangement "" constructor {args} { # defined below } public method insert {pos args} public method delete {first {last ""}} public method index {name} public method page {args} public method current {args} public method busy { bool } protected method _layout {} protected method _fixSize {} protected method _drawCrumbs {how} private variable _counter 0 ;# counter for page names private variable _dispatcher "" ;# dispatcher for !events private variable _pages "" ;# list of known pages private variable _page2info ;# maps page name => -frame,-title,-command private variable _current "" ;# page currently shown } itk::usual Pager { } # ---------------------------------------------------------------------- # CONSTRUCTOR # ---------------------------------------------------------------------- itcl::body Rappture::Pager::constructor {args} { Rappture::dispatcher _dispatcher $_dispatcher register !layout $_dispatcher dispatch $this !layout "[itcl::code $this _layout]; list" $_dispatcher register !fixsize $_dispatcher dispatch $this !fixsize "[itcl::code $this _fixSize]; list" itk_component add controls { frame $itk_interior.cntls } itk_component add next { button $itk_component(controls).next -text "Next >" \ -command [itcl::code $this current next>] } pack $itk_component(next) -side right itk_component add back { button $itk_component(controls).back -text "< Back" \ -command [itcl::code $this current ?-name ? ?-title