TextBox.st
author Claus Gittinger <cg@exept.de>
Fri, 28 Jun 2019 09:21:50 +0200
changeset 6078 08c9e2a47dc5
parent 6075 0c168e2e1937
child 6080 a90e3bbb4c79
permissions -rw-r--r--
#OTHER by cg self class name -> self className
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5932
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
     1
"{ Encoding: utf8 }"
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
     2
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
     3
"
4
claus
parents: 2
diff changeset
     4
 COPYRIGHT (c) 1992 by Claus Gittinger
26
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
     5
	      All Rights Reserved
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
     6
0fd7841626f6 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
0fd7841626f6 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
0fd7841626f6 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    13
"
2088
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
    15
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
    16
"{ NameSpace: Smalltalk }"
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
    17
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    18
EnterBox subclass:#TextBox
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
    19
	instanceVariableNames:'textViewClass textView'
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    20
	classVariableNames:''
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    21
	poolDictionaries:''
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    22
	category:'Views-DialogBoxes'
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    23
!
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    24
13
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    25
!TextBox class methodsFor:'documentation'!
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    26
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    27
copyright
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    28
"
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    29
 COPYRIGHT (c) 1992 by Claus Gittinger
26
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
    30
	      All Rights Reserved
13
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    31
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    32
 This software is furnished under a license and may be used
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    33
 only in accordance with the terms of that license and with the
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    35
 be provided or otherwise made available to, or used by, any
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    36
 other person.  No title to or ownership of the software is
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    37
 hereby transferred.
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    38
"
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    39
!
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    40
13
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    41
documentation
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    42
"
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    43
    this class implements a pop-up box to enter some text with 2 buttons,
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    44
    one to cancel, another to start some action.
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    45
    It is basically an enterBox, but allows entering of more than one line
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    46
    of text.
26
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
    47
"
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
    48
!
13
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    49
26
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
    50
examples
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
    51
"
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    52
  Example (using ok-action callBack):
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    53
                                                                        [exBegin]
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    54
    |textBox|
