1/* Part of XPCE --- The SWI-Prolog GUI toolkit 2 3 Author: Jan Wielemaker and Anjo Anjewierden 4 E-mail: J.Wielemaker@cs.vu.nl 5 WWW: http://www.swi-prolog.org/packages/xpce/ 6 Copyright (c) 1985-2011, University of Amsterdam 7 VU University Amsterdam 8 All rights reserved. 9 10 Redistribution and use in source and binary forms, with or without 11 modification, are permitted provided that the following conditions 12 are met: 13 14 1. Redistributions of source code must retain the above copyright 15 notice, this list of conditions and the following disclaimer. 16 17 2. Redistributions in binary form must reproduce the above copyright 18 notice, this list of conditions and the following disclaimer in 19 the documentation and/or other materials provided with the 20 distribution. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 POSSIBILITY OF SUCH DAMAGE. 34*/ 35 36:- module(pce_manual, 37 [ manpce/0, 38 manpce/1 39 ]). 40:- use_module(library(pce)). 41:- consult([ man/util % Common utilities 42 , man/p_card % General card infra-structure 43 , man/p_data % Manual specific infra-structure 44 , man/v_manual % Top level window 45 ]). 46:- require([ pce_warn/1 47 , pce_to_method/2 48 ]). 49 50/** <module> Start XPCE manual 51*/ 52 53:- pce_autoload(man_class_browser, library('man/v_class')). 54:- pce_autoload(man_editor, library('man/v_editor')). 55:- pce_autoload(man_card_editor, library('man/v_card')). 56:- pce_autoload(man_summary_browser, library('man/v_summary')). 57:- pce_autoload(man_class_hierarchy, library('man/v_hierarchy')). 58:- pce_autoload(man_search_tool, library('man/v_search')). 59:- pce_autoload(man_index_manager, library('man/man_index')). 60:- pce_autoload(man_topic_browser, library('man/v_topic')). 61:- pce_autoload(man_module_browser, library('man/v_module')). 62:- pce_autoload(man_statistics, library('man/v_statistics')). 63:- pce_autoload(isp_frame, library('man/v_inspector')). 64:- pce_autoload(vis_frame, library('man/v_visual')). 65:- pce_autoload(man_instance_browser, library('man/v_instance')). 66:- pce_autoload(man_global, library('man/v_global')). 67:- pce_autoload(man_object_browser, library('man/v_global')). 68:- pce_autoload(man_error_browser, library('man/v_error')). 69:- pce_autoload(man_group_browser, library('man/v_group')). 70 @manual, new(man_manual)). ( 72 73%! manpce is det. 74% 75% Starts the XPCE manual tools by opening a small window. 76 77manpce :- 78 in_pce_thread(send(@manual, expose)). 79 80 81%! manpce(+Spec) is det. 82% 83% Start the XPCE manual tools, opening the manual page for Spec. 84% Spec is translated into an XPCE object using pce_to_method/2. 85% Examples: 86% 87% == 88% ?- manpce(window). 89% ?- manpce(point->x). 90% == 91 92manpce(Spec) :- 93 in_pce_thread(manpce_(Spec)). 94 95manpce_(Spec) :- 96 ( method(Spec, Object) 97 -> send(@manual, manual, Object) 98 ; pce_warn(pce(no_help(Spec))), 99 fail 100 ). 101 102method(Spec, Method) :- 103 object(Spec), 104 send(Spec, '_instance_of', var), 105 !, 106 Spec = @Ref, 107 new(Method, man_global(Ref)). 108method(Spec, Method) :- 109 pce_to_method(Spec, Method), 110 !. 111method(Atom, Method) :- 112 atom(Atom), 113 catch(term_to_atom(Spec, Atom), _, fail), 114 pce_to_method(Spec, Method)