PageRenderTime 284ms CodeModel.GetById 161ms app.highlight 8ms RepoModel.GetById 112ms app.codeStats 1ms

/indra/newview/llchathistory.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 147 lines | 69 code | 17 blank | 61 comment | 0 complexity | 404f70291cc04b7b1eefa4377c6c92eb MD5 | raw file
  1/** 
  2 * @file llchathistory.h
  3 * @brief LLTextEditor base class
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LLCHATHISTORY_H_
 28#define LLCHATHISTORY_H_
 29
 30#include "lltexteditor.h"
 31#include "lltextbox.h"
 32#include "llviewerchat.h"
 33
 34//Chat log widget allowing addition of a message as a widget 
 35class LLChatHistory : public LLUICtrl
 36{
 37	public:
 38		struct Params : public LLInitParam::Block<Params, LLTextEditor::Params>
 39		{
 40			//Message header filename
 41			Optional<std::string>	message_header;
 42			//Message separator filename
 43			Optional<std::string>	message_separator;
 44			//Text left padding from the scroll rect
 45			Optional<S32>			left_text_pad;
 46			//Text right padding from the scroll rect
 47			Optional<S32>			right_text_pad;
 48			//Widget left padding from the scroll rect
 49			Optional<S32>			left_widget_pad;
 50			//Widget right padding from the scroll rect
 51			Optional<S32>			right_widget_pad;
 52			//Separator top padding
 53			Optional<S32>			top_separator_pad;
 54			//Separator bottom padding
 55			Optional<S32>			bottom_separator_pad;
 56			//Header top padding
 57			Optional<S32>			top_header_pad;
 58			//Header bottom padding
 59			Optional<S32>			bottom_header_pad;
 60
 61			Optional<LLTextBox::Params>	more_chat_text;
 62
 63			Params()
 64			:	message_header("message_header"),
 65				message_separator("message_separator"),
 66				left_text_pad("left_text_pad"),
 67				right_text_pad("right_text_pad"),
 68				left_widget_pad("left_widget_pad"),
 69				right_widget_pad("right_widget_pad"),
 70				top_separator_pad("top_separator_pad"),
 71				bottom_separator_pad("bottom_separator_pad"),
 72				top_header_pad("top_header_pad"),
 73				bottom_header_pad("bottom_header_pad"),
 74				more_chat_text("more_chat_text")
 75			{}
 76
 77		};
 78	protected:
 79		LLChatHistory(const Params&);
 80		friend class LLUICtrlFactory;
 81
 82		/*virtual*/ void draw();
 83		/**
 84		 * Redefinition of LLTextEditor::updateTextRect() to considerate text
 85		 * left/right padding params.
 86		 */
 87		//virtual void	updateTextRect();
 88		/**
 89		 * Builds a message separator.
 90		 * @return pointer to LLView separator object.
 91		 */
 92		LLView* getSeparator();
 93		/**
 94		 * Builds a message header.
 95		 * @return pointer to LLView header object.
 96		 */
 97		LLView* getHeader(const LLChat& chat,const LLStyle::Params& style_params, const LLSD& args);
 98
 99		void onClickMoreText();
100
101	public:
102		~LLChatHistory();
103
104		void initFromParams(const Params&);
105
106		/**
107		 * Appends a widget message.
108		 * If last user appended message, concurs with current user,
109		 * separator is added before the message, otherwise header is added.
110		 * The args LLSD contains:
111		 * - use_plain_text_chat_history (bool) - whether to add message as plain text.
112		 * - owner_id (LLUUID) - the owner ID for object chat
113		 * @param chat - base chat message.
114		 * @param args - additional arguments
115		 * @param input_append_params - font style.
116		 */
117		void appendMessage(const LLChat& chat, const LLSD &args = LLSD(), const LLStyle::Params& input_append_params = LLStyle::Params());
118		/*virtual*/ void clear();
119
120	private:
121		std::string mLastFromName;
122		LLUUID mLastFromID;
123		LLDate mLastMessageTime;
124		bool mIsLastMessageFromLog;
125		//std::string mLastMessageTimeStr;
126
127		std::string mMessageHeaderFilename;
128		std::string mMessageSeparatorFilename;
129
130		S32 mLeftTextPad;
131		S32 mRightTextPad;
132
133		S32 mLeftWidgetPad;
134		S32 mRightWidgetPad;
135
136		S32 mTopSeparatorPad;
137		S32 mBottomSeparatorPad;
138		S32 mTopHeaderPad;
139		S32 mBottomHeaderPad;
140
141		class LLLayoutPanel*	mMoreChatPanel;
142		LLTextBox*		mMoreChatText;
143		LLTextEditor*	mEditor;
144		typedef std::set<std::string> unread_chat_source_t;
145		unread_chat_source_t mUnreadChatSources;
146};
147#endif /* LLCHATHISTORY_H_ */