// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WBORDER_LAYOUT_H_
#define WBORDER_LAYOUT_H_

#include <WLayout>

namespace Wt {

/*! \class WBorderLayout WBorderLayout WBorderLayout
 *  \brief A layout manager which divides the container region in five regions.
 *
 * The five regions are composed of:
 * <pre>
     ------------------------------------
     |              North               |
     ------------------------------------
     |      |                    |      |
     | West |       Center       | East |
     |      |                    |      |
     ------------------------------------
     |              South               |
     ------------------------------------
 * </pre>
 *
 * Each region may hold no more than one widget, and for all but the
 * Center region, the widget is optional.
 *
 * Widgets in the North and South regions need to have their height
 * defined, and widgets in the West ad East regions their width. The
 * Center widget takes all available remaining space.
 */
class WT_API WBorderLayout : public WLayout
{
public:
  /*! \brief Enumeration of possible positions in the layout.
   */
  enum Position {
    North,  //!< North (top)
    East,   //!< East (left)
    South,  //!< South (bottom)
    West,   //!< West (right)
    Center  //!< Center
  };

  /*! \brief Create a new border layout.
   */
  WBorderLayout(WWidget *parent = 0);

  /*! \brief Remove a border layout.
   */
  ~WBorderLayout();

  virtual void addItem(WLayoutItem *item);
  virtual void removeItem(WLayoutItem *item);
  virtual WLayoutItem *itemAt(int index) const;
  virtual int indexOf(WLayoutItem *item) const;
  virtual int count() const;

  /*! \brief Add a widget to the given position.
   *
   * Only one widget per position is supported.
   *
   * \sa addWidget(WLayoutItem *, Position)
   */
  void addWidget(WWidget *widget, Position position);

  /*! \brief Add a layout item to the given position.
   *
   * Only one widget per position is supported.
   */
  void add(WLayoutItem *item, Position position);

  /*! \brief Return the position at which the given layout item is set.
   */
  Position position(WLayoutItem *item) const;

private:
  WLayoutItem *items_[5];
};

}

#endif // WBORDER_LAYOUT_H_
