// -*- C++ -*- /* * GChemPaint library * document.h * * Copyright (C) 2001-2007 Jean Bréfort * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifndef GCHEMPAINT_DOCUMENT_H #define GCHEMPAINT_DOCUMENT_H #include #include #include #include #include #include #include #include #include #include "atom.h" #include "fragment.h" #include "bond.h" #include "molecule.h" #include "operation.h" namespace OpenBabel { class OBMol; } using namespace OpenBabel; using namespace std; extern SignalId OnChangedSignal; extern SignalId OnDeleteSignal; extern SignalId OnThemeChangedSignal; class gcpView; class gcpApplication; class gcpWindow; class gcpTheme; class gcpDocument: public Document { //Constructor and destructor public: gcpDocument(gcpApplication *App, bool StandAlone, gcpWindow *window = NULL); virtual ~gcpDocument(); //Interface public: GtkWidget* GetWidget(); gcpView* GetView() {return m_pView;} void BuildBondList(list& BondList, Object* obj); bool ImportOB(OBMol& Mol); void ExportOB(); void BuildAtomTable(map& AtomTable, Object* obj, unsigned& index); void Save(); virtual bool Load(xmlNodePtr); const gchar* GetTitle(); void SetTitle(const gchar* title); void SetLabel(const gchar* label); const gchar* GetLabel(); void SetFileName (string const &, const gchar *mime_type); const gchar* GetFileName() {return m_filename;} void Print(GnomePrintContext *pc, gdouble width, gdouble height); void AddObject(Object* pObject); void AddAtom(gcpAtom* pAtom); void AddFragment(gcpFragment* pFragment); void AddBond(gcpBond* pBond); void ParseXMLTree(xmlDocPtr xml); void LoadObjects(xmlNodePtr node); xmlDocPtr BuildXMLTree(); void NotifyDirty (gcpBond* pBond) {m_DirtyObjects.insert (pBond);} void Update(); void Remove(Object*); void Remove(const char* Id); void OnProperties(); void OnUndo(); void OnRedo(); const GDate* GetCreationDate() {return &CreationDate;} const GDate* GetRevisionDate() {return &RevisionDate;} const gchar* GetAuthor() {return m_author;} const gchar* GetMail() {return m_mail;} const gchar* GetComment() {return m_comment;} void SetAuthor(const gchar* author); void SetMail(const gchar* mail); void SetComment(const gchar* comment); void FinishOperation(); void AbortOperation(); void PopOperation(); void PushOperation(gcpOperation* operation, bool undo = true); void SetActive(); gcpOperation* GetNewOperation(gcpOperationType type); gcpOperation* GetCurrentOperation () {return m_pCurOp;} void AddData(xmlNodePtr node); bool CanUndo() {return m_UndoList.size() > 0;} void SetEditable(bool editable) {m_bWriteable = editable; m_bUndoRedo = true;} bool GetEditable() {return m_bWriteable;} gcpApplication* GetApplication() {return m_pApp;} void ExportImage (string const &filename, const char* type, int resolution = -1); void SetReadOnly (bool ro); bool GetReadOnly () {return m_bReadOnly;} virtual double GetYAlign (); gcpWindow *GetWindow () {return m_Window;} void SetTheme (gcpTheme *theme); bool OnSignal (SignalId Signal, Object *Child); void SetDirty (bool isDirty = true); void OnThemeNamesChanged (); double GetMedianBondLength (); private: void RemoveAtom(gcpAtom* pAtom); void RemoveBond(gcpBond* pBond); void RemoveFragment(gcpFragment* pFragment); //Implementation private: gcpView * m_pView; gchar* m_filename; gchar *m_title; gchar *m_label; gchar *m_comment, *m_author, *m_mail; setm_DirtyObjects; bool m_bIsLoading, m_bUndoRedo, m_bReadOnly; string m_FileType; bool m_bWriteable; GDate CreationDate, RevisionDate; list m_UndoList, m_RedoList; gcpOperation* m_pCurOp; gcpApplication* m_pApp; gcpWindow *m_Window; unsigned long m_OpID; // last operation ID unsigned m_LastStackSize; // undo list size when last saved /* Theme is not really a read only property, but we provide a special Set method */ GCU_RO_PROP (gcpTheme*, Theme) GCU_PROP (double, BondLength) GCU_PROP (double, BondAngle) GCU_PROP (double, ArrowLength) GCU_PROP (gchar*, TextFontFamily) GCU_PROP (PangoStyle, TextFontStyle) GCU_PROP (PangoWeight, TextFontWeight) GCU_PROP (PangoVariant, TextFontVariant) GCU_PROP (PangoStretch, TextFontStretch) GCU_PROP (gint, TextFontSize) GCU_RO_PROP (PangoAttrList*, PangoAttrList) }; extern list Docs; extern bool bCloseAll; #endif // GCHEMPAINT_DOCUMENT_H