123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- class EXAMPLE9
- insert
- IUP_INTERFACE
- create {ANY}
- make
- feature {ANY}
- colors: ARRAY[TUPLE[INTEGER, INTEGER, INTEGER]]
- cb: IUP_COLOR_BAR
- selected_cell: INTEGER
-
- make
- local
- gui: IUP
- i: STRING
- lab: IUP_LABEL
- a: ARRAY[IUP_CANVAS]
- b: ARRAY[IUP_WIDGET]
- a_cells: IUP_CELLS
- h: IUP_HBOX
- v: IUP_VBOX
- w: IUP_DIALOG
- do
- gui := iup_open
- gui.load_iup_controls
- create lab.label("Select a color and click a cell")
- create a_cells.cells
- a_cells.set_scrollbar(False)
- a_cells.set_cb_number_of_lines(agent lines(?))
- a_cells.set_cb_number_of_columns(agent columns(?))
- a_cells.set_cb_height(agent height(?,?))
- a_cells.set_cb_width(agent width(?,?))
- a_cells.set_cb_draw(agent draw(?,?,?,?,?,?,?,?))
- a_cells.set_cb_scroll(agent scroll(?,?,?,?))
- a_cells.set_cb_mouse_click(agent mouse_click(?,?,?,?,?,?,?,?))
- create cb.color_bar
-
- cb.set_raster_size(70, 0)
- cb.set_number_of_parts(2)
- cb.set_expand_vertical
- cb.set_cb_select(agent select_color(?,?,?))
-
- a := {ARRAY[IUP_CANVAS] 1, << a_cells, cb >>}
- create h.hbox(a)
- b := {ARRAY[IUP_WIDGET] 1, << lab, h >>}
- create v.vbox(b)
-
- create w.dialog(v)
- w.set_title("An example of IUP_CELLS")
- w.set_raster_size(400, 350)
- w.set_resize(False)
- i := w.show
- gui.main_loop
- gui.close
- end
- select_color (widget: IUP_COLOR_BAR; cell, type: INTEGER): STRING
- do
- Result := "IUP_DEFAULT"
- end
- lines (widget: IUP_CELLS): INTEGER
- do
- Result := 10
- end
- columns (widget: IUP_CELLS): INTEGER
- do
- Result := 10
- end
- height (widget: IUP_CELLS; l: INTEGER): INTEGER
- do
- Result := 30
- end
- width (widget: IUP_CELLS; c: INTEGER): INTEGER
- do
- Result := 30
- end
- draw (widget: IUP_CELLS; l, c, xmin, xmax, ymin, ymax: INTEGER; cd: CD_IUP): STRING
- local
- mx, my: INTEGER
- do
- cd.set_predefined_background_color(cd.cd_black)
- mx := xmin + 15
- my := ymin + 15
- cd.draws_mark(mx, my)
- Result := "IUP_DEFAULT"
- end
- scroll (widget: IUP_CANVAS; op: INTEGER; posx, posy: REAL_32): STRING
- do
- Result := "IUP_IGNORE"
- end
- mouse_click (widget: IUP_CELLS; b, p, l, c, x, y: INTEGER; s: STRING): STRING
- local
- i: INTEGER
- tup: TUPLE[INTEGER, INTEGER, INTEGER]
- do
- -- If user press the left mouse button, draw a mark with
- -- the selected color.
- if b.is_equal(1) and p.is_equal(1) then
- i := cb.get_primary_cell
- tup := cb.get_cell_n_color(i)
- widget.get_cd_canvas.set_foreground_color(tup.item_1, tup.item_2, tup.item_3)
- widget.get_cd_canvas.draws_mark(30*(c - 1) + 15, (10 - l)*30 + 21)
- widget.get_cd_canvas.flush
- end
-
- Result := "IUP_CONTINUE"
- end
- end -- class EXAMPLE9
|