YesNoBox.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Mar 1996 19:44:55 +0100
changeset 447 ed41e1bbd9a1
parent 444 ef26eba8c854
child 572 121735c2aff6
permissions -rw-r--r--
also support goto-default (use selection if any)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
WarningBox subclass:#YesNoBox
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    14
	instanceVariableNames:''
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    15
	classVariableNames:'RequestBitmap'
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    16
	poolDictionaries:''
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    17
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    20
!YesNoBox class methodsFor:'documentation'!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    21
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    22
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    23
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    25
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    26
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    27
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    28
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    30
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    31
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    32
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    33
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    34
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    35
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    36
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    37
"
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    38
   Historic note:
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    39
        originally, ST/X had separate classes for the various entry methods;
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    40
        there were YesNoBox, EnterBox, InfoBox and so on.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    41
        In the meantime, the DialogBox class (and therefore its alias: Dialog)
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    42
        is going to duplicate most funcionality found in these classes.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    43
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    44
        In the future, those existing subclasses' functionality is going to
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    45
        be moved fully into Dialog, and the subclasses will be replaced by dummy
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    46
        delegators. (They will be kept for backward compatibility, though).
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    47
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    48
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    49
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    50
    this class implements yes-no boxes by adding another (no-) Button to the WarnBox-View.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    51
    They are created with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    52
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    53
        aBox := YesNoBox title:'some title'.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    54
        aBox okAction:[ .. some action to be performed when ok is pressed ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    55
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    56
    and finally shown with:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    57
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    58
        aBox showAtPointer
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    59
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    60
    The default box shows 'yes' and 'no' in its buttons; this can be changed with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    61
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    62
        aBox yesText:'some string'.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    63
        aBox noText:'some string'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    64
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    65
    There is also protocol to set both button titles in one message.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    66
    Also, the action associated to the noButton can be changed.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    67
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    68
    For very simple yes/no queries, you can also use the much simpler confirm:.
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    69
    Since implemented in Object, everyone understands confirm. You can pass
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    70
    a question message (but not change the buttons labels).
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    71
    Use is:
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    72
        self confirm:'some question'  
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    73
    and will return true or false.
125
claus
parents: 119
diff changeset
    74
claus
parents: 119
diff changeset
    75
    For compatibility with ST-80, use:
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    76
        Dialog confirm:'hello'
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    77
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    78
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    79
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    80
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    81
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    82
    Examples:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    83
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    84
	|aBox|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    85
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    86
	aBox := YesNoBox title:'Coffee or tee ?'.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    87
	aBox noText:'tee'.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    88
	aBox yesText:'coffee'.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    89
	aBox yesAction:[Transcript showCr:'make coffee'].
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    90
	aBox noAction:[Transcript showCr:'make tee'].
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    91
	aBox showAtPointer.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    92
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    93
    or, shorter:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    94
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    95
	|aBox|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    96
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    97
	aBox := YesNoBox new.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    98
	aBox title:'Coffee or Tee ?' 
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    99
	     yesAction:[Transcript showCr:'make coffee']
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   100
	     noAction:[Transcript showCr:'make tee'].
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   101
	aBox yesText:'Coffee' noText:'Tee'.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   102
	aBox showAtPointer
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   103
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   104
    Also, have a look at the inherited protocol; for example, this allows changing
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   105
    the bitmap (default: a question mark) and other properties.
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   106
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   107
    If the box is needed to ask for a simple boolean, you can also use the
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   108
    #confirm method, to bring up a box, let it ask for something and return
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   109
    true or false. 
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   110
    Example:
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   111
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   112
	|box value|
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   113
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   114
	box := YesNoBox new.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   115
	value := box confirm:'yes or no:'.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   116
	value ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   117
	    Transcript showCr:'yes'
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   118
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   119
	    Transcript showCr:'no'
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   120
	]
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   121
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   122
    of course, this can also be written shorter as:
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   123
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   124
	(YesNoBox new confirm:'yes or no:') ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   125
	    Transcript showCr:'yes'
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   126
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   127
	    Transcript showCr:'no'
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   128
	]
125
claus
parents: 119
diff changeset
   129
claus
parents: 119
diff changeset
   130
    or:
claus
parents: 119
diff changeset
   131
