// 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 WGLOBAL_H_
#define WGLOBAL_H_

#include <Wt/WFlags>

namespace Wt {
  class JSlot;
  class WAbstractToggleButton;
  class WAnchor;
  class WApplication;
  class WBorder;
  class WBreak;
  class WButtonGroup;
  class WCheckBox;
  class WColor;
  class WComboBox;
  class WCompositeWidget;
  class WContainerWidget;
  class WCssDecorationStyle;
  class WCssStyleSheet;
  class WDoubleValidator;
  class WEnvironment;
  class WMouseEvent;
  class WKeyEvent;
  class WFileResource;
  class WFileUpload;
  class WFont;
  class WFormWidget;
  class WGroupBox;
  class WIconPair;
  class WImage;
  class WInPlaceEdit;
  class WInteractWidget;
  class WIntValidator;
  class WLabel;
  class WLength;
  class WLineEdit;
  class WMenu;
  class WMenuItem;
  class WMessageResourceBundle;
  class WObject;
  class WPushButton;
  class WRadioButton;
  class WRegExpValidator;
  class WResource;
  class WScrollArea;
  class WScrollBar;
  class WSelectionBox;
  class WStackedWidget;
  class WString;
  class WSuggestionPopup;
  class WTable;
  class WTableCell;
  class WText;
  class WTextArea;
  class WTimer;
  class WTreeNode;
  class WValidationStatus;
  class WValidator;
  class WWebWidget;
  class WWidget;

/*! \brief Enumeration that indicates a direction.
 */
enum Orientation { Horizontal = 0x1, //!< Horizontal
		   Vertical   = 0x2  //!< Vertical
};
W_DECLARE_OPERATORS_FOR_FLAGS(Orientation)

/*! \brief Enumeration that indicates a standard button.
 *
 * Multiple buttons may be specified by logically or'ing these values
 * together, e.g.
 * \code
 * Ok | Cancel
 * \endcode
 *
 * \sa WMessageBox
 */
enum StandardButton {
  NoButton = 0x00,  //!< No button
  Ok = 0x01,        //!< An OK button.
  Cancel = 0x02,    //!< A Cancel button.
  Yes = 0x04,       //!< A Yes button.
  No = 0x08,        //!< A No button.
  Abort = 0x10,     //!< An Abort button.
  Retry = 0x20,     //!< A Retry button.
  Ignore = 0x40,    //!< An Ignore button.
  YesAll = 0x80,    //!< A Yes-to-All button.
  NoAll = 0x100     //!< A No-to-All button.
};
W_DECLARE_OPERATORS_FOR_FLAGS(StandardButton)

/*! \brief Enumeration that indiciates a standard icon.
 *
 * \note Not used yet.
 */
enum Icon {
  NoIcon = 0,       //!< No icon
  Information = 1,  //!< An information icon <i>(not implemented)</i>
  Warning = 2,      //!< An warning icon <i>(not implemented)</i>
  Critical = 3,     //!< An critical icon <i>(not implemented)</i>
  Question = 4      //!< An question icon <i>(not implemented)</i>
};

/*! \brief Enumeration that indicates how items may be selected.
 *
 * \sa WTreeView::setSelectionMode()
 */
enum SelectionMode { NoSelection = 0,      //!< No selections
		     SingleSelection = 1,  //!< Single selection only
		     ExtendedSelection = 3 //!< Multiple selection
};

/*! \brief Enumeration that indicates what is being selected.
 *
 * \sa WTreeView::setSelectionBehavior()
 */
enum SelectionBehavior { SelectItems = 0,    //!< Select single items
			 SelectRows = 1      //!< Select only rows
			 /*, SelectColumns */
};

/*! \brief Enumeration that indicates how to change a selection.
 *
 * \sa WTreeView::select()
 */
enum SelectionFlag {
  Select = 1,          //!< Add to selection
  Deselect = 2,        //!< Remove from selection
  ToggleSelect = 3,    //!< Toggle in selection
  ClearAndSelect = 4   //!< Clear selection and add single item
};

/*! \brief Enumeration that indicates a relative location.
 *
 * Values of CenterX, CenterY, and CenterXY are only valid for
 * WCssDecorationStyle::setBackgroundImage()
 *
 * \sa WWidget::setMargin(const WLength& x, WFlags<Side> sides)
 * \sa WWidget::setOffsets(const WLength& x, WFlags<Side> sides)
 * \sa WWidget::setFloatSide(Side s)
 * \sa WWidget::setClearSides(WFlags<Side> sides)
 * \sa WContainerWidget::setPadding(const WLength& x, WFlags<Side> sides)
 * \sa WCssDecorationStyle::setBackgroundImage()
 */
enum Side {
  Top = 0x1,                          //!< Top side
  Bottom = 0x2,                       //!< Bottom side
  Left = 0x4,                         //!< Left side
  Right = 0x8,                        //!< Right side
  CenterX = 0x10,                     //!< Center horiziontally
  CenterY = 0x20                      //!< Center vertically
};

W_DECLARE_OPERATORS_FOR_FLAGS(Side)

/** \brief No side */
static const WFlags<Side> None = 0;
/** \brief (CenterX | CenterY) */
static const WFlags<Side> CenterXY = CenterX | CenterY;
/** \brief (Left | Right) */
static const WFlags<Side> Horizontals = Left | Right;
/** \brief (Top | Bottom) */
static const WFlags<Side> Verticals = Top | Bottom;
/** \brief All sides */
static const WFlags<Side> All = Top | Bottom | Left | Right;

/*! \brief Enumeration that specifies a horizontal or a vertical alignment.
 *
 * The vertical alignment flags are AlignBaseline, AlignSub, AlignSuper,
 * AlignTop, AlignTextTop, AlignMiddle, AlignBottom and AlignTextBottom.
 * The horizontal alignment flags are AlignLeft, AlignRight, AlignCenter
 * and AlignJustify. Functions expecting either horizontal or vertical
 * alignment flags throw an exception when they are called with the wrong
 * alignment flag.
 *
 * When used with setVerticalAlignment(), this applies only
 * to inline widgets and determines how to position itself on the
 * current line, with respect to sibling inline widgets.
 *
 * When used with WTableCell::setContentAlignment(), this determines the
 * vertical alignment of contents within the table cell.
 *
 * When used with WPainter::drawText(), this determines the horizontal and
 * vertical alignment of the text with respect to the bounding rectangle.
 *
 * When used with WContainerWidget::setContentAlignment(), this specifies how
 * contents should be aligned horizontally within the container.
 *
 * Not all values are applicable in all situations. The most commonly
 * used values are AlignLeft, AlignCenter, AlignRight, AlignBottom,
 * AlignMiddle and AlignTop.
 */
enum AlignmentFlag {
  /*! \brief Align to the left
   */
  AlignLeft=0x1,
  /*! \brief Align to the right
   */
  AlignRight=0x2,
  /*! \brief Align horizontally in the center
   */
  AlignCenter=0x4,
  /*! \brief Justify left and right
   */
  AlignJustify=0x8,
  /*! \brief Align at baseline (default alignment).
   */
  AlignBaseline=0x10,
  /*! \brief Align below the baseline (as if subscript).
   */
  AlignSub=0x20,
  /*! \brief Align above the baseline (as if superscript).
   */
  AlignSuper=0x40,
  /*! \brief Align top of widget with top of tallest sibling widget.
   */
  AlignTop=0x80,
  /*! \brief Align top of widget with the top of the parent widget's font.
   */
  AlignTextTop=0x100,
  /*! \brief Align vertically the middle to the middle of the parent widget.
   */
  AlignMiddle=0x200,
  /*! \brief Align bottom of widget to the bottom of the lowest sigling widget.
   */
  AlignBottom=0x400,
  /*! \brief Align bottom of widget to the bottom of parent widget's font.
   */
  AlignTextBottom=0x800,
  AlignLength=0x1000  // ?
};

W_DECLARE_OPERATORS_FOR_FLAGS(AlignmentFlag)

/*! \brief Combination of all horizontal alignment flags */
static const WFlags<AlignmentFlag> AlignHorizontalMask
  = AlignLeft | AlignRight | AlignCenter | AlignJustify;

/*! \brief Combination of all vertical alignment flags */
static const WFlags<AlignmentFlag> AlignVerticalMask
  = AlignBaseline | AlignSub | AlignSuper | AlignTop | AlignTextTop | AlignMiddle | AlignBottom | AlignTextBottom | AlignLength;

/*! \brief Enumeration that specifies a layout mechanism for a widget.
 *
 * The layout mechanism determines how the widget positions itself relative
 * to the parent or sibling widgets.
 *
 * \sa WWidget::setPositionScheme(PositionScheme scheme)
 */
enum PositionScheme {
  /*! \brief Static position scheme.
   *
   *  The widget is layed-out with other \link Wt::Static
   *  Static \endlink and \link Wt::Relative Relative \endlink
   *  sibling widgets, one after another.
   *
   *  Inline widgets are layed out in horizontal lines (like text),
   *  wrapping around at the end of the line to continue on the next
   *  line. Block widgets are stacked vertically.
   *
   *  Static widgets may also float to the left or right border,
   *  using setFloatSide().
   */
  Static,
  /*! \brief Relative position scheme.
   *
   *  The widget is first layed out according to Static layout
   *  rules, but after layout, the widget may be offset relative to
   *  where it would be in a static layout, using setOffsets().
   *
   *  Another common use of a Relative position scheme (even with no
   *  specified offsets) is to provide a new reference coordinate
   *  system for Absolutely positioned widgets.
   */
  Relative,
  /*! \brief Absolute position scheme.
   *
   *  The widget is positioned at an absolute position
   *  with respect to the nearest ancestor widget that is either:
   *  <ul>
   *    <li> a WTableCell </li>
   *    <li> or has a position scheme that is \link Wt::Relative
   *  Relative\endlink or \link Wt::Absolute Absolute\endlink. </li>
   *  </ul>
   */
  Absolute,
  /*! \brief Fixed position scheme.
   *
   *  The widget is positioned at fixed position with respect to
   *  the browser's view-pane.
   */
  Fixed
};

/*! \brief Enumeration for a cursor style
 *
 * \sa WCssDecorationStyle::setCursor(), WAbstractArea::setCursor()
 */
enum Cursor {
  ArrowCursor,        //!< Arrow, CSS 'default' cursor
  AutoCursor,         //!< Cursor chosen by the browser, CSS 'auto' cursor.
  CrossCursor,        //!< Crosshair, CSS 'cross' cursor
  PointingHandCursor, //!< Pointing hand, CSS 'pointer' cursor
  OpenHandCursor,     //!< Open hand, CSS 'move' cursor
  WaitCursor,         //!< Wait, CSS 'wait' cursor
  IBeamCursor,        //!< Text edit, CSS 'text' cursor
  WhatsThisCursor     //!< Help, CSS 'help' cursor
};

/*! \brief Enumeration that indicates a character encoding.
 *
 * Character encodings are used to represent characters in a stream of
 * bytes.
 *
 * \relates WString
 */
enum CharEncoding {
  /*! \brief Each byte represents a character, using the local
   *         server-side system locale
   */
  LocalEncoding,
  /*! \brief The byte stream represents unicode characters encoded using UTF-8.
   */
  UTF8
};

/*! \brief Enumeration that indicates a pen style.
 *
 * \ingroup painting
 *
 * \relates WPen
 */
enum PenStyle {
  NoPen,          //!< Do not stroke
  SolidLine,      //!< Stroke with a solid line
  DashLine,       //!< Stroked with a dashed line
  DotLine,        //!< Stroke with a dotted line
  DashDotLine,    //!< Stroke with a dash dot line
  DashDotDotLine  //!< Stroke with a dash dot dot line
};

/*! \brief Enumeration that indicates how line end points are rendered
 *
 * \ingroup painting
 *
 * \relates WPen
 */
enum PenCapStyle {
  FlatCap,        //!< Flat ends
  SquareCap,      //!< Square ends (prolongs line with half width)
  RoundCap        //!< Round ends (terminates with a half circle)
};

/*! \brief Enumeration that indicates how line joins are rendered.
 *
 * \ingroup painting
 *
 * \relates WPen
 */
enum PenJoinStyle {
  MiterJoin,      //!< Pointy joins
  BevelJoin,      //!< Squared-off joins
  RoundJoin       //!< Rounded joins
};

/*! \brief Enumeration that indicates a fill style.
 *
 * \ingroup painting
 *
 * \relates WBrush
 */
enum WBrushStyle {
  NoBrush = 0,      //!< Do not fill
  SolidPattern = 1  //!< Fill with a solid color
};

/*! \brief Enumeration that specifies where the target of an anchor should
 *         be displayed.
 *
 * \sa WAnchor::setTarget()
 */
enum AnchorTarget {
  TargetSelf,      //!< Show Instead of the application
  TargetThisWindow,//!< Show in the top level frame of the application window
  TargetNewWindow  //!< Show in a separate new tab or window
};

/*! \brief Enumeration that indicates the text format.
 *
 * \sa WText::setTextFormat()
 */
enum TextFormat {
  XHTMLText,       //!< Format text as XSS-safe XHTML markup'ed text
  XHTMLUnsafeText, //!< Format text as XHTML markup'ed text
  PlainText        //!< Format text as plain text
};

/*! \brief Enumeration for predefined colors
 *
 * \ingroup style
 */
enum GlobalColor {
  /*! \brief Color white.
   */
  white,
  /*! \brief Color black.
   */
  black,
  /*! \brief Color red.
   */
  red,
  /*! \brief Color dark red.
   */
  darkRed,
  /*! \brief Color green.
   */
  green,
  /*! \brief Color dark green.
   */
  darkGreen,
  /*! \brief Color blue.
   */
  blue,
  /*! \brief Color dark blue.
   */
  darkBlue,
  /*! \brief Color cyan.
   */
  cyan,
  /*! \brief Color dark cyan.
   */
  darkCyan,
  /*! \brief Color magenta.
   */
  magenta,
  /*! \brief Color dark magenta.
   */
  darkMagenta,
  /*! \brief Color yellow.
   */
  yellow,
  /*! \brief Color dark yellow.
   */
  darkYellow,
  /*! \brief Color medium gray.
   */
  gray,
  /*! \brief Color dark gray.
   */
  darkGray,
  /*! \brief Color light gray.
   */
  lightGray,
  /*! \brief Color transparent.
   */
  transparent
};

/*! \brief Enumeration for keyboard modifiers
 *
 * \sa WMouseEvent::modifiers(), WKeyEvent::modifiers()
 *
 * \ingroup signalslot
 */
enum KeyboardModifier {
  NoModifier = 0x0,       //!< No modifiers
  ShiftModifier = 0x1,    //!< Shift key pressed
  ControlModifier = 0x2,  //!< Control key pressed
  AltModifier = 0x4,      //!< Alt key pressed
  MetaModifier = 0x8      //!< Meta key pressed ("Windows" or "Command" (Mac) key)
};

W_DECLARE_OPERATORS_FOR_FLAGS(KeyboardModifier)

/*! \brief Enumeration for key codes
 *
 * These are key codes that identify a key on a keyboard. All keys
 * listed here can be identified across all browsers and (Western)
 * keyboards. A %Key is returned by WKeyEvent::key(). If you want to
 * identify a character, you should use the WKeyEvent::charCode()
 * method instead.
 *
 * \sa WInteractWidget::keyWentDown, WInteractWidget::keyWentUp
 *
 * \ingroup signalslot
 */
enum Key {
  Key_unknown = 0,     //!< Unknown key.
  Key_Enter = 13,      //!< Enter key.
  Key_Tab = 9,         //!< Tab key.
  Key_Backspace = 8,   //!< Backspace key.
  Key_Shift = 16,      //!< Shift key.
  Key_Control = 17,    //!< Control key.
  Key_Alt = 18,        //!< Alt key.
  Key_PageUp = 33,     //!< Page up key.
  Key_PageDown = 34,   //!< Page down key.
  Key_End = 35,        //!< End key.
  Key_Home = 36,       //!< Home key.
  Key_Left = 37,       //!< Left arrow key.
  Key_Up = 38,         //!< Up arrow key.
  Key_Right = 39,      //!< Right arrow key.
  Key_Down = 40,       //!< Down arrow key.
  Key_Insert = 45,     //!< Insert key.
  Key_Delete = 46,     //!< Delete key.
  Key_Escape = 27,     //!< Escape key.
  Key_F1 = 112,        //!< F1 function key.
  Key_F2 = 113,        //!< F2 function key.
  Key_F3 = 114,        //!< F3 function key.
  Key_F4 = 115,        //!< F4 function key.
  Key_F5 = 116,        //!< F5 function key.
  Key_F6 = 117,        //!< F6 function key.
  Key_F7 = 118,        //!< F7 function key.
  Key_F8 = 119,        //!< F8 function key.
  Key_F9 = 120,        //!< F9 function key.
  Key_F10 = 121,       //!< F10 function key.
  Key_F11 = 122,       //!< F11 function key.
  Key_F12 = 123,       //!< F12 function key.
  Key_Space = ' ',     //!< Space
  Key_A = 'A',         //!< 'A' key
  Key_B = 'B',         //!< 'B' key
  Key_C = 'C',         //!< 'C' key
  Key_D = 'D',         //!< 'D' key
  Key_E = 'E',         //!< 'E' key
  Key_F = 'F',         //!< 'F' key
  Key_G = 'G',         //!< 'G' key
  Key_H = 'H',         //!< 'H' key
  Key_I = 'I',         //!< 'I' key
  Key_J = 'J',         //!< 'J' key
  Key_K = 'K',         //!< 'K' key
  Key_L = 'L',         //!< 'L' key
  Key_M = 'M',         //!< 'M' key
  Key_N = 'N',         //!< 'N' key
  Key_O = 'O',         //!< 'O' key
  Key_P = 'P',         //!< 'P' key
  Key_Q = 'Q',         //!< 'Q' key
  Key_R = 'R',         //!< 'R' key
  Key_S = 'S',         //!< 'S' key
  Key_T = 'T',         //!< 'T' key
  Key_U = 'U',         //!< 'U' key
  Key_V = 'V',         //!< 'V' key
  Key_W = 'W',         //!< 'W' key
  Key_X = 'X',         //!< 'X' key
  Key_Y = 'Y',         //!< 'Y' key
  Key_Z = 'Z'          //!< 'Z' key
};

/*! \brief Enumeration for the check state of a check box.
 *
 * \sa WCheckBox
 */
enum CheckState {
  Unchecked,        //!< Unchecked
  PartiallyChecked, //!< Partially checked (for a tri-state checkbox)
  Checked           //!< Checked
};

/*! \brief Enumeration that indicates how to change a selection.
 *
 * \sa WPaintedWidget::update(), WPaintDevice::paintFlags()
 */
enum PaintFlag {
  PaintUpdate = 0x1 //!< The canvas is not cleared, but further painted on.
};

W_DECLARE_OPERATORS_FOR_FLAGS(PaintFlag);

/*! \brief Enumeration that indicates a %Wt entrypoint type.
 *
 * An entry point binds a behavior to a public URL. Only the wthttpd
 * connector currently supports multiple entry points.
 */
enum EntryPointType {
  /*! \brief Specifies a full-screen application.
   *
   * A full screen application manages the entire browser window and
   * provides its own HTML page.
   *
   * \sa WServer::addEntryPoint(), WApplication::root()
   */
  Application,

  /*! \brief Specifies an application that manages one or more widgets.
   *
   * A widget set application is part of an existing HTML page. One or
   * more HTML elements in that web page may be bound to widgets managed
   * by the application.
   *
   * A widgetset application presents itself as a JavaScript file,
   * and therefore should be embedded in the web page using a
   * &lt;script&gt; tag, from within the &lt;body&gt; (since it
   * needs access to the &lt;body&gt;).
   *
   * \note A WidgetSet application requires JavaScript support
   *
   * \sa WServer::addEntryPoint(), WApplication::bindWidget()
   */
  WidgetSet,

  /*! \brief Specifies a static resource.
   *
   * A static resource binds a WResource to a public URL.
   *
   * \sa WServer::addResource()
   */
  StaticResource
};

enum RenderFlag {
  RenderFull    = 0x1,
  RenderUpdate  = 0x2
};

W_DECLARE_OPERATORS_FOR_FLAGS(RenderFlag)

}

#endif // WGLOBALS_H_
