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 MiniStatusWindow Minimap 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 99 of file window.h.

Member Enumeration Documentation

◆ ResizeHandles

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

Definition at line 660 of file window.h.

661  {
662  TOP = 0x01,
663  RIGHT = 0x02,
664  BOTTOM = 0x04,
665  LEFT = 0x08,
666  CLOSE = 0x10
667  };
@ RIGHT
Definition: window.h:663
@ TOP
Definition: window.h:662
@ BOTTOM
Definition: window.h:664
@ LEFT
Definition: window.h:665
@ CLOSE
Definition: window.h: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 109 of file window.cpp.

112  :
113  BasicContainer2(nullptr),
114  MouseListener(),
115  WidgetListener(),
116  mCaption(caption),
118  mPadding(2),
119  mTitleBarHeight(16),
121  mDragOffsetX(0),
122  mDragOffsetY(0),
123  mMoved(false),
124  mSkin(nullptr),
125  mDefaultX(0),
126  mDefaultY(0),
127  mDefaultWidth(0),
128  mDefaultHeight(0),
129  mCaptionOffsetX(7),
130  mCaptionOffsetY(5),
131  mShowTitle(true),
132  mLastRedraw(true),
133  mGrip(nullptr),
134  mParentWindow(parent),
135  mLayout(nullptr),
136  mCloseRect(),
137  mStickyRect(),
138  mGripRect(),
139  mTextChunk(),
140  mWindowName("window"),
141  mMinWinWidth(100),
142  mMinWinHeight(40),
147  mTitlePadding(4),
148  mGripPadding(2),
149  mResizeHandles(-1),
150  mOldResizeHandles(-1),
151  mClosePadding(0),
152  mStickySpacing(0),
153  mStickyPadding(0),
155  mModal(modal),
156  mCloseWindowButton(false),
157  mDefaultVisible(false),
158  mSaveVisible(false),
159  mStickyButton(false),
160  mSticky(false),
161  mStickyButtonLock(false),
162  mPlayVisibleSound(false),
163  mInit(false),
164  mTextChanged(true),
165  mAllowClose(false)
166 {
167  logger->log("Window::Window(\"%s\")", caption.c_str());
168 
169  mWindow = this;
170 
171  windowInstances++;
172 
173 // mFrameSize = 1;
174  addMouseListener(this);
175 
176  setFrameSize(0);
177  setPadding(3);
178  setTitleBarHeight(20);
179 
180  if (skin.empty())
181  {
182  reportAlways("Default skin was used for window: %s",
183  caption.c_str())
184  skin = "window.xml";
185  }
186 
187  int childPalette = 1;
188  // Loads the skin
189  if (theme != nullptr)
190  {
191  mSkin = theme->load(skin,
192  "window.xml",
193  true,
195  if (mSkin != nullptr)
196  {
198  if (getOptionBool("titlebarBold", false))
201  mGripPadding = getOption("resizePadding", 0);
202  mCaptionOffsetX = getOption("captionoffsetx", 0);
203  if (mCaptionOffsetX == 0)
204  mCaptionOffsetX = 7;
205  mCaptionOffsetY = getOption("captionoffsety", 0);
206  if (mCaptionOffsetY == 0)
207  mCaptionOffsetY = 5;
208  mCaptionAlign = static_cast<Graphics::Alignment>(
209  getOption("captionalign", 0));
212  {
214  }
216  getOption("titlebarHeight", 0)));
217  if (mTitleBarHeight == 0U)
219 
220  mTitleBarHeight += getOption("titlebarHeightRelative", 0);
221  setPalette(getOption("palette", 0));
222  childPalette = getOption("childPalette", 0);
223  mShowTitle = getOptionBool("showTitle", true);
224  mClosePadding = getOption("closePadding", 0);
225  mStickySpacing = getOption("stickySpacing", 0);
226  mStickyPadding = getOption("stickyPadding", 0);
227  }
228  }
229 
230  // Add this window to the window container
231  if (windowContainer != nullptr)
232  windowContainer->add(this);
233 
234  if (mModal == Modal_true)
235  {
238  }
239 
240  // Windows are invisible by default
241  setVisible(Visible_false, false);
242 
243  addWidgetListener(this);
244  mForegroundColor = getThemeColor(ThemeColorId::WINDOW, 255U);
245  mForegroundColor2 = getThemeColor(ThemeColorId::WINDOW_OUTLINE, 255U);
246  setPalette(childPalette);
247 }
#define CAST_U32
Definition: cast.h:31
#define reportAlways(...)
Definition: checkutils.h:253
virtual void add(Widget *const widget)
BasicContainer2(const Widget2 *const widget)
int getHeight() const
Definition: font.cpp:362
int mWidth
Definition: graphics.h:484
int mHeight
Definition: graphics.h:485
@ CENTER
Definition: graphics.h:132
void setCursorType(const CursorT index)
Definition: gui.h:196
void log(const char *const log_text,...)
Definition: logger.cpp:269
int getTitlePadding() const
Definition: skin.h:103
int getPadding() const
Definition: skin.h:100
static std::string getThemePath()
Definition: theme.h:67
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:179
Widget * mWindow
Definition: widget2.h:112
void setPalette(int palette)
Definition: widget2.h:69
Color mForegroundColor2
Definition: widget2.h:113
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
Color mForegroundColor
Definition: widget.h:1086
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:168
void requestModalFocus()
Definition: widget.cpp:380
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:292
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:302
Font * getFont() const
Definition: widget.cpp:331
int mDragOffsetY
Definition: window.h:642
int mDefaultY
Definition: window.h:651
int mTitlePadding
Definition: window.h:712
Graphics::Alignment mAlignment
Definition: window.h:613
int mMinWinWidth
Definition: window.h:695
std::string mWindowName
Definition: window.h:694
int mCaptionOffsetY
Definition: window.h:655
int mDefaultHeight
Definition: window.h:653
bool mStickyButtonLock
Definition: window.h:726
bool mLastRedraw
Definition: window.h:657
virtual void setVisible(Visible visible)
Definition: window.cpp:778
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1466
Skin * mSkin
Definition: window.h:649
bool mShowTitle
Definition: window.h:656
bool mPlayVisibleSound
Definition: window.h:727
ImageCollection * mVertexes
Definition: window.h:710
static int windowInstances
Definition: window.h:701
int getOption(const std::string &name, const int def) const
Definition: window.cpp:1454
bool mMoved
Definition: window.h:647
TextChunk mTextChunk
Definition: window.h:693
Rect mCloseRect
Definition: window.h:690
int mDragOffsetX
Definition: window.h:635
unsigned int mTitleBarHeight
Definition: window.h:623
int mMinWinHeight
Definition: window.h:696
Window * mParentWindow
Definition: window.h:688
bool mDefaultVisible
Definition: window.h:722
int mStickyPadding
Definition: window.h:718
int mDefaultWidth
Definition: window.h:652
int mOldResizeHandles
Definition: window.h:715
bool mSaveVisible
Definition: window.h:723
Layout * mLayout
Definition: window.h:689
bool mCloseWindowButton
Definition: window.h:721
Rect mGripRect
Definition: window.h:692
Graphics::Alignment mCaptionAlign
Definition: window.h:711
int mGripPadding
Definition: window.h:713
int mMaxWinHeight
Definition: window.h:698
bool mSticky
Definition: window.h:725
Image * mGrip
Definition: window.h:687
int mResizeHandles
Definition: window.h:714
Move mMovable
Definition: window.h:628
Rect mStickyRect
Definition: window.h:691
void setPadding(int padding)
Definition: window.h:494
int mPadding
Definition: window.h:618
bool mTextChanged
Definition: window.h:729
bool mAllowClose
Definition: window.h:730
int mMaxWinWidth
Definition: window.h:697
bool mInit
Definition: window.h:728
std::string mCaption
Definition: window.h:608
int mDefaultX
Definition: window.h:650
int mStickySpacing
Definition: window.h:717
bool mStickyButton
Definition: window.h:724
Modal mModal
Definition: window.h:720
void setTitleBarHeight(unsigned int height)
Definition: window.h:513
int mClosePadding
Definition: window.h:716
Font * mCaptionFont
Definition: window.h:719
int mCaptionOffsetX
Definition: window.h:654
const bool Move_true
Definition: move.h:30
Graphics * mainGraphics
Definition: graphics.cpp:109
if(!vert) return
Gui * gui
Definition: gui.cpp:111
Font * boldFont
Definition: gui.cpp:112
Logger * logger
Definition: logger.cpp:89
const bool Modal_true
Definition: modal.h:30
@ CURSOR_POINTER
Definition: cursor.h:29
Theme * theme
Definition: theme.cpp:62
const bool Visible_false
Definition: visible.h:30
WindowContainer * windowContainer

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, windowContainer, and windowInstances.

