diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h new file mode 100644 index 000000000..3d0b641fd --- /dev/null +++ b/code/nel/include/nel/gui/group_html.h @@ -0,0 +1,659 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_GROUP_HTML_H +#define CL_GROUP_HTML_H + +#define CURL_STATICLIB 1 +#include + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_scrolltext.h" +#include "nel/gui/group_tree.h" +#include "nel/gui/ctrl_button.h" +#include "nel/gui/group_table.h" + +typedef std::map TStyle; + +extern "C" +{ +#include "WWWInit.h" +} + +namespace NLGUI +{ + class CCtrlButton; + class CCtrlScroll; + class CGroupList; + class CDBGroupComboBox; + class CGroupParagraph; + + + + // HTML group + /** + * Widget to have a resizable scrolltext and its scrollbar + * \author Cyril 'Hulud' Corvazier + * \author Nevrax France + * \date 2002 + */ + class CGroupHTML : public CGroupScrollText + { + public: + friend void TextAdd (struct _HText *me, const char * buf, int len); + friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value); + friend void TextEndElement (_HText *me, int element_number); + friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value); + friend void TextBuild (HText * me, HTextStatus status); + friend void TextBeginUnparsedElement(HText *me, const char *buffer, int length); + friend void TextEndUnparsedElement(HText *me, const char *buffer, int length); + friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status); + + struct SWebOptions + { + public: + std::string appName; + std::string appVersion; + std::string languageCode; + std::vector< std::string > trustedDomains; + + SWebOptions() + { + } + }; + + static SWebOptions options; + + // Constructor + CGroupHTML(const TCtorParam ¶m); + ~CGroupHTML(); + + // CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void draw (); + + // Events + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + + // Browse + virtual void browse (const char *url); + + // Refresh + void refresh(); + + // submit form + void submitForm (uint formId, const char *submitButtonName); + + // Browse error + void browseError (const char *msg); + + // stop browse + void stopBrowse (); + + bool isBrowsing(); + + void clean() { stopBrowse(); updateRefreshButton(); removeContent(); } + + // Update coords + void updateCoords(); + + // New paragraph + void newParagraph(uint beginSpace); + + // End of the paragraph + void endParagraph(); + + // Timeout + void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);} + float getTimeout() const {return (float)_TimeoutValue;} + + // Some constants + NLMISC::CRGBA BgColor; + NLMISC::CRGBA ErrorColor; + NLMISC::CRGBA LinkColor; + NLMISC::CRGBA TextColor; + NLMISC::CRGBA H1Color; + NLMISC::CRGBA H2Color; + NLMISC::CRGBA H3Color; + NLMISC::CRGBA H4Color; + NLMISC::CRGBA H5Color; + NLMISC::CRGBA H6Color; + bool ErrorColorGlobalColor; + bool LinkColorGlobalColor; + bool TextColorGlobalColor; + bool H1ColorGlobalColor; + bool H2ColorGlobalColor; + bool H3ColorGlobalColor; + bool H4ColorGlobalColor; + bool H5ColorGlobalColor; + bool H6ColorGlobalColor; + uint TextFontSize; + uint H1FontSize; + uint H2FontSize; + uint H3FontSize; + uint H4FontSize; + uint H5FontSize; + uint H6FontSize; + uint TDBeginSpace; + uint PBeginSpace; + uint LIBeginSpace; + uint ULBeginSpace; + uint LIIndent; + uint ULIndent; + float LineSpaceFontFactor; + std::string DefaultButtonGroup; + std::string DefaultFormTextGroup; + std::string DefaultFormTextAreaGroup; + std::string DefaultFormSelectGroup; + std::string DefaultCheckBoxBitmapNormal; + std::string DefaultCheckBoxBitmapPushed; + std::string DefaultCheckBoxBitmapOver; + std::string DefaultBackgroundBitmapView; + std::string CurrentLinkTitle; + + // Browser home + std::string Home; + + // Undo browse: Browse the precedent url browsed. no op if none + void browseUndo (); + // Redo browse: Browse the precedent url undoed. no op if none + void browseRedo (); + // clear undo/redo + void clearUndoRedo(); + + + std::string getURL() const { return _URL; } + void setURL(const std::string &url); + + + int luaBrowse(CLuaState &ls); + int luaRefresh(CLuaState &ls); + int luaRemoveContent(CLuaState &ls); + int luaInsertText(CLuaState &ls); + int luaAddString(CLuaState &ls); + int luaAddImage(CLuaState &ls); + int luaBeginElement(CLuaState &ls); + int luaEndElement(CLuaState &ls); + int luaShowDiv(CLuaState &ls); + + REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) + REFLECT_LUA_METHOD("browse", luaBrowse) + REFLECT_LUA_METHOD("refresh", luaRefresh) + REFLECT_LUA_METHOD("removeContent", luaRemoveContent) + REFLECT_LUA_METHOD("insertText", luaInsertText) + REFLECT_LUA_METHOD("addString", luaAddString) + REFLECT_LUA_METHOD("addImage", luaAddImage) + REFLECT_LUA_METHOD("beginElement", luaBeginElement) + REFLECT_LUA_METHOD("endElement", luaEndElement) + REFLECT_LUA_METHOD("showDiv", luaShowDiv) + REFLECT_STRING("url", getURL, setURL) + REFLECT_FLOAT("timeout", getTimeout, setTimeout) + REFLECT_EXPORT_END + + protected : + + // \name callback from libwww + + // Begin of the parsing of a HTML document + virtual void beginBuild (); + + // End of the parsing of a HTML document + virtual void endBuild (); + + // A new text block has been parsed + virtual void addText (const char * buf, int len); + + // A link has been parsed + virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value); + + // A new begin HTML element has been parsed ( for exemple) + virtual void beginElement (uint element_number, const BOOL *present, const char **value); + + // A new end HTML element has been parsed ( for exemple) + virtual void endElement (uint element_number); + + // A new begin unparsed element has been found + virtual void beginUnparsedElement(const char *buffer, int length); + + // A new end unparsed element has been found + virtual void endUnparsedElement(const char *buffer, int length); + + // Add GET params to the url + virtual void addHTTPGetParams (std::string &url, bool trustedDomain); + + // Add POST params to the libwww list + virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain); + + // the current request is terminated + virtual void requestTerminated(HTRequest *request); + + // Get Home URL + virtual std::string home(); + + // Parse style html tag + TStyle parseStyle(const std::string &str_styles); + + // Handle some work at each pass + virtual void handle (); + + // \name internal methods + + // Add a group in the current parent group + void addGroup (CInterfaceGroup *group, uint beginSpace); + + // Get the current parent group + CInterfaceGroup *getCurrentGroup(); + + // Update current paragraph dependent data + void paragraphChange (); + + // Clear the contexts info + void clearContext(); + + // Translate a char + bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const; + + // Add a string in the current paragraph + void addString(const ucstring &str); + + // Add an image in the current paragraph + void addImage(const char *image, bool globalColor, bool reloadImg=false); + + // Add a text area in the current paragraph + CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content); + + // Add a combo box in the current paragraph + CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); + + // Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL. + CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap, + const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip); + + // Set the background color + void setBackgroundColor (const NLMISC::CRGBA &bgcolor); + + // Set the background + void setBackground (const std::string &bgtex, bool scale, bool tile); + + // Force the current string to be in a single string + void flushString(); + + // Set the title + void setTitle (const ucstring &title); + + // Lookup a url in local file system + bool lookupLocalFile (std::string &result, const char *url, bool isUrl); + + // Delete page content and prepare next page + void removeContent (); + + // Current URL + std::string _URL; + + // Current DOMAIN + bool _TrustedDomain; + + // Title prefix + ucstring _TitlePrefix; + + // Title string + ucstring _TitleString; + + // Need to browse next update coords.. + bool _BrowseNextTime; + bool _PostNextTime; + uint _PostFormId; + std::string _PostFormSubmitButton; + + // Browsing.. + bool _Browsing; + bool _Connecting; + double _TimeoutValue; // the timeout in seconds + double _ConnectingTimeout; + + // minimal embeded lua script support + // Note : any embeded script is executed immediately after the closing + // element has been found + // True when the element has been encountered + bool _ParsingLua; + bool _IgnoreText; + // the script to execute + std::string _LuaScript; + + bool _Object; + std::string _ObjectScript; + + // Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client. + static CGroupHTML *_ConnectingLock; + + // LibWWW data + class CLibWWWData *_LibWWW; + + // Current paragraph + std::string _DivName; + CGroupParagraph* _Paragraph; + inline CGroupParagraph *getParagraph() + { + return _Paragraph; + /*if (_Paragraph.empty()) + return NULL; + return _Paragraph.back();*/ + } + + // PRE mode + std::vector _PRE; + inline bool getPRE() const + { + if (_PRE.empty()) + return false; + return _PRE.back(); + } + + // UL mode + std::vector _UL; + inline bool getUL() const + { + if (_UL.empty()) + return false; + return _UL.back(); + } + + // A mode + std::vector _A; + inline bool getA() const + { + if (_A.empty()) + return false; + return _A.back(); + } + + // IL mode + bool _LI; + + // Current text color + std::vector _TextColor; + inline const NLMISC::CRGBA &getTextColor() const + { + if (_TextColor.empty()) + return TextColor; + return _TextColor.back(); + } + + // Current global color flag + std::vector _GlobalColor; + inline bool getGlobalColor() const + { + if (_GlobalColor.empty()) + return false; + return _GlobalColor.back(); + } + + // Current font size + std::vector _FontSize; + inline uint getFontSize() const + { + if (_FontSize.empty()) + return TextFontSize; + return _FontSize.back(); + } + + // Current link + std::vector _Link; + inline const char *getLink() const + { + if (_Link.empty()) + return ""; + return _Link.back().c_str(); + } + + std::vector _LinkTitle; + inline const char *getLinkTitle() const + { + if (_LinkTitle.empty()) + return ""; + return _LinkTitle.back().c_str(); + } + std::vector _LinkClass; + inline const char *getLinkClass() const + { + if (_LinkClass.empty()) + return ""; + return _LinkClass.back().c_str(); + } + + // Divs (i.e. interface group) + std::vector _Divs; + inline CInterfaceGroup *getDiv() const + { + if (_Divs.empty()) + return NULL; + return _Divs.back(); + } + + // Tables + std::vector _Tables; + inline CGroupTable *getTable() const + { + if (_Tables.empty()) + return NULL; + return _Tables.back(); + } + + // Cells + std::vector _Cells; + + // TR + std::vector _TR; + inline bool getTR() const + { + if (_TR.empty()) + return false; + return _TR.back(); + } + + // Forms + class CForm + { + public: + + class CEntry + { + public: + CEntry () + { + TextArea = NULL; + Checkbox = NULL; + ComboBox = NULL; + InitialSelection = 0; + } + + // Variable name + std::string Name; + + // Variable value + ucstring Value; + + // Text area group + CInterfaceGroup *TextArea; + + // Checkbox + CCtrlButton *Checkbox; + + // Combobox group + CDBGroupComboBox *ComboBox; + + // select values (for the tag) - std::vector SelectValues; - sint InitialSelection; // initial selection for the combo box - }; - - // The action the form has to perform - std::string Action; - - // The text area associated with the form - std::vector Entries; - }; - std::vector _Forms; - std::vector _Groups; - - // Cells parameters - class CCellParams - { - public: - CCellParams () : BgColor(0,0,0,0) - { - Align = CGroupCell::Left; - VAlign = CGroupCell::Top; - LeftMargin = 0; - NoWrap = false; - } - NLMISC::CRGBA BgColor; - std::string Style; - CGroupCell::TAlign Align; - CGroupCell::TVAlign VAlign; - sint32 LeftMargin; - bool NoWrap; - }; - std::vector _CellParams; - - // Indentation - uint _Indent; - - // Current node is a title - bool _Title; - - // Current node must be localized - bool _Localize; - - // Current node is a text area - bool _TextArea; - std::string _TextAreaTemplate; - ucstring _TextAreaContent; - std::string _TextAreaName; - uint _TextAreaRow; - uint _TextAreaCols; - - // current mode is in select option - bool _SelectOption; - ucstring _SelectOptionStr; - - // Current node is a object - std::string _ObjectType; - std::string _ObjectData; - std::string _ObjectMD5Sum; - std::string _ObjectAction; - std::string _TextAreaScript; - - // Get last char - ucchar getLastChar() const; - - // Current link view - class CViewLink *_CurrentViewLink; - class CViewBitmap *_CurrentViewImage; - - // Current group table - class CGroupCell *_CurrentCell; - - // The main group - class CGroupListAdaptor *_GroupListAdaptor; - - // For auto selecting the node in a BrowseTree bound to this HTML web page - std::string _BrowseTree; - // select the tree node that has the correct url - const std::string &selectTreeNodeRecurs(CGroupTree::SNode *node, const std::string &url); - // search if the action / params match the url. look recurs into procedures - bool actionLaunchUrlRecurs(const std::string &ah, const std::string ¶ms, const std::string &url); - - // Browse undo and redo - enum {MaxUrlUndoRedo= 256}; - std::string _BrowseUndoButton; - std::string _BrowseRedoButton; - std::string _BrowseRefreshButton; - // _BrowseUrl is different from _URL, in that _URL may change in handle() - std::string _AskedUrl; - std::deque _BrowseUndo; - std::deque _BrowseRedo; - void pushUrlUndoRedo(const std::string &url); - void doBrowse(const char *url); - void updateUndoRedoButtons(); - void updateRefreshButton(); - - // For Killing request. Associate each CGroupHTML object with a unique ID. - uint32 _GroupHtmlUID; - static uint32 _GroupHtmlUIDPool; - typedef std::map > TGroupHtmlByUIDMap; - static TGroupHtmlByUIDMap _GroupHtmlByUID; - -private: - - // decode all HTML entities - static ucstring decodeHTMLEntities(const ucstring &str); - - // ImageDownload system - enum TDataType {ImgType= 0, BnpType}; - - struct CDataDownload - { - CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f) - { - if (t == ImgType) imgs.push_back(i); - } - - CURL *curl; - std::string url; - std::string luaScript; - std::string md5sum; - TDataType type; - FILE *fp; - std::vector imgs; - }; - - std::vector Curls; - CURLM *MultiCurl; - int RunningCurls; - - void initImageDownload(); - void checkImageDownload(); - void addImageDownload(const std::string &url, CViewBase *img); - std::string localImageName(const std::string &url); - - bool isTrustedDomain(const std::string &domain); - void setImage(CViewBase *view, const std::string &file); - - // BnpDownload system - void initBnpDownload(); - void checkBnpDownload(); - bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum); - std::string localBnpName(const std::string &url); - - void releaseDownloads(); - void checkDownloads(); - -}; - -// adapter group that store y offset for inputs inside an html form -class CGroupHTMLInputOffset : public CInterfaceGroup -{ -public: - sint32 Offset; - CGroupHTMLInputOffset(const TCtorParam ¶m); - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); -}; - -#endif diff --git a/code/ryzom/client/src/interface_v3/group_html_cs.h b/code/ryzom/client/src/interface_v3/group_html_cs.h index e3c8a765e..9d322ad54 100644 --- a/code/ryzom/client/src/interface_v3/group_html_cs.h +++ b/code/ryzom/client/src/interface_v3/group_html_cs.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_CS_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_forum.h b/code/ryzom/client/src/interface_v3/group_html_forum.h index fe233fecc..c3a0bcbf6 100644 --- a/code/ryzom/client/src/interface_v3/group_html_forum.h +++ b/code/ryzom/client/src/interface_v3/group_html_forum.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_FORUM_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_mail.h b/code/ryzom/client/src/interface_v3/group_html_mail.h index 51f363c3c..5477be085 100644 --- a/code/ryzom/client/src/interface_v3/group_html_mail.h +++ b/code/ryzom/client/src/interface_v3/group_html_mail.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_MAIL_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_qcm.h b/code/ryzom/client/src/interface_v3/group_html_qcm.h index 61f763f8c..21607dced 100644 --- a/code/ryzom/client/src/interface_v3/group_html_qcm.h +++ b/code/ryzom/client/src/interface_v3/group_html_qcm.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_QCM_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.h b/code/ryzom/client/src/interface_v3/group_html_webig.h index 5967f671d..a0a71a27f 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.h +++ b/code/ryzom/client/src/interface_v3/group_html_webig.h @@ -18,7 +18,7 @@ #define CL_GROUP_HTML_WEBIG_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** * Auth HTML group diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 97777043d..9d2413f20 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -23,7 +23,7 @@ #include "../character_cl.h" #include "nel/gui/action_handler.h" #include "../entities.h" -#include "group_paragraph.h" // For CCtrlLink +#include "nel/gui/group_paragraph.h" // For CCtrlLink #include "../net_manager.h" #include "../string_manager_client.h" #include "../login.h" diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp deleted file mode 100644 index 0ad38ec64..000000000 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ /dev/null @@ -1,1223 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "group_paragraph.h" -#include "group_html.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/interface_element.h" -#include "nel/gui/view_pointer_base.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/view_text_id.h" -#include "nel/gui/group_container.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/i18n.h" -#include "nel/misc/xml_auto_ptr.h" - -using namespace std; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); - -// ---------------------------------------------------------------------------- -CGroupParagraph::CGroupParagraph(const TCtorParam ¶m) -: CInterfaceGroup(param), - _Templ(TCtorParam()) -{ - _IdCounter = 0; - _AddElt = Bottom; - _Align = Left; - _Space = 0; - _MinW= 0; - _MinH= 0; - _Over = false; - _OverColor = CRGBA(255,255,255,32); - _OverElt = -1; - _LastW = 0; - invalidateContent(); - _TopSpace = 0; - _Indent = 0; - _FirstViewIndentView = false; - _BrowseGroup = NULL; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addChild (CViewBase* child, bool deleteOnRemove) -{ - if (!child) - { - nlwarning(" : tried to add a NULL view"); - return; - } - - // add child at last index - addChildAtIndex(child, (uint)_Elements.size(), deleteOnRemove); - if (_Elements.size() >= 2) - { - setOrder((uint)_Elements.size() - 1, getOrder((uint)_Elements.size() - 2) + 1); - } - invalidateContent(); -} - -// ---------------------------------------------------------------------------- -CGroupParagraph::~CGroupParagraph() -{ - deleteAllChildren(); -} - -// ---------------------------------------------------------------------------- -// Set Hotspot of the first element in reference to the group -/*void CGroupParagraph::setHSGroup (CViewBase *child, EAlign addElt, EAlign align) -{ - switch (addElt) - { - case Bottom: - if (align == Left) - { - child->_ParentPosRef = Hotspot_TL; - child->_PosRef = Hotspot_TL; - } - else // align == Right - { - child->_ParentPosRef = Hotspot_TR; - child->_PosRef = Hotspot_TR; - } - break; - case Left: - if (align == Top) - { - child->_ParentPosRef = Hotspot_TR; - child->_PosRef = Hotspot_TR; - } - else // align == Bottom - { - child->_ParentPosRef = Hotspot_BR; - child->_PosRef = Hotspot_BR; - } - break; - case Top: - if (align == Left) - { - child->_ParentPosRef = Hotspot_BL; - child->_PosRef = Hotspot_BL; - } - else // align == Right - { - child->_ParentPosRef = Hotspot_BR; - child->_PosRef = Hotspot_BR; - } - break; - case Right: - if (align == Top) - { - child->_ParentPosRef = Hotspot_TL; - child->_PosRef = Hotspot_TL; - } - else // align == Bottom - { - child->_ParentPosRef = Hotspot_BL; - child->_PosRef = Hotspot_BL; - } - break; - default: - nlassert(false); - break; - } -}*/ - -// ---------------------------------------------------------------------------- -/** align an element towards its parent in the group - */ -/*void CGroupParagraph::setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space) -{ - if ((addElt == Top) || (addElt == Bottom)) - { - if (addElt == Bottom) - { - if (_Align == Left) - view->_ParentPosRef = Hotspot_BL; - else // align == Right - view->_ParentPosRef = Hotspot_BR; - view->_Y = -abs(space); - } - else if (addElt == Top) - { - if (_Align == Left) - view->_ParentPosRef = Hotspot_TL; - else // align == Right - view->_ParentPosRef = Hotspot_TR; - view->_Y = abs(space); - } - } - else - { - if (addElt == Left) - { - if (_Align == Top) - view->_ParentPosRef = Hotspot_TL; - else // align == Bottom - view->_ParentPosRef = Hotspot_BL; - view->_X = -abs(space); - } - else if (addElt == Right) - { - if (_Align == Top) - view->_ParentPosRef = Hotspot_TR; - else // align == Bottom - view->_ParentPosRef = Hotspot_BR; - view->_X = abs(space); - } - } -}*/ - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur,parentGroup)) - return false; - - // Parse location. If these properties are not specified, set them to 0 - - CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"addelt" )); - _AddElt = Bottom; - if (ptr) - { - if (stricmp(ptr,"B") == 0) - _AddElt = Bottom; - else if (stricmp(ptr,"T") == 0) - _AddElt = Top; - else if (stricmp(ptr,"L") == 0) - _AddElt = Left; - else if (stricmp(ptr,"R") == 0) - _AddElt = Right; - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"align" ); - _Align = Left; - if (ptr) - { - if (stricmp(ptr,"B") == 0) - _Align = Bottom; - else if (stricmp(ptr,"T") == 0) - _Align = Top; - else if (stricmp(ptr,"L") == 0) - _Align = Left; - else if (stricmp(ptr,"R") == 0) - _Align = Right; - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"space" ); - _Space = 0; - if (ptr) - fromString((const char*)ptr, _Space); - - EAlign addElt = _AddElt; -// EAlign align = _Align; - _GroupSizeRef = _SizeRef; - if ((addElt == Top) || (addElt == Bottom)) - { - setMaxW (_W); - setMaxH(_H); - _H = 0; - _SizeRef = _SizeRef&(~2); - } - else - { - setMaxW (_W); - setMaxH (_H); - _W = 0; - _SizeRef = _SizeRef&(~1); - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" ); - _Over = false; - if (ptr) _Over = convertBool(ptr); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"col_over" ); - _OverColor = CRGBA(255,255,255,32); - if (ptr) _OverColor = convertColor(ptr); - - - // TEMPLATE TEXT SETUP - - // justification parameters - _Templ.parseTextOptions (cur); - - // initial text - ptr = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); - if (ptr) - { - const char *propPtr = ptr; - ucstring Text = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - - addTextChild(Text); - } - else - { - ptr = (char*) xmlGetProp( cur, (xmlChar*)"textid" ); - if (ptr) - { - uint32 textId; - fromString((const char*)ptr, textId); - addTextChildID(textId); - } - } - - return true; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChild(const ucstring& line, bool multiLine /*= true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - view->setTextMode(_Templ.getTextMode()); - if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - - - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); - view->setColor (textColor); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChildID (uint32 nID, bool multiLine) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewTextID *view= new CViewTextID (elid, nID, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChildID(const std::string &dbPath,bool multiLine /*=true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewTextID *view= new CViewTextID (elid, dbPath, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::delChild (CViewBase* childToDel) -{ - // Look for child - uint posChildToDel = 0; - for (posChildToDel = 0; posChildToDel < _Elements.size(); ++posChildToDel) - { - CElementInfo rEI = _Elements[posChildToDel]; - if (rEI.Element == childToDel) - break; - } - - if (posChildToDel == _Elements.size()) - { - nlwarning("Can't del child %s, it does not exist in the list", childToDel->getId().c_str()); - return; - } - delChild(posChildToDel); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::delChild(uint posChildToDel) -{ - if (posChildToDel >= (uint) _Elements.size()) - { - nlwarning(" bad index"); - return; - } - - CViewBase* childToDel = _Elements[posChildToDel].Element; - bool ElementMustBeDeleted = _Elements[posChildToDel].EltDeleteOnRemove; - _Elements.erase (_Elements.begin()+posChildToDel); - // Remove from drawing - if (dynamic_cast(childToDel)) delGroup(static_cast(childToDel), !ElementMustBeDeleted); - else if (dynamic_cast(childToDel)) delCtrl(static_cast(childToDel), !ElementMustBeDeleted); - else delView(childToDel, !ElementMustBeDeleted); - - // Bind the new first element - if (posChildToDel < _Elements.size()) - { - CViewBase *pVB = _Elements[posChildToDel].Element; - if (posChildToDel == 0) - { - pVB->_ParentPos = NULL; - // setHSGroup (pVB, _AddElt, _Align); - if ((_AddElt == Top) || (_AddElt == Bottom)) - pVB->setY (0); - else - pVB->setX (0); - } - else - pVB->_ParentPos = _Elements[posChildToDel-1].Element; - } -} - -// ---------------------------------------------------------------------------- -/*void CGroupParagraph::removeHead () -{ - if (_Elements.empty()) - { - nlwarning(" Can't remove head, list is empty"); - return; - } - delChild (_Elements.begin()->Element);*/ - /*CViewBase *pVB = _Elements.begin()->Element; - if ((_AddElt == Top) || (_AddElt == Bottom)) - { - sint32 shift = _H - (pVB->getH() + _Space); - _H = shift; - } - else - { - sint32 shift = _W - (pVB->getW() + _Space); - _W = shift; - } - - bool FirstElementMustBeDeleted = _Elements.begin()->EltDeleteOnRemove; - if (FirstElementMustBeDeleted) - delete pVB; - _Elements.erase (_Elements.begin()); - // Remove from drawing - for (vector::iterator itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - if(*itg == pVB) - { - _ChildrenGroups.erase (itg); - break; - } - for (vector::iterator itc = _Controls.begin(); itc != _Controls.end(); itc++) - if(*itc == pVB) - { - _Controls.erase (itc); - break; - } - for (vector::iterator itv = _Views.begin(); itv != _Views.end(); itv++) - if(*itv == pVB) - { - _Views.erase (itv); - break; - } - delEltOrder (pVB); - - // Bind the new first element - pVB = _Elements.begin()->Element; - pVB->_ParentPos = NULL; - setHSGroup (pVB, _AddElt, _Align); - if ((_AddElt == Top) || (_AddElt == Bottom)) - pVB->setY (0); - else - pVB->setX (0);*/ -//} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setTextTemplate(const CViewText& templ) -{ - _Templ = templ; -} - - -// ---------------------------------------------------------------------------- -void CGroupParagraph::updateCoords() -{ - if (_Parent) - { - if (!_ContentValidated) - { - // Update W - CInterfaceElement::updateCoords(); - - // Current X and Y - sint32 x=_Indent; - sint32 y=-(sint32)_TopSpace; - - // Current W - sint width = std::min(getMaxWReal(), getWReal()); - - // For each elements, place them - uint firstElementOnLine = 0; - const uint elmCount = (uint)_Elements.size(); - uint i; - for (i = 0; i < elmCount+1; ++i) - { - // Force flush for the last element - bool changeLine = (i == elmCount); - uint lastLineElement = i+1; - - // Not the end of the element - if (i < elmCount) - { - // Active element ? - if (_Elements[i].Element->getActive()) - { - _Elements[i].Element->updateCoords(); - // Is a view text ? - CViewText *viewText = dynamic_cast(_Elements[i].Element); - if (viewText) - { - viewText->setFirstLineX(x + ((i==0)?_FirstViewIndentView:0)); - viewText->setX(0); - viewText->updateTextContext(); - } - else - { - _Elements[i].Element->setX(x + ((i==0)?_FirstViewIndentView:0)); - } - _Elements[i].Element->setPosRef(Hotspot_TL); - _Elements[i].Element->setParentPosRef(Hotspot_TL); - - // Update coords for this element - _Elements[i].Element->updateCoords(); - - // Does we balance the last line height ? - if (viewText) - { - changeLine = viewText->getNumLine() > 1; - if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == (ucchar) '\n') - { - changeLine = true; - } - } - else - { - // If this element is too big for the line, place it next time - if ((i!=firstElementOnLine) && ((_Elements[i].Element->getX() + _Elements[i].Element->getW()) > width)) - { - lastLineElement--; - changeLine = true; - i--; - } - } - - - // New x coordinate - x = _Elements[i].Element->getX() + _Elements[i].Element->getWReal(); - } - } - else - lastLineElement = i; - - // Balance line height - if (changeLine) - { - // Eval line height - uint j; - uint lineHeight = 0; - uint multiLineHeight = 0; - uint legHeight = 0; - uint lastLineWidth = _Indent; - - for (j=firstElementOnLine; j(_Elements[j].Element); - - // Element height - if (viewTextOnLine) - { - // Height is just under the first line letter - newHeight = viewTextOnLine->getFontHeight() - viewTextOnLine->getFontLegHeight(); - - // Leg height for this view - legHeight = std::max(legHeight, viewTextOnLine->getFontLegHeight()); - - // Last element is a text multi line - if (j==(lastLineElement-1)) - { - const uint numLine = viewTextOnLine->getNumLine(); - if (numLine>1) - { - multiLineHeight = (numLine-2) * viewTextOnLine->getFontHeight() + (numLine-1) * viewTextOnLine->getMultiLineSpace(); - lastLineWidth = _Indent + viewTextOnLine->getLastLineW (); - } - } - } - else - { - newHeight = _Elements[j].Element->getH(); - CGroupHTMLInputOffset *inputOffset = dynamic_cast(_Elements[j].Element); - if (inputOffset && inputOffset->Offset < 0) - { - newHeight += inputOffset->Offset; - legHeight = max(-(inputOffset->Offset), sint32(legHeight)); - } - } - - if (lineHeight < newHeight) - lineHeight = newHeight; - } - - // Repos element on the line - for (j=firstElementOnLine; j(_Elements[j].Element); - - sint32 offsetY=0; - CGroupHTMLInputOffset *inputOffset = dynamic_cast(_Elements[j].Element); - if (inputOffset) - offsetY = inputOffset->Offset; - // Element height - if (viewTextOnLine) - newHeight = viewTextOnLine->getFontHeight() - viewTextOnLine->getFontLegHeight() - offsetY; - else - newHeight = _Elements[j].Element->getH(); - - sint32 posY = y-lineHeight+newHeight+offsetY; - _Elements[j].Element->setY(posY); - } - - if (i < elmCount) - { - nlassert(lastLineElement>0); - nlassert(lastLineElement-1getNumLine()); - - // Number of line.. - uint j; - for (j=0; j<3; j++) - { - if (jsetId(getId()+":"+"links"+toString(i)+"-"+toString(j)); - ctrl->setParent (this); - ctrl->setParentSize (this); - ctrl->setParentPos (this); - ctrl->setParentPosRef (Hotspot_TL); - ctrl->setPosRef (Hotspot_TL); - ctrl->setActive(true); - if (_BrowseGroup) - { - ctrl->setActionOnLeftClick("browse"); - ctrl->setParamsOnLeftClick("name="+_BrowseGroup->getId()+"|url="+link.Link->Link); - } - ctrl->setScale(true); - addCtrl(ctrl); - } - - // Pos the links - int x, y, width, height; - int fontSize = link.Link->getFontHeight(); - int fontLineSpace = link.Link->getMultiLineSpace(); - - // X - x = (j == 0) ? link.Link->getFirstLineX() : link.Link->getX(); - - // Y - if (j < 2) - y = link.Link->getY() - (fontSize+fontLineSpace) * j; - else - y = link.Link->getY() - ((fontSize+fontLineSpace) * (link.Link->getNumLine()-1)); - - // Width - - // Last line ? - if (j == (links-1)) - width = link.Link->getLastLineW (); - else - { - width = link.Link->getW(); - - // First line ? - if (j == 0) - width -= (link.Link->getFirstLineX() - link.Link->getX()); - } - - if ((j == 1) && (links==3)) - height = (fontSize+fontLineSpace)*(link.Link->getNumLine()-2); - else - height = fontSize; - - ctrl->setX(x); - ctrl->setY(y); - ctrl->setW(width); - ctrl->setH(height); - } - else - { - if (link.CtrlLink[j]) - { - delCtrl (link.CtrlLink[j]); - link.CtrlLink[j] = NULL; - } - } - } - } - } - } - CInterfaceGroup::updateCoords(); - - // Validated - _ContentValidated = true; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::checkCoords () -{ - if (_Parent != NULL) - { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); - if (_LastW != (sint) parentWidth) - { - CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); - if (pCB != NULL) - { - CCtrlResizer *pCR = dynamic_cast(pCB); - if (pCR != NULL) - { - // We are resizing !!!! - } - else - { - _LastW = parentWidth; - invalidateContent(); - } - } - else - { - _LastW = parentWidth; - invalidateContent(); - } - } - } - CInterfaceGroup::checkCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::draw () -{ - // TEMP TEMP - //CViewRenderer &rVR = *CViewRenderer::getInstance(); - //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) ); - if (_Over) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - if (CWidgetManager::getInstance()->getModalWindow() == NULL) - { - sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); - sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - - CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x,y); - CInterfaceGroup *pParent = this; - bool bFound = false; - while (pParent != NULL) - { - if (pParent == pIG) - { - bFound = true; - break; - } - pParent = pParent->getParent(); - } - - sint32 clipx,clipy,clipw,cliph; - getClip(clipx,clipy,clipw,cliph); - if ((x < clipx) || - (x > (clipx + clipw)) || - (y < clipy) || - (y > (clipy + cliph)) || !bFound) - { - _OverElt = -1; - } - else - { - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - CViewBase *pVB = _Elements[i].Element; - if ((x >= pVB->getXReal()) && - (x < (pVB->getXReal() + pVB->getWReal()))&& - (y >= pVB->getYReal()) && - (y < (pVB->getYReal() + pVB->getHReal()))) - { - _OverElt = i; - } - } - } - } - - if (_OverElt != -1) - { - CViewBase *pVB = _Elements[_OverElt].Element; - CRGBA col = _OverColor; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _OverColor; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - rVR.drawRotFlipBitmap (_RenderLayer, pVB->getXReal(), pVB->getYReal(), - pVB->getWReal(), pVB->getHReal(), 0, false, rVR.getBlankTextureId(), - col ); - - } - } - - CInterfaceGroup::draw (); -} - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (!_Active) - return false; - - bool bReturn = CInterfaceGroup::handleEvent(event); - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - - _OverElt = -1; - if (!isIn(eventDesc.getX(), eventDesc.getY())) - return false; - - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - CViewBase *pVB = _Elements[i].Element; - if ((eventDesc.getX() >= pVB->getXReal()) && - (eventDesc.getX() < (pVB->getXReal() + pVB->getWReal()))&& - (eventDesc.getY() >= pVB->getYReal()) && - (eventDesc.getY() < (pVB->getYReal() + pVB->getHReal()))) - { - _OverElt = i; - } - } - } - - return bReturn; -} - - - -// predicate to remove a view from the list of element -struct CRemoveViewPred -{ - bool operator()(const CGroupParagraph::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - -// predicate to remove a ctrl from the list of element -struct CRemoveCtrlPred -{ - bool operator()(const CGroupParagraph::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - -// predicate to remove a group from the list of element -struct CRemoveGroupPred -{ - bool operator()(const CGroupParagraph::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - - -// ---------------------------------------------------------------------------- -void CGroupParagraph::clearViews() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveViewPred()), _Elements.end()); - CInterfaceGroup::clearViews(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::clearControls() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveCtrlPred()), _Elements.end()); - CInterfaceGroup::clearControls(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::clearGroups() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveGroupPred()), _Elements.end()); - CInterfaceGroup::clearGroups(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::forceSizeW (sint32 newSizeW) -{ - _W = newSizeW; - for (uint32 i = 0; i < _Elements.size(); ++i) - { - _Elements[i].Element->setW (_W); - _Elements[i].Element->CInterfaceElement::updateCoords(); - } -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::forceSizeH (sint32 newSizeH) -{ - _H = newSizeH; - for (uint32 i = 0; i < _Elements.size(); ++i) - { - _Elements[i].Element->setH (_H); - _Elements[i].Element->CInterfaceElement::updateCoords(); - } -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setMinW(sint32 minW) -{ - _MinW= minW; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setMinH(sint32 minH) -{ - _MinH= minH; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove /*=true*/) -{ - if (!child) - { - nlwarning(" : tried to add a NULL view"); - return false; - } - if (index > _Elements.size()) - { - return false; - } - child->_Parent = this; - child->_ParentPos = NULL; - child->_Active = true; - child->_X = 0; - child->_Y = 0; - child->_RenderLayer = this->_RenderLayer; - // Can't have sizeref on the coordinate corresponding to alignement - switch(_AddElt) - { - case Top: - case Bottom: - child->_SizeRef &= 1; // sizeref on w is permitted - break; - case Left: - case Right: - child->_SizeRef &= 2; // sizeref on h is permitted - break; - default: - nlwarning(" bad align"); - child->_SizeRef = 0; - break; - } - - child->_SizeDivW = 10; - child->_SizeDivH = 10; - - // Position the element according to the list alignement - // setHSGroup (child, _AddElt, _Align); - - // update coords of the element (it may use child_resize_h or w) - //child->updateCoords(); - child->invalidateCoords(); - - // Update size - if ((_AddElt == Top) || (_AddElt == Bottom)) - { - // update the list size - sint32 newH = _H + child->getH(); - if (_Elements.size() > 0) - newH += _Space; - _H = newH; - - if ((_SizeRef&1) == 0) // No parent size reference in W - { - sint32 newW = max (_W, child->getW()); - _W = newW; - } - } - else - { - // Update the list coords - sint32 newW = _W + child->getW(); - if (_Elements.size() > 0) - newW += _Space; - _W = newW; - - if ((_SizeRef&2) == 0) // No parent size reference in H - { - sint32 newH = max (_H, child->getH()); - _H = newH; - } - } - - CElementInfo ei; - ei.Element = child; - ei.EltDeleteOnRemove = deleteOnRemove; - ei.Order = 0; - - if (index != 0) - { - // update alignement - // setHSParent(child, _AddElt, _Align, _Space); - // child->_ParentPos = _Elements[index - 1].Element; - } - _Elements.insert(_Elements.begin() + index, ei); - // link next element to this one - if (index < _Elements.size() - 1) - { - // _Elements[index + 1].Element->_ParentPos = child; - // setHSParent(_Elements[index + 1].Element, _AddElt, _Align, _Space); - } - - // Add this element for drawing - { - CInterfaceGroup *pIG = dynamic_cast(child); - if (pIG != NULL) - { - addGroup (pIG, (sint) index); - return true; - } - CCtrlBase *pCB = dynamic_cast(child); - if (pCB != NULL) - { - addCtrl (pCB, (sint) index); - return true; - } - CViewBase *pVB = dynamic_cast(child); - if (pVB != NULL) - { - addView (pVB, (sint) index); - return true; - } - nlstop; - return false; - } - return false; -} - -// ---------------------------------------------------------------------------- -sint32 CGroupParagraph::getElementIndex(CViewBase* child) const -{ - for(uint k = 0; k < _Elements.size(); ++k) - { - if (_Elements[k].Element == child) return k; - } - return -1; -} - -// ---------------------------------------------------------------------------- -/*void CGroupParagraph::swapChildren(uint index1, uint index2) -{ - if (index1 >= _Elements.size() - || index2 >= _Elements.size()) - { - nlwarning(" bad indexes"); - return; - } - // prevent elements from being deleted - bool oldMustDelete1 = _Elements[index1].EltDeleteOnRemove; - bool oldMustDelete2 = _Elements[index2].EltDeleteOnRemove; - - uint order1 = _Elements[index1].Order; - uint order2 = _Elements[index2].Order; - - _Elements[index1].EltDeleteOnRemove = false; - _Elements[index2].EltDeleteOnRemove = false; - - CViewBase *v1 = _Elements[index1].Element; - CViewBase *v2 = _Elements[index2].Element; - - - if (index1 < index2) - { - delChild(index2); - delChild(index1); - addChildAtIndex(v2, index1, oldMustDelete2); - setOrder(index1, order2); - addChildAtIndex(v1, index2, oldMustDelete1); - setOrder(index2, order1); - } - else - { - delChild(index1); - delChild(index2); - addChildAtIndex(v1, index2, oldMustDelete1); - setOrder(index2, order1); - addChildAtIndex(v2, index1, oldMustDelete2); - setOrder(index1, order2); - } -}*/ - -// ---------------------------------------------------------------------------- -void CGroupParagraph::deleteAllChildren() -{ - uint numChildren = getNbElement(); - for(uint k = 0; k < numChildren; ++k) - { - delChild(numChildren - 1 - k); // delete in reverse order to avoid unnecessary vector copies - } -} - -// ---------------------------------------------------------------------------- -uint CGroupParagraph::getNumActiveChildren() const -{ - uint numChildren = 0; - for(uint k = 0; k < _Elements.size(); ++k) - { - if (_Elements[k].Element->getActive()) ++numChildren; - } - return numChildren; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setDelOnRemove(uint index, bool delOnRemove) -{ - if (index >= _Elements.size()) - { - nlwarning("bad index"); - return; - } - _Elements[index].EltDeleteOnRemove = delOnRemove; -} - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::getDelOnRemove(uint index) const -{ - if (index >= _Elements.size()) - { - nlwarning("bad index"); - return false; - } - return _Elements[index].EltDeleteOnRemove; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addChildLink (CViewLink* child, bool deleteOnRemove) -{ - // Add the child - addChild (child, deleteOnRemove); - - // Add the link - _Links.push_back (CLink(child)); -} - -// ---------------------------------------------------------------------------- -CGroupParagraph::CLink::CLink (CViewLink *link) -{ - Link = link; - CtrlLink[0] = NULL; - CtrlLink[1] = NULL; - CtrlLink[2] = NULL; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::onInvalidateContent() -{ - _ContentValidated = false; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -sint32 CGroupParagraph::getMaxUsedW() const -{ - // The paragraph max is the sum of the components max - sint maxWidth = 0; - for (uint k = 0; k < _Elements.size(); ++k) - { - // Get the child width - maxWidth += _Elements[k].Element->getMaxUsedW(); - } - return maxWidth; -} - -// ---------------------------------------------------------------------------- -sint32 CGroupParagraph::getMinUsedW() const -{ - // The paragraph min is the max of the components min - sint32 minWidth = 0; - for (uint k = 0; k < _Elements.size(); ++k) - { - // Get the child width - sint32 width = _Elements[k].Element->getMinUsedW(); - if (width > minWidth) - minWidth = width; - } - return minWidth; -} - diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h deleted file mode 100644 index ce13eb6c3..000000000 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ /dev/null @@ -1,299 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - -#ifndef NL_GROUP_PARAGRAPH_H -#define NL_GROUP_PARAGRAPH_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/group_frame.h" -#include "nel/gui/view_text.h" -#include "view_link.h" -#include "nel/gui/ctrl_button.h" - -class CCtrlLink : public CCtrlButton -{ -public: - CCtrlLink (const TCtorParam ¶m) : CCtrlButton(param) - {} -}; - -// ---------------------------------------------------------------------------- -class CGroupParagraph : public CInterfaceGroup -{ -public: - enum EAlign - { - Bottom = 0, - Top, - Left, - Right - }; - - ///constructor - CGroupParagraph(const TCtorParam ¶m); - - // dtor - ~CGroupParagraph(); - - /** - * add a child element to the group at the last position - * 'order' of the element is set to the last order + 1 - * \param child : pointer to the child element - */ - void addChild (CViewBase* child, bool deleteOnRemove=true); - - /** - * add a link element to the group at the last position - * \param child : pointer to the child element - */ - void addChildLink (CViewLink* child, bool deleteOnRemove=true); - - /** add a child before the element at the given index. - * 'order' of the element is set to 0 - * \return true if there was enough room for that child - */ - bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true); - - /** - * add a text child element to the group, using the text template - * \param line : text to be added - * \param color : text color - */ - void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); - - /** - * add a text child element to the group, using the text template - * \param line : text to be added - */ - void addTextChild (const ucstring& line, bool multiLine = true); - - /// Same as adding a text child but the text will be taken from the string manager - void addTextChildID (uint32 id, bool multiLine = true); - // the same, but with id taken from the database - void addTextChildID (const std::string &dbPath, bool multiLine = true); - -protected: - - void delChild (CViewBase* child); - - void delChild(uint index); - -public: - - CViewBase *getChild(uint index) const { return _Elements[index].Element; } - - void deleteAllChildren(); - - // void removeHead(); - - // Get the number of children - uint getNumChildren() const { return (uint)_Elements.size(); } - - // Get the number of active children - uint getNumActiveChildren() const; - - /** - * set the template that will be used to add text; - * \templ : a CViewText object. Only its font size, color and shadow are required. - */ - void setTextTemplate(const CViewText& templ); - - /** - * set the template that will be used to add text; - * \templ : a CViewText object. Only its font size, color and shadow are required. - */ - CViewText * getTextTemplatePtr() - { - return &_Templ; - } - - /** - * parse the element and initalize it - * \paral cur : pointer to the node describing this element - * \param parentGroup : the parent group of this element - * \return true if success - */ - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - //virtual uint32 getMemory(); - /** - * init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here - */ - virtual void updateCoords(); - - virtual void checkCoords(); - - virtual void draw(); - - virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); - - virtual void clearViews(); - virtual void clearControls(); - virtual void clearGroups(); - - void setSpace (sint32 s) { _Space = s; } - - virtual CInterfaceElement* getElement (const std::string &id) - { return CInterfaceGroup::getElement (id); } - - sint32 getNbElement() { return (sint32)_Elements.size(); } - sint32 getSpace() { return _Space; } - - void forceSizeW (sint32 newSizeW); - void forceSizeH (sint32 newSizeH); - - void setMinW(sint32 minW); - void setMinH(sint32 minH); - sint32 getMinW() const {return _MinW;} - sint32 getMinH() const {return _MinH;} - - // set the rank for the element at the given index (used to reinsert container after they have been turned into popups) - void setOrder(uint index, uint order) { _Elements[index].Order = order; } - uint getOrder(uint index) const { return _Elements[index].Order; } - - // get element of index or -1 if not found - sint32 getElementIndex(CViewBase* child) const; - - // swap 2 entries in the list (and also their orders) - // void swapChildren(uint index1, uint index2); - - // deleteOnRemove flag - void setDelOnRemove(uint index, bool delOnRemove); - bool getDelOnRemove(uint index) const; - - void setTopSpace(uint topSpace) - { - _TopSpace = topSpace; - setResizeFromChildHMargin(topSpace); - invalidateContent(); - }; - - uint getTopSpace() - { - return _TopSpace; - }; - - void setIndent(uint indent) { _Indent = indent; } - - void setFirstViewIndent(sint indent) - { - _FirstViewIndentView = indent; - invalidateContent(); - } - - // Set the HTML group used for links - void setBrowseGroup (CInterfaceElement *group) - { - _BrowseGroup = group; - } - - /// \from CInterfaceElement - void onInvalidateContent(); - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - -protected: - - // Content validated - bool _ContentValidated; - - // Where to add next element - EAlign _AddElt; - - // Where to align the newly added element - EAlign _Align; - - // Space between two elements in pixel - sint32 _Space; - - // Text template - CViewText _Templ; - - // Current id of the view - sint32 _IdCounter; - - // Do we have a color under the element pointed by the mouse - bool _Over; - - // If over is true so we have a color - NLMISC::CRGBA _OverColor; - - // Current elt over the pointer - sint32 _OverElt; - - struct CElementInfo - { - uint Order; // Used to sort the window by their insertion order. - // This is used to put back a window at the right place if it was turned into a popup. - CViewBase *Element; - bool EltDeleteOnRemove; - }; - friend struct CRemoveViewPred; - friend struct CRemoveCtrlPred; - friend struct CRemoveGroupPred; - - // The list is forced to be at least this size in updateCoords(). - sint32 _MinW; - sint32 _MinH; - - - // To conserve elements in the order they have been added - // (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup - std::vector _Elements; - - // Last parent width - sint32 _LastW; - - // Top space - uint _TopSpace; - - // Indent - uint _Indent; // Left margin - sint _FirstViewIndentView; // Additionnal left margin for the first view - - // A link structure - class CLink - { - public: - - CLink(CViewLink *link); - - // The link view - CViewLink *Link; - - // The three control button - CCtrlLink *CtrlLink[3]; - }; - - // The links - std::vector _Links; - - // The HTML group used - CInterfaceElement *_BrowseGroup; - -private: - - // void setHSGroup (CViewBase *child, EAlign addElt, EAlign align); - // void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space); - -}; - -#endif // NL_GROUP_PARAGRAPH_H - -/* End of group_paragraph.h */ - - diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index d67cbeb5d..ea6b4e6a6 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -23,8 +23,8 @@ #include "group_quick_help.h" #include "nel/gui/group_list.h" -#include "group_paragraph.h" -#include "../libwww.h" +#include "nel/gui/group_paragraph.h" +#include "nel/gui/libwww.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.h b/code/ryzom/client/src/interface_v3/group_quick_help.h index bef4bdd7e..05810fbeb 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.h +++ b/code/ryzom/client/src/interface_v3/group_quick_help.h @@ -21,7 +21,7 @@ #define CL_GROUP_QUICK_HELP_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 63a120944..6b627330d 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -26,7 +26,7 @@ #include "dbctrl_sheet.h" #include "nel/gui/group_container.h" #include "nel/gui/group_menu.h" -#include "group_html.h" +#include "nel/gui/group_html.h" #include "../init_main_loop.h" #include "inventory_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index b0308b5db..5a43ddbbb 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -70,7 +70,7 @@ #include "group_in_scene_bubble.h" #include "group_skills.h" #include "group_compas.h" -#include "group_html.h" +#include "nel/gui/group_html.h" // Misc #include "../input.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index b2ffddf3f..a65420c01 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -57,7 +57,7 @@ #include "nel/gui/ctrl_col_pick.h" #include "nel/gui/ctrl_tooltip.h" #include "nel/gui/ctrl_text_button.h" -#include "group_paragraph.h" // For CCtrlLink +#include "nel/gui/group_paragraph.h" // For CCtrlLink // DBCtrl #include "dbctrl_sheet.h" // Group diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 54892a61a..7b71fd3a5 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -60,7 +60,7 @@ #include "nel/misc/i18n.h" #include "nel/misc/time_nl.h" #include "skill_manager.h" -#include "group_html.h" +#include "nel/gui/group_html.h" #include "../net_manager.h" #include "../user_entity.h" #include "sphrase_manager.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 436e492e1..8c7d12dc5 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -49,7 +49,7 @@ #include "nel/gui/ctrl_scroll.h" #include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/group_tab.h" -#include "group_html.h" +#include "nel/gui/group_html.h" #include "nel/gui/group_header.h" #include "sphrase_manager.h" // diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 0b30cf47a..21c7bbd5f 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -21,8 +21,8 @@ #include "interface_manager.h" #include "nel/gui/view_renderer.h" #include "nel/gui/ctrl_col_pick.h" -#include "group_paragraph.h" -#include "group_html.h" +#include "nel/gui/group_paragraph.h" +#include "nel/gui/group_html.h" #include "group_map.h" // #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/libwww.cpp b/code/ryzom/client/src/libwww.cpp deleted file mode 100644 index b2c699cd5..000000000 --- a/code/ryzom/client/src/libwww.cpp +++ /dev/null @@ -1,708 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -// LibWWW -extern "C" -{ -#include "WWWLib.h" /* Global Library Include file */ -#include "WWWApp.h" -#include "WWWInit.h" -} - -#include "interface_v3/group_html.h" -#include "interface_v3/libwww_nel_stream.h" - -using namespace NLMISC; - -/// the cookie value for session identification (nel cookie) -std::string CurrentCookie; - -/// store all cookies we receive and resent them depending of the domain -std::map > HTTPCookies; -std::string HTTPCurrentDomain; // The current domain that will be used to get which cookies to send - -// *************************************************************************** - -// The HText structure for libwww -struct _HText -{ - CGroupHTML *Parent; -}; - -// *************************************************************************** - -// Some DTD table - -// Here, modify the DTD table to change the HTML parser (add new tags for examples) - -#undef HTML_ATTR -#define HTML_ATTR(a,b) { (char*) #b } - -HTAttr a_attr[] = -{ - HTML_ATTR(A,ACCESSKEY), - HTML_ATTR(A,CHARSET), - HTML_ATTR(A,CLASS), - HTML_ATTR(A,COORDS), - HTML_ATTR(A,DIR), - HTML_ATTR(A,HREF), - HTML_ATTR(A,HREFLANG), - HTML_ATTR(A,ID), - HTML_ATTR(A,NAME), - HTML_ATTR(A,REL), - HTML_ATTR(A,REV), - HTML_ATTR(A,SHAPE), - HTML_ATTR(A,STYLE), - HTML_ATTR(A,TABINDEX), - HTML_ATTR(A,TARGET), - HTML_ATTR(A,TYPE), - HTML_ATTR(A,TITLE), - HTML_ATTR(A,Z_ACTION_CATEGORY), - HTML_ATTR(A,Z_ACTION_PARAMS), - HTML_ATTR(A,Z_ACTION_SHORTCUT), - { 0 } -}; - -HTAttr table_attr[] = -{ - HTML_ATTR(TABLE,ALIGN), - HTML_ATTR(TABLE,BGCOLOR), - HTML_ATTR(TABLE,BORDER), - HTML_ATTR(TABLE,CELLPADDING), - HTML_ATTR(TABLE,CELLSPACING), - HTML_ATTR(TABLE,CLASS), - HTML_ATTR(TABLE,DIR), - HTML_ATTR(TABLE,FRAME), - HTML_ATTR(TABLE,ID), - HTML_ATTR(TABLE,L_MARGIN), - HTML_ATTR(TABLE,LANG), - HTML_ATTR(TABLE,NOWRAP), - HTML_ATTR(TABLE,RULES), - HTML_ATTR(TABLE,SUMMARY), - HTML_ATTR(TABLE,STYLE), - HTML_ATTR(TABLE,TITLE), - HTML_ATTR(TABLE,VALIGN), - HTML_ATTR(TABLE,WIDTH), - { 0 } -}; - -HTAttr tr_attr[] = -{ - HTML_ATTR(TR,ALIGN), - HTML_ATTR(TR,BGCOLOR), - HTML_ATTR(TR,L_MARGIN), - HTML_ATTR(TR,NOWRAP), - HTML_ATTR(TR,VALIGN), - { 0 } -}; - -HTAttr td_attr[] = -{ - HTML_ATTR(TD,ABBR), - HTML_ATTR(TD,ALIGN), - HTML_ATTR(TD,AXIS), - HTML_ATTR(TD,BGCOLOR), - HTML_ATTR(TD,CHAR), - HTML_ATTR(TD,CHAROFF), - HTML_ATTR(TD,CLASS), - HTML_ATTR(TD,COLSPAN), - HTML_ATTR(TD,DIR), - HTML_ATTR(TD,ID), - HTML_ATTR(TD,HEADERS), - HTML_ATTR(TD,HEIGHT), - HTML_ATTR(TD,L_MARGIN), - HTML_ATTR(TD,LANG), - HTML_ATTR(TD,NOWRAP), - HTML_ATTR(TD,ROWSPAN), - HTML_ATTR(TD,SCOPE), - HTML_ATTR(TD,STYLE), - HTML_ATTR(TD,TITLE), - HTML_ATTR(TD,VALIGN), - HTML_ATTR(TD,WIDTH), - { 0 } -}; - -HTAttr img_attr[] = -{ - HTML_ATTR(IMG,ALIGN), - HTML_ATTR(IMG,ALT), - HTML_ATTR(IMG,BORDER), - HTML_ATTR(IMG,CLASS), - HTML_ATTR(IMG,DIR), - HTML_ATTR(IMG,GLOBAL_COLOR), - HTML_ATTR(IMG,HEIGHT), - HTML_ATTR(IMG,HSPACE), - HTML_ATTR(IMG,ID), - HTML_ATTR(IMG,ISMAP), - HTML_ATTR(IMG,LANG), - HTML_ATTR(IMG,LONGDESC), - HTML_ATTR(IMG,SRC), - HTML_ATTR(IMG,STYLE), - HTML_ATTR(IMG,TITLE), - HTML_ATTR(IMG,USEMAP), - HTML_ATTR(IMG,VSPACE), - HTML_ATTR(IMG,WIDTH), - { 0 } -}; - -HTAttr input_attr[] = -{ - HTML_ATTR(INPUT,ACCEPT), - HTML_ATTR(INPUT,ACCESSKEY), - HTML_ATTR(INPUT,ALIGN), - HTML_ATTR(INPUT,ALT), - HTML_ATTR(INPUT,CHECKED), - HTML_ATTR(INPUT,CLASS), - HTML_ATTR(INPUT,DIR), - HTML_ATTR(INPUT,DISABLED), - HTML_ATTR(INPUT,GLOBAL_COLOR), - HTML_ATTR(INPUT,ID), - HTML_ATTR(INPUT,LANG), - HTML_ATTR(INPUT,MAXLENGTH), - HTML_ATTR(INPUT,NAME), - HTML_ATTR(INPUT,READONLY), - HTML_ATTR(INPUT,SIZE), - HTML_ATTR(INPUT,SRC), - HTML_ATTR(INPUT,STYLE), - HTML_ATTR(INPUT,TABINDEX), - HTML_ATTR(INPUT,TITLE), - HTML_ATTR(INPUT,TYPE), - HTML_ATTR(INPUT,USEMAP), - HTML_ATTR(INPUT,VALUE), - HTML_ATTR(INPUT,Z_BTN_TMPL), - HTML_ATTR(INPUT,Z_INPUT_TMPL), - HTML_ATTR(INPUT,Z_INPUT_WIDTH), - { 0 } -}; - -HTAttr textarea_attr[] = -{ - HTML_ATTR(TEXTAREA,CLASS), - HTML_ATTR(TEXTAREA,COLS), - HTML_ATTR(TEXTAREA,DIR), - HTML_ATTR(TEXTAREA,DISABLED), - HTML_ATTR(TEXTAREA,ID), - HTML_ATTR(TEXTAREA,LANG), - HTML_ATTR(TEXTAREA,NAME), - HTML_ATTR(TEXTAREA,READONLY), - HTML_ATTR(TEXTAREA,ROWS), - HTML_ATTR(TEXTAREA,STYLE), - HTML_ATTR(TEXTAREA,TABINDEX), - HTML_ATTR(TEXTAREA,TITLE), - HTML_ATTR(TEXTAREA,Z_INPUT_TMPL), - { 0 } -}; - - -HTAttr p_attr[] = -{ - HTML_ATTR(P,QUICK_HELP_CONDITION), - HTML_ATTR(P,QUICK_HELP_EVENTS), - HTML_ATTR(P,QUICK_HELP_LINK), - HTML_ATTR(P,NAME), - { 0 } -}; - - -HTAttr div_attr[] = -{ - HTML_ATTR(DIV,CLASS), - HTML_ATTR(DIV,ID), - HTML_ATTR(DIV,NAME), - HTML_ATTR(DIV,STYLE), - { 0 } -}; - -// *************************************************************************** - -void _VerifyLibWWW(const char *function, bool ok, const char *file, int line) -{ - if (!ok) - nlwarning("%s(%d) : LIBWWW %s returned a bad status", file, line, function); -} -#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__) - -// *************************************************************************** - -int NelPrinter (const char * fmt, va_list pArgs) -{ - char info[1024]; - int ret; - - ret = vsnprintf(info, sizeof(info), fmt, pArgs); - nlinfo("%s", info); - return ret; -} - -// *************************************************************************** - -int NelTracer (const char * fmt, va_list pArgs) -{ - char err[1024]; - int ret; - - ret = vsnprintf(err, sizeof(err), fmt, pArgs); - nlwarning ("%s", err); - return ret; -} - -// *************************************************************************** - -HText * TextNew (HTRequest * request, - HTParentAnchor * /* anchor */, - HTStream * /* output_stream */) -{ - HText *text = new HText; - text->Parent = (CGroupHTML *) HTRequest_context(request); - return text; -} - -// *************************************************************************** - -BOOL TextDelete (HText * me) -{ - delete me; - return YES; -} - -// *************************************************************************** - -void TextBuild (HText * me, HTextStatus status) -{ - // Do the work in the class - if (status == HTEXT_BEGIN) - me->Parent->beginBuild (); - else if (status == HTEXT_END) - me->Parent->endBuild (); -} - -// *************************************************************************** - -void TextAdd (HText * me, const char * buf, int len) -{ - // Do the work in the class - me->Parent->addText (buf, len); -} - -// *************************************************************************** - -void TextLink (HText * me, - int element_number, - int attribute_number, - HTChildAnchor * anchor, - const BOOL * present, - const char ** value) -{ - // Do the work in the class - me->Parent->addLink (element_number, attribute_number, anchor, present, value); -} - -// *************************************************************************** - -// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false -bool getPercentage (sint32 &width, float &percent, const char *str) -{ - // Percent ? - const char *percentChar; - if ((percentChar = strchr (str, '%')) != NULL) - { - std::string toto = str; - toto = toto.substr (0, percentChar - str); - fromString(toto, percent); - percent /= 100.f; - return true; - } - else - { - fromString(str, width); - return false; - } -} - -// *************************************************************************** - -CRGBA getColor (const char *color) -{ - if (strlen (color) != 7 && strlen (color) != 9 ) - return CRGBA::White; - char tmp[3] = {0,0,0}; - CRGBA dst; - int value; - tmp[0] = color[1]; - tmp[1] = color[2]; - sscanf (tmp, "%x", &value); - dst.R = uint8(value); - tmp[0] = color[3]; - tmp[1] = color[4]; - sscanf (tmp, "%x", &value); - dst.G = uint8(value); - tmp[0] = color[5]; - tmp[1] = color[6]; - sscanf (tmp, "%x", &value); - dst.B = uint8(value); - if (strlen (color) == 9) - { - tmp[0] = color[7]; - tmp[1] = color[8]; - sscanf (tmp, "%x", &value); - dst.A = uint8(value); - } - else - { - // extension to html ; try to parse an additional alpha - dst.A = 255; - } - return dst; -} - -// *************************************************************************** - -void TextBeginElement (HText *me, int element_number, const BOOL *present, const char **value) -{ - // Do the work in the class - me->Parent->beginElement (element_number, present, value); -} - -// *************************************************************************** - -void TextEndElement (HText *me, int element_number) -{ - // Do the work in the class - me->Parent->endElement (element_number); -} - -// *************************************************************************** -void TextBeginUnparsedElement(HText *me, const char *buffer, int length) -{ - me->Parent->beginUnparsedElement(buffer, length); -} - -// *************************************************************************** -void TextEndUnparsedElement(HText *me, const char *buffer, int length) -{ - me->Parent->endUnparsedElement(buffer, length); -} - -// *************************************************************************** -void TextUnparsedEntity (HText * /* HText */, const char *buffer, int length) -{ - std::string str(buffer, buffer+length); - nlinfo("Unparsed entity '%s'", str.c_str()); -} - -// *************************************************************************** -int requestTerminater (HTRequest * request, HTResponse * /* response */, - void * param, int /* status */) -{ - /* - Yoyo and Boris: we had to make the request terminate by UID and not by pointer (param is an uid). - Because this method was called at mainLoop time, but for GroupHTML created/deleted at login time !!! - => Memory Crash. - */ - - // TestYoyo - //nlinfo("** requestTerminater(): uid%d", (uint32)param); - - // the parameter is actually an uint32 - if (param != 0) - { - CGroupHTML::TGroupHtmlByUIDMap::iterator it= CGroupHTML::_GroupHtmlByUID.find((uint32)(size_t)param); - if(it!=CGroupHTML::_GroupHtmlByUID.end()) - { - // get the pointer. NB: the refptr should not be NULL - // since object removed from map when deleted - CGroupHTML *gh = it->second; - nlassert(gh); - - // callback the browser - gh->requestTerminated(request); - } - } - return HT_OK; -} - - -// callback called when receiving a cookie -BOOL receiveCookie (HTRequest * /* request */, HTCookie * cookie, void * /* param */) -{ - if (strcmp(HTCookie_name(cookie), "ryzomId") == 0) - { - // we receive the ryzom id cookie, store it - CurrentCookie = HTCookie_value(cookie); - } - else - { - // store the id/value cookie - HTTPCookies[HTTPCurrentDomain][HTCookie_name(cookie)] = HTCookie_value(cookie); -// nlwarning("get cookie for domain %s %s=%s", HTTPCurrentDomain.c_str(), HTCookie_name(cookie), HTCookie_value(cookie)); - } - - return YES; -} - -// callback called to add cookie to a request before sending it to the server -HTAssocList *sendCookie (HTRequest * /* request */, void * /* param */) -{ - HTAssocList * alist = 0; - if (!CurrentCookie.empty()) - { - if(alist == 0) alist = HTAssocList_new(); /* Is deleted by the cookie module */ - HTAssocList_addObject(alist, "ryzomId", CurrentCookie.c_str()); - } - - if(!HTTPCookies[HTTPCurrentDomain].empty()) - { - if(alist == 0) alist = HTAssocList_new(); - for(std::map::iterator it = HTTPCookies[HTTPCurrentDomain].begin(); it != HTTPCookies[HTTPCurrentDomain].end(); it++) - { - HTAssocList_addObject(alist, it->first.c_str(), it->second.c_str()); -// nlwarning("set cookie for domain '%s' %s=%s", HTTPCurrentDomain.c_str(), it->first.c_str(), it->second.c_str()); - } - } - return alist; -} - - -// *************************************************************************** - -HTAnchor * TextFindAnchor (HText * /* me */, int /* index */) -{ - return NULL; -} - -int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value) -{ - char * location = HTStrip(value); - - std::string finalLocation; - - //nlinfo("redirect to '%s' '%s'", value, location); - - // If not absolute URI (Error) then find the base - if (!HTURL_isAbsolute(location)) - { - char * base = HTAnchor_address((HTAnchor *) HTRequest_anchor(request)); - location = HTParse(location, base, PARSE_ALL); - //redirection = HTAnchor_findAddress(location); - finalLocation = location; - HT_FREE(base); - HT_FREE(location); - } - else - { - finalLocation = location; - } - //nlinfo("final location '%s'", finalLocation.c_str()); - - CGroupHTML *gh = (CGroupHTML *) HTRequest_context(request); - - gh->setURL(finalLocation); - - return HT_OK; -} - - -// *************************************************************************** - -const std::string &setCurrentDomain(const std::string &url) -{ - if(url.find("http://") == 0) - { - HTTPCurrentDomain = url.substr(7, url.find('/', 7)-7); -// nlinfo("****cd: %s", HTTPCurrentDomain.c_str()); - } - else - { - HTTPCurrentDomain.clear(); -// nlinfo("****cd: clear the domain"); - } - return HTTPCurrentDomain; -} - - -void initLibWWW() -{ - static bool initialized = false; - if (!initialized) - { - //HTProfile_newNoCacheClient("Ryzom", "1.1"); - - /* Need our own trace and print functions */ - HTPrint_setCallback(NelPrinter); - HTTrace_setCallback(NelTracer); - - /* Initiate libwww */ - - HTLib_setAppName( CGroupHTML::options.appName.c_str() ); - HTLib_setAppVersion( CGroupHTML::options.appVersion.c_str() ); - - /* Set up TCP as transport */ - VerifyLibWWW("HTTransport_add", HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new)); - VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTNeLReader_new, HTWriter_new)); - // VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTANSIReader_new, HTWriter_new)); - // VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTReader_new, HTWriter_new)); - - /* Set up HTTP as protocol */ - VerifyLibWWW("HTProtocol_add", HTProtocol_add("http", "buffered_tcp", 80, NO, HTLoadHTTP, NULL)); - VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadNeLFile, NULL)); - //VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL)); - // HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL); - - HTBind_init(); - // HTCacheInit(NULL, 20); - - /* Setup up transfer coders */ - HTFormat_addTransferCoding((char*)"chunked", HTChunkedEncoder, HTChunkedDecoder, 1.0); - - /* Setup MIME stream converters */ - HTFormat_addConversion("message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-foot", "*/*", HTMIMEFooter, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-head", "*/*", HTMIMEHeader, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-cont", "*/*", HTMIMEContinue, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-partial","*/*", HTMIMEPartial, 1.0, 0.0, 0.0); - HTFormat_addConversion("multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0); - - /* Setup HTTP protocol stream */ - HTFormat_addConversion("text/x-http", "*/*", HTTPStatus_new, 1.0, 0.0, 0.0); - - /* Setup the HTML parser */ - HTFormat_addConversion("text/html", "www/present", HTMLPresent, 1.0, 0.0, 0.0); - - /* Setup black hole stream */ - HTFormat_addConversion("*/*", "www/debug", HTBlackHoleConverter, 1.0, 0.0, 0.0); - HTFormat_addConversion("*/*", "www/present", HTBlackHoleConverter, 0.3, 0.0, 0.0); - - /* Set max number of sockets we want open simultaneously */ - HTNet_setMaxSocket(32); - - /* Register our HTML parser callbacks */ - VerifyLibWWW("HText_registerCDCallback", HText_registerCDCallback (TextNew, TextDelete)); - VerifyLibWWW("HText_registerBuildCallback", HText_registerBuildCallback (TextBuild)); - VerifyLibWWW("HText_registerTextCallback", HText_registerTextCallback(TextAdd)); - VerifyLibWWW("HText_registerLinkCallback", HText_registerLinkCallback (TextLink)); - VerifyLibWWW("HText_registerElementCallback", HText_registerElementCallback (TextBeginElement, TextEndElement)); - VerifyLibWWW("HText_registerUnparsedElementCallback", HText_registerUnparsedElementCallback(TextBeginUnparsedElement, TextEndUnparsedElement)); - VerifyLibWWW("HText_registerUnparsedEntityCallback ", HText_registerUnparsedEntityCallback (TextUnparsedEntity )); - - - /* Register the default set of MIME header parsers */ - struct { - const char * string; - HTParserCallback * pHandler; - } fixedHandlers[] = { - {"accept", &HTMIME_accept}, - {"accept-charset", &HTMIME_acceptCharset}, - {"accept-encoding", &HTMIME_acceptEncoding}, - {"accept-language", &HTMIME_acceptLanguage}, - {"accept-ranges", &HTMIME_acceptRanges}, - {"authorization", NULL}, - {"cache-control", &HTMIME_cacheControl}, - {"connection", &HTMIME_connection}, - {"content-encoding", &HTMIME_contentEncoding}, - {"content-length", &HTMIME_contentLength}, - {"content-range", &HTMIME_contentRange}, - {"content-transfer-encoding", &HTMIME_contentTransferEncoding}, - {"content-type", &HTMIME_contentType}, - {"digest-MessageDigest", &HTMIME_messageDigest}, - {"keep-alive", &HTMIME_keepAlive}, - {"link", &HTMIME_link}, - {"location", &HTMIME_location_custom}, - {"max-forwards", &HTMIME_maxForwards}, - {"mime-version", NULL}, - {"pragma", &HTMIME_pragma}, - {"protocol", &HTMIME_protocol}, - {"protocol-info", &HTMIME_protocolInfo}, - {"protocol-request", &HTMIME_protocolRequest}, - {"proxy-authenticate", &HTMIME_authenticate}, - {"proxy-authorization", &HTMIME_proxyAuthorization}, - {"public", &HTMIME_public}, - {"range", &HTMIME_range}, - {"referer", &HTMIME_referer}, - {"retry-after", &HTMIME_retryAfter}, - {"server", &HTMIME_server}, - {"trailer", &HTMIME_trailer}, - {"transfer-encoding", &HTMIME_transferEncoding}, - {"upgrade", &HTMIME_upgrade}, - {"user-agent", &HTMIME_userAgent}, - {"vary", &HTMIME_vary}, - {"via", &HTMIME_via}, - {"warning", &HTMIME_warning}, - {"www-authenticate", &HTMIME_authenticate}, - {"authentication-info", &HTMIME_authenticationInfo}, - {"proxy-authentication-info", &HTMIME_proxyAuthenticationInfo} - }; - - for (uint i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++) - HTHeader_addParser(fixedHandlers[i].string, NO, fixedHandlers[i].pHandler); - - /* Set up default event loop */ - HTEventInit(); - - /* Add our own request terminate handler */ - HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST); - - /* Setup cookies */ - HTCookie_init(); - HTCookie_setCookieMode(HTCookieMode(HT_COOKIE_ACCEPT | HT_COOKIE_SEND)); - HTCookie_setCallbacks(receiveCookie, NULL, sendCookie, NULL); - - /* Start the first request */ - - /* Go into the event loop... */ - // HTEventList_newLoop(); - - // App_delete(app); - - HTBind_add("htm", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ - HTBind_add("html", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ - - HTBind_caseSensitive(NO); - - // Change the HTML DTD - SGML_dtd *HTML_DTD = HTML_dtd (); - HTML_DTD->tags[HTML_TABLE].attributes = table_attr; - HTML_DTD->tags[HTML_TABLE].number_of_attributes = sizeof(table_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_TR].attributes = tr_attr; - HTML_DTD->tags[HTML_TR].number_of_attributes = sizeof(tr_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_TD].attributes = td_attr; - HTML_DTD->tags[HTML_TD].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_IMG].attributes = img_attr; - HTML_DTD->tags[HTML_IMG].number_of_attributes = sizeof(img_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_INPUT].attributes = input_attr; - HTML_DTD->tags[HTML_INPUT].number_of_attributes = sizeof(input_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_TEXTAREA].attributes = textarea_attr; - HTML_DTD->tags[HTML_TEXTAREA].number_of_attributes = sizeof(textarea_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_P].attributes = p_attr; - HTML_DTD->tags[HTML_P].number_of_attributes = sizeof(p_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_A].attributes = a_attr; - HTML_DTD->tags[HTML_A].number_of_attributes = sizeof(a_attr) / sizeof(HTAttr) - 1; - //HTML_DTD->tags[HTML_I].attributes = a_attr; - HTML_DTD->tags[HTML_I].number_of_attributes = 0; - HTML_DTD->tags[HTML_DIV].attributes = div_attr; - HTML_DTD->tags[HTML_DIV].number_of_attributes = sizeof(div_attr) / sizeof(HTAttr) - 1; - - // Set a request timeout -// HTHost_setEventTimeout (30000); -// HTHost_setActiveTimeout (30000); -// HTHost_setPersistTimeout (30000); - - // Initialized - initialized = true; - } -} - -// *************************************************************************** diff --git a/code/ryzom/client/src/libwww.h b/code/ryzom/client/src/libwww.h deleted file mode 100644 index aa3f6b424..000000000 --- a/code/ryzom/client/src/libwww.h +++ /dev/null @@ -1,283 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - - -#ifndef CL_LIB_WWW_H -#define CL_LIB_WWW_H - -extern "C" -{ -#include "WWWInit.h" -} - -namespace NLGUI -{ - class CCtrlBaseButton; - class CCtrlScroll; - class CGroupList; -} - -// *************************************************************************** - -// Init the libwww -void initLibWWW(); - -// Get an url and setup a local domain -const std::string &setCurrentDomain(const std::string &url); - -extern std::string CurrentCookie; - -// *************************************************************************** - -// Some DTD table - -// Here, modify the DTD table to change the HTML parser (add new tags for exemples) - -#undef HTML_ATTR -#define HTML_ATTR(t,a) MY_HTML_##t##_##a - -enum -{ - HTML_ATTR(A,ACCESSKEY) = 0, - HTML_ATTR(A,CHARSET), - HTML_ATTR(A,CLASS), - HTML_ATTR(A,COORDS), - HTML_ATTR(A,DIR), - HTML_ATTR(A,HREF), - HTML_ATTR(A,HREFLANG), - HTML_ATTR(A,ID), - HTML_ATTR(A,NAME), - HTML_ATTR(A,REL), - HTML_ATTR(A,REV), - HTML_ATTR(A,SHAPE), - HTML_ATTR(A,STYLE), - HTML_ATTR(A,TABINDEX), - HTML_ATTR(A,TARGET), - HTML_ATTR(A,TYPE), - HTML_ATTR(A,TITLE), - HTML_ATTR(A,Z_ACTION_CATEGORY), - HTML_ATTR(A,Z_ACTION_PARAMS), - HTML_ATTR(A,Z_ACTION_SHORTCUT), -}; - -enum -{ - HTML_ATTR(TABLE,ALIGN) = 0, - HTML_ATTR(TABLE,BGCOLOR), - HTML_ATTR(TABLE,BORDER), - HTML_ATTR(TABLE,CELLPADDING), - HTML_ATTR(TABLE,CELLSPACING), - HTML_ATTR(TABLE,CLASS), - HTML_ATTR(TABLE,DIR), - HTML_ATTR(TABLE,FRAME), - HTML_ATTR(TABLE,ID), - HTML_ATTR(TABLE,L_MARGIN), - HTML_ATTR(TABLE,LANG), - HTML_ATTR(TABLE,NOWRAP), - HTML_ATTR(TABLE,RULES), - HTML_ATTR(TABLE,SUMMARY), - HTML_ATTR(TABLE,STYLE), - HTML_ATTR(TABLE,TITLE), - HTML_ATTR(TABLE,VALIGN), - HTML_ATTR(TABLE,WIDTH) -}; - -enum -{ - HTML_ATTR(TR,ALIGN) = 0, - HTML_ATTR(TR,BGCOLOR), - HTML_ATTR(TR,L_MARGIN), - HTML_ATTR(TR,NOWRAP), - HTML_ATTR(TR,VALIGN), -}; - -enum -{ - HTML_ATTR(TD,ABBR) = 0, - HTML_ATTR(TD,ALIGN), - HTML_ATTR(TD,AXIS), - HTML_ATTR(TD,BGCOLOR), - HTML_ATTR(TD,CHAR), - HTML_ATTR(TD,CHAROFF), - HTML_ATTR(TD,CLASS), - HTML_ATTR(TD,COLSPAN), - HTML_ATTR(TD,DIR), - HTML_ATTR(TD,ID), - HTML_ATTR(TD,HEADERS), - HTML_ATTR(TD,HEIGHT), - HTML_ATTR(TD,L_MARGIN), - HTML_ATTR(TD,LANG), - HTML_ATTR(TD,NOWRAP), - HTML_ATTR(TD,ROWSPAN), - HTML_ATTR(TD,SCOPE), - HTML_ATTR(TD,STYLE), - HTML_ATTR(TD,TITLE), - HTML_ATTR(TD,VALIGN), - HTML_ATTR(TD,WIDTH), -}; - -enum -{ - HTML_ATTR(IMG,ALIGN) = 0, - HTML_ATTR(IMG,ALT), - HTML_ATTR(IMG,BORDER), - HTML_ATTR(IMG,CLASS), - HTML_ATTR(IMG,DIR), - HTML_ATTR(IMG,GLOBAL_COLOR), - HTML_ATTR(IMG,HEIGHT), - HTML_ATTR(IMG,HSPACE), - HTML_ATTR(IMG,ID), - HTML_ATTR(IMG,ISMAP), - HTML_ATTR(IMG,LANG), - HTML_ATTR(IMG,LONGDESC), - HTML_ATTR(IMG,SRC), - HTML_ATTR(IMG,STYLE), - HTML_ATTR(IMG,TITLE), - HTML_ATTR(IMG,USEMAP), - HTML_ATTR(IMG,VSPACE), - HTML_ATTR(IMG,WIDTH), -}; - -enum -{ - HTML_ATTR(INPUT,ACCEPT) = 0, - HTML_ATTR(INPUT,ACCESSKEY), - HTML_ATTR(INPUT,ALIGN), - HTML_ATTR(INPUT,ALT), - HTML_ATTR(INPUT,CHECKED), - HTML_ATTR(INPUT,CLASS), - HTML_ATTR(INPUT,DIR), - HTML_ATTR(INPUT,DISABLED), - HTML_ATTR(INPUT,GLOBAL_COLOR), - HTML_ATTR(INPUT,ID), - HTML_ATTR(INPUT,LANG), - HTML_ATTR(INPUT,MAXLENGTH), - HTML_ATTR(INPUT,NAME), - HTML_ATTR(INPUT,READONLY), - HTML_ATTR(INPUT,SIZE), - HTML_ATTR(INPUT,SRC), - HTML_ATTR(INPUT,STYLE), - HTML_ATTR(INPUT,TABINDEX), - HTML_ATTR(INPUT,TITLE), - HTML_ATTR(INPUT,TYPE), - HTML_ATTR(INPUT,USEMAP), - HTML_ATTR(INPUT,VALUE), - HTML_ATTR(INPUT,Z_BTN_TMPL), - HTML_ATTR(INPUT,Z_INPUT_TMPL), - HTML_ATTR(INPUT,Z_INPUT_WIDTH), -}; - -enum -{ - HTML_ATTR(TEXTAREA,CLASS) = 0, - HTML_ATTR(TEXTAREA,COLS), - HTML_ATTR(TEXTAREA,DIR), - HTML_ATTR(TEXTAREA,DISABLED), - HTML_ATTR(TEXTAREA,ID), - HTML_ATTR(TEXTAREA,LANG), - HTML_ATTR(TEXTAREA,NAME), - HTML_ATTR(TEXTAREA,READONLY), - HTML_ATTR(TEXTAREA,ROWS), - HTML_ATTR(TEXTAREA,STYLE), - HTML_ATTR(TEXTAREA,TABINDEX), - HTML_ATTR(TEXTAREA,TITLE), - HTML_ATTR(TEXTAREA,Z_INPUT_TMPL), -}; - -enum -{ - HTML_ATTR(P,QUICK_HELP_CONDITION) = 0, - HTML_ATTR(P,QUICK_HELP_EVENTS), - HTML_ATTR(P,QUICK_HELP_LINK), - HTML_ATTR(P,NAME), -}; - -enum -{ - HTML_ATTR(DIV,CLASS) = 0, - HTML_ATTR(DIV,ID), - HTML_ATTR(DIV,NAME), - HTML_ATTR(DIV,STYLE), -}; - - -#undef HTML_ATTR - -// *************************************************************************** - -// A smart ptr for LibWWW strings -class C3WSmartPtr -{ -public: - C3WSmartPtr () - { - _Ptr = NULL; - } - C3WSmartPtr (const char *ptr) - { - _Ptr = ptr; - } - ~C3WSmartPtr () - { - clear(); - } - void operator=(const char *str) - { - clear (); - _Ptr = str; - } - operator const char *() const - { - return _Ptr; - } - void clear() - { - if (_Ptr) - { - void *ptr = (void*)_Ptr; - HT_FREE(ptr); - } - _Ptr = NULL; - } -private: - const char *_Ptr; -}; - -// *************************************************************************** - -// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false -bool getPercentage (sint32 &width, float &percent, const char *str); - -// *************************************************************************** - -// Parse a HTML color -NLMISC::CRGBA getColor (const char *color); - -// *************************************************************************** - -void _VerifyLibWWW(const char *function, bool ok, const char *file, int line); -#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__) - -// *************************************************************************** - -// Standard request terminator -int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ; - -// *************************************************************************** - -#endif diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 7d1b8a3fa..df7d68e73 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -49,7 +49,7 @@ #include "client_cfg.h" #include "global.h" #include "input.h" -#include "libwww.h" +#include "nel/gui/libwww.h" #include "http_client.h" #include "http_client_curl.h" #include "login_progress_post_thread.h" diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index f91e22eb4..45bffbf57 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -55,7 +55,7 @@ #include "main_loop.h" #include "interface_v3/group_in_scene_bubble.h" #include "interface_v3/inventory_manager.h" -#include "interface_v3/group_html.h" +#include "nel/gui/group_html.h" #include "interface_v3/people_interraction.h" #include "init_main_loop.h" #include "view.h"