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=0, int height=0)
 
 ShortcutWindow (const std::string &title, const std::string &skinFile="", const int width=0, const int height=0)
 
 ~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="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
 
virtual ~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=0, int offsetY=0)
 
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=0, const int offsetY=0)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w=0, int h=0)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w=1, const int h=1)
 
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)
 
virtual ~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)
 
virtual ~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)
 
virtual ~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=255U) 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=0) const
 
bool getOptionBool (const std::string &name, const bool def=false) 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 37 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 = 0,
int  height = 0 
)

Constructor.

Definition at line 51 of file shortcutwindow.cpp.

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::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.

54  :
55  Window("Window", Modal_false, nullptr, skinFile),
56  mItems(content),
58  mTabs(nullptr),
59  mPages(),
60  mButtonIndex(0)
61 {
62  setWindowName(title);
64 
65  setShowTitle(false);
66  setResizable(true);
67  setDefaultVisible(false);
68  setSaveVisible(true);
69  setAllowClose(true);
70 
71  mDragOffsetX = 0;
72  mDragOffsetY = 0;
73 
74  if (content != nullptr)
75  content->setWidget2(this);
76  if (setupWindow != nullptr)
78 
79  setMinWidth(32);
80  setMinHeight(32);
81  const int border = SCROLL_PADDING * 2 + getPadding() * 2;
82  if (mItems != nullptr)
83  {
84  const int bw = mItems->getBoxWidth();
85  const int bh = mItems->getBoxHeight();
86  const int maxItems = mItems->getMaxItems();
87  setMaxWidth(bw * maxItems + border);
88  setMaxHeight(bh * maxItems + border);
89 
90  if (width == 0)
91  width = bw + border;
92  if (height == 0)
93  height = bh * maxItems + border;
94 
96 
97  mBoxesWidth += bw + border;
98  }
99 
102 
103  place(0, 0, mScrollArea, 5, 5).setPadding(0);
104 
105  Layout &layout = getLayout();
106  layout.setRowHeight(0, LayoutType::SET);
107  layout.setMargin(0);
108 
109  loadWindowState();
110  enableVisibleSound(true);
111 }
void setDefaultSize()
Definition: window.cpp:1186
std::vector< ShortcutContainer * > mPages
void setDefaultVisible(const bool save)
Definition: window.h:286
int mDragOffsetY
Definition: window.h:634
void setMaxWidth(const int width)
Definition: window.cpp:605
void loadWindowState()
Definition: window.cpp:1075
void setMaxHeight(const int height)
Definition: window.cpp:610
virtual void setWidget2(const Widget2 *const widget)
Definition: widget2.h:63
void setMinWidth(const int width)
Definition: window.cpp:579
int getBoxWidth() const
void setShowTitle(bool flag)
Definition: window.h:233
static int mBoxesWidth
int mDragOffsetX
Definition: window.h:627
void registerWindowForReset(Window *const window)
ScrollArea * mScrollArea
int getTitlePadding() const
Definition: window.h:594
int getMaxItems() const
int getBoxHeight() const
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
void setMargin(int m)
Definition: layout.h:53
const bool Opaque_false
Definition: opaque.h:29
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void enableVisibleSound(bool b)
Definition: window.h:473
void setMinHeight(const int height)
Definition: window.cpp:592
LayoutCell & setPadding(int p)
Definition: layoutcell.h:59
Layout & getLayout()
Definition: window.cpp:1353
void setAllowClose(const bool b)
Definition: window.h:187
void setSaveVisible(const bool save)
Definition: window.h:298
ShortcutContainer * mItems
TabbedArea * mTabs
void setResizable(const bool resize)
Definition: window.cpp:615
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
void setTitleBarHeight(unsigned int height)
Definition: window.h:505
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
Definition: layout.h:43
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
int getPadding() const
Definition: window.h:496
void setWindowName(const std::string &name)
Definition: window.h:353
static const int SCROLL_PADDING
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)

◆ ShortcutWindow() [2/3]

ShortcutWindow::ShortcutWindow ( const std::string &  title,
const std::string &  skinFile = "",
const int  width = 0,
const int  height = 0 
)
explicit

Definition at line 113 of file shortcutwindow.cpp.

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().

