![]() |
ManaPlus
|
#include <browserbox.h>
Public Types | |
| typedef std::list< std::string > | TextRows |
Public Member Functions | |
| BrowserBox (const Widget2 *const widget, const Opaque opaque, const std::string &skin) | |
| ~BrowserBox () | |
| void | setLinkHandler (LinkHandler *linkHandler) |
| void | setOpaque (Opaque opaque) |
| void | setMaxRow (unsigned max) |
| void | addRow (const std::string &row, const bool atTop) |
| void | addRow (const std::string &cmd, const char *const text) |
| void | addImage (const std::string &path) |
| void | clearRows () |
| void | mousePressed (MouseEvent &event) |
| void | mouseMoved (MouseEvent &event) |
| void | mouseExited (MouseEvent &event) |
| void | draw (Graphics *const graphics) |
| void | safeDraw (Graphics *const graphics) |
| void | updateHeight () |
| void | updateSize (const bool always) |
| TextRows & | getRows () |
| bool | hasRows () const |
| void | setAlwaysUpdate (const bool n) |
| void | setProcessVars (const bool n) |
| void | setEnableImages (const bool n) |
| void | setEnableKeys (const bool n) |
| void | setEnableTabs (const bool n) |
| std::string | getTextAtPos (const int x, const int y) const |
| int | getPadding () const |
| void | setForegroundColorAll (const Color &color1, const Color &color2) |
| unsigned int | getDataWidth () const |
| void | moveSelectionUp () |
| void | moveSelectionDown () |
| void | selectSelection () |
| void | widgetResized (const Event &event) |
Public Member Functions inherited from Widget | |
| Widget (const Widget2 *const widget) | |
| ~Widget () | |
| virtual void | drawFrame (Graphics *graphics) |
| virtual void | safeDrawFrame (Graphics *graphics) |
| void | setFrameSize (const unsigned int frameSize) |
| unsigned int | getFrameSize () const |
| virtual void | logic () |
| Widget * | getParent () const |
| void | setWidth (const int width) |
| int | getWidth () const |
| void | setHeight (const int height) |
| int | getHeight () const |
| void | setSize (const int width, const int height) |
| void | setX (const int x) |
| int | getX () const |
| void | setY (const int y) |
| int | getY () const |
| void | setPosition (const int x, const int y) |
| void | setDimension (const Rect &dimension) |
| const Rect & | getDimension () const |
| void | setFocusable (const bool focusable) |
| bool | isFocusable () const |
| virtual bool | isFocused () const |
| void | setEnabled (const bool enabled) |
| bool | isEnabled () const |
| void | setVisible (Visible visible) |
| bool | isVisible () const |
| void | setBaseColor (const Color &color) |
| const Color & | getBaseColor () const |
| void | setForegroundColor (const Color &color) |
| const Color & | getForegroundColor () const |
| void | setBackgroundColor (const Color &color) |
| const Color & | getBackgroundColor () const |
| virtual void | requestFocus () |
| virtual void | requestMoveToTop () |
| virtual void | requestMoveToBottom () |
| virtual void | setFocusHandler (FocusHandler *const focusHandler) |
| FocusHandler * | getFocusHandler () |
| void | addActionListener (ActionListener *const actionListener) |
| void | removeActionListener (ActionListener *const actionListener) |
| void | addDeathListener (WidgetDeathListener *const deathListener) |
| void | removeDeathListener (WidgetDeathListener *const deathListener) |
| void | addMouseListener (MouseListener *const mouseListener) |
| void | removeMouseListener (MouseListener *const mouseListener) |
| void | addKeyListener (KeyListener *const keyListener) |
| void | removeKeyListener (KeyListener *const keyListener) |
| void | addFocusListener (FocusListener *const focusListener) |
| void | removeFocusListener (FocusListener *const focusListener) |
| void | addWidgetListener (WidgetListener *const widgetListener) |
| void | removeWidgetListener (WidgetListener *const widgetListener) |
| void | setActionEventId (const std::string &actionEventId) |
| const std::string & | getActionEventId () const |
| virtual void | getAbsolutePosition (int &x, int &y) const |
| virtual void | setParent (Widget *parent) |
| Font * | getFont () const |
| void | setFont (Font *const font) |
| virtual void | fontChanged () |
| bool | isTabInEnabled () const |
| void | setTabInEnabled (const bool enabled) |
| bool | isTabOutEnabled () const |
| void | setTabOutEnabled (const bool enabled) |
| void | requestModalFocus () |
| virtual void | requestModalMouseInputFocus () |
| virtual void | releaseModalFocus () |
| virtual void | releaseModalMouseInputFocus () |
| virtual bool | isModalFocused () const |
| virtual bool | isModalMouseInputFocused () const |
| virtual Widget * | getWidgetAt (int x, int y) |
| const std::list< MouseListener * > & | getMouseListeners () const A_CONST |
| const std::list< KeyListener * > & | getKeyListeners () const A_CONST |
| const std::list< FocusListener * > & | getFocusListeners () const A_CONST |
| virtual Rect | getChildrenArea () |
| virtual FocusHandler * | getInternalFocusHandler () |
| void | setInternalFocusHandler (FocusHandler *const internalFocusHandler) |
| virtual void | moveToTop (Widget *widget) |
| virtual void | moveToBottom (Widget *widget) |
| virtual void | focusNext () |
| virtual void | focusPrevious () |
| virtual void | showWidgetPart (Widget *const widget, const Rect &area) |
| void | setId (const std::string &id) |
| const std::string & | getId () const |
| virtual void | showPart (const Rect &rectangle) |
| bool | isAllowLogic () const |
| void | setMouseConsume (const bool b) |
| bool | isMouseConsume () const |
| void | setRedraw (const bool b) |
| virtual bool | isSelectable () const |
| void | setSelectable (const bool selectable) |
| void | windowResized () |
| virtual void | postInit () |
Public Member Functions inherited from Widget2 | |
| virtual | ~Widget2 () |
| const Color & | getThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE |
| const Color & | getThemeCharColor (const signed char c, bool &valid) const A_INLINE |
| virtual void | setWidget2 (const Widget2 *const widget) |
| void | setPalette (int palette) |
| void | checkPalette () |
| void | setForegroundColor2 (const Color &color) |
| Widget * | getWindow () const |
| virtual void | setWindow (Widget *const window) |
Public Member Functions inherited from MouseListener | |
| virtual | ~MouseListener () |
| virtual void | mouseEntered (MouseEvent &event) |
| virtual void | mouseReleased (MouseEvent &event) |
| virtual void | mouseClicked (MouseEvent &event) |
| virtual void | mouseWheelMovedUp (MouseEvent &event) |
| virtual void | mouseWheelMovedDown (MouseEvent &event) |
| virtual void | mouseDragged (MouseEvent &event) |
Public Member Functions inherited from WidgetListener | |
| virtual | ~WidgetListener () |
| virtual void | widgetMoved (const Event &event) |
| virtual void | widgetHidden (const Event &event) |
| virtual void | widgetShown (const Event &event) |
Private Types | |
| typedef TextRows::iterator | TextRowIterator |
| typedef TextRows::const_iterator | TextRowCIter |
| typedef std::vector< LinePart > | LinePartList |
| typedef LinePartList::iterator | LinePartIterator |
| typedef LinePartList::const_iterator | LinePartCIter |
| typedef std::vector< BrowserLink > | Links |
| typedef Links::iterator | LinkIterator |
Private Member Functions | |
| int | calcHeight () |
Private Attributes | |
| TextRows | mTextRows |
| std::list< int > | mTextRowLinksCount |
| LinePartList | mLineParts |
| Links | mLinks |
| LinkHandler * | mLinkHandler |
| Skin * | mSkin |
| unsigned int | mHighlightMode |
| int | mSelectedLink |
| unsigned int | mMaxRows |
| int | mHeight |
| int | mWidth |
| int | mYStart |
| time_t | mUpdateTime |
| int | mPadding |
| unsigned int | mNewLinePadding |
| int | mItemPadding |
| unsigned int | mDataWidth |
| Color | mHighlightColor |
| Color | mHyperLinkColor |
| Color | mColors [2][ColorName::COLORS_MAX] |
| Opaque | mOpaque |
| bool | mUseLinksAndUserColors |
| bool | mUseEmotes |
| bool | mAlwaysUpdate |
| bool | mProcessVars |
| bool | mEnableImages |
| bool | mEnableKeys |
| bool | mEnableTabs |
Static Private Attributes | |
| static ImageSet * | mEmotes = 0 |
| static int | mInstances = 0 |
A simple browser box able to handle links and forward events to the parent conteiner.
Definition at line 48 of file browserbox.h.
|
private |
Definition at line 174 of file browserbox.h.
|
private |
Definition at line 173 of file browserbox.h.
|
private |
Definition at line 172 of file browserbox.h.
|
private |
Definition at line 178 of file browserbox.h.
|
private |
Definition at line 177 of file browserbox.h.
|
private |
Definition at line 168 of file browserbox.h.
|
private |
Definition at line 167 of file browserbox.h.
| typedef std::list<std::string> BrowserBox::TextRows |
Definition at line 122 of file browserbox.h.
| BrowserBox::BrowserBox | ( | const Widget2 *const | widget, |
| const Opaque | opaque, | ||
| const std::string & | skin | ||
| ) |
Constructor.
Definition at line 61 of file browserbox.cpp.
References Widget::addMouseListener(), Widget::addWidgetListener(), LinkHighlightMode::BACKGROUND, ColorName::BLACK, ColorName::BLUE, ColorName::BROWN, CAST_U32, Loader::getImageSet(), Skin::getOption(), Skin::getPadding(), Widget2::getThemeColor(), Theme::getThemePath(), ColorName::GRAY, ColorName::GREEN, Theme::load(), Widget::mAllowLogic, Widget::mBackgroundColor, mEmotes, Widget::mForegroundColor, Widget2::mForegroundColor2, mHighlightMode, mInstances, mItemPadding, mNewLinePadding, mPadding, mSkin, ColorName::ORANGE, ColorName::PINK, ColorName::PURPLE, readColor(), ColorName::RED, Widget::setFocusable(), theme, LinkHighlightMode::UNDERLINE, and ColorName::YELLOW.
| BrowserBox::~BrowserBox | ( | ) |
Destructor.
Definition at line 144 of file browserbox.cpp.
References Resource::decRef(), gui, mEmotes, mInstances, mSkin, Gui::removeDragged(), theme, and Theme::unload().
| void BrowserBox::addImage | ( | const std::string & | path | ) |
Definition at line 350 of file browserbox.cpp.
References mEnableImages, mTextRowLinksCount, and mTextRows.
| void BrowserBox::addRow | ( | const std::string & | cmd, |
| const char *const | text | ||
| ) |
Adds a menu line to the browser.
Definition at line 343 of file browserbox.cpp.
References addRow(), encodeLinkText(), and strprintf().
| void BrowserBox::addRow | ( | const std::string & | row, |
| const bool | atTop | ||
| ) |
Adds a text row to the browser.
Definition at line 171 of file browserbox.cpp.
References BrowserLink::caption, CAST_S32, CAST_SIZE, CAST_U32, FOR_EACH, Widget::getFont(), Font::getHeight(), PoDict::getStr(), Widget::getWidth(), Font::getWidth(), BrowserLink::link, mEnableKeys, mEnableTabs, mLinks, mMaxRows, mNewLinePadding, mProcessVars, mTextRowLinksCount, mTextRows, mUpdateTime, mUseLinksAndUserColors, BrowserBoxTools::replaceKeys(), BrowserBoxTools::replaceLinkCommands(), BrowserBoxTools::replaceTabs(), BrowserBoxTools::replaceVars(), Widget::setHeight(), translator, updateHeight(), x, BrowserLink::x1, BrowserLink::x2, y, BrowserLink::y1, and BrowserLink::y2.
Referenced by addRow(), ChatTab::addRow(), NpcDialog::addText(), NpcDialog::createSkinControls(), and QuestsWindow::showQuest().
|
private |
Definition at line 495 of file browserbox.cpp.
References ColorName::BLACK, ColorName::BLUE, boldFont, ColorName::BROWN, CAST_S32, CAST_S8, CAST_SIZE, CAST_U32, FOR_EACH, ImageSet::get(), Widget::getFont(), Font::getHeight(), Loader::getImage(), Widget2::getThemeCharColor(), Font::getWidth(), ColorName::GRAY, ColorName::GREEN, mColors, mDataWidth, Widget::mDimension, mEmotes, mEnableImages, Widget::mForegroundColor, Widget2::mForegroundColor2, mItemPadding, mLineParts, mLinks, mNewLinePadding, mPadding, mTextRows, mUseEmotes, mUseLinksAndUserColors, ColorName::ORANGE, ColorName::PINK, ColorName::PURPLE, ColorName::RED, Widget::setWidth(), EmoteDB::size(), ImageSet::size(), anonymous_namespace{stringutils.cpp}::start, anonymous_namespace{libxml.cpp}::valid, Rect::width, x, BrowserLink::x1, BrowserLink::x2, y, BrowserLink::y1, BrowserLink::y2, and ColorName::YELLOW.
Referenced by draw(), and updateHeight().
| void BrowserBox::clearRows | ( | ) |
Remove all rows.
Definition at line 359 of file browserbox.cpp.
References mDataWidth, mLinks, mSelectedLink, mTextRowLinksCount, mTextRows, mUpdateTime, Widget::setHeight(), Widget::setWidth(), and updateHeight().
Referenced by NpcDialog::action(), NpcDialog::clearRows(), ChatTab::clearText(), QuestsWindow::showQuest(), and Setup_Colors::valueChanged().
|
virtual |
Draws the browser box.
Implements Widget.
Definition at line 401 of file browserbox.cpp.
References LinkHighlightMode::BACKGROUND, BLOCK_END, BLOCK_START, boldFont, calcHeight(), CAST_S32, CAST_SIZE, cur_time, Graphics::drawImage(), Graphics::drawLine(), Font::drawString(), Graphics::fillRectangle(), FOR_EACH, Widget::getFont(), Graphics::getTopClip(), Rect::height, Widget::mBackgroundColor, LinePart::mBold, LinePart::mColor, LinePart::mColor2, Widget::mDimension, mHeight, mHighlightColor, mHighlightMode, mHyperLinkColor, LinePart::mImage, mLineParts, mLinks, mOpaque, mSelectedLink, LinePart::mText, LinePart::mType, mUpdateTime, mWidth, LinePart::mX, LinePart::mY, mYStart, Opaque_true, reportAlways, Graphics::setColor(), Widget::setHeight(), LinkHighlightMode::UNDERLINE, Rect::width, BrowserLink::x1, BrowserLink::x2, Rect::y, BrowserLink::y1, BrowserLink::y2, and ClipRect::yOffset.
Referenced by safeDraw().
|
inline |
|
inline |
|
inline |
Definition at line 124 of file browserbox.h.
References mTextRows.
Referenced by ChatTab::getRows().
| std::string BrowserBox::getTextAtPos | ( | const int | x, |
| const int | y | ||
| ) | const |
Definition at line 870 of file browserbox.cpp.
References FOR_EACH, Widget::getAbsolutePosition(), mLineParts, LinePart::mText, LinePart::mY, mYStart, x, and y.
Referenced by ChatWindow::copyToClipboard(), and NpcDialog::copyToClipboard().
|
inline |
Definition at line 127 of file browserbox.h.
References mTextRows.
Referenced by ChatTab::hasRows().
|
virtual |
Called when the mouse has exited the widget area.
| event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 396 of file browserbox.cpp.
References mSelectedLink.
|
virtual |
Called when the mouse has moved in the widget area and no mouse button has been pressed (i.e no widget is being dragged).
| event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 387 of file browserbox.cpp.
References CAST_S32, MouseEvent::getX(), MouseEvent::getY(), mLinks, and mSelectedLink.
|
virtual |
Handles mouse actions.
Reimplemented from MouseListener.
Definition at line 372 of file browserbox.cpp.
References MouseEvent::getX(), MouseEvent::getY(), LinkHandler::handleLink(), mLinkHandler, and mLinks.
| void BrowserBox::moveSelectionDown | ( | ) |
| void BrowserBox::moveSelectionUp | ( | ) |
|
virtual |
| void BrowserBox::selectSelection | ( | ) |
Definition at line 927 of file browserbox.cpp.
References CAST_SIZE, LinkHandler::handleLink(), mLinkHandler, mLinks, and mSelectedLink.
|
inline |
Definition at line 130 of file browserbox.h.
References mAlwaysUpdate.
Referenced by ChatTab::ChatTab().
|
inline |
Definition at line 136 of file browserbox.h.
References mEnableImages.
Referenced by NpcDialog::NpcDialog().
|
inline |
Definition at line 139 of file browserbox.h.
References mEnableKeys.
Referenced by NpcDialog::createSkinControls(), and NpcDialog::NpcDialog().
|
inline |
Definition at line 142 of file browserbox.h.
References mEnableTabs.
Referenced by NpcDialog::createSkinControls(), and NpcDialog::NpcDialog().
Definition at line 905 of file browserbox.cpp.
References Widget::mForegroundColor, and Widget2::mForegroundColor2.
| void BrowserBox::setLinkHandler | ( | LinkHandler * | linkHandler | ) |
Sets the handler for links.
Definition at line 166 of file browserbox.cpp.
References mLinkHandler.
Referenced by ChatTab::ChatTab(), NpcDialog::createSkinControls(), NpcDialog::NpcDialog(), QuestsWindow::QuestsWindow(), and Setup_Colors::Setup_Colors().
|
inline |
Sets the maximum numbers of rows in the browser box. 0 = no limit.
Definition at line 81 of file browserbox.h.
References mMaxRows.
Referenced by ChatTab::chatLog(), ChatTab::ChatTab(), NpcDialog::createSkinControls(), and NpcDialog::NpcDialog().
|
inline |
Sets the BrowserBox opacity.
Definition at line 75 of file browserbox.h.
References mOpaque.
Referenced by ChatTab::ChatTab(), NpcDialog::createSkinControls(), NpcDialog::NpcDialog(), QuestsWindow::QuestsWindow(), and Setup_Colors::Setup_Colors().
|
inline |
Definition at line 133 of file browserbox.h.
References mProcessVars.
Referenced by NpcDialog::createSkinControls(), and NpcDialog::NpcDialog().
| void BrowserBox::updateHeight | ( | ) |
Definition at line 851 of file browserbox.cpp.
References calcHeight(), cur_time, mAlwaysUpdate, Widget::mDimension, mHeight, mTextRows, mUpdateTime, mWidth, Widget::setHeight(), and Rect::width.
Referenced by addRow(), clearRows(), QuestsWindow::showQuest(), updateSize(), and widgetResized().
| void BrowserBox::updateSize | ( | const bool | always | ) |
Definition at line 863 of file browserbox.cpp.
References mUpdateTime, and updateHeight().
Referenced by ChatTab::ChatTab().
|
virtual |
Invoked when a widget changes its size.
| event | Describes the event. |
Reimplemented from WidgetListener.
Definition at line 940 of file browserbox.cpp.
References updateHeight().
|
private |
Definition at line 202 of file browserbox.h.
Referenced by setAlwaysUpdate(), and updateHeight().
|
private |
Definition at line 197 of file browserbox.h.
Referenced by calcHeight().
|
private |
Definition at line 193 of file browserbox.h.
Referenced by calcHeight(), clearRows(), and getDataWidth().
|
staticprivate |
Definition at line 208 of file browserbox.h.
Referenced by BrowserBox(), calcHeight(), and ~BrowserBox().
|
private |
Definition at line 204 of file browserbox.h.
Referenced by addImage(), calcHeight(), and setEnableImages().
|
private |
Definition at line 205 of file browserbox.h.
Referenced by addRow(), and setEnableKeys().
|
private |
Definition at line 206 of file browserbox.h.
Referenced by addRow(), and setEnableTabs().
|
private |
Definition at line 186 of file browserbox.h.
Referenced by draw(), and updateHeight().
|
private |
Definition at line 195 of file browserbox.h.
Referenced by draw().
|
private |
Definition at line 183 of file browserbox.h.
Referenced by BrowserBox(), and draw().
|
private |
Definition at line 196 of file browserbox.h.
Referenced by draw().
|
staticprivate |
Definition at line 209 of file browserbox.h.
Referenced by BrowserBox(), and ~BrowserBox().
|
private |
Definition at line 192 of file browserbox.h.
Referenced by BrowserBox(), and calcHeight().
|
private |
Definition at line 175 of file browserbox.h.
Referenced by calcHeight(), draw(), and getTextAtPos().
|
private |
Definition at line 181 of file browserbox.h.
Referenced by mousePressed(), selectSelection(), and setLinkHandler().
|
private |
Definition at line 179 of file browserbox.h.
Referenced by addRow(), calcHeight(), clearRows(), draw(), mouseMoved(), mousePressed(), moveSelectionDown(), moveSelectionUp(), and selectSelection().
|
private |
Definition at line 185 of file browserbox.h.
Referenced by addRow(), and setMaxRow().
|
private |
Definition at line 191 of file browserbox.h.
Referenced by addRow(), BrowserBox(), and calcHeight().
|
private |
Definition at line 199 of file browserbox.h.
Referenced by draw(), and setOpaque().
|
private |
Definition at line 190 of file browserbox.h.
Referenced by BrowserBox(), calcHeight(), and getPadding().
|
private |
Definition at line 203 of file browserbox.h.
Referenced by addRow(), and setProcessVars().
|
private |
Definition at line 184 of file browserbox.h.
Referenced by clearRows(), draw(), mouseExited(), mouseMoved(), moveSelectionDown(), moveSelectionUp(), and selectSelection().
|
private |
Definition at line 182 of file browserbox.h.
Referenced by BrowserBox(), and ~BrowserBox().
|
private |
Definition at line 170 of file browserbox.h.
Referenced by addImage(), addRow(), and clearRows().
|
private |
Definition at line 169 of file browserbox.h.
Referenced by addImage(), addRow(), calcHeight(), clearRows(), getRows(), hasRows(), and updateHeight().
|
private |
Definition at line 189 of file browserbox.h.
Referenced by addRow(), clearRows(), draw(), updateHeight(), and updateSize().
|
private |
Definition at line 201 of file browserbox.h.
Referenced by calcHeight().
|
private |
Definition at line 200 of file browserbox.h.
Referenced by addRow(), and calcHeight().
|
private |
Definition at line 187 of file browserbox.h.
Referenced by draw(), and updateHeight().
|
private |
Definition at line 188 of file browserbox.h.
Referenced by draw(), and getTextAtPos().