ProgressIndicator.st
author Claus Gittinger <cg@exept.de>
Fri, 18 Sep 2009 18:09:36 +0200
changeset 3748 4d72710a919e
parent 3626 b2087f53346e
child 3827 ec0aed04e61f
permissions -rw-r--r--
care for being not shown
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
"
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
1789
99a33f0b2164 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1740
diff changeset
    13
50
claus
parents:
diff changeset
    14
View subclass:#ProgressIndicator
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
    15
	instanceVariableNames:'percentage showPercentage fgColor bgColor connectedTop
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    16
		connectedLabel collector finishAction closeTopWhenDone showBusy
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    17
		busyPosition busyDelta busyIndicationProcess'
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    18
	classVariableNames:''
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    19
	poolDictionaries:''
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    20
	category:'Views-Misc'
50
claus
parents:
diff changeset
    21
!
claus
parents:
diff changeset
    22
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    23
!ProgressIndicator class methodsFor:'documentation'!
50
claus
parents:
diff changeset
    24
62
claus
parents: 50
diff changeset
    25
copyright
claus
parents: 50
diff changeset
    26
"
claus
parents: 50
diff changeset
    27
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 50
diff changeset
    28
	      All Rights Reserved
claus
parents: 50
diff changeset
    29
claus
parents: 50
diff changeset
    30
 This software is furnished under a license and may be used
claus
parents: 50
diff changeset
    31
 only in accordance with the terms of that license and with the
claus
parents: 50
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
claus
parents: 50
diff changeset
    33
 be provided or otherwise made available to, or used by, any
claus
parents: 50
diff changeset
    34
 other person.  No title to or ownership of the software is
claus
parents: 50
diff changeset
    35
 hereby transferred.
claus
parents: 50
diff changeset
    36
"
claus
parents: 50
diff changeset
    37
!
claus
parents: 50
diff changeset
    38
50
claus
parents:
diff changeset
    39
documentation
claus
parents:
diff changeset
    40
"
claus
parents:
diff changeset
    41
    a view showing a rectangle filled according the percentage value.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    42
    Can be used as a progress indicator a la MSwindows;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    43
    it can also be configured as a non-percentage busy indication
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    44
    via the showBusyIndication flag (a la netscape).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    45
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    46
    Can be used as a widget within an application, or
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    47
    via the convenient #inBox: instance creation messages,
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    48
    which shows a progressDisplay in a modalBox, while some
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    49
    action is performed.
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    50
    See examples.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    51
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    52
    [author:]
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    53
	Claus Gittinger
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    54
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    55
    [see also:]
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    56
	ActionWaitBox AnimatedLabel
50
claus
parents:
diff changeset
    57
"
claus
parents:
diff changeset
    58
!
claus
parents:
diff changeset
    59
claus
parents:
diff changeset
    60
examples
claus
parents:
diff changeset
    61
"
62
claus
parents: 50
diff changeset
    62
    basic (internal) interface
claus
parents: 50
diff changeset
    63
    (if progress indicator is to be used in a complex box ...):
50
claus
parents:
diff changeset
    64
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    65
    Before you get frustrated - see the convenient-interface examples
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    66
    at the end ;-)
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    67
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    68
									[exBegin]
50
claus
parents:
diff changeset
    69
      |top p h|
claus
parents:
diff changeset
    70
62
claus
parents: 50
diff changeset
    71
      top := ModalBox new.
50
claus
parents:
diff changeset
    72
      top extent:300@100.
claus
parents:
diff changeset
    73
      top label:'Progress'.
claus
parents:
diff changeset
    74
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
    75
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
    76
      p level:-1.
62
claus
parents: 50
diff changeset
    77
      h := p preferredExtent y.
50
claus
parents:
diff changeset
    78
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    79
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    80
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    81
	rightInset:5.
50
claus
parents:
diff changeset
    82
claus
parents:
diff changeset
    83
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    84
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    85
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    86
	      p percentage:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    87
	  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    88
	  top hide.
62
claus
parents: 50
diff changeset
    89
      ] fork.
claus
parents: 50
diff changeset
    90
      top open.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    91
									[exEnd]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    92
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    93
    as a busy indicator
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    94
									[exBegin]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    95
      |top p h|
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    96
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    97
      top := ModalBox new.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    98
      top extent:300@100.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    99
      top label:'Busy'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   100
      p := ProgressIndicator in:top.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   101
      p origin:(0.0@0.5) corner:(1.0@0.5).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   102
      p level:-1.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   103
      h := p preferredExtent y.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   104
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   105
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   106
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   107
	rightInset:5.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   108
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   109
      p showBusyIndication:true.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   110
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   111
	  'do something here ....'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   112
	  (Delay forSeconds:5) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   113
	  top hide.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   114
      ] fork.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   115
      top open.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   116
									[exEnd]
50
claus
parents:
diff changeset
   117
claus
parents:
diff changeset
   118
    changing colors, turning percentage display off:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   119
									[exBegin]
50
claus
parents:
diff changeset
   120
      |top p h|
claus
parents:
diff changeset
   121
claus
parents:
diff changeset
   122
      top := StandardSystemView new.
claus
parents:
diff changeset
   123
      top extent:300@100.
claus
parents:
diff changeset
   124
      top label:'Progress'.
claus
parents:
diff changeset
   125
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   126
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   127
      p level:-1.
claus
parents:
diff changeset
   128
      p showPercentage:false.
claus
parents:
diff changeset
   129
      p foregroundColor:(Color red).
claus
parents:
diff changeset
   130
      h := 10.
claus
parents:
diff changeset
   131
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   132
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   133
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   134
	rightInset:5.
50
claus
parents:
diff changeset
   135
      top open.
claus
parents:
diff changeset
   136
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   137
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   138
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   139
	      p percentage:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   140
	  ]
