1 /***************************************************************************/
2 /* 	This code is part of X-toolkit widget library called Nws 	   */
3 /*	Copyright (c) 1997,1998,1999 Ondrejicka Stefan			   */
4 /*	(ondrej@idata.sk)						   */
5 /*	Distributed under GPL 2 or later				   */
6 /***************************************************************************/
7 
8 #ifndef MW_NWS_H
9 #define MW_NWS_H
10 
11 #include <X11/Xlib.h>
12 #include <X11/xpm.h>
13 
14 #ifndef XtRBox_type
15 #define XtRBox_type	"Box_type"
16 #endif
17 
18 #ifndef XtRNwsJustify
19 #define XtRNwsJustify	"NwsJustify"
20 #endif
21 
22 #ifndef XtRIcon
23 #define XtRIcon		"Icon"
24 #endif
25 
26 #ifndef XtRCheck_type
27 #define XtRCheck_type		"Check_type"
28 #endif
29 
30 #ifndef XtRObject_type
31 #define XtRObject_type		"Object_type"
32 #endif
33 
34 #ifndef XtROrientation
35 #define XtROrientation		"Orientation"
36 #endif
37 
38 #ifndef XtRListStruct
39 #define XtRListStruct		"ListStruct"
40 #endif
41 
42 #ifndef XtRButtonMode
43 #define XtRButtonMode		"ButtonMode"
44 #endif
45 
46 #ifndef XtRStringList
47 #define XtRStringList		"StringList"
48 #endif
49 
50 /* constant for box type definition */
51 #define XtCno_box 		0
52 #define XtCsimple_box		1
53 #define XtCup_box		2
54 #define XtCdown_box		3
55 #define XtCframein_box		4
56 #define XtCframeout_box		5
57 #define XtCshadow_box		6
58 
59 /* constant for justifycation definition */
60 #define XtCcenter		0
61 #define XtCright		1
62 #define XtCleft			2
63 #define XtCbottom		3
64 #define XtCtop			4
65 
66 /* constant for check type definition */
67 #define XtCcheck		0
68 #define XtCcircle		1
69 #define XtCrectangle		2
70 #define XtCdiamond		3
71 #define XtCcross		4
72 #define XtCcircle2		5
73 
74 /* constant for object type definition */
75 #define XtCright_arrow		0
76 #define XtCleft_arrow		1
77 #define XtCtop_arrow		2
78 #define XtCbottom_arrow		3
79 
80 /* constant for orientation definition */
81 #define XtCvertical		0
82 #define XtChorizontal		1
83 
84 /* button mode constants */
85 #define XtCnormalMode	0
86 #define XtCcyclicMode	1
87 #define	XtCtoggleMode	2
88 
89 typedef struct {
90 	Pixmap		pixmap;
91 	Pixmap		shape;
92 	unsigned int	width;
93 	unsigned int	height;
94 } Icon;
95 
96 typedef struct {
97 	int		index;
98 	char		*label;
99 	Icon		*left_icon;
100 	Icon		*right_icon;
101 	Boolean		sensitive;
102 	void		*related_info;
103 } ListStruct;
104 
105 #if  NeedFunctionPrototypes
106 extern Boolean  cvtStringToStringList(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
107 extern Boolean  cvtStringToBoxType(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
108 extern Boolean  cvtBoxTypeToString(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
109 extern Boolean  cvtStringToJustify(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
110 extern Boolean  cvtStringToIcon(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
111 extern Boolean  cvtStringToCheckType(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
112 extern Boolean  cvtStringToObjectType(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
113 extern Boolean  cvtStringToOrientation(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
114 extern Boolean  cvtStringToListStruct(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
115 extern Boolean  cvtStringToButtonMode(Display *,XrmValuePtr,Cardinal *,XrmValuePtr,XrmValuePtr,XtPointer *);
116 #else
117 extern Boolean  cvtStringToStringList();
118 extern Boolean  cvtStringToBoxType();
119 extern Boolean  cvtBoxTypeToString();
120 extern Boolean  cvtStringToJustify();
121 extern Boolean  cvtStringToIcon();
122 extern Boolean  cvtStringToCheckType();
123 extern Boolean  cvtStringToObjectType();
124 extern Boolean  cvtStringToOrientation();
125 extern Boolean  cvtStringToListStruct();
126 extern Boolean  cvtStringToButtonMode();
127 #endif
128 
129 
130 #define MwNwsDone(type, value) do {\
131 	if (to->addr != NULL) {\
132 		if (to->size < sizeof(type)) {\
133 			to->size = sizeof(type);\
134 			return False;\
135 		}\
136 		*(type*)(to->addr) = (value);\
137 	} else {\
138 		static type static_val;\
139 		static_val = (value);\
140 		to->addr = (XtPointer)&static_val;\
141 	}\
142 	to->size = sizeof(type);\
143 	return True;\
144     }while (0 )
145 
146 #endif
147 /***************************************************************************/
148 /* 	This code is part of X-toolkit widget library called Nws 	   */
149 /*	Copyright (c) 1997,1998,1999 Ondrejicka Stefan			   */
150 /*	(ondrej@idata.sk)						   */
151 /*	Distributed under GPL 2 or later				   */
152 /***************************************************************************/
153 
154 #ifndef _dimdefP_H_
155 #define _dimdefP_H_
156 
157 #if NeedFunctionPrototypes
158 typedef void (*set_internal_dimension_Proc) (Widget,Dimension,Dimension);
159 #else
160 typedef void (*set_internal_dimension_Proc) ();
161 #endif
162 
163 #if NeedFunctionPrototypes
164 typedef void (*get_internal_dimension_Proc) (Widget,Position *,Position *,Dimension *,Dimension *);
165 #else
166 typedef void (*get_internal_dimension_Proc) ();
167 #endif
168 
169 #if NeedFunctionPrototypes
170 typedef Widget (*traverse_Proc) (Widget, int ,Time *);
171 typedef void (*traverseTo_Proc) (Widget, Widget ,Time *);
172 typedef void (*traverseOut_Proc) (Widget);
173 typedef Widget (*traverseInside_Proc) (Widget, int ,Time *);
174 typedef void (*highlightBorder_Proc) (Widget);
175 typedef void (*unhighlightBorder_Proc) (Widget);
176 #else
177 typedef Widget (*traverse_Proc) ();
178 typedef void (*traverseTo_Proc) ();
179 typedef void (*traverseOut_Proc) ();
180 typedef Widget (*traverseInside_Proc) ();
181 typedef void (*highlightBorder_Proc) ();
182 typedef void (*unhighlightBorder_Proc) ();
183 #endif
184 
185 #define  XtInheritGetInternalDimension ((get_internal_dimension_Proc) _XtInherit)
186 #define  XtInheritSetInternalDimension ((set_internal_dimension_Proc) _XtInherit)
187 #define  XtInheritTraverse ((traverse_Proc) _XtInherit)
188 #define  XtInheritTraverseTo ((traverseTo_Proc) _XtInherit)
189 #define  XtInheritTraverseOut ((traverseOut_Proc) _XtInherit)
190 #define  XtInheritTraverseInside ((traverseInside_Proc) _XtInherit)
191 #define  XtInheritHighlightBorder ((highlightBorder_Proc) _XtInherit)
192 #define  XtInheritUnhighlightBorder ((unhighlightBorder_Proc) _XtInherit)
193 
194 #endif
195 /***************************************************************************/
196 /* 	This code is part of X-toolkit widget library called Nws 	   */
197 /*	Copyright (c) 1997,1998,1999 Ondrejicka Stefan			   */
198 /*	(ondrej@idata.sk)						   */
199 /*	Distributed under GPL 2 or later				   */
200 /***************************************************************************/
201 
202 #ifndef _Init_h_
203 #define _Init_h_
204 
205 extern void _InitializeWidgetSet(void);
206 
207 #endif
208 
209 /***************************************************************************/
210 /* 	This code is part of X-toolkit widget library called Nws 	   */
211 /*	Copyright (c) 1997,1998,1999 Ondrejicka Stefan			   */
212 /*	(ondrej@idata.sk)						   */
213 /*	Distributed under GPL 2 or later				   */
214 /***************************************************************************/
215 
216 #ifndef _utils_h_
217 #define _utils_h_
218 
219 #include <X11/Xutil.h>
220 
221 extern void X_DrawSoft3DFrame(Display *, Drawable, int, int, int, int,
222 			int, Pixel, Pixel, Pixel);
223 
224 extern void X_DrawSimple3DFrame(Display * , Drawable , int , int , int ,
225 					int , int , Pixel , Pixel );
226 extern void X_DrawSimpleRawFrame(Display * , Drawable , int , int , int ,
227 					int , int , Pixel);
228 extern void X_DrawIcon(Display * , Drawable , Icon * , int , int );
229 extern void X_Draw3DArrow(Display * , Window , int , int , int , int ,
230 					int , Pixel , Pixel , Pixel);
231 extern void X_Draw3DRectangle(Display * , Drawable , int , int , int ,
232 					int , int , Pixel , Pixel , Pixel);
233 extern void X_Draw3DString(Display * , Drawable , XFontStruct * , int , int ,
234 					int , String , int , Pixel , Pixel);
235 extern void X_DrawTextCursor(Display * , Window , int , int , int , Pixel);
236 extern Icon * X_XpmDataToIcon(Display * , char **);
237 extern void X_GetWindowRootPosition(Display * , Window , int * , int *);
238 extern void Xt_SetInsensitive(Widget);
239 extern Widget Xt_GetShell(Widget);
240 extern Boolean Xt_IsUp(Widget);
241 
242 /* Original code */
243 /* makro na vypocet a alokaciu bledsej farby */
244 #define LightColor(intensity,fromcolor,tocolor) \
245 	tocolor.red = (fromcolor.red + intensity) <= 65280 ? \
246 	fromcolor.red + intensity : 65280 ; \
247 	tocolor.green = (fromcolor.green + intensity) <= 65280 ? \
248 	fromcolor.green + intensity : 65280 ; \
249 	tocolor.blue = (fromcolor.blue + intensity) <= 65280 ? \
250 	fromcolor.blue + intensity : 65280; \
251 	if (!XAllocColor(dpy, DefaultColormap(dpy ,DefaultScreen(dpy)),&tocolor)) \
252 	{ \
253 		XtWarning("unable to allocate color for border"); \
254 		tocolor.pixel=WhitePixel(dpy,DefaultScreen(dpy)); \
255 	}
256 
257 /* makro na vypocet a alokaciu tmavsej farby */
258 #define DarkColor(intensity,fromcolor,tocolor) \
259 	tocolor.red = (fromcolor.red - intensity) <= 0 ? \
260 	0 : fromcolor.red - intensity  ; \
261 	tocolor.green = (fromcolor.green - intensity) <= 0 ? \
262 	0 : fromcolor.green - intensity ; \
263 	tocolor.blue = (fromcolor.blue - intensity) <= 0 ? \
264 	0 : fromcolor.blue - intensity ; \
265 	if (!XAllocColor(dpy, DefaultColormap(dpy ,DefaultScreen(dpy)),&tocolor)) \
266 	{ \
267 		XtWarning("unable to allocate color for border"); \
268 		tocolor.pixel=BlackPixel(dpy,DefaultScreen(dpy)); \
269 	}
270 
271 /* More compatible with e.g. Xaw3d */
272 extern Pixel AllocShadowPixel(Widget, int);	/* from xcommon/Gcs.h */
273 #define LightColor2(widget, tocolor, contrast) \
274 	tocolor.pixel = AllocShadowPixel(widget, 100+(contrast))
275 #define DarkColor2(widget, tocolor, contrast) \
276 	tocolor.pixel = AllocShadowPixel(widget, 100-(contrast))
277 
278 
279 #endif
280 /***************************************************************************/
281 /* 	This code is part of X-toolkit widget library called Nws 	   */
282 /*	Copyright (c) 1997,1998,1999 Ondrejicka Stefan			   */
283 /*	(ondrej@idata.sk)						   */
284 /*	Distributed under GPL 2 or later				   */
285 /***************************************************************************/
286 
287 #ifndef _misc_h_
288 #define _misc_h_
289 
290 #define MAX_PATH_LEN   		2048
291 #define _DCtimeout		300
292 #define DefaultIntensity	10000
293 
294 #if NeedFunctionPrototypes
295 	extern int cnt_lines(char *);
296 	extern int max_line_width(char * , XFontStruct *);
297 	extern char * get_abs_path(char *);
298 	extern int x_atoi(char *);
299 #else
300 	extern int cnt_lines();
301 	extern int max_line_width();
302 	extern char * get_abs_path();
303 	extern int x_atoi();
304 #endif
305 
306 #ifndef MW_MAX
307 #define MW_MAX(x,y) ((x) > (y) ? (x) : (y))
308 #endif
309 
310 #ifndef MW_MIN
311 #define MW_MIN(x,y) ((x) < (y) ? (x) : (y))
312 #endif
313 
314 #ifndef MW_BETWEEN
315 #define MW_BETWEEN(x,a,b) ((x)>=(a) && (x)<=(b))
316 #endif
317 
318 #endif /* MW_NWS_H */
319