OptionBox.st
author Claus Gittinger <cg@exept.de>
Sat, 11 May 2019 12:15:03 +0200
changeset 6578 60be865bd75a
parent 6499 82f16794a274
child 6651 226b0380aadf
permissions -rw-r--r--
#QUALITY by cg class: Button changed: #activeLogo: #enteredLogo: #passiveLogo:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
     1
"{ Encoding: utf8 }"
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
     2
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     3
"
5
claus
parents: 3
diff changeset
     4
 COPYRIGHT (c) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
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
"
2212
7475e8be57bb recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    14
"{ Package: 'stx:libwidg' }"
7475e8be57bb recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
    15
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
    16
"{ NameSpace: Smalltalk }"
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
    17
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    18
DialogBox subclass:#OptionBox
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    19
	instanceVariableNames:'labelPanel formLabel textLabel textView buttons actions
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    20
		defaultButtonIndex'
6235
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
    21
	classVariableNames:'WarnBitmap InfoBitmap YesNoBitmap'
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    22
	poolDictionaries:''
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    23
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    24
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    25
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    26
!OptionBox class methodsFor:'documentation'!
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    27
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    28
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    29
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    30
 COPYRIGHT (c) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    31
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    32
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    33
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    34
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    36
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    37
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    38
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    39
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    40
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    41
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    42
documentation
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    43
"
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    44
   CAVEAT: this is a leftover - functionality has been merged into DialogBox
