gcp/view.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * view.h 
00006  *
00007  * Copyright (C) 2001-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_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 
00047 class View
00048 {
00049 public:
00050         //Constructor and destructor
00058         View (Document *pDoc, bool Embedded);
00062         virtual ~View ();
00063 
00064         //Interface     
00065 public:
00069         GtkWidget* GetWidget () {return m_pWidget;}
00073         Document* GetDoc () {return m_pDoc;}
00082         bool OnEvent (GnomeCanvasItem *item, GdkEvent *event, GtkWidget* widget);
00086         void AddObject (gcu::Object const *pObject);
00089         void Update (gcu::Object const *pObject);
00092         GtkWidget* CreateNewWidget ();
00095         void OnDestroy (GtkWidget* widget);
00098         GnomeCanvasItem* GetCanvasItem (GtkWidget* widget, gcu::Object* Object);
00101         GnomeCanvasItem* GetBackground ();
00104         double GetZoomFactor ();
00107         void UpdateFont ();
00110         void Remove (gcu::Object* pObject);
00113         PangoContext* GetPangoContext () {return m_PangoContext;}
00116         double GetFontHeight () {return m_dFontHeight;}
00119         gchar* GetFontName () {return m_sFontName;}
00122         gchar* GetSmallFontName () {return m_sSmallFontName;}
00125         PangoFontDescription* GetPangoFontDesc () {return m_PangoFontDesc;}
00128         PangoFontDescription* GetPangoSmallFontDesc () {return m_PangoSmallFontDesc;}
00134         void OnDeleteSelection (GtkWidget* w);
00141         void OnCopySelection (GtkWidget* w, GtkClipboard* clipboard);
00148         void OnPasteSelection (GtkWidget* w, GtkClipboard* clipboard);
00155         void OnCutSelection (GtkWidget* w, GtkClipboard* clipboard);
00159         bool OnKeyPress (GtkWidget* w, GdkEventKey* event);
00163         bool OnKeyRelease (GtkWidget* w, GdkEventKey* event);
00167         bool OnSize (GtkWidget *w, int width, int height);
00171         void UpdateSize (double x1, double y1, double x2, double y2);
00175         void SetGnomeCanvasPangoActive (GnomeCanvasPango* item);
00179         bool PrepareUnselect ();
00183         void OnReceive (GtkClipboard* clipboard, GtkSelectionData* selection_data);
00187         void OnSelectAll ();
00191         bool IsEmbedded () {return m_bEmbedded;}
00195         int GetNbWidgets () {return m_Widgets.size ();}
00199         void ExportImage (std::string const &filename, const char* type, int resolution = -1);
00203         xmlDocPtr BuildSVG ();
00211         GdkPixbuf *BuildPixbuf (int resolution);
00216         void EnsureSize ();
00222         void Zoom (double zoom);
00228         void ShowCursor (bool show);
00232         void UpdateTheme ();
00238         void Render (cairo_t *cr);
00239 
00240         //Implementation
00241 private:
00242         WidgetData* m_pData;
00243         Document* m_pDoc;
00244         GtkWidget* m_pWidget;
00245         std::list<GtkWidget*> m_Widgets;
00246         PangoContext* m_PangoContext;
00247         PangoFontDescription* m_PangoFontDesc, *m_PangoSmallFontDesc;
00248         double m_dFontHeight;
00249         gchar* m_sFontName, *m_sSmallFontName;
00250         int m_width, m_height;
00251         double m_lastx, m_lasty;
00252         bool m_bEmbedded;
00253         GtkUIManager *m_UIManager;
00254         bool m_Dragging;
00255         gcu::Object *m_CurObject;
00256 
00260 GCU_RO_PROP (double, BaseLineOffset)
00264 GCU_RO_PROP (GnomeCanvasPango*, ActiveRichText)
00265 };
00266 
00267 bool on_event (GnomeCanvasItem *item, GdkEvent *event, GtkWidget* widget);
00268 void on_receive (GtkClipboard *clipboard, GtkSelectionData *selection_data, View * pView);
00269 
00270 }       //      namespace gcp
00271 
00272 #endif // GCHEMPAINT_VIEW_H

Generated on Mon Aug 25 17:46:34 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6