ManaPlus
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

#include <shortcutwindow.h>

Inheritance diagram for ShortcutWindow:
Window BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 ShortcutWindow (const std::string &title, ShortcutContainer *const content, const std::string &skinFile, int width, int height)
 
 ShortcutWindow (const std::string &title, const std::string &skinFile, const int width, const int height)
 
 ~ShortcutWindow ()
 
void addTab (const std::string &name, ShortcutContainer *const content)
 
int getTabIndex () const
 
void widgetHidden (const Event &event)
 
void widgetMoved (const Event &event)
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void nextTab ()
 
void prevTab ()
 
void addButton (const std::string &text, const std::string &eventName, ActionListener *const listener)
 
- Public Member Functions inherited from Window
 Window (const std::string &caption, const Modal modal, Window *const parent, std::string skin)
 
 ~Window ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX, int offsetY)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetResized (const Event &event)
 
void setCloseButton (const bool flag)
 
bool getCloseButton () const
 
void setAllowClose (const bool b)
 
bool getAlowClose () const
 
bool isResizable () const
 
void setMinWidth (const int width)
 
int getMinWidth () const
 
void setMinHeight (const int height)
 
int getMinHeight () const
 
void setMaxWidth (const int width)
 
int getMaxWidth () const
 
void setMaxHeight (const int height)
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 
void setStickyButton (const bool flag)
 
void setSticky (const bool sticky)
 
bool isSticky () const
 
void setStickyButtonLock (const bool sticky)
 
bool isStickyButtonLock () const
 
virtual void setVisible (Visible visible)
 
void setVisible (const Visible visible, const bool forceSticky)
 
bool isDefaultVisible () const
 
void setDefaultVisible (const bool save)
 
bool willSaveVisible () const
 
void setSaveVisible (const bool save)
 
void postInit ()
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
void mouseMoved (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void mouseEntered (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- 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
 
WidgetgetParent () 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 RectgetDimension () 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 ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
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)
 
FontgetFont () 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
 
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 FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
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 ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (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)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 

Private Member Functions

 ShortcutWindow ()
 

Private Attributes

ShortcutContainermItems
 
ScrollAreamScrollArea
 
TabbedAreamTabs
 
std::vector< ShortcutContainer * > mPages
 
int mButtonIndex
 

Static Private Attributes

static int mBoxesWidth = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *const windowContainer)
 
- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Window
bool canMove () const
 
int getOption (const std::string &name, const int def) const
 
bool getOptionBool (const std::string &name, const bool def) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Attributes inherited from Window
std::string mCaption
 
Graphics::Alignment mAlignment
 
int mPadding
 
unsigned int mTitleBarHeight
 
Move mMovable
 
int mDragOffsetX
 
int mDragOffsetY
 
bool mMoved
 
SkinmSkin
 
int mDefaultX
 
int mDefaultY
 
int mDefaultWidth
 
int mDefaultHeight
 
int mCaptionOffsetX
 
int mCaptionOffsetY
 
bool mShowTitle
 
bool mLastRedraw
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A window around a ShortcutContainer.

Definition at line 38 of file shortcutwindow.h.

Constructor & Destructor Documentation

◆ ShortcutWindow() [1/3]

ShortcutWindow::ShortcutWindow ( const std::string &  title,
ShortcutContainer *const  content,
const std::string &  skinFile,
int  width,
int  height 
)

Constructor.

Definition at line 52 of file shortcutwindow.cpp.

