YesNoBox.st
author sr
Tue, 11 Jun 2019 11:47:16 +0200
changeset 6604 89a0c07bbba9
parent 6502 1e36a7f321dc
child 6831 cd449ea016f0
permissions -rw-r--r--
#BUGFIX by Stefan Reise fixed recursion when calling #showSelectedFont #updateFamilyList class: FontPanel added: #updateFamilyListAndDoShowSelectedFont: changed: #showSelectedFont #updateFamilyList
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6331
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
     1
"{ Encoding: utf8 }"
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
     2
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     3
"
5
claus
parents: 3
diff changeset
     4
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
     5
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
"
2304
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
    14
"{ Package: 'stx:libwidg' }"
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
    15
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
    16
"{ NameSpace: Smalltalk }"
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
    17
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
WarningBox subclass:#YesNoBox
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    19
	instanceVariableNames:''
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    20
	classVariableNames:'RequestBitmap'
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    21
	poolDictionaries:''
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    22
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    23
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    24
856
1b5b9d753163 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
    25
!YesNoBox class methodsFor:'documentation'!
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
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    28
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    29
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
    30
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    31
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    32
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    33
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    35
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    36
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    37
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    38
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    39
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    40
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    41
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    42
"
6331
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
    43
   aHistoric note:
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    44
        originally, ST/X had separate classes for the various entry methods;
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    45
        there were YesNoBox, EnterBox, InfoBox and so on.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    46
        In the meantime, the DialogBox class (and therefore its alias: Dialog)
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
    47
        is going to duplicate most functionality found in these classes.
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    48
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    49
        In the future, those existing subclasses' functionality is going to
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    50
        be moved fully into Dialog, and the subclasses will be replaced by dummy
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    51
        delegators. (They will be kept for backward compatibility, though).
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    52
949
4c9ab41146a1 commentary
Claus Gittinger <cg@exept.de>
parents: 946
diff changeset
    53
    New applications should use corresponding confirmation
4c9ab41146a1 commentary
Claus Gittinger <cg@exept.de>
parents: 946
diff changeset
    54
    methods from DialogBox.
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    55
6331
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
    56
    This class implements yes-no boxes by adding another (no-) Button to the WarnBox-View.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    57
    They are created with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    58
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    59
        aBox := YesNoBox title:'some title'.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    60
        aBox okAction:[ .. some action to be performed when ok is pressed ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    61
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    62
    and finally shown with:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    63
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    64
        aBox showAtPointer
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    65
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    66
    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
    67
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    68
        aBox yesText:'some string'.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    69
        aBox noText:'some string'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    70
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    71
    There is also protocol to set both button titles in one message.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    72
    Also, the action associated to the noButton can be changed.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
    73
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    74
    For very simple yes/no queries, you can also use the much simpler confirm:.
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    75
    Since implemented in Object, everyone understands confirm. You can pass
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    76
    a question message (but not change the buttons labels).
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    77
    Use is:
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
    78
        self confirm:'some question'
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    79
    and will return true or false.
125
claus
parents: 119
diff changeset
    80
claus
parents: 119
diff changeset
    81
    For compatibility with ST-80, use:
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    82
        Dialog confirm:'hello'
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    83
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    84
    [see also:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    85
        DialogBox
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    86
        EnterBox
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    87
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    88
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    89
        Claus Gittinger
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    90
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    91
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    92
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    93
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    94
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    95
"
2467
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
    96
    Notice, the preferred use is via the DialogBox class messages,
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
    97
    such as
2467
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
    98
                                                                        [exBegin]
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
    99
        Dialog confirm:'Coffee ?'
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   100
        Dialog confirmWithCancel:'Coffee ?'
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   101
                                                                        [exEnd]
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   102
    these (DialogBox) mesages are compatible with VW and should therefore
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   103
    be used for portability.
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   104
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   105
    Direct reference to YesNoBox is only required for highly specialized boxes.
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   106
82d16b9ea94d confirmBox icon (windows only)
Claus Gittinger <cg@exept.de>
parents: 2428
diff changeset
   107
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   108
    Examples:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   109
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   110
        |aBox|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   111
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   112
        aBox := YesNoBox title:'Coffee or tee ?'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   113
        aBox noText:'tee'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   114
        aBox yesText:'coffee'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   115
        aBox yesAction:[Transcript showCR:'make coffee'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   116
        aBox noAction:[Transcript showCR:'make tee'].
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   117
        aBox showAtPointer.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   118
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   119
    or, shorter:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   120
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   121
        |aBox|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   122
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   123
        aBox := YesNoBox new.
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   124
        aBox title:'Coffee or Tee?'
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   125
             yesAction:[Transcript showCR:'make coffee']
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   126
             noAction:[Transcript showCR:'make tee'].
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   127
        aBox yesText:'Coffee' noText:'Tee'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   128
        aBox showAtPointer
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   129
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   130
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   131
    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
   132
    the bitmap (default: a question mark) and other properties.
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   133
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   134
    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
   135
    #confirm method, to bring up a box, let it ask for something and return
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   136
    true or false.
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   137
    Example:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   138
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   139
        |box value|
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   140
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   141
        box := YesNoBox new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   142
        value := box confirm:'yes or no:'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   143
        value ifTrue:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   144
            Transcript showCR:'yes'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   145
        ] ifFalse:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   146
            Transcript showCR:'no'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   147
        ]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   148
                                                                        [exEnd]
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   149
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   150
    of course, this can also be written shorter as:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   151
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   152
        (YesNoBox new confirm:'yes or no:') ifTrue:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   153
            Transcript showCR:'yes'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   154
        ] ifFalse:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   155
            Transcript showCR:'no'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   156
        ]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   157
                                                                        [exEnd]
