// Vaca - Visual Application Components Abstraction // Copyright (c) 2005-2009 David Capello // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in // the documentation and/or other materials provided with the // distribution. // * Neither the name of the author nor the names of its contributors // may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef VACA_BASE_H #define VACA_BASE_H // If there are not a defined target (like VACA_WINDOWS)... #if !defined(VACA_WINDOWS) && \ !defined(VACA_ALLEGRO) && \ !defined(VACA_SDL) && \ !defined(VACA_GTK) && \ !defined(VACA_X11) // ...we define VACA_DEFAULT_PLATFORM to specify that the default // target will be used #define VACA_DEFAULT_TARGET #endif // If we are in Windows compiler #if defined(_MSC_VER) || \ defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || \ defined(WIN64) || defined(_WIN64) || defined(__WIN64__) #ifdef VACA_DEFAULT_TARGET #define VACA_WINDOWS #endif // We define a macro to know that we can use Windows API #define VACA_ON_WINDOWS #else #ifdef VACA_DEFAULT_TARGET #define VACA_ALLEGRO // TODO change this to VACA_X11 when X11 support be completed #endif #define VACA_ON_UNIXLIKE #endif #include #include "Vaca/Enum.h" namespace Vaca { #define VACA_VERSION 0 #define VACA_SUB_VERSION 0 #define VACA_WIP_VERSION 8 /** @def VACA_DLL @brief Used to export/import symbols to/from the dynamic library. */ #ifdef VACA_WINDOWS #ifdef VACA_STATIC #define VACA_DLL #else #ifdef VACA_SRC #define VACA_DLL __declspec(dllexport) #else #define VACA_DLL __declspec(dllimport) #endif #endif #else #define VACA_DLL #endif /** Returns the minimum of @a x and @a y. @note It is just like @b std::min, but there are problems in MSVC++ because a macro named @b min. @see max_value, clamp_value */ template inline T min_value(T x, T y) { return x < y ? x: y; } /** Returns the maximum of @a x and @a y. @note It is just like @b std::max, but there are problems in MSVC++ because a macro named @b max. @see min_value, clamp_value */ template inline T max_value(T x, T y) { return x > y ? x: y; } /** Limits the posible values of @a x to the speficied range. If @a x is great than @a high, then @a high is returned, if @a x is less than @a low, then @a low is returned. In other case, @a x is in the range, and @a x is returned. @see min_value, max_value */ template inline T clamp_value(T x, T low, T high) { return x > high ? high: (x < low ? low: x); } /** A wide character used in a String. @see String, @ref page_tn_008 */ typedef wchar_t Char; /** String type used through the Vaca API. It is a std::wstring. @see Char, @ref page_tn_008 */ typedef std::wstring String; /** An identifier for an application's Command. @see Widget#onCommand, Command */ typedef unsigned int CommandId; /** An identifier for a Thread. */ typedef unsigned int ThreadId; // ====================================================================== /** It's like a namespace for Orientation. @see Orientation */ struct OrientationEnum { enum enumeration { Horizontal, Vertical }; static const enumeration default_value = Horizontal; }; /** Horizontal or vertical orientation. One of the following values: @li Orientation::Horizontal (default) @li Orientation::Vertical */ typedef Enum Orientation; // ====================================================================== /** It's like a namespace for TextAlign. @see TextAlign */ struct TextAlignEnum { enum enumeration { Left, Center, Right }; static const enumeration default_value = Left; }; /** Horizontal alignment. One of the following values: @li TextAlign::Left (default) @li TextAlign::Center @li TextAlign::Right */ typedef Enum TextAlign; // ====================================================================== /** It's like a namespace for VerticalAlign. @see VerticalAlign */ struct VerticalAlignEnum { enum enumeration { Top, Middle, Bottom }; static const enumeration default_value = Top; }; /** Vertical alignment. One of the following values: @li VerticalAlign::Top @li VerticalAlign::Middle @li VerticalAlign::Bottom */ typedef Enum VerticalAlign; // ====================================================================== /** It's like a namespace for Side. @see Side */ struct SideEnum { enum enumeration { Left, Top, Right, Bottom }; static const enumeration default_value = Left; }; /** A side. One of the following values: @li Side::Left @li Side::Top @li Side::Right @li Side::Bottom */ typedef Enum Side; // ====================================================================== /** It's like a namespace for Sides. @see Sides */ struct SidesEnumSet { enum { None = 0, Left = 1, Top = 2, Right = 4, Bottom = 8, All = Left | Top | Right | Bottom }; }; /** A set of sides. Zero or more of the following values: @li Sides::Left @li Sides::Top @li Sides::Right @li Sides::Bottom */ typedef EnumSet Sides; // ====================================================================== /** It's like a namespace for CardinalDirection. @see CardinalDirection */ struct CardinalDirectionEnum { enum enumeration { North, Northeast, East, Southeast, South, Southwest, West, Northwest }; static const enumeration default_value = North; }; /** A cardinal direction. One of the following values: @li CardinalDirection::North @li CardinalDirection::Northeast @li CardinalDirection::East @li CardinalDirection::Southeast @li CardinalDirection::South @li CardinalDirection::Southwest @li CardinalDirection::West @li CardinalDirection::Northwest */ typedef Enum CardinalDirection; // ====================================================================== /** Removes an @a element from the specified STL @a container. This routine removes the first ocurrence of @a element in @a container. It is just a helper function to avoid cryptic STL code. @tparam ContainerType A STL container type. @param container The container to be modified. @param element The element to be removed from the container. */ template void remove_from_container(ContainerType& container, typename ContainerType::const_reference element) { for (typename ContainerType::iterator it = container.begin(), end = container.end(); it != end; ) { if (*it == element) { it = container.erase(it); end = container.end(); } else ++it; } } // ====================================================================== // Forward declarations class Anchor; class AnchorLayout; class Application; class BandedDockArea; class BasicDockArea; class Bix; class BoxConstraint; class BoxLayout; class Brush; class Button; class ButtonBase; class CancelableEvent; class CheckBox; class ChildEvent; class ClientLayout; class Clipboard; class CloseEvent; class Color; class ColorDialog; class ComboBox; class Command; class CommandEvent; class CommandsClient; class CommonDialog; class Component; class ConditionVariable; class Constraint; class Cursor; class CustomButton; class CustomLabel; class Dialog; class DockArea; class DockBar; class DockFrame; class DockInfo; class DragListBox; class DropFilesEvent; class Event; class Exception; class FileDialog; class FindTextDialog; class FocusEvent; class Font; class FontDialog; class FontMetrics; class Frame; class Graphics; class GraphicsPath; class GroupBox; class HttpRequest; class HttpRequestException; class Icon; class Image; class ImageHandle; class ImageList; class ImagePixels; class KeyEvent; class Label; class Layout; class LayoutEvent; class LinkLabel; class ListBox; class ListColumn; class ListItem; class ListView; class ListViewEvent; class MdiChild; class MdiClient; class MdiFrame; class MdiListMenu; class Menu; class MenuBar; class MenuItem; class MenuItemEvent; class MenuSeparator; class Message; class MouseEvent; class MsgBox; class Mutex; class Node; class NonCopyable; class OpenFileDialog; class PaintEvent; class Pen; class Point; class PopupMenu; class PreferredSizeEvent; class ProgressBar; class Property; class RadioButton; class RadioGroup; class ReBar; class ReBarBand; class Rect; class Referenceable; class Region; class ResizeEvent; class ResourceId; class SaveFileDialog; class SciEdit; class SciRegister; class ScopedLock; class ScreenGraphics; class ScrollEvent; class ScrollInfo; class Separator; class SetCursorEvent; class Size; class Slider; class SpinButton; class Spinner; class SplitBar; class StatusBar; class System; class Tab; class TabBase; class TabPage; class TextEdit; class Thread; class TimePoint; class Timer; class ToggleButton; class ToolBar; class ToolButton; class ToolSet; class TreeNode; class TreeView; class TreeViewEvent; class TreeViewIterator; class Widget; class WidgetClassName; template class SharedPtr; // ====================================================================== // Smart Pointers /** @defgroup smart_pointers Smart Pointers @{ */ typedef SharedPtr AnchorPtr; typedef SharedPtr AnchorLayoutPtr; typedef SharedPtr BandedDockAreaPtr; typedef SharedPtr BasicDockAreaPtr; typedef SharedPtr BixPtr; typedef SharedPtr BoxConstraintPtr; typedef SharedPtr BoxLayoutPtr; typedef SharedPtr