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:1461
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:1449
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:773
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:360
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:1160
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306
void windowRemoved(const Window *const window)
Definition: client.cpp:801
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:1144
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 1261 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().

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

1281 {
1282  if (mGrip == nullptr)
1283  return;
1284 
1285  const int screenWidth = mainGraphics->mWidth;
1286  const int screenHeight = mainGraphics->mHeight;
1287  const int oldWidth = mDimension.width;
1288  const int oldHeight = mDimension.height;
1289  if (oldWidth + mDimension.x > screenWidth)
1290  mDimension.x = 0;
1291  if (oldHeight + mDimension.y > screenHeight)
1292  mDimension.x = 0;
1293  if (mDimension.width > screenWidth)
1294  mDimension.width = screenWidth;
1295  if (mDimension.height > screenHeight)
1296  mDimension.height = screenHeight;
1297  if (oldWidth != mDimension.width || oldHeight != mDimension.height)
1298  widgetResized(Event(this));
1299 }
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:650
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 972 of file window.cpp.

References mSticky, and mStickyButtonLock.

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

973 {
974  return !mStickyButtonLock || !mSticky;
975 }
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 1417 of file window.cpp.

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

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

1418 {
1420 }
void setLocationHorisontallyRelativeTo(const Widget *const widget)
Definition: window.cpp:525
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 1367 of file window.cpp.

References BasicContainer::clear(), and mLayout.

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

1368 {
1369  clear();
1370 
1371  // Recreate layout instance when one is present
1372  if (mLayout != nullptr)
1373  {
1374  delete mLayout;
1375  mLayout = new Layout;
1376  }
1377 }
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:428
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 1422 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().

1423 {
1424  // Skip when a window hasn't got any size initialized yet
1425  if (mDimension.width == 0 && mDimension.height == 0)
1426  return;
1427 
1428  // Check the left and bottom screen boundaries
1433 
1434  // But never allow the windows to disappear in to the right and top
1435  if (mDimension.x < 0)
1436  mDimension.x = 0;
1437  if (mDimension.y < 0)
1438  mDimension.y = 0;
1439 }
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 1468 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().

