Sophie

Sophie

distrib > * > 2010.0 > * > by-pkgid > 345aa895e80053137c21f8693106c3a0 > files > 145

gtkmm2.4-documentation-2.17.4-1mdv2010.0.noarch.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Extending the print dialog</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.1">
<link rel="home" href="index.html" title="Programming with gtkmm">
<link rel="up" href="chapter-printing.html" title="Chapter 18. Printing">
<link rel="prev" href="sec-printing-export-to-pdf.html" title="Export to PDF">
<link rel="next" href="sec-printing-preview.html" title="Preview">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Extending the print dialog</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="sec-printing-export-to-pdf.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center">Chapter 18. Printing</th>
<td width="20%" align="right"> <a accesskey="n" href="sec-printing-preview.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Extending the print dialog">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-extending-print-dialog"></a>Extending the print dialog</h2></div></div></div>
<p>
You may add a custom tab to the print dialog:

</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
      Set the title of the tab via
      <code class="methodname">PrintOperation::set_custom_tab_label()</code>,
      create a new widget and return it from the
      <code class="literal">create_custom_widget</code> signal handler. You'll probably
      want this to be a container widget, packed with some others.
    </p></li>
<li class="listitem"><p>
      Get the data from the widgets in the
      <code class="literal">custom_widget_apply</code> signal handler.
    </p></li>
</ul></div>
<p>
</p>
<p>
Although the <code class="literal">custom_widget_apply</code> signal provides the widget you
previously created, to simplify things you can keep the widgets you expect
to contain some user input as class members. For example, let's say you have
a <code class="classname">Gtk::Entry</code> called <code class="literal">m_Entry</code> as
a member of your <code class="classname">CustomPrintOperation</code> class:

</p>
<pre class="programlisting">
Gtk::Widget* CustomPrintOperation::on_create_custom_widget()
{
  set_custom_tab_label("My custom tab");

  Gtk::HBox* hbox = new Gtk::HBox(false, 8);
  hbox-&gt;set_border_width(6);

  Gtk::Label* label = Gtk::manage(new Gtk::Label("Enter some text: "));
  hbox-&gt;pack_start(*label, false, false);
  label-&gt;show();

  hbox-&gt;pack_start(m_Entry, false, false);
  m_Entry.show();

  return hbox;
}

void CustomPrintOperation::on_custom_widget_apply(Gtk::Widget* /* widget */)
{
  Glib::ustring user_input = m_Entry.get_text();
  //...
}
</pre>
<p>

</p>
<p>
The example in examples/book/printing/advanced demonstrates this.
</p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="sec-printing-export-to-pdf.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"><a accesskey="u" href="chapter-printing.html"><img src="icons/up.png" alt="Up"></a></td>
<td width="40%" align="right"> <a accesskey="n" href="sec-printing-preview.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Export to PDF </td>
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="icons/home.png" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Preview</td>
</tr>
</table>
</div>
</body>
</html>