Mana
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members

A window. More...

#include <window.h>

Inheritance diagram for Window:
AbilitiesWindow BuyDialog BuySellDialog ChangeEmailDialog ChangePasswordDialog CharCreateDialog CharSelectDialog ChatWindow ConfirmDialog ConnectionDialog CustomServerDialog DebugWindow EquipmentWindow HelpWindow InventoryWindow ItemAmountWindow LoginDialog Minimap NpcDialog NpcPostDialog OkDialog OutfitWindow QuestsWindow QuitDialog Recorder RegisterDialog SellDialog ServerDialog Setup ShortcutWindow SkillDialog SocialWindow StatusWindow TextDialog TradeWindow UnRegisterDialog UpdaterWindow WorldSelectDialog

Public Member Functions

 Window (const std::string &caption="Window", bool modal=false, Window *parent=nullptr)
 Constructor.
 
 Window (SkinType skinType, const std::string &caption="Window", bool modal=false, Window *parent=nullptr)
 Constructor that allows customizing the SkinType used by the window.
 
 ~Window () override
 Destructor.
 
void draw (gcn::Graphics *graphics) override
 Draws the window contents.
 
void drawFrame (gcn::Graphics *graphics) override
 Draws the window frame.
 
void setContentSize (int width, int height)
 Sets the size of this window.
 
void setMinimumContentSize (int width, int height)
 Sets the minimum size of the window content.
 
void setLocationRelativeTo (gcn::Widget *widget)
 Sets the location relative to the given widget.
 
void setResizable (bool resize)
 Sets whether or not the window can be resized.
 
void redraw ()
 
void widgetResized (const gcn::Event &event) override
 Called whenever the widget changes size.
 
void widgetHidden (const gcn::Event &event) override
 Called whenever the widget is hidden.
 
void setCloseButton (bool flag)
 Sets whether or not the window has a close button.
 
bool isResizable () const
 Returns whether the window can be resized.
 
void setMinWidth (int width)
 Sets the minimum width of the window.
 
int getMinWidth () const
 
void setMinHeight (int height)
 Sets the minimum height of the window.
 
int getMinHeight () const
 
void setMaxWidth (int width)
 Sets the maximum width of the window.
 
int getMaxWidth () const
 
void setMaxHeight (int height)
 Sets the minimum height of the window.
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 Sets flag to show a title or not.
 
void setStickyButton (bool flag)
 Sets whether or not the window has a sticky button.
 
void setSticky (bool sticky)
 Sets whether the window is sticky.
 
bool isSticky () const
 Returns whether the window is sticky.
 
virtual void setVisible (bool visible)
 Overloads window setVisible by Guichan to allow sticky window handling.
 
void setVisible (bool visible, bool forceSticky)
 Overloads window setVisible by Guichan to allow sticky window handling, or not, if you force the sticky state.
 
bool isDefaultVisible () const
 Returns whether the window is visible by default.
 
void setDefaultVisible (bool save)
 Sets whether the window is visible by default.
 
bool willSaveVisible () const
 Returns whether the window will save it's visibility.
 
void setSaveVisible (bool save)
 Sets whether the window will save it's visibility.
 
WindowgetParentWindow () const
 Returns the parent window.
 
void scheduleDelete ()
 Schedule this window for deletion.
 
void mousePressed (gcn::MouseEvent &event) override
 Starts window resizing when appropriate.
 
void mouseDragged (gcn::MouseEvent &event) override
 Implements window resizing and makes sure the window is not dragged/resized outside of the screen.
 
void mouseMoved (gcn::MouseEvent &event) override
 Implements custom cursor image changing context, based on mouse relative position.
 
void mouseReleased (gcn::MouseEvent &event) override
 When the mouse button has been let go, this ensures that the mouse custom cursor is restored back to it's standard image.
 
void mouseExited (gcn::MouseEvent &event) override
 When the mouse leaves the window this ensures that the custom cursor is restored back to it's standard image.
 