1469 {
1470  return Rect(mPadding,
1472  mDimension.width - mPadding * 2,
1474 }
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 1449 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().

1450 {
1451  if (mSkin != nullptr)
1452  {
1453  const int val = mSkin->getOption(name);
1454  if (val != 0)
1455  return val;
1456  return def;
1457  }
1458  return def;
1459 }
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 1461 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().

1462 {
1463  if (mSkin != nullptr)
1464  return mSkin->getOption(name, static_cast<int>(def)) != 0;
1465  return def;
1466 }
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 1301 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().

1302 {
1303  if (event.getX() < 0 || event.getY() < 0)
1304  return 0;
1305 
1306  int resizeHandles = 0;
1307  const unsigned y = event.getY();
1308  const unsigned x = event.getX();
1309  if (mCloseRect.isPointInRect(x, y))
1310  return CLOSE;
1311 
1312  if (!mStickyButtonLock || !mSticky)
1313  {
1314  if ((mGrip != nullptr) &&
1315  (y > mTitleBarHeight ||
1316  (CAST_S32(y) < mPadding &&
1318  {
1319  if (!getWindowArea().isPointInRect(x, y)
1320  && event.getSource() == this)
1321  {
1322  resizeHandles |= (x > mDimension.width - resizeBorderWidth)
1323  ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
1324  resizeHandles |= (y > mDimension.height - resizeBorderWidth)
1325  ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
1326  }
1327  if (x >= CAST_U32(mGripRect.x)
1328  && y >= CAST_U32(mGripRect.y))
1329  {
1330  mDragOffsetX = x;
1331  mDragOffsetY = y;
1332  resizeHandles |= BOTTOM | RIGHT;
1333  }
1334  }
1335  }
1336 
1337  return resizeHandles;
1338 }
#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:1441
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 1441 of file window.cpp.

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

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

1442 {
1443  return Rect(mPadding,
1444  mPadding,
1445  mDimension.width - mPadding * 2,
1446  mDimension.height - mPadding * 2);
1447 }
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 751 of file window.cpp.

References mGrip.

Referenced by getAlowClose().

752 {
753  return mGrip != nullptr;
754 }
Image * mGrip
Definition: window.h:686

◆ isResizeAllowed()

bool Window::isResizeAllowed ( const MouseEvent event) const

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

1341 {
1342  const int y = event.getY();
1343 
1344  if ((mGrip != nullptr) &&
1345  (y > CAST_S32(mTitleBarHeight) ||
1346  y < mPadding))
1347  {
1348  const int x = event.getX();
1349 
1350  if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
1351  return true;
1352 
1353  if (x >= mGripRect.x && y >= mGripRect.y)
1354  return true;
1355  }
1356 
1357  return false;
1358 }
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:1441
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 1082 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().

1083 {
1084  const std::string &name = mWindowName;
1085  if (name.empty())
1086  return;
1087 
1088  setPosition(config.getValueInt(name + "WinX", mDefaultX),
1089  config.getValueInt(name + "WinY", mDefaultY));
1090 
1091  if (mSaveVisible)
1092  {
1094  + "Visible", mDefaultVisible), Visible));
1095  }
1096 
1097  if (mStickyButton)
1098  {
1100  + "Sticky", isSticky()));
1101  }
1102 
1103  if (mGrip != nullptr)
1104  {
1105  int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
1106  int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
1107 
1108  if (getMinWidth() > width)
1109  width = getMinWidth();
1110  else if (getMaxWidth() < width)
1111  width = getMaxWidth();
1112  if (getMinHeight() > height)
1113  height = getMinHeight();
1114  else if (getMaxHeight() < height)
1115  height = getMaxHeight();
1116 
1117  setSize(width, height);
1118  }
1119  else
1120  {
1122  }
1123 
1124  // Check if the window is off screen...
1125  ensureOnScreen();
1126 
1127  if (viewport != nullptr)
1128  {
1129  int width = mDimension.width;
1130  int height = mDimension.height;
1131 
1132  if (mDimension.x + width > viewport->getWidth())
1133  width = viewport->getWidth() - mDimension.x;
1134  if (mDimension.y + height > viewport->getHeight())
1135  height = viewport->getHeight() - mDimension.y;
1136  if (width < 0)
1137  width = 0;
1138  if (height < 0)
1139  height = 0;
1140  setSize(width, height);
1141  }
1142 }
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:1422
int getMinHeight() const
Definition: window.h:212
int x
Definition: rect.h:208
void setSticky(const bool sticky)
Definition: window.cpp:761
#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:773
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 977 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().

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

References updateResizeHandler().

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

915 {
916  updateResizeHandler(event);
917 }
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:925

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

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

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

920 {
921  if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
923 }
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 962 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().

963 {
964  updateResizeHandler(event);
965  if ((popupManager != nullptr) && !event.isConsumed())
966  {
969  }
970 }
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:925
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 831 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().