50
claus
parents:
diff changeset
   141
      ] fork
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   142
									[exEnd]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   143
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   144
    as a busy indicator and percentage display (as in netscape)
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   145
									[exBegin]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   146
      |top p h|
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   147
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   148
      top := ModalBox new.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   149
      top extent:300@60.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   150
      top label:'Busy'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   151
      p := ProgressIndicator in:top.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   152
      p origin:(0.0@0.5) corner:(1.0@0.5).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   153
      p level:-1.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   154
      p showPercentage:false.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   155
      p backgroundColor:(Color cyan).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   156
      h := p preferredExtent y.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   157
      p topInset:(h // 3) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   158
	bottomInset:(h // 3) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   159
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   160
	rightInset:5.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   161
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   162
      p showBusyIndication:true.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   163
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   164
	  top label:'Busy'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   165
	  1 to:100 do:[:i |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   166
	    (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   167
	  ].
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   168
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   169
	  top label:'Percentage'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   170
	  p showBusyIndication:false.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   171
	  1 to:100 do:[:i |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   172
	    (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   173
	    p percentage:i. 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   174
	  ].
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   175
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   176
	  top hide.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   177
      ] fork.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   178
      top open.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   179
									[exEnd]
50
claus
parents:
diff changeset
   180
claus
parents:
diff changeset
   181
    with border (2D look):
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   182
									[exBegin]
50
claus
parents:
diff changeset
   183
      |top p h|
claus
parents:
diff changeset
   184
claus
parents:
diff changeset
   185
      top := StandardSystemView new.
claus
parents:
diff changeset
   186
      top extent:300@100.
claus
parents:
diff changeset
   187
      top label:'Progress'.
claus
parents:
diff changeset
   188
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   189
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   190
      p borderWidth:1.
62
claus
parents: 50
diff changeset
   191
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   192
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   193
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   194
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   195
	rightInset:5.
50
claus
parents:
diff changeset
   196
      top open.
claus
parents:
diff changeset
   197
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   198
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   199
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   200
	      p percentage:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   201
	  ]
50
claus
parents:
diff changeset
   202
      ] fork
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   203
									[exEnd]
50
claus
parents:
diff changeset
   204
claus
parents:
diff changeset
   205
claus
parents:
diff changeset
   206
    getting progress from a model:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   207
									[exBegin]
50
claus
parents:
diff changeset
   208
      |model top p h|
claus
parents:
diff changeset
   209
claus
parents:
diff changeset
   210
      model := 0 asValue.
claus
parents:
diff changeset
   211
claus
parents:
diff changeset
   212
      top := StandardSystemView new.
claus
parents:
diff changeset
   213
      top extent:300@100.
claus
parents:
diff changeset
   214
      top label:'Progress'.
claus
parents:
diff changeset
   215
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   216
      p model:model.
claus
parents:
diff changeset
   217
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   218
      p level:-1.
62
claus
parents: 50
diff changeset
   219
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   220
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   221
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   222
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   223
	rightInset:5.
50
claus
parents:
diff changeset
   224
      top open.
claus
parents:
diff changeset
   225
claus
parents:
diff changeset
   226
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   227
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   228
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   229
	      model value:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   230
	  ]
50
claus
parents:
diff changeset
   231
      ] fork
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   232
									[exEnd]
50
claus
parents:
diff changeset
   233
62
claus
parents: 50
diff changeset
   234
50
claus
parents:
diff changeset
   235
    concrete example:
claus
parents:
diff changeset
   236
      search all files in the source directory for a string
claus
parents:
diff changeset
   237
      using grep. Show progress while doing so.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   238
									[exBegin]
50
claus
parents:
diff changeset
   239
      |top p h names done|
claus
parents:
diff changeset
   240
claus
parents:
diff changeset
   241
      top := StandardSystemView new.
claus
parents:
diff changeset
   242
      top extent:300@100.
claus
parents:
diff changeset
   243
      top label:'Searching ...'.
claus
parents:
diff changeset
   244
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   245
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   246
      p level:-1.
62
claus
parents: 50
diff changeset
   247
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   248
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   249
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   250
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   251
	rightInset:5.
50
claus
parents:
diff changeset
   252
      top openWithPriority:(Processor activePriority + 1).
claus
parents:
diff changeset
   253
claus
parents:
diff changeset
   254
      names := 'source' asFilename directoryContents.
claus
parents:
diff changeset
   255
      done := 0.
claus
parents:
diff changeset
   256
      names do:[:aName |
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   257
	|fn stream line|
50
claus
parents:
diff changeset
   258
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   259
	p percentage:(done / names size * 100).
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   260
	fn := ('source/' , aName) asFilename.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   261
	fn isDirectory ifFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   262
	    stream := fn readStream.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   263
	    [stream atEnd] whileFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   264
		line := stream nextLine.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   265
		(line findString:'subclass:') ~~ 0 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   266
		    Transcript showCR:line
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   267
		].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   268
	    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   269
	    stream close.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   270
	].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   271
	done := done + 1
50
claus
parents:
diff changeset
   272
      ].
claus
parents:
diff changeset
   273
claus
parents:
diff changeset
   274
      top destroy
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   275
									[exEnd]
62
claus
parents: 50
diff changeset
   276
claus
parents: 50
diff changeset
   277
claus
parents: 50
diff changeset
   278
   using the convenient inBox-interface
claus
parents: 50
diff changeset
   279
claus
parents: 50
diff changeset
   280
   (this creates a box and an activity label and evaluates a block
claus
parents: 50
diff changeset
   281
    to indicate ...)
claus
parents: 50
diff changeset
   282
claus
parents: 50
diff changeset
   283
    basic interface demonstration:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   284
									[exBegin]
62
claus
parents: 50
diff changeset
   285
      |p|
claus
parents: 50
diff changeset
   286
claus
parents: 50
diff changeset
   287
      p := ProgressIndicator 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   288
		inBoxWithLabel:'doing something  ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   289
		abortable:true.
