ProgressBar - Kirix Documentation

Developer Resources

ProgressBar

Overview

The ProgressBar class represents a progress bar control.

Base Class

FormControl

Constructor

ProgressBar(orientation : Integer, x_pos : Integer, y_pos : Integer, width : Integer, height : Integer)

Arguments

orientation
Determines the manner in which to create the ProgressBar object, depending on whether it's ProgressBar.Horizontal or ProgressBar.Vertical.
x_pos
The x position of the control.
y_pos
The y position of the control.
width
The width of the control.
height
The height of the control.

Properties

ProgressBar.Horizontal
A flag representing that a horizontal progress bar should be created.
ProgressBar.Vertical
A flag representing that a vertical progress bar should be created.

Methods

ProgressBar.getIndeterminate
Indicates whether the progress bar is in indeterminate mode or not.
ProgressBar.getMaximum
Gets the maximum value the progress bar can have.
ProgressBar.getValue
Gets the current value of the progress bar.
ProgressBar.setIndeterminate
Sets the indeterminate mode of the progress bar.
ProgressBar.setMaximum
Sets the maximum value the progress bar can have.
ProgressBar.setValue
Sets the current value of the progress bar.

Inherited Methods

FormControl.captureMouse
Captures the mouse on this form control.
FormControl.disablePaint
Disables the window from redrawing itself.
FormControl.enablePaint
Enables the window to redraw itself.
FormControl.getBackgroundColor
Gets the background color of the form control.
FormControl.getClientSize
Gets the client size of the form control.
FormControl.getEnabled
Indicates whether or not a form control is enabled.
FormControl.getFont
Gets the default font for the text of form control.
FormControl.getForegroundColor
Gets the foreground color of the form control.
FormControl.getMaxSize
Gets the maximum size of the form control.
FormControl.getMinSize
Gets the minimum size of the form control.
FormControl.getMousePosition
Gets the mouse position relative to this form control.
FormControl.getNativeHandle
Gets the native handle of the window/control
FormControl.getPosition
Gets the position of a form control.
FormControl.getSize
Gets the size of the form control.
FormControl.invalidate
Invalidates a form control, which will cause it to be repainted on the next paint event.
FormControl.refresh
Refreshes a form control, which immediately repaints the entire form control.
FormControl.releaseMouse
Releases the mouse from being captured on this form control.
FormControl.setBackgroundColor
Sets the background color of the form control.
FormControl.setClientSize
Sets the client size of a form control.
FormControl.setEnabled
Enables or disables the form control.
FormControl.setFocus
Sets the focus to the form control.
FormControl.setFont
Sets the default font for the text of the form control.
FormControl.setForegroundColor
Sets the foreground color of the form control.
FormControl.setMaxSize
Sets the maximum size of a form control.
FormControl.setMinSize
Sets the minimum size of a form control.
FormControl.setPosition
Sets the position of a form control relative to the the form control's parent.
FormControl.setSize
Sets the size of a form control.
FormControl.show
Shows or hides the form control.
FormControl.update
Updates a form control, which will immediately repaint any invalid areas.

Example

// create a new progress bar sample form
var f = new MyForm("ProgressBar Example", 0, 0, 400, 110);
f.center();
f.show();
Application.run();


// define the progressbar sample form
class MyForm extends Form
{
    // progress bar member variable
    var m_progressbar;

    function MyForm(caption, x_pos, y_pos, width, height)
    {
        // MyForm() gets called when a new object is created;
        // the super() function calls the contructor on the
        // base class, which in this case is Form since MyForm
        // extends Form
        super(caption, x_pos, y_pos, width, height);

        // create a progress bar and set the member variable
        // to the newly created progress bar
        m_progressbar = new ProgressBar(0,0,0,20);
        m_progressbar.setValue(0);
        m_progressbar.setMaximum(100);

        // create a start button and place it in a button
        // sizer so it's centered in the form
        var start_button = new Button("Start");
        var layout_button = new BoxLayout(Layout.Horizontal);
        layout_button.addStretchSpacer();
        layout_button.add(start_button, 0, Layout.Expand | Layout.Top | Layout.Bottom, 0);
        layout_button.addStretchSpacer();

        // add the progress bar and the start button to
        // the form
        var layout_main = new BoxLayout(Layout.Vertical);
        layout_main.addStretchSpacer();
        layout_main.add(m_progressbar, 0, Layout.Expand | Layout.Left | Layout.Right, 5);
        layout_main.addStretchSpacer();
        layout_main.add(layout_button, 0, Layout.Expand | Layout.Left | Layout.Right, 5);
        layout_main.addSpacer(10);

        // use layout_main for the main form layout
        setLayout(layout_main);

        // connect the start button to the event hander
        start_button.click.connect(this, onStart);
    }

    function onStart(sender, event_args)
    {
        // when the start button is pressed, advance the
        // progress bar to its maximum value
        var max = m_progressbar.getMaximum();
        for (var i = 0; i < max; ++i)
        {
            m_progressbar.setValue(i);
            System.sleep(10);
        }
    }
}

ProgressBar.getIndeterminate

function ProgressBar.getIndeterminate() : Boolean

Returns

Returns true if the progress bar is in indeterminate mode, and false otherwise.

Description

Indicates whether the progress bar is in indeterminate mode or not. If the progress bar is in indeterminate mode, the function returns true. If the progress bar is not in indeterminate mode, the function returns false.

ProgressBar.getMaximum

function ProgressBar.getMaximum() : Integer

Returns

Returns the maximum value the progress bar can have.

Description

Returns the maximum value the progress bar can have.

ProgressBar.getValue

function ProgressBar.getValue() : Integer

Returns

Returns the current value of the progress bar.

Description

Returns the current value of the progress bar.

ProgressBar.setIndeterminate

function ProgressBar.setIndeterminate(flag : Boolean)

Arguments

flag
A flag indicating whether the progress bar should be in indeterminate mode or not.

Description

Turns on the indeterminate mode if the flag is set to true. Turns off the indeterminate mode if the flag is set to false.

ProgressBar.setMaximum

function ProgressBar.setMaximum(number : Integer)

Arguments

number
The maximum value the progress bar can have.

Description

Sets the maximum value the progress bar can have.

ProgressBar.setValue

function ProgressBar.setValue(number : Integer)

Arguments

number
The current value of the progress bar.

Description

Sets the current value of the progress bar.