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

#include <window.h>

Inheritance diagram for Window:
BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2 BankWindow BuyDialog BuySellDialog ChangeEmailDialog ChangePasswordDialog CharCreateDialog CharSelectDialog ChatWindow ConfirmDialog ConnectionDialog CutInWindow DebugWindow DidYouKnowWindow EditDialog EditServerDialog EmoteWindow EquipmentWindow HelpWindow InventoryWindow ItemAmountWindow KillStats LoginDialog MailEditWindow MailViewWindow MailWindow Minimap MiniStatusWindow NpcDialog OkDialog OutfitWindow QuestsWindow QuitDialog RegisterDialog SellDialog ServerDialog ServerInfoWindow SetupWindow ShopWindow ShortcutWindow SkillDialog SocialWindow StatusWindow TextCommandEditor TextDialog TextSelectDialog TradeWindow UpdaterWindow WhoIsOnline WorldSelectDialog

Public Member Functions

 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 widgetMoved (const Event &event)
 
void widgetHidden (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 mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
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)
 

Static Public Member Functions

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)
 

Protected Member Functions

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

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
 

Private Types

enum  ResizeHandles {
  TOP = 0x01, RIGHT = 0x02, BOTTOM = 0x04, LEFT = 0x08,
  CLOSE = 0x10
}
 

Private Member Functions

void ensureOnScreen ()
 
void adjustSizeToScreen ()
 
int getResizeHandles (const MouseEvent &event)
 

Private Attributes

ImagemGrip
 
WindowmParentWindow
 
LayoutmLayout
 
Rect mCloseRect
 
Rect mStickyRect
 
Rect mGripRect
 
TextChunk mTextChunk
 
std::string mWindowName
 
int mMinWinWidth
 
int mMinWinHeight
 
int mMaxWinWidth
 
int mMaxWinHeight
 
ImageCollectionmVertexes
 
Graphics::Alignment mCaptionAlign
 
int mTitlePadding
 
int mGripPadding
 
int mResizeHandles
 
int mOldResizeHandles
 
int mClosePadding
 
int mStickySpacing
 
int mStickyPadding
 
FontmCaptionFont
 
Modal mModal
 
bool mCloseWindowButton
 
bool mDefaultVisible
 
bool mSaveVisible
 
bool mStickyButton
 
bool mSticky
 
bool mStickyButtonLock
 
bool mPlayVisibleSound
 
bool mInit
 
bool mTextChanged
 
bool mAllowClose
 

Static Private Attributes

static int mouseResize = 0
 
static int windowInstances = 0
 
static const unsigned resizeBorderWidth = 10
 

Additional Inherited Members

- 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
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A window. This window can be dragged around and has a title bar. Windows are invisible by default.

Definition at line 98 of file window.h.

Member Enumeration Documentation

◆ ResizeHandles

enum Window::ResizeHandles
private
Enumerator
TOP 
RIGHT 
BOTTOM 
LEFT 
CLOSE 

Definition at line 652 of file window.h.

653  {
654  TOP = 0x01,
655  RIGHT = 0x02,
656  BOTTOM = 0x04,
657  LEFT = 0x08,
658  CLOSE = 0x10
659  };

Constructor & Destructor Documentation

◆ Window()

Window::Window ( const std::string &  caption = "Window",
const Modal  modal = Modal_false,
Window *const  parent = 0,
std::string  skin = "" 
)
explicit

Constructor. Initializes the title to the given text and hooks itself into the window container.

Parameters
captionThe initial window title, "Window" by default.
modalBlock input to other windows.
parentThe parent window. This is the window standing above this one in the window hiearchy. When reordering, a window will never go below its parent window.
skinThe location where the window's skin XML can be found.

Definition at line 108 of file window.cpp.

References BasicContainer2::add(), Widget::addMouseListener(), Widget::addWidgetListener(), boldFont, CAST_U32, Cursor::CURSOR_POINTER, Font::getHeight(), getOption(), getOptionBool(), Skin::getPadding(), Widget2::getThemeColor(), Skin::getTitlePadding(), gui, Graphics::LEFT, Theme::load(), Logger::log(), logger, mCaptionAlign, mCaptionFont, mCaptionOffsetX, mCaptionOffsetY, mClosePadding, Widget::mForegroundColor, Widget2::mForegroundColor2, mGripPadding, mModal, Modal_true, mPadding, mShowTitle, mSkin, mStickyPadding, mStickySpacing, mTitleBarHeight, mTitlePadding, Widget2::mWindow, Widget::requestModalFocus(), Graphics::RIGHT, Gui::setCursorType(), Widget::setFrameSize(), setPadding(), Widget2::setPalette(), setTitleBarHeight(), setVisible(), theme, Visible_false, ThemeColorId::WINDOW, ThemeColorId::WINDOW_OUTLINE, windowContainer, and windowInstances.

111  :
112  BasicContainer2(nullptr),
113  MouseListener(),
114  WidgetListener(),
115  mCaption(caption),
117  mPadding(2),
118  mTitleBarHeight(16),
120  mDragOffsetX(0),
121  mDragOffsetY(0),
122  mMoved(false),
123  mSkin(nullptr),
124  mDefaultX(0),
125  mDefaultY(0),
126  mDefaultWidth(0),
127  mDefaultHeight(0),
128  mCaptionOffsetX(7),
129  mCaptionOffsetY(5),
130  mShowTitle(true),
131  mLastRedraw(true),
132  mGrip(nullptr),
133  mParentWindow(parent),
134  mLayout(nullptr),
135  mCloseRect(),
136  mStickyRect(),
137  mGripRect(),
138  mTextChunk(),
139  mWindowName("window"),
140  mMinWinWidth(100),
141  mMinWinHeight(40),
146  mTitlePadding(4),
147  mGripPadding(2),
148  mResizeHandles(-1),
149  mOldResizeHandles(-1),
150  mClosePadding(0),
151  mStickySpacing(0),
152  mStickyPadding(0),
154  mModal(modal),
155  mCloseWindowButton(false),
156  mDefaultVisible(false),
157  mSaveVisible(false),
158  mStickyButton(false),
159  mSticky(false),
160  mStickyButtonLock(false),
161  mPlayVisibleSound(false),
162  mInit(false),
163  mTextChanged(true),
164  mAllowClose(false)
165 {
166  logger->log("Window::Window(\"%s\")", caption.c_str());
167 
168  mWindow = this;
169 
170  windowInstances++;
171 
172 // mFrameSize = 1;
173  addMouseListener(this);
174 
175  setFrameSize(0);
176  setPadding(3);
177  setTitleBarHeight(20);
178 
179  if (skin.empty())
180  skin = "window.xml";
181 
182  int childPalette = 1;
183  // Loads the skin
184  if (theme != nullptr)
185  {
186  mSkin = theme->load(skin, "window.xml");
187  if (mSkin != nullptr)
188  {
190  if (getOptionBool("titlebarBold"))
193  mGripPadding = getOption("resizePadding");
194  mCaptionOffsetX = getOption("captionoffsetx");
195  if (mCaptionOffsetX == 0)
196  mCaptionOffsetX = 7;
197  mCaptionOffsetY = getOption("captionoffsety");
198  if (mCaptionOffsetY == 0)
199  mCaptionOffsetY = 5;
200  mCaptionAlign = static_cast<Graphics::Alignment>(
201  getOption("captionalign"));
204  {
206  }
208  getOption("titlebarHeight")));
209  if (mTitleBarHeight == 0u)
211 
212  mTitleBarHeight += getOption("titlebarHeightRelative");
213  setPalette(getOption("palette"));
214  childPalette = getOption("childPalette");
215  mShowTitle = getOptionBool("showTitle", true);
216  mClosePadding = getOption("closePadding");
217  mStickySpacing = getOption("stickySpacing");
218  mStickyPadding = getOption("stickyPadding");
219  }
220  }
221 
222  // Add this window to the window container
223  if (windowContainer != nullptr)
224  windowContainer->add(this);
225 
226  if (mModal == Modal_true)
227  {
230  }
231 
232  // Windows are invisible by default
233  setVisible(Visible_false, false);
234 
235  addWidgetListener(this);
238  setPalette(childPalette);
239 }
bool mShowTitle
Definition: window.h:648
#define CAST_U32
Definition: cast.h:30
Font * getFont() const
Definition: widget.cpp:330
Rect mGripRect
Definition: window.h:684
std::string mWindowName
Definition: window.h:686
Font * mCaptionFont
Definition: window.h:711
Skin * mSkin
Definition: window.h:641
Font * boldFont
Definition: gui.cpp:111
TextChunk mTextChunk
Definition: window.h:685
int mGripPadding
Definition: window.h:705
int mDragOffsetY
Definition: window.h:634
int mPadding
Definition: window.h:610
Gui * gui
Definition: gui.cpp:110
void requestModalFocus()
Definition: widget.cpp:379
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha=255U) const A_INLINE
Definition: widget2.h:44
WindowContainer * windowContainer
int mOldResizeHandles
Definition: window.h:707
bool mTextChanged
Definition: window.h:721
bool mStickyButtonLock
Definition: window.h:718
int mCaptionOffsetY
Definition: window.h:647
int mWidth
Definition: graphics.h:483
int mStickySpacing
Definition: window.h:709
bool mDefaultVisible
Definition: window.h:714
ImageCollection * mVertexes
Definition: window.h:702
Rect mCloseRect
Definition: window.h:682
bool mStickyButton
Definition: window.h:716
bool getOptionBool(const std::string &name, const bool def=false) const
Definition: window.cpp:1454
bool mMoved
Definition: window.h:639
Color mForegroundColor
Definition: widget.h:1085
int mCaptionOffsetX
Definition: window.h:646
int mDragOffsetX
Definition: window.h:627
int mMaxWinWidth
Definition: window.h:689
Logger * logger
Definition: logger.cpp:95
int mDefaultY
Definition: window.h:643
bool mAllowClose
Definition: window.h:722
int getPadding() const
Definition: skin.h:99
int mTitlePadding
Definition: window.h:704
const bool Visible_false
Definition: visible.h:29
Widget * mWindow
Definition: widget2.h:111
int mDefaultWidth
Definition: window.h:644
bool mLastRedraw
Definition: window.h:649
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:167
virtual void add(Widget *const widget)
int mStickyPadding
Definition: window.h:710
bool mInit
Definition: window.h:720
Graphics::Alignment mCaptionAlign
Definition: window.h:703
Graphics * mainGraphics
Definition: graphics.cpp:108
int getTitlePadding() const
Definition: skin.h:102
int mClosePadding
Definition: window.h:708
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
bool mCloseWindowButton
Definition: window.h:713
int mHeight
Definition: graphics.h:484
void setCursorType(const CursorT index)
Definition: gui.h:195
int mResizeHandles
Definition: window.h:706
bool mSticky
Definition: window.h:717
const bool Move_true
Definition: move.h:29
static int windowInstances
Definition: window.h:693
Rect mStickyRect
Definition: window.h:683
Modal mModal
Definition: window.h:712
bool mPlayVisibleSound
Definition: window.h:719
std::string mCaption
Definition: window.h:600
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
Skin * load(const std::string &filename, const std::string &filename2, const bool full=true, const std::string &defaultPath=getThemePath())
Definition: theme.cpp:178
bool mSaveVisible
Definition: window.h:715
Theme * theme
Definition: theme.cpp:61
virtual void setVisible(Visible visible)
Definition: window.cpp:766
Color mForegroundColor2
Definition: widget2.h:112
Move mMovable
Definition: window.h:620
int mDefaultHeight
Definition: window.h:645
BasicContainer2(const Widget2 *const widget)
int mDefaultX
Definition: window.h:642
Layout * mLayout
Definition: window.h:681
int getOption(const std::string &name, const int def=0) const
Definition: window.cpp:1442
void setPadding(int padding)
Definition: window.h:486
void log(const char *const log_text,...)
Definition: logger.cpp:243
void setTitleBarHeight(unsigned int height)
Definition: window.h:505
int getHeight() const
Definition: font.cpp:360
Window * mParentWindow
Definition: window.h:680
unsigned int mTitleBarHeight
Definition: window.h:615
int mMinWinWidth
Definition: window.h:687
Graphics::Alignment mAlignment
Definition: window.h:605
int mMaxWinHeight
Definition: window.h:690
int mMinWinHeight
Definition: window.h:688
void setPalette(int palette)
Definition: widget2.h:68
Image * mGrip
Definition: window.h:679

◆ ~Window()

Window::~Window ( )
virtual

Destructor. Deletes all the added widgets.

Definition at line 252 of file window.cpp.

References client, Image::decRef(), delete2, getCaption(), gui, Logger::log(), logger, mGrip, mInit, mLayout, mSkin, mVertexes, BasicContainer::mWidgets, mWindowName, Gui::removeDragged(), Widget::removeWidgetListener(), reportAlways, saveWindowState(), setupWindow, theme, Theme::unload(), SetupWindow::unregisterWindowForReset(), windowInstances, and Client::windowRemoved().

253 {
254  logger->log("Window::~Window(\"%s\")", getCaption().c_str());
255 
256  if (gui != nullptr)
257  gui->removeDragged(this);
258 
259 #ifndef DYECMD
260  if (setupWindow != nullptr)
262 #endif // DYECMD
263 
264  client->windowRemoved(this);
265 
266  saveWindowState();
267 
268  delete2(mLayout);
269 
270  while (!mWidgets.empty())
271  delete mWidgets.front();
272 
273  mWidgets.clear();
274 
275  removeWidgetListener(this);
277 
278  windowInstances--;
279 
280  if (mSkin != nullptr)
281  {
282  if (theme != nullptr)
283  theme->unload(mSkin);
284  mSkin = nullptr;
285  }
286  if (mGrip != nullptr)
287  {
288  mGrip->decRef();
289  mGrip = nullptr;
290  }
291  if (!mInit)
292  {
293  reportAlways("error: Window created without calling postInit(): %s",
294  mWindowName.c_str());
295  }
296 }
std::string mWindowName
Definition: window.h:686
Skin * mSkin
Definition: window.h:641
void unload(Skin *const skin)
Definition: theme.cpp:249
Gui * gui
Definition: gui.cpp:110
ImageCollection * mVertexes
Definition: window.h:702
Client * client
Definition: client.cpp:113
#define delete2(var)
Definition: delete2.h:24
Logger * logger
Definition: logger.cpp:95
bool mInit
Definition: window.h:720
static int windowInstances
Definition: window.h:693
Theme * theme
Definition: theme.cpp:61
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1144
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306
void windowRemoved(const Window *const window)
Definition: client.cpp:781
Layout * mLayout
Definition: window.h:681
WidgetList mWidgets
void unregisterWindowForReset(const Window *const window)
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
void log(const char *const log_text,...)
Definition: logger.cpp:243
void saveWindowState()
Definition: window.cpp:1137
const std::string & getCaption() const
Definition: window.h:532
#define reportAlways(...)
Definition: checkutils.h:252
void decRef()
Definition: image.cpp:521
Image * mGrip
Definition: window.h:679

Member Function Documentation

◆ adjustPositionAfterResize()

void Window::adjustPositionAfterResize ( const int  oldScreenWidth,
const int  oldScreenHeight 
)

Adjusts the window position after the application window has been resized.

Definition at line 1254 of file window.cpp.

References adjustSizeToScreen(), ensureOnScreen(), Rect::height, mainGraphics, Widget::mDimension, Graphics::mHeight, Graphics::mWidth, Rect::width, Rect::x, and Rect::y.

Referenced by getWindowName().

1256 {
1257  // If window was aligned to the right or bottom, keep it there
1258  const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
1259  const int bottomMargin = oldScreenHeight
1260  - (mDimension.y + mDimension.height);
1261  if (mDimension.x > 0 && mDimension.x > rightMargin)
1262  mDimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
1263  if (mDimension.y > 0 && mDimension.y > bottomMargin)
1264  {
1266  - bottomMargin - mDimension.height;
1267  }
1268 
1269  ensureOnScreen();
1271 }
int width
Definition: rect.h:218
void adjustSizeToScreen()
Definition: window.cpp:1273
int mWidth
Definition: graphics.h:483
void ensureOnScreen()
Definition: window.cpp:1415
int x
Definition: rect.h:208
int y
Definition: rect.h:213
Graphics * mainGraphics
Definition: graphics.cpp:108
int height
Definition: rect.h:223
int mHeight
Definition: graphics.h:484
Rect mDimension
Definition: widget.h:1100

◆ adjustSizeToScreen()

void Window::adjustSizeToScreen ( )
private

Definition at line 1273 of file window.cpp.

References Rect::height, mainGraphics, Widget::mDimension, mGrip, Graphics::mHeight, Graphics::mWidth, widgetResized(), Rect::width, Rect::x, and Rect::y.

Referenced by adjustPositionAfterResize().

1274 {
1275  if (mGrip == nullptr)
1276  return;
1277 
1278  const int screenWidth = mainGraphics->mWidth;
1279  const int screenHeight = mainGraphics->mHeight;
1280  const int oldWidth = mDimension.width;
1281  const int oldHeight = mDimension.height;
1282  if (oldWidth + mDimension.x > screenWidth)
1283  mDimension.x = 0;
1284  if (oldHeight + mDimension.y > screenHeight)
1285  mDimension.x = 0;
1286  if (mDimension.width > screenWidth)
1287  mDimension.width = screenWidth;
1288  if (mDimension.height > screenHeight)
1289  mDimension.height = screenHeight;
1290  if (oldWidth != mDimension.width || oldHeight != mDimension.height)
1291  widgetResized(Event(this));
1292 }
int width
Definition: rect.h:218
int mWidth
Definition: graphics.h:483
int x
Definition: rect.h:208
void widgetResized(const Event &event)
Definition: window.cpp:643
int y
Definition: rect.h:213
Graphics * mainGraphics
Definition: graphics.cpp:108
int height
Definition: rect.h:223
int mHeight
Definition: graphics.h:484
Definition: event.h:77
Rect mDimension
Definition: widget.h:1100
Image * mGrip
Definition: window.h:679

◆ canMove()

bool Window::canMove ( ) const
protected

Definition at line 965 of file window.cpp.

References mSticky, and mStickyButtonLock.

Referenced by isMovable(), ShortcutWindow::mouseDragged(), ChatWindow::mouseDragged(), mouseDragged(), and mousePressed().

966 {
967  return !mStickyButtonLock || !mSticky;
968 }
bool mStickyButtonLock
Definition: window.h:718
bool mSticky
Definition: window.h:717

◆ center()

void Window::center ( )

◆ centerHorisontally()

void Window::centerHorisontally ( )

Positions the window in the horisontal center of it's parent.

Definition at line 1410 of file window.cpp.

References Widget::getParent(), and setLocationHorisontallyRelativeTo().

Referenced by getWindowName(), and OkDialog::OkDialog().

1411 {
1413 }
void setLocationHorisontallyRelativeTo(const Widget *const widget)
Definition: window.cpp:518
Widget * getParent() const
Definition: widget.h:201

◆ clearLayout()

void Window::clearLayout ( )

Clears the window's layout (useful for redesigning the window). Does not delete the widgets!

Definition at line 1360 of file window.cpp.

References BasicContainer::clear(), and mLayout.

Referenced by NpcDialog::buildLayout(), getWindowName(), and NpcDialog::~NpcDialog().

1361 {
1362  clear();
1363 
1364  // Recreate layout instance when one is present
1365  if (mLayout != nullptr)
1366  {
1367  delete mLayout;
1368  mLayout = new Layout;
1369  }
1370 }
virtual void clear()
Layout * mLayout
Definition: window.h:681
Definition: layout.h:43

◆ close()

void Window::close ( )
virtual

◆ draw()

void Window::draw ( Graphics *const  graphics)
virtual

Draws the window.

Reimplemented from BasicContainer2.

Reimplemented in ChatWindow, EquipmentWindow, MiniStatusWindow, Minimap, ConnectionDialog, DebugWindow, OutfitWindow, and CutInWindow.

Definition at line 303 of file window.cpp.

References BLOCK_END, BLOCK_START, Graphics::calcTileCollection(), Graphics::calcWindow(), Graphics::CENTER, ImageCollection::clear(), CLOSE, TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), BasicContainer::drawChildren(), Graphics::drawImage(), Graphics::drawTileCollection(), Graphics::finalize(), Font::generate(), Skin::getBorder(), Skin::getCloseImage(), Skin::getStickyImage(), Font::getWidth(), Rect::height, TextChunk::img, Graphics::LEFT, mCaption, mCaptionAlign, mCaptionFont, mCaptionOffsetX, mCaptionOffsetY, mCloseRect, mCloseWindowButton, Widget::mDimension, Widget::mForegroundColor, Widget2::mForegroundColor2, mGrip, mGripRect, mLastRedraw, mOldResizeHandles, Widget::mRedraw, mResizeHandles, mShowTitle, mSkin, mSticky, mStickyButton, mStickyRect, mTextChanged, mTextChunk, mVertexes, Graphics::RIGHT, Graphics::setRedraw(), TextChunk::text, TextChunk::textFont, UserAgent::update(), Rect::width, x, Rect::x, and Rect::y.

Referenced by CutInWindow::draw(), OutfitWindow::draw(), DebugWindow::draw(), Minimap::draw(), EquipmentWindow::draw(), and ChatWindow::draw().

304 {
305  if (mSkin == nullptr)
306  return;
307 
308  BLOCK_START("Window::draw")
309  bool update = false;
310 
312  {
313  mRedraw = true;
314  mOldResizeHandles = mResizeHandles;
315  }
316  if (mRedraw)
317  {
318  mLastRedraw = true;
319  mRedraw = false;
320  update = true;
321  mVertexes->clear();
322  graphics->calcWindow(mVertexes,
323  0, 0,
326  mSkin->getBorder());
327 
328  // Draw Close Button
329  if (mCloseWindowButton)
330  {
331  const Image *const button = mSkin->getCloseImage(
332  mResizeHandles == CLOSE);
333  if (button != nullptr)
334  {
335  graphics->calcTileCollection(mVertexes,
336  button,
337  mCloseRect.x,
338  mCloseRect.y);
339  }
340  }
341  // Draw Sticky Button
342  if (mStickyButton)
343  {
344  const Image *const button = mSkin->getStickyImage(mSticky);
345  if (button != nullptr)
346  {
347  graphics->calcTileCollection(mVertexes,
348  button,
349  mStickyRect.x,
350  mStickyRect.y);
351  }
352  }
353 
354  if (mGrip != nullptr)
355  {
356  graphics->calcTileCollection(mVertexes,
357  mGrip,
358  mGripRect.x,
359  mGripRect.y);
360  }
361  graphics->finalize(mVertexes);
362  }
363  else
364  {
365  mLastRedraw = false;
366  }
367  graphics->drawTileCollection(mVertexes);
368 
369  // Draw title
370  if (mShowTitle)
371  {
372  int x;
373  switch (mCaptionAlign)
374  {
375  case Graphics::LEFT:
376  default:
377  x = mCaptionOffsetX;
378  break;
379  case Graphics::CENTER:
381  break;
382  case Graphics::RIGHT:
384  break;
385  }
386  if (mTextChanged)
387  {
394  mTextChanged = false;
395  }
396 
397  const Image *const image = mTextChunk.img;
398  if (image != nullptr)
399  graphics->drawImage(image, x, mCaptionOffsetY);
400  }
401 
402  if (update)
403  {
404  graphics->setRedraw(update);
405  drawChildren(graphics);
406  graphics->setRedraw(false);
407  }
408  else
409  {
410  drawChildren(graphics);
411  }
412  BLOCK_END("Window::draw")
413 }
bool mShowTitle
Definition: window.h:648
Rect mGripRect
Definition: window.h:684
int width
Definition: rect.h:218
std::string text
Definition: textchunk.h:64
Font * mCaptionFont
Definition: window.h:711
Skin * mSkin
Definition: window.h:641
TextChunk mTextChunk
Definition: window.h:685
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
int mOldResizeHandles
Definition: window.h:707
bool mTextChanged
Definition: window.h:721
int mCaptionOffsetY
Definition: window.h:647
#define BLOCK_START(name)
Definition: perfomance.h:78
ImageCollection * mVertexes
Definition: window.h:702
if(!vert) return
Rect mCloseRect
Definition: window.h:682
bool mStickyButton
Definition: window.h:716
#define BLOCK_END(name)
Definition: perfomance.h:79
Color mForegroundColor
Definition: widget.h:1085
int mCaptionOffsetX
Definition: window.h:646
Font * textFont
Definition: textchunk.h:63
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
int x
Definition: rect.h:208
const ImageRect & getBorder() const
Definition: skin.h:67
bool mLastRedraw
Definition: window.h:649
int y
Definition: rect.h:213
Graphics::Alignment mCaptionAlign
Definition: window.h:703
const Image * getStickyImage(const bool state) const
Definition: skin.h:80
int height
Definition: rect.h:223
bool mCloseWindowButton
Definition: window.h:713
int mResizeHandles
Definition: window.h:706
bool mSticky
Definition: window.h:717
Rect mStickyRect
Definition: window.h:683
std::string mCaption
Definition: window.h:600
const Image * getCloseImage(const bool state) const
Definition: skin.h:73
Color mForegroundColor2
Definition: widget2.h:112
Image * img
Definition: textchunk.h:62
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void drawChildren(Graphics *const graphics)
int getWidth(const std::string &text) const
Definition: font.cpp:333
bool mRedraw
Definition: widget.h:1163
Definition: image.h:61
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
Color color
Definition: textchunk.h:65
void setRedraw(const bool n)
Definition: graphics.h:283
void deleteImage()
Definition: textchunk.cpp:192
Color color2
Definition: textchunk.h:66
Rect mDimension
Definition: widget.h:1100
void update()
Definition: useragent.cpp:31
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
void generate(TextChunk &chunk)
Definition: font.cpp:428
Image * mGrip
Definition: window.h:679

◆ enableVisibleSound()

void Window::enableVisibleSound ( bool  b)
inline

◆ ensureOnScreen()

void Window::ensureOnScreen ( )
private

Ensures the window is on the screen, moving it if necessary. This is used by loadWindowState and setVisible(true), and when the screen is resized.

Definition at line 1415 of file window.cpp.

References Rect::height, mainGraphics, Widget::mDimension, Graphics::mHeight, Graphics::mWidth, Rect::width, Rect::x, and Rect::y.

Referenced by adjustPositionAfterResize(), loadWindowState(), and setVisible().

1416 {
1417  // Skip when a window hasn't got any size initialized yet
1418  if (mDimension.width == 0 && mDimension.height == 0)
1419  return;
1420 
1421  // Check the left and bottom screen boundaries
1426 
1427  // But never allow the windows to disappear in to the right and top
1428  if (mDimension.x < 0)
1429  mDimension.x = 0;
1430  if (mDimension.y < 0)
1431  mDimension.y = 0;
1432 }
int width
Definition: rect.h:218
int mWidth
Definition: graphics.h:483
int x
Definition: rect.h:208
int y
Definition: rect.h:213
Graphics * mainGraphics
Definition: graphics.cpp:108
int height
Definition: rect.h:223
int mHeight
Definition: graphics.h:484
Rect mDimension
Definition: widget.h:1100

◆ getAlignment()

Graphics::Alignment Window::getAlignment ( ) const
inline

Gets the alignment of the caption.

Returns
The alignment of caption.
See also
setAlignment, Graphics

Definition at line 550 of file window.h.

References mAlignment.

551  { return mAlignment; }
Graphics::Alignment mAlignment
Definition: window.h:605

◆ getAlowClose()

bool Window::getAlowClose ( ) const
inline

Definition at line 190 of file window.h.

References A_WARN_UNUSED, isResizable(), mAllowClose, mCloseWindowButton, and setMinWidth().

Referenced by PopupMenu::addWindowMenu().

191  { return mCloseWindowButton || mAllowClose; }
bool mAllowClose
Definition: window.h:722
bool mCloseWindowButton
Definition: window.h:713

◆ getCaption()

const std::string& Window::getCaption ( ) const
inline

Gets the caption of the window.

Returns
the caption of the window.
See also
setCaption

Definition at line 532 of file window.h.

References mCaption.

Referenced by ConfirmDialog::postInit(), and ~Window().

533  { return mCaption; }
std::string mCaption
Definition: window.h:600

◆ getChildrenArea()

Rect Window::getChildrenArea ( )
virtual

Gets the area of the widget occupied by the widget's children. By default this method returns an empty rectangle as not all widgets are containers. If you want to make a container this method should return the area where the children resides. This method is used when drawing children of a widget when computing clip rectangles for the children.

An example of a widget that overloads this method is ScrollArea. A ScrollArea has a view of its contant and that view is the children area. The size of a ScrollArea's children area might vary depending on if the scroll bars of the ScrollArea is shown or not.

Returns
The area of the widget occupied by the widget's children.
See also
BasicContainer
BasicContainer::getChildrenArea
BasicContainer::drawChildren

Reimplemented from BasicContainer.

Reimplemented in MiniStatusWindow.

Definition at line 1461 of file window.cpp.

References Rect::height, Widget::mDimension, mPadding, mTitleBarHeight, and Rect::width.

Referenced by ChatWindow::adjustTabSize(), Minimap::draw2(), isMovable(), EquipmentWindow::postInit(), redraw(), Minimap::screenToMap(), WhoIsOnline::updateSize(), SetupWindow::widgetResized(), and widgetResized().

