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 ClanWindow ConfirmDialog ConnectionDialog CutInWindow DebugWindow DidYouKnowWindow EditDialog EditServerDialog EmoteWindow EquipmentWindow HelpWindow InventoryWindow ItemAmountWindow KillStats LoginDialog MailEditWindow MailViewWindow MailWindow Minimap MiniStatusWindow NpcDialog OkDialog OutfitWindow PincodeDialog 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, const Modal modal, Window *const parent, std::string skin)
 
 ~Window ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX, int offsetY)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetResized (const Event &event)
 
void 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, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget *> &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 

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) const
 
bool getOptionBool (const std::string &name, const bool def) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 

Protected Attributes

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 659 of file window.h.

660  {
661  TOP = 0x01,
662  RIGHT = 0x02,
663  BOTTOM = 0x04,
664  LEFT = 0x08,
665  CLOSE = 0x10
666  };

Constructor & Destructor Documentation

◆ Window()

Window::Window ( const std::string &  caption,
const Modal  modal,
Window *const  parent,
std::string  skin 
)

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(), Theme::getThemePath(), 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, reportAlways, 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  {
181  reportAlways("Default skin was used for window: %s",
182  caption.c_str());
183  skin = "window.xml";
184  }
185 
186  int childPalette = 1;
187  // Loads the skin
188  if (theme != nullptr)
189  {
190  mSkin = theme->load(skin,
191  "window.xml",
192  true,
194  if (mSkin != nullptr)
195  {
197  if (getOptionBool("titlebarBold", false))
200  mGripPadding = getOption("resizePadding", 0);
201  mCaptionOffsetX = getOption("captionoffsetx", 0);
202  if (mCaptionOffsetX == 0)
203  mCaptionOffsetX = 7;
204  mCaptionOffsetY = getOption("captionoffsety", 0);
205  if (mCaptionOffsetY == 0)
206  mCaptionOffsetY = 5;
207  mCaptionAlign = static_cast<Graphics::Alignment>(
208  getOption("captionalign", 0));
211  {
213  }
215  getOption("titlebarHeight", 0)));
216  if (mTitleBarHeight == 0U)
218 
219  mTitleBarHeight += getOption("titlebarHeightRelative", 0);
220  setPalette(getOption("palette", 0));
221  childPalette = getOption("childPalette", 0);
222  mShowTitle = getOptionBool("showTitle", true);
223  mClosePadding = getOption("closePadding", 0);
224  mStickySpacing = getOption("stickySpacing", 0);
225  mStickyPadding = getOption("stickyPadding", 0);
226  }
227  }
228 
229  // Add this window to the window container
230  if (windowContainer != nullptr)
231  windowContainer->add(this);
232 
233  if (mModal == Modal_true)
234  {
237  }
238 
239  // Windows are invisible by default
240  setVisible(Visible_false, false);
241 
242  addWidgetListener(this);
245  setPalette(childPalette);
246 }
bool mShowTitle
Definition: window.h:655
#define CAST_U32
Definition: cast.h:30
Font * getFont() const
Definition: widget.cpp:330
Rect mGripRect
Definition: window.h:691
std::string mWindowName
Definition: window.h:693
Font * mCaptionFont
Definition: window.h:718
Skin * mSkin
Definition: window.h:648
Font * boldFont
Definition: gui.cpp:111
TextChunk mTextChunk
Definition: window.h:692
int mGripPadding
Definition: window.h:712
int mDragOffsetY
Definition: window.h:641
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1465
int mPadding
Definition: window.h:617
Gui * gui
Definition: gui.cpp:110
void requestModalFocus()
Definition: widget.cpp:379
WindowContainer * windowContainer
int mOldResizeHandles
Definition: window.h:714
bool mTextChanged
Definition: window.h:728
bool mStickyButtonLock
Definition: window.h:725
int mCaptionOffsetY
Definition: window.h:654
int mWidth
Definition: graphics.h:483
int mStickySpacing
Definition: window.h:716
static std::string getThemePath()
Definition: theme.h:66
bool mDefaultVisible
Definition: window.h:721
int getOption(const std::string &name, const int def) const
Definition: window.cpp:1453
ImageCollection * mVertexes
Definition: window.h:709
Rect mCloseRect
Definition: window.h:689
bool mStickyButton
Definition: window.h:723
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
bool mMoved
Definition: window.h:646
Color mForegroundColor
Definition: widget.h:1085
int mCaptionOffsetX
Definition: window.h:653
int mDragOffsetX
Definition: window.h:634
int mMaxWinWidth
Definition: window.h:696
Logger * logger
Definition: logger.cpp:88
int mDefaultY
Definition: window.h:650
bool mAllowClose
Definition: window.h:729
int getPadding() const
Definition: skin.h:99
int mTitlePadding
Definition: window.h:711
const bool Visible_false
Definition: visible.h:29
Widget * mWindow
Definition: widget2.h:111
int mDefaultWidth
Definition: window.h:651
bool mLastRedraw
Definition: window.h:656
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:167
virtual void add(Widget *const widget)
int mStickyPadding
Definition: window.h:717
bool mInit
Definition: window.h:727
Graphics::Alignment mCaptionAlign
Definition: window.h:710
Graphics * mainGraphics
Definition: graphics.cpp:108
int getTitlePadding() const
Definition: skin.h:102
int mClosePadding
Definition: window.h:715
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
bool mCloseWindowButton
Definition: window.h:720
int mHeight
Definition: graphics.h:484
void setCursorType(const CursorT index)
Definition: gui.h:195
int mResizeHandles
Definition: window.h:713
bool mSticky
Definition: window.h:724
const bool Move_true
Definition: move.h:29
static int windowInstances
Definition: window.h:700
Rect mStickyRect
Definition: window.h:690
Modal mModal
Definition: window.h:719
bool mPlayVisibleSound
Definition: window.h:726
std::string mCaption
Definition: window.h:607
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
bool mSaveVisible
Definition: window.h:722
Theme * theme
Definition: theme.cpp:61
virtual void setVisible(Visible visible)
Definition: window.cpp:777
Color mForegroundColor2
Definition: widget2.h:112
Move mMovable
Definition: window.h:627
int mDefaultHeight
Definition: window.h:652
BasicContainer2(const Widget2 *const widget)
int mDefaultX
Definition: window.h:649
Layout * mLayout
Definition: window.h:688
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:44
void setPadding(int padding)
Definition: window.h:493
void log(const char *const log_text,...)
Definition: logger.cpp:264
void setTitleBarHeight(unsigned int height)
Definition: window.h:512
int getHeight() const
Definition: font.cpp:361
Window * mParentWindow
Definition: window.h:687
unsigned int mTitleBarHeight
Definition: window.h:622
#define reportAlways(...)
Definition: checkutils.h:252
int mMinWinWidth
Definition: window.h:694
Graphics::Alignment mAlignment
Definition: window.h:612
int mMaxWinHeight
Definition: window.h:697
int mMinWinHeight
Definition: window.h:695
void setPalette(int palette)
Definition: widget2.h:68
Image * mGrip
Definition: window.h:686

◆ ~Window()

Window::~Window ( )

Destructor. Deletes all the added widgets.

Definition at line 259 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().

260 {
261  logger->log("Window::~Window(\"%s\")", getCaption().c_str());
262 
263  if (gui != nullptr)
264  gui->removeDragged(this);
265 
266 #ifndef DYECMD
267  if (setupWindow != nullptr)
269 #endif // DYECMD
270 
271  client->windowRemoved(this);
272 
273  saveWindowState();
274 
275  delete2(mLayout);
276 
277  while (!mWidgets.empty())
278  delete mWidgets.front();
279 
280  mWidgets.clear();
281 
282  removeWidgetListener(this);
284 
285  windowInstances--;
286 
287  if (mSkin != nullptr)
288  {
289  if (theme != nullptr)
290  theme->unload(mSkin);
291  mSkin = nullptr;
292  }
293  if (mGrip != nullptr)
294  {
295  mGrip->decRef();
296  mGrip = nullptr;
297  }
298  if (!mInit)
299  {
300  reportAlways("error: Window created without calling postInit(): %s",
301  mWindowName.c_str());
302  }
303 }
std::string mWindowName
Definition: window.h:693
Skin * mSkin
Definition: window.h:648
void unload(Skin *const skin)
Definition: theme.cpp:249
Gui * gui
Definition: gui.cpp:110
ImageCollection * mVertexes
Definition: window.h:709
Client * client
Definition: client.cpp:117
#define delete2(var)
Definition: delete2.h:24
Logger * logger
Definition: logger.cpp:88
bool mInit
Definition: window.h:727
static int windowInstances
Definition: window.h:700
Theme * theme
Definition: theme.cpp:61
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1161
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306
void windowRemoved(const Window *const window)
Definition: client.cpp:802
Layout * mLayout
Definition: window.h:688
WidgetList mWidgets
void unregisterWindowForReset(const Window *const window)
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
void log(const char *const log_text,...)
Definition: logger.cpp:264
void saveWindowState()
Definition: window.cpp:1148
const std::string & getCaption() const
Definition: window.h:539
#define reportAlways(...)
Definition: checkutils.h:252
void decRef()
Definition: image.cpp:522
Image * mGrip
Definition: window.h:686

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