◆ ~Window()

Window::~Window ( )

Destructor. Deletes all the added widgets.

Definition at line 260 of file window.cpp.

261 {
262  logger->log("Window::~Window(\"%s\")", getCaption().c_str());
263 
264  if (gui != nullptr)
265  gui->removeDragged(this);
266 
267 #ifndef DYECMD
268  if (setupWindow != nullptr)
270 #endif // DYECMD
271 
272  client->windowRemoved(this);
273 
274  saveWindowState();
275 
277 
278  while (!mWidgets.empty())
279  delete mWidgets.front();
280 
281  mWidgets.clear();
282 
283  removeWidgetListener(this);
285 
286  windowInstances--;
287 
288  if (mSkin != nullptr)
289  {
290  if (theme != nullptr)
291  theme->unload(mSkin);
292  mSkin = nullptr;
293  }
294  if (mGrip != nullptr)
295  {
296  mGrip->decRef();
297  mGrip = nullptr;
298  }
299  if (!mInit)
300  {
301  reportAlways("error: Window created without calling postInit(): %s",
302  mWindowName.c_str())
303  }
304 }
WidgetList mWidgets
void windowRemoved(const Window *const window)
Definition: client.cpp:803
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1162
void unregisterWindowForReset(const Window *const window)
void unload(Skin *const skin)
Definition: theme.cpp:250
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:307
const std::string & getCaption() const
Definition: window.h:540
void saveWindowState()
Definition: window.cpp:1149
#define delete2(var)
Definition: delete2.h:25
Client * client
Definition: client.cpp:118
SetupWindow * setupWindow
Definition: setupwindow.cpp:64

References client, 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().

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

1268 {
1269  // If window was aligned to the right or bottom, keep it there
1270  const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
1271  const int bottomMargin = oldScreenHeight
1272  - (mDimension.y + mDimension.height);
1273  if (mDimension.x > 0 && mDimension.x > rightMargin)
1274  mDimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
1275  if (mDimension.y > 0 && mDimension.y > bottomMargin)
1276  {
1278  - bottomMargin - mDimension.height;
1279  }
1280 
1281  ensureOnScreen();
1283 }
int y
Definition: rect.h:214
int width
Definition: rect.h:219
int x
Definition: rect.h:209
int height
Definition: rect.h:224
Rect mDimension
Definition: widget.h:1101
void adjustSizeToScreen()
Definition: window.cpp:1285
void ensureOnScreen()
Definition: window.cpp:1427

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

◆ adjustSizeToScreen()

void Window::adjustSizeToScreen ( )
private

Definition at line 1285 of file window.cpp.

1286 {
1287  if (mGrip == nullptr)
1288  return;
1289 
1290  const int screenWidth = mainGraphics->mWidth;
1291  const int screenHeight = mainGraphics->mHeight;
1292  const int oldWidth = mDimension.width;
1293  const int oldHeight = mDimension.height;
1294  if (oldWidth + mDimension.x > screenWidth)
1295  mDimension.x = 0;
1296  if (oldHeight + mDimension.y > screenHeight)
1297  mDimension.x = 0;
1298  if (mDimension.width > screenWidth)
1299  mDimension.width = screenWidth;
1300  if (mDimension.height > screenHeight)
1301  mDimension.height = screenHeight;
1302  if (oldWidth != mDimension.width || oldHeight != mDimension.height)
1303  widgetResized(Event(this));
1304 }
Definition: event.h:79
void widgetResized(const Event &event)
Definition: window.cpp:655

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

Referenced by adjustPositionAfterResize().

◆ canMove()

bool Window::canMove ( ) const
protected

Definition at line 977 of file window.cpp.

978 {
979  return !mStickyButtonLock || !mSticky;
980 }

References mSticky, and mStickyButtonLock.

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

◆ center()

void Window::center ( )

◆ centerHorisontally()

void Window::centerHorisontally ( )

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

Definition at line 1422 of file window.cpp.

1423 {
1425 }
void setLocationHorisontallyRelativeTo(const Widget *const widget)
Definition: window.cpp:528

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

Referenced by OkDialog::OkDialog().

◆ clearLayout()

void Window::clearLayout ( )

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

Definition at line 1372 of file window.cpp.

1373 {
1374  clear();
1375 
1376  // Recreate layout instance when one is present
1377  if (mLayout != nullptr)
1378  {
1379  delete mLayout;
1380  mLayout = new Layout;
1381  }
1382 }
virtual void clear()
Definition: layout.h:45

References BasicContainer::clear(), and mLayout.

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

◆ close()

void Window::close ( )
virtual

◆ draw()

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

Draws the window.

Reimplemented from BasicContainer2.

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

Definition at line 311 of file window.cpp.