125
claus
parents: 119
diff changeset
   158
    or:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   159
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   160
        (Dialog confirm:'yes or no:') ifTrue:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   161
            Transcript showCR:'yes'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   162
        ] ifFalse:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   163
            Transcript showCR:'no'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   164
        ]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   165
                                                                        [exEnd]
6331
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   166
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   167
    or even:
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   168
                                                                        [exBegin]
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   169
        Transcript showCR:(
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   170
            (Dialog confirm:'yes or no:')   
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   171
                ifTrue:['yes'] 
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   172
                ifFalse:['no'])
08ac4c72de00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6182
diff changeset
   173
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   174
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   175
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   176
856
1b5b9d753163 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   177
!YesNoBox class methodsFor:'instance creation'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   178
1187
6f8bd39b5515 comment
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
   179
title:titleString yesText:yesString noText:noString
572
121735c2aff6 commentary
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   180
    "return a new YesNoBox with title, and buttonLabels yesString/noString"
121735c2aff6 commentary
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   181
1187
6f8bd39b5515 comment
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
   182
    ^ (self new) title:titleString yesText:yesString noText:noString
572
121735c2aff6 commentary
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   183
1187
6f8bd39b5515 comment
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
   184
    "Modified: 11.4.1997 / 21:11:45 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   185
! !
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   186
856
1b5b9d753163 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   187
!YesNoBox class methodsFor:'icon bitmap'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   188
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   189
iconBitmap
1173
86440dfaca06 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   190
    "return the bitmap shown as icon in my instances.
86440dfaca06 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   191
     This is the default image; you can overwrite this in a concrete
1187
6f8bd39b5515 comment
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
   192
     instance with the #image: message."
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   193
1365
aa6a855b5013 new resource naming
Claus Gittinger <cg@exept.de>
parents: 1187
diff changeset
   194
    <resource: #style (#'requestBox.icon' #'requestBox.iconFile')>
