guiBubbleTextCtrl.cpp
Engine/source/gui/utility/guiBubbleTextCtrl.cpp
Public Functions
ConsoleDocClass(GuiBubbleTextCtrl , "@brief A single-line text <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> that displays its text in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> multi-line popup when <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">clicked.\n\n</a>" "This <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> acts like <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classguitextctrl/">GuiTextCtrl</a> , when clicked it creates <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classguimltextctrl/">GuiMLTextCtrl</a> " "roughly where you clicked with the same text in it. This allows you <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> have <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> single line text <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> " "which upon clicking will display the entire text contained in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> multi-line <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">format.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguibubbletextctrl/">GuiBubbleTextCtrl</a>(BubbleTextGUI)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " text=\"This is the first sentence. This second sentence can be sized outside of the default single " "line view, upon clicking this will be displayed in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> multi-line format.\";\n" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiTextCtrl\n</a>" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiMLTextCtrl\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControls\n</a>" )
Detailed Description
Public Functions
ConsoleDocClass(GuiBubbleTextCtrl , "@brief A single-line text <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> that displays its text in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> multi-line popup when <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">clicked.\n\n</a>" "This <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> acts like <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classguitextctrl/">GuiTextCtrl</a> , when clicked it creates <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classguimltextctrl/">GuiMLTextCtrl</a> " "roughly where you clicked with the same text in it. This allows you <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> have <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> single line text <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> " "which upon clicking will display the entire text contained in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> multi-line <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">format.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguibubbletextctrl/">GuiBubbleTextCtrl</a>(BubbleTextGUI)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " text=\"This is the first sentence. This second sentence can be sized outside of the default single " "line view, upon clicking this will be displayed in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> multi-line format.\";\n" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiTextCtrl\n</a>" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiMLTextCtrl\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControls\n</a>" )
IMPLEMENT_CONOBJECT(GuiBubbleTextCtrl )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "gui/utility/guiBubbleTextCtrl.h" 25#include "gui/core/guiCanvas.h" 26 27IMPLEMENT_CONOBJECT(GuiBubbleTextCtrl); 28 29ConsoleDocClass( GuiBubbleTextCtrl, 30 "@brief A single-line text control that displays its text in a multi-line popup when clicked.\n\n" 31 32 "This control acts like a GuiTextCtrl (and inherits from it), when clicked it creates a GuiMLTextCtrl " 33 "roughly where you clicked with the same text in it. This allows you to have a single line text control " 34 "which upon clicking will display the entire text contained in a multi-line format.\n\n" 35 36 "@tsexample\n" 37 "new GuiBubbleTextCtrl(BubbleTextGUI)\n" 38 "{\n" 39 " text = \"This is the first sentence. This second sentence can be sized outside of the default single " 40 "line view, upon clicking this will be displayed in a multi-line format.\";\n" 41 "};\n" 42 "@endtsexample\n\n" 43 44 "@see GuiTextCtrl\n" 45 "@see GuiMLTextCtrl\n\n" 46 47 "@ingroup GuiControls\n" 48); 49 50//------------------------------------------------------------------------------ 51void GuiBubbleTextCtrl::popBubble() 52{ 53 // Release the mouse: 54 mInAction = false; 55 mouseUnlock(); 56 57 // Pop the dialog 58 getRoot()->popDialogControl(mDlg); 59 60 // Kill the popup 61 mDlg->removeObject(mPopup); 62 mPopup->removeObject(mMLText); 63 mMLText->deleteObject(); 64 mPopup->deleteObject(); 65 mDlg->deleteObject(); 66} 67 68//------------------------------------------------------------------------------ 69void GuiBubbleTextCtrl::onMouseDown(const GuiEvent &event) 70{ 71 if (mInAction) 72 { 73 popBubble(); 74 75 return; 76 } 77 78 mDlg = new GuiControl(); 79 AssertFatal(mDlg, "Failed to create the GuiControl for the BubbleTextCtrl"); 80 mDlg->setDataField( StringTable->insert("profile"), NULL, "GuiModelessDialogProfile"); 81 mDlg->setField("horizSizing", "width"); 82 mDlg->setField("vertSizing", "height"); 83 mDlg->setField("extent", "640 480"); 84 85 mPopup = new GuiControl(); 86 AssertFatal(mPopup, "Failed to create the GuiControl for the BubbleTextCtrl"); 87 mPopup->setDataField( StringTable->insert("profile"), NULL, "GuiBubblePopupProfile"); 88 89 mMLText = new GuiMLTextCtrl(); 90 AssertFatal(mMLText, "Failed to create the GuiMLTextCtrl for the BubbleTextCtrl"); 91 mMLText->setDataField( StringTable->insert("profile"), NULL, "GuiBubbleTextProfile"); 92 mMLText->setField("position", "2 2"); 93 mMLText->setField("extent", "296 51"); 94 95 mMLText->setText((char*)mText,dStrlen(mText)); 96 97 mMLText->registerObject(); 98 mPopup->registerObject(); 99 mDlg->registerObject(); 100 101 mPopup->addObject(mMLText); 102 mDlg->addObject(mPopup); 103 104 mPopup->resize(event.mousePoint,Point2I(300,55)); 105 106 getRoot()->pushDialogControl(mDlg,0); 107 mouseLock(); 108 109 mInAction = true; 110} 111