55  :
56  Window("Window", Modal_false, nullptr, skinFile),
57  mItems(content),
58  mScrollArea(new ScrollArea(this, mItems, Opaque_false, std::string())),
59  mTabs(nullptr),
60  mPages(),
61  mButtonIndex(0)
62 {
63  setWindowName(title);
65 
66  setShowTitle(false);
67  setResizable(true);
68  setDefaultVisible(false);
69  setSaveVisible(true);
70  setAllowClose(true);
71 
72  mDragOffsetX = 0;
73  mDragOffsetY = 0;
74 
75  if (content != nullptr)
76  content->setSkin(this, mSkin);
77  if (setupWindow != nullptr)
79 
80  setMinWidth(32);
81  setMinHeight(32);
82  if (mItems != nullptr)
83  {
84  const int border = SCROLL_PADDING * 2 + getPadding() * 2;
85  const int bw = mItems->getBoxWidth();
86  const int bh = mItems->getBoxHeight();
87  const int maxItems = mItems->getMaxItems();
88  setMaxWidth(bw * maxItems + border);
89  setMaxHeight(bh * maxItems + border);
90 
91  if (width == 0)
92  width = bw + border;
93  if (height == 0)
94  height = bh * maxItems + border;
95 
96  setDefaultSize(width, height, ImagePosition::LOWER_RIGHT, 0, 0);
97 
98  mBoxesWidth += bw + border;
99  }
100 
103 
104  place(0, 0, mScrollArea, 5, 5).setPadding(0);
105 
106  Layout &layout = getLayout();
107  layout.setRowHeight(0, LayoutType::SET);
108  layout.setMargin(0);
109 
110  loadWindowState();
111  enableVisibleSound(true);
112 }
LayoutCell & setPadding(int p)
Definition: layoutcell.h:60
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:128
Definition: layout.h:45
void setMargin(int m)
Definition: layout.h:54
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void registerWindowForReset(Window *const window)
virtual void setSkin(const Widget2 *const widget, Skin *const skin)
int getBoxHeight() const
int getMaxItems() const
int getBoxWidth() const
TabbedArea * mTabs
ScrollArea * mScrollArea
std::vector< ShortcutContainer * > mPages
ShortcutContainer * mItems
static int mBoxesWidth
void setPosition(const int x, const int y)
Definition: widget.cpp:161
int mDragOffsetY
Definition: window.h:642
void setSaveVisible(const bool save)
Definition: window.h:300
void setResizable(const bool resize)
Definition: window.cpp:627
void setMaxWidth(const int width)
Definition: window.cpp:617
void setAllowClose(const bool b)
Definition: window.h:189
Skin * mSkin
Definition: window.h:649
int getTitlePadding() const
Definition: window.h:602
Layout & getLayout()
Definition: window.cpp:1365
void setWindowName(const std::string &name)
Definition: window.h:355
int mDragOffsetX
Definition: window.h:635
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
void setMinHeight(const int height)
Definition: window.cpp:604
void setMaxHeight(const int height)
Definition: window.cpp:622
void setMinWidth(const int width)
Definition: window.cpp:591
int getPadding() const
Definition: window.h:504
void enableVisibleSound(bool b)
Definition: window.h:481
void setShowTitle(bool flag)
Definition: window.h:235
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1384
void setDefaultVisible(const bool save)
Definition: window.h:288
void setDefaultSize()
Definition: window.cpp:1198
void loadWindowState()
Definition: window.cpp:1087
void setTitleBarHeight(unsigned int height)
Definition: window.h:513
const bool Modal_false
Definition: modal.h:30
const bool Opaque_false
Definition: opaque.h:30
SetupWindow * setupWindow
Definition: setupwindow.cpp:64
static const int SCROLL_PADDING

References Window::enableVisibleSound(), ShortcutContainer::getBoxHeight(), ShortcutContainer::getBoxWidth(), Window::getLayout(), ShortcutContainer::getMaxItems(), Window::getPadding(), Window::getTitlePadding(), Window::loadWindowState(), ImagePosition::LOWER_RIGHT, mBoxesWidth, Window::mDragOffsetX, Window::mDragOffsetY, mItems, mScrollArea, Window::mSkin, Window::place(), SetupWindow::registerWindowForReset(), SCROLL_PADDING, LayoutType::SET, Window::setAllowClose(), Window::setDefaultSize(), Window::setDefaultVisible(), ScrollArea::setHorizontalScrollPolicy(), Layout::setMargin(), Window::setMaxHeight(), Window::setMaxWidth(), Window::setMinHeight(), Window::setMinWidth(), LayoutCell::setPadding(), Widget::setPosition(), Window::setResizable(), LayoutCell::setRowHeight(), Window::setSaveVisible(), Window::setShowTitle(), Window::setTitleBarHeight(), setupWindow, Window::setWindowName(), and ScrollArea::SHOW_NEVER.

◆ ShortcutWindow() [2/3]

ShortcutWindow::ShortcutWindow ( const std::string &  title,
const std::string &  skinFile,
const int  width,
const int  height 
)

Definition at line 114 of file shortcutwindow.cpp.

116  :
117  Window("Window", Modal_false, nullptr, skinFile),
118  mItems(nullptr),
119  mScrollArea(nullptr),
121  mPages(),
122  mButtonIndex(0)
123 {
124  setWindowName(title);
126  setShowTitle(false);
127  setResizable(true);
128  setDefaultVisible(false);
129  setSaveVisible(true);
130  setAllowClose(true);
131 
132  mDragOffsetX = 0;
133  mDragOffsetY = 0;
134 
135  if (setupWindow != nullptr)
137 
138  if ((width != 0) && (height != 0))
139  setDefaultSize(width, height, ImagePosition::LOWER_RIGHT, 0, 0);
140 
141  setMinWidth(32);
142  setMinHeight(32);
143 
144  place(0, 0, mTabs, 5, 5);
145 
146  Layout &layout = getLayout();
147  layout.setRowHeight(0, LayoutType::SET);
148  layout.setMargin(0);
149 
150  loadWindowState();
151  enableVisibleSound(true);
152 }
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36

