From 1e0089c27a40a138bee5b33f4ec9cff63d388119 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Thu, 4 Mar 2010 15:42:11 -0700 Subject: Added menus from BetterNotecardFloater Cool Viewer patch. Patch by Henri Beauchamp. (slviewer-0-v12350-BetterNotecardFloater.patch) --- linden/indra/newview/llpreviewnotecard.cpp | 221 +++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) (limited to 'linden/indra/newview/llpreviewnotecard.cpp') diff --git a/linden/indra/newview/llpreviewnotecard.cpp b/linden/indra/newview/llpreviewnotecard.cpp index 04f8004..4260434 100644 --- a/linden/indra/newview/llpreviewnotecard.cpp +++ b/linden/indra/newview/llpreviewnotecard.cpp @@ -60,6 +60,7 @@ #include "llviewercontrol.h" // gSavedSettings #include "llappviewer.h" // app_abort_quit() #include "lllineeditor.h" +#include "llmenugl.h" #include "lluictrlfactory.h" ///---------------------------------------------------------------------------- @@ -146,6 +147,8 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name, editor->setSourceID(item_id); editor->setHandleEditKeysDirectly(TRUE); } + + initMenu(); } LLPreviewNotecard::~LLPreviewNotecard() @@ -659,4 +662,222 @@ LLTextEditor* LLPreviewNotecard::getEditor() return getChild("Notecard Editor"); } +void LLPreviewNotecard::initMenu() +{ + LLMenuItemCallGL* menuItem = getChild("Undo"); + menuItem->setMenuCallback(onUndoMenu, this); + menuItem->setEnabledCallback(enableUndoMenu); + + menuItem = getChild("Redo"); + menuItem->setMenuCallback(onRedoMenu, this); + menuItem->setEnabledCallback(enableRedoMenu); + + menuItem = getChild("Cut"); + menuItem->setMenuCallback(onCutMenu, this); + menuItem->setEnabledCallback(enableCutMenu); + + menuItem = getChild("Copy"); + menuItem->setMenuCallback(onCopyMenu, this); + menuItem->setEnabledCallback(enableCopyMenu); + + menuItem = getChild("Paste"); + menuItem->setMenuCallback(onPasteMenu, this); + menuItem->setEnabledCallback(enablePasteMenu); + + menuItem = getChild("Select All"); + menuItem->setMenuCallback(onSelectAllMenu, this); + menuItem->setEnabledCallback(enableSelectAllMenu); + + menuItem = getChild("Deselect"); + menuItem->setMenuCallback(onDeselectMenu, this); + menuItem->setEnabledCallback(enableDeselectMenu); + + menuItem = getChild("Search / Replace..."); + menuItem->setMenuCallback(onSearchMenu, this); + menuItem->setEnabledCallback(NULL); +} + +// static +void LLPreviewNotecard::onSearchMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + LLFloaterSearchReplace::show(editor); + } + } +} + +// static +void LLPreviewNotecard::onUndoMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + editor->undo(); + } + } +} + +// static +void LLPreviewNotecard::onRedoMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + editor->redo(); + } + } +} + +// static +void LLPreviewNotecard::onCutMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + editor->cut(); + } + } +} + +// static +void LLPreviewNotecard::onCopyMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + editor->copy(); + } + } +} + +// static +void LLPreviewNotecard::onPasteMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + editor->paste(); + } + } +} + +// static +void LLPreviewNotecard::onSelectAllMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + editor->selectAll(); + } + } +} + +// static +void LLPreviewNotecard::onDeselectMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (self) + { + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (editor) + { + editor->deselect(); + } + } +} + +// static +BOOL LLPreviewNotecard::enableUndoMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (!self) return FALSE; + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (!editor) return FALSE; + return editor->canUndo(); +} + +// static +BOOL LLPreviewNotecard::enableRedoMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (!self) return FALSE; + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (!editor) return FALSE; + return editor->canRedo(); +} + +// static +BOOL LLPreviewNotecard::enableCutMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (!self) return FALSE; + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (!editor) return FALSE; + return editor->canCut(); +} + +// static +BOOL LLPreviewNotecard::enableCopyMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (!self) return FALSE; + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (!editor) return FALSE; + return editor->canCopy(); +} + +// static +BOOL LLPreviewNotecard::enablePasteMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (!self) return FALSE; + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (!editor) return FALSE; + return editor->canPaste(); +} + +// static +BOOL LLPreviewNotecard::enableSelectAllMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (!self) return FALSE; + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (!editor) return FALSE; + return editor->canSelectAll(); +} + +// static +BOOL LLPreviewNotecard::enableDeselectMenu(void* userdata) +{ + LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + if (!self) return FALSE; + LLViewerTextEditor* editor = self->getChild("Notecard Editor"); + if (!editor) return FALSE; + return editor->canDeselect(); +} + + // EOF -- cgit v1.1