X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7463f75f9c170c29b4965d27dccf535ac32cfde..b271d60d6a009930d80092a8cb534a5df19fc99b:/utils/configtool/src/configtooldoc.h diff --git a/utils/configtool/src/configtooldoc.h b/utils/configtool/src/configtooldoc.h index 72baa93f61..277dba3151 100644 --- a/utils/configtool/src/configtooldoc.h +++ b/utils/configtool/src/configtooldoc.h @@ -12,16 +12,13 @@ #ifndef _CT_CONFIGTOOLDOC_H_ #define _CT_CONFIGTOOLDOC_H_ -#ifdef __GNUG__ -#pragma interface "configtooldoc.cpp" -#endif - #include "wx/docview.h" #include "wx/cmdproc.h" #include "configitem.h" class wxSimpleHtmlTag; +class ctConfiguration; /*! * ctConfigToolDoc @@ -38,9 +35,9 @@ public: virtual bool OnCreate(const wxString& path, long flags); virtual bool OnOpenDocument(const wxString& filename); virtual bool OnSaveDocument(const wxString& filename); - virtual bool OnNewDocument() { return TRUE; } + virtual bool OnNewDocument() { return true; } virtual bool OnCloseDocument() ; - virtual bool Save(); // Overridden only to correct bug in wxWindows, docview.cpp + virtual bool Save(); // Overridden only to correct bug in wxWidgets, docview.cpp //// Accessors @@ -91,21 +88,156 @@ public: /// Generate the text of a setup.h wxString GenerateSetup(); - + /// Helper function void GenerateSetup(ctConfigItem* item, wxString& str); - + /// Generate a configure command wxString GenerateConfigureCommand(); /// Helper function void GenerateConfigureCommand(ctConfigItem* item, wxString& str); - + + /// Finds the next item in the tree + ctConfigItem* FindNextItem(ctConfigItem* item, bool wrap); + + /// Finds the next sibling in the tree + ctConfigItem* FindNextSibling(ctConfigItem* item); + protected: ctConfigItem* m_topItem; ctConfigItem* m_clipboardItem; }; +/*! + * ctConfiguration is a configuration or a place-holder node within the + * hierarchy of configurations. + */ + +class ctConfiguration: public wxObject +{ +public: + /// Ctor and dtor + ctConfiguration(ctConfiguration* parent, const wxString& name); + ctConfiguration(); + ~ctConfiguration(); + + /// Copy constructor. + ctConfiguration(const ctConfiguration& configuration) : wxObject() + { + (*this) = configuration; + } + +/// Operations + + /// Assignment operator. + void operator= (const ctConfiguration& configuration); + + /// Create a clone + ctConfiguration* Clone() + { + ctConfiguration* configuration = new ctConfiguration; + *configuration = *this; + return configuration; + } + + /// Create a clone of this and children + ctConfiguration* DeepClone(); + + /// Clear children + void Clear(); + + /// Add a child + void AddChild(ctConfiguration* config); + + /// Remove (but don't delete) a child + void RemoveChild(ctConfiguration* config); + + /// Find an item in this hierarchy + ctConfiguration* FindConfiguration(const wxString& name); + + /// Find the next sibling + ctConfiguration* FindNextSibling(); + + /// Find the previous sibling + ctConfiguration* FindPreviousSibling(); + + /// Detach: remove from parent, and remove tree items + void Detach(); + + /// Attach: insert before the given position + void Attach(ctConfiguration* parent, ctConfiguration* insertbefore); + + void DetachFromTree(); + +/// Accessors + + /// Returns the top-level item. + ctConfigItem* GetTopItem() const { return m_topItem; } + + /// Sets the top-level item. + void SetTopItem(ctConfigItem* item) { m_topItem = item; } + + /// Returns the name. + wxString GetName() const { return m_name; } + + /// Sets the name. + void SetName(const wxString& name ) { m_name = name; } + + /// Get description. + wxString GetDescription() const { return m_description; } + + /// Set description. + void SetDescription(const wxString& descr) { m_description = descr; } + + /// Set the tree item id + void SetTreeItem(wxTreeItemId id) { m_treeItemId = id; } + + // Get the type + wxTreeItemId GetTreeItemId() const { return m_treeItemId ; } + + /// Get the list of children + wxList& GetChildren() { return m_children; } + + /// Get the nth child + ctConfiguration* GetChild(int n) const; + + /// Get the child count + int GetChildCount() const; + + /// Get the parent + ctConfiguration* GetParent() const { return m_parent; } + + /// Set the parent + void SetParent(ctConfiguration* parent) { m_parent = parent; } + + /// Get the associated document (currently, assumes + /// there's only ever one document active) + ctConfigToolDoc* GetDocument() ; + +protected: + + /// The corresponding tree item + wxTreeItemId m_treeItemId; + + /// The list of children. + wxList m_children; + + /// The parent config item + ctConfiguration* m_parent; + + /// The name + wxString m_name; + + /// The description + wxString m_description; + + /// The top-level item of this description, if any + ctConfigItem* m_topItem; + +DECLARE_CLASS(ctConfiguration) +}; + /*! * Implements a document editing command. @@ -124,16 +256,16 @@ public: ctConfigCommand(const wxString& name, int cmdId, ctConfigItem* activeState, ctConfigItem* savedState, ctConfigItem* parent = NULL, ctConfigItem* insertBefore = NULL, - bool ignoreFirstTime = FALSE); + bool ignoreFirstTime = false); ctConfigCommand(const wxString& name, int cmdId, ctConfigItem* activeState, ctProperties* properties, - bool ignoreFirstTime = FALSE); + bool ignoreFirstTime = false); ~ctConfigCommand(); bool Do(); bool Undo(); bool DoAndUndo(bool doCmd); // Combine Do and Undo into one - + protected: ctConfigItem* m_activeState; ctConfigItem* m_savedState;