1 /*
2  * swt.h - stephen's window toolkit
3  *
4  * Copyright (C) 1999 Stephen F. White, 2005 J. "MUFTI" Scheurich
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program (see the file "COPYING" for details); if
18  * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19  * Cambridge, MA 02139, USA.
20  */
21 
22 #ifndef _SWT_H
23 #define _SWT_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #ifdef WIN32
30 struct HINSTANCE__;
31 typedef struct HINSTANCE__ *HINSTANCE;
32 #endif
33 
34 #include "keycodes.h"
35 #include "swlanguages.h"
36 #include "swDebugf.h"
37 
38 #define SW_RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
39 #define SW_RED(c)       ( (c)        & 0x0000ff)
40 #define SW_GREEN(c)     (((c) >> 8)  & 0x0000ff)
41 #define SW_BLUE(c)      (((c) >> 16) & 0x0000ff)
42 
43 #include "swttypedef.h"
44 
45 typedef unsigned char cbyte;
46 
47 typedef void (*InitCallback)();
48 typedef void (*ExposeCallback)(void *data, int x, int y, int width, int height);
49 typedef void (*MouseCallback)(void *data, int x, int y, int modifiers);
50 typedef void (*KeyCallback)(void *data, int key, int value, int x, int y,
51                             int modifiers);
52 typedef void (*FocusCallback)(void *data, int value);
53 typedef void (*ResizeCallback)(void *data, int width, int height);
54 typedef void (*EnterCallback)(void *data, int value);
55 typedef void (*ActivateCallback)(void *data);
56 typedef void (*ScrollBarCallback)(void *data, int type, int value);
57 typedef void (*CommandCallback)(void *data, void *cmd);
58 typedef void (*HighlightCallback)(void *data, void *cmd);
59 typedef void (*CloseCallback)(void *data);
60 typedef int  (*DropCallback)(void *data,int type, int x, int y, int modifiers);
61 typedef void (*TreeCallback)(void *data, int type, STREEITEM item);
62 typedef void (*HeaderCallback)(void *data, int pos, int width);
63 typedef const char *(*TooltipCallback)(void *data, int id);
64 typedef int  (*TimerCallback)(void *data);
65 
66 typedef void (*CleanupCallback)(void);
67 
68 extern void swSetInitCallback(InitCallback cb );
69 extern void swSetExposeCallback(SWND wnd, ExposeCallback cb);
70 extern void swSetMouseCallback(SWND wnd, MouseCallback cb);
71 extern void swSetKeyCallback(SWND wnd, KeyCallback cb);
72 extern void swSetFocusCallback(SWND wnd, FocusCallback cb);
73 extern void swSetResizeCallback(SWND wnd, ResizeCallback cb);
74 extern void swSetEnterCallback(SWND wnd, EnterCallback cb);
75 extern void swSetActivateCallback(SWND wnd, ActivateCallback cb);
76 extern void swSetScrollBarCallback(SWND wnd, ScrollBarCallback cb);
77 extern void swSetCommandCallback(SWND wnd, HighlightCallback cb);
78 extern void swSetHighlightCallback(SWND wnd, CommandCallback cb);
79 extern void swSetCloseCallback(SWND wnd, CloseCallback cb);
80 extern void swSetClientData(SWND wnd, void *data);
81 extern void swCallCommandCallback(SWND wnd, void* id);
82 extern void swCallHighlightCallback(SWND wnd, void* id);
83 
84 #ifdef WIN32
85 extern void swInitialize(HINSTANCE hInstance, int stereotype, int want8BitFlag);
86 extern void swOpenGLStartup(SWND wnd);
87 #else
88 extern int swInitialize( int *argc, char **argv, int stereotype);
89 #endif
90 
91 int swSystem(const char *command);
92 int swSystemInDir(const char *command, const char *dir);
93 
94 int swHasVisual(void);
95 
96 extern int swMainLoop(void);
97 extern void swExit(void);
98 extern void swSetCleanup(CleanupCallback cb);
99 extern void swCleanup(void);
100 
101 extern void swGetScreenSize(int *x, int *y);
102 extern void swSetDefaultIcon(int resource);
103 extern void swDestroyWindow(SWND wnd);
104 extern int  swIsHidden(SWND wnd);
105 extern void swDestroyUpdate(SWND wnd);
106 extern void swSetPosition(SWND wnd, int x, int y);
107 extern void swGetPosition(SWND wnd, int *x, int *y);
108 extern void swGetAbsPosition(SWND wnd, int *x, int *y);
109 extern void swSetSize(SWND wnd, int width, int height);
110 extern void swGetSize(SWND wnd, int *width, int *height);
111 extern void swGetTotalSize(SWND wnd, int *width, int *height);
112 extern void swMoveWindow(SWND wnd, int x, int y, int width, int height);
113 extern void swGetTitle(SWND wnd, char *buf, int len);
114 extern void swSetTitle(SWND wnd, const char *title);
115 extern void swSetIcon(SWND wnd, SBITMAP bitmap, SBITMAP mask, int big);
116 extern SWND swGetParent(SWND wnd);
117 extern int swGetWindowColor(SWND wnd, int type);
118 extern void swShowWindow(SWND wnd);
119 extern void swHideWindow(SWND wnd);
120 extern void swMaximizeWindow(SWND wnd);
121 extern void swIconifyWindow(SWND wnd);
122 extern void swDeIconifyWindow(SWND wnd);
123 extern void swUpdate(void);
124 extern void swSetWindowBG(SWND wnd, int color);
125 extern int swIsVisible(SWND wnd);
126 extern int swIsMaximized(SWND wnd);
127 extern void swEnableWindow(SWND wnd, int enable);
128 extern void swSetFocus(SWND wnd);
129 extern void swEnableAccelerators(int enable);
130 extern void swInvalidateRect(SWND wnd, int x, int y,
131                             int width, int height);
132 extern void swInvalidateWindow(SWND wnd);
133 
134 extern STIMER swSetTimer(SWND wnd, int timeout, TimerCallback cb, void *data);
135 extern void swKillTimer(STIMER timer);
136 extern void swEnableTimers(void);
137 extern void swDisableTimers(void);
138 
139 /* browser preview */
140 extern SBROWSER swBrowserInit(STABLE prefs);
141 extern void swBrowserPreview(SBROWSER browser, const char *path, SWND wnd);
142 extern void swBrowserGetSettings(SBROWSER browser,
143                                  const char **command,
144                                  int *vrmlLevel,
145                                  int *useRemote,
146                                  int *xtypExecuteOrFork,
147                                  const char **remoteCommand,
148                                  const char **application,
149                                  const char **topic);
150 extern int swBrowserGetVrmlLevel(SBROWSER browser);
151 extern int swBrowserGetRemote(SBROWSER browser);
152 extern void swBrowserSetRemote(SBROWSER browser, int remote);
153 #ifndef WIN32
154 extern int swBrowserGetUseFork(SBROWSER browser);
155 #endif
156 extern void swBrowserSetSettings(SBROWSER browser,
157                                  const char *command,
158                                  int vrmlLevel,
159                                  int useRemote,
160                                  int xtypExecuteOrFork,
161                                  const char *remoteCommand,
162                                  const char *application,
163                                  const char *topic);
164 extern void swBrowserSetDefault(SBROWSER browser);
165 extern void swBrowserShutdown(SBROWSER browser);
166 extern void swBrowserSavePreferences(SBROWSER browser, STABLE prefs);
167 #ifndef WIN32
168  extern int swBrowserGetSettingsErrorToConsole(SBROWSER browser);
169  extern void swBrowserSetSettingsErrorToConsole(SBROWSER browser, int flag);
170 #endif
171 /* upload */
172 
173 extern SUPLOAD   swUploadInit(STABLE prefs);
174 extern void      swUploadGetSettings(SUPLOAD upload,
175                                      const char **commandline,
176                                      const char **htmlTag,
177                                      const char **password);
178 extern void      swUploadSetSettings(SUPLOAD upload,
179                                      const char *commandline,
180                                      const char *htmlTag,
181                                      const char *password);
182 extern void      swUploadCleanupPasswd(SUPLOAD upload);
183 extern int       swHasUpload(SUPLOAD upload);
184 extern char     *swUpload(SUPLOAD upload, char *fileToUpload,
185                           SHBROWSER browser, SWND wnd);
186 extern void     *swToPtr(int id);
187 extern int       swFromPtr(void *id);
188 
189 /* help browser */
190 
191 #ifdef HAVE_WWW_BROWSER
192 # define WWW_BROWSER HAVE_WWW_BROWSER
193 #else
194 # ifdef _WIN32
195 #  define WWW_BROWSER "\"C:\\Program Files\\Internet Explorer\\IExplore.exe\" %s"
196 # else
197 #  define WWW_BROWSER "firefox %s"
198 # endif
199 #endif
200 
201 #ifdef HAVE_HELP_URL
202 # define HELP_URL HAVE_HELP_URL
203 #else
204 # define HELP_URL "http://wdune.ourproject.org/docs/"
205 #endif
206 
207 #ifdef HAVE_VRML_NODES_URL
208 # define VRML_NODES_URL HAVE_VRML_NODES_URL
209 #else
210 # define VRML_NODES_URL "http://www.web3d.org/documents/specifications/14772/V2.0/part1/nodesRef.html"
211 #endif
212 
213 #ifdef HAVE_X3D_URL
214 # define X3D_URL HAVE_X3D_URL
215 #else
216 # define X3D_URL "http://www.web3d.org/documents/specifications/19775-1/V3.3/"
217 #endif
218 
219 /* vrml browser */
220 
221 #ifdef HAVE_VRML_BROWSER
222 # define VRML_BROWSER HAVE_VRML_BROWSER
223 #else
224 # define VRML_BROWSER "firefox %s"
225 #endif
226 
227 #ifdef HAVE_VRML_REMOTE_BROWSER
228 # define VRML_REMOTE 1
229 # define VRML_REMOTE_BROWSER HAVE_VRML_REMOTE_BROWSER
230 #else
231 # define VRML_REMOTE_BROWSER "firefox -remote OpenURL\\(%s,new-window\\)"
232 #endif
233 
234 extern SHBROWSER swHelpBrowserInit(STABLE prefs);
235 extern void      swHelpBrowserSetDefaults(SHBROWSER browser);
236 extern void      swHelpBrowserGetSettings(SHBROWSER browser,
237                                           const char **Command,
238                                           const char **remoteCommand,
239                                           const char **helpUrl,
240                                           const char **vrmlUrl,
241                                           const char **x3dUrl,
242                                           const char **application,
243                                           const char **topic);
244 extern void      swHelpBrowserSetSettings(SHBROWSER browser,
245                                           const char *Command,
246                                           const char *remoteCommand,
247                                           const char *helpUrl,
248                                           const char *vrmlUrl,
249                                           const char *x3dUrl,
250                                           const char *application,
251                                           const char *topic);
252 extern void      swHelpBrowserHTML(SHBROWSER browser, SWND wnd);
253 extern char     *swGetHelpUrl(SHBROWSER browser);
254 extern void      swHelpBrowserPath(SHBROWSER browser, const char* path,
255                                    SWND wnd);
256 extern void      swHelpBrowserVRML(SHBROWSER browser,
257                                    const char* selection_string,
258                                    int isCover, SWND wnd);
259 void             swHelpBrowserX3d(SHBROWSER browser, const char* string,
260                                   SWND wnd);
261 extern void      swHelpBrowserShutdown(SHBROWSER browser);
262 
263 /* Texteditor */
264 
265 extern STEXTEDIT swTextEditInit(STABLE prefs);
266 extern void      swTextEditGetSettings(STEXTEDIT textEdit,
267                                        const char **textEditCommand,
268                                        const char **textEditLinenumberOption,
269                                        int *textEditUseExtensionTxt);
270 
271 extern void      swTextEditGetSettingsUseExtensionTxt(STEXTEDIT textEdit,
272                        int *textEditUseExtensionTxt);
273 
274 extern void      swTextEditSetSettings(STEXTEDIT textEdit,
275                                        const char *textEditCommand,
276                                        const char *textEditLinenumberOption,
277                                        int textEditUseExtensionTxt);
278 extern char     *swTextEditGetCommand(STEXTEDIT textEdit);
279 
280 
281 /* Editors */
282 
283 extern char     *swImageEditGetSettings(STEXTEDIT textEdit);
284 extern void      swImageEditSetSettings(STEXTEDIT textEdit,
285                                         const char *imageEditCommand);
286 extern char     *swImageEdit4KidsGetSettings(STEXTEDIT textEdit);
287 extern void      swImageEdit4KidsSetSettings(STEXTEDIT textEdit,
288                                              const char *imageEdit4KidsCommand);
289 
290 extern char     *swSoundEditGetSettings(STEXTEDIT textEdit);
291 extern void      swSoundEditSetSettings(STEXTEDIT textEdit,
292                                         const char *soundEditCommand);
293 
294 extern char     *swMovieEditGetSettings(STEXTEDIT textEdit);
295 extern void      swMovieEditSetSettings(STEXTEDIT textEdit,
296                                         const char *movieEditCommand);
297 
298 /* Main Window */
299 
300 extern SWND swCreateMainWindow(const char *title, int x, int y,
301                                int width, int height);
302 
303 /* ScrollBar */
304 extern SWND swCreateScrollBar(int flags,
305                               int x, int y, int width, int height,
306                               int min, int max, int value, int visible,
307                               SWND parent);
308 
309 extern void swScrollBarSetRange(SWND scrollBar, int min, int max);
310 extern void swScrollBarSetVisible(SWND scrollBar, int visible);
311 extern void swScrollBarSetValue(SWND scrollBar, int value);
312 
313 /* Button */
314 extern SWND swCreateButton(const char *title, int x, int y,
315                            int width, int height, SWND parent);
316 
317 extern SWND swCreateCheckBox(const char *title, int x, int y,
318                              int width, int height, SWND parent);
319 
320 extern SWND swCreateRadioButton(const char *title, int x, int y,
321                                 int width, int height, SWND parent);
322 extern void swSetCheck(SWND wnd, int check);
323 extern int swGetCheck(SWND wnd);
324 
325 /* Label */
326 extern SWND swCreateLabel(const char *title, int x, int y,
327                           int width, int height, SWND parent);
328 extern void swLabelSetText(SWND wnd, const char *text);
329 
330 /* Popup */
331 
332 extern SWND swCreatePopup(const char *title, int x, int y,
333                           int width, int height, SWND parent);
334 
335 /* Text */
336 
337 extern SWND swCreateTextEdit(int flags, int x, int y, int width, int height,
338                              SWND parent);
339 extern void swSetText(SWND wnd, const char *text);
340 extern void swGetText(SWND wnd, char *text, int len);
341 extern void swTextEditSetSelection(SWND wnd, int start, int end);
342 extern void swSetTextCleanupPasswd(SWND wnd);
343 extern int swGetTextCaretPos(SWND wnd);
344 extern void swSetTextCaretPos(SWND wnd, int pos);
345 
346 /* Canvas */
347 extern SWND swCreateCanvas(const char *title, int x, int y,
348                            int width, int height, SWND parent);
349 
350 /* Scrolled Window */
351 extern SWND swCreateScrolledWindow(int x, int y, int width, int height,
352                                    SWND parent);
353 extern void swScrolledWindowSetChild(SWND wnd, SWND child);
354 extern void swGetScrollPosition(SWND wnd, int *x, int *y);
355 extern void swSetScrollPosition(SWND wnd, int x, int y);
356 extern void swGetScrollViewportSize(SWND wnd, int *w, int *h);
357 extern void swSetScrollSizes(SWND wnd, int width, int height);
358 
359 /* Group Box */
360 extern SWND swCreateGroupBox(const char *title, int x, int y, int width,
361                              int height, SWND parent);
362 
363 /* Drawing Context */
364 
365 extern SDC swCreateDC(SWND wnd);
366 extern SDC swCreateBitmapDC(SDC dc, int width, int height);
367 extern void swDestroyDC(SDC dc);
368 
369 /* GL Context */
370 extern SGLC swCreateGLContext(SDC dc);
371 extern void swDestroyGLContext(SGLC context);
372 extern void swMakeCurrent(SDC dc, SGLC context);
373 extern void swSwapBuffers(SDC dc, SGLC context);
374 extern int swLoadGLFont(const char *name, int style,
375                         float *kernX, float *kernY);
376 extern SGLC swCreateGLContext(SDC dc);
377 extern void swDestroyGLContext(SGLC context);
378 extern void swMakeCurrent(SDC dc, SGLC context);
379 #ifndef WIN32
380 extern SGLC swOSCreateGLContext(int *argc, char **argv);
381 extern void swOSDestroyGLContext(SGLC context);
382 extern void swOSMakeCurrent(SGLC context);
383 #endif
384 #ifndef WIN32
385 extern void swSetInDirectRendering(void);
386 #endif
387 
388 /* Drawing */
389 
390 extern void swSetFGColor(SDC dc, int color);
391 extern void swSetBGColor(SDC dc, int color);
392 extern void swSetFont(SDC dc, SFONT font);
393 extern void swSetLineStyle(SDC dc, int style);
394 extern void swSetLineWidth(SDC dc, int width);
395 extern void swSetCapStyle(SDC dc, int style);
396 extern void swSetJoinStyle(SDC dc, int style);
397 extern void swSetClipRect(SDC dc, int x, int y, int width, int height);
398 extern void swDrawLine(SDC dc, int x1, int y1, int x2, int y2);
399 extern void swDrawPoint(SDC dc, int x, int y);
400 extern void swDrawRect(SDC dc, int x, int y, int width, int height);
401 extern void swDraw3DRect(SDC dc, SWND wnd, int x, int y,
402                          int width, int height);
403 extern void swDraw3DIndent(SDC dc, SWND wnd, int x, int y,
404                            int width, int height);
405 /* beware: swDrawPlusBox changes foreground colour ! */
406 extern void swDrawPlusBox(SDC dc, int x, int y);
407 /* beware: swDrawMinusBox changes foreground colour ! */
408 extern void swDrawMinusBox(SDC dc, int x, int y);
409 extern void swDrawArc(SDC dc, int x, int y, int width, int height,
410                       float startAngle, float endAngle);
411 extern void swDrawPolygon(SDC dc, int *points, int npoints);
412 extern void swDrawText(SDC dc, int x, int y, const char *str);
413 extern void swDrawTextTruncated(SDC dc, int x, int y, int width, int height, const char *str);
414 extern void swFillRect(SDC dc, int x, int y, int width, int height);
415 extern void swFillPatternRect(SDC dc, int x, int y, int width, int height, SBITMAP bitmap);
416 extern void swFillPolygon(SDC dc, int *points, int npoints);
417 extern void swFillArc(SDC dc, int x, int y, int width, int height,
418                       float startAngle, float endAngle);
419 extern void swFillPie(SDC dc, int x, int y, int width, int height,
420                       float startAngle, float endAngle);
421 extern void swDrawBitmap(SDC dc, SBITMAP bitmap, int sx, int sy,
422                          int dx, int dy, int width, int height);
423 extern void swDrawMaskedBitmap(SDC dc, SBITMAP bitmap, SBITMAP mask,
424                                int sx, int sy, int dx, int dy,
425                                int width, int height);
426 extern void swCopyRect(SDC src, SDC dest, int sx, int sy,
427                        int dx, int dy, int width, int height);
428 extern void swDrawMappedPixels(SBITMAP bitmap,
429                                int srcx, int srcy, int dstx, int dsty,
430                                int width, int height, const cbyte *data,
431                                int numColors, const int *palette);
432 
433 /* Font */
434 
435 extern SFONT swGetDefaultFont();
436 extern SFONT swFindFont(const char *family, int style, int pointSize);
437 extern void swDeleteFont(SFONT font);
438 extern int swGetStringWidth(SFONT font, const char *str);
439 extern int swGetFontAscent(SFONT font);
440 extern int swGetFontDescent(SFONT font);
441 extern int swGetFontHeight(SFONT font);
442 #ifndef WIN32
443 extern void swSetDefaultFontSpec(char *fontSpec);
444 extern void swSetFontPath(char *path);
445 #endif
446 
447 /* Menu */
448 extern SMENU swCreateMenuBar(SWND wnd);
449 extern SMENU swLoadMenuBar(SWND wnd, int id);
450 extern SMENU swAppendMenu(SMENU parent, const char *title);
451 extern void swAppendMenuItem(SMENU menu, const char *title, int id);
452 extern void swInsertMenuItem(SMENU menu, unsigned int position, const char *title,
453                              int id);
454 extern void swDeleteMenuItem(SMENU menu, int id);
455 extern void swAppendSeparator(SMENU menu);
456 extern void swMenuSetFlags(SMENU menu, int id, int mask, int flags);
457 
458 extern SSTATUSBAR swCreateStatusBar(SWND wnd);
459 extern void swDestroyStatusBar(SSTATUSBAR bar);
460 extern void swStatusBarSetText(SSTATUSBAR bar, const char *text);
461 extern SWND swStatusBarGetWindow(SSTATUSBAR bar);
462 
463 /* Bitmap */
464 extern SBITMAP swLoadBitmap(SWND wnd, int id);
465 extern SBITMAP swLoadMappedBitmap(SWND wnd, int id, const int *mapFrom,
466                                   const int *mapTo, int nMaps);
467 extern SBITMAP swCreateBitmap(SWND wnd, int width, int height);
468 extern SBITMAP swCreateMask(SBITMAP bitmap, int width, int height,
469                             int bgcolor);
470 extern void swDestroyBitmap(SBITMAP bitmap);
471 
472 /* Cursor */
473 extern SCURSOR swLoadCursor(int id);
474 extern void swSetCursor(SWND wnd, SCURSOR cursor);
475 extern void swDestroyCursor(SCURSOR cursor);
476 
477 /* Dialogs */
478 extern SWND swCreateDialog(const char *title, int x, int y,
479                            int width, int height, SWND parent);
480 extern SWND swLoadDialog(SWND parent, int id);
481 extern int swDialog(SWND dialog);
482 extern void swEndDialog(int rc);
483 extern SWND swGetDialogItem(SWND dialog, int item);
484 extern void swSetDefaultButton(SWND dialog, SWND button);
485 extern void swSetCancelButton(SWND dialog, SWND button);
486 
487 extern int swOpenDirDialog(SWND wnd, const char *title, const char *filters,
488                            char *buf, int len);
489 extern int swOpenMaybeFileDialog(SWND wnd, const char *title,
490                             const char *filters, char *buf, int len);
491 extern int swOpenFileDialog(SWND wnd, const char *title,
492                             const char *filters, char *buf, int len);
493 extern int swOpenExecutableDialog(SWND wnd, const char *title,
494                                   const char *filters, char *buf, int len);
495 extern int swSaveFileDialog(SWND wnd, const char *title,
496                             const char *filters, char *buf, int len,
497                             const char* default_extension);
498 
499 /* MessageBox */
500 extern int swMessageBox(SWND wnd, const char *text, const char *title,
501                         int type, int icon);
502 
503 /* ComboBox */
504 extern SWND swCreateComboBox(const char *title, int x, int y,
505                              int width, int height, SWND parent, int id);
506 extern void swComboBoxDeleteAll(SWND list);
507 extern void swComboBoxAppendItem(SWND list, const char *str);
508 extern int swComboBoxGetSelection(SWND list);
509 extern void swComboBoxSetSelection(SWND list, int index);
510 
511 /* Tree */
512 extern STREE swCreateTree(int x, int y, int width, int height, SWND parent);
513 extern void swDestroyTree(STREE tree);
514 extern SWND swTreeGetWindow(STREE tree);
515 extern void *swTreeGetItemData(STREE tree, STREEITEM item);
516 extern void swTreeSetItemData(STREE tree, STREEITEM item, void *data);
517 extern void swTreeSetItemImage(STREE tree, STREEITEM item,
518                               int image1, int image2);
519 extern STREEITEM swTreeGetRootItem(STREE tree);
520 extern STREEITEM swTreeGetFirstChild(STREE tree, STREEITEM item);
521 extern STREEITEM swTreeGetLastChild(STREE tree, STREEITEM item);
522 extern STREEITEM swTreeGetNextItem(STREE tree, STREEITEM item);
523 extern STREEITEM swTreeGetPrevItem(STREE tree, STREEITEM item);
524 extern STREEITEM swTreeGetParentItem(STREE tree, STREEITEM item);
525 extern void swTreeDeleteItem(STREE tree, STREEITEM item);
526 extern void swTreeDeleteAllItems(STREE tree);
527 extern void swTreeSelectItem(STREE tree, STREEITEM item);
528 extern void swTreeDeselectItem(STREE tree, STREEITEM item);
529 extern void swTreeDeselectAll(STREE tree);
530 extern STREEITEM swTreeGetCurrentItem(STREE tree);
531 extern void swTreeSetCurrentItem(STREE tree, STREEITEM item);
532 extern void swTreeSelectDropTarget(STREE tree, STREEITEM item);
533 extern STREEITEM swTreeInsertItem(STREE tree, int position,
534                                   STREEITEM relative, const char *name);
535 extern void swTreeSetImageList(STREE tree, SBITMAP bitmap, SBITMAP mask,
536                                int width, int height, int count);
537 extern void swTreeSetItemCollapsed(STREE tree, STREEITEM item, int collapsed);
538 extern void swTreeSetCallback(STREE tree, TreeCallback cb);
539 extern void swTreeSetClientData(STREE tree, void *data);
540 extern int swTreeGetItemTitle(STREE tree, STREEITEM item, char *buf, int len);
541 extern STREEITEM swTreeHitTest(STREE tree, int x, int y);
542 extern void swTreeSetOverlayImage(STREE tree, int index);
543 extern void swTreeSetFlags(STREE tree, STREEITEM item, int mask, int flags);
544 extern void swTreeSetItemName(STREE tree, STREEITEM item, const char* name);
545 extern char *swTreeGetItemName(STREE tree, STREEITEM item);
546 
547 
548 /* header control */
549 extern SHEADER swCreateHeader(int x, int y, int width, int height,
550                               SWND parent);
551 extern void swDestroyHeader(SHEADER header);
552 extern void swHeaderInsertItem(SHEADER header, int pos, const char *name,
553                                int width);
554 extern void swHeaderGetSize(SHEADER header, int *width, int *height);
555 extern void swHeaderSetSize(SHEADER header, int width, int height);
556 extern int swHeaderGetItemWidth(SHEADER header, int pos);
557 extern void swHeaderSetItemWidth(SHEADER header, int pos, int width);
558 extern void swHeaderSetCallback(SHEADER header, HeaderCallback cb);
559 extern void swHeaderSetClientData(SHEADER header, void *data);
560 
561 /* toolbar */
562 extern STOOLBAR swCreateToolbar(SWND parent, SBITMAP bitmap,
563                                 int width, int height, int count,
564                                 const int *buttonInfo);
565 extern SWND swToolbarGetWindow(STOOLBAR toolbar);
566 extern void swToolbarSetButtonFlags(STOOLBAR toolbar, int button,
567                                     int mask, int flags);
568 extern void swToolbarSetTooltipCallback(STOOLBAR toolbar, TooltipCallback cb);
569 extern void swToolbarSetClientData(STOOLBAR toolbar, void *data);
570 extern void swDestroyToolbar(STOOLBAR tb);
571 
572 /* mouse capture */
573 
574 extern void swSetCapture(SWND wnd);
575 extern void swReleaseCapture(SWND wnd);
576 
577 /* miscellaneous */
578 
579 extern double swGetCurrentTime(void);
580 extern void swGetTempFile(char *buf, const char* name, const char* ext,
581                           int len);
582 extern void swGetTempDir(char *path, int len);
583 extern void swGetTempPath(char *path, const char* name, const char* ext,
584                           int len);
585 extern char swGetPathSeperator(void);
586 extern int swTruncateClose(int filedes);
587 extern const char* swGetLinefeedString(void);
588 extern int swIsXML(const char *filename);
589 extern void swRemoveFile(const char* path);
590 extern char* swKillFileQuotes(char* filename);
591 extern char* swGetEnv(const char* variablename);
592 extern const char* swGetToNullDevice(void);
593 extern int swMkdirCommand(SWND wnd, const char* dir);
594 extern int swCopyFile(SWND wnd, const char* file, const char* dir);
595 extern int swShellCommand(SWND wnd, const char* file,
596                           const char* command, const char* directory);
597 extern void swLoadString(int id, char *buf, int len);
598 extern void swDeleteCallbacks(SWND wnd);
599 
600 extern int swCheckRunningProcess(void);
601 extern int swCreateCheckableProcess(const char *cmdline);
602 extern int swGetLastError(void);
603 extern void swSetLang(int lang);
604 extern int swGetLang(void);
605 
606 /* persistent preferences */
607 extern void swPreferencesDefault(void);
608 extern STABLE swLoadPreferences(const char *companyName, const char *appName);
609 extern void swSavePreferences(STABLE pref);
610 extern void swDeletePreferences(STABLE pref);
611 extern const char *swGetPreference(STABLE table, const char *title,
612                                    const char *defaultValue);
613 extern void swSetPreference(STABLE table, const char *title, const char *value);
614 extern int swGetIntPreference(STABLE table, const char *title,
615                               int defaultValue);
616 extern void swSetIntPreference(STABLE table, const char *title, int value);
617 extern void swUninstall(STABLE table, const char *companyName,
618                         const char *appName);
619 
620 /* drag und drop */
621 
622 extern void swRegisterDropTarget(SWND wnd, DropCallback dropCB);
623 extern void swUnregisterDropTarget(SWND wnd);
624 extern int swDragDrop(SWND wnd, int operations, SBITMAP bitmap, SBITMAP mask,
625                       int x, int y, int width, int height);
626 
627 /* accelerators */
628 
629 extern void swAddAccelerator(SWND wnd, int key, int modifiers, int id);
630 
631 /* MacOSX X11 startup flag */
632 
633 #ifdef MACOSX
634 extern void set_start_aqua_X11(void);
635 #endif
636 
637 /* init callback */
638 extern void initCallback(void);
639 
640 /* Windows SpaceNavigator driver */
641 
642 #ifdef WIN32
643 extern int swSpaceNavInit();
644 extern int swSpaceNavGetData(int index);
645 extern void swSpaceNavFree();
646 #endif
647 
648 
649 /* tree relationships */
650 enum swInsert {
651     SW_INSERT_ROOT,
652     SW_INSERT_BEFORE,
653     SW_INSERT_AFTER,
654     SW_INSERT_FIRST_CHILD,
655     SW_INSERT_LAST_CHILD
656 };
657 
658 /* scrollbar flags */
659 enum swScrollbarFlags {
660     SW_VERTICAL   = 0x0001,
661     SW_HORIZONTAL = 0x0002,
662     SW_ARROWS     = 0x0004,
663     SW_NO_ARROWS  = 0x0008
664 };
665 
666 /* types of scrollbar events */
667 enum swScrollbarEvents {
668     SW_SB_SCROLL,
669     SW_SB_LINE_UP,
670     SW_SB_LINE_DOWN,
671     SW_SB_PAGE_UP,
672     SW_SB_PAGE_DOWN
673 };
674 
675 /* types of text edit controls */
676 enum swTextEditControls {
677     SW_EDITABLE     = 0x0000,
678     SW_NON_EDITABLE = 0x0001,
679     SW_MULTI_LINE   = 0x0002,
680     SW_SINGLE_LINE  = 0x0004,
681     SW_PASSWORD     = 0x0008
682 };
683 
684 /* font styles */
685 enum swTextFontStyles {
686     SW_PLAIN     = 0x0000,
687     SW_BOLD      = 0x0001,
688     SW_ITALIC    = 0x0002,
689     SW_UNDERLINE = 0x0004
690 };
691 
692 /* aligment */
693 enum swTextAlignment {
694     SW_ALIGN_LEFT,
695     SW_ALIGN_CENTER,
696     SW_ALIGN_RIGHT
697 };
698 
699 /* message box types */
700 enum swMessageBoxTypes {
701     SW_MB_OK,
702     SW_MB_OKCANCEL,
703     SW_MB_YESNO,
704     SW_MB_YESNOCANCEL
705 };
706 
707 /* message box icon types */
708 enum swMessageBoxIconTypes {
709     SW_MB_NOICON,
710     SW_MB_ERROR,
711     SW_MB_INFORMATION,
712     SW_MB_QUESTION,
713     SW_MB_WARNING
714 };
715 
716 /* message box return values */
717 #define IDOK 1
718 #define IDCANCEL 2
719 #define IDYES 6
720 #define IDNO 7
721 
722 /* line styles */
723 enum swLineStyles {
724     SW_SOLID,
725     SW_DASH,
726     SW_DOT
727 };
728 
729 /* line cap styles */
730 enum swLineCapStyles {
731     SW_CAP_ROUND,
732     SW_CAP_SQUARE,
733     SW_CAP_FLAT
734 };
735 
736 /* line join styles */
737 
738 enum swLineJoinStyles {
739     SW_JOIN_ROUND,
740     SW_JOIN_MITER,
741     SW_JOIN_BEVEL
742 };
743 
744 /* fill styles */
745 
746 enum swFillStyles {
747     SW_FILL_SOLID,
748     SW_FILL_STIPPLE
749 };
750 
751 /* tree item flags */
752 enum swTreeItemFlags {
753     SW_TREE_ITEM_COLLAPSED = 0x0001,
754     SW_TREE_ITEM_SELECTED  = 0x0002,
755     SW_TREE_ITEM_OVERLAY   = 0x0004
756 };
757 
758 /* standard cursors */
759 enum swStandardCursors {
760     SW_CURSOR_ARROW,
761     SW_CURSOR_DBL_ARROW_HORZ,
762     SW_CURSOR_DBL_ARROW_VERT,
763     SW_CURSOR_CROSS,
764     SW_CURSOR_CIRCLE,
765     SW_CURSOR_ROLL,
766     SW_CURSOR_NONE
767 };
768 
769 enum swTreeFlags {
770     SW_TREE_SELECT,
771     SW_TREE_BEGIN_DRAG
772 };
773 
774 /* modifier key masks */
775 enum swModifierKeyMasks {
776     SW_SHIFT   = 0x0001,
777     SW_ALT     = 0x0002,
778     SW_CONTROL = 0x0004
779 };
780 
781 enum swColorFlags {
782     SW_COLOR_WINDOW_FG,
783     SW_COLOR_WINDOW_BG,
784     SW_COLOR_TSHADOW,
785     SW_COLOR_BSHADOW,
786     SW_COLOR_FACE,
787     SW_COLOR_HIGHLIGHT,
788     SW_COLOR_TEXT,
789     SW_COLOR_HIGHLIGHT_TEXT
790 };
791 
792 enum swDragDropFlags {
793     SW_DRAG_ENTER,
794     SW_DRAG_OVER,
795     SW_DRAG_LEAVE,
796     SW_DROP
797 };
798 
799 enum swDragOperations {
800     SW_DRAG_COPY = 0x0001,
801     SW_DRAG_MOVE = 0x0002,
802     SW_DRAG_LINK = 0x0004
803 };
804 
805 enum swMenuFlags {
806     SW_MENU_DISABLED   = 0x0001,
807     SW_MENU_CHECKED    = 0x0002,
808     SW_MENU_RADIO_ITEM = 0x0004
809 };
810 
811 /* toolbar button states */
812 
813 enum swToolbarFlags {
814     SW_TB_DISABLED     = 0x0001,
815     SW_TB_CHECKED      = 0x0002,
816     SW_TB_DONT_UPDATE  = 0x0004
817 };
818 
819 #ifdef __cplusplus
820 }
821 #endif
822 
823 #endif /* _SWT_H */
824