The Gnome Chemistry Utils  0.14.0
widgetdata.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * widgetdata.h
6  *
7  * Copyright (C) 2002-2012 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCHEMPAINT_WIDGET_DATA_H
26 #define GCHEMPAINT_WIDGET_DATA_H
27 
28 #include <gcu/object.h>
29 #include <gccv/structs.h>
30 #include <map>
31 #include <set>
32 
34 namespace gcp {
35 
36 class Application;
37 class View;
38 
45 extern guint ClipboardDataType, ClipboardDataType1;
50  extern xmlChar* ClipboardData;
54 extern char* ClipboardTextData;
62 void on_receive_targets (GtkClipboard *clipboard, GtkSelectionData *selection_data, Application *App);
69 void on_clear_data (GtkClipboard *clipboard, gcu::Object *obj);
70 
75 {
92 };
93 
100 {
101 public:
109  GtkWidget *Canvas;
113  double Zoom;
117 // std::map<gcu::Object const*, GnomeCanvasGroup*>Items;
121  std::set < gcu::Object * >SelectedObjects;
122 
127  bool IsSelected (gcu::Object const *obj) const;
128 
134  bool ChildrenSelected (gcu::Object const *obj) const;
135 
136 
143 
150  void SetSelected (gcu::Object *obj, int state = gcp::SelStateSelected);
156  void Unselect (gcu::Object *obj);
160  void UnselectAll ();
169  void MoveSelectedItems (double dx, double dy);
177  void MoveSelection (double dx, double dy);
185  void RotateSelection (double x, double y, double angle);
189  void ClearSelection () {SelectedObjects.clear();}
195  void Copy (GtkClipboard* clipboard);
201  void GetSelectionBounds (gccv::Rect &rect) const;
205  bool HasSelection () {return !(SelectedObjects.empty());}
209  void SelectAll ();
214  static xmlDocPtr GetXmlDoc (GtkClipboard* clipboard);
221  void ShowSelection (bool state);
228  void GetObjectBounds (gcu::Object const *obj, gccv::Rect *rect) const;
235  void GetObjectsBounds (std::set <gcu::Object const *> const &objects, gccv::Rect *rect) const;
236  void GetObjectsBounds (std::set <gcu::Object *> const &objects, gccv::Rect *rect) const;
243  void GetObjectBounds (gcu::Object const* obj, gccv::Rect &rect) const;
244 
249  void SimplifySelection ();
250 
251 private:
252  void MoveItems (gcu::Object *obj, double dx, double dy);
253 };
254 
255 } // namespace gcp
256 
257 #endif //GCHEMPAINT_WIDGET_DATA_H