115  :
116  Window("Window", Modal_false, nullptr, skinFile),
117  mItems(nullptr),
118  mScrollArea(nullptr),
120  mPages(),
121  mButtonIndex(0)
122 {
123  setWindowName(title);
125  setShowTitle(false);
126  setResizable(true);
127  setDefaultVisible(false);
128  setSaveVisible(true);
129  setAllowClose(true);
130 
131  mDragOffsetX = 0;
132  mDragOffsetY = 0;
133 
134  if (setupWindow != nullptr)
136 
137  if ((width != 0) && (height != 0))
139 
140  setMinWidth(32);
141  setMinHeight(32);
142 
143  place(0, 0, mTabs, 5, 5);
144 
145  Layout &layout = getLayout();
146  layout.setRowHeight(0, LayoutType::SET);
147  layout.setMargin(0);
148 
149  loadWindowState();
150  enableVisibleSound(true);
151 }
void setDefaultSize()
Definition: window.cpp:1186
std::vector< ShortcutContainer * > mPages
void setDefaultVisible(const bool save)
Definition: window.h:286
int mDragOffsetY
Definition: window.h:634
void loadWindowState()
Definition: window.cpp:1075
void setMinWidth(const int width)
Definition: window.cpp:579
void setShowTitle(bool flag)
Definition: window.h:233
int mDragOffsetX
Definition: window.h:627
void registerWindowForReset(Window *const window)
ScrollArea * mScrollArea
int getTitlePadding() const
Definition: window.h:594
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
void setMargin(int m)
Definition: layout.h:53
void enableVisibleSound(bool b)
Definition: window.h:473
void setMinHeight(const int height)
Definition: window.cpp:592
Layout & getLayout()
Definition: window.cpp:1353
void setAllowClose(const bool b)
Definition: window.h:187
void setSaveVisible(const bool save)
Definition: window.h:298
ShortcutContainer * mItems
TabbedArea * mTabs
void setResizable(const bool resize)
Definition: window.cpp:615
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
void setTitleBarHeight(unsigned int height)
Definition: window.h:505
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
Definition: layout.h:43
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
int getPadding() const
Definition: window.h:496
void setWindowName(const std::string &name)
Definition: window.h:353

◆ ~ShortcutWindow()

ShortcutWindow::~ShortcutWindow ( )

Destructor.

Definition at line 153 of file shortcutwindow.cpp.

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

154 {
155  if (mTabs != nullptr)
156  mTabs->removeAll();
157  delete2(mTabs);
158  delete2(mItems);
159 }
#define delete2(var)
Definition: delete2.h:24
ShortcutContainer * mItems
TabbedArea * mTabs
void removeAll(const bool del=true)
Definition: tabbedarea.cpp:719

◆ 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 161 of file shortcutwindow.cpp.

References mButtonIndex, Window::place(), and Window::widgetResized().

164 {
165  place(mButtonIndex++, 5, new Button(this, text, eventName, listener));
166  Window::widgetResized(Event(nullptr));
167 }
Definition: button.h:94
void widgetResized(const Event &event)
Definition: window.cpp:643
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
Definition: event.h:77

◆ addTab()

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

Definition at line 169 of file shortcutwindow.cpp.

References TabbedArea::addTab(), mPages, mTabs, Opaque_false, SCROLL_PADDING, ScrollArea::setHorizontalScrollPolicy(), Widget::setPosition(), Widget2::setWidget2(), and ScrollArea::SHOW_NEVER.

Referenced by createGuiWindows().

171 {
172  if ((content == nullptr) || (mTabs == nullptr))
173  return;
174  ScrollArea *const scroll = new ScrollArea(this, content, Opaque_false);
177  content->setWidget2(this);
178  Tab *const tab = new ShortcutTab(this, name, content);
179  mTabs->addTab(tab, scroll);
180  mPages.push_back(content);
181 }
std::vector< ShortcutContainer * > mPages
Definition: tab.h:84
virtual void setWidget2(const Widget2 *const widget)
Definition: widget2.h:63
const bool Opaque_false
Definition: opaque.h:29
void setPosition(const int x, const int y)
Definition: widget.cpp:160
TabbedArea * mTabs
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:229
static const int SCROLL_PADDING
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)

◆ getTabIndex()

int ShortcutWindow::getTabIndex ( ) const

Definition at line 183 of file shortcutwindow.cpp.

References TabbedArea::getSelectedTabIndex(), and mTabs.

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

184 {
185  if (mTabs == nullptr)
186  return 0;
187  return mTabs->getSelectedTabIndex();
188 }
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:440
TabbedArea * mTabs

◆ 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 224 of file shortcutwindow.cpp.

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().

225 {
226  Window::mouseDragged(event);
227 
228  if (event.isConsumed())
229  return;
230 
231  if (canMove() && isMovable() && mMoved)
232  {
233  int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
234  int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
235  newX = std::min(mainGraphics->mWidth - getWidth(), newX);
236  newY = std::min(mainGraphics->mHeight - getHeight(), newY);
237  setPosition(newX, newY);
238  }
239 }
int getWidth() const
Definition: widget.h:220
int mDragOffsetY
Definition: window.h:634
int getY() const
Definition: widget.h:287
int mWidth
Definition: graphics.h:483
bool mMoved
Definition: window.h:639
int mDragOffsetX
Definition: window.h:627
bool isMovable() const
Definition: window.h:568
bool canMove() const
Definition: window.cpp:965
Graphics * mainGraphics
Definition: graphics.cpp:108
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int mHeight
Definition: graphics.h:484
bool isConsumed() const
int getY() const
Definition: mouseevent.h:135
int getX() const
Definition: widget.h:268
void mouseDragged(MouseEvent &event)
Definition: window.cpp:970
int getHeight() const
Definition: widget.h:239
int getX() const
Definition: mouseevent.h:124

