InfoBox.st
author Claus Gittinger <cg@exept.de>
Thu, 17 May 2001 14:17:46 +0200
changeset 2362 f6ace7307e4d
parent 2076 e863a4bf58d4
child 2469 da097548025a
permissions -rw-r--r--
examples fixed (bitmaps access)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    13
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    14
2362
f6ace7307e4d examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents: 2076
diff changeset
    15
"{ Package: 'stx:libwidg' }"
f6ace7307e4d examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents: 2076
diff changeset
    16
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    17
DialogBox subclass:#InfoBox
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    18
	instanceVariableNames:'formLabel textLabel'
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    19
	classVariableNames:'InfoBitmap'
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    20
	poolDictionaries:''
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    21
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    22
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    23
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
    24
!InfoBox class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    25
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    26
copyright
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    27
"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    28
 COPYRIGHT (c) 1989 by Claus Gittinger
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    29
	      All Rights Reserved
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    30
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    31
 This software is furnished under a license and may be used
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    32
 only in accordance with the terms of that license and with the
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    34
 be provided or otherwise made available to, or used by, any
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    35
 other person.  No title to or ownership of the software is
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    36
 hereby transferred.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    37
"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    38
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    39
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    40
!
8
82e87dc3540e *** empty log message ***
claus
parents: 7
diff changeset
    41
82e87dc3540e *** empty log message ***
claus
parents: 7
diff changeset
    42
documentation
82e87dc3540e *** empty log message ***
claus
parents: 7
diff changeset
    43
"
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    44
   Historic note:
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    45
        originally, ST/X had separate classes for the various entry methods;
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    46
        there were YesNoBox, EnterBox, InfoBox and so on.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    47
        In the meantime, the DialogBox class (and therefore its alias: Dialog)
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    48
        is going to duplicate most funcionality found in these classes.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    49
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    50
        In the future, those existing subclasses' functionality is going to
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    51
        be moved fully into Dialog, and the subclasses will be replaced by dummy
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    52
        delegators. (They will be kept for backward compatibility, though).
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    53
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    54
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    55
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    56
    this class implements a pop-up box to show an information message.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    57
    It has a single ok-Button, which closes the box.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    58
    Also entering return has (by default) the same effect as pressing
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    59
    the ok-button.
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    60
    InfoBox is a superclass of some other boxes - see WarningBox, YesNoBox etc.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    61
    most of them simply redefine the icon shown in the upper left or
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    62
    add buttons.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    63
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    64
    [instance variables:]
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    65
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    66
        formLabel        <Label>        shows a bitmap (warning, question-mark)
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    67
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    68
        textLabel        <Label>        shows the boxes text
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    69
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    70
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    71
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    72
        Claus Gittinger
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    73
"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    74
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    75
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    76
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    77
examples
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    78
"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    79
    InfoBoxes are created with:
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    80
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
    81
        aBox := InfoBox title:'some title'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    82
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    83
    and shown with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    84
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
    85
        aBox showAtPointer
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    86
    or
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
    87
        aBox open
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    88
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    89
    The default box shows 'yes' in its button; this can be changed with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    90
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
    91
        aBox okText:'some string'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    92
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    93
    the boxes bitmap-image can be changed with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    94
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
    95
        aBox image:aForm
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    96
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    97
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    98
    Since this type of information is pretty common, a convenient information
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
    99
    method has been added to Object.
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   100
    Thus, you can use:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   101
                                                                        [exBegin]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   102
        self information:'hello world'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   103
                                                                        [exEnd]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   104
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   105
    everwhere in your program.
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   106
    for ST-80 compatibility, you can also use:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   107
                                                                        [exBegin]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   108
        Dialog information:'hello world'
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   109
                                                                        [exEnd]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   110
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   111
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   112
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   113
    standard box:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   114
                                                                        [exBegin]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   115
        |box|
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   116
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   117
        box := InfoBox title:'hello world '.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   118
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   119
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   120
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   121
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   122
    changing the buttons label:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   123
                                                                        [exBegin]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   124
        |box|
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   125
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   126
        box := InfoBox title:'hello world '.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   127
        box okText:'wow'.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   128
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   129
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   130
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   131
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   132
    changing the icon:
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   133
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   134
                                                                        [exBegin]
2362
f6ace7307e4d examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents: 2076
diff changeset
   135
        |box|
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   136
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   137
        box := InfoBox title:'hello world '.
2362
f6ace7307e4d examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents: 2076
diff changeset
   138
        box image:(Image fromFile:'bitmaps/SBrowser.xbm' inPackage:'stx:libtool').
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   139
        box okText:'wow'.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   140
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   141
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   142
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   143
    or even:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   144
                                                                        [exBegin]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   145
        |box|
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   146
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   147
        box := InfoBox title:'hello garfield '.
2362
f6ace7307e4d examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents: 2076
diff changeset
   148
        box image:((Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages') magnifiedTo:200@100).
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   149
        box okText:'wow'.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   150
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   151
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   152
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   153
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   154
    If you plan to use boxes as in the last example, you may want to
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   155
    keep the box around for reuse (since the image magnification takes some time).
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   156
                                                                        [exBegin]
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   157
        |box|
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   158
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   159
        box := InfoBox title:'hello garfield '.
2362
f6ace7307e4d examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents: 2076
diff changeset
   160
        box image:((Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages') magnifiedTo:200@100).
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   161
        box okText:'wow'.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   162
        box open.
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   163
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   164
        box title:'hello again'.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   165
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   166
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   167
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   168
"
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   169
! !
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   170
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   171
!InfoBox class methodsFor:'instance creation'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   172
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   173
title:titleString
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   174
    "create a new infoBox with title, aTitleString"
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   175
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   176
    ^ (self new) title:titleString
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   177
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   178
    "
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   179
     (InfoBox title:'hello') open
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   180
    "
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   181
! !
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   182
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   183
!InfoBox class methodsFor:'defaults'!
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   184
574
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   185
defaultLabel
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   186
    "return the boxes default window title."
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   187
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   188
    ^ 'Info'
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   189
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   190
    "Created: 23.4.1996 / 17:12:33 / cg"
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   191
!
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   192
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   193
iconBitmap
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   194
    "return the bitmap shown as icon in my instances.
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   195
     This is the default image; you can overwrite this in a concrete
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   196
     instance with the #image: message"
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   197
1365
aa6a855b5013 new resource naming
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   198
    <resource: #style (#'infoBox.icon' #'infoBox.iconFile')>
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   199
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   200
    |img imgFileName|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   201
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   202
    InfoBitmap isNil ifTrue:[
1365
aa6a855b5013 new resource naming
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   203
        img := StyleSheet at:'infoBox.icon'.
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   204
        img notNil ifTrue:[
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   205
            InfoBitmap := img
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   206
        ] ifFalse:[
1365
aa6a855b5013 new resource naming
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   207
            imgFileName := StyleSheet at:'infoBox.iconFile' default:'bitmaps/Information.xbm'.
2076
e863a4bf58d4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2059
diff changeset
   208
            InfoBitmap := Smalltalk imageFromFileNamed:imgFileName forClass:self.
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   209
        ].
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   210
        InfoBitmap notNil ifTrue:[
1991
d3759873aed7 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1365
diff changeset
   211
            InfoBitmap := InfoBitmap onDevice:Display
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   212
        ]
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   213
    ].
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   214
    ^ InfoBitmap
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   215
1365
aa6a855b5013 new resource naming
Claus Gittinger <cg@exept.de>
parents: 1172
diff changeset
   216
    "Modified: / 26.10.1997 / 17:02:51 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   217
! !
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   218
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   219
!InfoBox class methodsFor:'styles'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   220
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   221
updateStyleCache
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   222
    "extract values from the styleSheet and cache them in class variables.
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   223
     Here, the cached infoBitmap is simply flushed."
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 370
diff changeset
   224
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   225
    InfoBitmap := nil
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   226
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   227
    "Modified: 1.4.1997 / 14:44:50 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   228
! !
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   229
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   230
!InfoBox methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   231
184
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   232
form:aFormOrImage
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   233
    "historical leftover - define a form to be displayed left of the title"
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   234
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   235
    self image:aFormOrImage
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   236
!
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
   237
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   238
formLabel
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   239
    "return the formLabel = can be used to change its appearance"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   240
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   241
    ^ formLabel
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   242
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
   243
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   244
image:aForm
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   245
    "define a form to be displayed left of the title
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   246
     - usually left as defaulted:
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   247
	an exclamation-mark here, warn-sign in warningBox,
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   248
	others in other subclasses."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   249
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   250
    formLabel form:aForm.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   251
    formLabel forceResize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   252
    shown ifTrue:[self resize]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   253
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   254
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   255
textLabel
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   256
    "return the textLabel = can be used to change its appearance"
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   257
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   258
    ^ textLabel
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   259
!
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   260
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   261
title
8
82e87dc3540e *** empty log message ***
claus
parents: 7
diff changeset
   262
    "return the boxes title string"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   263
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   264
    ^ textLabel label
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   265
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   266
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   267
title:aString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   268
    "set the boxes title string"
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   269
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   270
    aString ~= textLabel label ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   271
	textLabel label:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   272
	textLabel forceResize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   273
	shown ifTrue:[self resize]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   274
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   275
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   276
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   277
!InfoBox methodsFor:'initialization'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   278
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   279
initFormBitmap
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   280
    "setup the bitmap shown in the upper left -
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   281
     extracted into a separate method for easier redefinition
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   282
     in subclasses"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   283
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   284
    formLabel form:(self class iconBitmap)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   285
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   286
180
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   287
initFormLabel
570
4a82b61a1497 commentary
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   288
    "setup the icon shown in the infoBox.
4a82b61a1497 commentary
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   289
     Can be redefined in subclasses."
4a82b61a1497 commentary
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   290
180
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   291
    |mm|
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   292
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   293
    mm := ViewSpacing.
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   294
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   295
    formLabel := Label in:self.
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   296
    formLabel borderWidth:0.
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   297
    formLabel origin:(mm @ mm).
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   298
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   299
    "Created: 16.11.1995 / 18:32:32 / cg"
570
4a82b61a1497 commentary
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   300
    "Modified: 22.4.1996 / 18:15:37 / cg"
180
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   301
!
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   302
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   303
initialize
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   304
    |mm sep|
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   305
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   306
    super initialize.
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   307
    self addOkButton.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   308
574
165d1b2b7922 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   309
"/    label := 'Info'.
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   310
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   311
    mm := ViewSpacing.
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   312
180
0eb12501889e hook to create different labelView in subclasses
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   313
    self initFormLabel.
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   314
    self initFormBitmap.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   315
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   316
    textLabel := Label label:'Information' in:self.
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   317
    textLabel borderWidth:0.
367
bc778f90e42d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   318
    textLabel origin:[(mm + formLabel widthIncludingBorder + mm) @ mm].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   319
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   320
    (styleSheet at:'infoBoxSeparator' default:false) ifTrue:[
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   321
        sep := Separator in:self.
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   322
        sep origin:[0.0 @ ((formLabel bottom max:textLabel bottom) + ViewSpacing)].
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   323
        sep extent:(1.0 @ sep preferredExtent y).
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   324
    ].
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   325
77
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   326
    "
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   327
     |b|
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   328
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   329
     b := InfoBox new.
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   330
     b title:'hello'.
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   331
     b open
565b052f5277 *** empty log message ***
claus
parents: 72
diff changeset
   332
    "
367
bc778f90e42d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   333
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   334
    "Modified: 1.4.1997 / 14:53:16 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   335
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   336
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   337
!InfoBox methodsFor:'queries'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   338
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   339
preferredExtent 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   340
    "return my preferred extent"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   341
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   342
    |w h mm|
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   343
797
2f9cd56f48ee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   344
    "/ If I have an explicit preferredExtent ..
2f9cd56f48ee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   345
713
0c38ad51016d care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   346
    preferredExtent notNil ifTrue:[
0c38ad51016d care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   347
        ^ preferredExtent
0c38ad51016d care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   348
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   349
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   350
    mm := ViewSpacing.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   351
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   352
    w := ((margin + mm) * 2) + 
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   353
         formLabel widthIncludingBorder + 
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   354
         mm + textLabel width.
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   355
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   356
    w := w max:(okButton preferredExtent x + (mm * 2)).
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   357
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   358
    h := (mm * 6)
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   359
         + ((formLabel heightIncludingBorder) max:(textLabel height))
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   360
         + okButton heightIncludingBorder.
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   361
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   362
    (styleSheet at:'infoBoxSeparator' default:false) ifTrue:[
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   363
        h := h + (ViewSpacing * 3)
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   364
    ].
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   365
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   366
    ^ w @ h
370
dc5b51904d3f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   367
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   368
    "Modified: 1.4.1997 / 14:53:35 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   369
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   370
1172
d10e4627b0e3 allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   371
!InfoBox class methodsFor:'documentation'!
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   372
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   373
version
2362
f6ace7307e4d examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents: 2076
diff changeset
   374
    ^ '$Header: /cvs/stx/stx/libwidg/InfoBox.st,v 1.37 2001-05-17 12:17:40 cg Exp $'
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   375
! !