312 {
313  if (mSkin == nullptr)
314  return;
315 
316  BLOCK_START("Window::draw")
317  bool update = false;
318 
320  {
321  mRedraw = true;
323  }
324  if (mRedraw)
325  {
326  mLastRedraw = true;
327  mRedraw = false;
328  update = true;
329  mVertexes->clear();
330  graphics->calcWindow(mVertexes,
331  0, 0,
334  mSkin->getBorder());
335 
336  // Draw Close Button
337  if (mCloseWindowButton)
338  {
339  const Image *const button = mSkin->getCloseImage(
340  mResizeHandles == CLOSE);
341  if (button != nullptr)
342  {
343  graphics->calcTileCollection(mVertexes,
344  button,
345  mCloseRect.x,
346  mCloseRect.y);
347  }
348  }
349  // Draw Sticky Button
350  if (mStickyButton)
351  {
352  const Image *const button = mSkin->getStickyImage(mSticky);
353  if (button != nullptr)
354  {
355  graphics->calcTileCollection(mVertexes,
356  button,
357  mStickyRect.x,
358  mStickyRect.y);
359  }
360  }
361 
362  if (mGrip != nullptr)
363  {
364  graphics->calcTileCollection(mVertexes,
365  mGrip,
366  mGripRect.x,
367  mGripRect.y);
368  }
369  graphics->finalize(mVertexes);
370  }
371  else
372  {
373  mLastRedraw = false;
374  }
375  graphics->drawTileCollection(mVertexes);
376 
377  // Draw title
378  if (mShowTitle)
379  {
380  int x;
381  switch (mCaptionAlign)
382  {
383  case Graphics::LEFT:
384  default:
385  x = mCaptionOffsetX;
386  break;
387  case Graphics::CENTER:
389  break;
390  case Graphics::RIGHT:
392  break;
393  }
394  if (mTextChanged)
395  {
402  mTextChanged = false;
403  }
404 
405  const Image *const image = mTextChunk.img;
406  if (image != nullptr)
407  graphics->drawImage(image, x, mCaptionOffsetY);
408  }
409 
410  if (update)
411  {
412  graphics->setRedraw(update);
413  drawChildren(graphics);
414  graphics->setRedraw(false);
415  }
416  else
417  {
418  drawChildren(graphics);
419  }
420  BLOCK_END("Window::draw")
421 }
virtual void drawChildren(Graphics *const graphics)
void generate(TextChunk &chunk)
Definition: font.cpp:430
int getWidth(const std::string &text) const
Definition: font.cpp:334
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:465
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
void setRedraw(const bool n)
Definition: graphics.h:284
const ImageRect & getBorder() const
Definition: skin.h:68
const Image * getCloseImage(const bool state) const
Definition: skin.h:74
const Image * getStickyImage(const bool state) const
Definition: skin.h:81
void deleteImage()
Definition: textchunk.cpp:193
Font * textFont
Definition: textchunk.h:64
Image * img
Definition: textchunk.h:63
Color color
Definition: textchunk.h:66
Color color2
Definition: textchunk.h:67
std::string text
Definition: textchunk.h:65
bool mRedraw
Definition: widget.h:1164
void update()
Definition: useragent.cpp:32
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

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, Rect::x, x, and Rect::y.

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

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

1428 {
1429  // Skip when a window hasn't got any size initialized yet
1430  if (mDimension.width == 0 && mDimension.height == 0)
1431  return;
1432 
1433  // Check the left and bottom screen boundaries
1438 
1439  // But never allow the windows to disappear in to the right and top
1440  if (mDimension.x < 0)
1441  mDimension.x = 0;
1442  if (mDimension.y < 0)
1443  mDimension.y = 0;
1444 }

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

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

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

559  { return mAlignment; }

References mAlignment.

◆ getAlowClose()

bool Window::getAlowClose ( ) const
inline

Definition at line 192 of file window.h.

193  { return mCloseWindowButton || mAllowClose; }

References mAllowClose, and mCloseWindowButton.

Referenced by PopupMenu::addWindowMenu().

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

541  { return mCaption; }

References mCaption.

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

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

