12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- class EXAMPLE6
- -- This example show how use a progress bar with a sequencer.
- insert
- IUP_INTERFACE
- create {ANY}
- make
- feature {ANY}
- pb: IUP_PROGRESS_BAR
- counter: INTEGER
- lm: LOOP_STACK
- time: MICROSECOND_TIME
- make
- local
- bt: IUP_BUTTON
- a: ARRAY[IUP_WIDGET]
- vb: IUP_VBOX
- i: STRING
- w: IUP_DIALOG
- gui: IUP
- do
- gui := iup_open
-
- create pb.progress_bar
-
- create bt.button("Starts")
- bt.set_cb_action(agent bar(?))
-
- a := {ARRAY[IUP_WIDGET] 1, << pb, bt >>}
- create vb.vbox(a)
- vb.set_alignment("ACENTER")
- vb.set_gap(10)
- vb.set_margin(10, 10)
-
- create w.dialog(vb)
- w.set_title("Progress bar")
- i := w.show
- gui.main_loop
- gui.close
- end
- bar (widget: IUP_BUTTON): STRING
- local
- ls: STRING
- do
- -- These three lines are used to return the progress bar to
- -- 0, if the user press the button again. But of course,
- -- these are not always necessary.
- counter := 0
- pb.set_value(0.to_real_64)
- ls := iup_open.loop_step
- time.update
- create lm.make
- lm.add_job(create {SIMPLE_PERIODIC_JOB}.set_work(agent progress_bar,
- Void, 0, 1))
- lm.run
- Result := "IUP_DEFAULT"
- end
- progress_bar: BOOLEAN
- local
- r: REAL_64
- ls: STRING
- do
- ls := iup_open.loop_step -- Update the interface.
- r := counter.to_real_64 / 10.to_real_64
-
- io.put_real(r)
- io.put_string("%N")
-
- pb.set_value(r)
- ls := iup_open.loop_step -- Update the interface again.
- counter := counter + 1 -- Update the counter.
- if counter > 10 then
- Result := False
- else
- Result := True
- end
- end
- end
|