62
claus
parents: 50
diff changeset
   290
      p showProgressOf:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   291
	    [:progressValue :currentAction |
62
claus
parents: 50
diff changeset
   292
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   293
	      1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   294
		  (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   295
		  val == 25 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   296
		      currentAction value:'still going ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   297
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   298
		  val == 50 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   299
		      currentAction value:'halfway through ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   300
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   301
		  val == 75 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   302
		      currentAction value:'almost finished ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   303
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   304
		  progressValue value:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   305
	      ]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   306
	    ]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   307
									[exEnd]
62
claus
parents: 50
diff changeset
   308
claus
parents: 50
diff changeset
   309
claus
parents: 50
diff changeset
   310
    above search example using this convenient interface:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   311
									[exBegin]
62
claus
parents: 50
diff changeset
   312
      |p|
claus
parents: 50
diff changeset
   313
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   314
      p := ProgressIndicator 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   315
		inBoxWithLabel:'searching files ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   316
		abortable:false.
62
claus
parents: 50
diff changeset
   317
      p showProgressOf:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   318
	    [:progressValue :currentAction |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   319
		|names nDone|
62
claus
parents: 50
diff changeset
   320
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   321
		names := 'source' asFilename directoryContents.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   322
		nDone := 0.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   323
		names do:[:aName |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   324
		  |fn stream line|
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   325
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   326
		  progressValue value:(nDone / names size * 100).
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   327
		  currentAction value:'searching ' , 'source/' , aName , ' ...'.
62
claus
parents: 50
diff changeset
   328
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   329
		  fn := ('source/' , aName) asFilename.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   330
		  fn isDirectory ifFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   331
		      stream := fn readStream.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   332
		      [stream atEnd] whileFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   333
			  line := stream nextLine.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   334
			  (line findString:'subclass:') ~~ 0 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   335
			      Transcript showCR:line
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   336
			  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   337
		      ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   338
		      stream close.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   339
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   340
		  nDone := nDone + 1
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   341
		].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   342
	    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   343
									[exEnd]
62
claus
parents: 50
diff changeset
   344
claus
parents: 50
diff changeset
   345
claus
parents: 50
diff changeset
   346
    a nice example: copying files a la windows ...
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   347
    the following copies all files to /dev/null.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   348
									[exBegin]
62
claus
parents: 50
diff changeset
   349
      |p|
claus
parents: 50
diff changeset
   350
claus
parents: 50
diff changeset
   351
      (ProgressIndicator 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   352
		inBoxWithLabel:'copy files to /dev/null ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   353
		abortable:true)
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   354
	 showProgressOf:
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   355
	    [:progressValue :currentAction |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   356
		|files nFiles nDone|
62
claus
parents: 50
diff changeset
   357
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   358
		files := '.' asFilename directoryContents.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   359
		nFiles := files size.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   360
		nDone := 0.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   361
		files do:[:aFileName |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   362
		    |percent|
50
claus
parents:
diff changeset
   363
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   364
		    nDone := nDone + 1.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   365
		    percent := nDone / nFiles * 100.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   366
		    progressValue value:percent. 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   367
		    aFileName asFilename isDirectory ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   368
			Transcript showCR:('skipping ' , aFileName , ' ...'). 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   369
			currentAction value:('skipping ' , aFileName , ' ...'). 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   370
		    ] ifFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   371
			Transcript showCR:('copying ' , aFileName , ' ...').
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   372
			currentAction value:('copying ' , aFileName , ' ...').
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   373
			Object errorSignal handle:[:ex |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   374
			    self warn:'an error occurred while copying ' , aFileName.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   375
			    ex return
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   376
			] do:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   377
			    aFileName asFilename copyTo:'/dev/null'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   378
			]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   379
		    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   380
		].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   381
	    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   382
									[exEnd]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   383
"
50
claus
parents:
diff changeset
   384
! !
claus
parents:
diff changeset
   385
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   386
!ProgressIndicator class methodsFor:'instance creation'!
62
claus
parents: 50
diff changeset
   387
claus
parents: 50
diff changeset
   388
inBox
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   389
    "create a topView containing an instance of myself,
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   390
     for later use with #showProgressOf:"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   391
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   392
    ^ self inBoxWithLabel:'executing ...' abortable:false
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   393
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   394
    "Modified: 22.10.1997 / 21:08:37 / cg"
62
claus
parents: 50
diff changeset
   395
!
claus
parents: 50
diff changeset
   396
claus
parents: 50
diff changeset
   397
inBoxWithLabel:aLabel
claus
parents: 50
diff changeset
   398
    "create a topView containing an instance of myself,
claus
parents: 50
diff changeset
   399
     for later use with #showProgressOf:"
claus
parents: 50
diff changeset
   400
claus
parents: 50
diff changeset
   401
    ^ self inBoxWithLabel:aLabel abortable:false 
claus
parents: 50
diff changeset
   402
!
claus
parents: 50
diff changeset
   403
claus
parents: 50
diff changeset
   404
inBoxWithLabel:aLabel abortable:abortable
claus
parents: 50
diff changeset
   405
    "create a topView containing an instance of myself,
claus
parents: 50
diff changeset
   406
     for later use with #showProgressOf:"
claus
parents: 50
diff changeset
   407
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   408
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   409
	inBoxWithLabel:aLabel   
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   410
	text:''
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   411
	abortable:abortable
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   412
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   413
    "Modified: 17.7.1996 / 15:14:58 / cg"
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   414
!
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   415
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   416
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
   417
    "create a topView containing an instance of myself,
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   418
     return the new instance, for later use with #showProgressOf:"
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   419
2436
6c0df331b7b1 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 2435
diff changeset
   420
    |top p l y y2|
62
claus
parents: 50
diff changeset
   421
claus
parents: 50
diff changeset
   422
    top := Dialog new.
