SoWin  1.6.2
Coin3D GUI toolkit binding
Loading...
Searching...
No Matches
SoWinBasic.h
1#ifndef SOWIN_BASIC_H
2#define SOWIN_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 * SoWinMin(Val1, Val2) - returns minimum value
42 * SoWinMax(Val1, Val2) - returns maximum value
43 * SoWinClamp(Val, Min, Max) - returns clamped value
44 * SoWinSwap(Val1, Val2) - swaps the two values (no return value)
45 */
46
47template <class Type>
48inline Type SoWinAbs(Type Val) {
49 return (Val < 0) ? -Val : Val;
50}
51
52template <class Type>
53inline Type SoWinMin(Type a, Type b) {
54 return (b < a) ? b : a;
55}
56
57template <class Type>
58inline Type SoWinMax(Type a, Type b) {
59 return (b > a) ? b : a;
60}
61
62template <class Type>
63inline Type SoWinClamp(Type val, Type min, Type max) {
64 return SoWinMax(min, SoWinMin(max, val));
65}
66
67template <class Type>
68inline void SoWinSwap(Type & a, Type & b) {
69 Type t = a; a = b; b = t;
70}
71
72// *************************************************************************
73
74#define __COIN_SOWIN__
75
76#if ! defined(SOWIN_MAJOR_VERSION)
77#define SOWIN_MAJOR_VERSION 1
78#endif /* ! SOWIN_MAJOR_VERSION */
79#if ! defined(SOWIN_MINOR_VERSION)
80#define SOWIN_MINOR_VERSION 6
81#endif /* ! SOWIN_MINOR_VERSION */
82#if ! defined(SOWIN_MICRO_VERSION)
83#define SOWIN_MICRO_VERSION 2
84#endif /* ! SOWIN_MICRO_VERSION */
85#if ! defined(SOWIN_BETA_VERSION)
86#define SOWIN_BETA_VERSION
87#endif /* ! SOWIN_BETA_VERSION */
88#if ! defined(SOWIN_VERSION)
89#define SOWIN_VERSION "1.6.2"
90#endif /* ! SOWIN_VERSION */
91
92// *************************************************************************
93
94/* Precaution to avoid an error easily made by the application programmer. */
95#ifdef SOWIN_DLL_API
96# error Leave the internal SOWIN_DLL_API define alone.
97#endif /* SOWIN_DLL_API */
98
99/*
100 On Microsoft Windows platforms, one of these defines must always be set when
101 building application programs:
102
103 - "SOWIN_DLL", when the application programmer is using the
104 library in the form of a dynamic link library (DLL)
105
106 - "SOWIN_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 SOWIN_DLL or SOWIN_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 "SOWIN_DLL") or as a LIB (use
114 "SOWIN_NOT_DLL").
115
116 (Setting up defines for the compiler is typically done by either
117 adding something like "/DSOWIN_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 "SOWIN_NOT_DLL" when "SOWIN_DLL" is
126 correct is likely to cause mysterious crashes.
127 */
128#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
129# ifdef SOWIN_INTERNAL
130# ifdef SOWIN_MAKE_DLL
131# define SOWIN_DLL_API __declspec(dllexport)
132# endif /* SOWIN_MAKE_DLL */
133# else /* !SOWIN_INTERNAL */
134# ifdef SOWIN_DLL
135# define SOWIN_DLL_API __declspec(dllimport)
136# else /* !SOWIN_DLL */
137# ifndef SOWIN_NOT_DLL
138# error Define either SOWIN_DLL or SOWIN_NOT_DLL as appropriate for your linkage! See Inventor/Win/SoWinBasic.h for further instructions.
139# endif /* SOWIN_NOT_DLL */
140# endif /* !SOWIN_DLL */
141# endif /* !SOWIN_MAKE_DLL */
142#endif /* Microsoft Windows */
143
144/* Empty define to avoid errors when _not_ compiling an Microsoft Windows DLL. */
145#ifndef SOWIN_DLL_API
146# define SOWIN_DLL_API
147#endif /* !SOWIN_DLL_API */
148
149#ifndef GUI_TOOLKIT_VERSION
150#define GUI_TOOLKIT_VERSION "GetOSDisplayString()"
151#endif /* GUI_TOOLKIT_VERSION */
152
153#endif // ! SOWIN_BASIC_H