#ifndef SO@GUI@_BASIC_H
#define SO@GUI@_BASIC_H

// NB: this is not a pure configure-input file, it's also a config header...

/**************************************************************************\
 * Copyright (c) Kongsberg Oil & Gas Technologies AS
 * 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 copyright holder 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
 * HOLDER 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.
\**************************************************************************/

// *************************************************************************

/* Some useful inline template functions:
 *   So@Gui@Min(Val1, Val2)       - returns minimum value
 *   So@Gui@Max(Val1, Val2)       - returns maximum value
 *   So@Gui@Clamp(Val, Min, Max)  - returns clamped value
 *   So@Gui@Swap(Val1, Val2)      - swaps the two values (no return value)
 */

template <class Type>
inline Type So@Gui@Abs(Type Val) {
  return (Val < 0) ? -Val : Val;
}

template <class Type>
inline Type So@Gui@Min(Type a, Type b) {
  return (b < a) ? b : a;
}

template <class Type>
inline Type So@Gui@Max(Type a, Type b) {
  return (b > a) ? b : a;
}

template <class Type>
inline Type So@Gui@Clamp(Type val, Type min, Type max) {
  return So@Gui@Max(min, So@Gui@Min(max, val));
}

template <class Type>
inline void So@Gui@Swap(Type & a, Type & b) {
  Type t = a; a = b; b = t;
}

// *************************************************************************

#define __COIN_SO@GUI@__

#if ! defined(SO@GUI@_MAJOR_VERSION)
#define SO@GUI@_MAJOR_VERSION ${SO@GUI@_MAJOR_VERSION}
#endif /* ! SO@GUI@_MAJOR_VERSION */
#if ! defined(SO@GUI@_MINOR_VERSION)
#define SO@GUI@_MINOR_VERSION ${SO@GUI@_MINOR_VERSION}
#endif /* ! SO@GUI@_MINOR_VERSION */
#if ! defined(SO@GUI@_MICRO_VERSION)
#define SO@GUI@_MICRO_VERSION ${SO@GUI@_MICRO_VERSION}
#endif /* ! SO@GUI@_MICRO_VERSION */
#if ! defined(SO@GUI@_BETA_VERSION)
#define SO@GUI@_BETA_VERSION ${SO@GUI@_BETA_VERSION}
#endif /* ! SO@GUI@_BETA_VERSION */
#if ! defined(SO@GUI@_VERSION)
#define SO@GUI@_VERSION "${SO@GUI@_VERSION}"
#endif /* ! SO@GUI@_VERSION */

// *************************************************************************

/* Precaution to avoid an error easily made by the application programmer. */
#ifdef SO@GUI@_DLL_API
# error Leave the internal SO@GUI@_DLL_API define alone.
#endif /* SO@GUI@_DLL_API */

/*
  On Microsoft Windows platforms, one of these defines must always be set when
  building application programs:

   - "SO@GUI@_DLL", when the application programmer is using the
     library in the form of a dynamic link library (DLL)

   - "SO@GUI@_NOT_DLL", when the application programmer is using the
     library in the form of a static object library (LIB)

  Note that either SO@GUI@_DLL or SO@GUI@_NOT_DLL _must_ be defined by
  the application programmer on Microsoft Windows platforms, otherwise the
  #error statement will be hit. Set up one or the other of these two
  defines in your compiler environment according to how the library
  was built -- as a DLL (use "SO@GUI@_DLL") or as a LIB (use
  "SO@GUI@_NOT_DLL").

  (Setting up defines for the compiler is typically done by either
  adding something like "/DSO@GUI@_DLL" to the compiler's argument
  line (for command-line build processes), or by adding the define to
  the list of preprocessor symbols in your IDE GUI (in the MSVC IDE,
  this is done from the "Project"->"Settings" menu, choose the "C/C++"
  tab, then "Preprocessor" from the drop down list and add the
  appropriate define)).

  It is extremely important that the application programmer uses the
  correct define, as using "SO@GUI@_NOT_DLL" when "SO@GUI@_DLL" is
  correct is likely to cause mysterious crashes.
 */
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
# ifdef SO@GUI@_INTERNAL
#  ifdef SO@GUI@_MAKE_DLL
#   define SO@GUI@_DLL_API __declspec(dllexport)
#  endif /* SO@GUI@_MAKE_DLL */
# else /* !SO@GUI@_INTERNAL */
#  ifdef SO@GUI@_DLL
#   define SO@GUI@_DLL_API __declspec(dllimport)
#  else /* !SO@GUI@_DLL */
#   ifndef SO@GUI@_NOT_DLL
#    error Define either SO@GUI@_DLL or SO@GUI@_NOT_DLL as appropriate for your linkage! See Inventor/@Gui@/So@Gui@Basic.h for further instructions.
#   endif /* SO@GUI@_NOT_DLL */
#  endif /* !SO@GUI@_DLL */
# endif /* !SO@GUI@_MAKE_DLL */
#endif /* Microsoft Windows */

/* Empty define to avoid errors when _not_ compiling an Microsoft Windows DLL. */
#ifndef SO@GUI@_DLL_API
# define SO@GUI@_DLL_API
#endif /* !SO@GUI@_DLL_API */

#ifndef GUI_TOOLKIT_VERSION
#define GUI_TOOLKIT_VERSION "@GUI_TOOLKIT_VERSION@"
#endif /* GUI_TOOLKIT_VERSION */

#endif // ! SO@GUI@_BASIC_H