1267 {
1268  // If window was aligned to the right or bottom, keep it there
1269  const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
1270  const int bottomMargin = oldScreenHeight
1271  - (mDimension.y + mDimension.height);
1272  if (mDimension.x > 0 && mDimension.x > rightMargin)
1273  mDimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
1274  if (mDimension.y > 0 && mDimension.y > bottomMargin)
1275  {
1277  - bottomMargin - mDimension.height;
1278  }
1279 
1280  ensureOnScreen();
1282 }
int width
Definition: rect.h:218
void adjustSizeToScreen()
Definition: window.cpp:1284
int mWidth
Definition: graphics.h:483
void ensureOnScreen()
Definition: window.cpp:1426
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 1284 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().

1285 {
1286  if (mGrip == nullptr)
1287  return;
1288 
1289  const int screenWidth = mainGraphics->mWidth;
1290  const int screenHeight = mainGraphics->mHeight;
1291  const int oldWidth = mDimension.width;
1292  const int oldHeight = mDimension.height;
1293  if (oldWidth + mDimension.x > screenWidth)
1294  mDimension.x = 0;
1295  if (oldHeight + mDimension.y > screenHeight)
1296  mDimension.x = 0;
1297  if (mDimension.width > screenWidth)
1298  mDimension.width = screenWidth;
1299  if (mDimension.height > screenHeight)
1300  mDimension.height = screenHeight;
1301  if (oldWidth != mDimension.width || oldHeight != mDimension.height)
1302  widgetResized(Event(this));
1303 }
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:654
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:686

◆ canMove()

bool Window::canMove ( ) const
protected

Definition at line 976 of file window.cpp.

References mSticky, and mStickyButtonLock.

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

977 {
978  return !mStickyButtonLock || !mSticky;
979 }
bool mStickyButtonLock
Definition: window.h:725
bool mSticky
Definition: window.h:724

◆ center()

void Window::center ( )

◆ centerHorisontally()

void Window::centerHorisontally ( )

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

Definition at line 1421 of file window.cpp.

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

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

1422 {
1424 }
void setLocationHorisontallyRelativeTo(const Widget *const widget)
Definition: window.cpp:527
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 1371 of file window.cpp.

References BasicContainer::clear(), and mLayout.

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

1372 {
1373  clear();
1374 
1375  // Recreate layout instance when one is present
1376  if (mLayout != nullptr)
1377  {
1378  delete mLayout;
1379  mLayout = new Layout;
1380  }
1381 }
virtual void clear()
Layout * mLayout
Definition: window.h:688
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 310 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().

311 {
312  if (mSkin == nullptr)
313  return;
314 
315  BLOCK_START("Window::draw")
316  bool update = false;
317 
319  {
320  mRedraw = true;
321  mOldResizeHandles = mResizeHandles;
322  }
323  if (mRedraw)
324  {
325  mLastRedraw = true;
326  mRedraw = false;
327  update = true;
328  mVertexes->clear();
329  graphics->calcWindow(mVertexes,
330  0, 0,
333  mSkin->getBorder());
334 
335  // Draw Close Button
336  if (mCloseWindowButton)
337  {
338  const Image *const button = mSkin->getCloseImage(
339  mResizeHandles == CLOSE);
340  if (button != nullptr)
341  {
342  graphics->calcTileCollection(mVertexes,
343  button,
344  mCloseRect.x,
345  mCloseRect.y);
346  }
347  }
348  // Draw Sticky Button
349  if (mStickyButton)
350  {
351  const Image *const button = mSkin->getStickyImage(mSticky);
352  if (button != nullptr)
353  {
354  graphics->calcTileCollection(mVertexes,
355  button,
356  mStickyRect.x,
357  mStickyRect.y);
358  }
359  }
360 
361  if (mGrip != nullptr)
362  {
363  graphics->calcTileCollection(mVertexes,
364  mGrip,
365  mGripRect.x,
366  mGripRect.y);
367  }
368  graphics->finalize(mVertexes);
369  }
370  else
371  {
372  mLastRedraw = false;
373  }
374  graphics->drawTileCollection(mVertexes);
375 
376  // Draw title
377  if (mShowTitle)
378  {
379  int x;
380  switch (mCaptionAlign)
381  {
382  case Graphics::LEFT:
383  default:
384  x = mCaptionOffsetX;
385  break;
386  case Graphics::CENTER:
388  break;
389  case Graphics::RIGHT:
391  break;
392  }
393  if (mTextChanged)
394  {
401  mTextChanged = false;
402  }
403 
404  const Image *const image = mTextChunk.img;
405  if (image != nullptr)
406  graphics->drawImage(image, x, mCaptionOffsetY);
407  }
408 
409  if (update)
410  {
411  graphics->setRedraw(update);
412  drawChildren(graphics);
413  graphics->setRedraw(false);
414  }
415  else
416  {
417  drawChildren(graphics);
418  }
419  BLOCK_END("Window::draw")
420 }
bool mShowTitle
Definition: window.h:655
Rect mGripRect
Definition: window.h:691
int width
Definition: rect.h:218
std::string text
Definition: textchunk.h:64
Font * mCaptionFont
Definition: window.h:718
Skin * mSkin
Definition: window.h:648
TextChunk mTextChunk
Definition: window.h:692
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
int mOldResizeHandles
Definition: window.h:714
bool mTextChanged
Definition: window.h:728
int mCaptionOffsetY
Definition: window.h:654
#define BLOCK_START(name)
Definition: perfomance.h:78
ImageCollection * mVertexes
Definition: window.h:709
if(!vert) return
Rect mCloseRect
Definition: window.h:689
bool mStickyButton
Definition: window.h:723
#define BLOCK_END(name)
Definition: perfomance.h:79
Color mForegroundColor
Definition: widget.h:1085
int mCaptionOffsetX
Definition: window.h:653
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:656
int y
Definition: rect.h:213
Graphics::Alignment mCaptionAlign
Definition: window.h:710
const Image * getStickyImage(const bool state) const
Definition: skin.h:80
int height
Definition: rect.h:223
bool mCloseWindowButton
Definition: window.h:720
int mResizeHandles
Definition: window.h:713
bool mSticky
Definition: window.h:724
Rect mStickyRect
Definition: window.h:690
std::string mCaption
Definition: window.h:607
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:429
Image * mGrip
Definition: window.h:686

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

1427 {
1428  // Skip when a window hasn't got any size initialized yet
1429  if (mDimension.width == 0 && mDimension.height == 0)
1430  return;
1431 
1432  // Check the left and bottom screen boundaries
1437 
1438  // But never allow the windows to disappear in to the right and top
1439  if (mDimension.x < 0)
1440  mDimension.x = 0;
1441  if (mDimension.y < 0)
1442  mDimension.y = 0;
1443 }
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 557 of file window.h.

References mAlignment.

558  { return mAlignment; }
Graphics::Alignment mAlignment
Definition: window.h:612

◆ getAlowClose()

bool Window::getAlowClose ( ) const
inline

Definition at line 191 of file window.h.

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

Referenced by PopupMenu::addWindowMenu().

192  { return mCloseWindowButton || mAllowClose; }
bool mAllowClose
Definition: window.h:729
bool mCloseWindowButton
Definition: window.h:720

◆ 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 539 of file window.h.

References mCaption.

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

540  { return mCaption; }
std::string mCaption
Definition: window.h:607

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