1474 {
1475  return Rect(mPadding,
1477  mDimension.width - mPadding * 2,
1479 }
Definition: rect.h:74

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

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

◆ getCloseButton()

bool Window::getCloseButton ( ) const
inline

Definition at line 186 of file window.h.

187  { return mCloseWindowButton; }

References mCloseWindowButton.

◆ getLayout()

Layout & Window::getLayout ( )

◆ getMaxHeight()

int Window::getMaxHeight ( ) const
inline

Definition at line 229 of file window.h.

230  { return mMaxWinHeight; }

References mMaxWinHeight.

Referenced by loadWindowState(), and saveWindowState().

◆ getMaxWidth()

int Window::getMaxWidth ( ) const
inline

Definition at line 221 of file window.h.

222  { return mMaxWinWidth; }

References mMaxWinWidth.

Referenced by loadWindowState(), and saveWindowState().

◆ getMinHeight()

int Window::getMinHeight ( ) const
inline

Definition at line 213 of file window.h.

214  { return mMinWinHeight; }

References mMinWinHeight.

Referenced by loadWindowState(), and saveWindowState().

◆ getMinWidth()

int Window::getMinWidth ( ) const
inline

Definition at line 205 of file window.h.

206  { return mMinWinWidth; }

References mMinWinWidth.

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

◆ getOption()

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

Definition at line 1454 of file window.cpp.

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

References Skin::getOption(), and mSkin.

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

◆ getOptionBool()

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

Definition at line 1466 of file window.cpp.

1467 {
1468  if (mSkin != nullptr)
1469  return mSkin->getOption(name, static_cast<int>(def)) != 0;
1470  return def;
1471 }

References Skin::getOption(), and mSkin.

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

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

505  { return mPadding; }

References mPadding.

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

◆ getParentWindow()

Window* Window::getParentWindow ( ) const
inline

Returns the parent window.

Returns
The parent window or NULL if there is none.

Definition at line 310 of file window.h.

311  { return mParentWindow; }

References mParentWindow.

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

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

1307 {
1308  if (event.getX() < 0 || event.getY() < 0)
1309  return 0;
1310 
1311  int resizeHandles = 0;
1312  const unsigned y = event.getY();
1313  const unsigned x = event.getX();
1314  if (mCloseRect.isPointInRect(x, y))
1315  return CLOSE;
1316 
1317  if (!mStickyButtonLock || !mSticky)
1318  {
1319  if ((mGrip != nullptr) &&
1320  (y > mTitleBarHeight ||
1321  (CAST_S32(y) < mPadding &&
1323  {
1324  if (!getWindowArea().isPointInRect(x, y)
1325  && event.getSource() == this)
1326  {
1327  resizeHandles |= (x > mDimension.width - resizeBorderWidth)
1328  ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
1329  resizeHandles |= (y > mDimension.height - resizeBorderWidth)
1330  ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
1331  }
1332  if (x >= CAST_U32(mGripRect.x)
1333  && y >= CAST_U32(mGripRect.y))
1334  {
1335  mDragOffsetX = x;
1336  mDragOffsetY = y;
1337  resizeHandles |= BOTTOM | RIGHT;
1338  }
1339  }
1340  }
1341 
1342  return resizeHandles;
1343 }
#define CAST_S32
Definition: cast.h:30
Widget * getSource() const
Definition: event.h:104
int getX() const
Definition: mouseevent.h:127
int getY() const
Definition: mouseevent.h:138
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:197
Rect getWindowArea() const
Definition: window.cpp:1446
static const unsigned resizeBorderWidth
Definition: window.h:709

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

Referenced by mousePressed(), and updateResizeHandler().

◆ getTitleBarHeight()

unsigned int Window::getTitleBarHeight ( ) const
inline

Gets the title bar height.

Returns
The title bar height.
See also
setTitleBarHeight

Definition at line 522 of file window.h.

523  { return mTitleBarHeight; }

References mTitleBarHeight.

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

◆ getTitlePadding()

int Window::getTitlePadding ( ) const
inlineprotected

◆ getWindowArea()

Rect Window::getWindowArea ( ) const

Definition at line 1446 of file window.cpp.

1447 {
1448  return Rect(mPadding,
1449  mPadding,
1450  mDimension.width - mPadding * 2,
1451  mDimension.height - mPadding * 2);
1452 }

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

Referenced by getResizeHandles(), and isResizeAllowed().

◆ getWindowName()

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

Returns the name of the window. This is not the window title.

Definition at line 361 of file window.h.

362  { return mWindowName; }

References mWindowName.

Referenced by CharCreateDialog::CharCreateDialog(), InventoryWindow::InventoryWindow(), Minimap::Minimap(), and Minimap::~Minimap().

◆ isDefaultVisible()

bool Window::isDefaultVisible ( ) const
inline

Returns whether the window is visible by default.

Definition at line 282 of file window.h.

283  { return mDefaultVisible; }

References mDefaultVisible.

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

577  { return mMovable == Move_true; }

References mMovable, and Move_true.

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

◆ isResizable()

bool Window::isResizable ( ) const

Returns whether the window can be resized.

Definition at line 756 of file window.cpp.

757 {
758  return mGrip != nullptr;
759 }

References mGrip.

◆ isResizeAllowed()

bool Window::isResizeAllowed ( const MouseEvent event) const

Definition at line 1345 of file window.cpp.

1346 {
1347  const int y = event.getY();
1348 
1349  if ((mGrip != nullptr) &&
1350  (y > CAST_S32(mTitleBarHeight) ||
1351  y < mPadding))
1352  {
1353  const int x = event.getX();
1354 
1355  if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
1356  return true;
1357 
1358  if (x >= mGripRect.x && y >= mGripRect.y)
1359  return true;
1360  }
1361 
1362  return false;
1363 }

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

Referenced by ChatWindow::mousePressed().

◆ isSticky()

bool Window::isSticky ( ) const
inline

Returns whether the window is sticky.

Definition at line 253 of file window.h.

254  { return mSticky; }

References mSticky.

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

◆ isStickyButtonLock()

bool Window::isStickyButtonLock ( ) const
inline

Returns whether the window sticky locking window.

Definition at line 264 of file window.h.

265  { return mStickyButtonLock; }

References mStickyButtonLock.

Referenced by PopupMenu::addWindowMenu().

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

1088 {
1089  const std::string &name = mWindowName;
1090  if (name.empty())
1091  return;
1092 
1093  setPosition(config.getValueInt(name + "WinX", mDefaultX),
1094  config.getValueInt(name + "WinY", mDefaultY));
1095 
1096  if (mSaveVisible)
1097  {
1099  + "Visible", mDefaultVisible), Visible));
1100  }
1101 
1102  if (mStickyButton)
1103  {
1105  + "Sticky", isSticky()));
1106  }
1107 
1108  if (mGrip != nullptr)
1109  {
1110  int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
1111  int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
1112 
1113  if (getMinWidth() > width)
1114  width = getMinWidth();
1115  else if (getMaxWidth() < width)
1116  width = getMaxWidth();
1117  if (getMinHeight() > height)
1118  height = getMinHeight();
1119  else if (getMaxHeight() < height)
1120  height = getMaxHeight();
1121 
1122  setSize(width, height);
1123  }
1124  else
1125  {
1127  }
1128 
1129  // Check if the window is off screen...
1130  ensureOnScreen();
1131 
1132  if (viewport != nullptr)
1133  {
1134  int width = mDimension.width;
1135  int height = mDimension.height;
1136 
1137  if (mDimension.x + width > viewport->getWidth())
1138  width = viewport->getWidth() - mDimension.x;
1139  if (mDimension.y + height > viewport->getHeight())
1140  height = viewport->getHeight() - mDimension.y;
1141  if (width < 0)
1142  width = 0;
1143  if (height < 0)
1144  height = 0;
1145  setSize(width, height);
1146  }
1147 }
#define fromBool(val, name)
Definition: booldefines.h:49
int getValueInt(const std::string &key, const int deflt) const
bool getValueBool(const std::string &key, const bool deflt) const
void setSize(const int width, const int height)
Definition: widget.cpp:367
void setPosition(const int x, const int y)
Definition: widget.cpp:161
int getHeight() const
Definition: widget.h:240
int getWidth() const
Definition: widget.h:221
bool isSticky() const
Definition: window.h:253
void setSticky(const bool sticky)
Definition: window.cpp:766
int getMinWidth() const
Definition: window.h:205
int getMaxWidth() const
Definition: window.h:221
int getMaxHeight() const
Definition: window.h:229
int getMinHeight() const
Definition: window.h:213
Configuration config
Viewport * viewport
Definition: viewport.cpp:36
bool Visible
Definition: visible.h:30

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(), HelpWindow::HelpWindow(), BuyDialog::init(), BuySellDialog::init(), InventoryWindow::InventoryWindow(), KillStats::KillStats(), MailEditWindow::MailEditWindow(), MailViewWindow::MailViewWindow(), MailWindow::MailWindow(), Minimap::Minimap(), NpcDialog::NpcDialog(), OutfitWindow::OutfitWindow(), SellDialog::postInit(), LoginDialog::postInit(), SkillDialog::postInit(), SocialWindow::postInit(), TextSelectDialog::postInit(), WhoIsOnline::postInit(), QuestsWindow::QuestsWindow(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), ShopWindow::ShopWindow(), ShortcutWindow::ShortcutWindow(), StatusWindow::StatusWindow(), TradeWindow::TradeWindow(), and UpdaterWindow::UpdaterWindow().

◆ 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 ShortcutWindow, OutfitWindow, and ChatWindow.

Definition at line 982 of file window.cpp.

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

References BOTTOM, canMove(), Widget::getDimension(), Widget::getHeight(), Event::getSource(), MouseEvent::getX(), Widget::getX(), MouseEvent::getY(), 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 ChatWindow::mouseDragged(), OutfitWindow::mouseDragged(), and ShortcutWindow::mouseDragged().

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

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

References updateResizeHandler().

Referenced by ChatWindow::mouseEntered().