References Window::enableVisibleSound(), Window::getLayout(), Window::getPadding(), Window::getTitlePadding(), Window::loadWindowState(), ImagePosition::LOWER_RIGHT, Window::mDragOffsetX, Window::mDragOffsetY, mTabs, Window::place(), SetupWindow::registerWindowForReset(), LayoutType::SET, Window::setAllowClose(), Window::setDefaultSize(), Window::setDefaultVisible(), Layout::setMargin(), Window::setMinHeight(), Window::setMinWidth(), Window::setResizable(), LayoutCell::setRowHeight(), Window::setSaveVisible(), Window::setShowTitle(), Window::setTitleBarHeight(), setupWindow, and Window::setWindowName().

◆ ~ShortcutWindow()

ShortcutWindow::~ShortcutWindow ( )

Destructor.

Definition at line 154 of file shortcutwindow.cpp.

155 {
156  if (mTabs != nullptr)
157  mTabs->removeAll(true);
158  delete2(mTabs)
159  delete2(mItems)
160 }
void removeAll(const bool del)
Definition: tabbedarea.cpp:730
#define delete2(var)
Definition: delete2.h:25

References delete2, mItems, mTabs, and TabbedArea::removeAll().

◆ ShortcutWindow() [3/3]

ShortcutWindow::ShortcutWindow ( )
private

Member Function Documentation

◆ addButton()

void ShortcutWindow::addButton ( const std::string &  text,
const std::string &  eventName,
ActionListener *const  listener 
)

Definition at line 162 of file shortcutwindow.cpp.

165 {
167  5,
168  new Button(this, text, eventName, BUTTON_SKIN, listener),
169  1,
170  1);
171  Window::widgetResized(Event(nullptr));
172 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
Definition: event.h:79
void widgetResized(const Event &event)
Definition: window.cpp:655

References BUTTON_SKIN, anonymous_namespace{itemlinkhandler.cpp}::listener, mButtonIndex, Window::place(), and Window::widgetResized().

◆ addTab()

void ShortcutWindow::addTab ( const std::string &  name,
ShortcutContainer *const  content 
)

Definition at line 174 of file shortcutwindow.cpp.

176 {
177  if ((content == nullptr) || (mTabs == nullptr))
178  return;
179  ScrollArea *const scroll = new ScrollArea(this,
180  content,
181  Opaque_false,
182  std::string());
185  content->setSkin(this, mSkin);
186  Tab *const tab = new ShortcutTab(this, name, content);
187  mTabs->addTab(tab, scroll);
188  mPages.push_back(content);
189 }
Definition: tab.h:88
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:238

References TabbedArea::addTab(), mPages, Window::mSkin, mTabs, Opaque_false, SCROLL_PADDING, ScrollArea::setHorizontalScrollPolicy(), Widget::setPosition(), ShortcutContainer::setSkin(), and ScrollArea::SHOW_NEVER.

Referenced by createGuiWindows().

◆ getTabIndex()

int ShortcutWindow::getTabIndex ( ) const

Definition at line 191 of file shortcutwindow.cpp.

192 {
193  if (mTabs == nullptr)
194  return 0;
195  return mTabs->getSelectedTabIndex();
196 }
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:449

References TabbedArea::getSelectedTabIndex(), and mTabs.

Referenced by SkillDialog::action(), ItemContainer::mousePressed(), and SpellShortcutContainer::mouseReleased().

◆ mouseDragged()

void ShortcutWindow::mouseDragged ( MouseEvent event)
virtual

Implements window resizing and makes sure the window is not dragged/resized outside of the screen.

Reimplemented from Window.

Definition at line 232 of file shortcutwindow.cpp.

233 {
234  Window::mouseDragged(event);
235 
236  if (event.isConsumed())
237  return;
238 
239  if (canMove() && isMovable() && mMoved)
240  {
241  int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
242  int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
243  newX = std::min(mainGraphics->mWidth - getWidth(), newX);
244  newY = std::min(mainGraphics->mHeight - getHeight(), newY);
245  setPosition(newX, newY);
246  }
247 }
int mWidth
Definition: graphics.h:484
int mHeight
Definition: graphics.h:485
bool isConsumed() const
int getX() const
Definition: mouseevent.h:127
int getY() const
Definition: mouseevent.h:138
int getY() const
Definition: widget.h:288
int getX() const
Definition: widget.h:269
int getHeight() const
Definition: widget.h:240
int getWidth() const
Definition: widget.h:221
bool mMoved
Definition: window.h:647
void mouseDragged(MouseEvent &event)
Definition: window.cpp:982
bool canMove() const
Definition: window.cpp:977
bool isMovable() const
Definition: window.h:576
Graphics * mainGraphics
Definition: graphics.cpp:109

References Window::canMove(), Widget::getHeight(), Widget::getWidth(), MouseEvent::getX(), Widget::getX(), MouseEvent::getY(), Widget::getY(), InputGuiEvent::isConsumed(), Window::isMovable(), mainGraphics, Window::mDragOffsetX, Window::mDragOffsetY, Graphics::mHeight, Window::mMoved, Window::mouseDragged(), Graphics::mWidth, and Widget::setPosition().

◆ mousePressed()

void ShortcutWindow::mousePressed ( MouseEvent event)
virtual

Starts window resizing when appropriate.

Reimplemented from Window.

Definition at line 218 of file shortcutwindow.cpp.

219 {
220  Window::mousePressed(event);
221 
222  if (event.isConsumed())
223  return;
224 
225  if (event.getButton() == MouseButton::LEFT)
226  {
227  mDragOffsetX = event.getX();
228  mDragOffsetY = event.getY();
229  }
230 }
MouseButtonT getButton() const
Definition: mouseevent.h:116
void mousePressed(MouseEvent &event)
Definition: window.cpp:836

References MouseEvent::getButton(), InputGuiEvent::isConsumed(), MouseButton::LEFT, Window::mDragOffsetX, Window::mDragOffsetY, and Window::mousePressed().

◆ nextTab()

void ShortcutWindow::nextTab ( )

Definition at line 258 of file shortcutwindow.cpp.

259 {
260  if (mTabs != nullptr)
261  mTabs->selectNextTab();
262 }
void selectNextTab()
Definition: tabbedarea.cpp:819

References mTabs, and TabbedArea::selectNextTab().

◆ prevTab()

void ShortcutWindow::prevTab ( )

Definition at line 264 of file shortcutwindow.cpp.

265 {
266  if (mTabs != nullptr)
267  mTabs->selectPrevTab();
268 }
void selectPrevTab()
Definition: tabbedarea.cpp:828

References mTabs, and TabbedArea::selectPrevTab().

◆ widgetHidden()

void ShortcutWindow::widgetHidden ( const Event event)
virtual

Called whenever the widget is hidden.

Reimplemented from Window.

Definition at line 198 of file shortcutwindow.cpp.

199 {
200  Window::widgetHidden(event);
201  if (mItems != nullptr)
202  mItems->widgetHidden(event);
203  if (mTabs != nullptr)
204  {
205  ScrollArea *const scroll = static_cast<ScrollArea *>(
207  if (scroll != nullptr)
208  {
209  ShortcutContainer *const content = static_cast<ShortcutContainer*>(
210  scroll->getContent());
211 
212  if (content != nullptr)
213  content->widgetHidden(event);
214  }
215  }
216 }
Widget * getContent()
Widget * getCurrentWidget() const
Definition: tabbedarea.cpp:229
virtual void widgetHidden(const Event &event)
void widgetHidden(const Event &event)
Definition: window.cpp:725

References ScrollArea::getContent(), TabbedArea::getCurrentWidget(), mItems, mTabs, Window::widgetHidden(), and WidgetListener::widgetHidden().

◆ widgetMoved()

void ShortcutWindow::widgetMoved ( const Event event)
virtual

Invoked when a widget is moved.

Parameters
eventDescribes the event.

Reimplemented from Window.

Definition at line 249 of file shortcutwindow.cpp.

250 {
251  Window::widgetMoved(event);
252  if (mItems != nullptr)
253  mItems->setRedraw(true);
254  FOR_EACH (STD_VECTOR<ShortcutContainer*>::iterator, it, mPages)
255  (*it)->setRedraw(true);
256 }
void setRedraw(const bool b)
Definition: widget.h:942
void widgetMoved(const Event &event)
Definition: window.cpp:720
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References FOR_EACH, mItems, mPages, Widget::setRedraw(), and Window::widgetMoved().

Field Documentation

◆ mBoxesWidth

int ShortcutWindow::mBoxesWidth = 0
staticprivate

Definition at line 95 of file shortcutwindow.h.

Referenced by ShortcutWindow().

◆ mButtonIndex

int ShortcutWindow::mButtonIndex
private

Definition at line 93 of file shortcutwindow.h.

Referenced by addButton().

◆ mItems

ShortcutContainer* ShortcutWindow::mItems
private

Definition at line 88 of file shortcutwindow.h.

Referenced by ShortcutWindow(), widgetHidden(), widgetMoved(), and ~ShortcutWindow().

◆ mPages

std::vector<ShortcutContainer*> ShortcutWindow::mPages
private

Definition at line 92 of file shortcutwindow.h.

Referenced by addTab(), and widgetMoved().

◆ mScrollArea

ScrollArea* ShortcutWindow::mScrollArea
private

Definition at line 90 of file shortcutwindow.h.

Referenced by ShortcutWindow().

◆ mTabs

TabbedArea* ShortcutWindow::mTabs
private

The documentation for this class was generated from the following files: