1#
2# Messagedialog
3# ----------------------------------------------------------------------
4# Implements a message dialog composite widget.  The Messagedialog is
5# derived from the Dialog class and is composed of an image and text
6# component.  The image will accept both images as well as bitmaps.
7# The text can extend mutliple lines by embedding newlines.
8#
9# ----------------------------------------------------------------------
10#  AUTHOR: Mark L. Ulferts              EMAIL: mulferts@austin.dsccc.com
11#
12#  @(#) $Id: messagedialog.itk,v 1.3 2001/08/07 19:56:48 smithc Exp $
13# ----------------------------------------------------------------------
14#            Copyright (c) 1995 DSC Technologies Corporation
15# ======================================================================
16# Permission to use, copy, modify, distribute and license this software
17# and its documentation for any purpose, and without fee or written
18# agreement with DSC, is hereby granted, provided that the above copyright
19# notice appears in all copies and that both the copyright notice and
20# warranty disclaimer below appear in supporting documentation, and that
21# the names of DSC Technologies Corporation or DSC Communications
22# Corporation not be used in advertising or publicity pertaining to the
23# software without specific, written prior permission.
24#
25# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
26# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-
27# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE
28# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
29# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL
30# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
31# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
32# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
33# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
34# SOFTWARE.
35# ======================================================================
36
37#
38# Usual options.
39#
40itk::usual Messagedialog {
41    keep -background -cursor -font -foreground -modality
42    keep -wraplength -justify
43}
44
45# ------------------------------------------------------------------
46#                            MESSAGEDIALOG
47# ------------------------------------------------------------------
48itcl::class iwidgets::Messagedialog {
49    inherit iwidgets::Dialog
50
51    constructor {args} {}
52
53    itk_option define -imagepos imagePos Position w
54}
55
56#
57# Provide a lowercased access method for the Messagedialog class.
58#
59proc ::iwidgets::messagedialog {pathName args} {
60    uplevel ::iwidgets::Messagedialog $pathName $args
61}
62
63#
64# Use option database to override default resources of base classes.
65#
66option add *Messagedialog.title "Message Dialog" widgetDefault
67option add *Messagedialog.master "." widgetDefault
68option add *Messagedialog.textPadX 20 widgetDefault
69option add *Messagedialog.textPadY 20 widgetDefault
70
71# ------------------------------------------------------------------
72#                        CONSTRUCTOR
73# ------------------------------------------------------------------
74itcl::body iwidgets::Messagedialog::constructor {args} {
75    #
76    # Create the image component which may be either a bitmap or image.
77    #
78    itk_component add image {
79	label $itk_interior.image
80    } {
81	keep -background -bitmap -cursor -foreground -image
82    }
83
84    #
85    # Create the text message component.  The message may extend over
86    # several lines by embedding '\n' characters.
87    #
88    itk_component add message {
89	label $itk_interior.message
90    } {
91	keep -background -cursor -font -foreground -text
92	keep -wraplength -justify
93
94	rename -padx -textpadx textPadX Pad
95	rename -pady -textpady textPadY Pad
96    }
97
98    #
99    # Hide the apply and help buttons.
100    #
101    hide Apply
102    hide Help
103
104    #
105    # Initialize the widget based on the command line options.
106    #
107    eval itk_initialize $args
108}
109
110# ------------------------------------------------------------------
111#                             OPTIONS
112# ------------------------------------------------------------------
113
114# ------------------------------------------------------------------
115# OPTION: -imagepos
116#
117# Specifies the image position relative to the message: n, s,
118# e, or w.  The default is w.
119# ------------------------------------------------------------------
120itcl::configbody iwidgets::Messagedialog::imagepos {
121    switch $itk_option(-imagepos) {
122    	n {
123	    grid $itk_component(image) -row 0 -column 0
124	    grid $itk_component(message) -row 1 -column 0
125    	}
126    	s {
127	    grid $itk_component(message) -row 0 -column 0
128	    grid $itk_component(image) -row 1 -column 0
129    	}
130    	e {
131	    grid $itk_component(message) -row 0 -column 0
132	    grid $itk_component(image) -row 0 -column 1
133    	}
134    	w {
135	    grid $itk_component(image) -row 0 -column 0
136	    grid $itk_component(message) -row 0 -column 1
137    	}
138
139    	default {
140    	    error "bad imagepos option \"$itk_option(-imagepos)\":\
141		    should be n, e, s, or w"
142    	}
143    }
144}
145