◆ mousePressed()

void ShortcutWindow::mousePressed ( MouseEvent event)
virtual

Starts window resizing when appropriate.

Reimplemented from Window.

Definition at line 210 of file shortcutwindow.cpp.

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

211 {
212  Window::mousePressed(event);
213 
214  if (event.isConsumed())
215  return;
216 
217  if (event.getButton() == MouseButton::LEFT)
218  {
219  mDragOffsetX = event.getX();
220  mDragOffsetY = event.getY();
221  }
222 }
int mDragOffsetY
Definition: window.h:634
MouseButtonT getButton() const
Definition: mouseevent.h:113
int mDragOffsetX
Definition: window.h:627
bool isConsumed() const
void mousePressed(MouseEvent &event)
Definition: window.cpp:824

◆ nextTab()

void ShortcutWindow::nextTab ( )

Definition at line 250 of file shortcutwindow.cpp.

References mTabs, and TabbedArea::selectNextTab().

251 {
252  if (mTabs != nullptr)
253  mTabs->selectNextTab();
254 }
TabbedArea * mTabs
void selectNextTab()
Definition: tabbedarea.cpp:808

◆ prevTab()

void ShortcutWindow::prevTab ( )

Definition at line 256 of file shortcutwindow.cpp.

References BLOCK_END, BLOCK_START, BasicContainer::logicChildren(), mTabs, and TabbedArea::selectPrevTab().

257 {
258  if (mTabs != nullptr)
259  mTabs->selectPrevTab();
260 }
void selectPrevTab()
Definition: tabbedarea.cpp:817
TabbedArea * mTabs

◆ widgetHidden()

void ShortcutWindow::widgetHidden ( const Event event)
virtual

Called whenever the widget is hidden.

Reimplemented from Window.

Definition at line 190 of file shortcutwindow.cpp.

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

191 {
192  Window::widgetHidden(event);
193  if (mItems != nullptr)
194  mItems->widgetHidden(event);
195  if (mTabs != nullptr)
196  {
197  ScrollArea *const scroll = static_cast<ScrollArea *>(
199  if (scroll != nullptr)
200  {
201  ShortcutContainer *const content = static_cast<ShortcutContainer*>(
202  scroll->getContent());
203 
204  if (content != nullptr)
205  content->widgetHidden(event);
206  }
207  }
208 }
Widget * getCurrentWidget() const
Definition: tabbedarea.cpp:220
void widgetHidden(const Event &event)
Definition: window.cpp:713
ShortcutContainer * mItems
TabbedArea * mTabs
virtual void widgetHidden(const Event &event)
Widget * getContent()

◆ widgetMoved()

void ShortcutWindow::widgetMoved ( const Event event)
virtual

Invoked when a widget is moved.

Parameters
eventDescribes the event.

Reimplemented from Window.

Definition at line 241 of file shortcutwindow.cpp.

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

242 {
243  Window::widgetMoved(event);
244  if (mItems != nullptr)
245  mItems->setRedraw(true);
246  FOR_EACH (STD_VECTOR<ShortcutContainer*>::iterator, it, mPages)
247  (*it)->setRedraw(true);
248 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
std::vector< ShortcutContainer * > mPages
void setRedraw(const bool b)
Definition: widget.h:941
void widgetMoved(const Event &event)
Definition: window.cpp:708
ShortcutContainer * mItems

Field Documentation

◆ mBoxesWidth

int ShortcutWindow::mBoxesWidth = 0
staticprivate

Definition at line 92 of file shortcutwindow.h.

Referenced by ShortcutWindow().

◆ mButtonIndex

int ShortcutWindow::mButtonIndex
private

Definition at line 90 of file shortcutwindow.h.

Referenced by addButton().

◆ mItems

ShortcutContainer* ShortcutWindow::mItems
private

Definition at line 85 of file shortcutwindow.h.

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

◆ mPages

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

Definition at line 89 of file shortcutwindow.h.

Referenced by addTab(), and widgetMoved().

◆ mScrollArea

ScrollArea* ShortcutWindow::mScrollArea
private

Definition at line 87 of file shortcutwindow.h.

Referenced by ShortcutWindow().

◆ mTabs

TabbedArea* ShortcutWindow::mTabs
private

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