summaryrefslogtreecommitdiff
path: root/src/gui/window.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-06 17:50:52 +0100
committerIra Rice <irarice@gmail.com>2009-01-06 11:06:36 -0700
commit14a12cbe586f88ace6d90d9ca5b802edfb546768 (patch)
tree74a724358ec376df7347e566dab1f23fde92751a /src/gui/window.h
parent394989d94081cbc462ba7d567fc88d0c4dff8134 (diff)
downloadmana-14a12cbe586f88ace6d90d9ca5b802edfb546768.tar.gz
mana-14a12cbe586f88ace6d90d9ca5b802edfb546768.tar.bz2
mana-14a12cbe586f88ace6d90d9ca5b802edfb546768.tar.xz
mana-14a12cbe586f88ace6d90d9ca5b802edfb546768.zip
Merged layout handler from mainline
Also fixed login dialog layout. This is the layout handler by Guillaume Melquiond, which he started in commit 59472ef68fdef3f7e8858a81a46e28c127119c58.
Diffstat (limited to 'src/gui/window.h')
-rw-r--r--src/gui/window.h62
1 files changed, 41 insertions, 21 deletions
diff --git a/src/gui/window.h b/src/gui/window.h
index 9380fc88..89cc75a5 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -31,6 +31,11 @@
class ConfigListener;
class GCContainer;
+class ContainerPlacer;
+class Image;
+class ImageRect;
+class Layout;
+class LayoutCell;
class ResizeGrip;
class WindowContainer;
@@ -60,7 +65,7 @@ class Window : public gcn::Window, gcn::WidgetListener
Window *parent = NULL, const std::string &skin = "graphics/gui/gui.xml");
/**
- * Destructor.
+ * Destructor. Deletes all the added widgets.
*/
~Window();
@@ -75,18 +80,6 @@ class Window : public gcn::Window, gcn::WidgetListener
void draw(gcn::Graphics *graphics);
/**
- * Adds a widget to the window. The widget will be deleted by the
- * window.
- */
- void add(gcn::Widget *w);
-
- /**
- * Adds a widget to the window and also specifices its position. The
- * widget will be deleted by the window.
- */
- void add(gcn::Widget *w, int x, int y);
-
- /**
* Sets the size of this window.
*/
void setContentSize(int width, int height);
@@ -221,26 +214,56 @@ class Window : public gcn::Window, gcn::WidgetListener
* Don't forget to set these default values and resizable before
* calling this function.
*/
- virtual void loadWindowState();
+ void loadWindowState();
/**
* Set the default win pos and size.
* (which can be different of the actual ones.)
*/
- virtual void setDefaultSize(int defaultX, int defaultY,
- int defaultWidth, int defaultHeight);
+ void setDefaultSize(int defaultX, int defaultY,
+ int defaultWidth, int defaultHeight);
/**
* Reset the win pos and size to default. Don't forget to set defaults
* first.
*/
- virtual void resetToDefaultSize();
+ void resetToDefaultSize();
+
+ /**
+ * Gets the layout handler for this window.
+ */
+ Layout &getLayout();
+
+ /**
+ * Computes the position of the widgets according to the current
+ * layout. Resizes the window so that the layout fits. Deletes the
+ * layout.
+ * @param w if non-zero, force the window to this width.
+ * @param h if non-zero, force the window to this height.
+ * @note This function is meant to be called with fixed-size windows.
+ */
+ void reflowLayout(int w = 0, int h = 0);
/**
* Loads a window skin
*/
void loadSkin(const std::string filename);
+ /**
+ * Adds a widget to the window and sets it at given cell.
+ */
+ LayoutCell &place(int x, int y, gcn::Widget *, int w = 1, int h = 1);
+
+ /**
+ * Returns a proxy for adding widgets in an inner table of the layout.
+ */
+ ContainerPlacer getPlacer(int x, int y);
+
+ protected:
+ /** The window container windows add themselves to. */
+ static WindowContainer *windowContainer;
+
+ private:
enum ResizeHandles
{
TOP = 0x01,
@@ -249,7 +272,6 @@ class Window : public gcn::Window, gcn::WidgetListener
LEFT = 0x08
};
- protected:
/**
* Determines if the mouse is in a resize area and returns appropriate
* resize handles. Also initializes drag offset in case the resize
@@ -264,6 +286,7 @@ class Window : public gcn::Window, gcn::WidgetListener
GCContainer *mChrome; /**< Contained container */
ResizeGrip *mGrip; /**< Resize grip */
Window *mParent; /**< The parent window */
+ Layout *mLayout; /**< Layout handler */
std::string mWindowName; /**< Name of the window */
bool mShowTitle; /**< Window has a title bar */
bool mModal; /**< Window is modal */
@@ -280,9 +303,6 @@ class Window : public gcn::Window, gcn::WidgetListener
int mDefaultHeight; /**< Default window height */
std::string mSkin; /**< Name of the skin to use */
- /** The window container windows add themselves to. */
- static WindowContainer *windowContainer;
-
/**
* The config listener that listens to changes relevant to all windows.
*/