123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- deferred class IUP_WIDGET_INTERNALS
- -- Internals commands.
- inherit
- IUP_WIDGET
- undefine
- execute_map,
- execute_unmap,
- execute_destroy,
- execute_getfocus,
- execute_killfocus,
- execute_enterwindow,
- execute_leavewindow,
- execute_k_any,
- execute_help,
- execute_action,
- execute_close,
- execute_copydata,
- execute_dropfiles,
- execute_mdiactivate,
- execute_move,
- execute_resize,
- execute_show,
- execute_trayclick,
- execute_file,
- execute_colorupdate,
- execute_cancel,
- execute_button,
- execute_valuechanged,
- execute_action_fnff,
- execute_focus,
- execute_motion,
- execute_keypress,
- execute_scroll,
- execute_wheel,
- execute_detached,
- execute_restored,
- execute_openclose,
- execute_extrabutton,
- execute_click,
- execute_action_fnsii,
- execute_caret,
- execute_dblclick,
- execute_dragdrop,
- execute_dropdown,
- execute_edit,
- execute_multiselect,
- execute_spin,
- execute_tabchange,
- execute_tabchangepos,
- execute_tabclose,
- execute_rightclick,
- execute_action_fnis,
- execute_maskfail,
- execute_action_fni,
- execute_selection,
- execute_multiselection,
- execute_multiunselection,
- execute_branchopen,
- execute_branchclose,
- execute_executeleaf,
- execute_showrename,
- execute_rename,
- execute_noderemoved,
- execute_togglevalue,
- execute_highlight,
- execute_open,
- execute_menuclose,
- execute_dragbegin,
- execute_dragdatasize,
- execute_dragdata,
- execute_dragend,
- execute_dropdata,
- execute_dropmotion,
- execute_recent,
- execute_param,
- execute_flat_action,
- execute_flat_button,
- execute_flat_focus,
- execute_flat_enterwindow,
- execute_flat_leavewindow,
- execute_draw,
- execute_height,
- execute_hspan,
- execute_mouseclick,
- execute_mousemotion,
- execute_ncols,
- execute_nlines,
- execute_scrolling,
- execute_vspan,
- execute_width,
- execute_cell,
- execute_extended,
- execute_select,
- execute_switch,
- execute_action_fniiiis,
- execute_click_fniis,
- execute_colresize,
- execute_release,
- execute_resizematrix,
- execute_mousemove,
- execute_enteritem,
- execute_leaveitem,
- execute_scrolltop,
- execute_bgcolor,
- execute_fgcolor,
- execute_font,
- execute_type,
- execute_dropcheck,
- execute_translatevalue,
- execute_togglevalue_fniii,
- execute_drop,
- execute_menudrop,
- execute_dropselect,
- execute_edition,
- execute_value,
- execute_value_edit,
- execute_mark,
- execute_markedit,
- execute_flat_motion,
- execute_dropshow,
- execute_button_press,
- execute_button_release,
- execute_mousemove_fnd,
- execute_change,
- execute_drag
- end
- feature {ANY}
- is_yes_no (value: STRING): BOOLEAN
- do
- if value.is_equal("YES") or value.is_equal("NO") then
- Result := True
- else
- Result := False
- end
- end
- is_yes_no_ignore (value: STRING): BOOLEAN
- do
- if is_yes_no(value) or value.is_equal("IGNORE") then
- Result := True
- else
- Result := False
- end
- end
- is_valid_expand (value: STRING): BOOLEAN
- do
- if is_yes_no(value) or value.is_equal("HORIZONTAL") or
- value.is_equal("HORIZONTALFREE") or
- value.is_equal("VERTICAL") or
- value.is_equal("VERTICALFREE") then
- Result := True
- else
- Result := False
- end
- end
- is_valid_rgb_string (color: STRING): BOOLEAN
- local
- r, g, b: INTEGER
- v: LIST[STRING]
- do
- v := color.split(' ')
- if v.count.is_equal(3) then
-
- if v.at(1).is_integer and
- v.at(2).is_integer and
- v.at(3).is_integer then
-
- r := v.at(1).to_integer
- g := v.at(2).to_integer
- b := v.at(3).to_integer
-
- if r >= 0 and r <= 255 and
- g >= 0 and g <= 255 and
- b >= 0 and b <= 255 then
- Result := True
- end
- end
- end
- end
- is_valid_hexadecimal (value: STRING): BOOLEAN
- require
- sharp: value.starts_with("#")
- number_of_colors: value.count.is_equal(7)
- local
- x, y: INTEGER
- do
- value.remove_head(1)
- from
- x := 1
- y := 0
- until
- x <= value.count
- loop
- if value.character_32_item(x).is_hexa_digit then
- y := y + 1
- end
- x := x + 1
- end
- if y.is_equal(value.count) then
- Result := True
- else
- Result := False
- end
- end
- is_valid_string_date (value: STRING): BOOLEAN
- local
- str: STRING
- y, m, d: INTEGER
- v: LIST[STRING]
- do
- create str.make_from_string(value)
-
- if str.occurrences('/').is_equal(2) then
- v := str.split('/')
- if v.count.is_equal(3) then
- if v.at(1).is_integer and
- v.at(2).is_integer and
- v.at(3).is_integer then
- y := v.at(1).to_integer
- m := v.at(2).to_integer
- d := v.at(3).to_integer
- if y >= 0 and
- m >= 1 and m <= 12 and
- d >= 1 and d <= 31 then
-
- Result := True
- else
- Result := False
- end
- else
- Result := False
- end
- else
- Result := False
- end
- else
- Result := False
- end
- end
- feature {NONE}
-
- yesno_to_boolean (value: STRING): BOOLEAN
- do
- if value.is_equal("YES") then
- Result := True
- else
- Result := False
- end
- end
- boolean_to_yesno (value: BOOLEAN): STRING
- do
- if value then
- Result := "YES"
- else
- Result := "NO"
- end
- end
-
- rgb_to_string (red, green, blue: INTEGER): STRING
- require
- red >= 0
- red <= 255
- green >= 0
- green <= 255
- blue >= 0
- blue <= 255
- local
- color: STRING
- do
- color := red.out
- color.append_string(" ")
- color.append_string(green.out)
- color.append_string(" ")
- color.append_string(blue.out)
- Result := color
- end
- rgba_to_string (red, green, blue, alpha: INTEGER): STRING
- require
- alpha >= 0
- alpha <= 255
- local
- color: STRING
- do
- color := rgb_to_string(red, green, blue)
- color.append_string(" ")
- color.append_string(alpha.out)
- Result := color
- end
- hsi_to_string (h, s, i: INTEGER): STRING
- require
- h >= 0
- h <= 359
- s >= 0
- s <= 100
- i >= 0
- i <= 100
- local
- color: STRING
- do
- color := h.out
- color.append_string(" ")
- color.append_string(s.out)
- color.append_string(" ")
- color.append_string(i.out)
- Result := color
- end
- hsi_real_to_string (h, s, i: REAL_64): STRING
- require
- h >= 0
- h <= 360
- s >= 0
- s <= 1
- i >= 0
- i <= 1
- local
- color: STRING
- do
- color := h.out
- color.append_string(" ")
- color.append_string(s.out)
- color.append_string(" ")
- color.append_string(i.out)
- Result := color
- end
- rgb_to_hexadecimal (red, green, blue: INTEGER): STRING
- require
- red >= 0
- red <= 255
- green >= 0
- green <= 255
- blue >= 0
- blue <= 255
- local
- c: INTEGER
- color, rs, gs, bs: STRING
- do
- color := "#"
-
- rs := red.to_hex_string
- gs := green.to_hex_string
- bs := blue.to_hex_string
- c := rs.count
- if c > 2 then
- rs.remove_head(c - 2)
- end
- c := gs.count
- if c > 2 then
- gs.remove_head(c - 2)
- end
- c := bs.count
- if c > 2 then
- bs.remove_head(c - 2)
- end
- color.append_string(rs)
- color.append_string(gs)
- color.append_string(bs)
- Result := color
- end
- hexadecimal_to_rgb (color: STRING): TUPLE[INTEGER, INTEGER, INTEGER]
- require
- valid_color: is_valid_hexadecimal(color)
- local
- r, g, b, base: INTEGER
- tup: TUPLE[INTEGER, INTEGER, INTEGER]
- do
- base := 16
-
- r := color.character_32_item(1).out.to_integer_32 * base +
- color.character_32_item(2).out.to_integer
- g := color.character_32_item(3).out.to_integer_32 * base +
- color.character_32_item(4).out.to_integer
- b := color.character_32_item(5).out.to_integer_32 * base +
- color.character_32_item(6).out.to_integer
- tup := [r, g, b]
- Result := tup
- end
- string_to_rgb (color: STRING): TUPLE[INTEGER, INTEGER, INTEGER]
- local
- tup: TUPLE[INTEGER, INTEGER, INTEGER]
- v: LIST[STRING]
- do
- v := color.split(' ')
- if v.count.is_equal(3) and
- v.at(1).out.is_integer and
- v.at(2).out.is_integer and
- v.at(3).out.is_integer then
-
- tup := [v.at(1).out.to_integer, v.at(2).out.to_integer,
- v.at(3).out.to_integer]
- Result := tup
- else
- io.put_string("Something goes wrong %N")
- Result := [0, 0, 0]
- end
- end
- components_of (size: STRING; separator: CHARACTER): TUPLE[INTEGER, INTEGER]
- local
- i, c: INTEGER
- str, width, height: STRING
- tup: TUPLE[INTEGER, INTEGER]
- do
- create str.make_from_string(size)
-
- if str.has(separator) then
- i := str.index_of(separator, 1)
- c := str.count
- --io.put_string(size)
- --io.put_integer(i)
- --io.put_integer(c)
-
- if not i.is_equal(1) then
- width := str.substring(1, i - 1)
- else
- width := "0"
- end
-
- if not i.is_equal(c) then
- height := str.substring(i + 1, c)
- else
- height := "0"
- end
- --io.put_string(width)
- --io.put_string(height)
- tup := [width.to_integer, height.to_integer]
- Result := tup
- else
- io.put_string("Unable to get the components %N")
- Result := [0, 0]
- end
- end
- components_of_size (size: STRING): TUPLE[INTEGER, INTEGER]
- do
- Result := components_of (size, 'x')
- end
- components_of_position (size: STRING): TUPLE[INTEGER, INTEGER]
- do
- Result := components_of (size, ',')
- end
- components_of_minmax (size: STRING): TUPLE[INTEGER, INTEGER]
- do
- Result := components_of (size, ':')
- end
- components_of_limits (limits: STRING): TUPLE[INTEGER, INTEGER, INTEGER, INTEGER]
- local
- i, c: INTEGER
- xmin, xmax, ymin, ymax: STRING
- tup: TUPLE[INTEGER, INTEGER, INTEGER, INTEGER]
- do
- i := limits.index_of(':', 1)
- c := limits.count
- if not i.is_equal(1) then
- xmin := limits.substring(1, i - 1)
- limits.remove_substring(1, i)
- else
- xmin := "0"
- limits.remove_head(1)
- end
- i := limits.index_of(':', 1)
- if not i.is_equal(1) then
- xmax := limits.substring(1, i - 1)
- limits.remove_substring(1, i)
- else
- xmax := "0"
- limits.remove_head(1)
- end
- i := limits.index_of(':', 1)
- if not i.is_equal(1) then
- ymin := limits.substring(1, i - 1)
- limits.remove_substring(1, i)
- else
- ymin := "0"
- limits.remove_head(1)
- end
-
- ymax := limits
- tup := [xmin.to_integer, xmax.to_integer,
- ymin.to_integer, ymax.to_integer]
- Result := tup
- end
- convert_date_to_tuple (value: STRING): TUPLE[INTEGER, INTEGER, INTEGER]
- local
- str: STRING
- v: LIST[STRING]
- do
- create str.make_from_string(value)
- v := str.split('/')
- if v.count.is_equal(3) and
- v.at(1).out.is_integer and
- v.at(2).out.is_integer and
- v.at(3).out.is_integer then
-
- Result := [v.at(1).out.to_integer,
- v.at(2).out.to_integer,
- v.at(3).out.to_integer]
-
- else
- io.put_string("Something goes wrong %N")
- Result := [0, 0, 0]
- end
- end
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2016, 2017, 2019 by German A. Arias
- -- 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.
|