void setWindowName (const std::string &name)
 Sets the name of the window.
 
const std::string & getWindowName () const
 Returns the name of the window.
 
void loadWindowState ()
 Reads the position (and the size for resizable windows) in the configuration based on the given string.
 
void saveWindowState () const
 Saves the window state so that when the window is reloaded, it'll maintain its previous state and location.
 
void setDefaultSize (int defaultX, int defaultY, int defaultWidth, int defaultHeight)
 Set the default win pos and size.
 
void setDefaultSize ()
 Set the default win pos and size to the current ones.
 
void setDefaultSize (int defaultWidth, int defaultHeight, WindowAlignment alignment, int offsetx=0, int offsetY=0)
 Set the default win pos and size.
 
virtual void resetToDefaultSize ()
 Reset the win pos and size to default.
 
void adjustPositionAfterResize (int oldScreenWidth, int oldScreenHeight)
 Adjusts the window position after the application window has been resized.
 
LayoutgetLayout ()
 Gets the layout handler for this window.
 
void clearLayout ()
 Clears the window's layout (useful for redesigning the window).
 
void reflowLayout (int w=0, int h=0)
 Computes the position of the widgets according to the current layout.
 
LayoutCellplace (int x, int y, gcn::Widget *, int w=1, int h=1)
 Adds a widget to the window and sets it at given cell.
 
ContainerPlacer getPlacer (int x, int y)
 Returns a proxy for adding widgets in an inner table of the layout.
 
void center ()
 Positions the window in the center of it's parent.
 
virtual void close ()
 Overrideable functionality for when the window is to close.
 
const SkingetSkin () const
 Returns the Skin used by this window.
 

Static Public Member Functions

static void setWindowContainer (WindowContainer *windowContainer)
 Sets the window container to be used by new windows.
 
static int getGuiAlpha ()
 Gets the alpha value used by the window, in a Guichan usable format.
 

Static Protected Attributes

static int mouseResize = 0
 Active resize handles.
 

Private Types

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

Private Member Functions

void ensureOnScreen ()
 Ensures the window is on the screen, moving it if necessary.
 
int getResizeHandles (gcn::MouseEvent &event)
 Determines if the mouse is in a resize area and returns appropriate resize handles.
 
gcn::Rectangle getCloseButtonRect () const
 
gcn::Rectangle getStickyButtonRect () const
 

Private Attributes

ResizeGripmGrip = nullptr
 Resize grip.
 
WindowmParent
 The parent window.
 
LayoutmLayout = nullptr
 Layout handler.
 
std::string mWindowName
 Name of the window.
 
bool mShowTitle = true
 Window has a title bar.
 
bool mModal
 Window is modal.
 
bool mCloseButton = false
 Window has a close button.
 
bool mCloseButtonHovered = false
 
bool mDefaultVisible = false
 Window's default visibility.
 
bool mSaveVisible = false
 Window will save visibility.
 
bool mStickyButton = false
 Window has a sticky button.
 
bool mSticky = false
 Window resists hiding.
 
SkinType mSkinType
 The skin type used when drawing the window.
 
int mMinWinWidth = 100
 Minimum window width.
 
int mMinWinHeight = 40
 Minimum window height.
 
int mMaxWinWidth
 Maximum window width.
 
int mMaxWinHeight
 Maximum window height.
 
int mDefaultX
 Default window X position.
 
int mDefaultY
 Default window Y position.
 
int mDefaultWidth
 Default window width.
 
int mDefaultHeight
 Default window height.
 

Static Private Attributes

static int instances = 0
 Number of Window instances.
 

Detailed Description

A window.

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

Definition at line 58 of file window.h.

Member Enumeration Documentation

◆ ResizeHandles

enum Window::ResizeHandles
private
Enumerator
TOP 
RIGHT 
BOTTOM 
LEFT 

Definition at line 386 of file window.h.

Constructor & Destructor Documentation

◆ Window() [1/2]

Window::Window ( const std::string &  caption = "Window",
bool  modal = false,
Window parent = nullptr 
)

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.