1462 {
1463  return Rect(mPadding,
1465  mDimension.width - mPadding * 2,
1467 }
int width
Definition: rect.h:218
int mPadding
Definition: window.h:610
Definition: rect.h:72
int height
Definition: rect.h:223
Rect mDimension
Definition: widget.h:1100
unsigned int mTitleBarHeight
Definition: window.h:615

◆ getCloseButton()

bool Window::getCloseButton ( ) const
inline

Definition at line 184 of file window.h.

References mCloseWindowButton.

185  { return mCloseWindowButton; }
bool mCloseWindowButton
Definition: window.h:713

◆ getLayout()

Layout & Window::getLayout ( )

◆ getMaxHeight()

int Window::getMaxHeight ( ) const
inline

Definition at line 227 of file window.h.

References mMaxWinHeight.

Referenced by loadWindowState(), and saveWindowState().

228  { return mMaxWinHeight; }
int mMaxWinHeight
Definition: window.h:690

◆ getMaxWidth()

int Window::getMaxWidth ( ) const
inline

Definition at line 219 of file window.h.

References mMaxWinWidth, and setMaxHeight().

Referenced by loadWindowState(), and saveWindowState().

220  { return mMaxWinWidth; }
int mMaxWinWidth
Definition: window.h:689

◆ getMinHeight()

int Window::getMinHeight ( ) const
inline

Definition at line 211 of file window.h.

References mMinWinHeight, and setMaxWidth().

Referenced by loadWindowState(), and saveWindowState().

212  { return mMinWinHeight; }
int mMinWinHeight
Definition: window.h:688

◆ getMinWidth()

int Window::getMinWidth ( ) const
inline

Definition at line 203 of file window.h.

References mMinWinWidth, and setMinHeight().

Referenced by loadWindowState(), OkDialog::OkDialog(), ConfirmDialog::postInit(), and saveWindowState().

204  { return mMinWinWidth; }
int mMinWinWidth
Definition: window.h:687

◆ getOption()

int Window::getOption ( const std::string &  name,
const int  def = 0 
) const
protected

Definition at line 1442 of file window.cpp.

References Skin::getOption(), and mSkin.

Referenced by CharCreateDialog::CharCreateDialog(), EquipmentWindow::EquipmentWindow(), BuySellDialog::init(), isMovable(), OkDialog::OkDialog(), SetupWindow::postInit(), EditDialog::postInit(), ConfirmDialog::postInit(), ShopWindow::ShopWindow(), and Window().

1443 {
1444  if (mSkin != nullptr)
1445  {
1446  const int val = mSkin->getOption(name);
1447  if (val != 0)
1448  return val;
1449  return def;
1450  }
1451  return def;
1452 }
Skin * mSkin
Definition: window.h:641
int getOption(const std::string &name) const
Definition: skin.h:105

◆ getOptionBool()

bool Window::getOptionBool ( const std::string &  name,
const bool  def = false 
) const
protected

Definition at line 1454 of file window.cpp.

References Skin::getOption(), and mSkin.

Referenced by SocialWindow::addTab(), BuyDialog::init(), InventoryWindow::InventoryWindow(), isMovable(), SocialWindow::postInit(), TextSelectDialog::postInit(), SellDialog::postInit(), ServerDialog::ServerDialog(), Window(), and WorldSelectDialog::WorldSelectDialog().

1455 {
1456  if (mSkin != nullptr)
1457  return mSkin->getOption(name, static_cast<int>(def)) != 0;
1458  return def;
1459 }
Skin * mSkin
Definition: window.h:641
int getOption(const std::string &name) const
Definition: skin.h:105

◆ getPadding()

int Window::getPadding ( ) const
inline

Gets the padding of the window. The padding is the distance between the window border and the content.

Returns
The padding of the window.
See also
setPadding

Definition at line 496 of file window.h.

References mPadding.

Referenced by EquipmentWindow::addBox(), CharSelectDialog::CharSelectDialog(), ChatWindow::ChatWindow(), EquipmentWindow::loadSlot(), NpcDialog::logic(), EmoteWindow::postInit(), EditDialog::postInit(), CharCreateDialog::setAttributes(), Minimap::setMap(), and ShortcutWindow::ShortcutWindow().

497  { return mPadding; }
int mPadding
Definition: window.h:610

◆ getParentWindow()

Window* Window::getParentWindow ( ) const
inline

Returns the parent window.

Returns
The parent window or NULL if there is none.

Definition at line 308 of file window.h.

References mouseDragged(), mouseEntered(), mouseExited(), mouseMoved(), mousePressed(), mouseReleased(), mParentWindow, scheduleDelete(), and updateResizeHandler().

Referenced by EditServerDialog::EditServerDialog(), and ItemAmountWindow::ItemAmountWindow().

309  { return mParentWindow; }
Window * mParentWindow
Definition: window.h:680

◆ getPlacer()

ContainerPlacer Window::getPlacer ( const int  x,
const int  y 
)

◆ getResizeHandles()

int Window::getResizeHandles ( const MouseEvent event)
private

Determines if the mouse is in a resize area and returns appropriate resize handles. Also initializes drag offset in case the resize grip is used.

See also
ResizeHandles

Definition at line 1294 of file window.cpp.

References BOTTOM, CAST_S32, CAST_U32, CLOSE, getWindowArea(), MouseEvent::getX(), Rect::height, Rect::isPointInRect(), LEFT, mCloseRect, Widget::mDimension, mDragOffsetX, mDragOffsetY, mGrip, mGripRect, mPadding, mSticky, mStickyButtonLock, mTitleBarHeight, resizeBorderWidth, RIGHT, TOP, Rect::width, x, Rect::x, y, and Rect::y.

Referenced by mousePressed(), and updateResizeHandler().

1295 {
1296  if (event.getX() < 0 || event.getY() < 0)
1297  return 0;
1298 
1299  int resizeHandles = 0;
1300  const unsigned y = event.getY();
1301  const unsigned x = event.getX();
1302  if (mCloseRect.isPointInRect(x, y))
1303  return CLOSE;
1304 
1305  if (!mStickyButtonLock || !mSticky)
1306  {
1307  if ((mGrip != nullptr) &&
1308  (y > mTitleBarHeight ||
1309  (CAST_S32(y) < mPadding &&
1311  {
1312  if (!getWindowArea().isPointInRect(x, y)
1313  && event.getSource() == this)
1314  {
1315  resizeHandles |= (x > mDimension.width - resizeBorderWidth)
1316  ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
1317  resizeHandles |= (y > mDimension.height - resizeBorderWidth)
1318  ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
1319  }
1320  if (x >= CAST_U32(mGripRect.x)
1321  && y >= CAST_U32(mGripRect.y))
1322  {
1323  mDragOffsetX = x;
1324  mDragOffsetY = y;
1325  resizeHandles |= BOTTOM | RIGHT;
1326  }
1327  }
1328  }
1329 
1330  return resizeHandles;
1331 }
#define CAST_U32
Definition: cast.h:30
Rect mGripRect
Definition: window.h:684
int width
Definition: rect.h:218
int mDragOffsetY
Definition: window.h:634
int mPadding
Definition: window.h:610
bool mStickyButtonLock
Definition: window.h:718
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
Rect mCloseRect
Definition: window.h:682
int mDragOffsetX
Definition: window.h:627
int x
Definition: rect.h:208
#define CAST_S32
Definition: cast.h:29
int y
Definition: rect.h:213
static const unsigned resizeBorderWidth
Definition: window.h:701
int height
Definition: rect.h:223
Rect getWindowArea() const
Definition: window.cpp:1434
bool mSticky
Definition: window.h:717
int getX() const
Definition: mouseevent.h:124
Rect mDimension
Definition: widget.h:1100
unsigned int mTitleBarHeight
Definition: window.h:615
Image * mGrip
Definition: window.h:679

◆ getTitleBarHeight()

unsigned int Window::getTitleBarHeight ( ) const
inline

Gets the title bar height.

Returns
The title bar height.
See also
setTitleBarHeight

Definition at line 514 of file window.h.

References mTitleBarHeight.

Referenced by EquipmentWindow::addBox(), EquipmentWindow::loadSlot(), and Minimap::setMap().

515  { return mTitleBarHeight; }
unsigned int mTitleBarHeight
Definition: window.h:615

◆ getTitlePadding()

int Window::getTitlePadding ( ) const
inlineprotected

◆ getWindowArea()

Rect Window::getWindowArea ( ) const

Definition at line 1434 of file window.cpp.

References Rect::height, Widget::mDimension, mPadding, and Rect::width.

Referenced by getResizeHandles(), getWindowName(), and isResizeAllowed().

1435 {
1436  return Rect(mPadding,
1437  mPadding,
1438  mDimension.width - mPadding * 2,
1439  mDimension.height - mPadding * 2);
1440 }
int width
Definition: rect.h:218
int mPadding
Definition: window.h:610
Definition: rect.h:72
int height
Definition: rect.h:223
Rect mDimension
Definition: widget.h:1100

◆ getWindowName()

const std::string& Window::getWindowName ( ) const
inline

◆ isDefaultVisible()

bool Window::isDefaultVisible ( ) const
inline

Returns whether the window is visible by default.

Definition at line 280 of file window.h.

References mDefaultVisible.

281  { return mDefaultVisible; }
bool mDefaultVisible
Definition: window.h:714

◆ isMovable()

bool Window::isMovable ( ) const
inline

Checks if the window is movable.

Returns
True if the window is movable, false otherwise.
See also
setMovable

Definition at line 568 of file window.h.

References A_WARN_UNUSED, canMove(), getChildrenArea(), getOption(), getOptionBool(), BasicContainer::logic(), mMovable, Move_true, and resizeToContent().

Referenced by ShortcutWindow::mouseDragged(), ChatWindow::mouseDragged(), and mouseDragged().

569  { return mMovable == Move_true; }
const bool Move_true
Definition: move.h:29
Move mMovable
Definition: window.h:620

◆ isResizable()

bool Window::isResizable ( ) const

Returns whether the window can be resized.

Definition at line 744 of file window.cpp.

References mGrip.

Referenced by getAlowClose().

745 {
746  return mGrip != nullptr;
747 }
Image * mGrip
Definition: window.h:679

◆ isResizeAllowed()

bool Window::isResizeAllowed ( const MouseEvent event) const

Definition at line 1333 of file window.cpp.

References CAST_S32, Event::getSource(), getWindowArea(), mGrip, mGripRect, mPadding, mTitleBarHeight, x, Rect::x, y, and Rect::y.

Referenced by getWindowName(), and ChatWindow::mousePressed().

1334 {
1335  const int y = event.getY();
1336 
1337  if ((mGrip != nullptr) &&
1338  (y > CAST_S32(mTitleBarHeight) ||
1339  y < mPadding))
1340  {
1341  const int x = event.getX();
1342 
1343  if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
1344  return true;
1345 
1346  if (x >= mGripRect.x && y >= mGripRect.y)
1347  return true;
1348  }
1349 
1350  return false;
1351 }
Rect mGripRect
Definition: window.h:684
int mPadding
Definition: window.h:610
int x
Definition: rect.h:208
#define CAST_S32
Definition: cast.h:29
Widget * getSource() const
Definition: event.h:103
int y
Definition: rect.h:213
Rect getWindowArea() const
Definition: window.cpp:1434
unsigned int mTitleBarHeight
Definition: window.h:615
Image * mGrip
Definition: window.h:679

◆ isSticky()

bool Window::isSticky ( ) const
inline

Returns whether the window is sticky.

Definition at line 251 of file window.h.

References mSticky, and setStickyButtonLock().

Referenced by PopupMenu::addWindowMenu(), SetupWindow::hideWindows(), loadWindowState(), Minimap::Minimap(), mousePressed(), saveWindowState(), Minimap::setMap(), and Minimap::toggle().

252  { return mSticky; }
bool mSticky
Definition: window.h:717

◆ isStickyButtonLock()

bool Window::isStickyButtonLock ( ) const
inline

Returns whether the window sticky locking window.

Definition at line 262 of file window.h.

References mStickyButtonLock, and setVisible().

Referenced by PopupMenu::addWindowMenu().

263  { return mStickyButtonLock; }
bool mStickyButtonLock
Definition: window.h:718

◆ isWindowVisible()

bool Window::isWindowVisible ( ) const
inline

◆ loadWindowState()

void Window::loadWindowState ( )

Reads the position (and the size for resizable windows) in the configuration based on the given string. Uses the default values when config values are missing. Don't forget to set these default values and resizable before calling this function.

Definition at line 1075 of file window.cpp.

References config, ensureOnScreen(), fromBool, Widget::getHeight(), getMaxHeight(), getMaxWidth(), getMinHeight(), getMinWidth(), ConfigurationObject::getValueBool(), ConfigurationObject::getValueInt(), Widget::getWidth(), Rect::height, isSticky(), mDefaultHeight, mDefaultVisible, mDefaultWidth, mDefaultX, mDefaultY, Widget::mDimension, mGrip, mSaveVisible, mStickyButton, mWindowName, Widget::setPosition(), Widget::setSize(), setSticky(), setVisible(), viewport, Rect::width, Rect::x, and Rect::y.

Referenced by BankWindow::BankWindow(), ChatWindow::ChatWindow(), DebugWindow::DebugWindow(), DidYouKnowWindow::DidYouKnowWindow(), EditServerDialog::EditServerDialog(), EquipmentWindow::EquipmentWindow(), getWindowName(), HelpWindow::HelpWindow(), BuySellDialog::init(), BuyDialog::init(), InventoryWindow::InventoryWindow(), KillStats::KillStats(), MailEditWindow::MailEditWindow(), MailViewWindow::MailViewWindow(), MailWindow::MailWindow(), Minimap::Minimap(), NpcDialog::NpcDialog(), OutfitWindow::OutfitWindow(), SocialWindow::postInit(), WhoIsOnline::postInit(), LoginDialog::postInit(), SkillDialog::postInit(), TextSelectDialog::postInit(), SellDialog::postInit(), QuestsWindow::QuestsWindow(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), ShopWindow::ShopWindow(), ShortcutWindow::ShortcutWindow(), StatusWindow::StatusWindow(), TradeWindow::TradeWindow(), and UpdaterWindow::UpdaterWindow().

1076 {
1077  const std::string &name = mWindowName;
1078  if (name.empty())
1079  return;
1080 
1081  setPosition(config.getValueInt(name + "WinX", mDefaultX),
1082  config.getValueInt(name + "WinY", mDefaultY));
1083 
1084  if (mSaveVisible)
1085  {
1087  + "Visible", mDefaultVisible), Visible));
1088  }
1089 
1090  if (mStickyButton)
1091  {
1093  + "Sticky", isSticky()));
1094  }
1095 
1096  if (mGrip != nullptr)
1097  {
1098  int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
1099  int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
1100 
1101  if (getMinWidth() > width)
1102  width = getMinWidth();
1103  else if (getMaxWidth() < width)
1104  width = getMaxWidth();
1105  if (getMinHeight() > height)
1106  height = getMinHeight();
1107  else if (getMaxHeight() < height)
1108  height = getMaxHeight();
1109 
1110  setSize(width, height);
1111  }
1112  else
1113  {
1115  }
1116 
1117  // Check if the window is off screen...
1118  ensureOnScreen();
1119 
1120  if (viewport != nullptr)
1121  {
1122  int width = mDimension.width;
1123  int height = mDimension.height;
1124 
1125  if (mDimension.x + width > viewport->getWidth())
1126  width = viewport->getWidth() - mDimension.x;
1127  if (mDimension.y + height > viewport->getHeight())
1128  height = viewport->getHeight() - mDimension.y;
1129  if (width < 0)
1130  width = 0;
1131  if (height < 0)
1132  height = 0;
1133  setSize(width, height);
1134  }
1135 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
std::string mWindowName
Definition: window.h:686
int width
Definition: rect.h:218
int getWidth() const
Definition: widget.h:220
Configuration config
bool mDefaultVisible
Definition: window.h:714
bool mStickyButton
Definition: window.h:716
int mDefaultY
Definition: window.h:643
void ensureOnScreen()
Definition: window.cpp:1415
int getMinHeight() const
Definition: window.h:211
int x
Definition: rect.h:208
void setSticky(const bool sticky)
Definition: window.cpp:754
#define fromBool(val, name)
Definition: booldefines.h:48
int mDefaultWidth
Definition: window.h:644
int y
Definition: rect.h:213
bool getValueBool(const std::string &key, const bool deflt) const
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int height
Definition: rect.h:223
int getMaxHeight() const
Definition: window.h:227
bool mSaveVisible
Definition: window.h:715
virtual void setVisible(Visible visible)
Definition: window.cpp:766
bool Visible
Definition: visible.h:29
int mDefaultHeight
Definition: window.h:645
int getMaxWidth() const
Definition: window.h:219
int mDefaultX
Definition: window.h:642
int getHeight() const
Definition: widget.h:239
bool isSticky() const
Definition: window.h:251
int getValueInt(const std::string &key, const int deflt) const
Rect mDimension
Definition: widget.h:1100
int getMinWidth() const
Definition: window.h:203
Viewport * viewport
Definition: viewport.cpp:35
Image * mGrip
Definition: window.h:679

