widgetdata.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * widgetdata.h
00006  *
00007  * Copyright (C) 2002-2008 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 <libgnomecanvas/gnome-canvas.h>
00029 #include <map>
00030 #include <list>
00031 #include <gcu/object.h>
00032 
00034 namespace gcp {
00035 
00036 class Application;
00037 class View;
00038 
00039 extern guint ClipboardDataType, ClipboardDataType1;
00040 extern xmlChar* ClipboardData;
00041 extern char* ClipboardTextData;
00042 extern bool cleared;
00043 void on_receive_targets (GtkClipboard *clipboard, GtkSelectionData *selection_data, Application *App);
00044 void on_clear_data (GtkClipboard *clipboard, gcu::Object *obj);
00045 
00049 enum SelectionState
00050 {
00054         SelStateUnselected = 0,
00058         SelStateSelected,
00062         SelStateUpdating,
00066         SelStateErasing
00067 };
00068 
00074 class WidgetData
00075 {
00076 public:
00080         View* m_View;
00084         GtkWidget *Canvas;
00088         GnomeCanvasGroup *Group;
00092         GnomeCanvasItem* Background;
00096         double Zoom;
00100         std::map<gcu::Object const*, GnomeCanvasGroup*>Items;
00104         std::list<gcu::Object*>SelectedObjects;
00105         
00110         bool IsSelected (gcu::Object const *obj) const;
00116         void SetSelected (gcu::Object *obj);
00122         void Unselect (gcu::Object *obj);
00126         void UnselectAll ();
00135         void MoveSelectedItems (double dx, double dy);
00143         void MoveSelection (double dx, double dy);
00151         void RotateSelection (double x, double y, double angle);
00155         void ClearSelection () {SelectedObjects.clear();}
00161         void Copy (GtkClipboard* clipboard);
00167         void GetSelectionBounds (ArtDRect &rect) const;
00171         bool HasSelection () {return !(SelectedObjects.empty());}
00175         void SelectAll ();
00180         static xmlDocPtr GetXmlDoc (GtkClipboard* clipboard);
00187         void ShowSelection (bool state);
00194         void GetObjectBounds (gcu::Object const *obj, ArtDRect *rect) const;
00195 
00196 private:
00197         void MoveItems (gcu::Object *obj, double dx, double dy);
00198         void GetObjectBounds (gcu::Object const* obj, ArtDRect &rect) const;
00199 };
00200 
00201 }       // namespace gcp
00202 
00203 #endif //GCHEMPAINT_WIDGET_DATA_H

Generated on Wed Feb 3 12:55:26 2010 for The Gnome Chemistry Utils by  doxygen 1.6.1