libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GtkCRNAltoDocument.cpp
Go to the documentation of this file.
1 /* Copyright 2012-2016 CoReNum, INSA-Lyon
2  *
3  * This file is part of libgtkcrnmm.
4  *
5  * libgtkcrnmm is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libgtkcrnmm is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libgtkcrnmm. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: GdkCRNAltoDocument.cpp
19  * \author Yann LEYDIER
20  */
21 
22 #include <GtkCRNAltoDocument.h>
23 
24 #ifndef CRN_USING_GTKMM3
25 using namespace GtkCRN;
26 
28  doc(true, false)
29 {
30  add(doc);
31  doc.signal_view_selection_changed().connect(sigc::mem_fun(this, &AltoDocument::on_view_selection_changed));
32  doc.show();
33  imgwrapper.set_image(&doc.get_image());
34  toolbar.set_orientation(Gtk::ORIENTATION_VERTICAL);
35  toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS);
36  toolbar.append(*Gtk::manage(imgwrapper.get_actions()->get_action("alto-pages")->create_tool_item()));
37  toolbar.append(*Gtk::manage(imgwrapper.get_actions()->get_action("alto-spaces")->create_tool_item()));
38  toolbar.append(*Gtk::manage(imgwrapper.get_actions()->get_action("alto-textblocks")->create_tool_item()));
39  toolbar.append(*Gtk::manage(imgwrapper.get_actions()->get_action("alto-textlines")->create_tool_item()));
40  toolbar.append(*Gtk::manage(imgwrapper.get_actions()->get_action("alto-words")->create_tool_item()));
41  toolbar.append(*Gtk::manage(imgwrapper.get_actions()->get_action("alto-edit")->create_tool_item()));
42  doc.get_left_panel().pack_start(toolbar, true, true, 2);
43  toolbar.show_all();
44 }
45 
46 void AltoDocument::set_alto(const crn::xml::SAltoWrapper &aw)
47 {
48  alto = aw;
49  if (alto)
50  doc.set_document(alto->GetDocument());
51  else
52  doc.set_document(nullptr);
53 }
54 
56 {
57  toolbar.set_visible(show);
58 }
59 
60 void AltoDocument::on_view_selection_changed(const crn::String last_selected_view_id, const std::vector<crn::String> selected_views_ids)
61 {
62  if (last_selected_view_id.IsNotEmpty() && alto)
63  {
64  imgwrapper.set_view(alto->GetView(last_selected_view_id), false);
65  }
66  else
67  {
68  imgwrapper.unset_view(false);
69  }
70 }
71 
72 #endif
GtkCRN::Image & get_image()
Gets the image widget.
void set_view(const crn::xml::AltoWrapper::View &v, bool display_image)
Sets the alto view.
void set_image(Image *image)
Sets the Image widget to wrap around.
A UTF32 character string class.
Definition: CRNString.h:61
#define false
Definition: ConvertUTF.cpp:56
void set_alto(const crn::xml::SAltoWrapper &aw)
void set_document(const crn::SDocument &doc)
Sets the document to display.
#define true
Definition: ConvertUTF.cpp:57
void set_show_toolbar(bool show)
sigc::signal< void, const crn::String, const std::vector< crn::String > > signal_view_selection_changed()
Signal when the selection has changed. Connect to void on_view_selection_changed(const crn::String la...
Gtk::Box & get_left_panel()
Return the VBox on the left of the image.
Glib::RefPtr< Gtk::ActionGroup > get_actions()
Gets the action group associated to the alto wrapper.
void unset_view(bool clear_image)
Unsets the alto view.
bool IsNotEmpty() const noexcept
Checks if the string is not empty.
Definition: CRNString.h:168