Activity is a 4D v14 component which provides thermometer/barber pole progress indicators that are animated while executing code in the same process. It allows the developer to customize many aspects of its display objects (including colors, fonts, etc.), display and change text messages displayed along with the progress indicator, enable or disable an associated cancel button and determine if the user has clicked the cancel button. The developer can freely switch between a thermometer and barber pole during complex processing. In addition, multiple progress indicators can appear within the same form, each with their own characteristics.
Thermometer example:
Barber pole example:
- Example
- Installation
- Dependencies
- Adding a Progress Indicator to a Form
- Methods
- Activity_DisableCancelButton (SubformObjectName)
- Activity_EnableCancelButton (SubformObjectName)
- Activity_Hide (SubformObjectName)
- Activity_ResetUserCanceled (SubformObjectName)
- Activity_Resize (SubformObjectName)
- Activity_SetBackgroundColor (SubformObjectName; Color)
- Activity_SetCancelButtonColors (SubformObjectName; EnabledColor; {HoverColor; ClickColor; DisabledColor})
- Activity_SetFontColor (SubformObjectName; Color)
- Activity_SetFontFamily (SubformObjectName; FontFamily)
- Activity_SetFontWeight (SubformObjectName; FontWeight)
- Activity_SetMeterBackgrndColor (SubformObjectName; Color)
- Activity_SetMeterBorderColor (SubformObjectName; Color)
- Activity_SetMeterColor (SubformObjectName; Color)
- Activity_SetStepsCompleted (SubformObjectName; Steps)
- Activity_SetText (SubformObjectName; Text)
- Activity_SetTextWidthPercentage (SubformObjectName; Percentage)
- Activity_SetTotalSteps (SubformObjectName; Steps)
- Activity_Show (SubformObjectName)
- Activity_ShowBarberPole (SubformObjectName)
- Activity_UserCanceled (SubformObjectName)
- Known Issues
- Support
- Testing
- Contributions
- Contributors
- License
C_TEXT($ProgressIndicator)
$ProgressIndicator:="Progress"
Activity_ResetUserCanceled ($ProgressIndicator)
Activity_EnableCancelButton ($ProgressIndicator)
Activity_SetTextWidthPercentage ($ProgressIndicator;60)
Activity_SetText ($ProgressIndicator;"Searching for clients...")
Activity_ShowBarberPole ($ProgressIndicator)
Activity_Show ($ProgressIndicator)
QUERY([Clients];[Clients]School="Valley High")
Activity_SetText ($ProgressIndicator;"Capitalizing client names...")
Activity_SetStepsCompleted ($ProgressIndicator;0)
Activity_SetTotalSteps ($ProgressIndicator;Records in selection([Clients]))
While (Not(End selection([Clients])) & Not(Activity_UserCanceled ($ProgressIndicator)))
[Clients]LastName:=Uppercase([Clients]LastName)
SAVE RECORD([Clients])
Activity_SetStepsCompleted ($ProgressIndicator;Selected record number([Clients]))
End while
Activity_Hide ($ProgressIndicator)
Simply copy the Activity.4dbase component file into the Components folder for your 4D structure file.
- 4D v14.3+ (tested with v14.3)
###Using the Activity Object Library
- Choose File > Open > Object Library.
- Open the Activity.4dlibrary 4D object library file supplied with the Activity component.
- Drag the Progress Area object onto the form.
- Size the object as desired. The progress indicator will automatically resize its contents to fill the available area.
The progress indicators are designed to be horizontal, so it is better to make the horizontal length greater than the height. The minimum height to be sure the cancel button can fit properly is 15 pixels. If you plan on displaying text, be sure to include enough space to fit the anticipated longest message. 5. Call Activity_Resize in the form method when the subform area is resized.
###Manually Adding Using a Subform Object
- Add a subform object to the form.
- Size the subform object as desired. The progress indicator will automatically resize its contents to fill the available area.
The progress indicators are designed to be horizontal, so it is better to make the horizontal length greater than the height. The minimum height to be sure the cancel button can fit properly is 15 pixels. If you plan on displaying text, be sure to include enough space to fit the anticipated longest message. 3. Uncheck Output Subform in the subform's property list. 4. Enter Activity_Subform into the Detail Form field in the subform's property list. 5. Uncheck Horizontal Scroll Bar and Vertical Scroll Bar in the subform's property list. 6. You will probably want to uncheck Focusable in the subform's property list. 7. Call Activity_Resize in the form method when the subform area is resized.
Disables the stop button for the progress indicator within the given subform. After calling this method, user clicks on the stop button have no effect.
SubformObjectName
String - The name of the subform object containing the progress indicator.
Examples:
Activity_DisableCancelButton("ProgressIndicator")
Enables the stop button for the progress indicator within the given subform. After calling this method, user clicks on the stop button will be honored.
SubformObjectName
String - The name of the subform object containing the progress indicator.
Examples:
Activity_EnableCancelButton("ProgressIndicator")
Makes the progress indicator invisible within the given subform. Use Activity_Show to make it visible.
SubformObjectName
String - The name of the subform object containing the progress indicator.
Examples:
Activity_Hide("ProgressIndicator")
Sets the user canceled indicator to False within the given subform.
SubformObjectName
String - The name of the subform object containing the progress indicator.
Examples:
Activity_ResetUserCanceled("ProgressIndicator")
Call this method if the subform object containing the progress indicator is resized.
SubformObjectName
String - The name of the subform object containing the progress indicator.
Examples:
Activity_Resize("ProgressIndicator")
Sets the background color of the progress indicator area. This will typically be the background color of the area where the subform is located on the form.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Color
String - The color to use for the background. Any css color value is accepted.
Examples:
Activity_SetBackgroundColor("ProgressIndicator")
Activity_SetCancelButtonColors (SubformObjectName; EnabledColor; {HoverColor; ClickColor; DisabledColor})
Sets the colors to be displayed for the cancel button.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
EnabledColor
String - The normal color of the cancel button when it is enabled. Any css color value is accepted.
-
HoverColor
String - The color of the cancel button when the mouse cursor is hovering over it. Any css color value is accepted. -
ClickColor
String - The color of the cancel button when the mouse is clicking on it. Any css color value is accepted. -
DisabledColor
String - The color of the cancel button when it is disabled. Any css color value is accepted.
Examples:
Activity_SetCancelButtonColors("ProgressIndicator";"#666";#333";"black";"rgba(0, 0, 0, 0.3)")
Sets the color of the progress indicator text.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Color
String - The color of the text. Any css color value is accepted.
Examples:
Activity_SetFontColor("ProgressIndicator";"#666")
Sets the font family for the progress indicator text.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
FontFamily
String - The font family for the text.
Examples:
Activity_SetFontFamily("ProgressIndicator";"\"Times New Roman\", Georgia, Serif")
Sets the font weight for the progress indicator text.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
FontWeight
String - The font weight for the text.
Examples:
Activity_SetFontWeight("ProgressIndicator";"300")
Sets the color of the progress meter background which extends from its border to the thermometer or barber pole graphic.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Color
String - The color of the meter background. Any css color value is accepted.
Examples:
Activity_SetMeterBackgrndColor("ProgressIndicator";"white")
Sets the color of the progress meter border.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Color
String - The color of the meter border. Any css color value is accepted.
Examples:
Activity_SetMeterBorderColor("ProgressIndicator";"DarkGray")
Sets the color of the progress meter. When displaying a thermometer, the given solid color is used. For a barber pole, the given solid color with lighter stripes is used. Therefore, light colors don't work as well for barber poles.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Color
String - The color of the meter. Any css color value is accepted.
Examples:
Activity_SetMeterColor("ProgressIndicator";"orange")
Sets the number of steps completed during a determinate task. The percentage completed is displayed in the progress meter indicator based on this value and that set using Activity_SetTotalSteps.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Steps
Longint - The number of steps completed. This value must be greater than or equal to 0.
Examples:
Activity_SetStepsCompleted("ProgressIndicator";Selected record number([Clients]))
Sets the text to display. Be sure that the text width percentage is set greater than 0 by setting this value using the Activity_SetTextWidthPercentage method.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Text
String - The text to display.
Examples:
Activity_SetText("ProgressIndicator";"Searching...")
Sets the percentage of the subform area to devote to displaying text using the Activity_SetText method.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Percentage
Real - The percentage of the subform area to devote to displaying text. If a text value is too long to fit within this width, it is clipped with an added ellipsis. Set this value to 0 to display the progress meter across the entire width of the subform area and text will no longer appear.
Examples:
Activity_SetTextWidthPercentage("ProgressIndicator";60)
Sets the total number of steps to be completed during a determinate task. The percentage completed is displayed in the progress meter indicator based on this value and that set using Activity_SetStepsCompleted.
-
SubformObjectName
String - The name of the subform object containing the progress indicator. -
Steps
Longint - The number of steps to be completed. This value must be greater than 0.
Examples:
Activity_SetTotalSteps("ProgressIndicator";Records in selection([Clients]))
Makes the progress indicator visible within the given subform. Use Activity_Hide to make it invisible.
SubformObjectName
String - The name of the subform object containing the progress indicator.
Examples:
Activity_Show("ProgressIndicator")
Displays a barber pole in the progress indicator.
SubformObjectName
String - The name of the subform object containing the progress indicator.
Examples:
Activity_ShowBarberPole("ProgressIndicator")
Returns True if the user clicked the cancel button and returns False otherwise.
-
SubformObjectName
String - The name of the subform object containing the progress indicator.- A boolean value indicating if the user clicked the cancel button (True) or has not clicked it (False). If the user clicked the cancel button, the value can be reset to False by calling the Activity_ResetUserCanceled method.
Examples:
Activity_UserCanceled("ProgressIndicator")
When the subform object is resized, the web area used to display the progress indicator does not behave properly. I hope to address this issue in a future release. Until then, it is recommended that you use non-resizable subform areas.
Need to disallow the dropping of URLs or files onto the web area. The version of 4D past v14.3 is needed for this.
This component is offered "as is" with no support. If you have a question, feature request or bug report, please email [email protected], however a response is not guaranteed.
This component has been tested with 4D v14.3 on Mac OS X 10.9.5 and Windows 7 Service Pack 1.
If you wish to contribute to the development of this component, send a pull request. Please remember to update this markdown documentation if the public interface changes.
Thanks to Chris Coyier and his CSS-TRICKS website. Progress meter code and ideas were derived from http://css-tricks.com/css3-progress-bars/.
Cancel button code from http://enjoycss.com/gallery/shapes/gn#text.
Licensed under MIT.
Copyright (C) 2015 Jeff Grann [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.