The Gnome Chemistry Utils  0.13.6
gcp/brackets.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /*
00004  * GChemPaint library
00005  * brackets.h
00006  *
00007  * Copyright (C) 2010-2011 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_BRACKETS_H
00026 #define GCHEMPAINT_BRACKETS_H
00027 
00028 #include <gcu/object.h>
00029 #include <gccv/item-client.h>
00030 #include <gccv/brackets.h>
00031 #include <set>
00032 
00034 namespace gcp {
00035 
00036 extern gcu::TypeId BracketsType;
00037 
00038 typedef enum {
00039         BracketContentInvalid,
00040         BracketContentFragment,
00041         BracketContentMolecule,
00042         BracketContentGroup
00043 } BracketContent;
00044 
00045 typedef enum {
00046         BracketDecorationNone = 0,
00047         BracketSubscript = 1,
00048         BracketSuperscript = 2
00049 } BracketsDecorations;
00050 
00053 class Brackets: public gcu::Object, public gccv::ItemClient
00054 {
00055 public:
00059         Brackets (gccv::BracketsTypes type = gccv::BracketsTypeNormal);
00063         virtual ~Brackets();
00064 
00065 
00069         void AddItem ();
00070 
00078         bool Load (xmlNodePtr node);
00084         xmlNodePtr Save (xmlDocPtr xml) const;
00092         void SetSelected (int state);
00096         void OnLoaded ();
00097 
00104         void OnUnlink (Object *object);
00113         bool BuildContextualMenu (gcu::UIManager *UIManager, Object *object, double x, double y);
00114 
00115 
00116         void SetEmbeddedObjects (std::set < gcu::Object * > objects);
00117         std::set < gcu::Object * > const &GetEmbeddedObjects () {return m_EmbeddedObjects;}
00118         static bool ConnectedAtoms (std::set < gcu::Object * > const &objects);
00119 
00120 private:
00121         std::set < gcu::Object * > m_EmbeddedObjects;
00122         bool m_Valid;
00123         BracketContent m_Content;
00124 
00125 GCU_PROP (gccv::BracketsTypes, Type)
00126 GCU_PROP (gccv::BracketsUses, Used)
00127 GCU_RO_PROP (unsigned, Decorations)
00128 GCU_PROP (std::string, FontDesc)
00129 };
00130 
00131 }       //      namespace gcp
00132 
00133 #endif  //GCHEMPAINT_BRACKETS_H