feisty meow concerns codebase  2.140
windoze_helper.h
Go to the documentation of this file.
1 #ifndef WINDOZE_HELPER_GROUP
2 #define WINDOZE_HELPER_GROUP
3 
4 /*
5 * Name : windoze_helper definitions
6 * Author : Chris Koeritz
7 * Copyright (c) 1994-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
14 
16 
23 // gnarly headers that are needed for certain types of compilation...
24 
25 //unix headers not needed in here for new purpose of file.
26 //#ifndef _MSC_VER
27  #include <unistd.h>
28  #ifdef __GNU_WINDOWS__
29  #include <sys/unistd.h>
30  #endif
31 //#endif
32 #ifndef NO_XWINDOWS
33  #ifdef __XWINDOWS__
34  #include <Intrinsic.h>
35  #include <StringDefs.h>
36  #include <Xm/Xm.h>
37  #include <Xlib.h>
38  #endif
39 #endif
40 #ifdef __WIN32__
41  #ifndef STRICT
42  #define STRICT
43  #endif
44  // winsock support...
45 // #undef FD_SETSIZE
46 // #define FD_SETSIZE 1000
47  // if you don't set this, you can only select on a default of 64 sockets.
48 // #include <winsock2.h>
49 
50  // windows headers...
51 //noooo #define _WINSOCKAPI_ // make windows.h happy about winsock.
52  #ifndef _AFXDLL
53  // include ms-windows headers only if we're not doing mfc; mfc has its own
54  // special way of including the headers.
55  #include <windows.h>
56  #else
57  #include <afx.h>
58  #include <afxwin.h>
59  #endif
60 #endif
61 
62 // forward.
63 //class version;
64 
65 // wrapper classes defined in the sequel...
66 //
67 // application_instance -- this program's application object; used mainly
68 // in ms-windows.
69 //
70 // window_handle -- a wrapper for the root of all objects that can be
71 // referred to in the relevant windowing system.
72 
73 #include <basis/definitions.h>
74 
75 #ifdef __UNIX__
76  // the application_instance class is implemented very simply for unix;
77  // it's a stand-in since unix apps don't refer to an instance handle like
78  // ms-windows does.
79  typedef void *application_instance;
80 
81  // some definitions to quiet complaints from win32-based code.
82  #ifndef LONGINT_SIZE
83  #if defined(__alpha) || (defined(__HOS_AIX__) && defined(_LP64)) \
84  || defined(__sparcv9) || defined(__LP64__)
85  #define LONGINT_SIZE 8
86  #else
87  #define LONGINT_SIZE 4
88  #endif
89  #endif
90  #if (LONGINT_SIZE == 4)
91  // be compatible with linux's definitions on this subject.
92  typedef unsigned long DWORD;
93  #else
94  typedef unsigned int DWORD;
95  #endif
96 
97  typedef void *HANDLE;
98 
99  //temp; these just mimic function prototypes coming from non-portable code.
100  typedef void *ATOM;
101  typedef void *BITMAPINFO;
102  typedef void *HBITMAP;
103  typedef void *HDC;
104  typedef void *RGBQUAD;
105  #define LoadBitmap(a, b) (a)
106  #define __stdcall
107  #define afx_msg
108 
109  // windoze_helper definitions for the X windowing system.
110  #ifndef NO_XWINDOWS // protects regions with similar names.
111  #ifdef __XWINDOWS__
112  typedef Widget window_handle;
114 
115  typedef Colormap window_colormap;
117 
118  typedef XColor window_color;
120 
121  typedef XmString window_string;
123 
124 //is that really fixed?
125  const int MAXIMUM_COLOR_INTENSITY = 65535;
126  // largest valid value a color component (R, G or B) can have.
127  #else
128  // no x-windows.
129  typedef void *window_handle;
130  #endif
131  #endif
132 #endif
133 
134 #ifdef __WIN32__
135  typedef HINSTANCE application_instance;
136  // our moniker for an application's guts.
137 
138  typedef HWND window_handle;
139  // our alias for window handles in win32.
140 #endif
141 
142 namespace application {
143 
144 // istring module_name(const void *module_handle = NULL_POINTER);
146 
149 // u_int system_error();
151 
152 // istring system_error_text(u_int error_to_show);
154 
156 // istring null_device();
158 
161 // timeval fill_timeval_ms(int milliseconds);
163 
167  // this only really helps for win32.
170  #define DEFINE_INSTANCE_HANDLE application_instance application::_i_handle = 0
172 
174  #define SET_INSTANCE_HANDLE(value) application::_i_handle = value
176 
177  #define GET_INSTANCE_HANDLE() application::_i_handle
179 
181 
182  // Unix and Linux specific items are included here.
183  #ifdef __UNIX__
186 
187 // char *itoa(int to_convert, char *buffer, int radix);
189 
195  #define RGB(r, g, b) (b + (g << 8) + (r << 16))
197  #endif
198 
199  // ms-windows of more modern types, i.e. win32.
200  #ifdef __WIN32__
201 
202 // bool event_poll(MSG &message);
204 
209 //hmmm: is there an equivalent to this for unix?
210 // bool is_address_valid(const void *address, int size_expected,
211 // bool writable = false);
213 
217  #define BROADCAST_HANDLE HWND_BROADCAST
218 
219  enum known_operating_systems {
220  WIN_95, WIN_NT, WIN_2K, WIN_XP, WIN_SRV2K3, WIN_VISTA,
222  WIN_7, WIN_8, WIN_10,
223  UNKNOWN_OS
224  };
225  const char *opsystem_name(known_operating_systems which);
227 
228  known_operating_systems determine_OS();
230 
232 // istring rc_string(u_int id, application_instance instance);
234 
237 // istring rc_string(u_int id);
239 
242 // void show_wait_cursor();
244 // void show_normal_cursor();
246 
247  #endif // win32.
248 
249 } // namespace.
250 
251 #endif // outer guard.
252 
Constants and objects used throughout HOOPLE.
Implements an application lock to ensure only one is running at once.
application_instance _i_handle
< returns the name of the module for the "module_handle" where supported.
void * BITMAPINFO
void * ATOM
void * application_instance
void * HBITMAP
void * window_handle
void * HANDLE
void * HDC
unsigned long DWORD
void * RGBQUAD