1473 {
1474  return Rect(mPadding,
1476  mDimension.width - mPadding * 2,
1478 }
int width
Definition: rect.h:218
int mPadding
Definition: window.h:617
Definition: rect.h:72
int height
Definition: rect.h:223
Rect mDimension
Definition: widget.h:1100
unsigned int mTitleBarHeight
Definition: window.h:622

◆ getCloseButton()

bool Window::getCloseButton ( ) const
inline

Definition at line 185 of file window.h.

References mCloseWindowButton.

186  { return mCloseWindowButton; }
bool mCloseWindowButton
Definition: window.h:720

◆ getLayout()

Layout & Window::getLayout ( )

◆ getMaxHeight()

int Window::getMaxHeight ( ) const
inline

Definition at line 228 of file window.h.

References mMaxWinHeight.

Referenced by loadWindowState(), and saveWindowState().

229  { return mMaxWinHeight; }
int mMaxWinHeight
Definition: window.h:697

◆ getMaxWidth()

int Window::getMaxWidth ( ) const
inline

Definition at line 220 of file window.h.

References mMaxWinWidth, and setMaxHeight().

Referenced by loadWindowState(), and saveWindowState().

221  { return mMaxWinWidth; }
int mMaxWinWidth
Definition: window.h:696

◆ getMinHeight()

int Window::getMinHeight ( ) const
inline

Definition at line 212 of file window.h.

References mMinWinHeight, and setMaxWidth().

Referenced by loadWindowState(), and saveWindowState().

213  { return mMinWinHeight; }
int mMinWinHeight
Definition: window.h:695

◆ getMinWidth()

int Window::getMinWidth ( ) const
inline

Definition at line 204 of file window.h.

References mMinWinWidth, and setMinHeight().

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

205  { return mMinWinWidth; }
int mMinWinWidth
Definition: window.h:694

◆ getOption()

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

Definition at line 1453 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().

1454 {
1455  if (mSkin != nullptr)
1456  {
1457  const int val = mSkin->getOption(name);
1458  if (val != 0)
1459  return val;
1460  return def;
1461  }
1462  return def;
1463 }
Skin * mSkin
Definition: window.h:648
int getOption(const std::string &name) const
Definition: skin.h:105

◆ getOptionBool()

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

Definition at line 1465 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().

1466 {
1467  if (mSkin != nullptr)
1468  return mSkin->getOption(name, static_cast<int>(def)) != 0;
1469  return def;
1470 }
Skin * mSkin
Definition: window.h:648
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 503 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().

504  { return mPadding; }
int mPadding
Definition: window.h:617

◆ getParentWindow()

Window* Window::getParentWindow ( ) const
inline

Returns the parent window.

Returns
The parent window or NULL if there is none.

Definition at line 309 of file window.h.

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

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

310  { return mParentWindow; }
Window * mParentWindow
Definition: window.h:687

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

1306 {
1307  if (event.getX() < 0 || event.getY() < 0)
1308  return 0;
1309 
1310  int resizeHandles = 0;
1311  const unsigned y = event.getY();
1312  const unsigned x = event.getX();
1313  if (mCloseRect.isPointInRect(x, y))
1314  return CLOSE;
1315 
1316  if (!mStickyButtonLock || !mSticky)
1317  {
1318  if ((mGrip != nullptr) &&
1319  (y > mTitleBarHeight ||
1320  (CAST_S32(y) < mPadding &&
1322  {
1323  if (!getWindowArea().isPointInRect(x, y)
1324  && event.getSource() == this)
1325  {
1326  resizeHandles |= (x > mDimension.width - resizeBorderWidth)
1327  ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
1328  resizeHandles |= (y > mDimension.height - resizeBorderWidth)
1329  ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
1330  }
1331  if (x >= CAST_U32(mGripRect.x)
1332  && y >= CAST_U32(mGripRect.y))
1333  {
1334  mDragOffsetX = x;
1335  mDragOffsetY = y;
1336  resizeHandles |= BOTTOM | RIGHT;
1337  }
1338  }
1339  }
1340 
1341  return resizeHandles;
1342 }
#define CAST_U32
Definition: cast.h:30
Rect mGripRect
Definition: window.h:691
int width
Definition: rect.h:218
int mDragOffsetY
Definition: window.h:641
int mPadding
Definition: window.h:617
bool mStickyButtonLock
Definition: window.h:725
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
Rect mCloseRect
Definition: window.h:689
int mDragOffsetX
Definition: window.h:634
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:708
int height
Definition: rect.h:223
Rect getWindowArea() const
Definition: window.cpp:1445
bool mSticky
Definition: window.h:724
int getX() const
Definition: mouseevent.h:126
Rect mDimension
Definition: widget.h:1100
unsigned int mTitleBarHeight
Definition: window.h:622
Image * mGrip
Definition: window.h:686

◆ getTitleBarHeight()

unsigned int Window::getTitleBarHeight ( ) const
inline

Gets the title bar height.

Returns
The title bar height.
See also
setTitleBarHeight

Definition at line 521 of file window.h.

References mTitleBarHeight.

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

522  { return mTitleBarHeight; }
unsigned int mTitleBarHeight
Definition: window.h:622

◆ getTitlePadding()

int Window::getTitlePadding ( ) const
inlineprotected

◆ getWindowArea()

Rect Window::getWindowArea ( ) const

Definition at line 1445 of file window.cpp.

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

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

1446 {
1447  return Rect(mPadding,
1448  mPadding,
1449  mDimension.width - mPadding * 2,
1450  mDimension.height - mPadding * 2);
1451 }
int width
Definition: rect.h:218
int mPadding
Definition: window.h:617
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 281 of file window.h.

References mDefaultVisible.

282  { return mDefaultVisible; }
bool mDefaultVisible
Definition: window.h:721

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

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

◆ isResizable()

bool Window::isResizable ( ) const

Returns whether the window can be resized.

Definition at line 755 of file window.cpp.

References mGrip.

Referenced by getAlowClose().

756 {
757  return mGrip != nullptr;
758 }
Image * mGrip
Definition: window.h:686

◆ isResizeAllowed()

bool Window::isResizeAllowed ( const MouseEvent event) const

Definition at line 1344 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().

1345 {
1346  const int y = event.getY();
1347 
1348  if ((mGrip != nullptr) &&
1349  (y > CAST_S32(mTitleBarHeight) ||
1350  y < mPadding))
1351  {
1352  const int x = event.getX();
1353 
1354  if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
1355  return true;
1356 
1357  if (x >= mGripRect.x && y >= mGripRect.y)
1358  return true;
1359  }
1360 
1361  return false;
1362 }
Rect mGripRect
Definition: window.h:691
int mPadding
Definition: window.h:617
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:1445
unsigned int mTitleBarHeight
Definition: window.h:622
Image * mGrip
Definition: window.h:686

◆ isSticky()

bool Window::isSticky ( ) const
inline

Returns whether the window is sticky.

Definition at line 252 of file window.h.

References mSticky, and setStickyButtonLock().

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

253  { return mSticky; }
bool mSticky
Definition: window.h:724

◆ isStickyButtonLock()

bool Window::isStickyButtonLock ( ) const
inline

Returns whether the window sticky locking window.

Definition at line 263 of file window.h.

References mStickyButtonLock, and setVisible().

Referenced by PopupMenu::addWindowMenu().

264  { return mStickyButtonLock; }
bool mStickyButtonLock
Definition: window.h:725

◆ 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 1086 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(), ClanWindow::ClanWindow(), 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().

1087 {
1088  const std::string &name = mWindowName;
1089  if (name.empty())
1090  return;
1091 
1092  setPosition(config.getValueInt(name + "WinX", mDefaultX),
1093  config.getValueInt(name + "WinY", mDefaultY));
1094 
1095  if (mSaveVisible)
1096  {
1098  + "Visible", mDefaultVisible), Visible));
1099  }
1100 
1101  if (mStickyButton)
1102  {
1104  + "Sticky", isSticky()));
1105  }
1106 
1107  if (mGrip != nullptr)
1108  {
1109  int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
1110  int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
1111 
1112  if (getMinWidth() > width)
1113  width = getMinWidth();
1114  else if (getMaxWidth() < width)
1115  width = getMaxWidth();
1116  if (getMinHeight() > height)
1117  height = getMinHeight();
1118  else if (getMaxHeight() < height)
1119  height = getMaxHeight();
1120 
1121  setSize(width, height);
1122  }
1123  else
1124  {
1126  }
1127 
1128  // Check if the window is off screen...
1129  ensureOnScreen();
1130 
1131  if (viewport != nullptr)
1132  {
1133  int width = mDimension.width;
1134  int height = mDimension.height;
1135 
1136  if (mDimension.x + width > viewport->getWidth())
1137  width = viewport->getWidth() - mDimension.x;
1138  if (mDimension.y + height > viewport->getHeight())
1139  height = viewport->getHeight() - mDimension.y;
1140  if (width < 0)
1141  width = 0;
1142  if (height < 0)
1143  height = 0;
1144  setSize(width, height);
1145  }
1146 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
std::string mWindowName
Definition: window.h:693
int width
Definition: rect.h:218
int getWidth() const
Definition: widget.h:220
Configuration config
bool mDefaultVisible
Definition: window.h:721
bool mStickyButton
Definition: window.h:723
int mDefaultY
Definition: window.h:650
void ensureOnScreen()
Definition: window.cpp:1426
int getMinHeight() const
Definition: window.h:212
int x
Definition: rect.h:208
void setSticky(const bool sticky)
Definition: window.cpp:765
#define fromBool(val, name)
Definition: booldefines.h:48
int mDefaultWidth
Definition: window.h:651
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:228
bool mSaveVisible
Definition: window.h:722
virtual void setVisible(Visible visible)
Definition: window.cpp:777
bool Visible
Definition: visible.h:29
int mDefaultHeight
Definition: window.h:652
int getMaxWidth() const
Definition: window.h:220
int mDefaultX
Definition: window.h:649
int getHeight() const
Definition: widget.h:239
bool isSticky() const
Definition: window.h:252
int getValueInt(const std::string &key, const int deflt) const
Rect mDimension
Definition: widget.h:1100
int getMinWidth() const
Definition: window.h:204
Viewport * viewport
Definition: viewport.cpp:35
Image * mGrip
Definition: window.h:686

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