832 {
833  if (event.isConsumed())
834  return;
835 
836  if (event.getSource() == this)
837  {
838  if (getParent() != nullptr)
839  getParent()->moveToTop(this);
840 
841  mDragOffsetX = event.getX();
842  mDragOffsetY = event.getY();
843  mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
844  }
845 
846  const MouseButtonT button = event.getButton();
847  if (button == MouseButton::LEFT)
848  {
849  const int x = event.getX();
850  const int y = event.getY();
851 
852  // Handle close button
853  if (mCloseWindowButton &&
854  mSkin != nullptr &&
856  {
857  mouseResize = 0;
858  mMoved = false;
859  event.consume();
860  close();
861  return;
862  }
863 
864  // Handle sticky button
865  if (mStickyButton &&
866  mSkin != nullptr &&
868  {
869  setSticky(!isSticky());
870  mouseResize = 0;
871  mMoved = false;
872  event.consume();
873  return;
874  }
875 
876  // Handle window resizing
878  if (mouseResize != 0)
879  event.consume();
880  if (canMove())
881  mMoved = (mouseResize == 0);
882  else
883  mMoved = false;
884  }
885 #ifndef DYECMD
886  else if (button == MouseButton::RIGHT)
887  {
888  if (popupMenu != nullptr)
889  {
890  event.consume();
891  popupMenu->showWindowPopup(this);
892  }
893  }
894 #endif // DYECMD
895 }
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:897
#define CAST_S32
Definition: cast.h:29
void setSticky(const bool sticky)
Definition: window.cpp:761
bool canMove() const
Definition: window.cpp:972
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:1301
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 902 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().

903 {
904  if ((mGrip != nullptr) && (mouseResize != 0))
905  {
906  mouseResize = 0;
907  if (gui != nullptr)
909  }
910 
911  mMoved = false;
912 }
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 1379 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(), 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(), StatusWindow::StatusWindow(), TextDialog::TextDialog(), TradeWindow::TradeWindow(), and WorldSelectDialog::WorldSelectDialog().

1381 {
1382  add(wg);
1383  return getLayout().place(wg, x, y, w, h);
1384 }
virtual void add(Widget *const widget)
Layout & getLayout()
Definition: window.cpp:1360
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, InventoryWindow, TextSelectDialog, ServerDialog, EquipmentWindow, SkillDialog, LoginDialog, ConfirmDialog, RegisterDialog, TextCommandEditor, WhoIsOnline, EditDialog, EditServerDialog, QuitDialog, TextDialog, SocialWindow, WorldSelectDialog, ConnectionDialog, ItemAmountWindow, DidYouKnowWindow, SetupWindow, DebugWindow, 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(), ConfirmDialog::postInit(), RegisterDialog::postInit(), LoginDialog::postInit(), SkillDialog::postInit(), EquipmentWindow::postInit(), ServerDialog::postInit(), TextSelectDialog::postInit(), InventoryWindow::postInit(), ShopWindow::postInit(), NpcDialog::postInit(), UpdaterWindow::postInit(), CharSelectDialog::postInit(), SellDialog::postInit(), ChatWindow::postInit(), and setSaveVisible().

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

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

Referenced by NpcDialog::buildLayout().

1402 {
1403  if (mLayout != nullptr)
1404  {
1405  const Rect area = getChildrenArea();
1406  int w = area.width;
1407  int h = area.height;
1408  mLayout->reflow(w, h);
1409  }
1410 }
int width
Definition: rect.h:218
Rect getChildrenArea()
Definition: window.cpp:1468
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 1391 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().

1392 {
1393  if (mLayout == nullptr)
1394  return;
1395 
1396  mLayout->reflow(w, h);
1397  delete2(mLayout);
1398  setContentSize(w, h);
1399 }
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 1254 of file window.cpp.

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

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

1255 {
1258  saveWindowState();
1259 }
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:1144

◆ resizeToContent()

void Window::resizeToContent ( )
virtual

Resizes the window to fit the content.

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

1477 {
1478  int w = 0;
1479  int h = 0;
1480  for (WidgetListConstIterator it = mWidgets.begin();
1481  it != mWidgets.end(); ++ it)
1482  {
1483  const Widget *const widget = *it;
1484  const int x = widget->getX();
1485  const int y = widget->getY();
1486  const int width = widget->getWidth();
1487  const int height = widget->getHeight();
1488  if (x + width > w)
1489  w = x + width;
1490 
1491  if (y + height > h)
1492  h = y + height;
1493  }
1494 
1495  setSize(w + 2 * mPadding,
1496  h + mPadding + mTitleBarHeight);
1497 }
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:428
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 1144 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().

1145 {
1146  // Saving X, Y and Width and Height for resizables in the config
1147  if (!mWindowName.empty() && mWindowName != "window")
1148  {
1149  config.setValue(mWindowName + "WinX", mDimension.x);
1150  config.setValue(mWindowName + "WinY", mDimension.y);
1151 
1152  if (mSaveVisible)
1153  config.setValue(mWindowName + "Visible", isWindowVisible());
1154 
1155  if (mStickyButton)
1156  config.setValue(mWindowName + "Sticky", isSticky());
1157 
1158  if (mGrip != nullptr)
1159  {
1160  if (getMinWidth() > mDimension.width)
1161  setWidth(getMinWidth());
1162  else if (getMaxWidth() < mDimension.width)
1163  setWidth(getMaxWidth());
1164  if (getMinHeight() > mDimension.height)
1166  else if (getMaxHeight() < mDimension.height)
1168 
1169  config.setValue(mWindowName + "WinWidth", mDimension.width);
1170  config.setValue(mWindowName + "WinHeight", mDimension.height);
1171  }
1172  }
1173 }
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 826 of file window.cpp.

References WindowContainer::scheduleDelete(), and windowContainer.

Referenced by MailViewWindow::action(), ConfirmDialog::action(), EditDialog::action(), QuitDialog::action(), EditServerDialog::action(), CharCreateDialog::action(), OkDialog::action(), ServerDialog::action(), ServerInfoWindow::close(), 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().

827 {
829 }
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(), ConfirmDialog::postInit(), LoginDialog::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 1175 of file window.cpp.

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

1177 {
1178  if (mMinWinWidth > defaultWidth)
1179  defaultWidth = mMinWinWidth;
1180  else if (mMaxWinWidth < defaultWidth)
1181  defaultWidth = mMaxWinWidth;
1182  if (mMinWinHeight > defaultHeight)
1183  defaultHeight = mMinWinHeight;
1184  else if (mMaxWinHeight < defaultHeight)
1185  defaultHeight = mMaxWinHeight;
1186 
1187  mDefaultX = defaultX;
1188  mDefaultY = defaultY;
1189  mDefaultWidth = defaultWidth;
1190  mDefaultHeight = defaultHeight;
1191 }
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 1193 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().

1194 {
1199 }
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 1201 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.

1204 {
1205  int x = 0;
1206  int y = 0;
1207 
1208  if (position == ImagePosition::UPPER_LEFT)
1209  {
1210  }
1211  else if (position == ImagePosition::UPPER_CENTER)
1212  {
1213  x = (mainGraphics->mWidth - defaultWidth) / 2;
1214  }
1215  else if (position == ImagePosition::UPPER_RIGHT)
1216  {
1217  x = mainGraphics->mWidth - defaultWidth;
1218  }
1219  else if (position == ImagePosition::LEFT)
1220  {
1221  y = (mainGraphics->mHeight - defaultHeight) / 2;
1222  }
1223  else if (position == ImagePosition::CENTER)
1224  {
1225  x = (mainGraphics->mWidth - defaultWidth) / 2;
1226  y = (mainGraphics->mHeight - defaultHeight) / 2;
1227  }
1228  else if (position == ImagePosition::RIGHT)
1229  {
1230  x = mainGraphics->mWidth - defaultWidth;
1231  y = (mainGraphics->mHeight - defaultHeight) / 2;
1232  }
1233  else if (position == ImagePosition::LOWER_LEFT)
1234  {
1235  y = mainGraphics->mHeight - defaultHeight;
1236  }
1237  else if (position == ImagePosition::LOWER_CENTER)
1238  {
1239  x = (mainGraphics->mWidth - defaultWidth) / 2;
1240  y = mainGraphics->mHeight - defaultHeight;
1241  }
1242  else if (position == ImagePosition::LOWER_RIGHT)
1243  {
1244  x = mainGraphics->mWidth - defaultWidth;
1245  y = mainGraphics->mHeight - defaultHeight;
1246  }
1247 
1248  mDefaultX = x - offsetX;
1249  mDefaultY = y - offsetY;
1250  mDefaultWidth = defaultWidth;
1251  mDefaultHeight = defaultHeight;
1252 }
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 525 of file window.cpp.

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

Referenced by centerHorisontally().

526 {
527  if (widget == nullptr)
528  return;
529 
530  int wx, wy;
531  int x, y;
532 
533  widget->getAbsolutePosition(wx, wy);
534  getAbsolutePosition(x, y);
535 
536  setPosition(mDimension.x + (wx + (widget->getWidth()
537  - mDimension.width) / 2 - x), 0);
538 }
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, wy;
514  int x, y;
515 
516  widget->getAbsolutePosition(wx, wy);
517  getAbsolutePosition(x, y);
518 
519  setPosition(mDimension.x + (wx + (widget->getWidth()
520  - mDimension.width) / 2 - x),
521  mDimension.y + (wy + (widget->getHeight()
522  - mDimension.height) / 2 - y));
523 }
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 540 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.

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

References mMaxWinHeight.

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

618 {
619  mMaxWinHeight = height;
620 }
int mMaxWinHeight
Definition: window.h:697

◆ setMaxWidth()

void Window::setMaxWidth ( const int  width)

Sets the maximum width of the window.

Definition at line 612 of file window.cpp.

References mMaxWinWidth.

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

613 {
614  mMaxWinWidth = width;
615 }
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 1064 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().

1065 {
1066  if (mModal != modal)
1067  {
1068  mModal = modal;
1069  if (mModal == Modal_true)
1070  {
1071  if (gui != nullptr)
1074  }
1075  else
1076  {
1078  }
1079  }
1080 }
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 622 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().

623 {
624  if ((mGrip != nullptr) == r)
625  return;
626 
627  if (mGrip != nullptr)
628  mGrip->decRef();
629  if (r)
630  {
631  mGrip = Theme::getImageFromThemeXml("resize.xml", "");
632  if (mGrip != nullptr)
633  {
636  - mGripPadding;
637  }
638  else
639  {
640  mGripRect.x = 0;
641  mGripRect.y = 0;
642  }
643  }
644  else
645  {
646  mGrip = nullptr;
647  }
648 }
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 761 of file window.cpp.

References Widget::mRedraw, and mSticky.

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

762 {
763  mSticky = sticky;
764  mRedraw = true;
765 }
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 756 of file window.cpp.

References mStickyButton.

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

757 {
758  mStickyButton = flag;
759 }
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 773 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(), ConfirmDialog::postInit(), LoginDialog::postInit(), ServerDialog::postInit(), UpdaterWindow::postInit(), CharSelectDialog::postInit(), EAthena::MailRecv::processMailOpen(), Ea::TradeRecv::processTradeCancel(), Ea::TradeRecv::processTradeResponseContinue(), HelpWindow::search(), QuestsWindow::selectQuest(), Minimap::setMap(), BuySellDialog::setVisible(), DidYouKnowWindow::setVisible(), TextSelectDialog::setVisible(), SetupWindow::setVisible(), ShopWindow::setVisible(), SellDialog::setVisible(), InventoryWindow::setVisible(), BuyDialog::setVisible(), ChatWindow::setVisible(), NpcDialog::setVisible(), EmoteWindow::show(), CutInWindow::show(), Actions::showHelpPage(), Actions::showHideWindow(), Minimap::toggle(), and Window().

774 {
775  setVisible(visible, false);
776 }
virtual void setVisible(Visible visible)
Definition: window.cpp:773

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

779 {
780  if (visible == mVisible)
781  return;
782 
783  // Check if the window is off screen...
784  if (visible == Visible_true)
785  ensureOnScreen();
786  else
787  mResizeHandles = 0;
788 
789  if (mStickyButtonLock)
790  {
792  }
793  else
794  {
795  BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
796  visible == Visible_true, Visible));
797  }
798  if (visible == Visible_true)
799  {
800  if (mPlayVisibleSound)
802  if (gui != nullptr)
803  {
804  MouseEvent *const event = reinterpret_cast<MouseEvent*>(
805  gui->createMouseEvent(this));
806  if (event != nullptr)
807  {
808  const int x = event->getX();
809  const int y = event->getY();
810  if (x >= 0 && x <= mDimension.width
811  && y >= 0 && y <= mDimension.height)
812  {
813  mouseMoved(*event);
814  }
815  delete event;
816  }
817  }
818  }
819  else
820  {
821  if (mPlayVisibleSound)
823  }
824 }
MouseEvent * createMouseEvent(Window *const widget)
Definition: gui.cpp:984
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:962
Visible mVisible
Definition: widget.h:962
void ensureOnScreen()
Definition: window.cpp:1422
#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 925 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().