1173
86440dfaca06 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   195
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   196
    RequestBitmap isNil ifTrue:[
2786
06de7ca4b263 code shared
Claus Gittinger <cg@exept.de>
parents: 2785
diff changeset
   197
        RequestBitmap := self iconBitmapFromStyle:'requestBox.icon' orStyleFile:'requestBox.iconFile' orFilename:'bitmaps/Request.xbm'.
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   198
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   199
    ^ RequestBitmap
943
034b63540f10 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   200
1365
aa6a855b5013 new resource naming
Claus Gittinger <cg@exept.de>
parents: 1187
diff changeset
   201
    "Created: / 17.11.1995 / 18:16:47 / cg"
aa6a855b5013 new resource naming
Claus Gittinger <cg@exept.de>
parents: 1187
diff changeset
   202
    "Modified: / 26.10.1997 / 17:06:19 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   203
! !
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   204
856
1b5b9d753163 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   205
!YesNoBox class methodsFor:'styles'!
197
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
updateStyleCache
1173
86440dfaca06 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   208
    "extract values from the styleSheet and cache them in class variables.
86440dfaca06 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   209
     Here, the cached infoBitmap is simply flushed."
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   210
1173
86440dfaca06 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   211
    RequestBitmap := nil
444
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 373
diff changeset
   212
1173
86440dfaca06 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   213
    "Modified: 1.4.1997 / 14:51:30 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   214
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   215
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   216
!YesNoBox methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   217
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   218
initialize
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   219
    super initialize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   220
150
claus
parents: 130
diff changeset
   221
    label := resources string:'Choose'.
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   222
130
claus
parents: 125
diff changeset
   223
    buttonPanel horizontalLayout:#fitSpace.  "/ looks better; should it come from the StyleSheet ?
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   224
2428
f800d9ec09a8 upper-case
Claus Gittinger <cg@exept.de>
parents: 2361
diff changeset
   225
    textLabel label:(resources string:'Please confirm').
f800d9ec09a8 upper-case
Claus Gittinger <cg@exept.de>
parents: 2361
diff changeset
   226
    okButton label:(resources string:'Yes').
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   227
162
claus
parents: 150
diff changeset
   228
    abortButton := Button abortButton.
2304
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   229
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   230
    "/ changed:
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   231
    "/ now exclusively done by the buttonPanel itself
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   232
2698
cca702636705 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2567
diff changeset
   233
"/    (Dialog defaultOKButtonAtLeft) ifTrue:[
2304
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   234
"/        buttonPanel addSubView:abortButton after:okButton.
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   235
"/    ] ifFalse:[
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   236
"/        buttonPanel addSubView:abortButton before:okButton.
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   237
"/    ].
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   238
    buttonPanel addSubView:abortButton before:okButton.
c96b6b899023 button-roder reversal is now done exclusively in the buttonPanel
Claus Gittinger <cg@exept.de>
parents: 2074
diff changeset
   239
2428
f800d9ec09a8 upper-case
Claus Gittinger <cg@exept.de>
parents: 2361
diff changeset
   240
    abortButton label:(resources string:'No').
162
claus
parents: 150
diff changeset
   241
    abortButton height:(okButton height).
claus
parents: 150
diff changeset
   242
    abortButton model:self; change:#noPressed
856
1b5b9d753163 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   243
946
ccaa76951823 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
   244
    "Modified: 15.1.1997 / 23:32:21 / cg"
197
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
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   247
!YesNoBox methodsFor:'queries'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   248
3121
8e4d21e008c9 beep control
Claus Gittinger <cg@exept.de>
parents: 2802
diff changeset
   249
beepWhenOpening
8e4d21e008c9 beep control
Claus Gittinger <cg@exept.de>
parents: 2802
diff changeset
   250
    ^ false
8e4d21e008c9 beep control
Claus Gittinger <cg@exept.de>
parents: 2802
diff changeset
   251
!
8e4d21e008c9 beep control
Claus Gittinger <cg@exept.de>
parents: 2802
diff changeset
   252
6502
1e36a7f321dc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   253
computePreferredExtent
572
121735c2aff6 commentary
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   254
    "compute the boxes preferredExtent from the components' sizes"
121735c2aff6 commentary
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   255
6364
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   256
    |w h max mm nButtons|
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   257
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   258
    mm := ViewSpacing.
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   259
197
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
     make the two buttons of equal size
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
    "
6364
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   263
    nButtons := 2.
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   264
    max := 0.
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   265
    buttonPanel notNil ifTrue:[ 
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   266
        max := buttonPanel subViews 
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   267
                    inject:0 
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   268
                    into:[:maxSoFar :button |
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   269
                        maxSoFar max:button preferredWidth
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   270
                    ].
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   271
        nButtons := buttonPanel subViews size.           
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   272
    ].                
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   273
    max := max max:(okButton preferredWidth max:abortButton preferredWidth).
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   274
    okButton width:max.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   275
    abortButton width:max.
6364
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   276
    buttonPanel notNil ifTrue:[
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   277
        buttonPanel subViews do:[:each | each width:max].
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   278
    ].
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   279
    
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   280
    w := (formLabel width + textLabel width) max:(max * nButtons).
0524033012d2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6331
diff changeset
   281
    w := w + ((nButtons+1) * mm) + ((okButton borderWidth + abortButton borderWidth) * nButtons).
2802
19b141dd52b9 fixed preferredWidth when components were added
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   282
    w := w max:self maxPreferredWidthOfAddedComponents.
2800
25f261040a9a allow adding a (single) checkBox
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   283
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   284
    h := (mm * 5)
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   285
         + ((formLabel height) max:(textLabel height))
3616
d77444e898db added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3356
diff changeset
   286
         + ((addedComponents ? #()) inject:0 into:[:sum :thisComponent | sum + thisComponent preferredHeight])
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   287
         + okButton heightIncludingBorder.
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   288
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   289
    ^ (w @ h).
373
da46657e62bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   290
6502
1e36a7f321dc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6364
diff changeset
   291
    "Created: / 09-11-2018 / 20:04:33 / Claus Gittinger"
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   292
! !
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   293
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   294
!YesNoBox methodsFor:'startup'!
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   295
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   296
confirm
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   297
    "open the receiver and return true for yes, false for no.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   298
     This is an easier interface to use, since no action blocks
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   299
     have to be defined. The title is used as previously defined."
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   300
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   301
    self yesAction:[^ true] noAction:[^ false].
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   302
    self showAtPointer.
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   303
    self yesAction:nil noAction:nil. "/ clear actions for earlier release of context
6182
46362930b07b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
   304
    "/ not reached
46362930b07b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
   305
    ^ false
46362930b07b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
   306
    
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   307
    "
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   308
     YesNoBox new confirm
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   309
    "
6182
46362930b07b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
   310
46362930b07b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6174
diff changeset
   311
    "Modified (comment): / 16-07-2017 / 14:03:23 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   312
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   313
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   314
confirm:aString
3356
4a1ab6d0be69 comment
Claus Gittinger <cg@exept.de>
parents: 3121
diff changeset
   315
    "open a modal yes-no dialog.
4a1ab6d0be69 comment
Claus Gittinger <cg@exept.de>
parents: 3121
diff changeset
   316
     Return true for yes, false for no.
4a1ab6d0be69 comment
Claus Gittinger <cg@exept.de>
parents: 3121
diff changeset
   317
     This is an easier interface to use, since no action blocks have to be defined."
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 9
diff changeset
   318
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   319
    self title:aString.
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   320
    ^ self confirm
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   321
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   322
    "
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   323
     YesNoBox new confirm:'really?'
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   324
     YesNoBox confirm:'really?'
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   325
     self confirm:'really?'
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   326
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   327
    for ST-80 compatibility, you should use Dialogs confirm
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   328
    (which simply forwards the request to the YesNoBox anyway):
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   329
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   330
     Dialog confirm:'really?'
59
450ce95a72a4 *** empty log message ***
claus
parents: 55
diff changeset
   331
    "
253
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   332
f071ff350cd5 added confirm with button-labels
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   333
    "Modified: 13.12.1995 / 16:20:01 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   334
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   335
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   336
!YesNoBox methodsFor:'user interaction'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   337
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   338
noPressed
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   339
    "user pressed the no-button;
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   340
     hide myself and evaluate the action"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   341
162
claus
parents: 150
diff changeset
   342
    abortButton turnOffWithoutRedraw.
claus
parents: 150
diff changeset
   343
    self hideAndEvaluate:abortAction
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   344
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   345
856
1b5b9d753163 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   346
!YesNoBox class methodsFor:'documentation'!
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   347
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   348
version
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   349
    ^ '$Header$'
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   350
! !
5895
81e95a291980 #OTHER by mawalch
mawalch
parents: 3766
diff changeset
   351