aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llscrollbar.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/llscrollbar.h')
-rw-r--r--linden/indra/llui/llscrollbar.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/linden/indra/llui/llscrollbar.h b/linden/indra/llui/llscrollbar.h
new file mode 100644
index 0000000..b7689ea
--- /dev/null
+++ b/linden/indra/llui/llscrollbar.h
@@ -0,0 +1,142 @@
1/**
2 * @file llscrollbar.h
3 * @brief Scrollbar UI widget
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_SCROLLBAR_H
29#define LL_SCROLLBAR_H
30
31#include "stdtypes.h"
32#include "lluictrl.h"
33#include "v4color.h"
34
35//
36// Constants
37//
38const S32 SCROLLBAR_SIZE = 16;
39
40
41//
42// Classes
43//
44class LLScrollbar
45: public LLUICtrl
46{
47public:
48 enum ORIENTATION { HORIZONTAL, VERTICAL };
49
50 LLScrollbar(const LLString& name, LLRect rect,
51 ORIENTATION orientation,
52 S32 doc_size, S32 doc_pos, S32 page_size,
53 void(*change_callback)( S32 new_pos, LLScrollbar* self, void* userdata ),
54 void* callback_user_data = NULL,
55 S32 step_size = 1);
56
57 virtual ~LLScrollbar();
58
59 virtual void setValue(const LLSD& value);
60 virtual EWidgetType getWidgetType() const;
61 virtual LLString getWidgetTag() const;
62
63 // Overrides from LLView
64 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
65 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
66 virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
67 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
68 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
69 virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
70 EDragAndDropType cargo_type, void *carge_data, EAcceptance *accept, LLString &tooltip_msg);
71
72 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
73
74 virtual void draw();
75
76 void setDocParams( S32 size, S32 pos );
77
78 // How long the "document" is.
79 void setDocSize( S32 size );
80 S32 getDocSize() { return mDocSize; }
81
82 // How many "lines" the "document" has scrolled.
83 // 0 <= DocPos <= DocSize - DocVisibile
84 void setDocPos( S32 pos );
85 S32 getDocPos() { return mDocPos; }
86
87 // How many "lines" of the "document" is can appear on a page.
88 void setPageSize( S32 page_size );
89 S32 getPageSize() { return mPageSize; }
90
91 // The farthest the document can be scrolled (top of the last page).
92 S32 getDocPosMax() { return llmax( 0, mDocSize - mPageSize); }
93
94 void pageUp(S32 overlap);
95 void pageDown(S32 overlap);
96
97 static void onLineUpBtnPressed(void* userdata);
98 static void onLineDownBtnPressed(void* userdata);
99
100 void setTrackColor( const LLColor4& color ) { mTrackColor = color; }
101 void setThumbColor( const LLColor4& color ) { mThumbColor = color; }
102 void setHighlightColor( const LLColor4& color ) { mHighlightColor = color; }
103 void setShadowColor( const LLColor4& color ) { mShadowColor = color; }
104
105 void setOnScrollEndCallback(void (*callback)(void*), void* userdata) { mOnScrollEndCallback = callback; mOnScrollEndData = userdata;}
106protected:
107 void updateThumbRect();
108 void changeLine(S32 delta, BOOL update_thumb );
109
110protected:
111 void (*mChangeCallback)( S32 new_pos, LLScrollbar* self, void* userdata );
112 void* mCallbackUserData;
113
114 ORIENTATION mOrientation;
115 S32 mDocSize; // Size of the document that the scrollbar is modeling. Units depend on the user. 0 <= mDocSize.
116 S32 mDocPos; // Position within the doc that the scrollbar is modeling, in "lines" (user size)
117 S32 mPageSize; // Maximum number of lines that can be seen at one time.
118 S32 mStepSize;
119 BOOL mDocChanged;
120
121 LLRect mThumbRect;
122 S32 mDragStartX;
123 S32 mDragStartY;
124 F32 mHoverGlowStrength;
125 F32 mCurGlowStrength;
126
127 LLRect mOrigRect;
128 S32 mLastDelta;
129
130 LLColor4 mTrackColor;
131 LLColor4 mThumbColor;
132 LLColor4 mFocusColor;
133 LLColor4 mHighlightColor;
134 LLColor4 mShadowColor;
135
136 void (*mOnScrollEndCallback)(void*);
137 void *mOnScrollEndData;
138};
139
140
141
142#endif // LL_SCROLLBAR_H