3936
01654678a889 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
    45
   PLEASE use one of the `Dialog chooseXXX' methods instead of OptionBox.
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    46
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    47
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    48
   Historic note:
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    49
      originally, ST/X had separate classes for the various entry methods;
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    50
      there were YesNoBox, EnterBox, InfoBox and so on.
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    51
      In the meantime, the DialogBox class (and therefore its alias: Dialog)
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
    52
      is going to duplicate most functionality found in these classes.
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    53
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    54
      In the future, those existing subclasses' functionality is going to
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    55
      be moved fully into Dialog, and the subclasses will be replaced by dummy
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    56
      delegators. (They will be kept for backward compatibility, though).
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    57
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    58
    Description:
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    59
      OptionBoxes are like YesNoBoxes but with as many buttons as you like;
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    60
      this will finally be a superclass of WarnBox and YesNoBox - or maybe merged
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    61
      all into DialogBox..
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    62
      Use them for multiway questions.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    63
      For a consistent user interface, the rightmost (last) button should be the default return
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    64
      button (i.e. pressing return in the box performs this buttons function).
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    65
      However, this is reversed automatically if the viewStyle says so (Windows vs. OSX vs. Linux),
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    66
      so the programmer MUST always put the no-actions (i.e. cancel) first and the ok-actions (yes) last.
91
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
    67
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    68
    [author:]
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    69
        Claus Gittinger
91
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
    70
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    71
    [see also:]
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    72
        DialogBox
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    73
"
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    74
!
91
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
    75
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    76
examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    77
"
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    78
 just opening 
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    79
 (not real world examples, as you'd have to ask the box instance about the choice afterwards;
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    80
  see better usage examples below):
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    81
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    82
    |box|
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
    83
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    84
    box := OptionBox title:'hello' numberOfOptions:4.
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    85
    box showAtPointer
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    86
                                                                        [exEnd]
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
    87
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
    88
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    89
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    90
    |box|
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    91
    box := OptionBox title:'hello'.
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    92
    box buttonTitles:#('one' 'two' 'three').
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    93
    box defaultButtonIndex:3.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    94
    box showAtPointer
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    95
                                                                        [exEnd]
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    96
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    97
 showing a long list:                                                                    
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    98
                                                                        [exBegin]
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
    99
    |box|
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   100
    box := OptionBox title:(1 to:100 collect:#asString) numberOfOptions:3.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   101
    box buttonTitles:#('one' 'two' 'three').
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   102
    box defaultButtonIndex:3.
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   103
    box showAtPointer
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   104
                                                                        [exEnd]
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   105
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   106
 performing an action:
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   107
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   108
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   109
    |box|
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   110
    box := OptionBox title:'hello' numberOfOptions:3.
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   111
    box buttonTitles:#('one' 'two' 'three').
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   112
    box action:[:which | Transcript show:'button ';
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   113
                                    show: which;
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   114
                                    showCR:' was pressed'].
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   115
    box showAtPointer
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   116
                                                                        [exEnd]
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   117
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   118
 returning a value:
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   119
                                                                        [exBegin]
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   120
    |what|
133
claus
parents: 132
diff changeset
   121
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   122
    what := OptionBox
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   123
                  request:('text has not been accepted.\\Your modifications will be lost when continuing.') withCRs
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   124
                  label:' Attention'
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   125
                  image:(WarningBox iconBitmap)
3211
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   126
                  buttonLabels:#('Abort' 'Accept' 'Continue')
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   127
                  values:#(#abort #accept #continue).
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   128
    Transcript showCR:what.
646
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   129
                                                                        [exEnd]
3211
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   130
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   131
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   132
 use callBack-hook to intercept creation:
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   133
                                                                        [exBegin]
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   134
    |what|
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   135
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   136
    AboutToOpenBoxNotificationSignal handle:[:ex |
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   137
        |box|
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   138
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   139
        box := ex parameter.
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   140
        box verticalPanel
3211
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   141
            add:(CheckBox label:'Do no show this Dialog again.'
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   142
                          model:false asValue).
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   143
        ex proceed.
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   144
    ] do:[
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   145
        what := OptionBox
3211
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   146
                      request:('bla bla bla bla.\\You must bla bla bla!!') withCRs
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   147
                      label:' Attention'
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   148
                      image:(WarningBox iconBitmap)
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   149
                      buttonLabels:#('Abort' 'Accept' 'Continue')
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   150
                      values:#(#abort #accept #continue)
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   151
                      default:#continue.
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   152
    ].
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   153
    Transcript showCR:what.
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   154
                                                                        [exEnd]
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   155
"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   156
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   157
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   158
!OptionBox class methodsFor:'instance creation'!
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   159
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   160
title:titleString
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   161
    "create a new optionBox with title, aTitleString"
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   162
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   163
    |box|
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   164
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   165
    box := self basicNew.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   166
    box device:Screen current.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   167
    box initialize.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   168
    box title:titleString.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   169
    ^ box
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   170
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   171
    "Created: / 26-10-2018 / 10:56:42 / Claus Gittinger"
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   172
!
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   173
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   174
title:titleString numberOfOptions:nOptions
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   175
    "create a new optionBox with title, aTitleString and nOptions options"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   176
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   177
    |box|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   178
5027
d9c7b4ccfeff class: OptionBox
Stefan Vogel <sv@exept.de>
parents: 5026
diff changeset
   179
    box := self basicNew numberOfOptions:nOptions.
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   180
    box device:Screen current.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   181
    box initialize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   182
    box title:titleString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   183
    ^ box
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   184
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   185
    "Modified (comment): / 26-10-2018 / 10:56:48 / Claus Gittinger"
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   186
! !
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   187
2449
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2405
diff changeset
   188
!OptionBox class methodsFor:'easy startup'!
95
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   189
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   190
forRequest:title label:label image:anImage buttonLabels:labels values:values default:defaultValue
2585
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   191
    "create a new optionBox and return it.
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   192
     Does not open the box."
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   193
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   194
    |box|
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   195
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   196
    box := OptionBox title:title numberOfOptions:(labels size).
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   197
    box buttonTitles:labels.
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   198
    box defaultButtonIndex:(values indexOf:defaultValue).
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   199
    box label:label; image:anImage.
2898
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   200
    values keysAndValuesDo:[:idx :val |
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   201
        val == false ifTrue:[
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   202
            (box buttons at:idx) cursor:(Cursor thumbsDown).
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   203
        ].
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   204
        val == true ifTrue:[
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   205
            (box buttons at:idx) cursor:(Cursor thumbsUp).
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   206
        ].
b7ba089497d6 thumbsUp/down
Claus Gittinger <cg@exept.de>
parents: 2711
diff changeset
   207
    ].
2585
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   208
    ^ box
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   209
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   210
    "Modified: / 23.2.2000 / 11:59:32 / cg"
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   211
!
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   212
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   213
request:title buttonLabels:labels values:values
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   214
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   215
     the corresponding values collection. Return nil if canceled"
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   216
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   217
    ^ self
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   218
        request:title
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   219
        label:title
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   220
        buttonLabels:labels
4223
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   221
        values:values
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   222
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   223
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   224
     OptionBox
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   225
        request:'please select any'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   226
        buttonLabels:#('one' 'two' 'three')
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   227
        values:#(1 2 3)
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   228
    "
4223
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   229
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   230
    "Modified: / 08-02-2011 / 11:22:13 / cg"
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   231
    "Modified (comment): / 24-08-2017 / 15:03:02 / cg"
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   232
!
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   233
2669
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   234
request:title buttonLabels:labels values:values default:defaultValue
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   235
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   236
     the corresponding values collection. Return nil if canceled."
2669
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   237
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   238
    ^ self
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   239
        request:title label:title image:(YesNoBox iconBitmap) buttonLabels:labels values:values
2711
e18e9edca978 by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents: 2700
diff changeset
   240
        default:defaultValue onCancel:nil
2669
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   241
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   242
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   243
     OptionBox
2669
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   244
        request:'please select'
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   245
        buttonLabels:#('one' 'two' 'three')
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   246
        values:#(1 2 3)
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   247
        default:3
2669
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   248
    "
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   249
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   250
    "Modified (comment): / 24-08-2017 / 15:03:07 / cg"
2669
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   251
!
182aa7a00d83 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2668
diff changeset
   252
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   253
request:title label:label buttonLabels:labels values:values
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   254
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   255
     the corresponding values collection. Return nil if canceled"
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   256
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   257
    ^ self
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   258
        request:title
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   259
        label:label
4224
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
   260
        image:(YesNoBox iconBitmap)
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   261
        buttonLabels:labels
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   262
        values:values
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   263
        default:nil
4224
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
   264
        onCancel:nil
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   265
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   266
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   267
     OptionBox
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   268
        request:'please select'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   269
        label:'select any'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   270
        buttonLabels:#('one' 'two' 'three')
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   271
        values:#(1 2 3)
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   272
    "
4224
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
   273
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
   274
    "Modified: / 08-02-2011 / 11:32:48 / cg"
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   275
    "Modified (comment): / 24-08-2017 / 15:03:10 / cg"
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   276
!
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   277
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   278
request:title label:label buttonLabels:labels values:values default:defaultValue
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   279
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   280
     the corresponding values collection. Return nil if canceled"
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   281
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   282
    ^ self
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   283
        request:title label:label image:(YesNoBox iconBitmap) buttonLabels:labels values:values
2711
e18e9edca978 by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents: 2700
diff changeset
   284
        default:defaultValue onCancel:nil
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   285
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   286
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   287
     OptionBox
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   288
        request:'please select'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   289
        label:'select any'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   290
        buttonLabels:#('one' 'two' 'three')
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   291
        values:#(1 2 3)
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   292
        default:3
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   293
    "
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   294
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   295
    "Modified (comment): / 24-08-2017 / 15:03:15 / cg"
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   296
!
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   297
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   298
request:title label:label buttonLabels:labels values:values default:defaultValue onCancel:cancelValue
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   299
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   300
     the corresponding values collection. Return cancelValue if canceled."
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   301
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   302
    ^ self
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   303
        request:title label:label image:(YesNoBox iconBitmap) buttonLabels:labels values:values
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   304
        default:defaultValue onCancel:cancelValue
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   305
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   306
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   307
     OptionBox
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   308
        request:'please select'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   309
        label:'select any'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   310
        buttonLabels:#('one' 'two' 'three')
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   311
        values:#(1 2 3)
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   312
        default:3
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   313
        onCancel:2
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   314
    "
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   315
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   316
    "Modified (comment): / 24-08-2017 / 15:03:18 / cg"
2405
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   317
!
dcdb739b64f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2390
diff changeset
   318
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   319
request:title label:label image:anImage buttonLabels:labels values:values
133
claus
parents: 132
diff changeset
   320
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   321
     the corresponding values collection. Return nil, if canceled."
133
claus
parents: 132
diff changeset
   322
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   323
    ^ self
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   324
        request:title label:label image:anImage buttonLabels:labels values:values
2711
e18e9edca978 by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents: 2700
diff changeset
   325
        default:nil onCancel:nil
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   326
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   327
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   328
     OptionBox
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   329
        request:'please select'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   330
        label:'select any'
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   331
        image:(WarningBox iconBitmap)
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   332
        buttonLabels:#('one' 'two' 'three')
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   333
        values:#(1 2 3)
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   334
    "
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   335
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   336
    "Modified (comment): / 24-08-2017 / 15:03:31 / cg"
133
claus
parents: 132
diff changeset
   337
!
claus
parents: 132
diff changeset
   338
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   339
request:title label:label image:anImage buttonLabels:labels values:values default:defaultValue
95
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   340
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   341
     the corresponding values collection. Return nil if canceled."
95
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   342
2390
0a72663d8e59 added onCancel: value
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
   343
    ^ self
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   344
        request:title label:label image:anImage buttonLabels:labels values:values
2711
e18e9edca978 by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents: 2700
diff changeset
   345
        default:defaultValue onCancel:nil
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   346
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   347
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   348
     OptionBox
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   349
        request:'please select'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   350
        label:'select any'
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   351
        image:(WarningBox iconBitmap)
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   352
        buttonLabels:#('one' 'two' 'three')
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   353
        values:#(1 2 3)
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   354
        default:3
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   355
    "
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   356
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   357
    "Modified (comment): / 24-08-2017 / 15:03:34 / cg"
2390
0a72663d8e59 added onCancel: value
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
   358
!
0a72663d8e59 added onCancel: value
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
   359
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   360
request:title label:label image:anImage buttonLabels:labels values:values default:defaultValue onCancel:cancelValue
2390
0a72663d8e59 added onCancel: value
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
   361
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   362
     the corresponding values collection. Return cancelValue if canceled."
2390
0a72663d8e59 added onCancel: value
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
   363
2162
9ef1004f8e74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   364
    |box retVal|
95
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   365
2390
0a72663d8e59 added onCancel: value
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
   366
    retVal := cancelValue.
2585
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   367
    box := self
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   368
                forRequest:title
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   369
                label:label
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   370
                image:anImage
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   371
                buttonLabels:labels
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   372
                values:values
2585
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   373
                default:defaultValue.
bc342ad3c166 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2523
diff changeset
   374
2162
9ef1004f8e74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   375
    box action:[:n | retVal := values at:n].
3211
54cb5fb7fd2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3208
diff changeset
   376
    self showAndThenDestroyBox:box.
2389
ca78debb0223 return nil if cancelled
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   377
2162
9ef1004f8e74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   378
    ^ retVal
95
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   379
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   380
    "
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   381
     OptionBox
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   382
        request:'please select'
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   383
        label:'select any'
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   384
        image:(WarningBox iconBitmap)
2668
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   385
        buttonLabels:#('one' 'two' 'three')
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   386
        values:#(1 2 3)
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   387
        default:3
c8655a5eb411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2585
diff changeset
   388
        onCancel:nil
95
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   389
    "
920
8487cf717bdf destroy the box after use
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   390
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   391
    "Modified: / 23-02-2000 / 11:59:32 / cg"
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   392
    "Modified (comment): / 24-08-2017 / 15:03:36 / cg"
95
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   393
! !
7535cfca9509 *** empty log message ***
claus
parents: 91
diff changeset
   394
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   395
!OptionBox class methodsFor:'obsolete'!
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   396
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   397
forRequest:title label:label form:anImage buttonLabels:labels values:values default:defaultValue
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   398
    "create a new optionBox and return it.
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   399
     Does not open the box."
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   400
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   401
    <resource:#obsolete>
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   402
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   403
    self forRequest:title label:label image:anImage buttonLabels:labels values:values default:defaultValue
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   404
!
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   405
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   406
request:title label:label form:aForm buttonLabels:labels values:values
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   407
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   408
     the corresponding values collection. Return nil, if canceled."
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   409
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   410
    <resource:#obsolete>
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   411
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   412
    ^ self
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   413
        request:title label:label image:aForm buttonLabels:labels values:values
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   414
        default:nil onCancel:nil
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   415
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   416
    "Modified (comment): / 24-08-2017 / 15:03:22 / cg"
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   417
!
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   418
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   419
request:title label:label form:aForm buttonLabels:labels values:values default:defaultValue
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   420
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   421
     the corresponding values collection. Return nil if canceled."
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   422
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   423
    <resource:#obsolete>
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   424
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   425
    ^ self
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   426
        request:title
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   427
        label:label
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   428
        image:aForm
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   429
        buttonLabels:labels
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   430
        values:values
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   431
        default:defaultValue
2991
f8ba5fe56ea6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2969
diff changeset
   432
        onCancel:nil
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   433
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   434
    "Modified (comment): / 24-08-2017 / 15:03:25 / cg"
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   435
!
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   436
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   437
request:title label:label form:aForm buttonLabels:labels values:values default:defaultValue onCancel:cancelValue
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   438
    "create a new optionBox, open it modal and return the value of
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   439
     the corresponding values collection. Return cancelValue if canceled."
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   440
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   441
    <resource:#obsolete>
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   442
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   443
    ^ self request:title label:label image:aForm buttonLabels:labels values:values default:defaultValue onCancel:cancelValue
6196
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   444
2ce864a88bb4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   445
    "Modified (comment): / 24-08-2017 / 15:03:28 / cg"
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   446
! !
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   447
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   448
!OptionBox methodsFor:'accessing'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   449
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   450
action:actionBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   451
    "define a single the action for all buttons.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   452
     The action will be evaluated with the button index as argument."
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   453
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   454
    buttons keysAndValuesDo:[:index :button |
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   455
	button action:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   456
		       button turnOffWithoutRedraw.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   457
		       self hide.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   458
		       actionBlock value:index
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   459
		      ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   460
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   461
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   462
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   463
actions:actionBlocks
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   464
    "define the actions"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   465
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   466
    actions := actionBlocks
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   467
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   468
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   469
buttonTitles:titles actions:actionBlocks
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   470
    "define both button titles and actions"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   471
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   472
    self buttonTitles:titles.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   473
    actions := actionBlocks.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   474
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   475
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   476
defaultButtonIndex:index
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   477
    "define which button is the default (i.e. return-) button.
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   478
     By default, no returnButton is setup. 
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   479
     The argument must be an index 1..nButtons, or nil"
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   480
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   481
    defaultButtonIndex notNil ifTrue:[
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   482
        (buttons at:defaultButtonIndex) isReturnButton:false
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   483
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   484
    (index notNil and:[index ~~ 0]) ifTrue:[
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   485
        defaultButtonIndex := index.
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   486
        defaultButtonIndex notNil ifTrue:[
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   487
            (buttons at:defaultButtonIndex) isReturnButton:true
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   488
        ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   489
    ]
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   490
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   491
    "Modified: / 18-10-1996 / 14:53:36 / cg"
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   492
    "Modified (comment): / 26-10-2018 / 10:53:10 / Claus Gittinger"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   493
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   494
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   495
numberOfOptions
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   496
    "return the number of options"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   497
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   498
    ^ buttons size
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   499
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   500
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   501
numberOfOptions:nOptions
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   502
    "set the number of options - this is a private interface"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   503
5109
a81f7224bed4 class: OptionBox
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   504
    buttons := OrderedCollection newWithSize:nOptions.
a81f7224bed4 class: OptionBox
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   505
    actions := OrderedCollection newWithSize:nOptions
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   506
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   507
    "Modified: 18.10.1996 / 14:54:30 / cg"
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   508
! !
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   509
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   510
!OptionBox methodsFor:'accessing-components'!
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   511
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   512
buttons
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   513
    "return the buttons collection"
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   514
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   515
    ^ buttons
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   516
!
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   517
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   518
labelPanel
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   519
    ^ labelPanel
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   520
! !
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   521
2227
58426f7611f2 category changes
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   522
!OptionBox methodsFor:'accessing-look'!
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   523
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   524
buttonTitles:titles
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   525
    "set the button titles"
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   526
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   527
    buttons isNil ifTrue:[ self numberOfOptions:titles size; initializeButtons ].
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   528
    
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   529
    titles keysAndValuesDo:[:index :aString |
3733
1ff480685a0b button name including button index
fm
parents: 3613
diff changeset
   530
        |b|
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   531
3733
1ff480685a0b button name including button index
fm
parents: 3613
diff changeset
   532
        (b := buttons at:index) label:aString.
1ff480685a0b button name including button index
fm
parents: 3613
diff changeset
   533
        b name: (b name? ''), index printString.
1ff480685a0b button name including button index
fm
parents: 3613
diff changeset
   534
        b resize.
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   535
    ].
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   536
    shown ifTrue:[self resize]
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   537
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   538
    "Modified: / 26-10-2018 / 11:02:48 / Claus Gittinger"
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   539
!
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   540
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   541
form:aFormOrImage
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   542
    "historical leftover - define a form to be displayed left of the title"
2212
7475e8be57bb recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   543
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   544
    <resource:#obsolete>
2212
7475e8be57bb recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents: 2162
diff changeset
   545
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   546
    self image:aFormOrImage
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   547
!
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   548
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   549
formLabel
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   550
    "return the label-view which displays a bitmap"
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   551
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   552
    ^ formLabel
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   553
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   554
2476
7fb8b94e650c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   555
image:aFormOrImage
7fb8b94e650c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   556
    "set the image shown in the label-view"
7fb8b94e650c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   557
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   558
    |mm|
2476
7fb8b94e650c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   559
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   560
    mm := ViewSpacing.
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   561
    formLabel label:aFormOrImage.
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   562
    textLabel origin:((mm + formLabel width + mm) @ mm).
2476
7fb8b94e650c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   563
!
7fb8b94e650c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   564
2328
07521b0760e7 access to textLabel
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   565
textLabel
07521b0760e7 access to textLabel
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   566
    "return the label-view which displays a message string"
07521b0760e7 access to textLabel
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   567
07521b0760e7 access to textLabel
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   568
    ^ textLabel
07521b0760e7 access to textLabel
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   569
!
07521b0760e7 access to textLabel
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   570
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   571
title:aStringOrStringCollection
16
83d4f5c6f76c *** empty log message ***
claus
parents: 7
diff changeset
   572
    "set the boxes title"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   573
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   574
    |textShown lines|
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   575
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   576
    aStringOrStringCollection isString ifTrue:[
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   577
        textShown := aStringOrStringCollection withoutSeparators.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   578
    ] ifFalse:[
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   579
        textShown := aStringOrStringCollection asStringCollection.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   580
    ].        
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   581
    textShown ~= textLabel label ifTrue:[
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   582
        (lines := textShown asStringCollection) size > 25 ifTrue:[
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   583
            verticalPanel verticalLayout:#topFit.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   584
            textLabel label:''.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   585
            labelPanel height:(labelPanel preferredHeight).
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   586
            textView beVisible.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   587
            textLabel beInvisible.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   588
            textView contents:lines.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   589
        ] ifFalse:[
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   590
            textView beInvisible.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   591
            textLabel beVisible.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   592
            textLabel label:textShown.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   593
            textLabel forceResize.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   594
        ].
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   595
        shown ifTrue:[self resize]
16
83d4f5c6f76c *** empty log message ***
claus
parents: 7
diff changeset
   596
    ]
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   597
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   598
    "Modified: / 26-10-2018 / 10:46:16 / Claus Gittinger"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   599
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   600
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   601
title:aString numberOfOptions:nOptions
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   602
    "set the boxes title and number of options"
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   603
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   604
    self title:aString.
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   605
    buttons grow:nOptions.
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   606
    actions grow:nOptions
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   607
! !
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   608
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   609
!OptionBox methodsFor:'events'!
77
565b052f5277 *** empty log message ***
claus
parents: 63
diff changeset
   610
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   611
keyPress:aKey x:x y:y
2700
d6bc43ddc80f Spelling (du Dubl!)
Stefan Vogel <sv@exept.de>
parents: 2669
diff changeset
   612
    "return-key duplicates ok-function if acceptReturnAsOK is true"
77
565b052f5277 *** empty log message ***
claus
parents: 63
diff changeset
   613
4490
db468327af5d class: OptionBox
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   614
"/    <resource: #keyboard (#Return)>
490
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
   615
3804
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   616
"/ now done by keyboard processor
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   617
"/    |action|
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   618
"/
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   619
"/    defaultButtonIndex notNil ifTrue:[
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   620
"/        (aKey == #Return) ifTrue:[
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   621
"/            self hide.
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   622
"/            action := actions at:defaultButtonIndex.
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   623
"/            action value
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   624
"/        ]
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   625
"/    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   626
    super keyPress:aKey x:x y:y
490
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
   627
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
   628
    "Modified: 7.3.1996 / 13:17:36 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   629
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   630
2523
c10ebb01ab09 category rename
Claus Gittinger <cg@exept.de>
parents: 2476
diff changeset
   631
!OptionBox methodsFor:'initialization'!
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   632
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   633
initFormBitmap
6235
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   634
    self initYesNoBitmap
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   635
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   636
    "Modified: / 28-11-2017 / 14:33:16 / cg"
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   637
!
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   638
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   639
initInfoBitmap
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   640
    InfoBitmap isNil ifTrue:[
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   641
        InfoBitmap := InfoBox iconBitmap.
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   642
    ].
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   643
    formLabel label:InfoBitmap
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   644
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   645
    "Created: / 28-11-2017 / 14:31:51 / cg"
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   646
!
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   647
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   648
initWarnBitmap
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   649
    WarnBitmap isNil ifTrue:[
1914
f337a7fd99f5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1612
diff changeset
   650
        WarnBitmap := WarningBox iconBitmap.
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   651
"/        WarnBitmap := Image fromFile:'bitmaps/Warning.xbm' resolution:100 on:Display
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   652
    ].
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2898
diff changeset
   653
    formLabel label:WarnBitmap
899
aa84d3d39d94 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 847
diff changeset
   654
6235
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   655
    "Created: / 28-11-2017 / 14:31:31 / cg"
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   656
!
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   657
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   658
initYesNoBitmap
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   659
    YesNoBitmap isNil ifTrue:[
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   660
        YesNoBitmap := YesNoBox iconBitmap.
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   661
    ].
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   662
    formLabel label:YesNoBitmap
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   663
c9af202cf052 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6196
diff changeset
   664
    "Created: / 28-11-2017 / 14:32:45 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   665
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   666
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   667
initialize
4383
7d374bd7b21c changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 4382
diff changeset
   668
    |mm vPanelLayout|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   669
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   670
    super initialize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   671
372
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   672
    mm := ViewSpacing.
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   673
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   674
    verticalPanel := VerticalPanelView in:self.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   675
    vPanelLayout := LayoutFrame origin:(mm @ mm) corner:(1.0@1.0).
4903
22f1ae0f9268 class: OptionBox
Stefan Vogel <sv@exept.de>
parents: 4490
diff changeset
   676
    vPanelLayout bottomOffset:(gc font height + (mm * 5)) negated.
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   677
    vPanelLayout rightOffset:mm negated.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   678
    verticalPanel geometryLayout:vPanelLayout.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   679
    verticalPanel horizontalLayout:#fit.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   680
    verticalPanel verticalLayout:#bottomFit.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   681
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   682
    labelPanel := HorizontalPanelView in:verticalPanel.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   683
    labelPanel horizontalLayout:#leftSpace.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   684
    labelPanel verticalLayout:#topSpace.
3613
0a1963025199 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3260
diff changeset
   685
    labelPanel height:(labelPanel preferredHeight + (mm * 4)).
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   686
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   687
    formLabel := Label in:labelPanel.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   688
    self initFormBitmap.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   689
    formLabel borderWidth:0.
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   690
"/    formLabel origin:(mm @ mm).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   691
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   692
    textLabel := Label label:'Select' in:labelPanel.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   693
    textLabel borderWidth:0.
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   694
"/    textLabel origin:((mm + formLabel width + mm) @ mm).
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   695
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   696
    textView := ScrollableView for:TextView in:verticalPanel.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   697
    textView backgroundColor:(textLabel backgroundColor).
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   698
    textView viewBackground:(textLabel viewBackground).
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   699
    textView borderWidth:0.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   700
    textView hiddenOnRealize:true.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   701
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   702
    verticalPanel resize.
4383
7d374bd7b21c changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 4382
diff changeset
   703
    "/ cannot be done here - verticalPanel still has its defaul height and may be
7d374bd7b21c changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 4382
diff changeset
   704
    "/ not yet filled...
7d374bd7b21c changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 4382
diff changeset
   705
    "/ yPosition := verticalPanel height + (mm * 3).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   706
1612
e7d3bc88a533 oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   707
"/    buttonPanel isNil ifTrue:[
e7d3bc88a533 oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   708
"/        buttonPanel := HorizontalPanelView origin:(0.0 @ 1.0) corner:(1.0 @ 1.0) in:self.
e7d3bc88a533 oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   709
"/    ].
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   710
    buttonPanel
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   711
        bottomInset:0 "mm";
5916
d00575627127 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5893
diff changeset
   712
        topInset:(gc font height + (mm * 4) + ViewSpacing + ViewSpacing) negated.
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   713
    buttonPanel
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   714
        borderWidth:0;
372
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   715
        horizontalLayout:#fitSpace.
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   716
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   717
    self initializeButtons
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   718
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   719
    "
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   720
     |box|
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   721
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   722
     box := OptionBox title:'hello' numberOfOptions:4.
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   723
     box open
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   724
    "
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   725
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   726
    "Modified: / 28-02-2012 / 15:56:57 / cg"
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   727
    "Modified: / 26-10-2018 / 11:00:59 / Claus Gittinger"
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   728
!
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   729
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   730
initializeButtons
4383
7d374bd7b21c changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 4382
diff changeset
   731
    1 to:(buttons size) do:[:index |
372
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   732
        |button|
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   733
372
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   734
        button := Button label:'press'.
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   735
        button action:[
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   736
                       (buttons at:index) turnOffWithoutRedraw.
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   737
                       self hide.
3804
8a4b07e9ee4e no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents: 3757
diff changeset
   738
                       (actions at:index) value
372
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   739
                      ].
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   740
        buttonPanel addSubView:button.
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   741
        buttons at:index put:button.
91
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   742
    ].
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   743
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   744
    "/ no longer make the last button the default!!
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   745
    "/ buttons last isReturnButton:true
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   746
91
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   747
    "
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   748
     |box|
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   749
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   750
     box := OptionBox title:'hello' numberOfOptions:4.
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   751
     box open
e8db16616e97 *** empty log message ***
claus
parents: 85
diff changeset
   752
    "
372
2ee5887b00f0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   753
6468
dbd77c7b3738 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6235
diff changeset
   754
    "Created: / 26-10-2018 / 11:00:50 / Claus Gittinger"
133
claus
parents: 132
diff changeset
   755
! !
claus
parents: 132
diff changeset
   756
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   757
!OptionBox methodsFor:'queries'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   758
6499
82f16794a274 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6468
diff changeset
   759
computePreferredExtent
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   760
    "return a size to make everything fit into myself"
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   761
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   762
    |w w1 h buttonPanelsPref vPanelsPref mm|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   763
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   764
    mm := ViewSpacing.
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   765
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   766
    vPanelsPref := verticalPanel preferredExtent.
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   767
    w1 := (mm * 3) + formLabel width + textLabel width.
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   768
    buttonPanelsPref := buttonPanel preferredExtent.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   769
    w := w1 max:buttonPanelsPref x.
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   770
    w := w max:vPanelsPref x.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   771
3208
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   772
    h := mm
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   773
         + vPanelsPref y
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   774
         + mm
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   775
         + buttonPanelsPref y
7b4c5a215af9 use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
   776
         + mm.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   777
3905
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   778
    self subViews do:[:v |
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   779
        (v ~~ verticalPanel and:[v ~~ buttonPanel]) ifTrue:[
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   780
            h := h + v preferredExtent y.
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   781
            w := w max:(v preferredExtent x).
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   782
        ].
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   783
    ].
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   784
6499
82f16794a274 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6468
diff changeset
   785
    preferredExtent := super computePreferredExtent max:(w @ h).
3905
9005cad02a02 preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   786
    ^ preferredExtent
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   787
6499
82f16794a274 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6468
diff changeset
   788
    "Created: / 09-11-2018 / 19:58:19 / Claus Gittinger"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   789
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   790
847
0d760cfc9a8c commentary
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   791
!OptionBox class methodsFor:'documentation'!
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   792
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   793
version
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   794
    ^ '$Header$'
4223
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   795
!
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   796
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   797
version_CVS
5893
01e54cac0ec3 #OTHER by mawalch
mawalch
parents: 5109
diff changeset
   798
    ^ '$Header$'
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   799
! !
4490
db468327af5d class: OptionBox
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   800