Mana
|
A window. More...
#include <window.h>
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. | |
Window * | getParentWindow () 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. | |
Layout & | getLayout () |
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. | |
LayoutCell & | place (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 Skin & | getSkin () 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 | |
ResizeGrip * | mGrip = nullptr |
Resize grip. | |
Window * | mParent |
The parent window. | |
Layout * | mLayout = 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. | |
A window.
This window can be dragged around and has a title bar. Windows are invisible by default.
|
private |
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.
caption | The initial window title, "Window" by default. |
modal | Block input to other windows. |
parent | The 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::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.
|
override |
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.
void Window::center | ( | ) |
Positions the window in the center of it's parent.
Definition at line 768 of file window.cpp.
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.
|
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.
|
override |
Draws the window contents.
Definition at line 103 of file window.cpp.
|
override |
Draws the window frame.
Definition at line 125 of file window.cpp.
|
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.
|
private |
Definition at line 662 of file window.cpp.
|
static |
Gets the alpha value used by the window, in a Guichan usable format.
Definition at line 707 of file window.cpp.
Layout & Window::getLayout | ( | ) |
Gets the layout handler for this window.
Definition at line 714 of file window.cpp.
|
inline |
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.
|
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.
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.
const Skin & Window::getSkin | ( | ) | const |
Returns the Skin used by this window.
Definition at line 332 of file window.cpp.
|
private |
Definition at line 681 of file window.cpp.
|
inline |
|
inline |
bool Window::isResizable | ( | ) | const |
Returns whether the window can be resized.
Definition at line 267 of file window.cpp.
|
inline |
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.
|
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.
|
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.
|
override |
Implements custom cursor image changing context, based on mouse relative position.
Definition at line 352 of file window.cpp.
|
override |
Starts window resizing when appropriate.
Definition at line 304 of file window.cpp.
|
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.
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.
void Window::redraw | ( | ) |
Definition at line 757 of file window.cpp.
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.
w | if non-zero, force the window to this width. |
h | if non-zero, force the window to this height. |
Definition at line 748 of file window.cpp.
|
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.
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.
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.
void Window::setCloseButton | ( | bool | flag | ) |
Sets whether or not the window has a close button.
Definition at line 262 of file window.cpp.
void Window::setContentSize | ( | int | width, |
int | height | ||
) |
Sets the size of this window.
Definition at line 151 of file window.cpp.
void Window::setDefaultSize | ( | ) |
Set the default win pos and size to the current ones.
Definition at line 545 of file window.cpp.
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.
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.
|
inline |
void Window::setLocationRelativeTo | ( | gcn::Widget * | widget | ) |
Sets the location relative to the given widget.
Definition at line 178 of file window.cpp.
void Window::setMaxHeight | ( | int | height | ) |
Sets the minimum height of the window.
Definition at line 207 of file window.cpp.
void Window::setMaxWidth | ( | int | width | ) |
Sets the maximum width of the window.
Definition at line 202 of file window.cpp.
void Window::setMinHeight | ( | int | height | ) |
Sets the minimum height of the window.
Definition at line 197 of file window.cpp.
void Window::setMinimumContentSize | ( | int | width, |
int | height | ||
) |
Sets the minimum size of the window content.
Definition at line 168 of file window.cpp.
void Window::setMinWidth | ( | int | width | ) |
Sets the minimum width of the window.
Definition at line 192 of file window.cpp.
void Window::setResizable | ( | bool | resize | ) |
Sets whether or not the window can be resized.
Definition at line 212 of file window.cpp.
|
inline |
|
inline |
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.
void Window::setStickyButton | ( | bool | flag | ) |
Sets whether or not the window has a sticky button.
Definition at line 272 of file window.cpp.
|
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.
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.
|
static |
Sets the window container to be used by new windows.
Definition at line 98 of file window.cpp.
|
inline |
|
override |
Called whenever the widget is hidden.
Definition at line 248 of file window.cpp.
|
override |
Called whenever the widget changes size.
Definition at line 232 of file window.cpp.
|
inline |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprotected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |