/usr/share/doc/swi-prolog-doc/UserGuide/libdia.html is in swi-prolog-doc 5.6.59-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Programming in XPCE/Prolog: Section 11.3</TITLE><LINK REL=home HREF="index.html">
<LINK REL=contents HREF="Contents.html">
<LINK REL=index HREF="DocIndex.html">
<LINK REL=summary HREF="summary.html">
<LINK REL=previous HREF="balloon.html">
<LINK REL=next HREF="toc.html">
<STYLE type="text/css">
/* Style sheet for SWI-Prolog latex2html
*/
dd.defbody
{ margin-bottom: 1em;
}
dt.pubdef
{ background-color: #c5e1ff;
}
pre.code
{ margin-left: 1.5em;
margin-right: 1.5em;
border: 1px dotted;
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
background-color: #f8f8f8;
}
div.navigate
{ text-align: center;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
}
div.title
{ text-align: center;
padding-bottom: 1em;
font-size: 200%;
font-weight: bold;
}
div.author
{ text-align: center;
font-style: italic;
}
div.abstract
{ margin-top: 2em;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
margin-left: 10%; margin-right:10%;
}
div.abstract-title
{ text-align: center;
padding: 5px;
font-size: 120%;
font-weight: bold;
}
div.toc-h1
{ font-size: 200%;
font-weight: bold;
}
div.toc-h2
{ font-size: 120%;
font-weight: bold;
margin-left: 2em;
}
div.toc-h3
{ font-size: 100%;
font-weight: bold;
margin-left: 4em;
}
div.toc-h4
{ font-size: 100%;
margin-left: 6em;
}
span.sec-nr
{
}
span.sec-title
{
}
span.pred-ext
{ font-weight: bold;
}
/* Footnotes */
sup.fn { color: blue; text-decoration: underline; }
span.fn-text: { display: none; }
sup.fn span {display: none;}
sup:hover span
{ display: block !important;
position: absolute; top: auto; left: auto; width: 80%;
color: #000; background: white;
border: 2px solid;
padding: 5px; margin: 10px; z-index: 100;
font-size: smaller;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="white">
<DIV class="navigate"><A class="nav" href="index.html"><IMG SRC="home.gif" BORDER=0 ALT="Home"></A>
<A class="nav" href="Contents.html"><IMG SRC="index.gif" BORDER=0 ALT="Contents"></A>
<A class="nav" href="DocIndex.html"><IMG SRC="yellow_pages.gif" BORDER=0 ALT="Index"></A>
<A class="nav" href="summary.html"><IMG SRC="info.gif" BORDER=0 ALT="Summary"></A>
<A class="nav" href="balloon.html"><IMG SRC="prev.gif" BORDER=0 ALT="Previous"></A>
<A class="nav" href="toc.html"><IMG SRC="next.gif" BORDER=0 ALT="Next"></A>
</DIV>
<H2><A NAME="sec:11.3"><SPAN class="sec-nr">11.3</SPAN> <SPAN class="sec-title">Dialog
support libraries</SPAN></A></H2>
<A NAME="sec:libdia"></A>
<P>This section deals with a number of classes from the library to
simplify the creation of dialog windows.
<H3><A NAME="sec:11.3.1"><SPAN class="sec-nr">11.3.1</SPAN> <SPAN class="sec-title">Reporting
errors and warnings</SPAN></A></H3>
<P><A NAME="idx:messagesreporting:484"></A><A NAME="idx:errorsreporting:485"></A><A NAME="idx:reporting:486"></A>Error,
and warning and informational messages are raised using the
<B><CODE>-></CODE>report</B> or <B><CODE>-></CODE>error</B> method
defined on all <font size=-1>XPCE</font> objects. Basic error and
message handling is described in <A class="sec" href="errors.html">section
10.8</A>. The library
<CODE>library(pce_report)</CODE> defines the classes <B>reporter</B> and
<B>report_dialog</B>.
<P>
<UL>
<LI><I><B>reporter</B></I><BR>
This is a refinement of class <A class="" href="summary.html#class:label">label</A>,
displayed using the fashionable lowered 3D-style. In addition, it
redefines the <B><CODE>-></CODE>report</B> message to colour error
messages red.
<P>
<LI><I><B>report_dialog</B></I><BR>
This is a trivial subclass of <A class="" href="summary.html#class:dialog">dialog</A>,
displaying a
<B>reporter</B> and constraining this reporter to occupy the entire
window.
</UL>
<P>An example using these classes is in <A class="sec" href="libdia.html">section
11.3.2</A>.
<H3><A NAME="sec:11.3.2"><SPAN class="sec-nr">11.3.2</SPAN> <SPAN class="sec-title">Toolbar
support</SPAN></A></H3>
<A NAME="sec:toolbar"></A>
<P><A NAME="idx:buttonbar:487"></A>The library <CODE>library(toolbar)</CODE>
defines the classes <B>tool_bar</B>,
<B>tool_button</B> and <B>tool_status_button</B> to simplify the
definition of tool-bars.
<DL>
<DT><STRONG>tool_bar ->initialise:</STRONG> <VAR>Client:object*,
Orientation:[{horizontal,vertical}]</VAR></DT>
<DD class="defbody">
Create a <B>tool_bar</B> for which the buttons execute actions on
<VAR>Client</VAR> (see class <B>tool_button</B> for details). By default
the buttons are placed left-to-right, but using <CODE>vertical</CODE>
<VAR>Orientation</VAR> they can be stacked top-to-bottom.</DD>
<DT><STRONG>tool_bar ->append:</STRONG> <VAR>Button:tool_button<TT>|</TT>{gap}</VAR></DT>
<DD class="defbody">
Append a tool-button to the bar or, using the name <CODE>gap</CODE>,
make a small gap to separate logical groups of buttons.</DD>
<DT><STRONG>tool_bar ->activate:</STRONG> <VAR></VAR></DT>
<DD class="defbody">
Send <B><CODE>-></CODE>activate</B> to all member buttons, reflecting
whether they are ready to accept commands or `grayed-out'.</DD>
<DT><STRONG>tool_button ->initialise:</STRONG> <VAR></VAR></DT>
<DD class="defbody">
Define a button for <A NAME="idx:toolbarsendappend:488"></A>`<B>tool_bar<CODE>-></CODE>append</B>'. <VAR>Action</VAR>
is the action to execute. If this is a plain atom, this method without
arguments is invoked on the <A NAME="idx:toolbargetclient:489"></A>`<B>tool_bar<CODE><-</CODE>client</B>'.
If it is a code object this code is simply executed. <VAR>Label</VAR> is
the label. Normally for toolbars this will be an <A class="" href="summary.html#class:image">image</A>
object. <VAR>Balloon</VAR> defines the text for the popup-window if the
user rests the pointer long enough on the button. It it is a name, this
balloon is subject to
<A NAME="idx:namegetlabelname:490"></A>`<B>name<CODE><-</CODE>label_name</B>'
(see <A class="sec" href="mlingual.html">section 11.7</A>), otherwise it
is passed literally. Finally, if <VAR>Condition</VAR> is present it is
evaluated by
<B><CODE>-></CODE>activate</B> to determine the activation-state of
the button.</DD>
<DT><STRONG>tool_button ->activate:</STRONG> <VAR></VAR></DT>
<DD class="defbody">
If <B><CODE><-</CODE>condition</B> is present, evaluate it and send <B><CODE>-></CODE>active</B>.</DD>
<DT><STRONG>tool_button ->active:</STRONG> <VAR>Active:bool</VAR></DT>
<DD class="defbody">
If <A NAME="idx:off:491"></A><B>@off</B>, deactivate the button and
provide visual feedback for this.
</DD>
</DL>
<P>A <B>tool_status_button</B> is toggled between depressed state and
normal state on each click. If it has an atomic <B><CODE><-</CODE>action</B>
it will send <VAR>action</VAR>: <A NAME="idx:on:492"></A><B>@on</B> to
the client when going to depressed state and <VAR>action</VAR>:<A NAME="idx:off:493"></A><B>@off</B>
when returning to normal state. If the <B><CODE><-</CODE>action</B>
is a code object this boolean will for forwarded over the code object.
See <A class="sec" href="exeobjects.html">section 10.2</A>.
<H3><A NAME="sec:11.3.3"><SPAN class="sec-nr">11.3.3</SPAN> <SPAN class="sec-title">Example</SPAN></A></H3>
<P>The example below uses these classes as well as class <A class="" href="summary.html#class:menu_bar">menu_bar</A>
to arrive at a typical modern application layout.
<P><A NAME="fig:libdia"></A>
<CENTER>
<IMG SRC="libdia.gif">
</CENTER>
<TABLE ALIGN=center WIDTH="75%"><TR><TD>
<B>Figure 20 : </B>Simple application framework</TABLE>
<PRE class="code">
% Pull in the classes
:- pce_autoload(report_dialog, library(pce_report)).
:- pce_autoload(tool_bar, library(toolbar)).
:- pce_autoload(finder, library(find_file)).
:- pce_global(@finder, new(finder)).
% Define icons as program resources
resource(printer, image, image('16x16/print.xpm')).
resource(floppy, image, image('16x16/save.xpm')).
% Define the application as a subclass of frame.
:- pce_begin_class(myapp, frame,
"Frame representing the application").
initialise(MyApp) :->
send_super(MyApp, initialise, 'My application'),
send(MyApp, append, new(D, dialog)),
send(D, pen, 0),
send(D, gap, size(5, 5)),
send(D, append, new(menu_bar)),
send(D, append, new(tool_bar(MyApp))),
send(MyApp, fill_menu_bar),
send(MyApp, fill_tool_bar),
send(new(W, myapp_workspace), below, D),
send(new(report_dialog), below, W).
fill_menu_bar(F) :->
get(F, member, dialog, D),
get(D, member, menu_bar, MB),
send_list(MB, append,
[ new(File, popup(file)),
new(_Edit, popup(edit))
]),
send_list(File, append,
[ menu_item(load,
message(F, load),
end_group := @on),
menu_item(print,
message(F, print))
]).
fill_tool_bar(F) :->
get(F, member, dialog, D),
get(D, member, tool_bar, TB),
send_list(TB, append,
[ tool_button(load,
resource(floppy),
load),
gap, % skip a little
tool_button(print,
resource(printer),
print)
]).
print(MyApp) :->
"Print the document"::
send(MyApp, report, progress, 'Printing ...'),
get(MyApp, member, myapp_workspace, WS),
send(WS, print),
send(MyApp, report, progress, done).
load(MyApp) :->
"Ask a file and load it"::
get(@finder, file, @on, myp, File),
get(MyApp, member, myapp_workspace, WS),
send(WS, load, File).
:- pce_end_class(myapp).
% dummy class for the work-area of your application
:- pce_begin_class(myapp_workspace, window).
:- pce_end_class(myapp_workspace).</PRE>
<P></BODY></HTML>
|