view.h

Go to the documentation of this file.
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 
00030 #include <gcu/macros.h>
00031 #include <gccv/client.h>
00032 #include <list>
00033 #include <map>
00034 
00035 namespace gccv {
00036         class Canvas;
00037         class Text;
00038 }
00039 
00040 namespace gcu {
00041         class Object;
00042 };
00043 
00044 namespace gcp {
00045 
00046 class Atom;
00047 class Bond;
00048 class Document;
00049 class WidgetData;
00050 
00051 #define GCHEMPAINT_ATOM_NAME "application/x-gchempaint"
00052 extern GtkTargetEntry const targets[];
00053 
00057 class View: public gccv::Client
00058 {
00059 public:
00060         //Constructor and destructor
00068         View (Document *pDoc, bool Embedded);
00072         virtual ~View ();
00073 
00074         //Interface     
00075 public:
00079         GtkWidget* GetWidget () {return m_pWidget;}
00083         Document* GetDoc () {return m_pDoc;}
00089         void AddObject (gcu::Object *pObject);
00095         void Update (gcu::Object *pObject);
00101         GtkWidget* CreateNewWidget ();
00107         void OnDestroy (GtkWidget* widget);
00111         double GetZoomFactor ();
00115         void UpdateFont ();
00121         void Remove (gcu::Object* pObject);
00125         double GetFontHeight () {return m_dFontHeight;}
00129         gchar* GetFontName () {return m_sFontName;}
00133         gchar* GetSmallFontName () {return m_sSmallFontName;}
00137         PangoFontDescription* GetPangoFontDesc () {return m_PangoFontDesc;}
00141         PangoFontDescription* GetPangoSmallFontDesc () {return m_PangoSmallFontDesc;}
00147         void OnDeleteSelection (GtkWidget* w);
00154         void OnCopySelection (GtkWidget* w, GtkClipboard* clipboard);
00161         void OnPasteSelection (GtkWidget* w, GtkClipboard* clipboard);
00168         void OnCutSelection (GtkWidget* w, GtkClipboard* clipboard);
00176         bool OnKeyPress (GtkWidget* w, GdkEventKey* event);
00184         bool OnKeyRelease (GtkWidget* w, GdkEventKey* event);
00191         void SetTextActive (gccv::Text* item);
00198         bool PrepareUnselect ();
00205         void OnReceive (GtkClipboard* clipboard, GtkSelectionData* selection_data);
00209         void OnSelectAll ();
00213         bool IsEmbedded () {return m_bEmbedded;}
00217         int GetNbWidgets () {return m_Widgets.size ();}
00228         void ExportImage (std::string const &filename, const char* type, int resolution = -1);
00232         char *BuildSVG ();
00236         char *BuildEPS ();
00244         GdkPixbuf *BuildPixbuf (int resolution);
00249         void EnsureSize ();
00255         void Zoom (double zoom);
00261         void ShowCursor (bool show);
00265         void UpdateTheme ();
00271         void Render (cairo_t *cr);
00278         void SetSelectionState (gcu::Object *object, int state);
00279         // Signals
00280         // there is no needd to document these since the documentation in gccv/client.h is appropriate.
00281         bool OnButtonPressed (gccv::ItemClient *client, unsigned button, double x, double y, unsigned state);
00282         bool OnButtonReleased (gccv::ItemClient *client, unsigned button, double x, double y, unsigned state);
00283         bool OnDrag (gccv::ItemClient *client, double x, double y, unsigned state);
00284         bool OnMotion (gccv::ItemClient *client, double x, double y, unsigned state);
00285         bool OnLeaveNotify (unsigned state);
00286 
00290         WidgetData *GetData () {return m_pData;}
00291         //Implementation
00292 private:
00293         WidgetData* m_pData;
00294         Document* m_pDoc;
00295         GtkWidget* m_pWidget;
00296         std::list<GtkWidget*> m_Widgets;
00297         PangoFontDescription* m_PangoFontDesc, *m_PangoSmallFontDesc;
00298         double m_dFontHeight;
00299         gchar* m_sFontName, *m_sSmallFontName;
00300         int m_width, m_height;
00301         double m_lastx, m_lasty;
00302         bool m_bEmbedded;
00303         GtkUIManager *m_UIManager;
00304         bool m_Dragging;
00305         gcu::Object *m_CurObject;
00306         Atom *m_CurAtom;
00307         
00308 
00312 GCU_RO_PROP (double, BaseLineOffset)
00316 GCU_RO_PROP (gccv::Text *, ActiveRichText)
00320 GCU_RO_PROP (double, CHeight)
00324 GCU_RO_PROP (double, HWidth)
00325 };
00326 
00334 void on_receive (GtkClipboard *clipboard, GtkSelectionData *selection_data, View * pView);
00335 
00336 }       //      namespace gcp
00337 
00338 #endif // GCHEMPAINT_VIEW_H

Generated on Fri Sep 24 15:58:42 2010 for The Gnome Chemistry Utils by  doxygen 1.5.9