PageRenderTime 101ms CodeModel.GetById 40ms app.highlight 7ms RepoModel.GetById 34ms app.codeStats 0ms

/indra/newview/llsplitbutton.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 106 lines | 54 code | 23 blank | 29 comment | 0 complexity | 969eed03e1709e58cd01973b307dff07 MD5 | raw file
  1/** 
  2 * @file llsplitbutton.h
  3 * @brief LLSplitButton base class
  4 *
  5 * $LicenseInfo:firstyear=2009&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// A control that displays the name of the chosen item, which when clicked
 28// shows a scrolling box of choices.
 29
 30
 31#include "llbutton.h"
 32#include "llpanel.h"
 33#include "lluictrl.h"
 34
 35
 36#ifndef LL_LLSPLITBUTTON_H
 37#define LL_LLSPLITBUTTON_H
 38
 39class LLSplitButton
 40	:	public LLUICtrl
 41{
 42public:
 43	typedef enum e_arrow_position
 44	{
 45		LEFT,
 46		RIGHT
 47	} EArrowPosition;
 48
 49	struct ArrowPositionValues : public LLInitParam::TypeValuesHelper<EArrowPosition, ArrowPositionValues>
 50	{
 51		static void declareValues();
 52	};
 53
 54	struct ItemParams : public LLInitParam::Block<ItemParams, LLButton::Params>
 55	{
 56		ItemParams();
 57	};
 58
 59	struct Params :	public LLInitParam::Block<Params, LLUICtrl::Params>
 60	{
 61		Optional<EArrowPosition, ArrowPositionValues> arrow_position;
 62		Optional<LLButton::Params> arrow_button;
 63		Optional<LLPanel::Params> items_panel;
 64		Multiple<ItemParams> items;
 65
 66		Params();
 67	};
 68
 69
 70	virtual ~LLSplitButton() {};
 71
 72	//Overridden
 73	virtual void	onFocusLost();
 74	virtual void	setFocus(BOOL b);
 75	virtual void	setEnabled(BOOL enabled);
 76
 77	//Callbacks
 78	void	onArrowBtnDown();
 79	void	onHeldDownShownButton();
 80	void	onItemSelected(LLUICtrl* ctrl);
 81	void	setSelectionCallback(commit_callback_t cb) { mSelectionCallback = cb; }
 82
 83	virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
 84
 85	virtual void	showButtons();
 86	virtual void	hideButtons();
 87
 88
 89protected:
 90	friend class LLUICtrlFactory;
 91	LLSplitButton(const LLSplitButton::Params& p);
 92
 93	LLButton* prepareItemButton(LLButton::Params params);
 94	LLPanel* prepareItemsPanel(LLPanel::Params params, S32 items_count);
 95
 96	LLPanel* mItemsPanel;
 97	std::list<LLButton*> mHidenItems;
 98	LLButton* mArrowBtn;
 99	LLButton* mShownItem;
100	EArrowPosition mArrowPosition;
101
102	commit_callback_t mSelectionCallback;
103};
104
105
106#endif