changeset 7935:85d6296d51e1

Add gcbo/gcbf functions.
author John W. Eaton <jwe@octave.org>
date Wed, 16 Jul 2008 14:28:48 -0400
parents 5a156ab94dd2
children 78400fde223e
files scripts/ChangeLog scripts/plot/Makefile.in scripts/plot/gcbf.m scripts/plot/gcbo.m
diffstat 4 files changed, 83 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed Jul 16 14:26:18 2008 -0400
+++ b/scripts/ChangeLog	Wed Jul 16 14:28:48 2008 -0400
@@ -1,3 +1,8 @@
+2008-07-16  Michael Goffioul  <michael.goffioul@gmail.com>
+
+	* plot/gcbo.m, plot/gcbf.m: New functions.
+	* plot/Makefile.in (SOURCES): Add them to the list.
+
 2008-07-16  John W. Eaton  <jwe@octave.org>
 
 	* deprecated/loadimage.m: New file.
--- a/scripts/plot/Makefile.in	Wed Jul 16 14:26:18 2008 -0400
+++ b/scripts/plot/Makefile.in	Wed Jul 16 14:28:48 2008 -0400
@@ -107,6 +107,8 @@
   findobj.m \
   fplot.m \
   gca.m \
+  gcbf.m \
+  gcbo.m \
   gcf.m \
   ginput.m \
   grid.m \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/gcbf.m	Wed Jul 16 14:28:48 2008 -0400
@@ -0,0 +1,33 @@
+## Copyright (C) 2008 Michael Goffioul
+##
+## This file is part of Octave.
+##
+## Octave 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 3 of the License, or (at
+## your option) any later version.
+##
+## Octave 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 Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {@var{fig} =} gcbf ()
+## Return a handle to the figure containing the object whose callback
+## is currently executing. If no callback is executing, this function
+## returns the empty matrix. The handle returned by this function is
+## the same as the second output argument of gcbo.
+##
+##@seealso{gcf, gca, gcbo}
+##@end deftypefn
+
+function fig = gcbf ()
+
+  [dummy, fig] = gcbo ();
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/gcbo.m	Wed Jul 16 14:28:48 2008 -0400
@@ -0,0 +1,43 @@
+## Copyright (C) 2008 Michael Goffioul
+##
+## This file is part of Octave.
+##
+## Octave 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 3 of the License, or (at
+## your option) any later version.
+##
+## Octave 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 Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {@var{h} =} gcbo ()
+## @deftypefnx {Function File} {[@var{h}, @var{fig}] =} gcbo ()
+## Return a handle to the object whose callback is currently
+## executing. If no callback is executing, this function returns the
+## empty matrix. This handle is obtained from the root object property
+## "CallbackObject".
+##
+## Additionally return the handle of the figure containing the
+## object whose callback is currently executing. If no callback is
+## executing, the second output is also set to the empty matrix.
+##
+##@seealso{gcf, gca, gcbf}
+##@end deftypefn
+
+function [h, fig] = gcbo ()
+
+  h = get (0, "callbackobject");
+  fig = [];
+
+  if (! isempty (h) && nargout > 1)
+    fig = ancestor (h, "figure");
+  endif
+
+endfunction