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);
00088         void AddObject (gcu::Object const *pObject);
00094         void Update (gcu::Object const *pObject);
00100         GtkWidget* CreateNewWidget ();
00106         void OnDestroy (GtkWidget* widget);
00114         GnomeCanvasItem* GetCanvasItem (GtkWidget* widget, gcu::Object* object);
00118         GnomeCanvasItem* GetBackground ();
00122         double GetZoomFactor ();
00126         void UpdateFont ();
00132         void Remove (gcu::Object* pObject);
00136         PangoContext* GetPangoContext () {return m_PangoContext;}
00140         double GetFontHeight () {return m_dFontHeight;}
00144         gchar* GetFontName () {return m_sFontName;}
00148         gchar* GetSmallFontName () {return m_sSmallFontName;}
00152         PangoFontDescription* GetPangoFontDesc () {return m_PangoFontDesc;}
00156         PangoFontDescription* GetPangoSmallFontDesc () {return m_PangoSmallFontDesc;}
00162         void OnDeleteSelection (GtkWidget* w);
00169         void OnCopySelection (GtkWidget* w, GtkClipboard* clipboard);
00176         void OnPasteSelection (GtkWidget* w, GtkClipboard* clipboard);
00183         void OnCutSelection (GtkWidget* w, GtkClipboard* clipboard);
00191         bool OnKeyPress (GtkWidget* w, GdkEventKey* event);
00199         bool OnKeyRelease (GtkWidget* w, GdkEventKey* event);
00208         bool OnSize (GtkWidget *w, int width, int height);
00218         void UpdateSize (double x1, double y1, double x2, double y2);
00225         void SetGnomeCanvasPangoActive (GnomeCanvasPango* item);
00232         bool PrepareUnselect ();
00239         void OnReceive (GtkClipboard* clipboard, GtkSelectionData* selection_data);
00243         void OnSelectAll ();
00247         bool IsEmbedded () {return m_bEmbedded;}
00251         int GetNbWidgets () {return m_Widgets.size ();}
00262         void ExportImage (std::string const &filename, const char* type, int resolution = -1);
00266         xmlDocPtr BuildSVG ();
00274         GdkPixbuf *BuildPixbuf (int resolution);
00279         void EnsureSize ();
00285         void Zoom (double zoom);
00291         void ShowCursor (bool show);
00295         void UpdateTheme ();
00301         void Render (cairo_t *cr);
00302 
00303         //Implementation
00304 private:
00305         WidgetData* m_pData;
00306         Document* m_pDoc;
00307         GtkWidget* m_pWidget;
00308         std::list<GtkWidget*> m_Widgets;
00309         PangoContext* m_PangoContext;
00310         PangoFontDescription* m_PangoFontDesc, *m_PangoSmallFontDesc;
00311         double m_dFontHeight;
00312         gchar* m_sFontName, *m_sSmallFontName;
00313         int m_width, m_height;
00314         double m_lastx, m_lasty;
00315         bool m_bEmbedded;
00316         GtkUIManager *m_UIManager;
00317         bool m_Dragging;
00318         gcu::Object *m_CurObject;
00319 
00323 GCU_RO_PROP (double, BaseLineOffset)
00327 GCU_RO_PROP (GnomeCanvasPango*, ActiveRichText)
00328 };
00329 
00338 bool on_event (GnomeCanvasItem *item, GdkEvent *event, GtkWidget* widget);
00346 void on_receive (GtkClipboard *clipboard, GtkSelectionData *selection_data, View * pView);
00347 
00348 }       //      namespace gcp
00349 
00350 #endif // GCHEMPAINT_VIEW_H

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