⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 html.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 4 页
字号:
/* * =========================================================================== * PRODUCTION $Log: html.hpp,v $ * PRODUCTION Revision 1000.5  2004/06/01 19:15:12  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.75 * PRODUCTION * =========================================================================== */#ifndef HTML___HTML__HPP#define HTML___HTML__HPP/*  $Id: html.hpp,v 1000.5 2004/06/01 19:15:12 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Author:  Lewis Geer * *//// @file html.hpp /// HTML classes.////// Defines classes to generate HTML code.#include <corelib/ncbiobj.hpp>#include <html/node.hpp>#include <html/jsmenu.hpp>#include <html/htmlhelper.hpp>/** @addtogroup HTMLcomp * * @{ */BEGIN_NCBI_SCOPE/// Macro for declare html elements.#define CHTML_NAME(Tag) NCBI_NAME2(CHTML_, Tag)#define DECLARE_HTML_ELEMENT_CONSTRUCTORS(Tag, Parent) \    CHTML_NAME(Tag)(void) \        : CParent(sm_TagName) \        { } \    CHTML_NAME(Tag)(const char* text) \        : CParent(sm_TagName, text) \        { } \    CHTML_NAME(Tag)(const string& text) \        : CParent(sm_TagName, text) \        { } \    CHTML_NAME(Tag)(CNCBINode* node) \        : CParent(sm_TagName, node) \        { } \    ~CHTML_NAME(Tag)(void)#define DECLARE_HTML_ELEMENT_CONSTRUCTORS_WITH_INIT(Tag, Parent) \    CHTML_NAME(Tag)(void) \        : CParent(sm_TagName) \        { Init(); } \    CHTML_NAME(Tag)(const char* text) \        : CParent(sm_TagName, text) \        { Init(); } \    CHTML_NAME(Tag)(const string& text) \        : CParent(sm_TagName, text) \        { Init(); } \    CHTML_NAME(Tag)(CNCBINode* node) \        : CParent(sm_TagName, node) \        { Init(); } \    ~CHTML_NAME(Tag)(void)#define DECLARE_HTML_ELEMENT_TYPES(Parent) \    typedef Parent CParent; \    static const char sm_TagName[]#define DECLARE_HTML_ELEMENT_COMMON(Tag, Parent) \    DECLARE_HTML_ELEMENT_TYPES(Parent); \public: \    DECLARE_HTML_ELEMENT_CONSTRUCTORS(Tag, Parent)#define DECLARE_HTML_ELEMENT_COMMON_WITH_INIT(Tag, Parent) \    DECLARE_HTML_ELEMENT_TYPES(Parent); \public: \    DECLARE_HTML_ELEMENT_CONSTRUCTORS_WITH_INIT(Tag, Parent)#define DECLARE_HTML_ELEMENT(Tag, Parent) \class NCBI_XHTML_EXPORT CHTML_NAME(Tag) : public Parent \{ \    DECLARE_HTML_ELEMENT_COMMON(Tag, Parent); \}// Macro for declare special chars.#define DECLARE_HTML_SPECIAL_CHAR(Tag, plain) \class NCBI_XHTML_EXPORT CHTML_NAME(Tag) : public CHTMLSpecialChar \{ \    typedef CHTMLSpecialChar CParent; \public: \    CHTML_NAME(Tag)(int count = 1) \        : CParent(#Tag, plain, count) \        { } \    ~CHTML_NAME(Tag)(void) { }; \}// Event tag handler type.//// NOTE: Availability of realization event-handlers for some tags//       stand on from browser's type! Set of event-handlers for tags can //       fluctuate in different browsers.enum EHTML_EH_Attribute {    //                    work with next HTML-tags (tag's group):    eHTML_EH_Blur,        //   select, text, textarea    eHTML_EH_Change,      //   select, text, textarea     eHTML_EH_Click,       //   button, checkbox, radio, link, reset, submit    eHTML_EH_DblClick,    //       eHTML_EH_Focus,       //   select, text, textarea      eHTML_EH_Load,        //   body, frameset    eHTML_EH_Unload,      //   body, frameset    eHTML_EH_MouseDown,   //    eHTML_EH_MouseUp,     //    eHTML_EH_MouseMove,   //    eHTML_EH_MouseOver,   //    eHTML_EH_MouseOut,    //    eHTML_EH_Select,      //   text, textarea    eHTML_EH_Submit,      //   form      eHTML_EH_KeyDown,     //    eHTML_EH_KeyPress,    //    eHTML_EH_KeyUp        //};// Base class for html node.class NCBI_XHTML_EXPORT CHTMLNode : public CNCBINode{    typedef CNCBINode CParent;public:    CHTMLNode(void)    { }    CHTMLNode(const char* tagname)        : CParent(tagname)    { }    CHTMLNode(const char* tagname, const char* text)        : CParent(tagname)    {        AppendPlainText(text);    }    CHTMLNode(const char* tagname, const string& text)        : CParent(tagname)    {        AppendPlainText(text);    }    CHTMLNode(const char* tagname, CNCBINode* node)        : CParent(tagname)    {        AppendChild(node);    }    CHTMLNode(const string& tagname)        : CParent(tagname)    { }    CHTMLNode(const string& tagname, const char* text)        : CParent(tagname)    {        AppendPlainText(text);    }    CHTMLNode(const string& tagname, const string& text)        : CParent(tagname)    {        AppendPlainText(text);    }    CHTMLNode(const string& tagname, CNCBINode* node)        : CParent(tagname)    {        AppendChild(node);    }    ~CHTMLNode(void);    // Convenient way to set some common attributes.    CHTMLNode* SetClass(const string& class_name);    CHTMLNode* SetStyle(const string& style);    CHTMLNode* SetId(const string& id);    CHTMLNode* SetWidth(int width);    CHTMLNode* SetWidth(const string& width);    CHTMLNode* SetHeight(int height);    CHTMLNode* SetHeight(const string& width);    CHTMLNode* SetSize(int size);    CHTMLNode* SetAlign(const string& align);    CHTMLNode* SetVAlign(const string& align);    CHTMLNode* SetBgColor(const string& color);    CHTMLNode* SetColor(const string& color);    CHTMLNode* SetNameAttribute(const string& name);    const string& GetNameAttribute(void) const;    CHTMLNode* SetTitle(const string& title);    CHTMLNode* SetAccessKey(char key);    // Convenient way to add CHTMLPlainText or CHTMLText.    void AppendPlainText(const char* text, bool noEncode = false);    void AppendPlainText(const string& text, bool noEncode = false);    void AppendHTMLText (const char* text);    void AppendHTMLText (const string& text);    // Get event handler name.    string GetEventHandlerName(const EHTML_EH_Attribute event) const;    // Set tag event handler.    void SetEventHandler(const EHTML_EH_Attribute event, const string& value);    // Attach the specified popup menu to HTML node.    // Popup menu will be shown when the "event" occurs.    // NOTES:    //   2) For eKurdin menu type the parameter "event" cannot be an    //      eHTML_EH_MouseOut, because it is used to hide the menu.    //   3) For eKurdinSide menu type the event parameters are not used.    void AttachPopupMenu(const CHTMLPopupMenu*  menu,                         EHTML_EH_Attribute     event = eHTML_EH_MouseOver);};// <@XXX@> mapping node.class NCBI_XHTML_EXPORT CHTMLTagNode : public CNCBINode{    typedef CNCBINode CParent;public:    CHTMLTagNode(const char* tag);    CHTMLTagNode(const string& tag);    ~CHTMLTagNode(void);    virtual CNcbiOstream& PrintChildren(CNcbiOstream& out, TMode mode);};// Dual print node.class NCBI_XHTML_EXPORT CHTMLDualNode : public CNCBINode{    typedef CNCBINode CParent;public:    CHTMLDualNode(const char* html, const char* plain);    CHTMLDualNode(CNCBINode* child, const char* plain);    ~CHTMLDualNode(void);    virtual CNcbiOstream& PrintChildren(CNcbiOstream& out, TMode mode);protected:    string m_Plain;};// A text node that contains plain text.class NCBI_XHTML_EXPORT CHTMLPlainText : public CNCBINode{    typedef CNCBINode CParent;public:    CHTMLPlainText(const char* text, bool noEncode = false);    CHTMLPlainText(const string& text, bool noEncode = false);    ~CHTMLPlainText(void);        const string& GetText(void) const;    void SetText(const string& text);    bool NoEncode(void) const    {        return m_NoEncode;    }    void SetNoEncode(bool noEncode = true)    {        m_NoEncode = noEncode;    }    virtual CNcbiOstream& PrintBegin(CNcbiOstream& out, TMode mode);private:    bool   m_NoEncode;    string m_Text;};// A text node that contains html text with tags and possibly <@TAG@>.class NCBI_XHTML_EXPORT CHTMLText : public CNCBINode{    typedef CNCBINode CParent;public:    CHTMLText(const char* text);    CHTMLText(const string& text);    ~CHTMLText(void);        const string& GetText(void) const;    void SetText(const string& text);    virtual CNcbiOstream& PrintBegin(CNcbiOstream& out, TMode mode);private:    CNcbiOstream& x_PrintBegin(CNcbiOstream& out, TMode mode,                               const string& s) const;private:    string m_Text;};// HTML tag base class.class NCBI_XHTML_EXPORT CHTMLOpenElement: public CHTMLNode{    typedef CHTMLNode CParent;public:    CHTMLOpenElement(const char* tagname)        : CParent(tagname), m_NoWrap(false)    { }    CHTMLOpenElement(const char* tagname, const char* text)        : CParent(tagname, text), m_NoWrap(false)    { }    CHTMLOpenElement(const char* tagname, const string& text)        : CParent(tagname, text), m_NoWrap(false)    { }    CHTMLOpenElement(const char* tagname, CNCBINode* node)        : CParent(tagname, node), m_NoWrap(false)    { }    CHTMLOpenElement(const string& tagname)        : CParent(tagname), m_NoWrap(false)    { }    CHTMLOpenElement(const string& tagname, const char* text)        : CParent(tagname, text), m_NoWrap(false)    { }    CHTMLOpenElement(const string& tagname, const string& text)        : CParent(tagname, text), m_NoWrap(false)    { }    CHTMLOpenElement(const string& tagname, CNCBINode* node)        : CParent(tagname, node), m_NoWrap(false)    { }    ~CHTMLOpenElement(void);    // Print tag itself.    virtual CNcbiOstream& PrintBegin(CNcbiOstream &, TMode mode);    // Set NOWRAP attribute (NOTE: it is depricated in HTML 4.0)    virtual void SetNoWrap(bool noWrap = true)        { m_NoWrap = noWrap; }protected:    bool m_NoWrap;};// HTML inline tagclass NCBI_XHTML_EXPORT CHTMLInlineElement: public CHTMLOpenElement{    typedef CHTMLOpenElement CParent;public:    CHTMLInlineElement(const char* tagname)        : CParent(tagname)    { }    CHTMLInlineElement(const char* tagname, const char* text)        : CParent(tagname, text)    { }    CHTMLInlineElement(const char* tagname, const string& text)        : CParent(tagname, text)    { }    CHTMLInlineElement(const char* tagname, CNCBINode* node)        : CParent(tagname, node)    { }    CHTMLInlineElement(const string& tagname)        : CParent(tagname)    { }    CHTMLInlineElement(const string& tagname, const char* text)        : CParent(tagname, text)    { }    CHTMLInlineElement(const string& tagname, const string& text)        : CParent(tagname, text)    { }    CHTMLInlineElement(const string& tagname, CNCBINode* node)        : CParent(tagname, node)    { }    ~CHTMLInlineElement(void);    // Print tag close.    virtual CNcbiOstream& PrintEnd(CNcbiOstream &, TMode mode);   };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -