summaryrefslogtreecommitdiffstats
path: root/doc/html/motif-walkthrough-5.html
blob: 8d0be21c788775b0177524df37b306942eaecef6 (plain)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/motif/doc/walkthrough.doc:661 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Using Existing Dialogs with TQMotifDialog</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Using Existing Dialogs with TQMotifDialog</h1>



[ <a href="motif-walkthrough-4.html">Previous: Using Custom TQDialogs</a> ]
[ <a href="motif-walkthrough.html">Home</a> ]
[ <a href="motif-walkthrough-6.html">Next: Using TQt Main Window Classes</a> ]
<p> As mentioned earlier, the <em>Print</em> dialog cannot be replaced until we
have converted the <em>View</em> widget.  The <em>Print</em> dialog will be
removed once we have finished our migration, since we will use
<a href="qprinter.html">TQPrinter</a> instead.  Based on this information, we decide that it is not
worth replacing the <em>Print</em> dialog with a custom <a href="qdialog.html">TQDialog</a> replacement.
Instead, we will keep the <a href="motif-extension.html#Motif">Motif</a> based dialog and use <a href="qmotifdialog.html">TQMotifDialog</a> to
integrate the dialog with the application.
<p> <h2> Modality Retquirements
</h2>
<a name="1"></a><p> Modality with TQDialog is different from Motif.  The <a href="qdialog.html#exec">TQDialog::exec</a>()
function does not return until the dialog is finished.  In Motif,
modality is simply a property of the shell, and the application
programmer must write TQDialog::exec() style functionality if they
want that behavior.
<p> Since we will be using TQMotifDialog (which is a TQDialog subclass), we
will need to have an <em>accept</em> and a <em>reject</em> callback for each
dialog we integrate with TQMotifDialog.  The predefined Motif dialogs
have these already: the <tt>XmNokCallback</tt> and <tt>XmNcancelCallback</tt>
callbacks.  However, the <em>Print</em> dialog only has an <em>accept</em> callback
(the <tt>XmdNprintCallback</tt>), but it does not have a <em>reject</em> callback.
We need to add this.
<p> This is easily done.  We add an <tt>XtCallbackList</tt> for the <tt>XmNcancelCallback</tt> callback in <tt>Xmd/PrintP.h</tt>:
<p> 

<pre></pre>
<p> We add the <tt>XmNcancelCallback</tt> callback to the list of resources for
the <tt>XmdPrint</tt> widget class in <tt>Xmd/Print.c</tt>:
<p> 

<pre></pre>
<p> We need to activate this callback whenever we unmanage the widget and
do not activate the <em>print</em> callback, which is in the <tt>do_help_cb()</tt>
function:
<p> <pre></pre>
<p> ... and in the unmanage_cb() function:
<p> <pre></pre>
<p> <h2> Integrating the <em>Print</em> Dialog
</h2>
<a name="2"></a><p> Now that the <em>Print</em> dialog has the appropriate <em>accept</em> and <em>reject</em> callbacks, we can use <a href="qmotifdialog.html">TQMotifDialog</a>.  First we need to include
the TQMotifDialog header in <tt>todo.cpp</tt>.
<p> 

<p> <pre></pre>
<p> We add a <tt>ShowPrintDialog()</tt> function which will create and execute the
print dialog.
<p> <pre></pre>
<p> We change the <em>Print</em> menu item callback to call the new <tt>ShowPrintDialog()</tt> function.  We pass the top-level <a href="qmotifwidget.html">TQMotifWidget</a>, which
we will use as the parent for the dialog.
<p> <pre></pre>
<p> The <tt>ShowPrintDialog()</tt> function creates the <em>Print</em> dialog and
executes it.  We use the <tt>XmdNprintCallback</tt> callback to accept the
dialog and the <tt>XmNcancelCallback</tt> callback to reject the dialog.  We
can do this easily by using the <a href="qmotifdialog.html#acceptCallback">TQMotifDialog::acceptCallback</a>() and
<a href="qmotifdialog.html#rejectCallback">TQMotifDialog::rejectCallback</a>() functions, respectively.  We also
ensure that the <em>print</em> callback continues to call the <tt>Print()</tt> function as before.
<p> <pre></pre>
<p> After we build the project, the application runs and operates as
expected.  There is no visual or behavioral difference, even though
the <em>Print</em> dialog is using <a href="qmotifdialog.html">TQMotifDialog</a>.
<p> [ <a href="motif-walkthrough-4.html">Previous: Using Custom TQDialogs</a> ]
[ <a href="motif-walkthrough.html">Home</a> ]
[ <a href="motif-walkthrough-6.html">Next: Using TQt Main Window Classes</a> ]
<p> 
<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>