The Gnome Chemistry Utils 0.13.3
widgetdata.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * widgetdata.h
00006  *
00007  * Copyright (C) 2002-2011 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef GCHEMPAINT_WIDGET_DATA_H
00026 #define GCHEMPAINT_WIDGET_DATA_H
00027 
00028 #include <gcu/object.h>
00029 #include <gccv/structs.h>
00030 #include <map>
00031 #include <set>
00032 
00034 namespace gcp {
00035 
00036 class Application;
00037 class View;
00038 
00045 extern guint ClipboardDataType, ClipboardDataType1;
00050         extern xmlChar* ClipboardData;
00054 extern char* ClipboardTextData;
00062 void on_receive_targets (GtkClipboard *clipboard, GtkSelectionData *selection_data, Application *App);
00069 void on_clear_data (GtkClipboard *clipboard, gcu::Object *obj);
00070 
00074 enum SelectionState
00075 {
00079         SelStateUnselected = 0,
00083         SelStateSelected,
00087         SelStateUpdating,
00091         SelStateErasing
00092 };
00093 
00099 class WidgetData
00100 {
00101 public:
00105         View* m_View;
00109         GtkWidget *Canvas;
00113         double Zoom;
00117 //      std::map<gcu::Object const*, GnomeCanvasGroup*>Items;
00121         std::set < gcu::Object * >SelectedObjects;
00122         
00127         bool IsSelected (gcu::Object const *obj) const;
00128         
00134         bool ChildrenSelected (gcu::Object const *obj) const;
00135 
00136         
00142         gcu::Object *GetSelectedAncestor (gcu::Object *obj);
00143 
00150         void SetSelected (gcu::Object *obj, int state = gcp::SelStateSelected);
00156         void Unselect (gcu::Object *obj);
00160         void UnselectAll ();
00169         void MoveSelectedItems (double dx, double dy);
00177         void MoveSelection (double dx, double dy);
00185         void RotateSelection (double x, double y, double angle);
00189         void ClearSelection () {SelectedObjects.clear();}
00195         void Copy (GtkClipboard* clipboard);
00201         void GetSelectionBounds (gccv::Rect &rect) const;
00205         bool HasSelection () {return !(SelectedObjects.empty());}
00209         void SelectAll ();
00214         static xmlDocPtr GetXmlDoc (GtkClipboard* clipboard);
00221         void ShowSelection (bool state);
00228         void GetObjectBounds (gcu::Object const *obj, gccv::Rect *rect) const;
00235         void GetObjectsBounds (std::set <gcu::Object const *> const &objects, gccv::Rect *rect) const;
00236         void GetObjectsBounds (std::set <gcu::Object *> const &objects, gccv::Rect *rect) const;
00237         void GetObjectBounds (gcu::Object const* obj, gccv::Rect &rect) const;
00238          
00243         void SimplifySelection ();
00244 
00245 private:
00246         void MoveItems (gcu::Object *obj, double dx, double dy);
00247 };
00248 
00249 }       // namespace gcp
00250 
00251 #endif //GCHEMPAINT_WIDGET_DATA_H