<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.4"/> <title>gtkspellmm: example/example.cc</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">gtkspellmm  <span id="projectnumber">3.0.2</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.4 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">example/example.cc</div> </div> </div><!--header--> <div class="contents"> <p>A gtkspellmm example program.</p> <div class="fragment"><div class="line"><span class="comment">/* Copyright (c) 2013 Sandro Mani <manisandro@gmail.com></span></div> <div class="line"><span class="comment"> *</span></div> <div class="line"><span class="comment"> * This file is part of gtkspellmm.</span></div> <div class="line"><span class="comment"> *</span></div> <div class="line"><span class="comment"> * gtkspellmm is free software: you can redistribute it and/or modify it</span></div> <div class="line"><span class="comment"> * under the terms of the GNU General Public License as published by the</span></div> <div class="line"><span class="comment"> * Free Software Foundation, either version 2 of the License, or</span></div> <div class="line"><span class="comment"> * (at your option) any later version.</span></div> <div class="line"><span class="comment"> *</span></div> <div class="line"><span class="comment"> * gtkspellmm is distributed in the hope that it will be useful, but</span></div> <div class="line"><span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span></div> <div class="line"><span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span></div> <div class="line"><span class="comment"> * See the GNU General Public License for more details.</span></div> <div class="line"><span class="comment"> *</span></div> <div class="line"><span class="comment"> * You should have received a copy of the GNU General Public License along</span></div> <div class="line"><span class="comment"> * with this program. If not, see <http://www.gnu.org/licenses/>.</span></div> <div class="line"><span class="comment"> */</span></div> <div class="line"></div> <div class="line"><span class="preprocessor">#include <gtkmm.h></span></div> <div class="line"><span class="preprocessor">#include <gtkspellmm.h></span></div> <div class="line"><span class="preprocessor">#include <<a class="codeRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00821.html">iostream</a>></span></div> <div class="line"></div> <div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div> <div class="line">{</div> <div class="line"> <a name="a0"></a><a class="code" href="namespaceGtkSpell.html#a1ca323af21a58bf907e1c71456908f37" title="Initializes the GtkSpell library. ">GtkSpell::init</a>();</div> <div class="line"> <a name="_a1"></a><a class="codeRef" href="http://library.gnome.org/devel/glibmm/unstable/classGlib_1_1RefPtr.html">Glib::RefPtr<Gtk::Application></a> app = <a name="a2"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1Application.html#a0521e314658e75606184c53dcb4b8cef">Gtk::Application::create</a>(argc, argv,</div> <div class="line"> <span class="stringliteral">"org.gtkmm.examples.gtkspell"</span>);</div> <div class="line"></div> <div class="line"> <a name="_a3"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1ApplicationWindow.html">Gtk::ApplicationWindow</a> window;</div> <div class="line"></div> <div class="line"> <a name="_a4"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1TextView.html">Gtk::TextView</a> view;</div> <div class="line"> view.<a name="a5"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1TextView.html#a662a116b04038b2a0f084626a3d9e63a">set_wrap_mode</a>(<a name="a6"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/group__gtkmmEnums.html#ggad4b21987a45f87bbdae74d63d92e543ba6af0013689b6b57aa72d821f00b55156">Gtk::WRAP_WORD</a>);</div> <div class="line"></div> <div class="line"> <a name="_a7"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1ScrolledWindow.html">Gtk::ScrolledWindow</a> scroll;</div> <div class="line"> scroll.<a name="a8"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1ScrolledWindow.html#a17352bdfd39d8a895e5c885f0bd1a246">set_policy</a>(<a name="a9"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/group__gtkmmEnums.html#ggacb7ebcc442f2bdbeca2bf7436c18ffd9ac48d495984e6875158f7d08bbce45200">Gtk::POLICY_AUTOMATIC</a>, <a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/group__gtkmmEnums.html#ggacb7ebcc442f2bdbeca2bf7436c18ffd9ac48d495984e6875158f7d08bbce45200">Gtk::POLICY_AUTOMATIC</a>);</div> <div class="line"> scroll.<a name="a10"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1ScrolledWindow.html#af77cafa057cf36404d634eede6b773d8">set_shadow_type</a>(<a name="a11"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/group__gtkmmEnums.html#ggac5cfb21bae7f04c83c5eabdacb92512eacf9802885c29c9c566924579e3ccbf72">Gtk::SHADOW_IN</a>);</div> <div class="line"> scroll.<a name="a12"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1ScrolledWindow.html#a17c588d56d93923841d38f0d5e2ec9d7">add</a>(view);</div> <div class="line"></div> <div class="line"> <a name="_a13"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1Label.html">Gtk::Label</a> label(<span class="stringliteral">"Type some text into the text box.\n"</span></div> <div class="line"> <span class="stringliteral">"Try misspelling some words. Then right-click on them."</span>);</div> <div class="line"></div> <div class="line"> <a name="_a14"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1Box.html">Gtk::Box</a> box(<a name="a15"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/group__gtkmmEnums.html#gga84179a467b0ed4f61b4e325eb09b0b1ca7afd14e4fa7da142c9c8397417501609">Gtk::ORIENTATION_VERTICAL</a>, 5);</div> <div class="line"> box.pack_start(label, <span class="keyword">false</span>, <span class="keyword">false</span>, 0);</div> <div class="line"> box.pack_start(scroll, <span class="keyword">true</span>, <span class="keyword">true</span>, 0);</div> <div class="line"></div> <div class="line"> <a name="_a16"></a><a class="code" href="classGtkSpell_1_1Checker.html">GtkSpell::Checker</a> spell;</div> <div class="line"> <span class="keywordflow">try</span> {</div> <div class="line"> spell.<a name="a17"></a><a class="code" href="classGtkSpell_1_1Checker.html#a7f1b26cca2a8e4d3f542179a834c2184" title="Sets the language to be used for spelling, throws an exception on failure. ">set_language</a>(<span class="stringliteral">"en_US"</span>);</div> <div class="line"> } <span class="keywordflow">catch</span>(<span class="keyword">const</span> <a name="_a18"></a><a class="code" href="classGtkSpell_1_1Error.html">GtkSpell::Error</a>& e) {</div> <div class="line"> label.set_text(<a name="_a19"></a><a class="codeRef" href="http://library.gnome.org/devel/glibmm/unstable/classGlib_1_1ustring.html">Glib::ustring</a>(<span class="stringliteral">"GtkSpell initialization failed.\n"</span>) + e.<a name="a20"></a><a class="codeRef" href="http://library.gnome.org/devel/glibmm/unstable/classGlib_1_1Exception.html#a2423c81571a101571751fe0a046beef0">what</a>());</div> <div class="line"> }</div> <div class="line"> spell.<a name="a21"></a><a class="code" href="classGtkSpell_1_1Checker.html#a1e5dbb84ae8621ff6f856939ef6c25c8" title="Attach the GtkSpell::Checker to the specified Gtk::TextView. ">attach</a>(view);</div> <div class="line"></div> <div class="line"> window.set_default_size(400, 400);</div> <div class="line"> window.set_title(<span class="stringliteral">"Simple GtkSpell Demonstration"</span>);</div> <div class="line"> window.set_border_width(10);</div> <div class="line"> window.add(box);</div> <div class="line"> box.show_all();</div> <div class="line"></div> <div class="line"> <span class="keywordflow">return</span> app-><a name="a22"></a><a class="codeRef" href="http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1Application.html#a41ede16109c06bbefce5194f4b601780">run</a>(window);</div> <div class="line">}</div> </div><!-- fragment --> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Tue Jun 4 2013 00:37:38 for gtkspellmm by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.4 </small></address> </body> </html>