#include <window.h>
This window can be dragged around and has a title bar. Windows are invisible by default.
Definition at line 45 of file window.h.
Public Member Functions | |
Window (const std::string &caption="Window", bool modal=false, Window *parent=NULL, const std::string &skin="graphics/gui/gui.xml") | |
Constructor. | |
~Window () | |
Destructor. | |
void | draw (gcn::Graphics *graphics) |
Draws the window. | |
void | setContentSize (int width, int height) |
Sets the size of this window. | |
void | setLocationRelativeTo (gcn::Widget *widget) |
Sets the location relative to the given widget. | |
void | setLocationRelativeTo (ImageRect::ImagePosition position, int offsetX=0, int offsetY=0) |
Sets the location relative to the given enumerated position. | |
void | setResizable (bool resize) |
Sets whether or not the window can be resized. | |
void | widgetResized (const gcn::Event &event) |
Called whenever the widget changes size. | |
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. | |
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 will save it's visibility. | |
void | setDefaultVisible (bool save) |
Returns whether the window will save it's visibility. | |
bool | willSaveVisible () const |
Returns whether the window will save it's visibility. | |
void | setSaveVisible (bool save) |
Returns 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) |
Starts window resizing when appropriate. | |
void | mouseDragged (gcn::MouseEvent &event) |
Implements window resizing and makes sure the window is not dragged/resized outside of the screen. | |
void | mouseMoved (gcn::MouseEvent &event) |
Implements custom cursor image changing context, based on mouse relative position. | |
void | mouseReleased (gcn::MouseEvent &event) |
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) |
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 () |
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 tot he current ones. | |
void | setDefaultSize (int defaultWidth, int defaultHeight, ImageRect::ImagePosition position, int offsetx=0, int offsetY=0) |
Set the default win pos and size. | |
virtual void | resetToDefaultSize () |
Reset the win pos and size to default. | |
Layout & | getLayout () |
Gets the layout handler for this 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. | |
int | getGuiAlpha () |
Gets the alpha value used by the window, in a GUIChan usable format. | |
Static Public Member Functions | |
static void | setWindowContainer (WindowContainer *windowContainer) |
Sets the window container to be used by new windows. | |
Private Types | |
enum | ResizeHandles { TOP = 0x01, RIGHT = 0x02, BOTTOM = 0x04, LEFT = 0x08 } |
Private Member Functions | |
int | getResizeHandles (gcn::MouseEvent &event) |
Determines if the mouse is in a resize area and returns appropriate resize handles. | |
Private Attributes | |
ResizeGrip * | mGrip |
Resize grip. | |
Window * | mParent |
The parent window. | |
Layout * | mLayout |
Layout handler. | |
std::string | mWindowName |
Name of the window. | |
std::string | mDefaultSkinPath |
Default skin path for this window. | |
bool | mShowTitle |
Window has a title bar. | |
bool | mModal |
Window is modal. | |
bool | mCloseButton |
Window has a close button. | |
bool | mDefaultVisible |
Window's default visibility. | |
bool | mSaveVisible |
Window will save visibility. | |
bool | mStickyButton |
Window has a sticky button. | |
bool | mSticky |
Window resists hiding. | |
int | mMinWinWidth |
Minimum window width. | |
int | mMinWinHeight |
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. | |
Skin * | mSkin |
Skin in use by this window. | |
Static Private Attributes | |
static int | mouseResize = 0 |
Active resize handles. | |
static int | instances = 0 |
Number of Window instances. | |
static const int | resizeBorderWidth = 10 |
The width of the resize border. |
enum Window::ResizeHandles [private] |
Window::Window | ( | const std::string & | caption = "Window" , |
|
bool | modal = false , |
|||
Window * | parent = NULL , |
|||
const std::string & | skin = "graphics/gui/gui.xml" | |||
) |
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. | |
skin | The location where the window's skin XML can be found. |
Definition at line 42 of file window.cpp.
Window::~Window | ( | ) |
void Window::setWindowContainer | ( | WindowContainer * | windowContainer | ) | [static] |
void Window::draw | ( | gcn::Graphics * | graphics | ) |
Draws the window.
Reimplemented in BuddyWindow, EquipmentWindow, GuildWindow, MagicDialog, Minimap, PartyWindow, SkillDialog, StatusWindow, and StatusWindow.
Definition at line 114 of file window.cpp.
void Window::setContentSize | ( | int | width, | |
int | height | |||
) |
void Window::setLocationRelativeTo | ( | gcn::Widget * | widget | ) |
void Window::setLocationRelativeTo | ( | ImageRect::ImagePosition | position, | |
int | offsetX = 0 , |
|||
int | offsetY = 0 | |||
) |
Sets the location relative to the given enumerated position.
Definition at line 179 of file window.cpp.
void Window::setResizable | ( | bool | resize | ) |
void Window::widgetResized | ( | const gcn::Event & | event | ) |
Called whenever the widget changes size.
Reimplemented in ChatWindow, and NpcTextDialog.
Definition at line 266 of file window.cpp.
void Window::setCloseButton | ( | bool | flag | ) |
bool Window::isResizable | ( | ) | const |
void Window::setMinWidth | ( | int | width | ) |
void Window::setMinHeight | ( | int | height | ) |
void Window::setMaxWidth | ( | int | width | ) |
void Window::setMaxHeight | ( | int | height | ) |
void Window::setShowTitle | ( | bool | flag | ) | [inline] |
void Window::setStickyButton | ( | bool | flag | ) |
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 297 of file window.cpp.
bool Window::isSticky | ( | ) | const [inline] |
void Window::setVisible | ( | bool | visible | ) |
Overloads window setVisible by Guichan to allow sticky window handling.
Reimplemented in BuyDialog, BuySellDialog, ChatWindow, NpcIntegerDialog, NpcListDialog, NpcStringDialog, and SellDialog.
Definition at line 302 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 307 of file window.cpp.
bool Window::isDefaultVisible | ( | ) | const [inline] |
void Window::setDefaultVisible | ( | bool | save | ) | [inline] |
bool Window::willSaveVisible | ( | ) | const [inline] |
void Window::setSaveVisible | ( | bool | save | ) | [inline] |
Window* Window::getParentWindow | ( | ) | const [inline] |
void Window::scheduleDelete | ( | ) |
Schedule this window for deletion.
It will be deleted at the start of the next logic update.
Definition at line 312 of file window.cpp.
void Window::mousePressed | ( | gcn::MouseEvent & | event | ) |
Starts window resizing when appropriate.
Reimplemented in EquipmentWindow.
Definition at line 317 of file window.cpp.
void Window::mouseDragged | ( | gcn::MouseEvent & | event | ) |
Implements window resizing and makes sure the window is not dragged/resized outside of the screen.
Definition at line 411 of file window.cpp.
void Window::mouseMoved | ( | gcn::MouseEvent & | event | ) |
Implements custom cursor image changing context, based on mouse relative position.
Reimplemented in EquipmentWindow.
Definition at line 386 of file window.cpp.
void Window::mouseReleased | ( | gcn::MouseEvent & | event | ) |
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 368 of file window.cpp.
void Window::mouseExited | ( | gcn::MouseEvent & | event | ) |
When the mouse leaves the window this ensures that the custom cursor is restored back to it's standard image.
Reimplemented in EquipmentWindow.
Definition at line 380 of file window.cpp.
void Window::setWindowName | ( | const std::string & | name | ) | [inline] |
const std::string& Window::getWindowName | ( | ) | const [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 487 of file window.cpp.
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 531 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 564 of file window.cpp.
void Window::setDefaultSize | ( | ) |
void Window::setDefaultSize | ( | int | defaultWidth, | |
int | defaultHeight, | |||
ImageRect::ImagePosition | position, | |||
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 590 of file window.cpp.
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 642 of file window.cpp.
Layout & Window::getLayout | ( | ) |
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 701 of file window.cpp.
LayoutCell & Window::place | ( | int | x, | |
int | y, | |||
gcn::Widget * | wg, | |||
int | w = 1 , |
|||
int | h = 1 | |||
) |
ContainerPlacer Window::getPlacer | ( | int | x, | |
int | y | |||
) |
Returns a proxy for adding widgets in an inner table of the layout.
Definition at line 696 of file window.cpp.
void Window::center | ( | ) |
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 BuyDialog, ItemAmountWindow, SellDialog, StorageWindow, and TradeWindow.
Definition at line 363 of file window.cpp.
int Window::getGuiAlpha | ( | ) |
Gets the alpha value used by the window, in a GUIChan usable format.
Definition at line 678 of file window.cpp.
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.
Definition at line 649 of file window.cpp.
ResizeGrip* Window::mGrip [private] |
Window* Window::mParent [private] |
Layout* Window::mLayout [private] |
std::string Window::mWindowName [private] |
std::string Window::mDefaultSkinPath [private] |
bool Window::mShowTitle [private] |
bool Window::mModal [private] |
bool Window::mCloseButton [private] |
bool Window::mDefaultVisible [private] |
bool Window::mSaveVisible [private] |
bool Window::mStickyButton [private] |
bool Window::mSticky [private] |
int Window::mMinWinWidth [private] |
int Window::mMinWinHeight [private] |
int Window::mMaxWinWidth [private] |
int Window::mMaxWinHeight [private] |
int Window::mDefaultX [private] |
int Window::mDefaultY [private] |
int Window::mDefaultWidth [private] |
int Window::mDefaultHeight [private] |
int Window::mouseResize = 0 [static, private] |
int Window::instances = 0 [static, private] |
Skin* Window::mSkin [private] |
const int Window::resizeBorderWidth = 10 [static, private] |