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

Generated on Thu Dec 20 11:20:46 2007 for The Gnome Chemistry Utils by  doxygen 1.5.4