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 <gcu/macros.h>
00029 #include <gccv/client.h>
00030 #include <list>
00031 #include <map>
00032 
00033 namespace gccv {
00034         class Canvas;
00035         class Text;
00036 }
00037 
00038 namespace gcu {
00039         class Object;
00040 };
00041 
00042 namespace gcp {
00043 
00044 class Atom;
00045 class Bond;
00046 class Document;
00047 class WidgetData;
00048 
00049 #define GCHEMPAINT_ATOM_NAME "application/x-gchempaint"
00050 extern GtkTargetEntry const targets[];
00051 
00055 class View: public gccv::Client
00056 {
00057 public:
00058         //Constructor and destructor
00066         View (Document *pDoc, bool Embedded);
00070         virtual ~View ();
00071 
00072         //Interface     
00073 public:
00077         GtkWidget* GetWidget () {return m_pWidget;}
00081         Document* GetDoc () {return m_pDoc;}
00087         void AddObject (gcu::Object *pObject);
00093         void Update (gcu::Object *pObject);
00099         GtkWidget* CreateNewWidget ();
00105         void OnDestroy (GtkWidget* widget);
00109         double GetZoomFactor ();
00113         void UpdateFont ();
00119         void Remove (gcu::Object* pObject);
00123         double GetFontHeight () {return m_dFontHeight;}
00127         gchar* GetFontName () {return m_sFontName;}
00131         gchar* GetSmallFontName () {return m_sSmallFontName;}
00135         PangoFontDescription* GetPangoFontDesc () {return m_PangoFontDesc;}
00139         PangoFontDescription* GetPangoSmallFontDesc () {return m_PangoSmallFontDesc;}
00145         void OnDeleteSelection (GtkWidget* w);
00152         void OnCopySelection (GtkWidget* w, GtkClipboard* clipboard);
00159         void OnPasteSelection (GtkWidget* w, GtkClipboard* clipboard);
00166         void OnCutSelection (GtkWidget* w, GtkClipboard* clipboard);
00174         bool OnKeyPress (GtkWidget* w, GdkEventKey* event);
00182         bool OnKeyRelease (GtkWidget* w, GdkEventKey* event);
00189         void SetTextActive (gccv::Text* item);
00196         bool PrepareUnselect ();
00203         void OnReceive (GtkClipboard* clipboard, GtkSelectionData* selection_data);
00207         void OnSelectAll ();
00211         bool IsEmbedded () {return m_bEmbedded;}
00215         int GetNbWidgets () {return m_Widgets.size ();}
00226         void ExportImage (std::string const &filename, const char* type, int resolution = -1);
00230         char *BuildSVG ();
00234         char *BuildEPS ();
00242         GdkPixbuf *BuildPixbuf (int resolution);
00247         void EnsureSize ();
00253         void Zoom (double zoom);
00259         void ShowCursor (bool show);
00263         void UpdateTheme ();
00269         void Render (cairo_t *cr);
00276         void SetSelectionState (gcu::Object *object, int state);
00277         // Signals
00278         bool OnButtonPressed (gccv::ItemClient *client, unsigned button, double x, double y, unsigned state);
00279         bool OnButtonReleased (gccv::ItemClient *client, unsigned button, double x, double y, unsigned state);
00280         bool OnDrag (gccv::ItemClient *client, double x, double y, unsigned state);
00281         bool OnMotion (gccv::ItemClient *client, double x, double y, unsigned state);
00282 
00283         WidgetData *GetData () {return m_pData;}
00284         //Implementation
00285 private:
00286         WidgetData* m_pData;
00287         Document* m_pDoc;
00288         GtkWidget* m_pWidget;
00289         std::list<GtkWidget*> m_Widgets;
00290         PangoFontDescription* m_PangoFontDesc, *m_PangoSmallFontDesc;
00291         double m_dFontHeight;
00292         gchar* m_sFontName, *m_sSmallFontName;
00293         int m_width, m_height;
00294         double m_lastx, m_lasty;
00295         bool m_bEmbedded;
00296         GtkUIManager *m_UIManager;
00297         bool m_Dragging;
00298         gcu::Object *m_CurObject;
00299         
00300 
00304 GCU_RO_PROP (double, BaseLineOffset)
00308 GCU_RO_PROP (gccv::Text *, ActiveRichText)
00312 GCU_RO_PROP (double, CHeight)
00316 GCU_RO_PROP (double, HWidth)
00317 };
00318 
00326 void on_receive (GtkClipboard *clipboard, GtkSelectionData *selection_data, View * pView);
00327 
00328 }       //      namespace gcp
00329 
00330 #endif // GCHEMPAINT_VIEW_H

Generated on Wed Dec 17 13:43:18 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6