SoXt  1.4.1
Coin3D GUI toolkit binding
Loading...
Searching...
No Matches
SoXtBasic.h
1#ifndef SOXT_BASIC_H
2#define SOXT_BASIC_H
3
4// NB: this is not a pure configure-input file, it's also a config header...
5
6/**************************************************************************\
7 * Copyright (c) Kongsberg Oil & Gas Technologies AS
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
13 *
14 * Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * Neither the name of the copyright holder nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36\**************************************************************************/
37
38// *************************************************************************
39
40/* Some useful inline template functions:
41 * SoXtMin(Val1, Val2) - returns minimum value
42 * SoXtMax(Val1, Val2) - returns maximum value
43 * SoXtClamp(Val, Min, Max) - returns clamped value
44 * SoXtSwap(Val1, Val2) - swaps the two values (no return value)
45 */
46
47template <class Type>
48inline Type SoXtAbs(Type Val) {
49 return (Val < 0) ? -Val : Val;
50}
51
52template <class Type>
53inline Type SoXtMin(Type a, Type b) {
54 return (b < a) ? b : a;
55}
56
57template <class Type>
58inline Type SoXtMax(Type a, Type b) {
59 return (b > a) ? b : a;
60}
61
62template <class Type>
63inline Type SoXtClamp(Type val, Type min, Type max) {
64 return SoXtMax(min, SoXtMin(max, val));
65}
66
67template <class Type>
68inline void SoXtSwap(Type & a, Type & b) {
69 Type t = a; a = b; b = t;
70}
71
72// *************************************************************************
73
74#define __COIN_SOXT__
75
76#if ! defined(SOXT_MAJOR_VERSION)
77#define SOXT_MAJOR_VERSION 1
78#endif /* ! SOXT_MAJOR_VERSION */
79#if ! defined(SOXT_MINOR_VERSION)
80#define SOXT_MINOR_VERSION 4
81#endif /* ! SOXT_MINOR_VERSION */
82#if ! defined(SOXT_MICRO_VERSION)
83#define SOXT_MICRO_VERSION 1
84#endif /* ! SOXT_MICRO_VERSION */
85#if ! defined(SOXT_BETA_VERSION)
86#define SOXT_BETA_VERSION
87#endif /* ! SOXT_BETA_VERSION */
88#if ! defined(SOXT_VERSION)
89#define SOXT_VERSION "1.4.1"
90#endif /* ! SOXT_VERSION */
91
92// *************************************************************************
93
94/* Precaution to avoid an error easily made by the application programmer. */
95#ifdef SOXT_DLL_API
96# error Leave the internal SOXT_DLL_API define alone.
97#endif /* SOXT_DLL_API */
98
99/*
100 On Microsoft Windows platforms, one of these defines must always be set when
101 building application programs:
102
103 - "SOXT_DLL", when the application programmer is using the
104 library in the form of a dynamic link library (DLL)
105
106 - "SOXT_NOT_DLL", when the application programmer is using the
107 library in the form of a static object library (LIB)
108
109 Note that either SOXT_DLL or SOXT_NOT_DLL _must_ be defined by
110 the application programmer on Microsoft Windows platforms, otherwise the
111 #error statement will be hit. Set up one or the other of these two
112 defines in your compiler environment according to how the library
113 was built -- as a DLL (use "SOXT_DLL") or as a LIB (use
114 "SOXT_NOT_DLL").
115
116 (Setting up defines for the compiler is typically done by either
117 adding something like "/DSOXT_DLL" to the compiler's argument
118 line (for command-line build processes), or by adding the define to
119 the list of preprocessor symbols in your IDE GUI (in the MSVC IDE,
120 this is done from the "Project"->"Settings" menu, choose the "C/C++"
121 tab, then "Preprocessor" from the drop down list and add the
122 appropriate define)).
123
124 It is extremely important that the application programmer uses the
125 correct define, as using "SOXT_NOT_DLL" when "SOXT_DLL" is
126 correct is likely to cause mysterious crashes.
127 */
128#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
129# ifdef SOXT_INTERNAL
130# ifdef SOXT_MAKE_DLL
131# define SOXT_DLL_API __declspec(dllexport)
132# endif /* SOXT_MAKE_DLL */
133# else /* !SOXT_INTERNAL */
134# ifdef SOXT_DLL
135# define SOXT_DLL_API __declspec(dllimport)
136# else /* !SOXT_DLL */
137# ifndef SOXT_NOT_DLL
138# error Define either SOXT_DLL or SOXT_NOT_DLL as appropriate for your linkage! See Inventor/Xt/SoXtBasic.h for further instructions.
139# endif /* SOXT_NOT_DLL */
140# endif /* !SOXT_DLL */
141# endif /* !SOXT_MAKE_DLL */
142#endif /* Microsoft Windows */
143
144/* Empty define to avoid errors when _not_ compiling an Microsoft Windows DLL. */
145#ifndef SOXT_DLL_API
146# define SOXT_DLL_API
147#endif /* !SOXT_DLL_API */
148
149#ifndef GUI_TOOLKIT_VERSION
150#define GUI_TOOLKIT_VERSION "238"
151#endif /* GUI_TOOLKIT_VERSION */
152
153#endif // ! SOXT_BASIC_H