gcp/view.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * view.h 
00006  *
00007  * Copyright (C) 2001-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_VIEW_H
00026 #define GCHEMPAINT_VIEW_H
00027 
00028 #include <map>
00029 #include <list>
00030 #include <libgnomecanvas/libgnomecanvas.h>
00031 #include <canvas/gcp-canvas-pango.h>
00032 #include <gcu/macros.h>
00033 #include "atom.h"
00034 #include "bond.h"
00035 
00036 namespace gcp {
00037 
00038 class Document;
00039 class WidgetData;
00040 
00041 #define GCHEMPAINT_ATOM_NAME "application/x-gchempaint"
00042 extern GtkTargetEntry const targets[];
00043 
00044 class View
00045 {
00046 public:
00047         //Constructor and destructor
00048         View (Document *pDoc, bool Embedded);
00049         virtual ~View ();
00050 
00051         //Interface     
00052 public:
00053         GtkWidget* GetWidget () {return m_pWidget;}
00054         Document* GetDoc () {return m_pDoc;}
00055         bool OnEvent (GnomeCanvasItem *item, GdkEvent *event, GtkWidget* widget);
00056         void AddObject (gcu::Object const *pObject);
00057         void Update (gcu::Object const *pObject);
00058         GtkWidget* CreateNewWidget ();
00059         void OnDestroy (GtkWidget* widget);
00060         GnomeCanvasItem* GetCanvasItem (GtkWidget* widget, gcu::Object* Object);
00061         GnomeCanvasItem* GetBackground ();
00062         double GetZoomFactor ();
00063         void UpdateFont ();
00064         void Remove (gcu::Object* pObject);
00065         PangoContext* GetPangoContext () {return m_PangoContext;}
00066         double GetFontHeight () {return m_dFontHeight;}
00067         gchar* GetFontName () {return m_sFontName;}
00068         gchar* GetSmallFontName () {return m_sSmallFontName;}
00069         PangoFontDescription* GetPangoFontDesc () {return m_PangoFontDesc;}
00070         PangoFontDescription* GetPangoSmallFontDesc () {return m_PangoSmallFontDesc;}
00071         void OnDeleteSelection (GtkWidget* w);
00072         void OnCopySelection (GtkWidget* w, GtkClipboard* clipboard);
00073         void OnPasteSelection (GtkWidget* w, GtkClipboard* clipboard);
00074         void OnCutSelection (GtkWidget* w, GtkClipboard* clipboard);
00075         bool OnKeyPress (GtkWidget* w, GdkEventKey* event);
00076         bool OnKeyRelease (GtkWidget* w, GdkEventKey* event);
00077         bool OnSize (GtkWidget *w, int width, int height);
00078         void UpdateSize (double x1, double y1, double x2, double y2);
00079         void SetGnomeCanvasPangoActive (GnomeCanvasPango* item);
00080         bool PrepareUnselect ();
00081         void OnReceive (GtkClipboard* clipboard, GtkSelectionData* selection_data);
00082         void OnSelectAll ();
00083         bool IsEmbedded () {return m_bEmbedded;}
00084         int GetNbWidgets () {return m_Widgets.size ();}
00085         void ExportImage (std::string const &filename, const char* type, int resolution = -1);
00086         xmlDocPtr BuildSVG ();
00087         GdkPixbuf *BuildPixbuf (int resolution);
00088         void EnsureSize ();
00089         void Zoom (double zoom);
00090         void ShowCursor (bool show);
00091         void UpdateTheme ();
00092         void Render (cairo_t *cr);
00093 
00094         //Implementation
00095 private:
00096         WidgetData* m_pData;
00097         Document* m_pDoc;
00098         GtkWidget* m_pWidget;
00099         std::list<GtkWidget*> m_Widgets;
00100         PangoContext* m_PangoContext;
00101         PangoFontDescription* m_PangoFontDesc, *m_PangoSmallFontDesc;
00102         double m_dFontHeight;
00103         gchar* m_sFontName, *m_sSmallFontName;
00104         int m_width, m_height;
00105         double m_lastx, m_lasty;
00106         bool m_bEmbedded;
00107         GtkUIManager *m_UIManager;
00108         bool m_Dragging;
00109         gcu::Object *m_CurObject;
00110 
00111 GCU_RO_PROP (double, BaseLineOffset)
00112 GCU_RO_PROP (GnomeCanvasPango*, ActiveRichText)
00113 };
00114 
00115 bool on_event (GnomeCanvasItem *item, GdkEvent *event, GtkWidget* widget);
00116 void on_receive (GtkClipboard *clipboard, GtkSelectionData *selection_data, View * pView);
00117 
00118 }       //      namespace gcp
00119 
00120 #endif // GCHEMPAINT_VIEW_H

Generated on Sun Jun 22 13:26:05 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6