ProgressIndicator.st
author Claus Gittinger <cg@exept.de>
Fri, 23 Apr 1999 14:47:39 +0200
changeset 1328 95a7d89cf335
parent 1168 35e46761842f
child 1462 e3c0a367a7e8
permissions -rw-r--r--
category change
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62
claus
parents: 50
diff changeset
     1
"
claus
parents: 50
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 50
diff changeset
     3
	      All Rights Reserved
claus
parents: 50
diff changeset
     4
claus
parents: 50
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 50
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 50
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 50
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 50
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 50
diff changeset
    10
 hereby transferred.
claus
parents: 50
diff changeset
    11
"
50
claus
parents:
diff changeset
    12
claus
parents:
diff changeset
    13
View subclass:#ProgressIndicator
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
    14
	instanceVariableNames:'percentage showPercentage fgColor bgColor connectedTop
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    15
		connectedLabel collector finishAction closeTopWhenDone showBusy
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    16
		busyPosition busyDelta busyIndicationProcess'
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    17
	classVariableNames:''
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    18
	poolDictionaries:''
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    19
	category:'Views-Misc'
50
claus
parents:
diff changeset
    20
!
claus
parents:
diff changeset
    21
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    22
!ProgressIndicator class methodsFor:'documentation'!
50
claus
parents:
diff changeset
    23
62
claus
parents: 50
diff changeset
    24
copyright
claus
parents: 50
diff changeset
    25
"
claus
parents: 50
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 50
diff changeset
    27
	      All Rights Reserved
claus
parents: 50
diff changeset
    28
claus
parents: 50
diff changeset
    29
 This software is furnished under a license and may be used
claus
parents: 50
diff changeset
    30
 only in accordance with the terms of that license and with the
claus
parents: 50
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
claus
parents: 50
diff changeset
    32
 be provided or otherwise made available to, or used by, any
claus
parents: 50
diff changeset
    33
 other person.  No title to or ownership of the software is
claus
parents: 50
diff changeset
    34
 hereby transferred.
claus
parents: 50
diff changeset
    35
"
claus
parents: 50
diff changeset
    36
!
claus
parents: 50
diff changeset
    37
50
claus
parents:
diff changeset
    38
documentation
claus
parents:
diff changeset
    39
"
claus
parents:
diff changeset
    40
    a view showing a rectangle filled according the percentage value.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    41
    Can be used as a progress indicator a la MSwindows;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    42
    it can also be configured as a non-percentage busy indication
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    43
    via the showBusyIndication flag (a la netscape).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    44
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    45
    Can be used as a widget within an application, or
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    46
    via the convenient #inBox: instance creation messages,
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    47
    which shows a progressDisplay in a modalBox, while some
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    48
    action is performed.
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    49
    See examples.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    50
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    51
    [author:]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    52
        Claus Gittinger
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    53
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    54
    [see also:]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    55
        ActionWaitBox AnimatedLabel
50
claus
parents:
diff changeset
    56
"
claus
parents:
diff changeset
    57
!
claus
parents:
diff changeset
    58
claus
parents:
diff changeset
    59
examples
claus
parents:
diff changeset
    60
"
62
claus
parents: 50
diff changeset
    61
    basic (internal) interface
claus
parents: 50
diff changeset
    62
    (if progress indicator is to be used in a complex box ...):
50
claus
parents:
diff changeset
    63
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    64
    Before you get frustrated - see the convenient-interface examples
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    65
    at the end ;-)
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    66
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    67
                                                                        [exBegin]
50
claus
parents:
diff changeset
    68
      |top p h|
claus
parents:
diff changeset
    69
62
claus
parents: 50
diff changeset
    70
      top := ModalBox new.
50
claus
parents:
diff changeset
    71
      top extent:300@100.
claus
parents:
diff changeset
    72
      top label:'Progress'.
claus
parents:
diff changeset
    73
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
    74
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
    75
      p level:-1.
62
claus
parents: 50
diff changeset
    76
      h := p preferredExtent y.
50
claus
parents:
diff changeset
    77
      p topInset:(h // 2) negated; 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    78
        bottomInset:(h // 2) negated;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    79
        leftInset:5;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    80
        rightInset:5.
50
claus
parents:
diff changeset
    81
claus
parents:
diff changeset
    82
      [
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    83
          1 to:100 do:[:val |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    84
              (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    85
              p percentage:val 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    86
          ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    87
          top hide.
62
claus
parents: 50
diff changeset
    88
      ] fork.
claus
parents: 50
diff changeset
    89
      top open.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    90
                                                                        [exEnd]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    91
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    92
    as a busy indicator
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    93
                                                                        [exBegin]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    94
      |top p h|
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    95
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    96
      top := ModalBox new.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    97
      top extent:300@100.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    98
      top label:'Busy'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    99
      p := ProgressIndicator in:top.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   100
      p origin:(0.0@0.5) corner:(1.0@0.5).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   101
      p level:-1.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   102
      h := p preferredExtent y.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   103
      p topInset:(h // 2) negated; 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   104
        bottomInset:(h // 2) negated;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   105
        leftInset:5;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   106
        rightInset:5.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   107
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   108
      p showBusyIndication:true.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   109
      [
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   110
          'do something here ....'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   111
          (Delay forSeconds:5) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   112
          top hide.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   113
      ] fork.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   114
      top open.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   115
                                                                        [exEnd]
50
claus
parents:
diff changeset
   116
claus
parents:
diff changeset
   117
    changing colors, turning percentage display off:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   118
                                                                        [exBegin]
50
claus
parents:
diff changeset
   119
      |top p h|
claus
parents:
diff changeset
   120
claus
parents:
diff changeset
   121
      top := StandardSystemView new.
claus
parents:
diff changeset
   122
      top extent:300@100.
claus
parents:
diff changeset
   123
      top label:'Progress'.
claus
parents:
diff changeset
   124
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   125
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   126
      p level:-1.
claus
parents:
diff changeset
   127
      p showPercentage:false.
claus
parents:
diff changeset
   128
      p foregroundColor:(Color red).
claus
parents:
diff changeset
   129
      h := 10.
claus
parents:
diff changeset
   130
      p topInset:(h // 2) negated; 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   131
        bottomInset:(h // 2) negated;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   132
        leftInset:5;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   133
        rightInset:5.
50
claus
parents:
diff changeset
   134
      top open.
claus
parents:
diff changeset
   135
      [
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   136
          1 to:100 do:[:val |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   137
              (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   138
              p percentage:val 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   139
          ]
50
claus
parents:
diff changeset
   140
      ] fork
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   141
                                                                        [exEnd]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   142
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   143
    as a busy indicator and percentage display (as in netscape)
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   144
                                                                        [exBegin]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   145
      |top p h|
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   146
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   147
      top := ModalBox new.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   148
      top extent:300@60.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   149
      top label:'Busy'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   150
      p := ProgressIndicator in:top.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   151
      p origin:(0.0@0.5) corner:(1.0@0.5).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   152
      p level:-1.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   153
      p showPercentage:false.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   154
      p backgroundColor:(Color cyan).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   155
      h := p preferredExtent y.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   156
      p topInset:(h // 3) negated; 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   157
        bottomInset:(h // 3) negated;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   158
        leftInset:5;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   159
        rightInset:5.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   160
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   161
      p showBusyIndication:true.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   162
      [
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   163
          top label:'Busy'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   164
          1 to:100 do:[:i |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   165
            (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   166
          ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   167
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   168
          top label:'Percentage'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   169
          p showBusyIndication:false.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   170
          1 to:100 do:[:i |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   171
            (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   172
            p percentage:i. 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   173
          ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   174
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   175
          top hide.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   176
      ] fork.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   177
      top open.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   178
                                                                        [exEnd]
50
claus
parents:
diff changeset
   179
claus
parents:
diff changeset
   180
    with border (2D look):
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   181
                                                                        [exBegin]
50
claus
parents:
diff changeset
   182
      |top p h|
claus
parents:
diff changeset
   183
claus
parents:
diff changeset
   184
      top := StandardSystemView new.
claus
parents:
diff changeset
   185
      top extent:300@100.
claus
parents:
diff changeset
   186
      top label:'Progress'.
claus
parents:
diff changeset
   187
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   188
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   189
      p borderWidth:1.
62
claus
parents: 50
diff changeset
   190
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   191
      p topInset:(h // 2) negated; 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   192
        bottomInset:(h // 2) negated;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   193
        leftInset:5;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   194
        rightInset:5.
50
claus
parents:
diff changeset
   195
      top open.
claus
parents:
diff changeset
   196
      [
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   197
          1 to:100 do:[:val |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   198
              (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   199
              p percentage:val 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   200
          ]
50
claus
parents:
diff changeset
   201
      ] fork
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   202
                                                                        [exEnd]
50
claus
parents:
diff changeset
   203
claus
parents:
diff changeset
   204
claus
parents:
diff changeset
   205
    getting progress from a model:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   206
                                                                        [exBegin]
50
claus
parents:
diff changeset
   207
      |model top p h|
claus
parents:
diff changeset
   208
claus
parents:
diff changeset
   209
      model := 0 asValue.
claus
parents:
diff changeset
   210
claus
parents:
diff changeset
   211
      top := StandardSystemView new.
claus
parents:
diff changeset
   212
      top extent:300@100.
claus
parents:
diff changeset
   213
      top label:'Progress'.
claus
parents:
diff changeset
   214
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   215
      p model:model.
claus
parents:
diff changeset
   216
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   217
      p level:-1.
62
claus
parents: 50
diff changeset
   218
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   219
      p topInset:(h // 2) negated; 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   220
        bottomInset:(h // 2) negated;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   221
        leftInset:5;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   222
        rightInset:5.
50
claus
parents:
diff changeset
   223
      top open.
claus
parents:
diff changeset
   224
claus
parents:
diff changeset
   225
      [
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   226
          1 to:100 do:[:val |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   227
              (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   228
              model value:val 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   229
          ]
50
claus
parents:
diff changeset
   230
      ] fork
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   231
                                                                        [exEnd]
50
claus
parents:
diff changeset
   232
62
claus
parents: 50
diff changeset
   233
50
claus
parents:
diff changeset
   234
    concrete example:
claus
parents:
diff changeset
   235
      search all files in the source directory for a string
claus
parents:
diff changeset
   236
      using grep. Show progress while doing so.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   237
                                                                        [exBegin]
50
claus
parents:
diff changeset
   238
      |top p h names done|
claus
parents:
diff changeset
   239
claus
parents:
diff changeset
   240
      top := StandardSystemView new.
claus
parents:
diff changeset
   241
      top extent:300@100.
claus
parents:
diff changeset
   242
      top label:'Searching ...'.
claus
parents:
diff changeset
   243
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   244
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   245
      p level:-1.
62
claus
parents: 50
diff changeset
   246
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   247
      p topInset:(h // 2) negated; 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   248
        bottomInset:(h // 2) negated;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   249
        leftInset:5;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   250
        rightInset:5.
50
claus
parents:
diff changeset
   251
      top openWithPriority:(Processor activePriority + 1).
claus
parents:
diff changeset
   252
claus
parents:
diff changeset
   253
      names := 'source' asFilename directoryContents.
claus
parents:
diff changeset
   254
      done := 0.
claus
parents:
diff changeset
   255
      names do:[:aName |
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   256
        |fn stream line|
50
claus
parents:
diff changeset
   257
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   258
        p percentage:(done / names size * 100).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   259
        fn := ('source/' , aName) asFilename.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   260
        fn isDirectory ifFalse:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   261
            stream := fn readStream.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   262
            [stream atEnd] whileFalse:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   263
                line := stream nextLine.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   264
                (line findString:'subclass:') ~~ 0 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   265
                    Transcript showCR:line
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   266
                ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   267
            ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   268
            stream close.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   269
        ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   270
        done := done + 1
50
claus
parents:
diff changeset
   271
      ].
claus
parents:
diff changeset
   272
claus
parents:
diff changeset
   273
      top destroy
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   274
                                                                        [exEnd]
62
claus
parents: 50
diff changeset
   275
claus
parents: 50
diff changeset
   276
claus
parents: 50
diff changeset
   277
   using the convenient inBox-interface
claus
parents: 50
diff changeset
   278
claus
parents: 50
diff changeset
   279
   (this creates a box and an activity label and evaluates a block
claus
parents: 50
diff changeset
   280
    to indicate ...)
claus
parents: 50
diff changeset
   281
claus
parents: 50
diff changeset
   282
    basic interface demonstration:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   283
                                                                        [exBegin]
62
claus
parents: 50
diff changeset
   284
      |p|
claus
parents: 50
diff changeset
   285
claus
parents: 50
diff changeset
   286
      p := ProgressIndicator 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   287
                inBoxWithLabel:'doing something  ...'
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   288
                abortable:true.
62
claus
parents: 50
diff changeset
   289
      p showProgressOf:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   290
            [:progressValue :currentAction |
62
claus
parents: 50
diff changeset
   291
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   292
              1 to:100 do:[:val |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   293
                  (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   294
                  val == 25 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   295
                      currentAction value:'still going ...'
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   296
                  ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   297
                  val == 50 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   298
                      currentAction value:'halfway through ...'
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   299
                  ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   300
                  val == 75 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   301
                      currentAction value:'almost finished ...'
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   302
                  ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   303
                  progressValue value:val 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   304
              ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   305
            ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   306
                                                                        [exEnd]
62
claus
parents: 50
diff changeset
   307
claus
parents: 50
diff changeset
   308
claus
parents: 50
diff changeset
   309
    above search example using this convenient interface:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   310
                                                                        [exBegin]
62
claus
parents: 50
diff changeset
   311
      |p|
claus
parents: 50
diff changeset
   312
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   313
      p := ProgressIndicator 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   314
                inBoxWithLabel:'searching files ...'
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   315
                abortable:false.
62
claus
parents: 50
diff changeset
   316
      p showProgressOf:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   317
            [:progressValue :currentAction |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   318
                |names nDone|
62
claus
parents: 50
diff changeset
   319
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   320
                names := 'source' asFilename directoryContents.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   321
                nDone := 0.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   322
                names do:[:aName |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   323
                  |fn stream line|
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   324
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   325
                  progressValue value:(nDone / names size * 100).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   326
                  currentAction value:'searching ' , 'source/' , aName , ' ...'.
62
claus
parents: 50
diff changeset
   327
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   328
                  fn := ('source/' , aName) asFilename.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   329
                  fn isDirectory ifFalse:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   330
                      stream := fn readStream.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   331
                      [stream atEnd] whileFalse:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   332
                          line := stream nextLine.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   333
                          (line findString:'subclass:') ~~ 0 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   334
                              Transcript showCR:line
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   335
                          ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   336
                      ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   337
                      stream close.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   338
                  ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   339
                  nDone := nDone + 1
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   340
                ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   341
            ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   342
                                                                        [exEnd]
62
claus
parents: 50
diff changeset
   343
claus
parents: 50
diff changeset
   344
claus
parents: 50
diff changeset
   345
    a nice example: copying files a la windows ...
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   346
    the following copies all files to /dev/null.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   347
                                                                        [exBegin]
62
claus
parents: 50
diff changeset
   348
      |p|
claus
parents: 50
diff changeset
   349
claus
parents: 50
diff changeset
   350
      (ProgressIndicator 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   351
                inBoxWithLabel:'copy files to /dev/null ...'
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   352
                abortable:true)
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   353
         showProgressOf:
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   354
            [:progressValue :currentAction |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   355
                |files nFiles nDone|
62
claus
parents: 50
diff changeset
   356
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   357
                files := '.' asFilename directoryContents.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   358
                nFiles := files size.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   359
                nDone := 0.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   360
                files do:[:aFileName |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   361
                    |percent|
50
claus
parents:
diff changeset
   362
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   363
                    nDone := nDone + 1.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   364
                    percent := nDone / nFiles * 100.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   365
                    progressValue value:percent. 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   366
                    aFileName asFilename isDirectory ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   367
                        Transcript showCR:('skipping ' , aFileName , ' ...'). 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   368
                        currentAction value:('skipping ' , aFileName , ' ...'). 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   369
                    ] ifFalse:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   370
                        Transcript showCR:('copying ' , aFileName , ' ...').
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   371
                        currentAction value:('copying ' , aFileName , ' ...').
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   372
                        Object errorSignal handle:[:ex |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   373
                            self warn:'an error occurred while copying ' , aFileName.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   374
                            ex return
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   375
                        ] do:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   376
                            aFileName asFilename copyTo:'/dev/null'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   377
                        ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   378
                    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   379
                ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   380
            ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   381
                                                                        [exEnd]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   382
"
50
claus
parents:
diff changeset
   383
! !
claus
parents:
diff changeset
   384
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   385
!ProgressIndicator class methodsFor:'instance creation'!
62
claus
parents: 50
diff changeset
   386
claus
parents: 50
diff changeset
   387
inBox
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   388
    "create a topView containing an instance of myself,
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   389
     for later use with #showProgressOf:"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   390
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   391
    ^ self inBoxWithLabel:'executing ...' abortable:false
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   392
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   393
    "Modified: 22.10.1997 / 21:08:37 / cg"
62
claus
parents: 50
diff changeset
   394
!
claus
parents: 50
diff changeset
   395
claus
parents: 50
diff changeset
   396
inBoxWithLabel:aLabel
claus
parents: 50
diff changeset
   397
    "create a topView containing an instance of myself,
claus
parents: 50
diff changeset
   398
     for later use with #showProgressOf:"
claus
parents: 50
diff changeset
   399
claus
parents: 50
diff changeset
   400
    ^ self inBoxWithLabel:aLabel abortable:false 
claus
parents: 50
diff changeset
   401
!
claus
parents: 50
diff changeset
   402
claus
parents: 50
diff changeset
   403
inBoxWithLabel:aLabel abortable:abortable
claus
parents: 50
diff changeset
   404
    "create a topView containing an instance of myself,
claus
parents: 50
diff changeset
   405
     for later use with #showProgressOf:"
claus
parents: 50
diff changeset
   406
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   407
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   408
	inBoxWithLabel:aLabel   
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   409
	text:''
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   410
	abortable:abortable
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   411
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   412
    "Modified: 17.7.1996 / 15:14:58 / cg"
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   413
!
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   414
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   415
inBoxWithLabel:aLabel icon:anIcon text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   416
    "create a topView containing an instance of myself,
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   417
     for later use with #showProgressOf:"
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   418
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   419
    |top p l h y y2|
62
claus
parents: 50
diff changeset
   420
claus
parents: 50
diff changeset
   421
    top := Dialog new.
claus
parents: 50
diff changeset
   422
    top label:aLabel.
claus
parents: 50
diff changeset
   423
    top cursor:(Cursor wait).
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   424
    y2 := 0.
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   425
    anIcon notNil ifTrue:[
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   426
        y := top yPosition.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   427
        l := top addTextLabel:anIcon.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   428
        l borderWidth:0.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   429
        l adjust:#left.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   430
        l cursor:(Cursor wait).
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   431
        y2 := top yPosition.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   432
        top yPosition:y.
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   433
    ].
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   434
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   435
    l := top addTextLabel:text.
62
claus
parents: 50
diff changeset
   436
    l borderWidth:0.
74
claus
parents: 62
diff changeset
   437
    l adjust:#left.
62
claus
parents: 50
diff changeset
   438
    l cursor:(Cursor wait).
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   439
    anIcon notNil ifTrue: [l leftInset:(anIcon width + 10)].
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   440
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   441
    top yPosition:(top yPosition max:y2).
62
claus
parents: 50
diff changeset
   442
claus
parents: 50
diff changeset
   443
    top addVerticalSpace.
claus
parents: 50
diff changeset
   444
claus
parents: 50
diff changeset
   445
    p := ProgressIndicator new.
claus
parents: 50
diff changeset
   446
    p extent:(1.0 @ p preferredExtent y).
claus
parents: 50
diff changeset
   447
    p level:-1.
claus
parents: 50
diff changeset
   448
    p leftInset:5;
claus
parents: 50
diff changeset
   449
      rightInset:5.
claus
parents: 50
diff changeset
   450
    p cursor:(Cursor wait).
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   451
    p closeTopWhenDone:closeWhenDoneBoolean.
62
claus
parents: 50
diff changeset
   452
    p connectToTop:top label:l.
claus
parents: 50
diff changeset
   453
claus
parents: 50
diff changeset
   454
    top addComponent:p.
claus
parents: 50
diff changeset
   455
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   456
    additionalView notNil ifTrue:[
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   457
        top addComponent:additionalView.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   458
        additionalView extent:(1.0 @ additionalView preferredExtent y).
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   459
    ].
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   460
62
claus
parents: 50
diff changeset
   461
    abortable ifTrue:[
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   462
        top addVerticalSpace.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   463
        top addAbortButton
62
claus
parents: 50
diff changeset
   464
    ].
claus
parents: 50
diff changeset
   465
claus
parents: 50
diff changeset
   466
    ^ p
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   467
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   468
    "Created: 17.7.1996 / 15:14:33 / cg"
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   469
    "Modified: 17.7.1996 / 15:16:58 / cg"
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   470
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   471
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   472
inBoxWithLabel:aLabel text:text abortable:abortable
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   473
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   474
     for later use with #showProgressOf:"
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   475
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   476
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   477
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   478
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   479
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   480
	view:nil
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   481
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   482
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   483
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   484
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   485
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   486
     for later use with #showProgressOf:"
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   487
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   488
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   489
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   490
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   491
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   492
	view:additionalView 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   493
	closeWhenDone:true
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   494
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   495
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   496
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   497
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   498
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   499
     for later use with #showProgressOf:"
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   500
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   501
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   502
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   503
	icon:nil
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   504
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   505
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   506
	view:additionalView 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   507
	closeWhenDone:closeWhenDoneBoolean
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   508
62
claus
parents: 50
diff changeset
   509
! !
claus
parents: 50
diff changeset
   510
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   511
!ProgressIndicator methodsFor:'accessing'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   512
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   513
percentage:aNumber
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   514
    "set the percentage"
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   515
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   516
    |newPercentage|
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   517
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   518
    newPercentage := ((aNumber max:0) min:100) rounded.
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   519
    newPercentage ~= percentage ifTrue:[
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   520
        percentage := newPercentage.
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   521
        shown ifTrue:[self invalidateRepairNow:true].
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   522
    ]
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   523
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   524
    "Modified: / 6.6.1998 / 19:43:56 / cg"
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   525
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   526
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   527
showBusyIndication:aBooleanHolder
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   528
    "switch between percentage mode (if false) and busy indication (if true)"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   529
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   530
    aBooleanHolder ~~ showBusy ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   531
        showBusy notNil ifTrue:[        
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   532
            showBusy removeDependent:self.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   533
        ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   534
        showBusy := aBooleanHolder.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   535
        showBusy addDependent:self.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   536
        (showBusy value) ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   537
            self startBusyIndicationProcess.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   538
        ] ifFalse:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   539
            self stopBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   540
        ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   541
        shown ifTrue:[self redraw]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   542
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   543
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   544
    "Created: / 21.10.1998 / 17:35:16 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   545
    "Modified: / 21.10.1998 / 18:03:06 / cg"
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   546
! !
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   547
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   548
!ProgressIndicator methodsFor:'accessing - behavior'!
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   549
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   550
closeTopWhenDone:aBoolean
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   551
    "set/clear the close-topView-when-done flag"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   552
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   553
    closeTopWhenDone := aBoolean
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   554
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   555
    "Created: 3.9.1996 / 14:22:03 / cg"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   556
    "Modified: 29.3.1997 / 16:08:19 / cg"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   557
!
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   558
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   559
finishAction:aBlock 
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   560
    "define an action to be performed when finished"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   561
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   562
    finishAction := aBlock
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   563
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   564
    "Created: 3.9.1996 / 14:15:15 / cg"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   565
    "Modified: 29.3.1997 / 16:08:35 / cg"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   566
! !
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   567
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   568
!ProgressIndicator methodsFor:'accessing - look'!
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   569
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   570
backgroundColor 
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   571
    "return the percentage displays background color"
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   572
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   573
    ^ bgColor
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   574
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   575
!
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   576
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   577
backgroundColor:aColor 
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   578
    "set the percentage displays background color"
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   579
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   580
    aColor ~= bgColor ifTrue:[
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   581
        bgColor := aColor.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   582
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   583
        shown ifTrue:[
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   584
            self invalidateRepairNow:true
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   585
        ]
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   586
    ].
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   587
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   588
    "Modified: / 20.7.1998 / 23:32:48 / cg"
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   589
!
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   590
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   591
foregroundColor 
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   592
    "return the percentage displays foreground color"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   593
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   594
    ^ fgColor
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   595
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   596
    "Created: 29.3.1997 / 16:12:28 / cg"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   597
!
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   598
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   599
foregroundColor:aColor 
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   600
    "set the percentage displays foreground color"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   601
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   602
    aColor ~= fgColor ifTrue:[
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   603
        fgColor := aColor.
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   604
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   605
        shown ifTrue:[
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   606
            self invalidateRepairNow:true
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   607
        ]
336
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   608
    ].
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   609
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   610
    "Modified: / 20.7.1998 / 23:27:47 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   611
!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   612
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   613
showPercentage
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   614
    "return the flag controlling if the percentage is to be shown numerically"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   615
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   616
    ^ showPercentage
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   617
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   618
    "Created: 29.3.1997 / 16:12:39 / cg"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   619
!
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   620
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   621
showPercentage:aBoolean
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   622
    "set/clear the flag controlling if the percentage is to be shown numerically"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   623
336
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   624
    showPercentage := aBoolean.
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   625
    shown ifTrue:[
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   626
        self invalidateRepairNow:true
336
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   627
    ].
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   628
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   629
    "Modified: / 6.6.1998 / 19:28:44 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   630
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   631
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   632
!ProgressIndicator methodsFor:'change & update'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   633
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   634
update:aspect with:aParameter from:changedObject
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   635
    "react upon value changes of my model"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   636
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   637
    (aspect == aspectMsg
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   638
    and:[changedObject == model]) ifTrue:[
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   639
        self percentage:(model perform:aspectMsg).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   640
        ^ self
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   641
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   642
    changedObject == showBusy ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   643
        self redraw.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   644
        ^ self
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   645
    ].
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   646
    ^ super update:aspect with:aParameter from:changedObject
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   647
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   648
    "Modified: / 21.10.1998 / 18:01:52 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   649
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   650
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   651
!ProgressIndicator methodsFor:'drawing'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   652
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   653
redraw
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   654
    "redraw the percentage bar and optional percentage string"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   655
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   656
    |s lx rx sx sy sw m2 m w h|
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   657
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   658
    m := margin + 1.
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   659
    m2 := m*2.
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   660
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   661
    w := width - m2.
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   662
    h := height - m2.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   663
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   664
"/    self clear.
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   665
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   666
    showBusy value ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   667
        self paint:bgColor.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   668
        self fillRectangleX:m y:m width:w height:h.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   669
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   670
        lx := (w * busyPosition / 100) rounded.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   671
        rx := (w * (busyPosition + 20) / 100) rounded.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   672
        rx := rx min:w.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   673
        lx := lx max:m.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   674
        self paint:fgColor.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   675
        self fillRectangleX:lx y:m width:(rx - lx) height:h.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   676
        ^ self
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   677
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   678
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   679
    rx := (w * percentage / 100) rounded.
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   680
    self paint:bgColor.
843
34de7f6bea2d do only draw what to draw
tz
parents: 826
diff changeset
   681
    self fillRectangleX:m+rx y:m width:w-rx height:h.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   682
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   683
    showPercentage ifTrue:[
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   684
        s := percentage printString , ' %'.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   685
        sw := font widthOf:s.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   686
        sx := (width - sw) // 2.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   687
        sy := height // 2 + font descent + 2.
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   688
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   689
        rx <= (sx+sw) ifTrue:[
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   690
            self paint:Color black.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   691
            self displayString:s x:sx y:sy.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   692
        ]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   693
    ].
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   694
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   695
    self paint:fgColor.
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   696
    self fillRectangleX:m y:m width:rx height:h.
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   697
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   698
    showPercentage ifTrue:[
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   699
        rx >= sx ifTrue:[
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   700
            self clippingRectangle:(m@m corner:rx+1 @ h).
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   701
            self paint:Color white.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   702
            self displayString:s x:sx y:sy.
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   703
            self clippingRectangle:nil
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   704
        ]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   705
    ]
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   706
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   707
    "Modified: / 21.10.1998 / 18:01:58 / cg"
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   708
!
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   709
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   710
sizeChanged:how
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   711
    super sizeChanged:how.
865
5c15ad847ad2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   712
    shown ifTrue:[
5c15ad847ad2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   713
        self invalidate
5c15ad847ad2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   714
    ]
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   715
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   716
    "Created: / 18.4.1998 / 02:34:37 / cg"
865
5c15ad847ad2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   717
    "Modified: / 18.4.1998 / 14:09:40 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   718
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   719
1328
95a7d89cf335 category change
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   720
!ProgressIndicator methodsFor:'initialize / release'!
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   721
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   722
destroy
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   723
    busyIndicationProcess notNil ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   724
        self stopBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   725
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   726
    super destroy.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   727
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   728
    "Created: / 21.10.1998 / 17:29:58 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   729
    "Modified: / 21.10.1998 / 17:30:36 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   730
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   731
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   732
initStyle
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   733
    "initialize styleSheet values"
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   734
575
9279151db8f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   735
    <resource: #style (#'progressIndicator.viewBackground'
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   736
                      #'progressIndicator.foregroundColor')>
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   737
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   738
    super initStyle.
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   739
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   740
    self is3D ifTrue:[
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   741
        self level:-1
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   742
    ].
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   743
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   744
    bgColor := styleSheet colorAt:'progressIndicator.viewBackground' default:Color white.
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   745
    fgColor := styleSheet colorAt:'progressIndicator.foregroundColor' default:Color blue.
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   746
    fgColor := fgColor onDevice:device.
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   747
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   748
    showPercentage := true.
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   749
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   750
!
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   751
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   752
initialize
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   753
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   754
    super initialize.
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   755
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   756
    percentage := 0.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   757
    showBusy := false.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   758
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   759
    "Modified: / 21.10.1998 / 17:33:02 / cg"
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   760
! !
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   761
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   762
!ProgressIndicator methodsFor:'private'!
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   763
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   764
connectToTop:top label:label
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   765
    connectedTop := top.
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   766
    connectedLabel := label
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   767
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   768
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   769
startBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   770
    busyIndicationProcess isNil ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   771
        busyPosition := 0.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   772
        busyDelta := 5.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   773
        busyIndicationProcess := [
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   774
                                    [true] whileTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   775
                                        Delay waitForSeconds:0.2.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   776
                                        self updateBusyIndicatorPosition
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   777
                                    ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   778
                                 ] fork.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   779
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   780
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   781
    "Created: / 21.10.1998 / 18:02:35 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   782
    "Modified: / 21.10.1998 / 18:03:49 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   783
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   784
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   785
stopBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   786
    busyIndicationProcess notNil ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   787
        busyIndicationProcess terminate.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   788
        busyIndicationProcess := nil
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   789
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   790
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   791
    "Created: / 21.10.1998 / 17:30:19 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   792
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   793
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   794
updateBusyIndicatorPosition
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   795
    busyPosition := busyPosition + busyDelta.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   796
    busyPosition >= 80 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   797
        busyDelta > 0 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   798
            busyDelta := busyDelta negated.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   799
        ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   800
    ] ifFalse:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   801
        busyPosition <= 0 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   802
            busyDelta < 0 ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   803
                busyDelta := busyDelta negated.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   804
            ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   805
        ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   806
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   807
    shown ifTrue:[self redraw]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   808
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   809
    "Created: / 21.10.1998 / 17:33:28 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   810
    "Modified: / 21.10.1998 / 17:58:58 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   811
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   812
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   813
!ProgressIndicator methodsFor:'queries'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   814
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   815
preferredExtent
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   816
    "return my preferred extent"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   817
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   818
    preferredExtent notNil ifTrue:[
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   819
	^ preferredExtent
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   820
    ].
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   821
    ^ 100 @ (font height + font descent + ((margin + 1) * 2))
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   822
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   823
    "Modified: 22.10.1997 / 21:07:17 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   824
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   825
62
claus
parents: 50
diff changeset
   826
!ProgressIndicator methodsFor:'showing progress'!
claus
parents: 50
diff changeset
   827
claus
parents: 50
diff changeset
   828
showProgressOf:aBlock
claus
parents: 50
diff changeset
   829
    "show progress, while evaluating aBlock.
claus
parents: 50
diff changeset
   830
     If the receiver has been created with inBox, show the
claus
parents: 50
diff changeset
   831
     box centered on the screen. If not, the view is assumed to
claus
parents: 50
diff changeset
   832
     be contained in another view, and no special startup actions
claus
parents: 50
diff changeset
   833
     are performed.
claus
parents: 50
diff changeset
   834
claus
parents: 50
diff changeset
   835
     The block is passed two arguments, the progressValue,
claus
parents: 50
diff changeset
   836
     which should be set to the percentage from time-to-time
claus
parents: 50
diff changeset
   837
     within the block and an action value, which should be set to
claus
parents: 50
diff changeset
   838
     the currently performed action (a string) from time to time.
claus
parents: 50
diff changeset
   839
     The second valueHolder can be left unchanged.
claus
parents: 50
diff changeset
   840
claus
parents: 50
diff changeset
   841
     Caveat: cannot (currently) suppress close of the box ..."
claus
parents: 50
diff changeset
   842
221
976e5a608dfb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
   843
    |progressValue labelValue p|
62
claus
parents: 50
diff changeset
   844
claus
parents: 50
diff changeset
   845
    progressValue := 0 asValue.
claus
parents: 50
diff changeset
   846
    labelValue := '' asValue.
claus
parents: 50
diff changeset
   847
claus
parents: 50
diff changeset
   848
    connectedLabel notNil ifTrue:[
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   849
        connectedLabel 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   850
            model:labelValue;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   851
            aspect:#value;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   852
            labelMessage:#value.
62
claus
parents: 50
diff changeset
   853
    ].
claus
parents: 50
diff changeset
   854
claus
parents: 50
diff changeset
   855
    self model:progressValue.
claus
parents: 50
diff changeset
   856
221
976e5a608dfb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
   857
    "/ the worker process
976e5a608dfb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
   858
62
claus
parents: 50
diff changeset
   859
    p := [
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   860
        [
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   861
            WindowGroup windowGroupQuerySignal handle:[:ex |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   862
                ex proceedWith:self topView windowGroup
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   863
            ] do:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   864
                aBlock value:progressValue value:labelValue
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   865
            ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   866
        ] valueNowOrOnUnwindDo:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   867
            p := nil.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   868
            closeTopWhenDone ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   869
                connectedTop hide
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   870
            ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   871
            finishAction notNil ifTrue:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   872
                finishAction value
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   873
            ]
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   874
        ]
62
claus
parents: 50
diff changeset
   875
    ] fork.
claus
parents: 50
diff changeset
   876
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   877
    Processor activeProcess 
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   878
        withPriority:(Processor activePriority + 1)
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   879
        do:[
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   880
            self topView show.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   881
        ].
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   882
    p notNil ifTrue:[p terminate].
62
claus
parents: 50
diff changeset
   883
claus
parents: 50
diff changeset
   884
    "
claus
parents: 50
diff changeset
   885
      |p|
claus
parents: 50
diff changeset
   886
claus
parents: 50
diff changeset
   887
      p := ProgressIndicator inBox.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   888
      p showBusyIndication:true.
62
claus
parents: 50
diff changeset
   889
      p showProgressOf:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   890
            [:progressValue :currentAction |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   891
                1 to:200 do:[:percent |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   892
                    (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   893
                    progressValue value:percent 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   894
                ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   895
            ].
62
claus
parents: 50
diff changeset
   896
claus
parents: 50
diff changeset
   897
      'it can be reused ...'.  
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   898
      p showBusyIndication:false.
62
claus
parents: 50
diff changeset
   899
      p showProgressOf:
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   900
            [:progressValue :currentAction |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   901
                1 to:100 by:5 do:[:percent |
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   902
                    (Delay forSeconds:0.05) wait.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   903
                    progressValue value:percent 
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   904
                ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   905
            ].
62
claus
parents: 50
diff changeset
   906
claus
parents: 50
diff changeset
   907
    "
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   908
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   909
    "Modified: / 21.10.1998 / 17:37:00 / cg"
62
claus
parents: 50
diff changeset
   910
! !
claus
parents: 50
diff changeset
   911
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   912
!ProgressIndicator class methodsFor:'documentation'!
50
claus
parents:
diff changeset
   913
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   914
version
1328
95a7d89cf335 category change
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   915
    ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.26 1999-04-23 12:46:51 cg Exp $'
50
claus
parents:
diff changeset
   916
! !