◆ 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 MiniStatusWindow, Minimap, ItemAmountWindow, InventoryWindow, EquipmentWindow, and ChatWindow.

Definition at line 924 of file window.cpp.

925 {
926  if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
928 }

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

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

◆ mouseMoved()

void Window::mouseMoved ( MouseEvent event)
virtual

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

Reimplemented from MouseListener.

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

Definition at line 967 of file window.cpp.

968 {
969  updateResizeHandler(event);
970  if ((popupManager != nullptr) && !event.isConsumed())
971  {
974  }
975 }
static void hideTextPopup()
static void hideBeingPopup()
PopupManager * popupManager

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

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

◆ mousePressed()

void Window::mousePressed ( MouseEvent event)
virtual

Starts window resizing when appropriate.

Reimplemented from MouseListener.

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

Definition at line 836 of file window.cpp.

837 {
838  if (event.isConsumed())
839  return;
840 
841  if (event.getSource() == this)
842  {
843  if (getParent() != nullptr)
844  getParent()->moveToTop(this);
845 
846  mDragOffsetX = event.getX();
847  mDragOffsetY = event.getY();
848  mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
849  }
850 
851  const MouseButtonT button = event.getButton();
852  if (button == MouseButton::LEFT)
853  {
854  const int x = event.getX();
855  const int y = event.getY();
856 
857  // Handle close button
858  if (mCloseWindowButton &&
859  mSkin != nullptr &&
861  {
862  mouseResize = 0;
863  mMoved = false;
864  event.consume();
865  close();
866  return;
867  }
868 
869  // Handle sticky button
870  if (mStickyButton &&
871  mSkin != nullptr &&
873  {
874  setSticky(!isSticky());
875  mouseResize = 0;
876  mMoved = false;
877  event.consume();
878  return;
879  }
880 
881  // Handle window resizing
883  if (mouseResize != 0)
884  event.consume();
885  if (canMove())
886  mMoved = (mouseResize == 0);
887  else
888  mMoved = false;
889  }
890 #ifndef DYECMD
891  else if (button == MouseButton::RIGHT)
892  {
893  if (popupMenu != nullptr)
894  {
895  event.consume();
896  popupMenu->showWindowPopup(this);
897  }
898  }
899 #endif // DYECMD
900 }
void showWindowPopup(Window *const window)
Definition: popupmenu.cpp:1164
virtual void moveToTop(Widget *widget)
Definition: widget.h:867
virtual void close()
Definition: window.cpp:902
int getResizeHandles(const MouseEvent &event)
Definition: window.cpp:1306
MouseButton ::T MouseButtonT
Definition: mousebutton.h:78
PopupMenu * popupMenu
Definition: popupmenu.cpp:103
const int resizeMask
Definition: window.cpp:104

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 ChatWindow::mousePressed(), EquipmentWindow::mousePressed(), Minimap::mousePressed(), NpcDialog::mousePressed(), OutfitWindow::mousePressed(), and ShortcutWindow::mousePressed().

◆ 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 OutfitWindow, Minimap, and EquipmentWindow.

Definition at line 907 of file window.cpp.

908 {
909  if ((mGrip != nullptr) && (mouseResize != 0))
910  {
911  mouseResize = 0;
912  if (gui != nullptr)
914  }
915 
916  mMoved = false;
917 }

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

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

◆ place()

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

◆ postInit()

void Window::postInit ( )
virtual

Reimplemented from Widget.

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

Definition at line 249 of file window.cpp.

250 {
251  if (mInit)
252  {
253  reportAlways("error: Window created with calling postInit() "
254  "more than once: %s",
255  mWindowName.c_str())
256  }
257  mInit = true;
258 }

References mInit, mWindowName, and reportAlways.

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

◆ redraw()

void Window::redraw ( )

Definition at line 1406 of file window.cpp.

1407 {
1408  if (mLayout != nullptr)
1409  {
1410  const Rect area = getChildrenArea();
1411  int w = area.width;
1412  int h = area.height;
1413  mLayout->reflow(w, h);
1414  }
1415 }
void reflow(int &nW, int &nH)
Definition: layout.cpp:36
Rect getChildrenArea()
Definition: window.cpp:1473

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

Referenced by NpcDialog::buildLayout().

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

1397 {
1398  if (mLayout == nullptr)
1399  return;
1400 
1401  mLayout->reflow(w, h);
1402  delete2(mLayout)
1403  setContentSize(w, h);
1404 }
void setContentSize(int width, int height)
Definition: window.cpp:492

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

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

◆ resetToDefaultSize()

void Window::resetToDefaultSize ( )
virtual

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

Definition at line 1259 of file window.cpp.

1260 {
1263  saveWindowState();
1264 }

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

Referenced by Minimap::setMap().

◆ resizeToContent()

void Window::resizeToContent ( )
virtual

Resizes the window to fit the content.

Definition at line 1481 of file window.cpp.

1482 {
1483  int w = 0;
1484  int h = 0;
1485  for (WidgetListConstIterator it = mWidgets.begin();
1486  it != mWidgets.end(); ++ it)
1487  {
1488  const Widget *const widget = *it;
1489  const int x = widget->getX();
1490  const int y = widget->getY();
1491  const int width = widget->getWidth();
1492  const int height = widget->getHeight();
1493  if (x + width > w)
1494  w = x + width;
1495 
1496  if (y + height > h)
1497  h = y + height;
1498  }
1499 
1500  setSize(w + 2 * mPadding,
1501  h + mPadding + mTitleBarHeight);
1502 }
WidgetList::const_iterator WidgetListConstIterator
Definition: widget.h:99

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

◆ safeDraw()

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

Reimplemented from BasicContainer2.

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

Definition at line 423 of file window.cpp.

424 {
425  if (mSkin == nullptr)
426  return;
427 
428  BLOCK_START("Window::safeDraw")
429 
430  graphics->drawImageRect(0, 0,
431  mDimension.width,
432  mDimension.height,
433  mSkin->getBorder());
434 
435  // Draw Close Button
437  {
438  const Image *const button = mSkin->getCloseImage(
439  mResizeHandles == CLOSE);
440  if (button != nullptr)
441  graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
442  }
443  // Draw Sticky Button
444  if (mStickyButton)
445  {
446  const Image *const button = mSkin->getStickyImage(mSticky);
447  if (button != nullptr)
448  graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
449  }
450 
451  if (mGrip != nullptr)
452  graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
453 
454  // Draw title
455  if (mShowTitle)
456  {
457  int x;
458  switch (mCaptionAlign)
459  {
460  case Graphics::LEFT:
461  default:
462  x = mCaptionOffsetX;
463  break;
464  case Graphics::CENTER:
466  break;
467  case Graphics::RIGHT:
469  break;
470  }
471  if (mTextChanged)
472  {
479  mTextChanged = false;
480  }
481 
482  const Image *const image = mTextChunk.img;
483  if (image != nullptr)
484  graphics->drawImage(image, x, mCaptionOffsetY);
485  }
486 
487  safeDrawChildren(graphics);
488 
489  BLOCK_END("Window::safeDraw")
490 }
virtual void safeDrawChildren(Graphics *const graphics)
void drawImageRect(int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 override final

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, Rect::x, x, and Rect::y.

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

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

1150 {
1151  // Saving X, Y and Width and Height for resizables in the config
1152  if (!mWindowName.empty() && mWindowName != "window")
1153  {
1154  config.setValue(mWindowName + "WinX", mDimension.x);
1155  config.setValue(mWindowName + "WinY", mDimension.y);
1156 
1157  if (mSaveVisible)
1158  config.setValue(mWindowName + "Visible", isWindowVisible());
1159 
1160  if (mStickyButton)
1161  config.setValue(mWindowName + "Sticky", isSticky());
1162 
1163  if (mGrip != nullptr)
1164  {
1165  if (getMinWidth() > mDimension.width)
1166  setWidth(getMinWidth());
1167  else if (getMaxWidth() < mDimension.width)
1168  setWidth(getMaxWidth());
1169  if (getMinHeight() > mDimension.height)
1171  else if (getMaxHeight() < mDimension.height)
1173 
1174  config.setValue(mWindowName + "WinWidth", mDimension.width);
1175  config.setValue(mWindowName + "WinHeight", mDimension.height);
1176  }
1177  }
1178 }
void setValue(const std::string &key, const std::string &value)
void setWidth(const int width)
Definition: widget.cpp:133
void setHeight(const int height)
Definition: widget.cpp:140
bool isWindowVisible() const
Definition: window.h:484

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 resetToDefaultSize(), and ~Window().

◆ scheduleDelete()

void Window::scheduleDelete ( )
virtual

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

Reimplemented in TextCommandEditor, and ChatWindow.

Definition at line 831 of file window.cpp.

832 {
834 }
void scheduleDelete(Widget *const widget)

References WindowContainer::scheduleDelete(), and windowContainer.

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

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

550  { mAlignment = alignment; }

References mAlignment.

◆ setAllowClose()

void Window::setAllowClose ( const bool  b)
inline

Definition at line 189 of file window.h.

190  { mAllowClose = b; }

References mAllowClose.

Referenced by ShortcutWindow::ShortcutWindow().

◆ setCaption()

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

◆ setCaptionFont()

void Window::setCaptionFont ( Font font)
inline

Definition at line 478 of file window.h.

479  { mCaptionFont = font; }

References mCaptionFont.

Referenced by TradeWindow::initTrade().

◆ setCloseButton()

void Window::setCloseButton ( const bool  flag)

◆ setContentSize()

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

◆ setDefaultSize() [1/3]

void Window::setDefaultSize ( )

◆ setDefaultSize() [2/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 1206 of file window.cpp.

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

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.

◆ setDefaultSize() [3/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 1180 of file window.cpp.

1182 {
1183  if (mMinWinWidth > defaultWidth)
1184  defaultWidth = mMinWinWidth;
1185  else if (mMaxWinWidth < defaultWidth)
1186  defaultWidth = mMaxWinWidth;
1187  if (mMinWinHeight > defaultHeight)
1188  defaultHeight = mMinWinHeight;
1189  else if (mMaxWinHeight < defaultHeight)
1190  defaultHeight = mMaxWinHeight;
1191 
1192  mDefaultX = defaultX;
1193  mDefaultY = defaultY;
1194  mDefaultWidth = defaultWidth;
1195  mDefaultHeight = defaultHeight;
1196 }

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

◆ setDefaultVisible()

void Window::setDefaultVisible ( const bool  save)
inline

Sets whether the window is visible by default.

Definition at line 288 of file window.h.

289  { mDefaultVisible = save; }

References mDefaultVisible.

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

529 {
530  if (widget == nullptr)
531  return;
532 
533  int wx;
534  int wy;
535  int x;
536  int y;
537 
538  widget->getAbsolutePosition(wx, wy);
540 
541  setPosition(mDimension.x + (wx + (widget->getWidth()
542  - mDimension.width) / 2 - x), 0);
543 }
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:312

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

Referenced by centerHorisontally().

◆ setLocationRelativeTo() [1/2]

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

Sets the location relative to the given enumerated position.

Definition at line 545 of file window.cpp.

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

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.

◆ setLocationRelativeTo() [2/2]

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

Sets the location relative to the given widget.

Definition at line 509 of file window.cpp.

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

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

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

◆ setMaxHeight()

void Window::setMaxHeight ( const int  height)

Sets the minimum height of the window.

Definition at line 622 of file window.cpp.

623 {
624  mMaxWinHeight = height;
625 }

References mMaxWinHeight.

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

◆ setMaxWidth()

void Window::setMaxWidth ( const int  width)

Sets the maximum width of the window.

Definition at line 617 of file window.cpp.

618 {
619  mMaxWinWidth = width;
620 }

References mMaxWinWidth.

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

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

1070 {
1071  if (mModal != modal)
1072  {
1073  mModal = modal;
1074  if (mModal == Modal_true)
1075  {
1076  if (gui != nullptr)
1079  }
1080  else
1081  {
1083  }
1084  }
1085 }
virtual void releaseModalFocus()
Definition: widget.cpp:394

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

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

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

568  { mMovable = movable; }

References mMovable.

Referenced by ConnectionDialog::ConnectionDialog().

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

495  { mPadding = padding; }

References mPadding.

Referenced by Window().

◆ setResizable()

void Window::setResizable ( const bool  resize)

Sets whether or not the window can be resized.

Definition at line 627 of file window.cpp.

628 {
629  if ((mGrip != nullptr) == r)
630  return;
631 
632  if (mGrip != nullptr)
633  mGrip->decRef();
634  if (r)
635  {
636  mGrip = Theme::getImageFromThemeXml("resize.xml", "");
637  if (mGrip != nullptr)
638  {
639  mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
640  mGripRect.y = mDimension.height - mGrip->getHeight()
641  - mGripPadding;
642  }
643  else
644  {
645  mGripRect.x = 0;
646  mGripRect.y = 0;
647  }
648  }
649  else
650  {
651  mGrip = nullptr;
652  }
653 }
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:926

References Theme::getImageFromThemeXml(), 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(), SellDialog::postInit(), SocialWindow::postInit(), TextSelectDialog::postInit(), WhoIsOnline::postInit(), QuestsWindow::QuestsWindow(), ServerDialog::ServerDialog(), ServerInfoWindow::ServerInfoWindow(), SetupWindow::SetupWindow(), ShopWindow::ShopWindow(), ShortcutWindow::ShortcutWindow(), SkillDialog::SkillDialog(), StatusWindow::StatusWindow(), TradeWindow::TradeWindow(), and UpdaterWindow::UpdaterWindow().

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

236  { mShowTitle = flag; }

References mShowTitle.

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

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

767 {
768  mSticky = sticky;
769  mRedraw = true;
770 }

References Widget::mRedraw, and mSticky.

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

◆ setStickyButton()

void Window::setStickyButton ( const bool  flag)

Sets whether or not the window has a sticky button.

Definition at line 761 of file window.cpp.

762 {
763  mStickyButton = flag;
764 }

References mStickyButton.

Referenced by Minimap::Minimap().

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

514  { mTitleBarHeight = height; }

References mTitleBarHeight.

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

◆ setTitlePadding()

void Window::setTitlePadding ( const int  p)
inlineprotected

Definition at line 599 of file window.h.

600  { mTitlePadding = p; }

References mTitlePadding.

◆ setVisible() [1/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 783 of file window.cpp.

784 {
785  if (visible == mVisible)
786  return;
787 
788  // Check if the window is off screen...
789  if (visible == Visible_true)
790  ensureOnScreen();
791  else
792  mResizeHandles = 0;
793 
794  if (mStickyButtonLock)
795  {
797  }
798  else
799  {
800  BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
801  visible == Visible_true, Visible));
802  }
803  if (visible == Visible_true)
804  {
805  if (mPlayVisibleSound)
807  if (gui != nullptr)
808  {
809  MouseEvent *const event = reinterpret_cast<MouseEvent*>(
810  gui->createMouseEvent(this));
811  if (event != nullptr)
812  {
813  const int x = event->getX();
814  const int y = event->getY();
815  if (x >= 0 && x <= mDimension.width
816  && y >= 0 && y <= mDimension.height)
817  {
818  mouseMoved(*event);
819  }
820  delete event;
821  }
822  }
823  }
824  else
825  {
826  if (mPlayVisibleSound)
828  }
829 }
MouseEvent * createMouseEvent(Window *const widget)
Definition: gui.cpp:986
void playGuiSound(const std::string &name)
void setVisible(Visible visible)
Definition: widget.cpp:225
void mouseMoved(MouseEvent &event)
Definition: window.cpp:967
static const std::string SOUND_HIDE_WINDOW
Definition: sound.h:38
static const std::string SOUND_SHOW_WINDOW
Definition: sound.h:37
SoundManager soundManager

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.

◆ setVisible() [2/2]

void Window::setVisible ( Visible  visible)
virtual

Overloads window setVisible by Guichan to allow sticky window handling.

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

Definition at line 778 of file window.cpp.

779 {
780  setVisible(visible, false);
781 }

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(), CutInWindow::hide(), EmoteWindow::hide(), SetupWindow::hideWindows(), HelpWindow::loadHelp(), HelpWindow::loadHelpSimple(), loadWindowState(), MailEditWindow::MailEditWindow(), MailViewWindow::MailViewWindow(), Minimap::Minimap(), MiniStatusWindow::MiniStatusWindow(), OkDialog::OkDialog(), CharSelectDialog::postInit(), ConfirmDialog::postInit(), ConnectionDialog::postInit(), EditDialog::postInit(), EditServerDialog::postInit(), ItemAmountWindow::postInit(), LoginDialog::postInit(), PincodeDialog::postInit(), QuitDialog::postInit(), RegisterDialog::postInit(), ServerDialog::postInit(), ServerInfoWindow::postInit(), SocialWindow::postInit(), TextCommandEditor::postInit(), TextDialog::postInit(), UpdaterWindow::postInit(), WhoIsOnline::postInit(), WorldSelectDialog::postInit(), EAthena::MailRecv::processMailOpen(), Ea::TradeRecv::processTradeCancel(), Ea::TradeRecv::processTradeResponseContinue(), HelpWindow::search(), QuestsWindow::selectQuest(), Minimap::setMap(), SellDialog::setVisible(), BuyDialog::setVisible(), BuySellDialog::setVisible(), ChatWindow::setVisible(), DidYouKnowWindow::setVisible(), InventoryWindow::setVisible(), NpcDialog::setVisible(), SetupWindow::setVisible(), ShopWindow::setVisible(), TextSelectDialog::setVisible(), EmoteWindow::show(), CutInWindow::show(), Actions::showHelpPage(), Actions::showHideWindow(), Minimap::toggle(), and Window().

◆ setWindowContainer()

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

Sets the window container to be used by new windows.

Definition at line 306 of file window.cpp.

307 {
308  windowContainer = wc;
309 }

References windowContainer.

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

◆ setWindowName()

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

◆ updateResizeHandler()

void Window::updateResizeHandler ( MouseEvent event)

Definition at line 930 of file window.cpp.

931 {
932  if (gui == nullptr)
933  return;
934 
935 #ifndef DYECMD
936  if (!dragDrop.isEmpty())
937  return;
938 #endif // DYECMD
939 
941 
942  // Changes the custom mouse cursor based on it's current position.
943  switch (mResizeHandles & resizeMask)
944  {
945  case BOTTOM | RIGHT:
946  case TOP | LEFT:
948  break;
949  case TOP | RIGHT:
950  case BOTTOM | LEFT:
952  break;
953  case BOTTOM:
954  case TOP:
956  break;
957  case RIGHT:
958  case LEFT:
960  break;
961  default:
963  break;
964  }
965 }
bool isEmpty() const
Definition: dragdrop.h:196
DragDrop dragDrop
@ CURSOR_RESIZE_DOWN_RIGHT
Definition: cursor.h:33
@ CURSOR_RESIZE_DOWN
Definition: cursor.h:31
@ CURSOR_RESIZE_DOWN_LEFT
Definition: cursor.h:32
@ CURSOR_RESIZE_ACROSS
Definition: cursor.h:30

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 mouseEntered(), and mouseMoved().

◆ widgetHidden()

void Window::widgetHidden ( const Event event)
virtual

Called whenever the widget is hidden.

Reimplemented from WidgetListener.

Reimplemented in ShortcutWindow, and InventoryWindow.

Definition at line 725 of file window.cpp.

726 {
728  mVertexes->clear();
729 
731 
732  mTextChanged = true;
733  mRedraw = true;
734 
735  if (gui != nullptr)
737 
738  if (mFocusHandler == nullptr)
739  return;
740 
741  for (WidgetListConstIterator it = mWidgets.begin();
742  it != mWidgets.end(); ++ it)
743  {
744  if (mFocusHandler->isFocused(*it))
746  }
747 }
bool isFocused(const Widget *const widget) const
FocusHandler * mFocusHandler
Definition: widget.h:1116
RenderType openGLMode
#define isBatchDrawRenders(val)
Definition: renderers.h:31

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 InventoryWindow::widgetHidden(), and ShortcutWindow::widgetHidden().

◆ widgetMoved()

void Window::widgetMoved ( const Event event)
virtual

Invoked when a widget is moved.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Reimplemented in ShortcutWindow, and EmoteWindow.

Definition at line 720 of file window.cpp.

721 {
722  mRedraw = true;
723 }

References Widget::mRedraw.

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

◆ widgetResized()

void Window::widgetResized ( const Event event)
virtual

Called whenever the widget changes size.

Reimplemented from WidgetListener.

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

Definition at line 655 of file window.cpp.

656 {
657  if (mGrip != nullptr)
658  {
659  mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
660  mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
661  }
662 
663  if (mLayout != nullptr)
664  {
665  const Rect area = getChildrenArea();
666  int w = area.width;
667  int h = area.height;
668  mLayout->reflow(w, h);
669  }
670  if (mSkin != nullptr)
671  {
672  const bool showClose = mCloseWindowButton
673  && (mSkin->getCloseImage(false) != nullptr);
674  if (showClose)
675  {
676  const Image *const button = mSkin->getCloseImage(false);
677  if (button != nullptr)
678  {
679  const int buttonWidth = button->getWidth();
683  mCloseRect.height = button->getHeight();
684  }
685  }
686  if (mStickyButton)
687  {
688  const Image *const button = mSkin->getStickyImage(mSticky);
689  if (button != nullptr)
690  {
691  const int buttonWidth = button->getWidth();
692  int x = mDimension.width - buttonWidth
694 
695  if (showClose)
696  x -= mSkin->getCloseImage(false)->getWidth();
697 
698  mStickyRect.x = x;
701  mStickyRect.height = button->getHeight();
702  }
703  }
704  }
705  else
706  {
707  mCloseRect.x = 0;
708  mCloseRect.y = 0;
709  mCloseRect.width = 0;
710  mCloseRect.height = 0;
711  mStickyRect.x = 0;
712  mStickyRect.y = 0;
713  mStickyRect.width = 0;
714  mStickyRect.height = 0;
715  }
716 
717  mRedraw = true;
718 }
static const int buttonWidth
Definition: sliderlist.cpp:35

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

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

◆ willSaveVisible()

bool Window::willSaveVisible ( ) const
inline

Returns whether the window will save it's visibility.

Definition at line 294 of file window.h.

295  { return mSaveVisible; }

References mSaveVisible.

Field Documentation

◆ mAlignment

Graphics::Alignment Window::mAlignment
protected

Holds the alignment of the caption.

Definition at line 613 of file window.h.

Referenced by getAlignment(), and setAlignment().

◆ mAllowClose

bool Window::mAllowClose
private

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

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

◆ mCaptionAlign

Graphics::Alignment Window::mCaptionAlign
private

Definition at line 711 of file window.h.

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

◆ mCaptionFont

Font* Window::mCaptionFont
private

Definition at line 719 of file window.h.

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

◆ mCaptionOffsetX

int Window::mCaptionOffsetX
protected

Definition at line 654 of file window.h.

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

◆ mCaptionOffsetY

int Window::mCaptionOffsetY
protected

Definition at line 655 of file window.h.

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

◆ mClosePadding

int Window::mClosePadding
private

Definition at line 716 of file window.h.

Referenced by widgetResized(), and Window().

◆ mCloseRect

Rect Window::mCloseRect
private

Close button rectangle

Definition at line 690 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 721 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 653 of file window.h.

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

◆ mDefaultVisible

bool Window::mDefaultVisible
private

Window's default visibility

Definition at line 722 of file window.h.

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

◆ mDefaultWidth

int Window::mDefaultWidth
protected

Default window width

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

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

◆ mDefaultY

int Window::mDefaultY
protected

Default window Y position

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

Referenced by getResizeHandles(), mouseDragged(), ChatWindow::mouseDragged(), ShortcutWindow::mouseDragged(), mousePressed(), ChatWindow::mousePressed(), ShortcutWindow::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 642 of file window.h.

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

◆ mGrip

Image* Window::mGrip
private

◆ mGripPadding

int Window::mGripPadding
private

Definition at line 713 of file window.h.

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

◆ mGripRect

Rect Window::mGripRect
private

Resize grip rectangle

Definition at line 692 of file window.h.

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

◆ mInit

bool Window::mInit
private

Definition at line 728 of file window.h.

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

◆ mLastRedraw

bool Window::mLastRedraw
protected

Definition at line 657 of file window.h.

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

◆ mLayout

Layout* Window::mLayout
private

Layout handler

Definition at line 689 of file window.h.

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

◆ mMaxWinHeight

int Window::mMaxWinHeight
private

Maximum window height

Definition at line 698 of file window.h.

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

◆ mMaxWinWidth

int Window::mMaxWinWidth
private

Maximum window width

Definition at line 697 of file window.h.

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

◆ mMinWinHeight

int Window::mMinWinHeight
private

Minimum window height

Definition at line 696 of file window.h.

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

◆ mMinWinWidth

int Window::mMinWinWidth
private

Minimum window width

Definition at line 695 of file window.h.

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

◆ mModal

Modal Window::mModal
private

Window is modal

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

Referenced by isMovable(), and setMovable().

◆ mMoved

bool Window::mMoved
protected

◆ mOldResizeHandles

int Window::mOldResizeHandles
private

Definition at line 715 of file window.h.

Referenced by draw().

◆ mouseResize

int Window::mouseResize = 0
staticprivate

Active resize handles

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

Referenced by getParentWindow().

◆ mPlayVisibleSound

bool Window::mPlayVisibleSound
private

Definition at line 727 of file window.h.

Referenced by enableVisibleSound(), and setVisible().

◆ mResizeHandles

int Window::mResizeHandles
private

Definition at line 714 of file window.h.

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

◆ mSaveVisible

bool Window::mSaveVisible
private

Window will save visibility

Definition at line 723 of file window.h.

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

◆ mShowTitle

bool Window::mShowTitle
protected

Window has a title bar

Definition at line 656 of file window.h.

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

◆ mSkin

Skin* Window::mSkin
protected

◆ mSticky

bool Window::mSticky
private

Window resists hiding

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

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

◆ mStickyPadding

int Window::mStickyPadding
private

Definition at line 718 of file window.h.

Referenced by widgetResized(), and Window().

◆ mStickyRect

Rect Window::mStickyRect
private

Sticky button rectangle

Definition at line 691 of file window.h.

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

◆ mStickySpacing

int Window::mStickySpacing
private

Definition at line 717 of file window.h.

Referenced by widgetResized(), and Window().

◆ mTextChanged

bool Window::mTextChanged
private

Definition at line 729 of file window.h.

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

◆ mTextChunk

TextChunk Window::mTextChunk
private

Definition at line 693 of file window.h.

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

◆ mTitleBarHeight

unsigned int Window::mTitleBarHeight
protected

◆ mTitlePadding

int Window::mTitlePadding
private

Definition at line 712 of file window.h.

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

◆ mVertexes

ImageCollection* Window::mVertexes
private

Definition at line 710 of file window.h.

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

◆ mWindowName

std::string Window::mWindowName
private

Name of the window

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

Referenced by getResizeHandles().

◆ windowInstances

int Window::windowInstances = 0
staticprivate

Number of Window instances

Definition at line 701 of file window.h.

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


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