◆ mouseDragged()

void Window::mouseDragged ( MouseEvent event)
virtual

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

Reimplemented from MouseListener.

Reimplemented in ChatWindow, ShortcutWindow, and OutfitWindow.

Definition at line 970 of file window.cpp.

References BOTTOM, canMove(), InputGuiEvent::consume(), Widget::getDimension(), Widget::getHeight(), MouseEvent::getX(), Widget::getX(), Widget::getY(), Rect::height, InputGuiEvent::isConsumed(), isMovable(), LEFT, mainGraphics, Widget::mDimension, mDragOffsetX, mDragOffsetY, Graphics::mHeight, mMaxWinHeight, mMaxWinWidth, mMinWinHeight, mMinWinWidth, mMoved, mouseResize, Graphics::mWidth, RIGHT, Widget::setDimension(), Widget::setPosition(), TOP, Rect::width, Rect::x, and Rect::y.

Referenced by getParentWindow(), OutfitWindow::mouseDragged(), ShortcutWindow::mouseDragged(), and ChatWindow::mouseDragged().

971 {
972  if (canMove())
973  {
974  if (!event.isConsumed() && event.getSource() == this)
975  {
976  if (isMovable() && mMoved)
977  {
978  setPosition(event.getX() - mDragOffsetX + getX(),
979  event.getY() - mDragOffsetY + getY());
980  }
981 
982  event.consume();
983  }
984  }
985  else
986  {
987  if (!event.isConsumed() && event.getSource() == this)
988  event.consume();
989  return;
990  }
991 
992  // Keep guichan window inside screen when it may be moved
993  if (isMovable() && mMoved)
994  {
996  std::max(0, mDimension.x)),
998  std::max(0, mDimension.y)));
999  }
1000 
1001  if ((mouseResize != 0) && !mMoved)
1002  {
1003  const int dx = event.getX() - mDragOffsetX;
1004  const int dy = event.getY() - mDragOffsetY;
1005  Rect newDim = getDimension();
1006 
1007  if ((mouseResize & (TOP | BOTTOM)) != 0)
1008  {
1009  const int newHeight = newDim.height
1010  + ((mouseResize & TOP) != 0 ? -dy : dy);
1011  newDim.height = std::min(mMaxWinHeight,
1012  std::max(mMinWinHeight, newHeight));
1013 
1014  if ((mouseResize & TOP) != 0)
1015  newDim.y -= newDim.height - getHeight();
1016  }
1017 
1018  if ((mouseResize & (LEFT | RIGHT)) != 0)
1019  {
1020  const int newWidth = newDim.width
1021  + ((mouseResize & LEFT) != 0 ? -dx : dx);
1022  newDim.width = std::min(mMaxWinWidth,
1023  std::max(mMinWinWidth, newWidth));
1024 
1025  if ((mouseResize & LEFT) != 0)
1026  newDim.x -= newDim.width - mDimension.width;
1027  }
1028 
1029  // Keep guichan window inside screen (supports resizing any side)
1030  if (newDim.x < 0)
1031  {
1032  newDim.width += newDim.x;
1033  newDim.x = 0;
1034  }
1035  if (newDim.y < 0)
1036  {
1037  newDim.height += newDim.y;
1038  newDim.y = 0;
1039  }
1040  if (newDim.x + newDim.width > mainGraphics->mWidth)
1041  newDim.width = mainGraphics->mWidth - newDim.x;
1042  if (newDim.y + newDim.height > mainGraphics->mHeight)
1043  newDim.height = mainGraphics->mHeight - newDim.y;
1044 
1045  // Update mouse offset when dragging bottom or right border
1046  if ((mouseResize & BOTTOM) != 0)
1047  mDragOffsetY += newDim.height - mDimension.height;
1048 
1049  if ((mouseResize & RIGHT) != 0)
1050  mDragOffsetX += newDim.width - mDimension.width;
1051 
1052  // Set the new window and content dimensions
1053  setDimension(newDim);
1054  }
1055 }
int width
Definition: rect.h:218
int mDragOffsetY
Definition: window.h:634
int getY() const
Definition: widget.h:287
static int mouseResize
Definition: window.h:692
Definition: rect.h:72
int mWidth
Definition: graphics.h:483
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
bool mMoved
Definition: window.h:639
int mDragOffsetX
Definition: window.h:627
bool isMovable() const
Definition: window.h:568
int mMaxWinWidth
Definition: window.h:689
int x
Definition: rect.h:208
bool canMove() const
Definition: window.cpp:965
int y
Definition: rect.h:213
Graphics * mainGraphics
Definition: graphics.cpp:108
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int height
Definition: rect.h:223
int mHeight
Definition: graphics.h:484
bool isConsumed() const
const Rect & getDimension() const
Definition: widget.h:316
int getX() const
Definition: widget.h:268
int getHeight() const
Definition: widget.h:239
int getX() const
Definition: mouseevent.h:124
Rect mDimension
Definition: widget.h:1100
int mMinWinWidth
Definition: window.h:687
int mMaxWinHeight
Definition: window.h:690
int mMinWinHeight
Definition: window.h:688

◆ mouseEntered()

void Window::mouseEntered ( MouseEvent event)
virtual

Called when the mouse has entered into the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Reimplemented in ChatWindow.

Definition at line 907 of file window.cpp.

References updateResizeHandler().

Referenced by getParentWindow(), and ChatWindow::mouseEntered().

908 {
909  updateResizeHandler(event);
910 }
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:918

◆ mouseExited()

void Window::mouseExited ( MouseEvent event)
virtual

When the mouse leaves the window this ensures that the custom cursor is restored back to it's standard image.

Reimplemented from MouseListener.

Reimplemented in ChatWindow, InventoryWindow, EquipmentWindow, MiniStatusWindow, Minimap, and ItemAmountWindow.

Definition at line 912 of file window.cpp.

References Cursor::CURSOR_POINTER, gui, mGrip, mouseResize, and Gui::setCursorType().

Referenced by getParentWindow(), Minimap::mouseExited(), MiniStatusWindow::mouseExited(), and ChatWindow::mouseExited().

913 {
914  if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
916 }
Gui * gui
Definition: gui.cpp:110
static int mouseResize
Definition: window.h:692
void setCursorType(const CursorT index)
Definition: gui.h:195
Image * mGrip
Definition: window.h:679

◆ mouseMoved()

void Window::mouseMoved ( MouseEvent event)
virtual

Implements custom cursor image changing context, based on mouse relative position.

Reimplemented from MouseListener.

Reimplemented in ChatWindow, InventoryWindow, EquipmentWindow, MiniStatusWindow, Minimap, and ItemAmountWindow.

Definition at line 955 of file window.cpp.

References PopupManager::hideBeingPopup(), PopupManager::hideTextPopup(), InputGuiEvent::isConsumed(), popupManager, and updateResizeHandler().

Referenced by getParentWindow(), ItemAmountWindow::mouseMoved(), Minimap::mouseMoved(), MiniStatusWindow::mouseMoved(), EquipmentWindow::mouseMoved(), InventoryWindow::mouseMoved(), ChatWindow::mouseMoved(), and setVisible().

956 {
957  updateResizeHandler(event);
958  if ((popupManager != nullptr) && !event.isConsumed())
959  {
962  }
963 }
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:918
PopupManager * popupManager
static void hideTextPopup()
bool isConsumed() const
static void hideBeingPopup()

◆ mousePressed()

void Window::mousePressed ( MouseEvent event)
virtual

Starts window resizing when appropriate.

Reimplemented from MouseListener.

Reimplemented in NpcDialog, ChatWindow, EquipmentWindow, MiniStatusWindow, Minimap, ShortcutWindow, and OutfitWindow.

Definition at line 824 of file window.cpp.

References canMove(), CAST_S32, close(), Widget::getParent(), getResizeHandles(), Event::getSource(), InputGuiEvent::isConsumed(), Rect::isPointInRect(), isSticky(), MouseButton::LEFT, mCloseRect, mCloseWindowButton, mDragOffsetX, mDragOffsetY, mMoved, mouseResize, Widget::moveToTop(), mSkin, mStickyButton, mStickyRect, mTitleBarHeight, popupMenu, resizeMask, MouseButton::RIGHT, setSticky(), PopupMenu::showWindowPopup(), x, and y.

Referenced by getParentWindow(), OutfitWindow::mousePressed(), ShortcutWindow::mousePressed(), Minimap::mousePressed(), EquipmentWindow::mousePressed(), ChatWindow::mousePressed(), and NpcDialog::mousePressed().