claus
parents: 50
diff changeset
   423
    top label:aLabel.
claus
parents: 50
diff changeset
   424
    top cursor:(Cursor wait).
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   425
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   426
    y2 := 0.
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   427
    anIcon notNil ifTrue:[
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   428
        y := top yPosition.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   429
        l := top addTextLabel:anIcon.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   430
        l borderWidth:0.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   431
        l adjust:#left.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   432
        l cursor:(Cursor wait).
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   433
        y2 := top yPosition.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   434
        top yPosition:y.
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   435
    ].
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   436
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   437
    l := top addTextLabel:text.
62
claus
parents: 50
diff changeset
   438
    l borderWidth:0.
74
claus
parents: 62
diff changeset
   439
    l adjust:#left.
62
claus
parents: 50
diff changeset
   440
    l cursor:(Cursor wait).
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   441
    anIcon notNil ifTrue: [l leftInset:(anIcon width + 10)].
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   442
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   443
    top yPosition:(top yPosition max:y2).
62
claus
parents: 50
diff changeset
   444
claus
parents: 50
diff changeset
   445
    top addVerticalSpace.
claus
parents: 50
diff changeset
   446
claus
parents: 50
diff changeset
   447
    p := ProgressIndicator new.
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   448
    p extent:(1.0 @ p preferredHeight).
62
claus
parents: 50
diff changeset
   449
    p level:-1.
claus
parents: 50
diff changeset
   450
    p leftInset:5;
claus
parents: 50
diff changeset
   451
      rightInset:5.
claus
parents: 50
diff changeset
   452
    p cursor:(Cursor wait).
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   453
    p closeTopWhenDone:closeWhenDoneBoolean.
62
claus
parents: 50
diff changeset
   454
    p connectToTop:top label:l.
claus
parents: 50
diff changeset
   455
claus
parents: 50
diff changeset
   456
    top addComponent:p.
claus
parents: 50
diff changeset
   457
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   458
    additionalView notNil ifTrue:[
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   459
        top addComponent:additionalView.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   460
        additionalView extent:(1.0 @ additionalView preferredHeight).
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   461
    ].
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   462
62
claus
parents: 50
diff changeset
   463
    abortable ifTrue:[
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   464
        top addVerticalSpace.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   465
        top addAbortButton
62
claus
parents: 50
diff changeset
   466
    ].
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   467
    abortable ifFalse:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   468
        "/ top beUndecorated.  -- buggy for now; sets wrong height (caption not included ?)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   469
        "/ would need the following kludge:
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   470
        "/ top preferredExtent:(top preferredExtent + (0@30)).
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   471
    ].
62
claus
parents: 50
diff changeset
   472
claus
parents: 50
diff changeset
   473
    ^ p
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   474
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   475
    "Created: 17.7.1996 / 15:14:33 / cg"
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   476
    "Modified: 17.7.1996 / 15:16:58 / cg"
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   477
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   478
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   479
inBoxWithLabel:aLabel text:text abortable:abortable
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   480
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   481
     for later use with #showProgressOf:"
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
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   484
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   485
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   486
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   487
	view:nil
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   488
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   489
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   490
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   491
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   492
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   493
     for later use with #showProgressOf:"
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
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   496
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   497
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   498
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   499
	view:additionalView 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   500
	closeWhenDone:true
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   501
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   502
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   503
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   504
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   505
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   506
     for later use with #showProgressOf:"
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   507
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   508
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   509
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   510
	icon:nil
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   511
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   512
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   513
	view:additionalView 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   514
	closeWhenDone:closeWhenDoneBoolean
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   515
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   516
!
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   517
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   518
progressOpenOn:progressModel label:aLabel
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   519
    "create and open a progressIndicator dialog window,
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   520
     bit do not open it modal; instead, it is opened modeless
1834
ba170c21ed76 defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   521
     and control returns to the caller.
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   522
     The models value is assumed to be 0..1 
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   523
     (which is for compatibility and different from ST/X's percentage use)
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   524
     Added for VW compatibility (RB)."
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   525
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   526
    |p ra|
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   527
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   528
    p := self
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   529
	    inBoxWithLabel:aLabel 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   530
	    icon:nil
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   531
	    text:aLabel
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   532
	    abortable:false
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   533
	    view:nil
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   534
	    closeWhenDone:false.
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   535
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   536
    ra := RangeAdaptor on:progressModel start:0 stop:0.01 grid:nil.
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   537
    p model:ra.
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   538
2132
fd5b29a20fe1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2082
diff changeset
   539
    p topView openModeless; waitUntilVisible.
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   540
    ^ p.
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   541
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   542
    "Modified: / 4.2.2000 / 01:25:55 / cg"
62
claus
parents: 50
diff changeset
   543
! !
claus
parents: 50
diff changeset
   544
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   545
!ProgressIndicator class methodsFor:'simple puplic API'!
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   546
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   547
displayBusyIndicator:aLabel abortable:abortable at:aPoint during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   548
    "easy interface - show progress while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   549
     The block is passed the progressIndicator as argument
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   550
     so the block can change the label and/or change the progress value."
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   551
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   552
    |p|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   553
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   554
    p := self
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   555
            inBoxWithLabel:aLabel 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   556
            icon:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   557
            text:aLabel
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   558
            abortable:abortable
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   559
            view:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   560
            closeWhenDone:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   561
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   562
    p showBusyIndication:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   563
    p showBusyIndicatorDuring:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   564
        CannotReturnError catch:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   565
            aBlock valueWithOptionalArgument:p.    
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   566
        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   567
    ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   568
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   569
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   570
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   571
        displayBusyIndicator:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   572
        abortable:true
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   573
        at:(Screen default center)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   574
        during:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   575
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   576
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   577
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   578
        ].
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   579
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   580
     ProgressIndicator
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   581
        displayBusyIndicator:'doobidoobidoo...'
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   582
        abortable:true
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   583
        at:(Screen default center)
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   584
        during:[
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   585
            Delay waitForSeconds:3.
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   586
        ].
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   587
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   588
!
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   589
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   590
displayBusyIndicator:aLabel at:aPoint during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   591
    "easy interface - show progress while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   592
     The block is passed a valueHolder, which is to be set to values from
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   593
     startValue to endValue during the blocks evaluation.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   594
     This is scaled to 0..100% completion.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   595
     Set the valueHolder to nil, to get a busy-indicator"
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   596
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   597
    self
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   598
        displayBusyIndicator:aLabel 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   599
        abortable:false 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   600
        at:aPoint 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   601
        during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   602
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   603
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   604
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   605
        displayBusyIndicator:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   606
        at:(Screen default center)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   607
        during:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   608
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   609
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   610
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   611
        ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   612
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   613
!
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   614
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   615
displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   616
    "easy interface - show progress while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   617
     The block is passed a valueHolder, which is to be set to values from
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   618
     startValue to endValue during the blocks evaluation.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   619
     This is scaled to 0..100% completion.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   620
     Set the valueHolder to nil, to get a busy-indicator"
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   621
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   622
    |p|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   623
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   624
    p := self
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   625
            inBoxWithLabel:aLabel 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   626
            icon:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   627
            text:aLabel
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   628
            abortable:false
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   629
            view:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   630
            closeWhenDone:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   631
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   632
    p showProgressOf:[:progressValue :currentAction |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   633
        |scaler|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   634
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   635
        scaler := [:scaledValue | 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   636
                        |newPercentage oldPercentage oldLabel|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   637
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   638
                        scaledValue isNil ifTrue:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   639
                            p showBusyIndication:true
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   640
                        ] ifFalse:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   641
                            p showBusyIndication:false.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   642
                            oldPercentage := progressValue value.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   643
                            newPercentage := (scaledValue - startValue) / (endValue-startValue) * 100.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   644
                            newPercentage ~= oldPercentage ifTrue:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   645
                                progressValue value:newPercentage.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   646
                            ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   647
                            oldLabel := currentAction value.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   648
                            oldLabel ~= aLabel ifTrue:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   649
                                currentAction value:aLabel.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   650
                            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   651
                        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   652
                  ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   653
        CannotReturnError catch:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   654
            aBlock valueWithOptionalArgument:scaler and:p.    
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   655
        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   656
    ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   657
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   658
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   659
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   660
        displayProgress:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   661
        at:(Screen default center)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   662
        from:200 to:400
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   663
        during:[:val |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   664
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   665
                val value:i.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   666
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   667
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   668
        ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   669
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   670
!
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   671
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   672
displayProgressNotifications:aLabel abortable:abortable at:aPointOrNil during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   673
    "easy interface - show progress as provided by progressNotifications
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   674
     while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   675
     The block is passed the progressIndicator as optional argument,
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   676
     however, progressNotifications are handled and update the percentage."
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   677
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   678
    |p|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   679
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   680
    p := self
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   681
            inBoxWithLabel:aLabel 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   682
            icon:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   683
            text:aLabel
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   684
            abortable:abortable
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   685
            view:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   686
            closeWhenDone:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   687
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   688
    p showBusyIndicatorDuring:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   689
        CannotReturnError catch:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   690
            ProgressNotification handle:[:ex |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   691
                p percentage:ex progressValue.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   692
                ex proceed.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   693
            ] do:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   694
                aBlock valueWithOptionalArgument:p.    
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   695
            ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   696
        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   697
    ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   698
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   699
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   700
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   701
        displayProgressNotifications:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   702
        abortable:true
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   703
        at:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   704
        during:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   705
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   706
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   707
                ProgressNotification progressPercentage:(i / 4).
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   708
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   709
        ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   710
    "
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   711
    "
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   712
     ProgressIndicator
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   713
        displayProgressNotifications:'doobidoobidoo...'
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   714
        abortable:true
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   715
        at:nil
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   716
        during:[
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   717
            Delay waitForSeconds:3.
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   718
        ].
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   719
    "
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   720
! !
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   721
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   722
!ProgressIndicator methodsFor:'accessing'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   723
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   724
percentage:aNumber
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   725
    "set the percentage"
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   726
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   727
    |newPercentage|
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   728
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   729
    aNumber < 0 ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   730
        newPercentage := -1.
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   731
    ] ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   732
        newPercentage := ((aNumber max:0) min:100) rounded.
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   733
    ].
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   734
    newPercentage ~= percentage ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   735
        percentage := newPercentage.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   736
        self invalidateRepairNow:true.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   737
    ]
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   738
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   739
    "Modified: / 6.6.1998 / 19:43:56 / cg"
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   740
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   741
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   742
showBusyIndication:aBooleanHolder
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   743
    "switch between percentage mode (if false) and busy indication (if true)"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   744
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   745
    aBooleanHolder ~~ showBusy ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   746
	showBusy notNil ifTrue:[        
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   747
	    showBusy removeDependent:self.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   748
	].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   749
	showBusy := aBooleanHolder.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   750
	showBusy addDependent:self.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   751
	(showBusy value) ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   752
	    self startBusyIndicationProcess.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   753
	] ifFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   754
	    self stopBusyIndicationProcess
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   755
	].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   756
	shown ifTrue:[self redraw]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   757
    ].
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
    "Created: / 21.10.1998 / 17:35:16 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   760
    "Modified: / 21.10.1998 / 18:03:06 / cg"
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   761
! !
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   762
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   763
!ProgressIndicator methodsFor:'accessing-behavior'!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   764
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   765
closeTopWhenDone:aBoolean
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   766
    "set/clear the close-topView-when-done flag"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   767
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   768
    closeTopWhenDone := aBoolean
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   769
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   770
    "Created: 3.9.1996 / 14:22:03 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   771
    "Modified: 29.3.1997 / 16:08:19 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   772
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   773
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   774
finishAction:aBlock 
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   775
    "define an action to be performed when finished"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   776
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   777
    finishAction := aBlock
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   778
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   779
    "Created: 3.9.1996 / 14:15:15 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   780
    "Modified: 29.3.1997 / 16:08:35 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   781
! !
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   782
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   783
!ProgressIndicator methodsFor:'accessing-look'!
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   784
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   785
backgroundColor 
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   786
    "return the percentage displays background color"
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   787
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   788
    ^ bgColor
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   789
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   790
!
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   791
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   792
backgroundColor:aColor 
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   793
    "set the percentage displays background color"
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   794
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   795
    aColor ~= bgColor ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   796
        bgColor := aColor.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   797
        self invalidateRepairNow:true
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   798
    ].
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   799
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   800
    "Modified: / 20.7.1998 / 23:32:48 / cg"
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   801
!
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   802
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   803
foregroundColor 
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   804
    "return the percentage displays foreground color"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   805
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   806
    ^ fgColor
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   807
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   808
    "Created: 29.3.1997 / 16:12:28 / cg"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   809
!
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   810
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   811
foregroundColor:aColor 
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   812
    "set the percentage displays foreground color"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   813
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   814
    aColor ~= fgColor ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   815
        fgColor := aColor.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   816
        self invalidateRepairNow:true
336
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   817
    ].
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   818
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   819
    "Modified: / 20.7.1998 / 23:27:47 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   820
!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   821
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   822
showPercentage
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   823
    "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
   824
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   825
    ^ showPercentage
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   826
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   827
    "Created: 29.3.1997 / 16:12:39 / cg"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   828
!
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   829
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   830
showPercentage:aBoolean
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   831
    "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
   832
336
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   833
    showPercentage := aBoolean.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   834
    self invalidateRepairNow:true
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   835
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   836
    "Modified: / 6.6.1998 / 19:28:44 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   837
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   838
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   839
!ProgressIndicator methodsFor:'change & update'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   840
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   841
update:aspect with:aParameter from:changedObject
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   842
    "react upon value changes of my model"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   843
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   844
    (aspect == aspectMsg
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   845
    and:[changedObject == model]) ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   846
        self percentage:(model perform:aspectMsg).
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   847
        ^ self
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   848
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   849
    changedObject == showBusy ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   850
        showBusy value 
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   851
            ifTrue:[self startBusyIndicationProcess]
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   852
            ifFalse:[self stopBusyIndicationProcess].
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   853
        self redraw.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   854
        ^ self
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   855
    ].
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   856
    ^ super update:aspect with:aParameter from:changedObject
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   857
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   858
    "Modified: / 21-10-1998 / 18:01:52 / cg"
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   859
    "Modified: / 01-11-2006 / 08:40:50 / janfrog"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   860
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   861
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   862
!ProgressIndicator methodsFor:'drawing'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   863
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   864
redraw
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   865
    "redraw the percentage bar and optional percentage string"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   866
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   867
    |s lx rx sx sy sw m2 m w h doBusy|
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   868
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   869
    self shown ifFalse:[^self].
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   870
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   871
    m := margin + 1.
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   872
    m2 := m*2.
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   873
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   874
    w := width - m2.
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   875
    h := height - m2.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   876
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   877
"/    self clear.
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   878
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   879
    doBusy := showBusy value.
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   880
    doBusy ifFalse:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   881
        percentage value < 0 ifTrue:[
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   882
            self startBusyIndicationProcess.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   883
            doBusy := true.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   884
        ].        
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   885
    ].
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   886
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   887
    doBusy ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   888
        self paint:bgColor.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   889
        self fillRectangleX:m y:m width:w height:h.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   890
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   891
        lx := (w * busyPosition / 100) rounded.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   892
        rx := (w * (busyPosition + 20) / 100) rounded.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   893
        rx := rx min:w.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   894
        lx := lx max:m.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   895
        self paint:fgColor.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   896
        self fillRectangleX:lx y:m width:(rx - lx) height:h.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   897
        ^ self
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   898
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   899
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   900
    self stopBusyIndicationProcess.
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   901
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   902
    rx := (w * percentage / 100) rounded.
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   903
    self paint:bgColor.
843
34de7f6bea2d do only draw what to draw
tz
parents: 826
diff changeset
   904
    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
   905
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   906
    showPercentage ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   907
        s := percentage printString , ' %'.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   908
        font := font onDevice:device.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   909
        sw := font widthOf:s .
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   910
        sx := (width - sw) // 2.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   911
        sy := height // 2 + font descent + 2.
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   912
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   913
        rx <= (sx+sw) ifTrue:[
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   914
            self paint:Color black.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   915
            self displayString:s x:sx y:sy.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   916
        ]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   917
    ].
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   918
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   919
    self paint:fgColor.
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   920
    self fillRectangleX:m y:m width:rx height:h.
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   921
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   922
    showPercentage ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   923
        rx >= sx ifTrue:[
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   924
            self clippingRectangle:(m@m corner:rx+1 @ h).
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   925
            self paint:Color white.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   926
            self displayString:s x:sx y:sy.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   927
            self clippingRectangle:nil
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   928
        ]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   929
    ]
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   930
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   931
    "Modified: / 21-10-1998 / 18:01:58 / cg"
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   932
    "Modified: / 12-12-2006 / 18:26:02 / janfrog"
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   933
!
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   934
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   935
sizeChanged:how
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   936
    super sizeChanged:how.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   937
    self invalidate
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   938
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   939
    "Created: / 18.4.1998 / 02:34:37 / cg"
865
5c15ad847ad2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   940
    "Modified: / 18.4.1998 / 14:09:40 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   941
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   942
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   943
!ProgressIndicator methodsFor:'initialization & release'!
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   944
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   945
destroy
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   946
    busyIndicationProcess notNil ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   947
	self stopBusyIndicationProcess
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   948
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   949
    super destroy.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   950
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   951
    "Created: / 21.10.1998 / 17:29:58 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   952
    "Modified: / 21.10.1998 / 17:30:36 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   953
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   954
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   955
initStyle
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   956
    "initialize styleSheet values"
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   957
575
9279151db8f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   958
    <resource: #style (#'progressIndicator.viewBackground'
2921
1e8c394e895e resource directive
Claus Gittinger <cg@exept.de>
parents: 2878
diff changeset
   959
                       #'progressIndicator.foregroundColor')>
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   960
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   961
    super initStyle.
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   962
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   963
    self is3D ifTrue:[
2921
1e8c394e895e resource directive
Claus Gittinger <cg@exept.de>
parents: 2878
diff changeset
   964
        self level:-1
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   965
    ].
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   966
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   967
    bgColor := styleSheet colorAt:'progressIndicator.viewBackground' default:Color white.
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   968
    fgColor := styleSheet colorAt:'progressIndicator.foregroundColor' default:Color blue.
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   969
    fgColor := fgColor onDevice:device.
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   970
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   971
    showPercentage := true.
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   972
!
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   973
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   974
initialize
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   975
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   976
    super initialize.
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   977
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   978
    percentage := 0.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   979
    showBusy := false.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   980
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   981
    "Modified: / 21.10.1998 / 17:33:02 / cg"
1935
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   982
!
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   983
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   984
mapped
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   985
    super mapped.
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   986
    (showBusy value) ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   987
	self startBusyIndicationProcess.
1935
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   988
    ].
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   989
!
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   990
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   991
unmapped
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   992
    super unmapped.
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   993
    (showBusy value) ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   994
	self stopBusyIndicationProcess.
1935
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
   995
    ].
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   996
! !
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   997
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   998
!ProgressIndicator methodsFor:'private'!
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   999
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1000
connectToTop:top label:label
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1001
    connectedTop := top.
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1002
    connectedLabel := label
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1003
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1004
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1005
startBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1006
    busyIndicationProcess isNil ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1007
	busyPosition := 0.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1008
	busyDelta := 5.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1009
	busyIndicationProcess := [
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1010
				    [self realized] whileTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1011
					Delay waitForSeconds:0.2.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1012
					self shown ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1013
					    self updateBusyIndicatorPosition.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1014
					]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1015
				    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1016
				    busyIndicationProcess := nil.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1017
				 ] fork.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1018
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1019
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1020
    "Created: / 21.10.1998 / 18:02:35 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1021
    "Modified: / 21.10.1998 / 18:03:49 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1022
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1023
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1024
stopBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1025
    busyIndicationProcess notNil ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1026
	busyIndicationProcess terminate.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1027
	busyIndicationProcess := nil
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1028
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1029
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1030
    "Created: / 21.10.1998 / 17:30:19 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1031
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1032
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1033
updateBusyIndicatorPosition
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1034
    busyPosition := busyPosition + busyDelta.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1035
    busyPosition >= 80 ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1036
        busyDelta > 0 ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1037
            busyDelta := busyDelta negated.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1038
        ]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1039
    ] ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1040
        busyPosition <= 0 ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1041
            busyDelta < 0 ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1042
                busyDelta := busyDelta negated.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1043
            ]
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1044
        ]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1045
    ].
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1046
    self invalidate
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1047
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1048
    "Created: / 21.10.1998 / 17:33:28 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1049
    "Modified: / 21.10.1998 / 17:58:58 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1050
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1051
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1052
!ProgressIndicator methodsFor:'queries'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1053
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1054
preferredExtent
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1055
    "return my preferred extent"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1056
3581
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1057
    "/ If I have an explicit preferredExtent..
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1058
    explicitExtent notNil ifTrue:[
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1059
        ^ explicitExtent
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1060
    ].
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1061
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1062
    "/ If I have a cached preferredExtent value..
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1063
    preferredExtent notNil ifTrue:[
3581
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1064
        ^ preferredExtent
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1065
    ].
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1066
    ^ 100 @ (font height + font descent + ((margin + 1) * 2))
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1067
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1068
    "Modified: 22.10.1997 / 21:07:17 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1069
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1070
62
claus
parents: 50
diff changeset
  1071
!ProgressIndicator methodsFor:'showing progress'!
claus
parents: 50
diff changeset
  1072
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1073
showBusyIndicatorDuring:aBlock
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1074
    "show progress, while evaluating aBlock.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1075
     If the receiver has been created with inBox, show the
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1076
     box centered on the screen. If not, the view is assumed to
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1077
     be contained in another view, and no special startup actions
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1078
     are performed.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1079
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1080
     Caveat: cannot (currently) suppress close of the box ..."
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1081
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1082
    |labelValue p|
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1083
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1084
    connectedLabel notNil ifTrue:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1085
        labelValue := (connectedLabel label ? '') asValue.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1086
        connectedLabel 
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1087
            model:labelValue;
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1088
            aspect:#value;
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1089
            labelMessage:#value.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1090
    ] ifFalse:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1091
        labelValue := '' asValue.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1092
    ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1093
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1094
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1095
    "/ the worker process
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1096
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1097
    p := [
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1098
        [
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1099
            WindowGroup windowGroupQuerySignal handle:[:ex |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1100
                ex proceedWith:self topView windowGroup
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1101
            ] do:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1102
                aBlock value
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1103
            ]
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1104
        ] ensure:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1105
            p := nil.
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
  1106
            self stopBusyIndicationProcess.
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1107
            closeTopWhenDone ifTrue:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1108
                connectedTop hide
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1109
            ].
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
  1110
            finishAction value.
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
  1111
            
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1112
        ]
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1113
    ] newProcess.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1114
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1115
    Processor activeProcess 