982 {
983  if (canMove())
984  {
985  if (!event.isConsumed() && event.getSource() == this)
986  {
987  if (isMovable() && mMoved)
988  {
989  setPosition(event.getX() - mDragOffsetX + getX(),
990  event.getY() - mDragOffsetY + getY());
991  }
992 
993  event.consume();
994  }
995  }
996  else
997  {
998  if (!event.isConsumed() && event.getSource() == this)
999  event.consume();
1000  return;
1001  }
1002 
1003  // Keep guichan window inside screen when it may be moved
1004  if (isMovable() && mMoved)
1005  {
1007  std::max(0, mDimension.x)),
1008  std::min(mainGraphics->mHeight - mDimension.height,
1009  std::max(0, mDimension.y)));
1010  }
1011 
1012  if ((mouseResize != 0) && !mMoved)
1013  {
1014  const int dx = event.getX() - mDragOffsetX;
1015  const int dy = event.getY() - mDragOffsetY;
1016  Rect newDim = getDimension();
1017 
1018  if ((mouseResize & (TOP | BOTTOM)) != 0)
1019  {
1020  const int newHeight = newDim.height
1021  + ((mouseResize & TOP) != 0 ? -dy : dy);
1022  newDim.height = std::min(mMaxWinHeight,
1023  std::max(mMinWinHeight, newHeight));
1024 
1025  if ((mouseResize & TOP) != 0)
1026  newDim.y -= newDim.height - getHeight();
1027  }
1028 
1029  if ((mouseResize & (LEFT | RIGHT)) != 0)
1030  {
1031  const int newWidth = newDim.width
1032  + ((mouseResize & LEFT) != 0 ? -dx : dx);
1033  newDim.width = std::min(mMaxWinWidth,
1034  std::max(mMinWinWidth, newWidth));
1035 
1036  if ((mouseResize & LEFT) != 0)
1037  newDim.x -= newDim.width - mDimension.width;
1038  }
1039 
1040  // Keep guichan window inside screen (supports resizing any side)
1041  if (newDim.x < 0)
1042  {
1043  newDim.width += newDim.x;
1044  newDim.x = 0;
1045  }
1046  if (newDim.y < 0)
1047  {
1048  newDim.height += newDim.y;
1049  newDim.y = 0;
1050  }
1051  if (newDim.x + newDim.width > mainGraphics->mWidth)
1052  newDim.width = mainGraphics->mWidth - newDim.x;
1053  if (newDim.y + newDim.height > mainGraphics->mHeight)
1054  newDim.height = mainGraphics->mHeight - newDim.y;
1055 
1056  // Update mouse offset when dragging bottom or right border
1057  if ((mouseResize & BOTTOM) != 0)
1058  mDragOffsetY += newDim.height - mDimension.height;
1059 
1060  if ((mouseResize & RIGHT) != 0)
1061  mDragOffsetX += newDim.width - mDimension.width;
1062 
1063  // Set the new window and content dimensions
1064  setDimension(newDim);
1065  }
1066 }
int width
Definition: rect.h:218
int mDragOffsetY
Definition: window.h:641
int getY() const
Definition: widget.h:287
static int mouseResize
Definition: window.h:699
Definition: rect.h:72
int mWidth
Definition: graphics.h:483
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
bool mMoved
Definition: window.h:646
int mDragOffsetX
Definition: window.h:634
bool isMovable() const
Definition: window.h:575
int mMaxWinWidth
Definition: window.h:696
int x
Definition: rect.h:208
bool canMove() const
Definition: window.cpp:976
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:126
Rect mDimension
Definition: widget.h:1100
int mMinWinWidth
Definition: window.h:694
int mMaxWinHeight
Definition: window.h:697
int mMinWinHeight
Definition: window.h:695

◆ 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 918 of file window.cpp.

References updateResizeHandler().

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

919 {
920  updateResizeHandler(event);
921 }
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:929

◆ 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 923 of file window.cpp.

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

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

924 {
925  if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
927 }
Gui * gui
Definition: gui.cpp:110
static int mouseResize
Definition: window.h:699
void setCursorType(const CursorT index)
Definition: gui.h:195
Image * mGrip
Definition: window.h:686

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

967 {
968  updateResizeHandler(event);
969  if ((popupManager != nullptr) && !event.isConsumed())
970  {
973  }
974 }
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:929
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 835 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().