claus
parents: 119
diff changeset
   132
	(Dialog confirm:'yes or no:') ifTrue:[
claus
parents: 119
diff changeset
   133
	    Transcript showCr:'yes'
claus
parents: 119
diff changeset
   134
	] ifFalse:[
claus
parents: 119
diff changeset
   135
	    Transcript showCr:'no'
claus
parents: 119
diff changeset
   136
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   137
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   138
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   139
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   140
!YesNoBox class methodsFor:'instance creation'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   141
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   142
title:t yesText:yesString noText:noString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   143
    ^ (self new) title:t yesText:yesString noText:noString
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   144
! !
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   145
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   146
!YesNoBox class methodsFor:'icon bitmap'!
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   147
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   148
iconBitmap
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   149
    "return the bitmap shown as icon in my instances"
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   150
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   151
    RequestBitmap isNil ifTrue:[
109
0f014b33eba2 *** empty log message ***
claus
parents: 105
diff changeset
   152
	RequestBitmap := Image fromFile:'bitmaps/Request.xbm'. 
0f014b33eba2 *** empty log message ***
claus
parents: 105
diff changeset
   153
	RequestBitmap notNil ifTrue:[
0f014b33eba2 *** empty log message ***
claus
parents: 105
diff changeset
   154
	    RequestBitmap := RequestBitmap on:Display 
0f014b33eba2 *** empty log message ***
claus
parents: 105
diff changeset
   155
	].
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   156
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   157
    ^ RequestBitmap
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   158
! !
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   159
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   160
!YesNoBox class methodsFor:'styles'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   161
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   162
updateStyleCache
444
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   163
    "extract values from the styleSheet and cache them in class variables"
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   164
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   165
    <resource: #style (#requestBoxIcon)>
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   166
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   167
    |img|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   168
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   169
    img := StyleSheet at:'requestBoxIcon'.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   170
    img notNil ifTrue:[RequestBitmap := img on:Display].
444
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   171
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   172
    "Modified: 1.3.1996 / 13:52:18 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   173
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   174
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   175
!YesNoBox methodsFor:'accessing'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   176
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   177
noAction:aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   178
    "define the action to be performed when no is pressed"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   179
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   180
    abortAction := aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   181
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   182
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   183
noButton
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   184
    "return the no-button"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   185
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   186
    ^ abortButton
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   187
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   188
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   189
noLabel:aString
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   190
    "define the label of the no-button"
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   191
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   192
    self noText:aString.
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   193
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   194
    "Created: 13.12.1995 / 16:21:57 / cg"
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   195
!
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   196
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   197
noText:aString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   198
    "define the label of the no-button"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   199
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   200
    aString ~= abortButton label ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   201
	abortButton label:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   202
	abortButton resize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   203
	shown ifTrue:[self resize]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   204
    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   205
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   206
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   207
okText:yesString noText:noString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   208
    "define the labels of both buttons - same as yesText:noText"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   209
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   210
    ^ self yesText:yesString noText:noString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   211
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   212
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   213
title:aString yesAction:yesBlock noAction:noBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   214
    "define title and actions"
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   215
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   216
    self title:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   217
    okAction := yesBlock.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   218
    abortAction := noBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   219
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   220
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   221
title:aString yesText:yesString noText:noString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   222
    "define title and button labels"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   223
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   224
    self title:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   225
    self yesText:yesString noText:noString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   226
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   227
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   228
yesAction:aBlock 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   229
    "define the action to be performed when yes is pressed"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   230
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   231
    okAction := aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   232
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   233
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   234
yesAction:yesBlock noAction:noBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   235
    "define both actions"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   236
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   237
    okAction := yesBlock.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   238
    abortAction := noBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   239
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   240
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   241
yesButton
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   242
    "return the yes-button"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   243
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   244
    ^ okButton
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   245
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   246
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   247
yesLabel:aString
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   248
    "define the label of the yes-button"
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   249
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   250
    self yesText:aString.
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   251
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   252
    "Created: 13.12.1995 / 16:22:05 / cg"
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   253
!
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   254
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   255
yesText:aString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   256
    "define the label of the yes-button"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   257
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   258
    self okText:aString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   259
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   260
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   261
yesText:yesString noText:noString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
    "define the labels of both buttons"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   264
    ((yesString ~= okButton label) or:[noString ~= abortButton label]) ifTrue:[
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   265
        okButton label:yesString. 
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   266
        abortButton label:noString.
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   267
        okButton resize.
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   268
        abortButton resize.
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   269
        shown ifTrue:[self resize]
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   270
    ]
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   271
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   272
    "Modified: 21.2.1996 / 00:58:38 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   273
! !
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   274
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   275
!YesNoBox methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   276
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   277
focusSequence
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   278
    ^ Array with:abortButton with:okButton 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   279
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   280
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   281
initialize
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   282
    super initialize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   283
150
claus
parents: 130
diff changeset
   284
    label := resources string:'Choose'.
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   285
130
claus
parents: 125
diff changeset
   286
    buttonPanel horizontalLayout:#fitSpace.  "/ looks better; should it come from the StyleSheet ?
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   287
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   288
    textLabel label:'please Confirm'.
162
claus
parents: 150
diff changeset
   289
    okButton logo:(resources at:'yes').
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   290
162
claus
parents: 150
diff changeset
   291
    abortButton := Button abortButton.
claus
parents: 150
diff changeset
   292
    buttonPanel addSubView:abortButton before:okButton.
claus
parents: 150
diff changeset
   293
    abortButton logo:(resources at:'no').
claus
parents: 150
diff changeset
   294
    abortButton height:(okButton height).
claus
parents: 150
diff changeset
   295
    abortButton model:self; change:#noPressed
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   296
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   297
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   298
!YesNoBox methodsFor:'queries'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   299
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   300
preferredExtent 
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   301
    |w h max mm|
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   302
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   303
    mm := ViewSpacing.
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   304
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   305
    "
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   306
     make the two buttons of equal size
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   307
    "
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   308
    max := okButton preferredExtent x max:abortButton preferredExtent x.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   309
    okButton width:max.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   310
    abortButton width:max.
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   311
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   312
    w := (formLabel width + textLabel width) max:max * 2.
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   313
    w := w + (3 * mm) + (okButton borderWidth + abortButton borderWidth * 2).
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   314
    h := (mm * 5)
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   315
         + ((formLabel height) max:(textLabel height))
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   316
         + okButton heightIncludingBorder.
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   317
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   318
    ^ (w @ h).
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   319
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   320
    "Modified: 21.2.1996 / 00:58:04 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   321
! !
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   322
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   323
!YesNoBox methodsFor:'startup'!
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   324
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   325
confirm
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   326
    "open the receiver and return true for yes, false for no.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   327
     This is an easier interface to use, since no action blocks
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   328
     have to be defined. The title is used as previously defined."
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   329
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   330
    self yesAction:[^ true] noAction:[^ false].
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   331
    self showAtPointer.
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   332
    self yesAction:nil noAction:nil. "/ clear actions for earlier release of context
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   333
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   334
    "
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   335
     YesNoBox new confirm
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   336
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   337
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   338
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   339
confirm:aString
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   340
    "open the receiver and return true for yes, false for no.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   341
     This is an easier interface to use, since no action blocks
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   342
     have to be defined."
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   343
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   344
    self title:aString.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   345
    ^ self confirm
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   346
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   347
    "
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   348
     YesNoBox new confirm:'really ?'
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   349
     YesNoBox confirm:'really ?'
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   350
     self confirm:'really ?'
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   351
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   352
    for ST-80 compatibility, you should use Dialogs confirm
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   353
    (which simply forwards the request to the YesNoBox anyway):
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   354
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   355
     Dialog confirm:'really ?'    
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   356
    "
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   357
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   358
    "Modified: 13.12.1995 / 16:20:01 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   359
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   360
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   361
!YesNoBox methodsFor:'user interaction'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   362
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   363
noPressed
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   364
    "user pressed the no-button;
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   365
     hide myself and evaluate the action"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   366
162
claus
parents: 150
diff changeset
   367
    abortButton turnOffWithoutRedraw.
claus
parents: 150
diff changeset
   368
    self hideAndEvaluate:abortAction
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   369
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   370
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   371
!YesNoBox class methodsFor:'documentation'!
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   372
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   373
version
444
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   374
    ^ '$Header: /cvs/stx/stx/libwidg/YesNoBox.st,v 1.25 1996-03-01 13:05:52 cg Exp $'
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   375
! !