widgetdata.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * widgetdata.h
00006  *
00007  * Copyright (C) 2002-2007 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 
00033 using namespace gcu;
00034 
00035 namespace gcp {
00036 
00037 class Application;
00038 class View;
00039 
00040 extern guint ClipboardDataType, ClipboardDataType1;
00041 extern xmlChar* ClipboardData;
00042 extern bool cleared;
00043 void on_receive_targets (GtkClipboard *clipboard, GtkSelectionData *selection_data, Application *App);
00044 void on_clear_data (GtkClipboard *clipboard, Application *App);
00045 
00046 enum
00047 {
00048         SelStateUnselected = 0,
00049         SelStateSelected,
00050         SelStateUpdating,
00051         SelStateErasing
00052 };
00053 
00054 class WidgetData
00055 {
00056 public:
00057         View* m_View;
00058         GtkWidget *Canvas;
00059         GnomeCanvasGroup *Group;
00060         GnomeCanvasItem* Background;
00061         double Zoom;
00062         std::map<Object*, GnomeCanvasGroup*>Items;
00063         std::list<Object*>SelectedObjects;
00064         
00065         bool IsSelected (Object* obj);
00066         void SetSelected (Object* obj);
00067         void Unselect (Object* obj);
00068         void UnselectAll ();
00069         void MoveSelectedItems (double dx, double dy);
00070         void MoveSelection (double dx, double dy);
00071         void RotateSelection (double dx, double dy, double angle);
00072         void ClearSelection () {SelectedObjects.clear();}
00073         void Copy (GtkClipboard* clipboard);
00074         void GetSelectionBounds (ArtDRect &rect);
00075         bool HasSelection () {return !(SelectedObjects.empty());}
00076         void SelectAll ();
00077         static xmlDocPtr GetXmlDoc (GtkClipboard* clipboard);
00078         void ShowSelection (bool state);
00079         void GetObjectBounds (Object* obj, ArtDRect *rect);
00080 
00081 private:
00082         void MoveItems (Object *obj, double dx, double dy);
00083         void GetObjectBounds (Object* obj, ArtDRect &rect);
00084 };
00085 
00086 }       // namespace gcp
00087 
00088 #endif //GCHEMPAINT_WIDGET_DATA_H

Generated on Sun Sep 16 14:21:55 2007 for The Gnome Chemistry Utils by  doxygen 1.5.3