#                   I N T R O P A G E . I T K
# BRL-CAD
#
# Copyright (c) 2004-2021 United States Government as represented by
# the U.S. Army Research Laboratory.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this file; see the file named COPYING for more
# information.
#
###
#
# This file provides a page that can be used for providing a general
# overview of the picture making process.
#


package require Itcl
package require Itk
package require Iwidgets

namespace eval RtWizard {

    package provide IntroPage 1.0

    #
    # intropage - Provides a lowercased access method for the
    #             IntroPage class
    #
    proc intropage {pathName args} {
	uplevel IntroPage $pathName $args
    }

    #
    # Add options
    #
    option add *IntroPage.borderWidth 2 widgetDefault
    option add *IntroPage.labelPos wn widgetDefault
    option add *IntroPage.listHeight 150 widgetDefault
    option add *IntroPage.hscrollMode dynamic widgetDefault
    option add *IntroPage.vscrollMode dynamic widgetDefault
    option add *IntroPage.textBackground #ccccff

    #
    # Define the usual options
    #
    ::itk::usual IntroPage {
	keep    -background \
	    -borderwidth \
	    -cursor \
	    -elementborderwidth \
	    -foreground \
	    -highlightcolor \
	    -highlightthickness \
	    -insertbackground \
	    -insertborderwidth \
	    -insertofftime \
	    -insertontime \
	    -insertwidth \
	    -jump \
	    -labelfont \
	    -selectbackground \
	    -selectborderwidth \
	    -textbackground \
	    -textfont \
	    -troughcolor \
	    -stepName
    }

    #
    # IntroPage
    #
    # The intropage holds helpful text
    #

    #
    # Use the singleton pattern to allow the picture types to
    # easily change the greeting text.
    #
    set ::introInstance ""

    ::itcl::class IntroPage {
	inherit ::iwidgets::Labeledwidget

	#
	# Configuration variables
	#

	itk_option define -greeting greeting Greeting \
	    "Welcome to the RtWizard."

	public {
	    #
	    # methods
	    #
	    constructor {args} {};

	    method onSelect {}
	    method onDeselect {}
	    method getStepInfo {}
	}


	private {
	    #
	    # methods
	    #

	    #
	    # variables
	    #
	}
    }

    #--------------------#
    #   Public Methods   #
    #--------------------#
    #
    # constructor - builds the Intro Page
    #
    ::itcl::body IntroPage::constructor {args} {

	global introInstance

	if { [string length $introInstance] > 0 } {
	    error "Can not instantiate a second IntroPage object."
	}

	#
	# Set up the childsite
	#
	set cs [ $this childsite ]
	$cs configure -relief groove -bd 2

	#
	# Splat instructive text.
	#
	itk_component add greetPanel {
	    ::iwidgets::scrolledtext $cs.gp \
		-vscrollmode dynamic \
		-hscrollmode dynamic \
		-wrap word \
		-visibleitems 75x30 \
		-textfont {helvetica 10 bold} \
		-relief sunken

	} {
	    usual
	    ignore -textfont
	}

	# Next
	itk_component add next {
	    button $cs.next \
		-text Next \
		-width 8 \
		-command "[itcl::code $this goNext]"
	} {
	    usual
	}

	#
	# Pack it!
	#
	pack $itk_component(greetPanel) -anchor w -fill both -expand 1

	#
	# Evaluate any additional args.
	#
	eval itk_initialize $args

	set introInstance $this
    }

    #
    # greeting
    #
    ::itcl::configbody IntroPage::greeting {
	$itk_component(greetPanel) configure -state normal
	$itk_component(greetPanel) clear
	$itk_component(greetPanel) insert end [cget -greeting]
	$itk_component(greetPanel) configure -state disabled
    }

    #
    # onSelect
    #
    # Makes any necessary changes to the Wizard configuration
    # when this page is selected.
    #
    ::itcl::body IntroPage::onSelect {} {
	#
	# Nothing yet!
	#
    }

    #
    # onDeselect
    #
    # Cleans up when the page is deselected
    #
    ::itcl::body IntroPage::onDeselect {} {
	#
	# Nothing yet!
	#
    }

    #
    # getStepInfo
    #
    # In principal, returns a name for the step, and a variable that
    # can be queried for state. The Intro page is not a 'step',
    # so it returns "No Step"
    #
    ::itcl::body IntroPage::getStepInfo {} {
	set a "No Step"
	set b "banana"
	return [list $a $b]
    }

    #--------------------#
    #  Private Methods   #
    #--------------------#

}
#end namespace


# Local Variables:
# mode: Tcl
# tab-width: 8
# c-basic-offset: 4
# tcl-indent-level: 4
# indent-tabs-mode: t
# End:
# ex: shiftwidth=4 tabstop=8