Definition at line 43 of file window.cpp.

◆ Window() [2/2]

Window::Window ( SkinType  skinType,
const std::string &  caption = "Window",
bool  modal = false,
Window parent = nullptr 
)

Constructor that allows customizing the SkinType used by the window.

Definition at line 47 of file window.cpp.

◆ ~Window()

Window::~Window ( )
override

Destructor.

Deletes all the added widgets.

Definition at line 82 of file window.cpp.

Member Function Documentation

◆ adjustPositionAfterResize()

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

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

Definition at line 607 of file window.cpp.

◆ center()

void Window::center ( )

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

Definition at line 768 of file window.cpp.

◆ clearLayout()

void Window::clearLayout ( )

Clears the window's layout (useful for redesigning the window).

Does not delete the widgets!

Definition at line 721 of file window.cpp.

◆ close()

void Window::close ( )
virtual

Overrideable functionality for when the window is to close.

This allows for class implementations to clean up or do certain actions on window close they couldn't do otherwise.

Reimplemented in InventoryWindow, ItemAmountWindow, NpcDialog, and TradeWindow.

Definition at line 327 of file window.cpp.

◆ draw()

void Window::draw ( gcn::Graphics *  graphics)
override

Draws the window contents.

Definition at line 103 of file window.cpp.

◆ drawFrame()

void Window::drawFrame ( gcn::Graphics *  graphics)
override

Draws the window frame.

Definition at line 125 of file window.cpp.

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

◆ getCloseButtonRect()

gcn::Rectangle Window::getCloseButtonRect ( ) const
private

Definition at line 662 of file window.cpp.

◆ getGuiAlpha()

int Window::getGuiAlpha ( )
static

Gets the alpha value used by the window, in a Guichan usable format.

Definition at line 707 of file window.cpp.

◆ getLayout()

Layout & Window::getLayout ( )

Gets the layout handler for this window.

Definition at line 714 of file window.cpp.

◆ getMaxHeight()

int Window::getMaxHeight ( ) const
inline

Definition at line 171 of file window.h.

◆ getMaxWidth()

int Window::getMaxWidth ( ) const
inline

Definition at line 164 of file window.h.

◆ getMinHeight()

int Window::getMinHeight ( ) const
inline

Definition at line 157 of file window.h.

◆ getMinWidth()

int Window::getMinWidth ( ) const
inline

Definition at line 150 of file window.h.

◆ getParentWindow()

Window * Window::getParentWindow ( ) const
inline

Returns the parent window.

Returns
The parent window or NULL if there is none.

Definition at line 232 of file window.h.

◆ getPlacer()

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

Returns a proxy for adding widgets in an inner table of the layout.

Definition at line 743 of file window.cpp.

◆ getResizeHandles()