13
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    55
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    56
    textBox := TextBox new.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    57
    textBox title:'enter some text'.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    58
    textBox action:[:text | Transcript showCR:('the entered text was:\' , text) withCRs].
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    59
    textBox showAtPointer.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    60
                                                                        [exEnd]
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    61
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    62
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    63
  Example (asking afterwards):
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    64
                                                                        [exBegin]
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    65
    |textBox|
13
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    66
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    67
    textBox := TextBox new.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    68
    textBox title:'enter some text'.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    69
    textBox showAtPointer.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    70
    textBox accepted ifTrue:[
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    71
        Transcript showCR:'accepted text is:'.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    72
        Transcript showCR:textBox contents
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    73
    ].
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    74
                                                                        [exEnd]
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    75
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    76
  Example - readonly text (useful for status display):
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    77
                                                                        [exBegin]
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    78
    |textBox|
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    79
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    80
    textBox := TextBox new.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    81
    textBox initialText:('Makefile' asFilename contents).
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    82
    textBox title:'Makefile:'.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    83
    textBox readOnly:true.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    84
    textBox noCancel.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    85
    textBox label:'Makefile'.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    86
    textBox extent:(600@250); sizeFixed:true.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    87
    textBox showAtPointer.
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    88
                                                                        [exEnd]
13
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    89
"
a6185c5180a1 2.10.3 pre-final version
claus
parents: 4
diff changeset
    90
! !
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
    91
1654
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
    92
!TextBox class methodsFor:'common dialogs'!
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
    93
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
    94
openOn:someText
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
    95
    "open a textBox on some text, 
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
    96
     return (the possibly modified) text if accepted; nil otherwise."
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
    97
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
    98
    ^ self openOn:someText title:'Enter Text:'
2088
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
    99
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   100
    "
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   101
     TextBox openOn:'hello'
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   102
    "
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   103
!
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   104
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   105
openOn:someText title:titleString
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   106
    "open a textBox on some text, the titleString is shown above the text area as information 
2088
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   107
     return (the possibly modified) text if accepted; nil otherwise."
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   108
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   109
    ^ self openOn:someText title:titleString readOnly:false
1654
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
   110
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   111
"/    |box returnValue|
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   112
"/
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   113
"/    box := self new.
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   114
"/    box title:titleString.
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   115
"/    box initialText:someText.
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   116
"/    box action:[:text | returnValue := text].
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   117
"/    box showAtPointer.
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   118
"/    ^ returnValue.
1654
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
   119
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
   120
    "
2088
c8a9d7712cc2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
   121
     TextBox openOn:'hello' title:'hi there'
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   122
     TextBox openOn:'hello' title:'hi there
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   123
this is a very long title
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   124
but only the first line is shown in the
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   125
caption.
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   126
'
1654
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
   127
    "
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   128
!
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   129
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   130
openOn:someText title:titleString readOnly:readOnly
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   131
    "open a textBox on some text, 
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   132
     return (the possibly modified) text if accepted; nil otherwise."
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   133
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   134
    ^ self 
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   135
        openOn:someText 
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   136
        title:titleString 
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   137
        windowTitle:nil 
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   138
        readOnly:readOnly
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   139
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   140
    "
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   141
     TextBox openOn:'hello' title:'hi there' readOnly:true
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   142
     TextBox openOn:'hello' title:'hi there' readOnly:false
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   143
    "
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   144
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   145
    "Created: / 29-10-2010 / 17:10:04 / cg"
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   146
!
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   147
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   148
openOn:someText title:titleString windowTitle:windowTitle readOnly:readOnly
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   149
    "open a textBox on some text, the optional titleString is shown as label
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   150
     above the text areay. The optional windowTitle is used as title in the caption.        
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   151
     return (the possibly modified) text if accepted; nil otherwise."
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   152
6075
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   153
    ^ self new 
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   154
        openOn:someText title:titleString windowTitle:windowTitle readOnly:readOnly
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   155
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   156
    "
4753
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   157
     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:true
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   158
     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:false
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   159
     TextBox openOn:'hello' title:'hi there' windowTitle:nil readOnly:false
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   160
     TextBox openOn:'hello' title:nil windowTitle:'some Box' readOnly:false
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   161
     TextBox openOn:'hello' title:nil windowTitle:nil readOnly:false
e579fa76300e class: TextBox
Claus Gittinger <cg@exept.de>
parents: 4582
diff changeset
   162
     TextBox openOn:'hello' title:nil windowTitle:'foo' readOnly:false
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   163
    "
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   164
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   165
    "Created: / 29-10-2010 / 17:10:04 / cg"
6075
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   166
    "Modified: / 26-06-2019 / 10:55:57 / Claus Gittinger"
1654
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
   167
! !
790df576b51b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1555
diff changeset
   168
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   169
!TextBox class methodsFor:'defaults'!
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   170
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   171
defaultExtent
4466
7b936f52873d Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents: 3956
diff changeset
   172
    ^ (Screen current pixelPerMillimeter * (120 @ 90)) rounded
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   173
! !
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   174
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   175
!TextBox methodsFor:'accessing'!
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   176
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   177
contents
5444
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   178
    "return my contents (i.e. possibly modified text after accept)"
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   179
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   180
    ^ textView contents
5444
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   181
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   182
    "Modified (comment): / 04-02-2017 / 18:01:03 / cg"
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   183
!
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   184
5932
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   185
contents:newText
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   186
    "set my contents"
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   187
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   188
    textView contents:newText
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   189
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   190
    "Created: / 04-11-2018 / 21:38:13 / Claus Gittinger"
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   191
!
34eebda99f9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5444
diff changeset
   192
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   193
initialText:aString
5444
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   194
    "define the initial text in the texteditor"
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   195
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   196
    textView contents:aString
5444
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   197
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   198
    "Modified (comment): / 04-02-2017 / 18:01:16 / cg"
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   199
!
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   200
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   201
readOnly:aBoolean
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   202
    "make my text readOnly or readWrite"
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   203
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   204
    textView readOnly:aBoolean
5444
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   205
! !
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   206
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   207
!TextBox methodsFor:'accessing-contents'!
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   208
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   209
textView
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   210
    ^ textView
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   211
!
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   212
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   213
textViewClass:something
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   214
    textViewClass := something.
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   215
! !
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   216
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   217
!TextBox methodsFor:'initialization'!
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   218
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   219
initialize
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   220
    |space2 space3 innerWidth|
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   221
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   222
    super initialize.
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   223
2437
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   224
    enterField destroy.
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   225
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   226
    space2 := 2 * ViewSpacing.
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   227
    space3 := 3 * ViewSpacing.
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   228
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   229
    "kludge: preset extent to something useful since other subviews
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   230
     depend on it (extent blocks are not evaluated until view is realized)
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   231
     - avoid visible resizing when realized the first time"
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   232
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   233
    innerWidth := width - space2.
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   234
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   235
    textView := HVScrollableView for:(textViewClass ? EditTextView) miniScrollerH:true in:self.
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   236
    textView origin:(ViewSpacing @ (space2 + labelField height))
2437
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   237
             extent:(innerWidth @ (height - ViewSpacing -
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   238
                                   labelField height - ViewSpacing -
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   239
                                   buttonPanel height - space3) ).
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   240
    textView origin:[ViewSpacing @ (space2 + labelField height)]
2437
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   241
             extent:[(width - space2) @ (height - ViewSpacing -
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   242
                                   labelField height - ViewSpacing -
c9ba20e3367a destroy the unused enterField
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   243
                                   buttonPanel height - space3) ].
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   244
54
claus
parents: 47
diff changeset
   245
    self delegate:(KeyboardForwarder toView:textView scrolledView)
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   246
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   247
    "TextBox new showAtPointer"
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   248
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   249
    "Modified: / 29-10-2010 / 17:14:49 / cg"
6075
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   250
!
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   251
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   252
openOn:someText title:titleString windowTitle:windowTitle readOnly:readOnly
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   253
    "open a textBox on some text, the optional titleString is shown as label
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   254
     above the text areay. The optional windowTitle is used as title in the caption.        
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   255
     return (the possibly modified) text if accepted; nil otherwise."
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   256
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   257
    |returnValue usedWindowTitle|
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   258
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   259
    readOnly ifTrue:[ self textViewClass:TextView ].
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   260
    self initialize.
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   261
    titleString notNil ifTrue:[ self title:titleString ].
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   262
    self initialText:someText.
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   263
    self action:[:text | returnValue := text].
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   264
    self readOnly:readOnly.
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   265
    readOnly ifTrue:[ self abortButton destroy ].
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   266
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   267
    usedWindowTitle := windowTitle.
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   268
    usedWindowTitle isNil ifTrue:[
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   269
        titleString notNil ifTrue:[
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   270
            usedWindowTitle := titleString asString asStringCollection first
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   271
        ] ifFalse:[
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   272
            usedWindowTitle := readOnly ifTrue:'Value' ifFalse:'Input'
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   273
        ].
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   274
    ].
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   275
    self window label:usedWindowTitle.
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   276
    self showAtPointer.
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   277
    ^ returnValue.
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   278
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   279
    "
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   280
     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:true
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   281
     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:false
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   282
     TextBox openOn:'hello' title:'hi there' windowTitle:nil readOnly:false
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   283
     TextBox openOn:'hello' title:nil windowTitle:'some Box' readOnly:false
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   284
     TextBox openOn:'hello' title:nil windowTitle:nil readOnly:false
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   285
     TextBox openOn:'hello' title:nil windowTitle:'foo' readOnly:false
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   286
    "
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   287
0c168e2e1937 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5960
diff changeset
   288
    "Created: / 26-06-2019 / 10:55:37 / Claus Gittinger"
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   289
! !
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   290
26
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
   291
!TextBox methodsFor:'queries'!
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   292
5960
d150862d8ea3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5932
diff changeset
   293
computePreferredExtent
26
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
   294
    "return the extent needed to make everything visible"
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   295
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   296
    |wWanted hWanted wPanel|
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   297
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   298
    wWanted := labelField width + ViewSpacing + ViewSpacing.
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   299
    (wWanted > width) ifFalse:[
2618
855495c01b1c care for preferredExtent
Claus Gittinger <cg@exept.de>
parents: 2437
diff changeset
   300
        wWanted := width
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   301
    ].
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   302
    wPanel := ViewSpacing * 3.
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   303
    buttonPanel subViews do:[:aView |
2618
855495c01b1c care for preferredExtent
Claus Gittinger <cg@exept.de>
parents: 2437
diff changeset
   304
        wPanel := wPanel + aView width + ViewSpacing
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   305
    ].
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   306
    wPanel > wWanted ifTrue:[
2618
855495c01b1c care for preferredExtent
Claus Gittinger <cg@exept.de>
parents: 2437
diff changeset
   307
        wWanted := wPanel
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   308
    ].
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   309
    hWanted := ViewSpacing + labelField height +
2618
855495c01b1c care for preferredExtent
Claus Gittinger <cg@exept.de>
parents: 2437
diff changeset
   310
               ViewSpacing + textView height +
3418
8243c6e537e0 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   311
               (ViewSpacing * 6) + buttonPanel preferredHeight +
2618
855495c01b1c care for preferredExtent
Claus Gittinger <cg@exept.de>
parents: 2437
diff changeset
   312
               ViewSpacing.
26
ff148983c183 *** empty log message ***
claus
parents: 13
diff changeset
   313
    ^ (wWanted @ hWanted)
5960
d150862d8ea3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5932
diff changeset
   314
d150862d8ea3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5932
diff changeset
   315
    "Created: / 09-11-2018 / 20:02:29 / Claus Gittinger"
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   316
! !
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   317
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   318
!TextBox class methodsFor:'documentation'!
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   319
1555
333b639caa8a added #readOnly:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   320
version
5444
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   321
    ^ '$Header$'
3956
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   322
!
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   323
32c277e2d606 readonly attribute
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
   324
version_CVS
5444
90c4fcd20bd4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
   325
    ^ '$Header$'
0
0fd7841626f6 Initial revision
claus
parents:
diff changeset
   326
! !
4466
7b936f52873d Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents: 3956
diff changeset
   327