Mercurial > octave-nkf
view scripts/java/listdlg.m @ 15625:acf0addfc610
include Octave Forge java package in core Octave
* scripts/java: New directory tree.
* scripts/Makefile.am: Include java/module.mk.
(JAR_FILES): New variable.
(nobase_fcnfile_DATA): Include $(JAR_FILES) in the list.
(all-local): Depend on $(JAR_FILES).
(java/PKG_ADD, java_GEN_FCN_FILES, java/$(octave_dirstamp)):
New rules.
* libinterp/link-deps (LIBOCTINTERP_LINK_DEP): Include $(JAVA_LIBS) in
the list.
* dldfcn/__java__.h, dldfcn/__java__.cc: New files.
* dldfcn/module-files (__java__.cc): New file description.
* doc/interpreter/java.txi: New file.
* doc/interpreter/octave.texi: Include java.texi.
* doc/interpreter/java-images: New directory.
* doc/interpreter/Makefile.am (JAVA_IMAGES): New variable.
(IMAGES): Include $(JAVA_IMAGSES) in the list.
(MUNGED_TEXI_SRC): Include java.texi in the list.
* configure.ac: Check for Java libraries and tools.
Include Java info in the summary message.
* build-aux/common.mk (JAVA_CPPFLAGS, JAVA_LIBS): New variables.
* NEWS: Update.
* contributors.in: Include Martin Hepperle in the list.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 23 Nov 2012 15:29:13 -0500 |
parents | |
children | 9fee0b741de6 |
line wrap: on
line source
## Copyright (C) 2010 Martin Hepperle ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function file} {@var{[SEL,OK]} =} listdlg (@var{KEY} ,@var{VALUE} [, @var{KEY} ,@var{VALUE}, ...]]) ## ## Returns the user's inputs from a list dialog box in form of a vector of ## selection indices SEL and a flag OK indicating how the user closed the dialog box. ## The returned flag OK is 1 if the user closed the box with the OK button, ## otherwise it is 0 and SEL is empty. ## The indices in SEL are 1 based, i.e. the first list item carries the index 1. ## ## The arguments are specified in form of @var{KEY}, @var{VALUE} pairs. ## At least the 'ListString' argument pair must be specified. ## ## @var{KEY}s and @var{VALUE}s pairs can be selected from the following list: ## ## @table @samp ## @item ListString ## a cell array of strings comprising the content of the list. ## @item SelectionMode ## can be either @samp{Single} or @samp{Multiple}. ## @item ListSize ## a vector with two elements [width, height] defining the size of the list field in pixels. ## @item InitialValue ## a vector containing 1-based indices of preselected elements. ## @item Name ## a string to be used as the dialog caption. ## @item PromptString ## a cell array of strings to be displayed above the list field. ## @item OKString ## a string used to label the OK button. ## @item CancelString ## a string used to label the Cancel button. ## @end table ## ## Example: ## ## @example ## [sel, ok] = listdlg ( 'ListString',@{'An item', 'another', 'yet another'@}, 'SelectionMode','Multiple' ); ## if ok == 1 ## imax = length(sel); ## for i=1:1:imax ## disp(sel(i)); ## end ## end ## @end example ## ## @end deftypefn ## @seealso{errordlg, helpdlg, inputdlg, questdlg, warndlg} function varargout = listdlg(varargin) if nargin < 2 print_usage (); return; end listcell = {''}; selmode = 'single'; listsize = [300,160]; % vector! initialvalue = [1]; % vector! name = ''; prompt = {''}; okstring = 'OK'; cancelstring = 'Cancel'; % handle key, value pairs for i=1:2:nargin-1 if strcmp(varargin{i},'ListString') listcell = varargin{i+1}; elseif strcmp(varargin{i},'SelectionMode') selmode = varargin{i+1}; elseif strcmp(varargin{i},'ListSize') listsize = varargin{i+1}; elseif strcmp(varargin{i},'InitialValue') initialvalue = varargin{i+1}; elseif strcmp(varargin{i},'Name') name = varargin{i+1}; elseif strcmp(varargin{i},'PromptString') prompt = varargin{i+1}; elseif strcmp(varargin{i},'OKString') okstring = varargin{i+1}; elseif strcmp(varargin{i},'CancelString') cancelstring = varargin{i+1}; end end % make sure prompt strings are a cell array if ! iscell(prompt) prompt = {prompt}; end % make sure listcell strings are a cell array if ! iscell(listcell) listcell = {listcell}; end % transform matrices to cell arrays of strings listsize = arrayfun(@num2str,listsize,'UniformOutput',false); initialvalue = arrayfun(@num2str,initialvalue,'UniformOutput',false); ret = java_invoke ('org.octave.JDialogBox', 'listdlg', listcell, ... selmode, listsize, initialvalue, name, prompt, ... okstring, cancelstring ); if length(ret) > 0 varargout = {ret, 1}; else varargout = {{}, 0}; end end