For libwraster:
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
blob2ec68e6d97a790fbf9bded00735175cb5911f62f
1 #ifndef _WINGSP_H_
2 #define _WINGSP_H_
5 #include <X11/Xlib.h>
6 #include <X11/Xutil.h>
9 #include <WINGs/WINGs.h>
11 #if WINGS_H_VERSION < 20010117
12 #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
13 #endif
15 #include <assert.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <stdio.h>
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
25 #define DOUBLE_BUFFER
29 #define WC_UserWidget 128
33 #define SCROLLER_WIDTH 20
37 #define XDND_VERSION 4
40 typedef struct W_Application {
41 char *applicationName;
42 int argc;
43 char **argv;
44 char *resourcePath;
45 } W_Application;
48 typedef struct W_Font {
49 struct W_Screen *screen;
51 union {
52 XFontSet set;
53 XFontStruct *normal;
54 } font;
55 short height;
56 short y;
57 short refCount;
58 char *name;
59 unsigned int notFontSet:1;
60 } W_Font;
63 typedef struct W_Pixmap {
64 struct W_Screen *screen;
65 Pixmap pixmap;
66 Pixmap mask;
67 unsigned short width;
68 unsigned short height;
69 short depth;
70 short refCount;
71 } W_Pixmap;
74 typedef struct W_Color {
75 struct W_Screen *screen;
77 XColor color;
78 short refCount;
79 GC gc;
80 struct {
81 unsigned int exact:1;
82 } flags;
83 } W_Color;
86 typedef struct W_FocusInfo {
87 struct W_View *toplevel;
88 struct W_View *focused; /* view that has the focus in this toplevel */
89 struct W_FocusInfo *next;
90 } W_FocusInfo;
94 struct W_DraggingInfo {
95 Window destinationWindow;
96 Window sourceWindow;
98 WMPoint location;
100 unsigned sourceOperation;
101 WMPixmap *image;
102 WMPoint imageLocation;
104 char **types;
106 Time timestamp;
108 int protocolVersion;
110 /* should be treated as internal data */
111 WMView *sourceView;
112 WMView *destView;
113 WMSize mouseOffset;
114 unsigned finished:1;
118 typedef struct W_Screen {
119 Display *display;
120 int screen;
121 int depth;
123 Colormap colormap;
125 Visual *visual;
127 Time lastEventTime;
129 Window rootWin;
131 struct W_View *rootView;
133 RContext *rcontext;
135 /* application related */
137 W_FocusInfo *focusInfo;
139 RImage *applicationIconImage; /* image (can have alpha channel) */
140 struct W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
141 Window applicationIconWindow;
143 struct W_Window *windowList; /* list of windows in the app */
145 Window groupLeader; /* the leader of the application */
146 /* also used for other things */
148 struct W_SelectionHandlers *selectionHandlerList;
150 struct {
151 unsigned int hasAppIcon:1;
152 unsigned int simpleApplication:1;
153 } aflags;
155 WMOpenPanel *sharedOpenPanel;
156 WMSavePanel *sharedSavePanel;
158 struct W_FontPanel *sharedFontPanel;
160 struct W_ColorPanel *sharedColorPanel;
162 Pixmap stipple;
164 struct W_View *dragSourceView;
165 struct W_DraggingInfo dragInfo;
167 /* colors */
168 W_Color *white;
169 W_Color *black;
170 W_Color *gray;
171 W_Color *darkGray;
173 GC stippleGC;
175 GC copyGC;
176 GC clipGC;
178 GC monoGC; /* GC for 1bpp visuals */
180 GC xorGC;
182 GC ixorGC; /* IncludeInferiors XOR */
184 GC textFieldGC;
186 W_Font *normalFont;
188 W_Font *boldFont;
190 WMHashTable *fontCache;
192 Bool useMultiByte;
194 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
196 struct W_Balloon *balloon;
199 struct W_Pixmap *checkButtonImageOn;
200 struct W_Pixmap *checkButtonImageOff;
202 struct W_Pixmap *radioButtonImageOn;
203 struct W_Pixmap *radioButtonImageOff;
205 struct W_Pixmap *buttonArrow;
206 struct W_Pixmap *pushedButtonArrow;
208 struct W_Pixmap *scrollerDimple;
210 struct W_Pixmap *upArrow;
211 struct W_Pixmap *downArrow;
212 struct W_Pixmap *leftArrow;
213 struct W_Pixmap *rightArrow;
215 struct W_Pixmap *hiUpArrow;
216 struct W_Pixmap *hiDownArrow;
217 struct W_Pixmap *hiLeftArrow;
218 struct W_Pixmap *hiRightArrow;
220 struct W_Pixmap *pullDownIndicator;
221 struct W_Pixmap *popUpIndicator;
223 struct W_Pixmap *checkMark;
225 struct W_Pixmap *homeIcon;
226 struct W_Pixmap *altHomeIcon;
228 struct W_Pixmap *trashcanIcon;
229 struct W_Pixmap *altTrashcanIcon;
231 struct W_Pixmap *createDirIcon;
232 struct W_Pixmap *altCreateDirIcon;
234 struct W_Pixmap *disketteIcon;
235 struct W_Pixmap *altDisketteIcon;
236 struct W_Pixmap *unmountIcon;
237 struct W_Pixmap *altUnmountIcon;
239 struct W_Pixmap *magnifyIcon;
240 /* struct W_Pixmap *altMagnifyIcon;*/
241 struct W_Pixmap *wheelIcon;
242 struct W_Pixmap *grayIcon;
243 struct W_Pixmap *rgbIcon;
244 struct W_Pixmap *cmykIcon;
245 struct W_Pixmap *hsbIcon;
246 struct W_Pixmap *customPaletteIcon;
247 struct W_Pixmap *colorListIcon;
249 struct W_Pixmap *defaultObjectIcon;
251 Cursor defaultCursor;
253 Cursor textCursor;
255 Cursor invisibleCursor;
257 Atom attribsAtom; /* GNUstepWindowAttributes */
259 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
261 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
263 Atom clipboardAtom; /* CLIPBOARD */
265 Atom xdndAwareAtom; /* XdndAware */
266 Atom xdndSelectionAtom;
267 Atom xdndEnterAtom;
268 Atom xdndLeaveAtom;
269 Atom xdndPositionAtom;
270 Atom xdndDropAtom;
271 Atom xdndFinishedAtom;
272 Atom xdndTypeListAtom;
273 Atom xdndStatusAtom;
275 Atom xdndActionCopy;
276 Atom xdndActionMove;
277 Atom xdndActionLink;
278 Atom xdndActionAsk;
279 Atom xdndActionPrivate;
281 Atom wmIconDragOffsetAtom;
283 Atom wmStateAtom; /* WM_STATE */
285 /* stuff for detecting double-clicks */
286 Time lastClickTime; /* time of last mousedown event */
287 Window lastClickWindow; /* window of the last mousedown */
289 struct W_View *modalView;
290 unsigned modalLoop:1;
291 unsigned ignoreNextDoubleClick:1;
292 } W_Screen;
296 typedef struct W_ViewDelegate {
297 void *data;
299 void (*didMove)(struct W_ViewDelegate*, WMView*);
301 void (*didResize)(struct W_ViewDelegate*, WMView*);
303 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
305 void (*willResize)(struct W_ViewDelegate*, WMView*,
306 unsigned int*, unsigned int*);
307 } W_ViewDelegate;
311 typedef struct W_View {
312 struct W_Screen *screen;
314 WMWidget *self; /* must point to the widget the
315 * view belongs to */
317 W_ViewDelegate *delegate;
319 Window window;
321 WMSize size;
323 short topOffs;
324 short leftOffs;
325 short bottomOffs;
326 short rightOffs;
328 WMPoint pos;
330 struct W_View *nextFocusChain; /* next/prev in focus chain */
331 struct W_View *prevFocusChain;
333 struct W_View *nextResponder; /* next to receive keyboard events */
335 struct W_View *parent; /* parent WMView */
337 struct W_View *childrenList; /* first in list of child windows */
339 struct W_View *nextSister; /* next on parent's children list */
341 WMArray *eventHandlers; /* event handlers for this window */
343 unsigned long attribFlags;
344 XSetWindowAttributes attribs;
346 void *hangedData; /* data holder for user program */
348 WMColor *backColor;
350 Cursor cursor;
352 Atom *droppableTypes;
353 struct W_DragSourceProcs *dragSourceProcs;
354 struct W_DragDestinationProcs *dragDestinationProcs;
355 int helpContext;
358 struct {
359 unsigned int realized:1;
360 unsigned int mapped:1;
361 unsigned int parentDying:1;
362 unsigned int dying:1; /* the view is being destroyed */
363 unsigned int topLevel:1; /* is a top level window */
364 unsigned int root:1; /* is the root window */
365 unsigned int mapWhenRealized:1;/* map the view when it's realized */
366 unsigned int alreadyDead:1; /* view was freed */
368 unsigned int dontCompressMotion:1; /* motion notify event compress */
369 unsigned int notifySizeChanged:1;
370 unsigned int dontCompressExpose:1; /* will compress all expose
371 events into one */
372 /* toplevel only */
373 unsigned int worksWhenModal:1;
374 unsigned int pendingRelease1:1;
375 unsigned int pendingRelease2:1;
376 unsigned int pendingRelease3:1;
377 unsigned int pendingRelease4:1;
378 unsigned int pendingRelease5:1;
379 unsigned int xdndHintSet:1;
380 } flags;
382 int refCount;
383 } W_View;
386 typedef struct W_EventHandler {
387 unsigned long eventMask;
389 WMEventProc *proc;
391 void *clientData;
392 } W_EventHandler;
397 typedef struct _WINGsConfiguration {
398 char *systemFont;
399 char *boldSystemFont;
400 int defaultFontSize;
401 Bool useMultiByte;
402 char *floppyPath;
403 unsigned doubleClickDelay;
404 unsigned mouseWheelUp;
405 unsigned mouseWheelDown;
406 } _WINGsConfiguration;
408 extern _WINGsConfiguration WINGsConfiguration;
412 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
415 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
416 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
418 #define W_VIEW_REALIZED(view) (view)->flags.realized
419 #define W_VIEW_MAPPED(view) (view)->flags.mapped
421 #define W_VIEW_DISPLAY(view) (view)->screen->display
422 #define W_VIEW_SCREEN(view) (view)->screen
423 #define W_VIEW_DRAWABLE(view) (view)->window
425 #define W_VIEW_WIDTH(view) (view)->size.width
426 #define W_VIEW_HEIGHT(view) (view)->size.height
429 #define W_PIXEL(c) (c)->color.pixel
431 #define W_FONTID(f) (f)->font->fid
433 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
437 W_View *W_GetViewForXWindow(Display *display, Window window);
439 W_View *W_CreateView(W_View *parent);
441 W_View *W_CreateTopView(W_Screen *screen);
443 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
446 W_View *W_CreateRootView(W_Screen *screen);
448 void W_DestroyView(W_View *view);
450 void W_RealizeView(W_View *view);
452 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
454 void W_RaiseView(W_View *view);
456 void W_LowerView(W_View *view);
459 void W_MapView(W_View *view);
461 void W_MapSubviews(W_View *view);
463 void W_UnmapSubviews(W_View *view);
465 W_View *W_TopLevelOfView(W_View *view);
467 void W_UnmapView(W_View *view);
469 void W_MoveView(W_View *view, int x, int y);
471 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
473 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
475 void W_SetViewCursor(W_View *view, Cursor cursor);
477 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
478 unsigned int height, WMReliefType relief);
480 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
481 unsigned int width, unsigned int height,
482 WMReliefType relief,
483 GC black, GC dark, GC light, GC white);
485 void W_CallDestroyHandlers(W_View *view);
487 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
488 WMReliefType relief, char *text,
489 WMAlignment alignment, W_Pixmap *image,
490 WMImagePosition position, GC backGC, int ofs);
492 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
493 int width, WMAlignment alignment, GC gc,
494 int wrap, char *text, int length);
496 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
499 int W_TextWidth(WMFont *font, char *text, int length);
502 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
504 void W_DispatchMessage(W_View *target, XEvent *event);
506 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
508 W_View *W_FocusedViewOfToplevel(W_View *view);
510 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
512 void W_ReleaseView(WMView *view);
514 WMView *W_RetainView(WMView *view);
516 void W_InitApplication(WMScreen *scr);
518 void W_InitNotificationCenter(void);
520 W_Class W_RegisterUserWidget(void);
522 void W_RedisplayView(WMView *view);
524 Bool W_ApplicationInitialized(void);
526 void W_HandleSelectionEvent(XEvent *event);
528 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
530 void W_FlushASAPNotificationQueue(void);
532 void W_FlushIdleNotificationQueue(void);
534 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
536 void W_BalloonHandleEnterView(WMView *view);
538 void W_BalloonHandleLeaveView(WMView *view);
540 Bool W_CheckIdleHandlers(void);
542 void W_CheckTimerHandlers(void);
544 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
546 #ifdef __cplusplus
548 #endif /* __cplusplus */
550 #endif /* _WINGSP_H_ */