123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- class IUP_GET_FILE
- -- Shows a modal dialog of the native interface system to select a filename.
- -- Uses the IUP_FILE_DIALOG element.
- --
- -- The function does not allocate memory space to store the complete filename
- -- entered by the user. Therefore, the filename parameter must be large enough
- -- to contain the directory and file names. The string is limited to 4096
- -- characters.
- --
- -- The function will reuse the directory from one call to another, so in the
- -- next call will open in the directory of the last selected file.
- --
- -- The dialog uses a global attribute called "PARENTDIALOG" as the parent
- -- dialog if it is defined. It also uses a global attribute called "ICON" as
- -- the dialog icon if it is defined.
- --
- -- For a more controlled dialog use directly the IUP_FILE_DIALOG element.
- inherit
- IUP_WIDGET
- create {ANY}
- get_file
-
- feature {ANY}
- get_file (dir, filter: STRING)
- -- dir parameter is used to define the default directory, for
- -- example "../docs/". And filter is used to define the default
- -- filter, for example "*.txt".
- do
- create filename.make(4096)
-
- if dir.head(1).is_equal("/") then
- filename.append_string(dir)
- filename.append_string(filter)
- else
- filename.append_string(dir)
- filename.append_string("/")
- filename.append_string(filter)
- end
- end
- launch: TUPLE[INTEGER, STRING]
- -- Returns: a status code, whose values can be:
- --
- -- "1": New file.
- -- "0": Normal, existing file.
- -- "-1": Operation cancelled.
- --
- -- And the selected file.
- local
- p: POINTER
- i: INTEGER
- fl: STRING
- tup: TUPLE[INTEGER, STRING]
- do
- p := get_pointer(filename.to_c)
- i := int_get_file(p)
- create fl.make_from_c(p)
- tup := [i, fl]
- Result := tup
- end
- feature {NONE}
- filename: STRING
- -- Internal
-
- int_get_file (fn: POINTER): INTEGER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupGetFile ($fn);"
- 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.
|