836 {
837  if (event.isConsumed())
838  return;
839 
840  if (event.getSource() == this)
841  {
842  if (getParent() != nullptr)
843  getParent()->moveToTop(this);
844 
845  mDragOffsetX = event.getX();
846  mDragOffsetY = event.getY();
847  mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
848  }
849 
850  const MouseButtonT button = event.getButton();
851  if (button == MouseButton::LEFT)
852  {
853  const int x = event.getX();
854  const int y = event.getY();
855 
856  // Handle close button
857  if (mCloseWindowButton &&
858  mSkin != nullptr &&
860  {
861  mouseResize = 0;
862  mMoved = false;
863  event.consume();
864  close();
865  return;
866  }
867 
868  // Handle sticky button
869  if (mStickyButton &&
870  mSkin != nullptr &&
872  {
873  setSticky(!isSticky());
874  mouseResize = 0;
875  mMoved = false;
876  event.consume();
877  return;
878  }
879 
880  // Handle window resizing
882  if (mouseResize != 0)
883  event.consume();
884  if (canMove())
885  mMoved = (mouseResize == 0);
886  else
887  mMoved = false;
888  }
889 #ifndef DYECMD
890  else if (button == MouseButton::RIGHT)
891  {
892  if (popupMenu != nullptr)
893  {
894  event.consume();
895  popupMenu->showWindowPopup(this);
896  }
897  }
898 #endif // DYECMD
899 }
Skin * mSkin
Definition: window.h:648
int mDragOffsetY
Definition: window.h:641
static int mouseResize
Definition: window.h:699
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
Rect mCloseRect
Definition: window.h:689
bool mStickyButton
Definition: window.h:723
bool mMoved
Definition: window.h:646
int mDragOffsetX
Definition: window.h:634
virtual void close()
Definition: window.cpp:901
#define CAST_S32
Definition: cast.h:29
void setSticky(const bool sticky)
Definition: window.cpp:765
bool canMove() const
Definition: window.cpp:976
Widget * getSource() const
Definition: event.h:103
PopupMenu * popupMenu
Definition: popupmenu.cpp:102
bool mCloseWindowButton
Definition: window.h:720
bool isConsumed() const
Rect mStickyRect
Definition: window.h:690
virtual void moveToTop(Widget *widget)
Definition: widget.h:866
Widget * getParent() const
Definition: widget.h:201
bool isSticky() const
Definition: window.h:252
void showWindowPopup(Window *const window)
Definition: popupmenu.cpp:1163
MouseButton ::T MouseButtonT
Definition: mousebutton.h:77
unsigned int mTitleBarHeight
Definition: window.h:622
int getResizeHandles(const MouseEvent &event)
Definition: window.cpp:1305
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 906 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().

907 {
908  if ((mGrip != nullptr) && (mouseResize != 0))
909  {
910  mouseResize = 0;
911  if (gui != nullptr)
913  }
914 
915  mMoved = false;
916 }
Gui * gui
Definition: gui.cpp:110
static int mouseResize
Definition: window.h:699
bool mMoved
Definition: window.h:646
void setCursorType(const CursorT index)
Definition: gui.h:195
Image * mGrip
Definition: window.h:686

◆ place()

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

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

Definition at line 1383 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(), InfoClanTab::InfoClanTab(), InventoryWindow::InventoryWindow(), KillStats::KillStats(), LoginDialog::LoginDialog(), MapDebugTab::MapDebugTab(), NetDebugTab::NetDebugTab(), OutfitWindow::OutfitWindow(), PincodeDialog::PincodeDialog(), 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(), StatDebugTab::StatDebugTab(), StatusWindow::StatusWindow(), TextDialog::TextDialog(), TradeWindow::TradeWindow(), and WorldSelectDialog::WorldSelectDialog().

1385 {
1386  add(wg);
1387  return getLayout().place(wg, x, y, w, h);
1388 }
virtual void add(Widget *const widget)
Layout & getLayout()
Definition: window.cpp:1364
LayoutCell & place(Widget *const wg, const int x, const int y, const int w, const int h)
Definition: layoutcell.cpp:110

◆ postInit()

void Window::postInit ( )
virtual

Reimplemented from Widget.

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

Definition at line 248 of file window.cpp.

References mInit, mWindowName, and reportAlways.

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

249 {
250  if (mInit)
251  {
252  reportAlways("error: Window created with calling postInit() "
253  "more than once: %s",
254  mWindowName.c_str());
255  }
256  mInit = true;
257 }
std::string mWindowName
Definition: window.h:693
bool mInit
Definition: window.h:727
#define reportAlways(...)
Definition: checkutils.h:252

◆ redraw()

void Window::redraw ( )

Definition at line 1405 of file window.cpp.

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

Referenced by NpcDialog::buildLayout().

1406 {
1407  if (mLayout != nullptr)
1408  {
1409  const Rect area = getChildrenArea();
1410  int w = area.width;
1411  int h = area.height;
1412  mLayout->reflow(w, h);
1413  }
1414 }
int width
Definition: rect.h:218
Rect getChildrenArea()
Definition: window.cpp:1472
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:688

◆ reflowLayout()

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

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 1395 of file window.cpp.

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

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

1396 {
1397  if (mLayout == nullptr)
1398  return;
1399 
1400  mLayout->reflow(w, h);
1401  delete2(mLayout);
1402  setContentSize(w, h);
1403 }
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:491
Layout * mLayout
Definition: window.h:688

◆ resetToDefaultSize()

void Window::resetToDefaultSize ( )
virtual

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

Definition at line 1258 of file window.cpp.

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

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

1259 {
1262  saveWindowState();
1263 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int mDefaultY
Definition: window.h:650
int mDefaultWidth
Definition: window.h:651
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int mDefaultHeight
Definition: window.h:652
int mDefaultX
Definition: window.h:649
void saveWindowState()
Definition: window.cpp:1148

◆ resizeToContent()

void Window::resizeToContent ( )
virtual

Resizes the window to fit the content.

Definition at line 1480 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().

1481 {
1482  int w = 0;
1483  int h = 0;
1484  for (WidgetListConstIterator it = mWidgets.begin();
1485  it != mWidgets.end(); ++ it)
1486  {
1487  const Widget *const widget = *it;
1488  const int x = widget->getX();
1489  const int y = widget->getY();
1490  const int width = widget->getWidth();
1491  const int height = widget->getHeight();
1492  if (x + width > w)
1493  w = x + width;
1494 
1495  if (y + height > h)
1496  h = y + height;
1497  }
1498 
1499  setSize(w + 2 * mPadding,
1500  h + mPadding + mTitleBarHeight);
1501 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int getWidth() const
Definition: widget.h:220
int mPadding
Definition: window.h:617
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:622

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

423 {
424  if (mSkin == nullptr)
425  return;
426 
427  BLOCK_START("Window::safeDraw")
428 
429  graphics->drawImageRect(0, 0,
430  mDimension.width,
431  mDimension.height,
432  mSkin->getBorder());
433 
434  // Draw Close Button
436  {
437  const Image *const button = mSkin->getCloseImage(
438  mResizeHandles == CLOSE);
439  if (button != nullptr)
440  graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
441  }
442  // Draw Sticky Button
443  if (mStickyButton)
444  {
445  const Image *const button = mSkin->getStickyImage(mSticky);
446  if (button != nullptr)
447  graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
448  }
449 
450  if (mGrip != nullptr)
451  graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
452 
453  // Draw title
454  if (mShowTitle)
455  {
456  int x;
457  switch (mCaptionAlign)
458  {
459  case Graphics::LEFT:
460  default:
461  x = mCaptionOffsetX;
462  break;
463  case Graphics::CENTER:
465  break;
466  case Graphics::RIGHT:
468  break;
469  }
470  if (mTextChanged)
471  {
478  mTextChanged = false;
479  }
480 
481  const Image *const image = mTextChunk.img;
482  if (image != nullptr)
483  graphics->drawImage(image, x, mCaptionOffsetY);
484  }
485 
486  safeDrawChildren(graphics);
487 
488  BLOCK_END("Window::safeDraw")
489 }
bool mShowTitle
Definition: window.h:655
Rect mGripRect
Definition: window.h:691
std::string text
Definition: textchunk.h:64
Font * mCaptionFont
Definition: window.h:718
Skin * mSkin
Definition: window.h:648
TextChunk mTextChunk
Definition: window.h:692
bool mTextChanged
Definition: window.h:728
int mCaptionOffsetY
Definition: window.h:654
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
Rect mCloseRect
Definition: window.h:689
bool mStickyButton
Definition: window.h:723
#define BLOCK_END(name)
Definition: perfomance.h:79
Color mForegroundColor
Definition: widget.h:1085
int mCaptionOffsetX
Definition: window.h:653
Font * textFont
Definition: textchunk.h:63
int x
Definition: rect.h:208
int y
Definition: rect.h:213
Graphics::Alignment mCaptionAlign
Definition: window.h:710
const Image * getStickyImage(const bool state) const
Definition: skin.h:80
bool mCloseWindowButton
Definition: window.h:720
void drawImageRect(int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 override final
int mResizeHandles
Definition: window.h:713
bool mSticky
Definition: window.h:724
Rect mStickyRect
Definition: window.h:690
std::string mCaption
Definition: window.h:607
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:429
Image * mGrip
Definition: window.h:686

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

1149 {
1150  // Saving X, Y and Width and Height for resizables in the config
1151  if (!mWindowName.empty() && mWindowName != "window")
1152  {
1153  config.setValue(mWindowName + "WinX", mDimension.x);
1154  config.setValue(mWindowName + "WinY", mDimension.y);
1155 
1156  if (mSaveVisible)
1157  config.setValue(mWindowName + "Visible", isWindowVisible());
1158 
1159  if (mStickyButton)
1160  config.setValue(mWindowName + "Sticky", isSticky());
1161 
1162  if (mGrip != nullptr)
1163  {
1164  if (getMinWidth() > mDimension.width)
1165  setWidth(getMinWidth());
1166  else if (getMaxWidth() < mDimension.width)
1167  setWidth(getMaxWidth());
1168  if (getMinHeight() > mDimension.height)
1170  else if (getMaxHeight() < mDimension.height)
1172 
1173  config.setValue(mWindowName + "WinWidth", mDimension.width);
1174  config.setValue(mWindowName + "WinHeight", mDimension.height);
1175  }
1176  }
1177 }
std::string mWindowName
Definition: window.h:693
int width
Definition: rect.h:218
void setWidth(const int width)
Definition: widget.cpp:132
Configuration config
bool mStickyButton
Definition: window.h:723
int getMinHeight() const
Definition: window.h:212
int x
Definition: rect.h:208
int y
Definition: rect.h:213
bool isWindowVisible() const
Definition: window.h:483
int height
Definition: rect.h:223
int getMaxHeight() const
Definition: window.h:228
void setHeight(const int height)
Definition: widget.cpp:139
bool mSaveVisible
Definition: window.h:722
int getMaxWidth() const
Definition: window.h:220
bool isSticky() const
Definition: window.h:252
Rect mDimension
Definition: widget.h:1100
void setValue(const std::string &key, const std::string &value)
int getMinWidth() const
Definition: window.h:204
Image * mGrip
Definition: window.h:686

◆ 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 830 of file window.cpp.

References WindowContainer::scheduleDelete(), and windowContainer.

Referenced by MailViewWindow::action(), EditDialog::action(), EditServerDialog::action(), QuitDialog::action(), CharCreateDialog::action(), OkDialog::action(), ConfirmDialog::action(), ServerDialog::action(), ServerInfoWindow::close(), PincodeDialog::close(), MailEditWindow::close(), ItemAmountWindow::close(), TextDialog::close(), InventoryWindow::close(), DialogsManager::closeDialogs(), PincodeManager::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().

831 {
833 }
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 548 of file window.h.

References mAlignment.

549  { mAlignment = alignment; }
Graphics::Alignment mAlignment
Definition: window.h:612

◆ setAllowClose()

void Window::setAllowClose ( const bool  b)
inline

Definition at line 188 of file window.h.

References mAllowClose.

Referenced by ShortcutWindow::ShortcutWindow().

189  { mAllowClose = b; }
bool mAllowClose
Definition: window.h:729

◆ setCaption()

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

◆ setCaptionFont()

void Window::setCaptionFont ( Font font)
inline

Definition at line 477 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 491 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(), LoginDialog::postInit(), ConfirmDialog::postInit(), reflowLayout(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), CharCreateDialog::setAttributes(), and MiniStatusWindow::updateBars().

492 {
493  width = width + 2 * mPadding;
494  height = height + mPadding + mTitleBarHeight;
495 
496  if (mMinWinWidth > width)
497  width = mMinWinWidth;
498  else if (mMaxWinWidth < width)
499  width = mMaxWinWidth;
500  if (mMinWinHeight > height)
501  height = mMinWinHeight;
502  else if (mMaxWinHeight < height)
503  height = mMaxWinHeight;
504 
505  setSize(width, height);
506 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int mPadding
Definition: window.h:617
int mMaxWinWidth
Definition: window.h:696
unsigned int mTitleBarHeight
Definition: window.h:622
int mMinWinWidth
Definition: window.h:694
int mMaxWinHeight
Definition: window.h:697
int mMinWinHeight
Definition: window.h:695

◆ 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 1179 of file window.cpp.

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

1181 {
1182  if (mMinWinWidth > defaultWidth)
1183  defaultWidth = mMinWinWidth;
1184  else if (mMaxWinWidth < defaultWidth)
1185  defaultWidth = mMaxWinWidth;
1186  if (mMinWinHeight > defaultHeight)
1187  defaultHeight = mMinWinHeight;
1188  else if (mMaxWinHeight < defaultHeight)
1189  defaultHeight = mMaxWinHeight;
1190 
1191  mDefaultX = defaultX;
1192  mDefaultY = defaultY;
1193  mDefaultWidth = defaultWidth;
1194  mDefaultHeight = defaultHeight;
1195 }
int mMaxWinWidth
Definition: window.h:696
int mDefaultY
Definition: window.h:650
int mDefaultWidth
Definition: window.h:651
int mDefaultHeight
Definition: window.h:652
int mDefaultX
Definition: window.h:649
int mMinWinWidth
Definition: window.h:694
int mMaxWinHeight
Definition: window.h:697
int mMinWinHeight
Definition: window.h:695

◆ setDefaultSize() [2/3]

void Window::setDefaultSize ( )

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

Definition at line 1197 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(), ClanWindow::ClanWindow(), 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().

1198 {
1203 }
int width
Definition: rect.h:218
int mDefaultY
Definition: window.h:650
int x
Definition: rect.h:208
int mDefaultWidth
Definition: window.h:651
int y
Definition: rect.h:213
int height
Definition: rect.h:223
int mDefaultHeight
Definition: window.h:652
int mDefaultX
Definition: window.h:649
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,
const int  offsetY 
)

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

1208 {
1209  int x = 0;
1210  int y = 0;
1211 
1212  if (position == ImagePosition::UPPER_LEFT)
1213  {
1214  }
1215  else if (position == ImagePosition::UPPER_CENTER)
1216  {
1217  x = (mainGraphics->mWidth - defaultWidth) / 2;
1218  }
1219  else if (position == ImagePosition::UPPER_RIGHT)
1220  {
1221  x = mainGraphics->mWidth - defaultWidth;
1222  }
1223  else if (position == ImagePosition::LEFT)
1224  {
1225  y = (mainGraphics->mHeight - defaultHeight) / 2;
1226  }
1227  else if (position == ImagePosition::CENTER)
1228  {
1229  x = (mainGraphics->mWidth - defaultWidth) / 2;
1230  y = (mainGraphics->mHeight - defaultHeight) / 2;
1231  }
1232  else if (position == ImagePosition::RIGHT)
1233  {
1234  x = mainGraphics->mWidth - defaultWidth;
1235  y = (mainGraphics->mHeight - defaultHeight) / 2;
1236  }
1237  else if (position == ImagePosition::LOWER_LEFT)
1238  {
1239  y = mainGraphics->mHeight - defaultHeight;
1240  }
1241  else if (position == ImagePosition::LOWER_CENTER)
1242  {
1243  x = (mainGraphics->mWidth - defaultWidth) / 2;
1244  y = mainGraphics->mHeight - defaultHeight;
1245  }
1246  else if (position == ImagePosition::LOWER_RIGHT)
1247  {
1248  x = mainGraphics->mWidth - defaultWidth;
1249  y = mainGraphics->mHeight - defaultHeight;
1250  }
1251 
1252  mDefaultX = x - offsetX;
1253  mDefaultY = y - offsetY;
1254  mDefaultWidth = defaultWidth;
1255  mDefaultHeight = defaultHeight;
1256 }
int mWidth
Definition: graphics.h:483
int mDefaultY
Definition: window.h:650
int mDefaultWidth
Definition: window.h:651
Graphics * mainGraphics
Definition: graphics.cpp:108
int mHeight
Definition: graphics.h:484
int mDefaultHeight
Definition: window.h:652
int mDefaultX
Definition: window.h:649

◆ setDefaultVisible()

void Window::setDefaultVisible ( const bool  save)
inline

Sets whether the window is visible by default.

Definition at line 287 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 527 of file window.cpp.

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

Referenced by centerHorisontally().

528 {
529  if (widget == nullptr)
530  return;
531 
532  int wx;
533  int wy;
534  int x;
535  int y;
536 
537  widget->getAbsolutePosition(wx, wy);
538  getAbsolutePosition(x, y);
539 
540  setPosition(mDimension.x + (wx + (widget->getWidth()
541  - mDimension.width) / 2 - x), 0);
542 }
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 508 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(), PincodeDialog::postInit(), TextDialog::postInit(), QuitDialog::postInit(), WhoIsOnline::postInit(), and SkillDialog::postInit().

509 {
510  if (widget == nullptr)
511  return;
512 
513  int wx;
514  int wy;
515  int x;
516  int y;
517 
518  widget->getAbsolutePosition(wx, wy);
519  getAbsolutePosition(x, y);
520 
521  setPosition(mDimension.x + (wx + (widget->getWidth()
522  - mDimension.width) / 2 - x),
523  mDimension.y + (wy + (widget->getHeight()
524  - mDimension.height) / 2 - y));
525 }
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,
int  offsetY 
)

Sets the location relative to the given enumerated position.

Definition at line 544 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.

546 {
547  if (position == ImagePosition::UPPER_LEFT)
548  {
549  }
550  else if (position == ImagePosition::UPPER_CENTER)
551  {
552  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
553  }
554  else if (position == ImagePosition::UPPER_RIGHT)
555  {
556  offsetX += mainGraphics->mWidth - mDimension.width;
557  }
558  else if (position == ImagePosition::LEFT)
559  {
560  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
561  }
562  else if (position == ImagePosition::CENTER)
563  {
564  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
565  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
566  }
567  else if (position == ImagePosition::RIGHT)
568  {
569  offsetX += mainGraphics->mWidth - mDimension.width;
570  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
571  }
572  else if (position == ImagePosition::LOWER_LEFT)
573  {
574  offsetY += mainGraphics->mHeight - mDimension.height;
575  }
576  else if (position == ImagePosition::LOWER_CENTER)
577  {
578  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
579  offsetY += mainGraphics->mHeight - mDimension.height;
580  }
581  else if (position == ImagePosition::LOWER_RIGHT)
582  {
583  offsetX += mainGraphics->mWidth - mDimension.width;
584  offsetY += mainGraphics->mHeight - mDimension.height;
585  }
586 
587  setPosition(offsetX, offsetY);
588 }
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 621 of file window.cpp.

References mMaxWinHeight.

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

622 {
623  mMaxWinHeight = height;
624 }
int mMaxWinHeight
Definition: window.h:697

◆ setMaxWidth()

void Window::setMaxWidth ( const int  width)

Sets the maximum width of the window.

Definition at line 616 of file window.cpp.

References mMaxWinWidth.

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

617 {
618  mMaxWinWidth = width;
619 }
int mMaxWinWidth
Definition: window.h:696

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

1069 {
1070  if (mModal != modal)
1071  {
1072  mModal = modal;
1073  if (mModal == Modal_true)
1074  {
1075  if (gui != nullptr)
1078  }
1079  else
1080  {
1082  }
1083  }
1084 }
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:719

◆ 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 566 of file window.h.

References mMovable.

Referenced by ConnectionDialog::ConnectionDialog().

567  { mMovable = movable; }
Move mMovable
Definition: window.h:627

◆ 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 493 of file window.h.

References mPadding.

Referenced by Window().

494  { mPadding = padding; }
int mPadding
Definition: window.h:617

◆ setResizable()

void Window::setResizable ( const bool  resize)

Sets whether or not the window can be resized.

Definition at line 626 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(), ClanWindow::ClanWindow(), 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().

627 {
628  if ((mGrip != nullptr) == r)
629  return;
630 
631  if (mGrip != nullptr)
632  mGrip->decRef();
633  if (r)
634  {
635  mGrip = Theme::getImageFromThemeXml("resize.xml", "");
636  if (mGrip != nullptr)
637  {
640  - mGripPadding;
641  }
642  else
643  {
644  mGripRect.x = 0;
645  mGripRect.y = 0;
646  }
647  }
648  else
649  {
650  mGrip = nullptr;
651  }
652 }
Rect mGripRect
Definition: window.h:691
int width
Definition: rect.h:218
int mGripPadding
Definition: window.h:712
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:925
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:522
int getHeight() const A_INLINE
Definition: image.h:122
Image * mGrip
Definition: window.h:686

◆ 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 234 of file window.h.

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

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

235  { mShowTitle = flag; }
bool mShowTitle
Definition: window.h:655

◆ 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 765 of file window.cpp.

References Widget::mRedraw, and mSticky.

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

766 {
767  mSticky = sticky;
768  mRedraw = true;
769 }
bool mSticky
Definition: window.h:724
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 760 of file window.cpp.

References mStickyButton.

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

761 {
762  mStickyButton = flag;
763 }
bool mStickyButton
Definition: window.h:723

◆ 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 512 of file window.h.

References mTitleBarHeight.

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

513  { mTitleBarHeight = height; }
unsigned int mTitleBarHeight
Definition: window.h:622

◆ setTitlePadding()

void Window::setTitlePadding ( const int  p)
inlineprotected

Definition at line 598 of file window.h.

References mTitlePadding.

599  { mTitlePadding = p; }
int mTitlePadding
Definition: window.h:711

◆ setVisible() [1/2]

void Window::setVisible ( Visible  visible)
virtual

Overloads window setVisible by Guichan to allow sticky window handling.

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

Definition at line 777 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(), PincodeDialog::postInit(), ConnectionDialog::postInit(), ItemAmountWindow::postInit(), SocialWindow::postInit(), WorldSelectDialog::postInit(), TextDialog::postInit(), EditDialog::postInit(), EditServerDialog::postInit(), QuitDialog::postInit(), WhoIsOnline::postInit(), TextCommandEditor::postInit(), RegisterDialog::postInit(), LoginDialog::postInit(), ServerDialog::postInit(), ConfirmDialog::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(), BuyDialog::setVisible(), ChatWindow::setVisible(), NpcDialog::setVisible(), EmoteWindow::show(), CutInWindow::show(), Actions::showHelpPage(), Actions::showHideWindow(), Minimap::toggle(), and Window().

778 {
779  setVisible(visible, false);
780 }
virtual void setVisible(Visible visible)
Definition: window.cpp:777

◆ 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 782 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.

783 {
784  if (visible == mVisible)
785  return;
786 
787  // Check if the window is off screen...
788  if (visible == Visible_true)
789  ensureOnScreen();
790  else
791  mResizeHandles = 0;
792 
793  if (mStickyButtonLock)
794  {
796  }
797  else
798  {
799  BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
800  visible == Visible_true, Visible));
801  }
802  if (visible == Visible_true)
803  {
804  if (mPlayVisibleSound)
806  if (gui != nullptr)
807  {
808  MouseEvent *const event = reinterpret_cast<MouseEvent*>(
809  gui->createMouseEvent(this));
810  if (event != nullptr)
811  {
812  const int x = event->getX();
813  const int y = event->getY();
814  if (x >= 0 && x <= mDimension.width
815  && y >= 0 && y <= mDimension.height)
816  {
817  mouseMoved(*event);
818  }
819  delete event;
820  }
821  }
822  }
823  else
824  {
825  if (mPlayVisibleSound)
827  }
828 }
MouseEvent * createMouseEvent(Window *const widget)
Definition: gui.cpp:985
static const std::string SOUND_HIDE_WINDOW
Definition: sound.h:37
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:725
SoundManager soundManager
void mouseMoved(MouseEvent &event)
Definition: window.cpp:966
Visible mVisible
Definition: widget.h:962
void ensureOnScreen()
Definition: window.cpp:1426
#define fromBool(val, name)
Definition: booldefines.h:48
int height
Definition: rect.h:223
int mResizeHandles
Definition: window.h:713
bool mSticky
Definition: window.h:724
bool mPlayVisibleSound
Definition: window.h:726
static const std::string SOUND_SHOW_WINDOW
Definition: sound.h:36
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 305 of file window.cpp.

References windowContainer.

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

306 {
307  windowContainer = wc;
308 }

◆ setWindowName()

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

◆ updateResizeHandler()

void Window::updateResizeHandler ( MouseEvent event)

Definition at line 929 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().

930 {
931  if (gui == nullptr)
932  return;
933 
934 #ifndef DYECMD
935  if (!dragDrop.isEmpty())
936  return;
937 #endif // DYECMD
938 
940 
941  // Changes the custom mouse cursor based on it's current position.
942  switch (mResizeHandles & resizeMask)
943  {
944  case BOTTOM | RIGHT:
945  case TOP | LEFT:
947  break;
948  case TOP | RIGHT:
949  case BOTTOM | LEFT:
951  break;
952  case BOTTOM:
953  case TOP:
955  break;
956  case RIGHT:
957  case LEFT:
959  break;
960  default:
962  break;
963  }
964 }
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:713
int getResizeHandles(const MouseEvent &event)
Definition: window.cpp:1305
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 724 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().

725 {
727  mVertexes->clear();
728 
730 
731  mTextChanged = true;
732  mRedraw = true;
733 
734  if (gui != nullptr)
736 
737  if (mFocusHandler == nullptr)
738  return;
739 
740  for (WidgetListConstIterator it = mWidgets.begin();
741  it != mWidgets.end(); ++ it)
742  {
743  if (mFocusHandler->isFocused(*it))
745  }
746 }
TextChunk mTextChunk
Definition: window.h:692
Gui * gui
Definition: gui.cpp:110
WidgetList::const_iterator WidgetListConstIterator
bool mTextChanged
Definition: window.h:728
bool isFocused(const Widget *const widget) const
ImageCollection * mVertexes
Definition: window.h:709
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 719 of file window.cpp.

References Widget::mRedraw.

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

720 {
721  mRedraw = true;
722 }
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, DebugWindow, and ClanWindow.

Definition at line 654 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(), ClanWindow::widgetResized(), DebugWindow::widgetResized(), EmoteWindow::widgetResized(), SetupWindow::widgetResized(), WhoIsOnline::widgetResized(), CharSelectDialog::widgetResized(), SocialWindow::widgetResized(), SkillDialog::widgetResized(), InventoryWindow::widgetResized(), and ChatWindow::widgetResized().

655 {
656  if (mGrip != nullptr)
657  {
660  }
661 
662  if (mLayout != nullptr)
663  {
664  const Rect area = getChildrenArea();
665  int w = area.width;
666  int h = area.height;
667  mLayout->reflow(w, h);
668  }
669  if (mSkin != nullptr)
670  {
671  const bool showClose = mCloseWindowButton
672  && (mSkin->getCloseImage(false) != nullptr);
673  if (showClose)
674  {
675  const Image *const button = mSkin->getCloseImage(false);
676  if (button != nullptr)
677  {
678  const int buttonWidth = button->getWidth();
679  mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
682  mCloseRect.height = button->getHeight();
683  }
684  }
685  if (mStickyButton)
686  {
687  const Image *const button = mSkin->getStickyImage(mSticky);
688  if (button != nullptr)
689  {
690  const int buttonWidth = button->getWidth();
691  int x = mDimension.width - buttonWidth
693 
694  if (showClose)
695  x -= mSkin->getCloseImage(false)->getWidth();
696 
697  mStickyRect.x = x;
700  mStickyRect.height = button->getHeight();
701  }
702  }
703  }
704  else
705  {
706  mCloseRect.x = 0;
707  mCloseRect.y = 0;
708  mCloseRect.width = 0;
709  mCloseRect.height = 0;
710  mStickyRect.x = 0;
711  mStickyRect.y = 0;
712  mStickyRect.width = 0;
713  mStickyRect.height = 0;
714  }
715 
716  mRedraw = true;
717 }
static const int buttonWidth
Definition: sliderlist.cpp:34
Rect mGripRect
Definition: window.h:691
int width
Definition: rect.h:218
Skin * mSkin
Definition: window.h:648
int mGripPadding
Definition: window.h:712
Rect getChildrenArea()
Definition: window.cpp:1472
Definition: rect.h:72
void reflow(int &nW, int &nH)
Definition: layout.cpp:35
int mStickySpacing
Definition: window.h:716
Rect mCloseRect
Definition: window.h:689
bool mStickyButton
Definition: window.h:723
int x
Definition: rect.h:208
int y
Definition: rect.h:213
int mStickyPadding
Definition: window.h:717
const Image * getStickyImage(const bool state) const
Definition: skin.h:80
int mClosePadding
Definition: window.h:715
int height
Definition: rect.h:223
bool mCloseWindowButton
Definition: window.h:720
bool mSticky
Definition: window.h:724
Rect mStickyRect
Definition: window.h:690
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:688
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:686

◆ willSaveVisible()

bool Window::willSaveVisible ( ) const
inline

Returns whether the window will save it's visibility.

Definition at line 293 of file window.h.

References mSaveVisible.

294  { return mSaveVisible; }
bool mSaveVisible
Definition: window.h:722

Field Documentation

◆ mAlignment

Graphics::Alignment Window::mAlignment
protected

Holds the alignment of the caption.

Definition at line 612 of file window.h.

Referenced by getAlignment(), and setAlignment().

◆ mAllowClose

bool Window::mAllowClose
private

Definition at line 729 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 607 of file window.h.

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

◆ mCaptionAlign

Graphics::Alignment Window::mCaptionAlign
private

Definition at line 710 of file window.h.

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

◆ mCaptionFont

Font* Window::mCaptionFont
private

Definition at line 718 of file window.h.

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

◆ mCaptionOffsetX

int Window::mCaptionOffsetX
protected

Definition at line 653 of file window.h.

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

◆ mCaptionOffsetY

int Window::mCaptionOffsetY
protected

Definition at line 654 of file window.h.

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

◆ mClosePadding

int Window::mClosePadding
private

Definition at line 715 of file window.h.

Referenced by widgetResized(), and Window().

◆ mCloseRect

Rect Window::mCloseRect
private

Close button rectangle

Definition at line 689 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 720 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 652 of file window.h.

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

◆ mDefaultVisible

bool Window::mDefaultVisible
private

Window's default visibility

Definition at line 721 of file window.h.

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

◆ mDefaultWidth

int Window::mDefaultWidth
protected

Default window width

Definition at line 651 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 649 of file window.h.

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

◆ mDefaultY

int Window::mDefaultY
protected

Default window Y position

Definition at line 650 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 634 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 641 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 712 of file window.h.

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

◆ mGripRect

Rect Window::mGripRect
private

Resize grip rectangle

Definition at line 691 of file window.h.

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

◆ mInit

bool Window::mInit
private

Definition at line 727 of file window.h.

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

◆ mLastRedraw

bool Window::mLastRedraw
protected

Definition at line 656 of file window.h.

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

◆ mLayout

Layout* Window::mLayout
private

Layout handler

Definition at line 688 of file window.h.

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

◆ mMaxWinHeight

int Window::mMaxWinHeight
private

Maximum window height

Definition at line 697 of file window.h.

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

◆ mMaxWinWidth

int Window::mMaxWinWidth
private

Maximum window width

Definition at line 696 of file window.h.

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

◆ mMinWinHeight

int Window::mMinWinHeight
private

Minimum window height

Definition at line 695 of file window.h.

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

◆ mMinWinWidth

int Window::mMinWinWidth
private

Minimum window width

Definition at line 694 of file window.h.

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

◆ mModal

Modal Window::mModal
private

Window is modal

Definition at line 719 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 627 of file window.h.

Referenced by isMovable(), and setMovable().

◆ mMoved

bool Window::mMoved
protected

◆ mOldResizeHandles

int Window::mOldResizeHandles
private

Definition at line 714 of file window.h.

Referenced by draw().

◆ mouseResize

int Window::mouseResize = 0
staticprivate

Active resize handles

Definition at line 699 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 687 of file window.h.

Referenced by getParentWindow().

◆ mPlayVisibleSound

bool Window::mPlayVisibleSound
private

Definition at line 726 of file window.h.

Referenced by enableVisibleSound(), and setVisible().

◆ mResizeHandles

int Window::mResizeHandles
private

Definition at line 713 of file window.h.

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

◆ mSaveVisible

bool Window::mSaveVisible
private

Window will save visibility

Definition at line 722 of file window.h.

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

◆ mShowTitle

bool Window::mShowTitle
protected

Window has a title bar

Definition at line 655 of file window.h.

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

◆ mSkin

Skin* Window::mSkin
protected

◆ mSticky

bool Window::mSticky
private

Window resists hiding

Definition at line 724 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 725 of file window.h.

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

◆ mStickyPadding

int Window::mStickyPadding
private

Definition at line 717 of file window.h.

Referenced by widgetResized(), and Window().

◆ mStickyRect

Rect Window::mStickyRect
private

Sticky button rectangle

Definition at line 690 of file window.h.

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

◆ mStickySpacing

int Window::mStickySpacing
private

Definition at line 716 of file window.h.

Referenced by widgetResized(), and Window().

◆ mTextChanged

bool Window::mTextChanged
private

Definition at line 728 of file window.h.

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

◆ mTextChunk

TextChunk Window::mTextChunk
private

Definition at line 692 of file window.h.

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

◆ mTitleBarHeight

unsigned int Window::mTitleBarHeight
protected

◆ mTitlePadding

int Window::mTitlePadding
private

Definition at line 711 of file window.h.

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

◆ mVertexes

ImageCollection* Window::mVertexes
private

Definition at line 709 of file window.h.

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

◆ mWindowName

std::string Window::mWindowName
private

Name of the window

Definition at line 693 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 708 of file window.h.

Referenced by getResizeHandles().

◆ windowInstances

int Window::windowInstances = 0
staticprivate

Number of Window instances

Definition at line 700 of file window.h.

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


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