int Window::getResizeHandles ( gcn::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

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

◆ getSkin()

const Skin & Window::getSkin ( ) const

Returns the Skin used by this window.

Definition at line 332 of file window.cpp.

◆ getStickyButtonRect()

gcn::Rectangle Window::getStickyButtonRect ( ) const
private

Definition at line 681 of file window.cpp.

◆ getWindowName()

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

Returns the name of the window.

This is not the window title.

Definition at line 277 of file window.h.

◆ isDefaultVisible()

bool Window::isDefaultVisible ( ) const
inline

Returns whether the window is visible by default.

Definition at line 210 of file window.h.

◆ isResizable()

bool Window::isResizable ( ) const

Returns whether the window can be resized.

Definition at line 267 of file window.cpp.

◆ isSticky()

bool Window::isSticky ( ) const
inline

Returns whether the window is sticky.

Definition at line 193 of file window.h.

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

◆ mouseDragged()

void Window::mouseDragged ( gcn::MouseEvent &  event)
override

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

Definition at line 397 of file window.cpp.

◆ mouseExited()

void Window::mouseExited ( gcn::MouseEvent &  event)
override

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

Definition at line 344 of file window.cpp.

◆ mouseMoved()

void Window::mouseMoved ( gcn::MouseEvent &  event)
override

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

Definition at line 352 of file window.cpp.

◆ mousePressed()

void Window::mousePressed ( gcn::MouseEvent &  event)
override

Starts window resizing when appropriate.

Definition at line 304 of file window.cpp.

◆ mouseReleased()

void Window::mouseReleased ( gcn::MouseEvent &  event)
override

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

Definition at line 337 of file window.cpp.

◆ place()

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

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

Definition at line 737 of file window.cpp.

◆ redraw()

void Window::redraw ( )

Definition at line 757 of file window.cpp.

◆ reflowLayout()

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

Computes the position of the widgets according to the current layout.

Resizes the window so that the layout fits. Deletes the layout.

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

Definition at line 748 of file window.cpp.

◆ resetToDefaultSize()

void Window::resetToDefaultSize ( )
virtual

Reset the win pos and size to default.

Don't forget to set defaults first.

Reimplemented in ChatWindow.

Definition at line 600 of file window.cpp.

◆ saveWindowState()

void Window::saveWindowState ( ) const

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

Definition at line 502 of file window.cpp.

◆ scheduleDelete()

void Window::scheduleDelete ( )

Schedule this window for deletion.

It will be deleted at the start of the next logic update.

Definition at line 299 of file window.cpp.

◆ setCloseButton()

void Window::setCloseButton ( bool  flag)

Sets whether or not the window has a close button.

Definition at line 262 of file window.cpp.

◆ setContentSize()

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

Sets the size of this window.

Definition at line 151 of file window.cpp.

◆ setDefaultSize() [1/3]

void Window::setDefaultSize ( )

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

Definition at line 545 of file window.cpp.

◆ setDefaultSize() [2/3]

void Window::setDefaultSize ( int  defaultWidth,
int  defaultHeight,
WindowAlignment  alignment,
int  offsetx = 0,
int  offsetY = 0 
)

Set the default win pos and size.

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

Definition at line 553 of file window.cpp.

◆ setDefaultSize() [3/3]

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

Set the default win pos and size.

(which can be different of the actual ones.)

Definition at line 527 of file window.cpp.

◆ setDefaultVisible()

void Window::setDefaultVisible ( bool  save)
inline

Sets whether the window is visible by default.

Definition at line 215 of file window.h.

◆ setLocationRelativeTo()

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

Sets the location relative to the given widget.

Definition at line 178 of file window.cpp.

◆ setMaxHeight()

void Window::setMaxHeight ( int  height)

Sets the minimum height of the window.

Definition at line 207 of file window.cpp.

◆ setMaxWidth()

void Window::setMaxWidth ( int  width)

Sets the maximum width of the window.

Definition at line 202 of file window.cpp.

◆ setMinHeight()

void Window::setMinHeight ( int  height)

Sets the minimum height of the window.

Definition at line 197 of file window.cpp.

◆ setMinimumContentSize()

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

Sets the minimum size of the window content.

Definition at line 168 of file window.cpp.

◆ setMinWidth()

void Window::setMinWidth ( int  width)

Sets the minimum width of the window.

Definition at line 192 of file window.cpp.

◆ setResizable()

void Window::setResizable ( bool  resize)

Sets whether or not the window can be resized.

Definition at line 212 of file window.cpp.

◆ setSaveVisible()

void Window::setSaveVisible ( bool  save)
inline

Sets whether the window will save it's visibility.

Definition at line 225 of file window.h.

◆ setShowTitle()

void Window::setShowTitle ( bool  flag)
inline

Sets flag to show a title or not.

Definition at line 176 of file window.h.

◆ setSticky()

void Window::setSticky ( 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 277 of file window.cpp.

◆ setStickyButton()

void Window::setStickyButton ( bool  flag)

Sets whether or not the window has a sticky button.

Definition at line 272 of file window.cpp.

◆ setVisible() [1/2]

void Window::setVisible ( bool  visible)
virtual

Overloads window setVisible by Guichan to allow sticky window handling.

Reimplemented in BuyDialog, BuySellDialog, ChatWindow, NpcDialog, NpcPostDialog, and SellDialog.

Definition at line 282 of file window.cpp.

◆ setVisible() [2/2]

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

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

Definition at line 287 of file window.cpp.

◆ setWindowContainer()

void Window::setWindowContainer ( WindowContainer windowContainer)
static

Sets the window container to be used by new windows.

Definition at line 98 of file window.cpp.

◆ setWindowName()

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

Sets the name of the window.

This is not the window title.

Definition at line 272 of file window.h.

◆ widgetHidden()

void Window::widgetHidden ( const gcn::Event &  event)
override

Called whenever the widget is hidden.

Definition at line 248 of file window.cpp.

◆ widgetResized()

void Window::widgetResized ( const gcn::Event &  event)
override

Called whenever the widget changes size.

Definition at line 232 of file window.cpp.

◆ willSaveVisible()

bool Window::willSaveVisible ( ) const
inline

Returns whether the window will save it's visibility.

Definition at line 220 of file window.h.

Member Data Documentation

◆ instances

int Window::instances = 0
staticprivate

Number of Window instances.

Definition at line 435 of file window.h.

◆ mCloseButton

bool Window::mCloseButton = false
private

Window has a close button.

Definition at line 419 of file window.h.

◆ mCloseButtonHovered

bool Window::mCloseButtonHovered = false
private

Definition at line 420 of file window.h.

◆ mDefaultHeight

int Window::mDefaultHeight
private

Default window height.

Definition at line 433 of file window.h.

◆ mDefaultVisible

bool Window::mDefaultVisible = false
private

Window's default visibility.

Definition at line 421 of file window.h.

◆ mDefaultWidth

int Window::mDefaultWidth
private

Default window width.

Definition at line 432 of file window.h.

◆ mDefaultX

int Window::mDefaultX
private

Default window X position.

Definition at line 430 of file window.h.

◆ mDefaultY

int Window::mDefaultY
private

Default window Y position.

Definition at line 431 of file window.h.

◆ mGrip

ResizeGrip* Window::mGrip = nullptr
private

Resize grip.

Definition at line 413 of file window.h.

◆ mLayout

Layout* Window::mLayout = nullptr
private

Layout handler.

Definition at line 415 of file window.h.

◆ mMaxWinHeight

int Window::mMaxWinHeight
private

Maximum window height.

Definition at line 429 of file window.h.

◆ mMaxWinWidth

int Window::mMaxWinWidth
private

Maximum window width.

Definition at line 428 of file window.h.

◆ mMinWinHeight

int Window::mMinWinHeight = 40
private

Minimum window height.

Definition at line 427 of file window.h.

◆ mMinWinWidth

int Window::mMinWinWidth = 100
private

Minimum window width.

Definition at line 426 of file window.h.

◆ mModal

bool Window::mModal
private

Window is modal.

Definition at line 418 of file window.h.

◆ mouseResize

int Window::mouseResize = 0
staticprotected

Active resize handles.

Definition at line 383 of file window.h.

◆ mParent

Window* Window::mParent
private

The parent window.

Definition at line 414 of file window.h.

◆ mSaveVisible

bool Window::mSaveVisible = false
private

Window will save visibility.

Definition at line 422 of file window.h.

◆ mShowTitle

bool Window::mShowTitle = true
private

Window has a title bar.

Definition at line 417 of file window.h.

◆ mSkinType

SkinType Window::mSkinType
private

The skin type used when drawing the window.

Definition at line 425 of file window.h.

◆ mSticky

bool Window::mSticky = false
private

Window resists hiding.

Definition at line 424 of file window.h.

◆ mStickyButton

bool Window::mStickyButton = false
private

Window has a sticky button.

Definition at line 423 of file window.h.

◆ mWindowName

std::string Window::mWindowName
private

Name of the window.

Definition at line 416 of file window.h.


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