825 {
826  if (event.isConsumed())
827  return;
828 
829  if (event.getSource() == this)
830  {
831  if (getParent() != nullptr)
832  getParent()->moveToTop(this);
833 
834  mDragOffsetX = event.getX();
835  mDragOffsetY = event.getY();
836  mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
837  }
838 
839  const MouseButtonT button = event.getButton();
840  if (button == MouseButton::LEFT)
841  {
842  const int x = event.getX();
843  const int y = event.getY();
844 
845  // Handle close button
846  if (mCloseWindowButton &&
847  mSkin != nullptr &&
849  {
850  mouseResize = 0;
851  mMoved = false;
852  event.consume();
853  close();
854  return;
855  }
856 
857  // Handle sticky button
858  if (mStickyButton &&
859  mSkin != nullptr &&
861  {
862  setSticky(!isSticky());
863  mouseResize = 0;
864  mMoved = false;
865  event.consume();
866  return;
867  }
868 
869  // Handle window resizing
871  if (mouseResize != 0)
872  event.consume();
873  if (canMove())
874  mMoved = (mouseResize == 0);
875  else
876  mMoved = false;
877  }
878 #ifndef DYECMD
879  else if (button == MouseButton::RIGHT)
880  {
881  if (popupMenu != nullptr)
882  {
883  event.consume();
884  popupMenu->showWindowPopup(this);
885  }
886  }
887 #endif // DYECMD
888 }
Skin * mSkin
Definition: window.h:641
int mDragOffsetY
Definition: window.h:634
static int mouseResize
Definition: window.h:692
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
Rect mCloseRect
Definition: window.h:682
bool mStickyButton
Definition: window.h:716
bool mMoved
Definition: window.h:639
int mDragOffsetX
Definition: window.h:627
virtual void close()
Definition: window.cpp:890
#define CAST_S32
Definition: cast.h:29
void setSticky(const bool sticky)
Definition: window.cpp:754
bool canMove() const
Definition: window.cpp:965
Widget * getSource() const
Definition: event.h:103
PopupMenu * popupMenu
Definition: popupmenu.cpp:102
bool mCloseWindowButton
Definition: window.h:713
bool isConsumed() const
Rect mStickyRect
Definition: window.h:683
virtual void moveToTop(Widget *widget)
Definition: widget.h:866
Widget * getParent() const
Definition: widget.h:201
bool isSticky() const
Definition: window.h:251
void showWindowPopup(Window *const window)
Definition: popupmenu.cpp:1153
MouseButton ::T MouseButtonT
Definition: mousebutton.h:77
unsigned int mTitleBarHeight
Definition: window.h:615
int getResizeHandles(const MouseEvent &event)
Definition: window.cpp:1294
const int resizeMask
Definition: window.cpp:103

◆ mouseReleased()

void Window::mouseReleased ( MouseEvent event)
virtual

When the mouse button has been let go, this ensures that the mouse custom cursor is restored back to it's standard image.

Reimplemented from MouseListener.

Reimplemented in EquipmentWindow, Minimap, and OutfitWindow.

Definition at line 895 of file window.cpp.

References Cursor::CURSOR_POINTER, gui, mGrip, mMoved, mouseResize, and Gui::setCursorType().

Referenced by getParentWindow(), OutfitWindow::mouseReleased(), Minimap::mouseReleased(), and EquipmentWindow::mouseReleased().

896 {
897  if ((mGrip != nullptr) && (mouseResize != 0))
898  {
899  mouseResize = 0;
900  if (gui != nullptr)
902  }
903 
904  mMoved = false;
905 }
Gui * gui
Definition: gui.cpp:110
static int mouseResize
Definition: window.h:692
bool mMoved
Definition: window.h:639
void setCursorType(const CursorT index)
Definition: gui.h:195
Image * mGrip
Definition: window.h:679

◆ place()

LayoutCell & Window::place ( const int  x,
const int  y,
Widget *const  wg,
const int  w = 1,
const int  h = 1 
)

Adds a widget to the window and sets it at given cell.

Definition at line 1372 of file window.cpp.

References BasicContainer2::add(), getLayout(), and LayoutCell::place().

Referenced by ShortcutWindow::addButton(), ChangePasswordDialog::ChangePasswordDialog(), ConnectionDialog::ConnectionDialog(), DidYouKnowWindow::DidYouKnowWindow(), EditServerDialog::EditServerDialog(), getWindowName(), HelpWindow::HelpWindow(), InventoryWindow::InventoryWindow(), KillStats::KillStats(), LoginDialog::LoginDialog(), MapDebugTab::MapDebugTab(), NetDebugTab::NetDebugTab(), OutfitWindow::OutfitWindow(), NpcDialog::placeIntInputControls(), NpcDialog::placeItemInputControls(), NpcDialog::placeMenuControls(), NpcDialog::placeNormalControls(), NpcDialog::placeSkinControls(), NpcDialog::placeTextInputControls(), SocialWindow::postInit(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), Setup_Audio::Setup_Audio(), ShortcutWindow::ShortcutWindow(), SkillDialog::SkillDialog(), StatusWindow::StatusWindow(), TargetDebugTab::TargetDebugTab(), TextDialog::TextDialog(), TradeWindow::TradeWindow(), and WorldSelectDialog::WorldSelectDialog().

1374 {
1375  add(wg);
1376  return getLayout().place(wg, x, y, w, h);
1377 }
LayoutCell & place(Widget *const wg, const int x, const int y, const int w=1, const int h=1)
Definition: layoutcell.cpp:110
virtual void add(Widget *const widget)
Layout & getLayout()
Definition: window.cpp:1353

◆ postInit()

void Window::postInit ( )
virtual

Reimplemented from Widget.

Reimplemented in ChatWindow, CharSelectDialog, UpdaterWindow, NpcDialog, ShopWindow, InventoryWindow, TextSelectDialog, ServerDialog, EquipmentWindow, SkillDialog, ConfirmDialog, LoginDialog, RegisterDialog, TextCommandEditor, WhoIsOnline, EditServerDialog, QuitDialog, EditDialog, TextDialog, SocialWindow, WorldSelectDialog, ConnectionDialog, ItemAmountWindow, DidYouKnowWindow, SetupWindow, DebugWindow, EmoteWindow, and ServerInfoWindow.

Definition at line 241 of file window.cpp.

References mInit, mWindowName, and reportAlways.

Referenced by ServerInfoWindow::postInit(), EmoteWindow::postInit(), DebugWindow::postInit(), SetupWindow::postInit(), DidYouKnowWindow::postInit(), ConnectionDialog::postInit(), ItemAmountWindow::postInit(), SocialWindow::postInit(), WorldSelectDialog::postInit(), EditDialog::postInit(), TextDialog::postInit(), QuitDialog::postInit(), EditServerDialog::postInit(), WhoIsOnline::postInit(), TextCommandEditor::postInit(), RegisterDialog::postInit(), ConfirmDialog::postInit(), LoginDialog::postInit(), SkillDialog::postInit(), EquipmentWindow::postInit(), ServerDialog::postInit(), TextSelectDialog::postInit(), InventoryWindow::postInit(), ShopWindow::postInit(), NpcDialog::postInit(), UpdaterWindow::postInit(), CharSelectDialog::postInit(), SellDialog::postInit(), ChatWindow::postInit(), and setSaveVisible().

242 {
243  if (mInit)
244  {
245  reportAlways("error: Window created with calling postInit() "
246  "more than once: %s",
247  mWindowName.c_str());
248  }
249  mInit = true;
250 }
std::string mWindowName
Definition: window.h:686
bool mInit
Definition: window.h:720
#define reportAlways(...)
Definition: checkutils.h:252

◆ redraw()

void Window::redraw ( )

Definition at line 1394 of file window.cpp.

References getChildrenArea(), Rect::height, mLayout, Layout::reflow(), and Rect::width.

Referenced by NpcDialog::buildLayout().

1395 {
1396  if (mLayout != nullptr)
1397  {
1398  const Rect area = getChildrenArea();
1399  int w = area.width;
1400  int h = area.height;
1401  mLayout->reflow(w, h);
1402  }
1403 }
int width
Definition: rect.h:218
Rect getChildrenArea()
Definition: window.cpp:1461
Definition: rect.h:72
void reflow(int &nW, int &nH)
Definition: layout.cpp:35
int height
Definition: rect.h:223
Layout * mLayout
Definition: window.h:681

◆ reflowLayout()

void Window::reflowLayout ( int  w = 0,
int  h = 0 
)

Computes the position of the widgets according to the current layout. Resizes the window so that the layout fits. Deletes the layout.

Parameters
wif non-zero, force the window to this width.
hif non-zero, force the window to this height.
Note
This function is meant to be called with fixed-size windows.

Definition at line 1384 of file window.cpp.

References delete2, mLayout, Layout::reflow(), and setContentSize().

Referenced by BankWindow::BankWindow(), ChangePasswordDialog::ChangePasswordDialog(), CharSelectDialog::CharSelectDialog(), ConnectionDialog::ConnectionDialog(), getWindowName(), ItemAmountWindow::ItemAmountWindow(), LoginDialog::postInit(), QuitDialog::QuitDialog(), RegisterDialog::RegisterDialog(), TextCommandEditor::TextCommandEditor(), TextDialog::TextDialog(), and WorldSelectDialog::WorldSelectDialog().

1385 {
1386  if (mLayout == nullptr)
1387  return;
1388 
1389  mLayout->reflow(w, h);
1390  delete2(mLayout);
1391  setContentSize(w, h);
1392 }
void reflow(int &nW, int &nH)
Definition: layout.cpp:35
#define delete2(var)
Definition: delete2.h:24
void setContentSize(int width, int height)
Definition: window.cpp:484
Layout * mLayout
Definition: window.h:681

◆ resetToDefaultSize()

void Window::resetToDefaultSize ( )
virtual

Reset the win pos and size to default. Don't forget to set defaults first.

Definition at line 1247 of file window.cpp.

References mDefaultHeight, mDefaultWidth, mDefaultX, mDefaultY, saveWindowState(), Widget::setPosition(), and Widget::setSize().

Referenced by getWindowName(), and Minimap::setMap().

1248 {
1251  saveWindowState();
1252 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int mDefaultY
Definition: window.h:643
int mDefaultWidth
Definition: window.h:644
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int mDefaultHeight
Definition: window.h:645
int mDefaultX
Definition: window.h:642
void saveWindowState()
Definition: window.cpp:1137

◆ resizeToContent()

void Window::resizeToContent ( )
virtual

Resizes the window to fit the content.

Definition at line 1469 of file window.cpp.

References BLOCK_END, BLOCK_START, Widget::getHeight(), Widget::getWidth(), Widget::getX(), Widget::getY(), BasicContainer::logic(), BasicContainer::logicChildren(), mPadding, mTitleBarHeight, BasicContainer::mWidgets, Widget::setSize(), x, and y.

Referenced by isMovable().

1470 {
1471  int w = 0;
1472  int h = 0;
1473  for (WidgetListConstIterator it = mWidgets.begin();
1474  it != mWidgets.end(); ++ it)
1475  {
1476  const Widget *const widget = *it;
1477  const int x = widget->getX();
1478  const int y = widget->getY();
1479  const int width = widget->getWidth();
1480  const int height = widget->getHeight();
1481  if (x + width > w)
1482  w = x + width;
1483 
1484  if (y + height > h)
1485  h = y + height;
1486  }
1487 
1488  setSize(w + 2 * mPadding,
1489  h + mPadding + mTitleBarHeight);
1490 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int getWidth() const
Definition: widget.h:220
int mPadding
Definition: window.h:610
int getY() const
Definition: widget.h:287
WidgetList::const_iterator WidgetListConstIterator
int getX() const
Definition: widget.h:268
Definition: widget.h:97
int getHeight() const
Definition: widget.h:239
WidgetList mWidgets
unsigned int mTitleBarHeight
Definition: window.h:615

◆ safeDraw()

void Window::safeDraw ( Graphics *const  graphics)
virtual

Reimplemented from BasicContainer2.

Reimplemented in ChatWindow, EquipmentWindow, MiniStatusWindow, Minimap, ConnectionDialog, DebugWindow, OutfitWindow, and CutInWindow.

Definition at line 415 of file window.cpp.

References BLOCK_END, BLOCK_START, Graphics::CENTER, CLOSE, TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), Graphics::drawImage(), Graphics::drawImageRect(), Font::generate(), Skin::getBorder(), Skin::getCloseImage(), Skin::getStickyImage(), Font::getWidth(), Rect::height, TextChunk::img, Graphics::LEFT, mCaption, mCaptionAlign, mCaptionFont, mCaptionOffsetX, mCaptionOffsetY, mCloseRect, mCloseWindowButton, Widget::mDimension, Widget::mForegroundColor, Widget2::mForegroundColor2, mGrip, mGripRect, mResizeHandles, mShowTitle, mSkin, mSticky, mStickyButton, mStickyRect, mTextChanged, mTextChunk, Graphics::RIGHT, BasicContainer::safeDrawChildren(), TextChunk::text, TextChunk::textFont, Rect::width, x, Rect::x, and Rect::y.

Referenced by CutInWindow::safeDraw(), OutfitWindow::safeDraw(), DebugWindow::safeDraw(), Minimap::safeDraw(), EquipmentWindow::safeDraw(), and ChatWindow::safeDraw().

416 {
417  if (mSkin == nullptr)
418  return;
419 
420  BLOCK_START("Window::safeDraw")
421 
422  graphics->drawImageRect(0, 0,
423  mDimension.width,
424  mDimension.height,
425  mSkin->getBorder());
426 
427  // Draw Close Button
429  {
430  const Image *const button = mSkin->getCloseImage(
431  mResizeHandles == CLOSE);
432  if (button != nullptr)
433  graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
434  }
435  // Draw Sticky Button
436  if (mStickyButton)
437  {
438  const Image *const button = mSkin->getStickyImage(mSticky);
439  if (button != nullptr)
440  graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
441  }
442 
443  if (mGrip != nullptr)
444  graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
445 
446  // Draw title
447  if (mShowTitle)
448  {
449  int x;
450  switch (mCaptionAlign)
451  {
452  case Graphics::LEFT:
453  default:
454  x = mCaptionOffsetX;
455  break;
456  case Graphics::CENTER:
458  break;
459  case Graphics::RIGHT:
461  break;
462  }
463  if (mTextChanged)
464  {
471  mTextChanged = false;
472  }
473 
474  const Image *const image = mTextChunk.img;
475  if (image != nullptr)
476  graphics->drawImage(image, x, mCaptionOffsetY);
477  }
478 
479  safeDrawChildren(graphics);
480 
481  BLOCK_END("Window::safeDraw")
482 }
bool mShowTitle
Definition: window.h:648
Rect mGripRect
Definition: window.h:684
std::string text
Definition: textchunk.h:64
Font * mCaptionFont
Definition: window.h:711
Skin * mSkin
Definition: window.h:641
TextChunk mTextChunk
Definition: window.h:685
bool mTextChanged
Definition: window.h:721
int mCaptionOffsetY
Definition: window.h:647
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
Rect mCloseRect
Definition: window.h:682
bool mStickyButton
Definition: window.h:716
#define BLOCK_END(name)
Definition: perfomance.h:79
Color mForegroundColor
Definition: widget.h:1085
int mCaptionOffsetX
Definition: window.h:646
Font * textFont
Definition: textchunk.h:63
int x
Definition: rect.h:208
int y
Definition: rect.h:213
Graphics::Alignment mCaptionAlign
Definition: window.h:703
const Image * getStickyImage(const bool state) const
Definition: skin.h:80
bool mCloseWindowButton
Definition: window.h:713
void drawImageRect(int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 override final
int mResizeHandles
Definition: window.h:706
bool mSticky
Definition: window.h:717
Rect mStickyRect
Definition: window.h:683
std::string mCaption
Definition: window.h:600
const Image * getCloseImage(const bool state) const
Definition: skin.h:73
Color mForegroundColor2
Definition: widget2.h:112
Image * img
Definition: textchunk.h:62
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
int getWidth(const std::string &text) const
Definition: font.cpp:333
Definition: image.h:61
Color color
Definition: textchunk.h:65
void deleteImage()
Definition: textchunk.cpp:192
Color color2
Definition: textchunk.h:66
Rect mDimension
Definition: widget.h:1100
virtual void safeDrawChildren(Graphics *const graphics)
void generate(TextChunk &chunk)
Definition: font.cpp:428
Image * mGrip
Definition: window.h:679

◆ saveWindowState()

void Window::saveWindowState ( )

Saves the window state so that when the window is reloaded, it'll maintain its previous state and location.

Definition at line 1137 of file window.cpp.

References config, getMaxHeight(), getMaxWidth(), getMinHeight(), getMinWidth(), Rect::height, isSticky(), isWindowVisible(), Widget::mDimension, mGrip, mSaveVisible, mStickyButton, mWindowName, Widget::setHeight(), Configuration::setValue(), Widget::setWidth(), Rect::width, Rect::x, and Rect::y.

Referenced by getWindowName(), resetToDefaultSize(), and ~Window().

1138 {
1139  // Saving X, Y and Width and Height for resizables in the config
1140  if (!mWindowName.empty() && mWindowName != "window")
1141  {
1142  config.setValue(mWindowName + "WinX", mDimension.x);
1143  config.setValue(mWindowName + "WinY", mDimension.y);
1144 
1145  if (mSaveVisible)
1146  config.setValue(mWindowName + "Visible", isWindowVisible());
1147 
1148  if (mStickyButton)
1149  config.setValue(mWindowName + "Sticky", isSticky());
1150 
1151  if (mGrip != nullptr)
1152  {
1153  if (getMinWidth() > mDimension.width)
1154  setWidth(getMinWidth());
1155  else if (getMaxWidth() < mDimension.width)
1156  setWidth(getMaxWidth());
1157  if (getMinHeight() > mDimension.height)
1159  else if (getMaxHeight() < mDimension.height)
1161 
1162  config.setValue(mWindowName + "WinWidth", mDimension.width);
1163  config.setValue(mWindowName + "WinHeight", mDimension.height);
1164  }
1165  }
1166 }
std::string mWindowName
Definition: window.h:686
int width
Definition: rect.h:218
void setWidth(const int width)
Definition: widget.cpp:132
Configuration config
bool mStickyButton
Definition: window.h:716
int getMinHeight() const
Definition: window.h:211
int x
Definition: rect.h:208
int y
Definition: rect.h:213
bool isWindowVisible() const
Definition: window.h:476
int height
Definition: rect.h:223
int getMaxHeight() const
Definition: window.h:227
void setHeight(const int height)
Definition: widget.cpp:139
bool mSaveVisible
Definition: window.h:715
int getMaxWidth() const
Definition: window.h:219
bool isSticky() const
Definition: window.h:251
Rect mDimension
Definition: widget.h:1100
void setValue(const std::string &key, const std::string &value)
int getMinWidth() const
Definition: window.h:203
Image * mGrip
Definition: window.h:679

◆ scheduleDelete()

void Window::scheduleDelete ( )
virtual

Schedule this window for deletion. It will be deleted at the start of the next logic update.

Reimplemented in ChatWindow, and TextCommandEditor.

Definition at line 819 of file window.cpp.

References WindowContainer::scheduleDelete(), and windowContainer.

Referenced by MailViewWindow::action(), ConfirmDialog::action(), EditDialog::action(), QuitDialog::action(), EditServerDialog::action(), CharCreateDialog::action(), OkDialog::action(), ServerDialog::action(), ServerInfoWindow::close(), MailEditWindow::close(), ItemAmountWindow::close(), TextDialog::close(), InventoryWindow::close(), DialogsManager::closeDialogs(), createGuiWindows(), WindowManager::createWindows(), UpdaterWindow::deleteSelf(), getParentWindow(), EditServerDialog::keyPressed(), TmwAthena::BeingRecv::processBeingResurrect(), EAthena::BeingRecv::processBeingResurrect(), TmwAthena::CharServerRecv::processCharCreate(), EAthena::CharServerRecv::processCharCreate(), TextCommandEditor::scheduleDelete(), ChatWindow::scheduleDelete(), EggSelectionDialog::sellAction(), InsertCardDialog::sellAction(), BuySellDialog::setVisible(), TextSelectDialog::setVisible(), SellDialog::setVisible(), BuyDialog::setVisible(), NpcDialog::setVisible(), LocalPlayer::slowLogic(), Game::slowLogic(), SocialTab::~SocialTab(), and SocialWindow::~SocialWindow().

820 {
822 }
void scheduleDelete(Widget *const widget)
WindowContainer * windowContainer

◆ setAlignment()

void Window::setAlignment ( Graphics::Alignment  alignment)
inline

Sets the alignment of the caption.

Parameters
alignmentThe alignment of the caption.
See also
getAlignment, Graphics

Definition at line 541 of file window.h.

References mAlignment.

542  { mAlignment = alignment; }
Graphics::Alignment mAlignment
Definition: window.h:605

◆ setAllowClose()

void Window::setAllowClose ( const bool  b)
inline

Definition at line 187 of file window.h.

References mAllowClose.

Referenced by ShortcutWindow::ShortcutWindow().

188  { mAllowClose = b; }
bool mAllowClose
Definition: window.h:722

◆ setCaption()

void Window::setCaption ( const std::string &  caption)
inline

◆ setCaptionFont()

void Window::setCaptionFont ( Font font)
inline

Definition at line 470 of file window.h.

References ServerCommandType::font, and mCaptionFont.

Referenced by TradeWindow::initTrade().

◆ setCloseButton()

void Window::setCloseButton ( const bool  flag)

◆ setContentSize()

void Window::setContentSize ( int  width,
int  height 
)

Sets the size of this window.

Definition at line 484 of file window.cpp.

References mMaxWinHeight, mMaxWinWidth, mMinWinHeight, mMinWinWidth, mPadding, mTitleBarHeight, and Widget::setSize().

Referenced by BankWindow::BankWindow(), ChangeEmailDialog::ChangeEmailDialog(), CharCreateDialog::CharCreateDialog(), DidYouKnowWindow::DidYouKnowWindow(), EditServerDialog::EditServerDialog(), HelpWindow::HelpWindow(), BuySellDialog::init(), NpcDialog::NpcDialog(), OkDialog::OkDialog(), SetupWindow::postInit(), EditDialog::postInit(), ConfirmDialog::postInit(), LoginDialog::postInit(), reflowLayout(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), CharCreateDialog::setAttributes(), and MiniStatusWindow::updateBars().

485 {
486  width = width + 2 * mPadding;
487  height = height + mPadding + mTitleBarHeight;
488 
489  if (mMinWinWidth > width)
490  width = mMinWinWidth;
491  else if (mMaxWinWidth < width)
492  width = mMaxWinWidth;
493  if (mMinWinHeight > height)
494  height = mMinWinHeight;
495  else if (mMaxWinHeight < height)
496  height = mMaxWinHeight;
497 
498  setSize(width, height);
499 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int mPadding
Definition: window.h:610
int mMaxWinWidth
Definition: window.h:689
unsigned int mTitleBarHeight
Definition: window.h:615
int mMinWinWidth
Definition: window.h:687
int mMaxWinHeight
Definition: window.h:690
int mMinWinHeight
Definition: window.h:688

◆ setDefaultSize() [1/3]

void Window::setDefaultSize ( const int  defaultX,
const int  defaultY,
int  defaultWidth,
int  defaultHeight 
)

Set the default win pos and size. (which can be different of the actual ones.)

Definition at line 1168 of file window.cpp.

References mDefaultHeight, mDefaultWidth, mDefaultX, mDefaultY, mMaxWinHeight, mMaxWinWidth, mMinWinHeight, and mMinWinWidth.

1170 {
1171  if (mMinWinWidth > defaultWidth)
1172  defaultWidth = mMinWinWidth;
1173  else if (mMaxWinWidth < defaultWidth)
1174  defaultWidth = mMaxWinWidth;
1175  if (mMinWinHeight > defaultHeight)
1176  defaultHeight = mMinWinHeight;
1177  else if (mMaxWinHeight < defaultHeight)
1178  defaultHeight = mMaxWinHeight;
1179 
1180  mDefaultX = defaultX;
1181  mDefaultY = defaultY;
1182  mDefaultWidth = defaultWidth;
1183  mDefaultHeight = defaultHeight;
1184 }
int mMaxWinWidth
Definition: window.h:689
int mDefaultY
Definition: window.h:643
int mDefaultWidth
Definition: window.h:644
int mDefaultHeight
Definition: window.h:645
int mDefaultX
Definition: window.h:642
int mMinWinWidth
Definition: window.h:687
int mMaxWinHeight
Definition: window.h:690
int mMinWinHeight
Definition: window.h:688

◆ setDefaultSize() [2/3]

void Window::setDefaultSize ( )

Set the default win pos and size to the current ones.

Definition at line 1186 of file window.cpp.

References Rect::height, mDefaultHeight, mDefaultWidth, mDefaultX, mDefaultY, Widget::mDimension, Rect::width, Rect::x, and Rect::y.

Referenced by BankWindow::BankWindow(), ChatWindow::ChatWindow(), DebugWindow::DebugWindow(), DidYouKnowWindow::DidYouKnowWindow(), EditServerDialog::EditServerDialog(), getWindowName(), HelpWindow::HelpWindow(), BuySellDialog::init(), BuyDialog::init(), InventoryWindow::InventoryWindow(), KillStats::KillStats(), MailEditWindow::MailEditWindow(), MailViewWindow::MailViewWindow(), MailWindow::MailWindow(), Minimap::Minimap(), NpcDialog::NpcDialog(), OutfitWindow::OutfitWindow(), SocialWindow::postInit(), WhoIsOnline::postInit(), LoginDialog::postInit(), TextSelectDialog::postInit(), SellDialog::postInit(), QuestsWindow::QuestsWindow(), EquipmentWindow::recalcSize(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), Minimap::setMap(), ShopWindow::ShopWindow(), ShortcutWindow::ShortcutWindow(), SkillDialog::SkillDialog(), StatusWindow::StatusWindow(), TextCommandEditor::TextCommandEditor(), TradeWindow::TradeWindow(), and UpdaterWindow::UpdaterWindow().

1187 {
1192 }
int width
Definition: rect.h:218
int mDefaultY
Definition: window.h:643
int x
Definition: rect.h:208
int mDefaultWidth
Definition: window.h:644
int y
Definition: rect.h:213
int height
Definition: rect.h:223
int mDefaultHeight
Definition: window.h:645
int mDefaultX
Definition: window.h:642
Rect mDimension
Definition: widget.h:1100

◆ setDefaultSize() [3/3]

void Window::setDefaultSize ( const int  defaultWidth,
const int  defaultHeight,
const ImagePosition::Type position,
const int  offsetx = 0,
const int  offsetY = 0 
)

Set the default win pos and size. (which can be different of the actual ones.) This version of setDefaultSize sets the window's position based on a relative enumerated position, rather than a coordinate position.

Definition at line 1194 of file window.cpp.

References ImagePosition::CENTER, ImagePosition::LEFT, ImagePosition::LOWER_CENTER, ImagePosition::LOWER_LEFT, ImagePosition::LOWER_RIGHT, mainGraphics, mDefaultHeight, mDefaultWidth, mDefaultX, mDefaultY, Graphics::mHeight, Graphics::mWidth, ImagePosition::RIGHT, ImagePosition::UPPER_CENTER, ImagePosition::UPPER_LEFT, ImagePosition::UPPER_RIGHT, x, and y.

1197 {
1198  int x = 0;
1199  int y = 0;
1200 
1201  if (position == ImagePosition::UPPER_LEFT)
1202  {
1203  }
1204  else if (position == ImagePosition::UPPER_CENTER)
1205  {
1206  x = (mainGraphics->mWidth - defaultWidth) / 2;
1207  }
1208  else if (position == ImagePosition::UPPER_RIGHT)
1209  {
1210  x = mainGraphics->mWidth - defaultWidth;
1211  }
1212  else if (position == ImagePosition::LEFT)
1213  {
1214  y = (mainGraphics->mHeight - defaultHeight) / 2;
1215  }
1216  else if (position == ImagePosition::CENTER)
1217  {
1218  x = (mainGraphics->mWidth - defaultWidth) / 2;
1219  y = (mainGraphics->mHeight - defaultHeight) / 2;
1220  }
1221  else if (position == ImagePosition::RIGHT)
1222  {
1223  x = mainGraphics->mWidth - defaultWidth;
1224  y = (mainGraphics->mHeight - defaultHeight) / 2;
1225  }
1226  else if (position == ImagePosition::LOWER_LEFT)
1227  {
1228  y = mainGraphics->mHeight - defaultHeight;
1229  }
1230  else if (position == ImagePosition::LOWER_CENTER)
1231  {
1232  x = (mainGraphics->mWidth - defaultWidth) / 2;
1233  y = mainGraphics->mHeight - defaultHeight;
1234  }
1235  else if (position == ImagePosition::LOWER_RIGHT)
1236  {
1237  x = mainGraphics->mWidth - defaultWidth;
1238  y = mainGraphics->mHeight - defaultHeight;
1239  }
1240 
1241  mDefaultX = x - offsetX;
1242  mDefaultY = y - offsetY;
1243  mDefaultWidth = defaultWidth;
1244  mDefaultHeight = defaultHeight;
1245 }
int mWidth
Definition: graphics.h:483
int mDefaultY
Definition: window.h:643
int mDefaultWidth
Definition: window.h:644
Graphics * mainGraphics
Definition: graphics.cpp:108
int mHeight
Definition: graphics.h:484
int mDefaultHeight
Definition: window.h:645
int mDefaultX
Definition: window.h:642

◆ setDefaultVisible()

void Window::setDefaultVisible ( const bool  save)
inline

Sets whether the window is visible by default.

Definition at line 286 of file window.h.

References mDefaultVisible, and ServerCommandType::save.

Referenced by ChatWindow::ChatWindow(), CutInWindow::CutInWindow(), Minimap::Minimap(), and ShortcutWindow::ShortcutWindow().

◆ setLocationHorisontallyRelativeTo()

void Window::setLocationHorisontallyRelativeTo ( const Widget *const  widget)

Sets the location relative to the given widget (only horisontally)

Definition at line 518 of file window.cpp.

References Widget::getAbsolutePosition(), Widget::getWidth(), Widget::mDimension, Widget::setPosition(), Rect::width, x, Rect::x, and y.

Referenced by centerHorisontally().

519 {
520  if (widget == nullptr)
521  return;
522 
523  int wx, wy;
524  int x, y;
525 
526  widget->getAbsolutePosition(wx, wy);
527  getAbsolutePosition(x, y);
528 
529  setPosition(mDimension.x + (wx + (widget->getWidth()
530  - mDimension.width) / 2 - x), 0);
531 }
int width
Definition: rect.h:218
int getWidth() const
Definition: widget.h:220
int x
Definition: rect.h:208
void setPosition(const int x, const int y)
Definition: widget.cpp:160
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:311
Rect mDimension
Definition: widget.h:1100

◆ setLocationRelativeTo() [1/2]

void Window::setLocationRelativeTo ( const Widget *const  widget)

Sets the location relative to the given widget.

Definition at line 501 of file window.cpp.

References Widget::getAbsolutePosition(), Widget::getHeight(), Widget::getWidth(), Rect::height, Widget::mDimension, Widget::setPosition(), Rect::width, x, Rect::x, y, and Rect::y.

Referenced by center(), EditServerDialog::EditServerDialog(), ItemAmountWindow::ItemAmountWindow(), TextDialog::postInit(), QuitDialog::postInit(), WhoIsOnline::postInit(), and SkillDialog::postInit().

502 {
503  if (widget == nullptr)
504  return;
505 
506  int wx, wy;
507  int x, y;
508 
509  widget->getAbsolutePosition(wx, wy);
510  getAbsolutePosition(x, y);
511 
512  setPosition(mDimension.x + (wx + (widget->getWidth()
513  - mDimension.width) / 2 - x),
514  mDimension.y + (wy + (widget->getHeight()
515  - mDimension.height) / 2 - y));
516 }
int width
Definition: rect.h:218
int getWidth() const
Definition: widget.h:220
int x
Definition: rect.h:208
int y
Definition: rect.h:213
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int height
Definition: rect.h:223
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:311
int getHeight() const
Definition: widget.h:239
Rect mDimension
Definition: widget.h:1100

◆ setLocationRelativeTo() [2/2]

void Window::setLocationRelativeTo ( const ImagePosition::Type position,
int  offsetX = 0,
int  offsetY = 0 
)

Sets the location relative to the given enumerated position.

Definition at line 533 of file window.cpp.

References ImagePosition::CENTER, Rect::height, ImagePosition::LEFT, ImagePosition::LOWER_CENTER, ImagePosition::LOWER_LEFT, ImagePosition::LOWER_RIGHT, mainGraphics, Widget::mDimension, Graphics::mHeight, Graphics::mWidth, ImagePosition::RIGHT, Widget::setPosition(), ImagePosition::UPPER_CENTER, ImagePosition::UPPER_LEFT, ImagePosition::UPPER_RIGHT, and Rect::width.

535 {
536  if (position == ImagePosition::UPPER_LEFT)
537  {
538  }
539  else if (position == ImagePosition::UPPER_CENTER)
540  {
541  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
542  }
543  else if (position == ImagePosition::UPPER_RIGHT)
544  {
545  offsetX += mainGraphics->mWidth - mDimension.width;
546  }
547  else if (position == ImagePosition::LEFT)
548  {
549  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
550  }
551  else if (position == ImagePosition::CENTER)
552  {
553  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
554  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
555  }
556  else if (position == ImagePosition::RIGHT)
557  {
558  offsetX += mainGraphics->mWidth - mDimension.width;
559  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
560  }
561  else if (position == ImagePosition::LOWER_LEFT)
562  {
563  offsetY += mainGraphics->mHeight - mDimension.height;
564  }
565  else if (position == ImagePosition::LOWER_CENTER)
566  {
567  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
568  offsetY += mainGraphics->mHeight - mDimension.height;
569  }
570  else if (position == ImagePosition::LOWER_RIGHT)
571  {
572  offsetX += mainGraphics->mWidth - mDimension.width;
573  offsetY += mainGraphics->mHeight - mDimension.height;
574  }
575 
576  setPosition(offsetX, offsetY);
577 }
int width
Definition: rect.h:218
int mWidth
Definition: graphics.h:483
Graphics * mainGraphics
Definition: graphics.cpp:108
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int height
Definition: rect.h:223
int mHeight
Definition: graphics.h:484
Rect mDimension
Definition: widget.h:1100

◆ setMaxHeight()

void Window::setMaxHeight ( const int  height)

Sets the minimum height of the window.

Definition at line 610 of file window.cpp.

References mMaxWinHeight.

Referenced by getMaxWidth(), Minimap::setMap(), and ShortcutWindow::ShortcutWindow().

611 {
612  mMaxWinHeight = height;
613 }
int mMaxWinHeight
Definition: window.h:690

◆ setMaxWidth()

void Window::setMaxWidth ( const int  width)

Sets the maximum width of the window.

Definition at line 605 of file window.cpp.

References mMaxWinWidth.

Referenced by getMinHeight(), Minimap::setMap(), and ShortcutWindow::ShortcutWindow().

606 {
607  mMaxWinWidth = width;
608 }
int mMaxWinWidth
Definition: window.h:689

◆ setMinHeight()

void Window::setMinHeight ( const int  height)

◆ setMinWidth()

void Window::setMinWidth ( const int  width)

◆ setModal()

void Window::setModal ( const Modal  modal)

Allows the windows modal status to change

Definition at line 1057 of file window.cpp.

References Cursor::CURSOR_POINTER, gui, mModal, Modal_true, Widget::releaseModalFocus(), Widget::requestModalFocus(), and Gui::setCursorType().

Referenced by getWindowName(), SkillDialog::useSkillDefault(), SkillDialog::useSkillPosition(), and SkillDialog::useSkillTarget().

1058 {
1059  if (mModal != modal)
1060  {
1061  mModal = modal;
1062  if (mModal == Modal_true)
1063  {
1064  if (gui != nullptr)
1067  }
1068  else
1069  {
1071  }
1072  }
1073 }
Gui * gui
Definition: gui.cpp:110
void requestModalFocus()
Definition: widget.cpp:379
virtual void releaseModalFocus()
Definition: widget.cpp:393
void setCursorType(const CursorT index)
Definition: gui.h:195
Modal mModal
Definition: window.h:712

◆ setMovable()

void Window::setMovable ( Move  movable)
inline

Sets the window to be moveble or not.

Parameters
movableTrue if the window should be movable, false otherwise.
See also
isMovable

Definition at line 559 of file window.h.

References mMovable.

Referenced by ConnectionDialog::ConnectionDialog().

560  { mMovable = movable; }
Move mMovable
Definition: window.h:620

◆ setPadding()

void Window::setPadding ( int  padding)
inline

Sets the padding of the window. The padding is the distance between the window border and the content.

Parameters
paddingThe padding of the window.
See also
getPadding

Definition at line 486 of file window.h.

References mPadding.

Referenced by Window().

487  { mPadding = padding; }
int mPadding
Definition: window.h:610

◆ setResizable()

void Window::setResizable ( const bool  resize)

Sets whether or not the window can be resized.

Definition at line 615 of file window.cpp.

References Image::decRef(), Image::getHeight(), Theme::getImageFromThemeXml(), Image::getWidth(), Rect::height, Widget::mDimension, mGrip, mGripPadding, mGripRect, Rect::width, Rect::x, and Rect::y.

Referenced by ChatWindow::ChatWindow(), CutInWindow::CutInWindow(), DebugWindow::DebugWindow(), DidYouKnowWindow::DidYouKnowWindow(), EditServerDialog::EditServerDialog(), EmoteWindow::EmoteWindow(), HelpWindow::HelpWindow(), BuyDialog::init(), InventoryWindow::InventoryWindow(), KillStats::KillStats(), MailEditWindow::MailEditWindow(), MailViewWindow::MailViewWindow(), MailWindow::MailWindow(), Minimap::Minimap(), NpcDialog::NpcDialog(), OutfitWindow::OutfitWindow(), SocialWindow::postInit(), WhoIsOnline::postInit(), TextSelectDialog::postInit(), SellDialog::postInit(), QuestsWindow::QuestsWindow(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), SetupWindow::SetupWindow(), ShopWindow::ShopWindow(), ShortcutWindow::ShortcutWindow(), SkillDialog::SkillDialog(), StatusWindow::StatusWindow(), TradeWindow::TradeWindow(), and UpdaterWindow::UpdaterWindow().

616 {
617  if ((mGrip != nullptr) == r)
618  return;
619 
620  if (mGrip != nullptr)
621  mGrip->decRef();
622  if (r)
623  {
624  mGrip = Theme::getImageFromThemeXml("resize.xml", "");
625  if (mGrip != nullptr)
626  {
629  - mGripPadding;
630  }
631  else
632  {
633  mGripRect.x = 0;
634  mGripRect.y = 0;
635  }
636  }
637  else
638  {
639  mGrip = nullptr;
640  }
641 }
Rect mGripRect
Definition: window.h:684
int width
Definition: rect.h:218
int mGripPadding
Definition: window.h:705
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:1129
int x
Definition: rect.h:208
int y
Definition: rect.h:213
int height
Definition: rect.h:223
int getWidth() const A_INLINE
Definition: image.h:116
Rect mDimension
Definition: widget.h:1100
void decRef()
Definition: image.cpp:521
int getHeight() const A_INLINE
Definition: image.h:122
Image * mGrip
Definition: window.h:679

◆ setSaveVisible()

void Window::setSaveVisible ( const bool  save)
inline

◆ setShowTitle()

void Window::setShowTitle ( bool  flag)
inline

Sets flag to show a title or not.

Definition at line 233 of file window.h.

References mShowTitle, setSticky(), and setStickyButton().

Referenced by ChatWindow::ChatWindow(), CutInWindow::CutInWindow(), EmoteWindow::EmoteWindow(), ShortcutWindow::ShortcutWindow(), and CutInWindow::show().

234  { mShowTitle = flag; }
bool mShowTitle
Definition: window.h:648

◆ setSticky()

void Window::setSticky ( const bool  sticky)

Sets whether the window is sticky. A sticky window will not have its visibility set to false on a general setVisible(false) call. Use this to set the default before you call loadWindowState().

Definition at line 754 of file window.cpp.

References Widget::mRedraw, and mSticky.

Referenced by CharCreateDialog::CharCreateDialog(), PopupMenu::handleLink(), loadWindowState(), Minimap::Minimap(), mousePressed(), and setShowTitle().

755 {
756  mSticky = sticky;
757  mRedraw = true;
758 }
bool mSticky
Definition: window.h:717
bool mRedraw
Definition: widget.h:1163

◆ setStickyButton()

void Window::setStickyButton ( const bool  flag)

Sets whether or not the window has a sticky button.

Definition at line 749 of file window.cpp.

References mStickyButton.

Referenced by Minimap::Minimap(), and setShowTitle().

750 {
751  mStickyButton = flag;
752 }
bool mStickyButton
Definition: window.h:716

◆ setStickyButtonLock()

void Window::setStickyButtonLock ( const bool  sticky)

◆ setTitleBarHeight()

void Window::setTitleBarHeight ( unsigned int  height)
inline

Sets the title bar height.

Parameters
heightThe title height value.
See also
getTitleBarHeight

Definition at line 505 of file window.h.

References mTitleBarHeight.

Referenced by ChatWindow::ChatWindow(), EmoteWindow::postInit(), ShortcutWindow::ShortcutWindow(), and Window().

506  { mTitleBarHeight = height; }
unsigned int mTitleBarHeight
Definition: window.h:615

◆ setTitlePadding()

void Window::setTitlePadding ( const int  p)
inlineprotected

Definition at line 591 of file window.h.

References mTitlePadding.

592  { mTitlePadding = p; }
int mTitlePadding
Definition: window.h:704

◆ setVisible() [1/2]

void Window::setVisible ( Visible  visible)
virtual

Overloads window setVisible by Guichan to allow sticky window handling.

Reimplemented in NpcDialog, BuyDialog, ChatWindow, InventoryWindow, SellDialog, ShopWindow, SetupWindow, TextSelectDialog, DidYouKnowWindow, and BuySellDialog.

Definition at line 766 of file window.cpp.

Referenced by QuestsWindow::action(), SkillDialog::action(), TradeWindow::action(), CharSelectDialog::attemptCharacterSelect(), CharCreateDialog::CharCreateDialog(), EmoteWindow::clearColor(), EmoteWindow::clearEmote(), EmoteWindow::clearFont(), EmoteWindow::clearText(), close(), TradeWindow::completeTrade(), createGuiWindows(), CutInWindow::CutInWindow(), Actions::getAmountFromEvent(), EmoteWindow::hide(), CutInWindow::hide(), SetupWindow::hideWindows(), isStickyButtonLock(), HelpWindow::loadHelp(), HelpWindow::loadHelpSimple(), loadWindowState(), MailEditWindow::MailEditWindow(), MailViewWindow::MailViewWindow(), Minimap::Minimap(), MiniStatusWindow::MiniStatusWindow(), OkDialog::OkDialog(), ServerInfoWindow::postInit(), ConnectionDialog::postInit(), ItemAmountWindow::postInit(), SocialWindow::postInit(), WorldSelectDialog::postInit(), EditDialog::postInit(), TextDialog::postInit(), EditServerDialog::postInit(), QuitDialog::postInit(), WhoIsOnline::postInit(), TextCommandEditor::postInit(), RegisterDialog::postInit(), LoginDialog::postInit(), ConfirmDialog::postInit(), ServerDialog::postInit(), UpdaterWindow::postInit(), CharSelectDialog::postInit(), EAthena::MailRecv::processMailOpen(), Ea::TradeRecv::processTradeCancel(), Ea::TradeRecv::processTradeResponseContinue(), HelpWindow::search(), QuestsWindow::selectQuest(), Minimap::setMap(), BuySellDialog::setVisible(), DidYouKnowWindow::setVisible(), TextSelectDialog::setVisible(), SetupWindow::setVisible(), ShopWindow::setVisible(), SellDialog::setVisible(), InventoryWindow::setVisible(), ChatWindow::setVisible(), BuyDialog::setVisible(), NpcDialog::setVisible(), EmoteWindow::show(), CutInWindow::show(), Actions::showHelpPage(), Actions::showHideWindow(), Minimap::toggle(), and Window().

767 {
768  setVisible(visible, false);
769 }
virtual void setVisible(Visible visible)
Definition: window.cpp:766

◆ setVisible() [2/2]

void Window::setVisible ( const Visible  visible,
const bool  forceSticky 
)

Overloads window setVisible by Guichan to allow sticky window handling, or not, if you force the sticky state.

Definition at line 771 of file window.cpp.

References Gui::createMouseEvent(), ensureOnScreen(), fromBool, gui, Rect::height, Widget::mDimension, mouseMoved(), mPlayVisibleSound, mResizeHandles, mSticky, mStickyButtonLock, Widget::mVisible, SoundManager::playGuiSound(), Widget::setVisible(), SOUND_HIDE_WINDOW, SOUND_SHOW_WINDOW, soundManager, Visible_true, Rect::width, x, and y.

772 {
773  if (visible == mVisible)
774  return;
775 
776  // Check if the window is off screen...
777  if (visible == Visible_true)
778  ensureOnScreen();
779  else
780  mResizeHandles = 0;
781 
782  if (mStickyButtonLock)
783  {
785  }
786  else
787  {
788  BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
789  visible == Visible_true, Visible));
790  }
791  if (visible == Visible_true)
792  {
793  if (mPlayVisibleSound)
795  if (gui != nullptr)
796  {
797  MouseEvent *const event = reinterpret_cast<MouseEvent*>(
798  gui->createMouseEvent(this));
799  if (event != nullptr)
800  {
801  const int x = event->getX();
802  const int y = event->getY();
803  if (x >= 0 && x <= mDimension.width
804  && y >= 0 && y <= mDimension.height)
805  {
806  mouseMoved(*event);
807  }
808  delete event;
809  }
810  }
811  }
812  else
813  {
814  if (mPlayVisibleSound)
816  }
817 }
MouseEvent * createMouseEvent(Window *const widget)
Definition: gui.cpp:974
static const std::string SOUND_HIDE_WINDOW
Definition: sound.h:35
int width
Definition: rect.h:218
Gui * gui
Definition: gui.cpp:110
const bool Visible_true
Definition: visible.h:29
void setVisible(Visible visible)
Definition: widget.cpp:224
bool mStickyButtonLock
Definition: window.h:718
SoundManager soundManager
void mouseMoved(MouseEvent &event)
Definition: window.cpp:955
Visible mVisible
Definition: widget.h:962
void ensureOnScreen()
Definition: window.cpp:1415
#define fromBool(val, name)
Definition: booldefines.h:48
int height
Definition: rect.h:223
int mResizeHandles
Definition: window.h:706
bool mSticky
Definition: window.h:717
bool mPlayVisibleSound
Definition: window.h:719
static const std::string SOUND_SHOW_WINDOW
Definition: sound.h:34
Rect mDimension
Definition: widget.h:1100
void playGuiSound(const std::string &name)

◆ setWindowContainer()

void Window::setWindowContainer ( WindowContainer *const  windowContainer)
static

Sets the window container to be used by new windows.

Definition at line 298 of file window.cpp.

References windowContainer.

Referenced by Gui::postInit(), and Gui::~Gui().

299 {
300  windowContainer = wc;
301 }

◆ setWindowName()

void Window::setWindowName ( const std::string &  name)
inline

◆ updateResizeHandler()

void Window::updateResizeHandler ( MouseEvent event)

Definition at line 918 of file window.cpp.

References BOTTOM, Cursor::CURSOR_POINTER, Cursor::CURSOR_RESIZE_ACROSS, Cursor::CURSOR_RESIZE_DOWN, Cursor::CURSOR_RESIZE_DOWN_LEFT, Cursor::CURSOR_RESIZE_DOWN_RIGHT, dragDrop, getResizeHandles(), gui, DragDrop::isEmpty(), LEFT, mResizeHandles, resizeMask, RIGHT, Gui::setCursorType(), and TOP.

Referenced by getParentWindow(), mouseEntered(), and mouseMoved().

919 {
920  if (gui == nullptr)
921  return;
922 
923 #ifndef DYECMD
924  if (!dragDrop.isEmpty())
925  return;
926 #endif // DYECMD
927 
929 
930  // Changes the custom mouse cursor based on it's current position.
931  switch (mResizeHandles & resizeMask)
932  {
933  case BOTTOM | RIGHT:
934  case TOP | LEFT:
936  break;
937  case TOP | RIGHT:
938  case BOTTOM | LEFT:
940  break;
941  case BOTTOM:
942  case TOP:
944  break;
945  case RIGHT:
946  case LEFT:
948  break;
949  default:
951  break;
952  }
953 }
Gui * gui
Definition: gui.cpp:110
DragDrop dragDrop
bool isEmpty() const
Definition: dragdrop.h:195
void setCursorType(const CursorT index)
Definition: gui.h:195
int mResizeHandles
Definition: window.h:706
int getResizeHandles(const MouseEvent &event)
Definition: window.cpp:1294
const int resizeMask
Definition: window.cpp:103

◆ widgetHidden()

void Window::widgetHidden ( const Event event)
virtual

Called whenever the widget is hidden.

Reimplemented from WidgetListener.

Reimplemented in InventoryWindow, and ShortcutWindow.

Definition at line 713 of file window.cpp.

References ImageCollection::clear(), Cursor::CURSOR_POINTER, TextChunk::deleteImage(), FocusHandler::focusNone(), gui, isBatchDrawRenders, FocusHandler::isFocused(), Widget::mFocusHandler, Widget::mRedraw, mTextChanged, mTextChunk, mVertexes, BasicContainer::mWidgets, openGLMode, and Gui::setCursorType().

Referenced by ShortcutWindow::widgetHidden(), and InventoryWindow::widgetHidden().

714 {
716  mVertexes->clear();
717 
719 
720  mTextChanged = true;
721  mRedraw = true;
722 
723  if (gui != nullptr)
725 
726  if (mFocusHandler == nullptr)
727  return;
728 
729  for (WidgetListConstIterator it = mWidgets.begin();
730  it != mWidgets.end(); ++ it)
731  {
732  if (mFocusHandler->isFocused(*it))
734  }
735 }
TextChunk mTextChunk
Definition: window.h:685
Gui * gui
Definition: gui.cpp:110
WidgetList::const_iterator WidgetListConstIterator
bool mTextChanged
Definition: window.h:721
bool isFocused(const Widget *const widget) const
ImageCollection * mVertexes
Definition: window.h:702
RenderType openGLMode
FocusHandler * mFocusHandler
Definition: widget.h:1115
void setCursorType(const CursorT index)
Definition: gui.h:195
bool mRedraw
Definition: widget.h:1163
WidgetList mWidgets
void deleteImage()
Definition: textchunk.cpp:192
#define isBatchDrawRenders(val)
Definition: renderers.h:30

◆ widgetMoved()

void Window::widgetMoved ( const Event event)
virtual

Invoked when a widget is moved.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Reimplemented in EmoteWindow, and ShortcutWindow.

Definition at line 708 of file window.cpp.

References Widget::mRedraw.

Referenced by ShortcutWindow::widgetMoved(), and EmoteWindow::widgetMoved().

709 {
710  mRedraw = true;
711 }
bool mRedraw
Definition: widget.h:1163

◆ widgetResized()

void Window::widgetResized ( const Event event)
virtual

Called whenever the widget changes size.

Reimplemented from WidgetListener.

Reimplemented in ChatWindow, InventoryWindow, SkillDialog, SocialWindow, CharSelectDialog, WhoIsOnline, SetupWindow, EmoteWindow, and DebugWindow.

Definition at line 643 of file window.cpp.

References buttonWidth, getChildrenArea(), Skin::getCloseImage(), Image::getHeight(), Skin::getStickyImage(), Image::getWidth(), Rect::height, mClosePadding, mCloseRect, mCloseWindowButton, Widget::mDimension, mGrip, mGripPadding, mGripRect, mLayout, Widget::mRedraw, mSkin, mSticky, mStickyButton, mStickyPadding, mStickyRect, mStickySpacing, Layout::reflow(), Rect::width, x, Rect::x, and Rect::y.

Referenced by ShortcutWindow::addButton(), adjustSizeToScreen(), HelpWindow::HelpWindow(), DidYouKnowWindow::postInit(), ServerInfoWindow::ServerInfoWindow(), DebugWindow::widgetResized(), EmoteWindow::widgetResized(), SetupWindow::widgetResized(), WhoIsOnline::widgetResized(), CharSelectDialog::widgetResized(), SocialWindow::widgetResized(), SkillDialog::widgetResized(), InventoryWindow::widgetResized(), and ChatWindow::widgetResized().

644 {
645  if (mGrip != nullptr)
646  {
649  }
650 
651  if (mLayout != nullptr)
652  {
653  const Rect area = getChildrenArea();
654  int w = area.width;
655  int h = area.height;
656  mLayout->reflow(w, h);
657  }
658  if (mSkin != nullptr)
659  {
660  const bool showClose = mCloseWindowButton
661  && (mSkin->getCloseImage(false) != nullptr);
662  if (showClose)
663  {
664  const Image *const button = mSkin->getCloseImage(false);
665  if (button != nullptr)
666  {
667  const int buttonWidth = button->getWidth();
668  mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
671  mCloseRect.height = button->getHeight();
672  }
673  }
674  if (mStickyButton)
675  {
676  const Image *const button = mSkin->getStickyImage(mSticky);
677  if (button != nullptr)
678  {
679  const int buttonWidth = button->getWidth();
680  int x = mDimension.width - buttonWidth
682 
683  if (showClose)
684  x -= mSkin->getCloseImage(false)->getWidth();
685 
686  mStickyRect.x = x;
689  mStickyRect.height = button->getHeight();
690  }
691  }
692  }
693  else
694  {
695  mCloseRect.x = 0;
696  mCloseRect.y = 0;
697  mCloseRect.width = 0;
698  mCloseRect.height = 0;
699  mStickyRect.x = 0;
700  mStickyRect.y = 0;
701  mStickyRect.width = 0;
702  mStickyRect.height = 0;
703  }
704 
705  mRedraw = true;
706 }
static const int buttonWidth
Definition: sliderlist.cpp:34
Rect mGripRect
Definition: window.h:684
int width
Definition: rect.h:218
Skin * mSkin
Definition: window.h:641
int mGripPadding
Definition: window.h:705
Rect getChildrenArea()
Definition: window.cpp:1461
Definition: rect.h:72
void reflow(int &nW, int &nH)
Definition: layout.cpp:35
int mStickySpacing
Definition: window.h:709
Rect mCloseRect
Definition: window.h:682
bool mStickyButton
Definition: window.h:716
int x
Definition: rect.h:208
int y
Definition: rect.h:213
int mStickyPadding
Definition: window.h:710
const Image * getStickyImage(const bool state) const
Definition: skin.h:80
int mClosePadding
Definition: window.h:708
int height
Definition: rect.h:223
bool mCloseWindowButton
Definition: window.h:713
bool mSticky
Definition: window.h:717
Rect mStickyRect
Definition: window.h:683
const Image * getCloseImage(const bool state) const
Definition: skin.h:73
bool mRedraw
Definition: widget.h:1163
Definition: image.h:61
Layout * mLayout
Definition: window.h:681
int getWidth() const A_INLINE
Definition: image.h:116
Rect mDimension
Definition: widget.h:1100
int getHeight() const A_INLINE
Definition: image.h:122
Image * mGrip
Definition: window.h:679

◆ willSaveVisible()

bool Window::willSaveVisible ( ) const
inline

Returns whether the window will save it's visibility.

Definition at line 292 of file window.h.

References mSaveVisible.

293  { return mSaveVisible; }
bool mSaveVisible
Definition: window.h:715

Field Documentation

◆ mAlignment

Graphics::Alignment Window::mAlignment
protected

Holds the alignment of the caption.

Definition at line 605 of file window.h.

Referenced by getAlignment(), and setAlignment().

◆ mAllowClose

bool Window::mAllowClose
private

Definition at line 722 of file window.h.

Referenced by getAlowClose(), setAllowClose(), and setCloseButton().

◆ mCaption

std::string Window::mCaption
protected

Holds the caption of the window.

Definition at line 600 of file window.h.

Referenced by draw(), getCaption(), Minimap::mouseMoved(), safeDraw(), and setCaption().

◆ mCaptionAlign

Graphics::Alignment Window::mCaptionAlign
private

Definition at line 703 of file window.h.

Referenced by draw(), safeDraw(), and Window().

◆ mCaptionFont

Font* Window::mCaptionFont
private

Definition at line 711 of file window.h.

Referenced by draw(), safeDraw(), setCaptionFont(), and Window().

◆ mCaptionOffsetX

int Window::mCaptionOffsetX
protected

Definition at line 646 of file window.h.

Referenced by draw(), ConfirmDialog::postInit(), safeDraw(), and Window().

◆ mCaptionOffsetY

int Window::mCaptionOffsetY
protected

Definition at line 647 of file window.h.

Referenced by draw(), safeDraw(), and Window().

◆ mClosePadding

int Window::mClosePadding
private

Definition at line 708 of file window.h.

Referenced by widgetResized(), and Window().

◆ mCloseRect

Rect Window::mCloseRect
private

Close button rectangle

Definition at line 682 of file window.h.

Referenced by draw(), getResizeHandles(), mousePressed(), safeDraw(), and widgetResized().

◆ mCloseWindowButton

bool Window::mCloseWindowButton
private

Window has a close button

Definition at line 713 of file window.h.

Referenced by draw(), getAlowClose(), getCloseButton(), mousePressed(), safeDraw(), setCloseButton(), and widgetResized().

◆ mDefaultHeight

int Window::mDefaultHeight
protected

Default window height

Definition at line 645 of file window.h.

Referenced by loadWindowState(), resetToDefaultSize(), and setDefaultSize().

◆ mDefaultVisible

bool Window::mDefaultVisible
private

Window's default visibility

Definition at line 714 of file window.h.

Referenced by isDefaultVisible(), loadWindowState(), and setDefaultVisible().

◆ mDefaultWidth

int Window::mDefaultWidth
protected

Default window width

Definition at line 644 of file window.h.

Referenced by EditDialog::EditDialog(), loadWindowState(), EditDialog::postInit(), resetToDefaultSize(), and setDefaultSize().

◆ mDefaultX

int Window::mDefaultX
protected

Default window X position

Definition at line 642 of file window.h.

Referenced by loadWindowState(), resetToDefaultSize(), and setDefaultSize().

◆ mDefaultY

int Window::mDefaultY
protected

Default window Y position

Definition at line 643 of file window.h.

Referenced by loadWindowState(), resetToDefaultSize(), and setDefaultSize().

◆ mDragOffsetX

int Window::mDragOffsetX
protected

Holds a drag offset as an x coordinate where the drag of the window started if the window is being dragged. It's used to move the window correctly when dragged.

Definition at line 627 of file window.h.

Referenced by getResizeHandles(), ShortcutWindow::mouseDragged(), ChatWindow::mouseDragged(), mouseDragged(), ShortcutWindow::mousePressed(), ChatWindow::mousePressed(), mousePressed(), and ShortcutWindow::ShortcutWindow().

◆ mDragOffsetY

int Window::mDragOffsetY
protected

Holds a drag offset as an y coordinate where the drag of the window started if the window is being dragged. It's used to move the window correctly when dragged.

Definition at line 634 of file window.h.

Referenced by getResizeHandles(), ShortcutWindow::mouseDragged(), ChatWindow::mouseDragged(), mouseDragged(), ShortcutWindow::mousePressed(), ChatWindow::mousePressed(), mousePressed(), and ShortcutWindow::ShortcutWindow().

◆ mGrip

Image* Window::mGrip
private

◆ mGripPadding

int Window::mGripPadding
private

Definition at line 705 of file window.h.

Referenced by setResizable(), widgetResized(), and Window().

◆ mGripRect

Rect Window::mGripRect
private

Resize grip rectangle

Definition at line 684 of file window.h.

Referenced by draw(), getResizeHandles(), isResizeAllowed(), safeDraw(), setResizable(), and widgetResized().

◆ mInit

bool Window::mInit
private

Definition at line 720 of file window.h.

Referenced by postInit(), and ~Window().

◆ mLastRedraw

bool Window::mLastRedraw
protected

Definition at line 649 of file window.h.

Referenced by EquipmentWindow::draw(), and draw().

◆ mLayout

Layout* Window::mLayout
private

Layout handler

Definition at line 681 of file window.h.

Referenced by clearLayout(), getLayout(), redraw(), reflowLayout(), widgetResized(), and ~Window().

◆ mMaxWinHeight

int Window::mMaxWinHeight
private

Maximum window height

Definition at line 690 of file window.h.

Referenced by getMaxHeight(), mouseDragged(), setContentSize(), setDefaultSize(), and setMaxHeight().

◆ mMaxWinWidth

int Window::mMaxWinWidth
private

Maximum window width

Definition at line 689 of file window.h.

Referenced by getMaxWidth(), mouseDragged(), setContentSize(), setDefaultSize(), and setMaxWidth().

◆ mMinWinHeight

int Window::mMinWinHeight
private

Minimum window height

Definition at line 688 of file window.h.

Referenced by getMinHeight(), mouseDragged(), setContentSize(), setDefaultSize(), and setMinHeight().

◆ mMinWinWidth

int Window::mMinWinWidth
private

Minimum window width

Definition at line 687 of file window.h.

Referenced by getMinWidth(), mouseDragged(), setContentSize(), setDefaultSize(), and setMinWidth().

◆ mModal

Modal Window::mModal
private

Window is modal

Definition at line 712 of file window.h.

Referenced by setModal(), and Window().

◆ mMovable

Move Window::mMovable
protected

True if the window is movable, false otherwise.

Definition at line 620 of file window.h.

Referenced by isMovable(), and setMovable().

◆ mMoved

bool Window::mMoved
protected

◆ mOldResizeHandles

int Window::mOldResizeHandles
private

Definition at line 707 of file window.h.

Referenced by draw().

◆ mouseResize

int Window::mouseResize = 0
staticprivate

Active resize handles

Definition at line 692 of file window.h.

Referenced by mouseDragged(), mouseExited(), mousePressed(), and mouseReleased().

◆ mPadding

int Window::mPadding
protected

◆ mParentWindow

Window* Window::mParentWindow
private

The parent window

Definition at line 680 of file window.h.

Referenced by getParentWindow().

◆ mPlayVisibleSound

bool Window::mPlayVisibleSound
private

Definition at line 719 of file window.h.

Referenced by enableVisibleSound(), and setVisible().

◆ mResizeHandles

int Window::mResizeHandles
private

Definition at line 706 of file window.h.

Referenced by draw(), safeDraw(), setVisible(), and updateResizeHandler().

◆ mSaveVisible

bool Window::mSaveVisible
private

Window will save visibility

Definition at line 715 of file window.h.

Referenced by loadWindowState(), saveWindowState(), setSaveVisible(), and willSaveVisible().

◆ mShowTitle

bool Window::mShowTitle
protected

Window has a title bar

Definition at line 648 of file window.h.

Referenced by draw(), safeDraw(), setShowTitle(), and Window().

◆ mSkin

Skin* Window::mSkin
protected

Skin in use by this window

Definition at line 641 of file window.h.

Referenced by draw(), getOption(), getOptionBool(), mousePressed(), safeDraw(), setMinHeight(), setMinWidth(), widgetResized(), Window(), and ~Window().

◆ mSticky

bool Window::mSticky
private

Window resists hiding

Definition at line 717 of file window.h.

Referenced by canMove(), draw(), getResizeHandles(), isSticky(), safeDraw(), setSticky(), setVisible(), and widgetResized().

◆ mStickyButton

bool Window::mStickyButton
private

◆ mStickyButtonLock

bool Window::mStickyButtonLock
private

Window locked if sticky enabled

Definition at line 718 of file window.h.

Referenced by canMove(), getResizeHandles(), isStickyButtonLock(), setStickyButtonLock(), and setVisible().

◆ mStickyPadding

int Window::mStickyPadding
private

Definition at line 710 of file window.h.

Referenced by widgetResized(), and Window().

◆ mStickyRect

Rect Window::mStickyRect
private

Sticky button rectangle

Definition at line 683 of file window.h.

Referenced by draw(), mousePressed(), safeDraw(), and widgetResized().

◆ mStickySpacing

int Window::mStickySpacing
private

Definition at line 709 of file window.h.

Referenced by widgetResized(), and Window().

◆ mTextChanged

bool Window::mTextChanged
private

Definition at line 721 of file window.h.

Referenced by draw(), safeDraw(), setCaption(), and widgetHidden().

◆ mTextChunk

TextChunk Window::mTextChunk
private

Definition at line 685 of file window.h.

Referenced by draw(), safeDraw(), and widgetHidden().

◆ mTitleBarHeight

unsigned int Window::mTitleBarHeight
protected

◆ mTitlePadding

int Window::mTitlePadding
private

Definition at line 704 of file window.h.

Referenced by getTitlePadding(), setTitlePadding(), and Window().

◆ mVertexes

ImageCollection* Window::mVertexes
private

Definition at line 702 of file window.h.

Referenced by draw(), widgetHidden(), and ~Window().

◆ mWindowName

std::string Window::mWindowName
private

Name of the window

Definition at line 686 of file window.h.

Referenced by getWindowName(), loadWindowState(), postInit(), saveWindowState(), setWindowName(), and ~Window().

◆ resizeBorderWidth

const unsigned Window::resizeBorderWidth = 10
staticprivate

The width of the resize border. Is independent of the actual window border width, and determines mostly the size of the corner area where two borders are moved at the same time.

Definition at line 701 of file window.h.

Referenced by getResizeHandles().

◆ windowInstances

int Window::windowInstances = 0
staticprivate

Number of Window instances

Definition at line 693 of file window.h.

Referenced by Window(), and ~Window().


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