2878
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1116
        withHigherPriorityDo:
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1117
            [
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1118
                p resume.
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1119
                self topView show.
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1120
            ].
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1121
    p notNil ifTrue:[p terminate].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1122
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1123
    "
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1124
      |p|
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1125
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1126
      p := ProgressIndicator inBox.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1127
      p showBusyIndication:true.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1128
      p showProgressOf:
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1129
            [:progressValue :currentAction |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1130
                1 to:200 do:[:percent |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1131
                    (Delay forSeconds:0.05) wait.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1132
                    progressValue value:percent 
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1133
                ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1134
            ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1135
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1136
      'it can be reused ...'.  
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1137
      p showBusyIndication:false.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1138
      p showProgressOf:
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1139
            [:progressValue :currentAction |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1140
                1 to:100 by:5 do:[:percent |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1141
                    (Delay forSeconds:0.05) wait.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1142
                    progressValue value:percent 
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1143
                ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1144
            ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1145
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1146
    "
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1147
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1148
    "Modified: / 21.10.1998 / 17:37:00 / cg"
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1149
!
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1150
62
claus
parents: 50
diff changeset
  1151
showProgressOf:aBlock
claus
parents: 50
diff changeset
  1152
    "show progress, while evaluating aBlock.
claus
parents: 50
diff changeset
  1153
     If the receiver has been created with inBox, show the
claus
parents: 50
diff changeset
  1154
     box centered on the screen. If not, the view is assumed to
claus
parents: 50
diff changeset
  1155
     be contained in another view, and no special startup actions
claus
parents: 50
diff changeset
  1156
     are performed.
claus
parents: 50
diff changeset
  1157
claus
parents: 50
diff changeset
  1158
     The block is passed two arguments, the progressValue,
claus
parents: 50
diff changeset
  1159
     which should be set to the percentage from time-to-time
claus
parents: 50
diff changeset
  1160
     within the block and an action value, which should be set to
claus
parents: 50
diff changeset
  1161
     the currently performed action (a string) from time to time.
claus
parents: 50
diff changeset
  1162
     The second valueHolder can be left unchanged.
claus
parents: 50
diff changeset
  1163
claus
parents: 50
diff changeset
  1164
     Caveat: cannot (currently) suppress close of the box ..."
claus
parents: 50
diff changeset
  1165
221
976e5a608dfb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
  1166
    |progressValue labelValue p|
62
claus
parents: 50
diff changeset
  1167
claus
parents: 50
diff changeset
  1168
    progressValue := 0 asValue.
claus
parents: 50
diff changeset
  1169
claus
parents: 50
diff changeset
  1170
    connectedLabel notNil ifTrue:[
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1171
        labelValue := (connectedLabel label ? '') asValue.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1172
        connectedLabel 
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1173
            model:labelValue;
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1174
            aspect:#value;
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1175
            labelMessage:#value.
1834
ba170c21ed76 defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1176
    ] ifFalse:[
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1177
        labelValue := '' asValue.
62
claus
parents: 50
diff changeset
  1178
    ].
claus
parents: 50
diff changeset
  1179
1834
ba170c21ed76 defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1180
62
claus
parents: 50
diff changeset
  1181
    self model:progressValue.
claus
parents: 50
diff changeset
  1182
221
976e5a608dfb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
  1183
    "/ the worker process
976e5a608dfb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
  1184
62
claus
parents: 50
diff changeset
  1185
    p := [
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1186
        [
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1187
            WindowGroup windowGroupQuerySignal handle:[:ex |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1188
                ex proceedWith:self topView windowGroup
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1189
            ] do:[
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1190
                aBlock value:progressValue value:labelValue
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1191
            ]
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1192
        ] ensure:[
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1193
            p := nil.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1194
            closeTopWhenDone ifTrue:[
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1195
                connectedTop hide
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1196
            ].
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1197
            finishAction value
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1198
        ]
1850
e22e95d8f184 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1835
diff changeset
  1199
    ] newProcess.
62
claus
parents: 50
diff changeset
  1200
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
  1201
    Processor activeProcess 
2878
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1202
        withHigherPriorityDo:[
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1203
            p resume.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1204
            self topView show.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1205
        ].
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
  1206
    p notNil ifTrue:[p terminate].
62
claus
parents: 50
diff changeset
  1207
claus
parents: 50
diff changeset
  1208
    "
claus
parents: 50
diff changeset
  1209
      |p|
claus
parents: 50
diff changeset
  1210
claus
parents: 50
diff changeset
  1211
      p := ProgressIndicator inBox.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1212
      p showBusyIndication:true.
62
claus
parents: 50
diff changeset
  1213
      p showProgressOf:
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1214
            [:progressValue :currentAction |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1215
                1 to:200 do:[:percent |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1216
                    (Delay forSeconds:0.05) wait.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1217
                    progressValue value:percent 
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1218
                ].
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1219
            ].
62
claus
parents: 50
diff changeset
  1220
claus
parents: 50
diff changeset
  1221
      'it can be reused ...'.  
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1222
      p showBusyIndication:false.
62
claus
parents: 50
diff changeset
  1223
      p showProgressOf:
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1224
            [:progressValue :currentAction |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1225
                1 to:100 by:5 do:[:percent |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1226
                    (Delay forSeconds:0.05) wait.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1227
                    progressValue value:percent 
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1228
                ].
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1229
            ].
62
claus
parents: 50
diff changeset
  1230
claus
parents: 50
diff changeset
  1231
    "
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
  1232
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1233
    "Modified: / 21.10.1998 / 17:37:00 / cg"
62
claus
parents: 50
diff changeset
  1234
! !
claus
parents: 50
diff changeset
  1235
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1236
!ProgressIndicator class methodsFor:'documentation'!
50
claus
parents:
diff changeset
  1237
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1238
version
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1239
    ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.59 2009-09-18 16:09:36 cg Exp $'
50
claus
parents:
diff changeset
  1240
! !