Window Class Reference
[Core GUI related classes (widgets)]

#include <window.h>

Inheritance diagram for Window:

BuddyWindow BuyDialog BuySellDialog ChangeEmailDialog ChangePasswordDialog CharCreateDialog CharSelectDialog ChatWindow ConfirmDialog ConnectionDialog DebugWindow EmoteWindow EquipmentWindow GuildWindow HelpWindow InventoryWindow ItemAmountWindow LoginDialog MagicDialog Minimap NpcIntegerDialog NpcListDialog NpcPostDialog NpcStringDialog NpcTextDialog OkDialog PartyWindow QuitDialog Recorder RegisterDialog SellDialog ServerDialog ServerSelectDialog Setup ShortcutWindow SkillDialog SkillDialog StatusWindow StatusWindow StorageWindow TextDialog TradeWindow UnRegisterDialog UpdaterWindow

List of all members.


Detailed Description

A window.

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.
WindowgetParentWindow () 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.
LayoutgetLayout ()
 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.
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.
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

ResizeGripmGrip
 Resize grip.
WindowmParent
 The parent window.
LayoutmLayout
 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.
SkinmSkin
 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.

Member Enumeration Documentation

enum Window::ResizeHandles [private]

Enumerator:
TOP 
RIGHT 
BOTTOM 
LEFT 

Definition at line 333 of file window.h.


Constructor & Destructor Documentation

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.

Parameters:
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 (  ) 

Destructor.

Deletes all the added widgets.

Definition at line 91 of file window.cpp.


Member Function Documentation

void Window::setWindowContainer ( WindowContainer windowContainer  )  [static]

Sets the window container to be used by new windows.

Definition at line 109 of file window.cpp.

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 
)

Sets the size of this window.

Definition at line 150 of file window.cpp.

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

Sets the location relative to the given widget.

Definition at line 167 of file window.cpp.

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  ) 

Sets whether or not the window can be resized.

Definition at line 246 of file window.cpp.

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  ) 

Sets whether or not the window has a close button.

Definition at line 282 of file window.cpp.

bool Window::isResizable (  )  const

Returns whether the window can be resized.

Definition at line 287 of file window.cpp.

void Window::setMinWidth ( int  width  ) 

Sets the minimum width of the window.

Definition at line 225 of file window.cpp.

int Window::getMinWidth (  )  const [inline]

Definition at line 118 of file window.h.

void Window::setMinHeight ( int  height  ) 

Sets the minimum height of the window.

Definition at line 230 of file window.cpp.

int Window::getMinHeight (  )  const [inline]

Definition at line 125 of file window.h.

void Window::setMaxWidth ( int  width  ) 

Sets the maximum width of the window.

Definition at line 236 of file window.cpp.

int Window::getMaxWidth (  )  const [inline]

Definition at line 132 of file window.h.

void Window::setMaxHeight ( int  height  ) 

Sets the minimum height of the window.

Definition at line 241 of file window.cpp.

int Window::getMaxHeight (  )  const [inline]

Definition at line 139 of file window.h.

void Window::setShowTitle ( bool  flag  )  [inline]

Sets flag to show a title or not.

Definition at line 144 of file window.h.

void Window::setStickyButton ( bool  flag  ) 

Sets whether or not the window has a sticky button.

Definition at line 292 of file window.cpp.

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]

Returns whether the window is sticky.

Definition at line 161 of file window.h.

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]

Returns whether the window will save it's visibility.

Definition at line 178 of file window.h.

void Window::setDefaultVisible ( bool  save  )  [inline]

Returns whether the window will save it's visibility.

Definition at line 183 of file window.h.

bool Window::willSaveVisible (  )  const [inline]

Returns whether the window will save it's visibility.

Definition at line 188 of file window.h.

void Window::setSaveVisible ( bool  save  )  [inline]

Returns whether the window will save it's visibility.

Definition at line 193 of file window.h.

Window* Window::getParentWindow (  )  const [inline]

Returns the parent window.

Returns:
The parent window or NULL if there is none.

Definition at line 200 of file window.h.

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]

Sets the name of the window.

This is not the window title.

Definition at line 240 of file window.h.

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

Returns the name of the window.

This is not the window title.

Definition at line 245 of file window.h.

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 (  ) 

Set the default win pos and size tot he current ones.

Definition at line 582 of file window.cpp.

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 (  ) 

Gets the layout handler for this window.

Definition at line 684 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.

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

Definition at line 701 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 690 of file window.cpp.

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 (  ) 

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

Definition at line 710 of file window.cpp.

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.

See also:
ResizeHandles

Definition at line 649 of file window.cpp.


Member Data Documentation

Resize grip.

Definition at line 350 of file window.h.

Window* Window::mParent [private]

The parent window.

Definition at line 351 of file window.h.

Layout* Window::mLayout [private]

Layout handler.

Definition at line 352 of file window.h.

std::string Window::mWindowName [private]

Name of the window.

Definition at line 353 of file window.h.

std::string Window::mDefaultSkinPath [private]

Default skin path for this window.

Definition at line 354 of file window.h.

bool Window::mShowTitle [private]

Window has a title bar.

Definition at line 355 of file window.h.

bool Window::mModal [private]

Window is modal.

Definition at line 356 of file window.h.

bool Window::mCloseButton [private]

Window has a close button.

Definition at line 357 of file window.h.

bool Window::mDefaultVisible [private]

Window's default visibility.

Definition at line 358 of file window.h.

bool Window::mSaveVisible [private]

Window will save visibility.

Definition at line 359 of file window.h.

bool Window::mStickyButton [private]

Window has a sticky button.

Definition at line 360 of file window.h.

bool Window::mSticky [private]

Window resists hiding.

Definition at line 361 of file window.h.

int Window::mMinWinWidth [private]

Minimum window width.

Definition at line 362 of file window.h.

int Window::mMinWinHeight [private]

Minimum window height.

Definition at line 363 of file window.h.

int Window::mMaxWinWidth [private]

Maximum window width.

Definition at line 364 of file window.h.

int Window::mMaxWinHeight [private]

Maximum window height.

Definition at line 365 of file window.h.

int Window::mDefaultX [private]

Default window X position.

Definition at line 366 of file window.h.

int Window::mDefaultY [private]

Default window Y position.

Definition at line 367 of file window.h.

int Window::mDefaultWidth [private]

Default window width.

Definition at line 368 of file window.h.

int Window::mDefaultHeight [private]

Default window height.

Definition at line 369 of file window.h.

int Window::mouseResize = 0 [static, private]

Active resize handles.

Definition at line 371 of file window.h.

int Window::instances = 0 [static, private]

Number of Window instances.

Definition at line 372 of file window.h.

Skin* Window::mSkin [private]

Skin in use by this window.

Definition at line 374 of file window.h.

const int Window::resizeBorderWidth = 10 [static, private]

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


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

Generated on Sun Apr 26 17:30:44 2009 for The Mana World by  doxygen 1.5.5