diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llui/lltexteditor.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llui/lltexteditor.cpp')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 166 |
1 files changed, 77 insertions, 89 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 545fddb..4ed936f 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -64,6 +64,8 @@ | |||
64 | // | 64 | // |
65 | // Globals | 65 | // Globals |
66 | // | 66 | // |
67 | static LLRegisterWidget<LLTextEditor> r("simple_text_editor"); | ||
68 | |||
67 | BOOL gDebugTextEditorTips = FALSE; | 69 | BOOL gDebugTextEditorTips = FALSE; |
68 | 70 | ||
69 | // | 71 | // |
@@ -304,10 +306,10 @@ LLTextEditor::LLTextEditor( | |||
304 | // Init the scrollbar | 306 | // Init the scrollbar |
305 | LLRect scroll_rect; | 307 | LLRect scroll_rect; |
306 | scroll_rect.setOriginAndSize( | 308 | scroll_rect.setOriginAndSize( |
307 | getRect().getWidth() - UI_TEXTEDITOR_BORDER - SCROLLBAR_SIZE, | 309 | getRect().getWidth() - SCROLLBAR_SIZE, |
308 | UI_TEXTEDITOR_BORDER, | 310 | 1, |
309 | SCROLLBAR_SIZE, | 311 | SCROLLBAR_SIZE, |
310 | getRect().getHeight() - 2 * UI_TEXTEDITOR_BORDER ); | 312 | getRect().getHeight() - 1); |
311 | S32 lines_in_doc = getLineCount(); | 313 | S32 lines_in_doc = getLineCount(); |
312 | mScrollbar = new LLScrollbar( "Scrollbar", scroll_rect, | 314 | mScrollbar = new LLScrollbar( "Scrollbar", scroll_rect, |
313 | LLScrollbar::VERTICAL, | 315 | LLScrollbar::VERTICAL, |
@@ -1102,14 +1104,7 @@ BOOL LLTextEditor::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rec | |||
1102 | BOOL LLTextEditor::handleScrollWheel(S32 x, S32 y, S32 clicks) | 1104 | BOOL LLTextEditor::handleScrollWheel(S32 x, S32 y, S32 clicks) |
1103 | { | 1105 | { |
1104 | // Pretend the mouse is over the scrollbar | 1106 | // Pretend the mouse is over the scrollbar |
1105 | if (getVisible()) | 1107 | return mScrollbar->handleScrollWheel( 0, 0, clicks ); |
1106 | { | ||
1107 | return mScrollbar->handleScrollWheel( 0, 0, clicks ); | ||
1108 | } | ||
1109 | else | ||
1110 | { | ||
1111 | return FALSE; | ||
1112 | } | ||
1113 | } | 1108 | } |
1114 | 1109 | ||
1115 | BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) | 1110 | BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) |
@@ -1197,91 +1192,88 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) | |||
1197 | BOOL handled = FALSE; | 1192 | BOOL handled = FALSE; |
1198 | 1193 | ||
1199 | mHoverSegment = NULL; | 1194 | mHoverSegment = NULL; |
1200 | if( getVisible() ) | 1195 | if(hasMouseCapture() ) |
1201 | { | 1196 | { |
1202 | if(hasMouseCapture() ) | 1197 | if( mIsSelecting ) |
1203 | { | 1198 | { |
1204 | if( mIsSelecting ) | 1199 | if (x != mLastSelectionX || y != mLastSelectionY) |
1205 | { | 1200 | { |
1206 | if (x != mLastSelectionX || y != mLastSelectionY) | 1201 | mLastSelectionX = x; |
1207 | { | 1202 | mLastSelectionY = y; |
1208 | mLastSelectionX = x; | 1203 | } |
1209 | mLastSelectionY = y; | ||
1210 | } | ||
1211 | 1204 | ||
1212 | if( y > mTextRect.mTop ) | 1205 | if( y > mTextRect.mTop ) |
1206 | { | ||
1207 | mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 ); | ||
1208 | } | ||
1209 | else | ||
1210 | if( y < mTextRect.mBottom ) | ||
1211 | { | ||
1212 | mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 ); | ||
1213 | } | ||
1214 | |||
1215 | setCursorAtLocalPos( x, y, TRUE ); | ||
1216 | mSelectionEnd = mCursorPos; | ||
1217 | |||
1218 | updateScrollFromCursor(); | ||
1219 | } | ||
1220 | |||
1221 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; | ||
1222 | getWindow()->setCursor(UI_CURSOR_IBEAM); | ||
1223 | handled = TRUE; | ||
1224 | } | ||
1225 | |||
1226 | if( !handled ) | ||
1227 | { | ||
1228 | // Pass to children | ||
1229 | handled = LLView::childrenHandleHover(x, y, mask) != NULL; | ||
1230 | } | ||
1231 | |||
1232 | if( handled ) | ||
1233 | { | ||
1234 | // Delay cursor flashing | ||
1235 | resetKeystrokeTimer(); | ||
1236 | } | ||
1237 | |||
1238 | // Opaque | ||
1239 | if( !handled && mTakesNonScrollClicks) | ||
1240 | { | ||
1241 | // Check to see if we're over an HTML-style link | ||
1242 | if( !mSegments.empty() ) | ||
1243 | { | ||
1244 | const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); | ||
1245 | if( cur_segment ) | ||
1246 | { | ||
1247 | if(cur_segment->getStyle().isLink()) | ||
1213 | { | 1248 | { |
1214 | mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 ); | 1249 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl; |
1250 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
1251 | handled = TRUE; | ||
1215 | } | 1252 | } |
1216 | else | 1253 | else |
1217 | if( y < mTextRect.mBottom ) | 1254 | if(cur_segment->getStyle().getIsEmbeddedItem()) |
1218 | { | 1255 | { |
1219 | mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 ); | 1256 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl; |
1257 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
1258 | //getWindow()->setCursor(UI_CURSOR_ARROW); | ||
1259 | handled = TRUE; | ||
1220 | } | 1260 | } |
1221 | 1261 | mHoverSegment = cur_segment; | |
1222 | setCursorAtLocalPos( x, y, TRUE ); | ||
1223 | mSelectionEnd = mCursorPos; | ||
1224 | |||
1225 | updateScrollFromCursor(); | ||
1226 | } | 1262 | } |
1227 | |||
1228 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; | ||
1229 | getWindow()->setCursor(UI_CURSOR_IBEAM); | ||
1230 | handled = TRUE; | ||
1231 | } | 1263 | } |
1232 | 1264 | ||
1233 | if( !handled ) | 1265 | if( !handled ) |
1234 | { | 1266 | { |
1235 | // Pass to children | 1267 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; |
1236 | handled = LLView::childrenHandleHover(x, y, mask) != NULL; | 1268 | if (!mScrollbar->getVisible() || x < getRect().getWidth() - SCROLLBAR_SIZE) |
1237 | } | ||
1238 | |||
1239 | if( handled ) | ||
1240 | { | ||
1241 | // Delay cursor flashing | ||
1242 | resetKeystrokeTimer(); | ||
1243 | } | ||
1244 | |||
1245 | // Opaque | ||
1246 | if( !handled && mTakesNonScrollClicks) | ||
1247 | { | ||
1248 | // Check to see if we're over an HTML-style link | ||
1249 | if( !mSegments.empty() ) | ||
1250 | { | 1269 | { |
1251 | const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); | 1270 | getWindow()->setCursor(UI_CURSOR_IBEAM); |
1252 | if( cur_segment ) | ||
1253 | { | ||
1254 | if(cur_segment->getStyle().isLink()) | ||
1255 | { | ||
1256 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl; | ||
1257 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
1258 | handled = TRUE; | ||
1259 | } | ||
1260 | else | ||
1261 | if(cur_segment->getStyle().getIsEmbeddedItem()) | ||
1262 | { | ||
1263 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl; | ||
1264 | getWindow()->setCursor(UI_CURSOR_HAND); | ||
1265 | //getWindow()->setCursor(UI_CURSOR_ARROW); | ||
1266 | handled = TRUE; | ||
1267 | } | ||
1268 | mHoverSegment = cur_segment; | ||
1269 | } | ||
1270 | } | 1271 | } |
1271 | 1272 | else | |
1272 | if( !handled ) | ||
1273 | { | 1273 | { |
1274 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; | 1274 | getWindow()->setCursor(UI_CURSOR_ARROW); |
1275 | if (!mScrollbar->getVisible() || x < getRect().getWidth() - SCROLLBAR_SIZE) | ||
1276 | { | ||
1277 | getWindow()->setCursor(UI_CURSOR_IBEAM); | ||
1278 | } | ||
1279 | else | ||
1280 | { | ||
1281 | getWindow()->setCursor(UI_CURSOR_ARROW); | ||
1282 | } | ||
1283 | handled = TRUE; | ||
1284 | } | 1275 | } |
1276 | handled = TRUE; | ||
1285 | } | 1277 | } |
1286 | } | 1278 | } |
1287 | 1279 | ||
@@ -2154,14 +2146,14 @@ void LLTextEditor::unindentLineBeforeCloseBrace() | |||
2154 | } | 2146 | } |
2155 | 2147 | ||
2156 | 2148 | ||
2157 | BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent ) | 2149 | BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) |
2158 | { | 2150 | { |
2159 | BOOL handled = FALSE; | 2151 | BOOL handled = FALSE; |
2160 | BOOL selection_modified = FALSE; | 2152 | BOOL selection_modified = FALSE; |
2161 | BOOL return_key_hit = FALSE; | 2153 | BOOL return_key_hit = FALSE; |
2162 | BOOL text_may_have_changed = TRUE; | 2154 | BOOL text_may_have_changed = TRUE; |
2163 | 2155 | ||
2164 | if ( (gFocusMgr.getKeyboardFocus() == this) && getVisible()) | 2156 | if ( gFocusMgr.getKeyboardFocus() == this ) |
2165 | { | 2157 | { |
2166 | // Special case for TAB. If want to move to next field, report | 2158 | // Special case for TAB. If want to move to next field, report |
2167 | // not handled and let the parent take care of field movement. | 2159 | // not handled and let the parent take care of field movement. |
@@ -2245,7 +2237,7 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent ) | |||
2245 | } | 2237 | } |
2246 | 2238 | ||
2247 | 2239 | ||
2248 | BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent) | 2240 | BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char) |
2249 | { | 2241 | { |
2250 | if ((uni_char < 0x20) || (uni_char == 0x7F)) // Control character or DEL | 2242 | if ((uni_char < 0x20) || (uni_char == 0x7F)) // Control character or DEL |
2251 | { | 2243 | { |
@@ -2254,7 +2246,7 @@ BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_pare | |||
2254 | 2246 | ||
2255 | BOOL handled = FALSE; | 2247 | BOOL handled = FALSE; |
2256 | 2248 | ||
2257 | if ( (gFocusMgr.getKeyboardFocus() == this) && getVisible()) | 2249 | if ( gFocusMgr.getKeyboardFocus() == this ) |
2258 | { | 2250 | { |
2259 | // Handle most keys only if the text editor is writeable. | 2251 | // Handle most keys only if the text editor is writeable. |
2260 | if( !mReadOnly ) | 2252 | if( !mReadOnly ) |
@@ -2939,8 +2931,8 @@ void LLTextEditor::drawText() | |||
2939 | LLStyle style = cur_segment->getStyle(); | 2931 | LLStyle style = cur_segment->getStyle(); |
2940 | if ( style.isImage() && (cur_segment->getStart() >= seg_start) && (cur_segment->getStart() <= clipped_end)) | 2932 | if ( style.isImage() && (cur_segment->getStart() >= seg_start) && (cur_segment->getStart() <= clipped_end)) |
2941 | { | 2933 | { |
2942 | LLImageGL *image = style.getImage(); | 2934 | LLUIImagePtr image = style.getImage(); |
2943 | gl_draw_scaled_image( llround(text_x), llround(text_y)+line_height-style.mImageHeight, style.mImageWidth, style.mImageHeight, image, LLColor4::white ); | 2935 | image->draw(llround(text_x), llround(text_y)+line_height-style.mImageHeight, style.mImageWidth, style.mImageHeight); |
2944 | } | 2936 | } |
2945 | 2937 | ||
2946 | if (cur_segment == mHoverSegment && style.getIsEmbeddedItem()) | 2938 | if (cur_segment == mHoverSegment && style.getIsEmbeddedItem()) |
@@ -2984,7 +2976,7 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 | |||
2984 | 2976 | ||
2985 | if ( style.getFontString()[0] ) | 2977 | if ( style.getFontString()[0] ) |
2986 | { | 2978 | { |
2987 | font = gResMgr->getRes(style.getFontID()); | 2979 | font = LLResMgr::getInstance()->getRes(style.getFontID()); |
2988 | } | 2980 | } |
2989 | 2981 | ||
2990 | U8 font_flags = LLFontGL::NORMAL; | 2982 | U8 font_flags = LLFontGL::NORMAL; |
@@ -3051,10 +3043,6 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 | |||
3051 | 3043 | ||
3052 | void LLTextEditor::draw() | 3044 | void LLTextEditor::draw() |
3053 | { | 3045 | { |
3054 | if( !getVisible() ) | ||
3055 | { | ||
3056 | return; | ||
3057 | } | ||
3058 | { | 3046 | { |
3059 | LLLocalClipRect clip(LLRect(0, getRect().getHeight(), getRect().getWidth() - (mScrollbar->getVisible() ? SCROLLBAR_SIZE : 0), 0)); | 3047 | LLLocalClipRect clip(LLRect(0, getRect().getHeight(), getRect().getWidth() - (mScrollbar->getVisible() ? SCROLLBAR_SIZE : 0), 0)); |
3060 | 3048 | ||