view.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00068 View (Document *pDoc, bool Embedded);
00072 virtual ~View ();
00073
00074
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
00280
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
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 }
00337
00338 #endif // GCHEMPAINT_VIEW_H