926 {
927  if (gui == nullptr)
928  return;
929 
930 #ifndef DYECMD
931  if (!dragDrop.isEmpty())
932  return;
933 #endif // DYECMD
934 
936 
937  // Changes the custom mouse cursor based on it's current position.
938  switch (mResizeHandles & resizeMask)
939  {
940  case BOTTOM | RIGHT:
941  case TOP | LEFT:
943  break;
944  case TOP | RIGHT:
945  case BOTTOM | LEFT:
947  break;
948  case BOTTOM:
949  case TOP:
951  break;
952  case RIGHT:
953  case LEFT:
955  break;
956  default:
958  break;
959  }
960 }
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:1301
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 720 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().

721 {
723  mVertexes->clear();
724 
726 
727  mTextChanged = true;
728  mRedraw = true;
729 
730  if (gui != nullptr)
732 
733  if (mFocusHandler == nullptr)
734  return;
735 
736  for (WidgetListConstIterator it = mWidgets.begin();
737  it != mWidgets.end(); ++ it)
738  {
739  if (mFocusHandler->isFocused(*it))
741  }
742 }
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 715 of file window.cpp.

References Widget::mRedraw.

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

716 {
717  mRedraw = true;
718 }
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 650 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().

651 {
652  if (mGrip != nullptr)
653  {
656  }
657 
658  if (mLayout != nullptr)
659  {
660  const Rect area = getChildrenArea();
661  int w = area.width;
662  int h = area.height;
663  mLayout->reflow(w, h);
664  }
665  if (mSkin != nullptr)
666  {
667  const bool showClose = mCloseWindowButton
668  && (mSkin->getCloseImage(false) != nullptr);
669  if (showClose)
670  {
671  const Image *const button = mSkin->getCloseImage(false);
672  if (button != nullptr)
673  {
674  const int buttonWidth = button->getWidth();
675  mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
678  mCloseRect.height = button->getHeight();
679  }
680  }
681  if (mStickyButton)
682  {
683  const Image *const button = mSkin->getStickyImage(mSticky);
684  if (button != nullptr)
685  {
686  const int buttonWidth = button->getWidth();
687  int x = mDimension.width - buttonWidth
689 
690  if (showClose)
691  x -= mSkin->getCloseImage(false)->getWidth();
692 
693  mStickyRect.x = x;
696  mStickyRect.height = button->getHeight();
697  }
698  }
699  }
700  else
701  {
702  mCloseRect.x = 0;
703  mCloseRect.y = 0;
704  mCloseRect.width = 0;
705  mCloseRect.height = 0;
706  mStickyRect.x = 0;
707  mStickyRect.y = 0;
708  mStickyRect.width = 0;
709  mStickyRect.height = 0;
710  }
711 
712  mRedraw = true;
713 }
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:1468
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

Skin in use by this window

Definition at line 648 of file window.h.

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

◆ mSticky

bool Window::mSticky
private

Window resists hiding

Definition at line 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: