123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- class EXAMPLE5
- -- This example show how use tabs and many other controls.
- insert
- IUP_INTERFACE
- create {ANY}
- make
- feature {ANY}
- ml: IUP_MULTILINE
- l4: IUP_LABEL
- pb: IUP_PROGRESS_BAR
- lm: LOOP_STACK
- counter: INTEGER
- time: MICROSECOND_TIME
- make
- local
- gui: IUP
- i: STRING
- w: IUP_DIALOG
- t: IUP_TABS
- v1, v2, v3: IUP_VBOX
- h1: IUP_HBOX
- b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12: IUP_BUTTON
- im: IUP_IMAGE
- l1, l2, l3: IUP_LABEL
- s1: IUP_VAL
- lt: IUP_LIST
- fl: IUP_FILL
- al: IUP_ANIMATED_LABEL
- d: IUP_DATE_PICK
- c: IUP_CALENDAR
- tx1: IUP_TEXT
- sb1: IUP_SPIN_BOX
- scll: IUP_SCROLL_BOX
- frm: IUP_FRAME
- ml1: IUP_MULTILINE
- sb: IUP_SPLIT
- do
- gui := iup_open
- gui.load_images
- gui.load_iup_controls
- -- Controls at first tab
- ---------------------------------
-
- create im.image({FAST_ARRAY2[INTEGER] 10, 10, << 15, 15, 15, 15, 15, 15, 15, 15, 15, 15;
- 15, 15, 15, 1, 1, 1, 1, 15, 15, 15;
- 15, 15, 15, 1, 15, 15, 15, 15, 15, 15;
- 15, 15, 15, 1, 15, 15, 15, 15, 15, 15;
- 15, 15, 15, 1, 15, 15, 15, 15, 15, 15;
- 15, 15, 15, 1, 1, 1, 15, 15, 15, 15;
- 15, 15, 15, 1, 15, 15, 15, 15, 15, 15;
- 15, 15, 15, 1, 15, 15, 15, 15, 15, 15;
- 15, 15, 15, 1, 15, 15, 15, 15, 15, 15;
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 >>})
- im.set_widget_name("my_image")
- create b1.button("Launch an alarn")
- b1.set_cb_action(agent alarm(?))
- create b2.button("Select a file")
- b2.set_cb_action(agent file(?))
- create b3.button("Select a color")
- b3.set_cb_action(agent color(?))
- create b4.button("Write a message")
- b4.set_cb_action(agent get_message(?))
- create b5.button("Select an option")
- b5.set_cb_action(agent list(?))
- create b6.button("Preferences")
- b6.set_cb_action(agent param(?))
- create b7.button("Font")
- b7.set_image("my_image")
- b7.set_cb_action(agent font(?))
- create b8.button("A message")
- b8.set_cb_action(agent message(?))
- create b9.button("Color dialog")
- b9.set_cb_action(agent color_dialog(?))
- create b10.button("A message dialog")
- b10.set_cb_action(agent message_dlg(?))
- create fl.fill
- create al.animated_label_empty
- al.set_animation("IUP_CircleProgressAnimation")
- create ml.multiline
- ml.set_expand("YES")
- create v1.vbox({ARRAY[IUP_WIDGET] 1, << b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, fl, al >>})
- v1.set_alignment("ACENTER")
- v1.set_gap(10)
- v1.set_margin(10, 10)
- v1.set_normalize_size("HORIZONTAL")
- create h1.hbox({ARRAY[IUP_WIDGET] 1, << v1, ml >>})
- -- Controls at second tab
- -----------------------------------------
-
- create l1.label("Age")
- create l2.label("City")
- create l3.label("Date")
- create d.date_pick
- create s1.horizontal_val
- create lt.list
- lt.set_drop_down(True)
- lt.set_size(80, 12)
- create c.calendar
- create v2.vbox({ARRAY[IUP_WIDGET] 1, << d, l1, s1, l2, lt, l3,
- c >>})
- v2.set_gap(10)
- v2.set_margin(10, 10)
- -- Controls at third tab
- -----------------------------------------
-
- create tx1.text
- tx1.set_value("0")
- tx1.set_spin(True)
- create l4.label("0")
- l4.set_size(40, 12)
- l4.set_alignment("ACENTER", "ACENTER")
- create sb1.spin_box(l4)
- sb1.set_cb_spin(agent spin_click(?, ?))
- create frm.frame(sb1)
- frm.set_title("Spin-label")
- create ml1.multiline
- ml1.set_expand("YES")
- ml1.set_size(550, 350)
- create pb.progress_bar
- create b11.button("Starts")
- b11.set_cb_action(agent progress_bar(?))
- create b12.button("Progress dialog")
- b12.set_cb_action(agent progress_dialog(?))
- create scll.scroll_box(ml1)
- create v3.vbox({ARRAY[IUP_WIDGET] 1, << tx1, sb1, pb, b11, b12 >>})
- v3.set_gap(10)
- v3.set_margin(10, 10)
- create sb.split(v3, scll)
- --sb.set_show_grip("LINES")
- sb.set_min_and_max(250, 750)
- sb.set_value(500)
- -- Create the tabs
- -------------------------------
- create t.tabs({ARRAY[IUP_WIDGET] 1, << h1, v2, sb >>})
- t.set_tab_n_title("Buttons", 0)
- t.set_tab_n_title("List, Slider and Date", 1)
- t.set_tab_n_title("Split", 2)
- -- Create the window.
- -------------------------
-
- create w.dialog(t)
- w.set_title("Controls test")
- w.set_predefined_size("HALF", "250")
- w.set_widget_name("window")
- i := w.show
- -- Start the animation.
- al.start
- -- Add items at list.
- lt.append_item("London")
- lt.append_item("Madrid")
- lt.append_item("New York")
- lt.append_item("Paris")
- lt.append_item("Milan")
- lt.append_item("Tokyo")
- lt.append_item("Buenos Aires")
- lt.set_value_string("Milan")
-
- gui.main_loop
- gui.close
- end
- alarm (widget: IUP_WIDGET): STRING
- local
- r: INTEGER
- al: IUP_ALARM
- do
- create al.alarm_three_buttons("Alarm", "Select a button", "1",
- "2", "3")
- r := al.launch
- if r.is_equal(1) then
- ml.append("You selected the first button; %N")
- elseif r.is_equal(2) then
- ml.append("You selected the second button; %N")
- elseif r.is_equal(3) then
- ml.append("You selected the third button; %N")
- end
-
- Result := "IUP_DEFAULT"
- end
- file (widget: IUP_WIDGET): STRING
- local
- tup: TUPLE[INTEGER, STRING]
- fl: IUP_GET_FILE
- do
- create fl.get_file("~/", "*.txt")
- tup := fl.launch
- if tup.item_1.is_equal(0) then
- ml.append(tup.item_2)
- ml.append("%N")
- end
- Result := "IUP_DEFAULT"
- end
- color (widget: IUP_BUTTON): STRING
- local
- tup: TUPLE[INTEGER, INTEGER, INTEGER, INTEGER]
- gc: IUP_GET_COLOR
- do
- create gc.get_color_with_initial(0, 0, 0)
- tup := gc.launch_predefined_xy("IUP_CENTER", "IUP_CENTER")
- if tup.item_1.is_equal(1) then
- ml.set_rgb_foreground_color(tup.item_2, tup.item_3, tup.item_4)
- end
- Result := "IUP_DEFAULT"
- end
- get_message (widget: IUP_BUTTON): STRING
- local
- tup: TUPLE[INTEGER, STRING]
- gt: IUP_GET_TEXT
- do
- create gt.get_text_with_initial("Write a message", "...", 40)
- tup := gt.launch
- if not tup.item_1.is_equal(0) then
- ml.append(tup.item_2)
- ml.append("%N")
- end
- Result := "IUP_DEFAULT"
- end
- list (widget: IUP_BUTTON): STRING
- local
- ld: IUP_LIST_DIALOG
- a: ARRAY[STRING]
- tup: TUPLE[INTEGER, STRING]
- do
- a := {ARRAY[STRING] 1, << "Uno", "Dos", "Tres", "Cuatro", "Cinco",
- "Seis", "Siete", "Ocho", "Nueve", "Diez" >>}
-
- --create ld.list_dialog_simple("Select", a, 1, 1, 1)
- create ld.list_dialog_multiple("Select", a, 1, 5)
- tup := ld.launch
- ml.append(tup.item_2)
- ml.append("%N")
- Result := "IUP_DEFAULT"
- end
- param (widget: IUP_BUTTON): STRING
- local
- i: INTEGER
- gp: IUP_GET_PARAM
- p: POINTER
- d1, d2, d3, d4, d5: INTEGER
- dr1, dr2, dr3: REAL_32
- do
- d1 := 1.to_integer_32
- d2 := 3456.to_integer_32
- d3 := 192
- d4 := 1
- d5 := 2
- dr1 := 3.543.force_to_real_32
- dr2 := 0.5.force_to_real_32
- dr3 := 90.to_real_32
-
- create gp.get_param ("Preferences", agent preferences(?, ?, ?), p)
- gp.add_buttons_parameter (", MyCancel, Help!")
- gp.add_boolean_parameter ("Boolean:", "No,Yes", "", $d1)
- gp.add_integer_parameter ("Integer:", "", "", $d2)
- gp.add_real_parameter ("Real 1:", "", "", $dr1)
- gp.add_separator ("Sep1")
- gp.add_integer_parameter ("Integer:", "0,255", "", $d3)
- gp.add_real_parameter ("Real 2:", "-1.5,1.5,0.05", "", $dr2)
- gp.add_separator ("Sep2")
- gp.add_angle_real_parameter ("Angle:", "0,360", "", $dr3)
- gp.add_string_parameter ("String:", "", "", "string text".to_external)
- gp.add_radio_parameter ("Options:", "item0|item1|item2", "", $d4)
- gp.add_list_parameter ("List:", "item0|item1|item2|item3|item4|item5|item6", "", $d5)
- gp.add_file_parameter ("File:", "OPEN|*.bmp;*.jpg|CURRENT|NO|NO", "", "test.jpg".to_external)
- gp.add_color_parameter ("Color", "", "255 0 128".to_external)
- gp.add_font_parameter ("Font", "", "Courier, 24".to_external)
- gp.add_separator ("Sep3")
- gp.add_multiline_parameter ("Multiline:", "", "", "second text%Nsecond line".to_external)
- i := gp.launch
-
- Result := "IUP_DEFAULT"
- end
-
- preferences (dialog: IUP_GET_PARAM; index: INTEGER; data: POINTER): INTEGER
- local
- dat: STRING
- do
- --io.put_string("Hello %N")
- dat := dialog.get_parameter_value_at(index)
- io.put_string(dat)
- io.put_string("%N")
- Result := 1
- end
- font (widget: IUP_BUTTON): STRING
- local
- fd: IUP_FONT_DIALOG
- str: STRING
- status: INTEGER
- do
- create fd.font_dialog
- str := fd.popup_predefined_xy("IUP_CENTER", "IUP_CENTER")
- status := fd.get_status
- if status.is_equal(1) then
- ml.set_font(fd.get_value)
- end
-
- Result := "IUP_DEFAULT"
- end
- message (widget: IUP_BUTTON): STRING
- local
- ms: IUP_MESSAGE
- do
- create ms.message("A message", "Your message")
- Result := "IUP_DEFAULT"
- end
- color_dialog (widget: IUP_BUTTON): STRING
- local
- cd: IUP_COLOR_DIALOG
- rs: STRING
- status: INTEGER
- tup: TUPLE[INTEGER, INTEGER, INTEGER, INTEGER]
- do
- create cd.color_dialog
- rs := cd.popup_predefined_xy("IUP_CENTER", "IUP_CENTER")
- status := cd.get_status
- if status.is_equal(1) then
- tup := cd.get_value
- ml.set_rgb_foreground_color(tup.item_1, tup.item_2, tup.item_3)
- end
- cd.destroy
-
- Result := "IUP_DEFAULT"
- end
- message_dlg (widget: IUP_BUTTON): STRING
- local
- mdlg: IUP_MESSAGE_DIALOG
- i: STRING
- r: INTEGER
- do
- create mdlg.message_dialog
- mdlg.set_title("A message dialog")
- mdlg.set_value("Are you sure?")
- mdlg.set_buttons("YESNOCANCEL")
- mdlg.set_dialog_type("QUESTION")
- mdlg.set_parent_dialog("window")
- i := mdlg.popup_predefined_xy("IUP_CENTER", "IUP_CENTER")
- r := mdlg.get_button_response
- ml.append(r.to_string)
- ml.append("%N")
-
- Result := "IUP_DEFAULT"
- end
- progress_bar (widget: IUP_BUTTON): STRING
- local
- cl: INTEGER
- pr: REAL_64
- ls: STRING
- do
- from
- cl := 0
- until
- cl > 1000
- loop
- pr := cl.to_real_64 / 1000.to_real_64
- pb.set_value(pr)
- ls := iup_open.loop_step
- cl := cl + 1
- end
- Result := "IUP_DEFAULT"
- end
- progress_dialog (widget: IUP_BUTTON): STRING
- local
- pdlg: IUP_PROGRESS_DIALOG
- cl: INTEGER
- ls, i: STRING
- do
- create pdlg.progress_dialog
- pdlg.set_total_count(500)
- i := pdlg.show
- from
- cl := 0
- until
- cl > 1000
- loop
- pdlg.increment_one
- ls := iup_open.loop_step
- cl := cl + 1
- end
- pdlg.hide
- pdlg.destroy
-
- Result := "IUP_DEFAULT"
- end
- spin_click (wgt: IUP_SPIN_BOX; inc: INTEGER): STRING
- local
- lint: INTEGER
- do
- if l4.get_title.is_integer then
- lint := l4.get_title.to_integer + inc
- l4.set_title(lint.to_string)
- end
-
- Result := "IUP_DEFAULT"
- end
- end -- class EXAMPLE5
|