- updated the XDND code in WINGs to work with GDK based applications.
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
blobb72de53bd726dbb0650491d35e1392dde373e3fc
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 < 20041030
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 */
26 #define DOUBLE_BUFFER 1
28 #define WC_UserWidget 128
30 #define SCROLLER_WIDTH 20
32 #define XDND_VERSION 3
35 typedef struct W_Application {
36 char *applicationName;
37 int argc;
38 char **argv;
39 char *resourcePath;
40 } W_Application;
43 typedef struct W_Font {
44 struct W_Screen *screen;
46 struct _XftFont *font;
48 short height;
49 short y;
50 short refCount;
51 char *name;
52 } W_Font;
55 typedef struct W_Pixmap {
56 struct W_Screen *screen;
57 Pixmap pixmap;
58 Pixmap mask;
59 unsigned short width;
60 unsigned short height;
61 short depth;
62 short refCount;
63 } W_Pixmap;
66 typedef struct W_Color {
67 struct W_Screen *screen;
69 XColor color;
70 unsigned short alpha;
71 short refCount;
72 GC gc;
73 struct {
74 unsigned int exact:1;
75 } flags;
76 } W_Color;
79 typedef struct W_FocusInfo {
80 struct W_View *toplevel;
81 struct W_View *focused; /* view that has the focus in this toplevel */
82 struct W_FocusInfo *next;
83 } W_FocusInfo;
87 typedef void* W_DndState(WMView *destView, XClientMessageEvent *event,
88 WMDraggingInfo *info);
91 typedef struct W_DragOperationItem {
92 WMDragOperationType type;
93 char* text;
94 } W_DragOperationItem;
97 typedef struct W_DragSourceInfo {
98 WMView *sourceView;
99 Window destinationWindow;
100 W_DndState *state;
101 WMSelectionProcs *selectionProcs;
102 Window icon;
103 WMPoint imageLocation;
104 WMPoint mouseOffset; /* mouse pos in icon */
105 Cursor dragCursor;
106 WMRect noPositionMessageZone;
107 Atom firstThreeTypes[3];
108 } W_DragSourceInfo;
111 typedef struct W_DragDestinationInfo {
112 WMView *destView;
113 WMView *xdndAwareView;
114 Window sourceWindow;
115 W_DndState *state;
116 Bool sourceActionChanged;
117 WMArray *sourceTypes;
118 WMArray *requiredTypes;
119 Bool typeListAvailable;
120 WMArray *dropDatas;
121 } W_DragDestinationInfo;
124 struct W_DraggingInfo {
125 unsigned char protocolVersion; /* version supported on the other side */
126 Time timestamp;
128 Atom sourceAction;
129 Atom destinationAction;
131 W_DragSourceInfo* sourceInfo; /* infos needed by source */
132 W_DragDestinationInfo* destInfo; /* infos needed by destination */
133 } W_DraggingInfo;
136 typedef struct W_Screen {
137 Display *display;
138 int screen;
139 int depth;
141 Colormap colormap;
143 Visual *visual;
145 Time lastEventTime;
147 Window rootWin;
149 struct W_View *rootView;
151 RContext *rcontext;
153 struct W_IMContext *imctx;
155 struct _XftDraw *xftdraw; /* shared XftDraw */
157 /* application related */
159 W_FocusInfo *focusInfo;
161 RImage *applicationIconImage; /* image (can have alpha channel) */
162 struct W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
163 Window applicationIconWindow;
165 struct W_Window *windowList; /* list of windows in the app */
167 Window groupLeader; /* the leader of the application */
168 /* also used for other things */
170 struct W_SelectionHandlers *selectionHandlerList;
172 struct {
173 unsigned int hasAppIcon:1;
174 unsigned int simpleApplication:1;
175 } aflags;
177 WMOpenPanel *sharedOpenPanel;
178 WMSavePanel *sharedSavePanel;
180 struct W_FontPanel *sharedFontPanel;
182 struct W_ColorPanel *sharedColorPanel;
184 Pixmap stipple;
186 struct W_View *dragSourceView;
187 struct W_DraggingInfo dragInfo;
189 /* colors */
190 W_Color *white;
191 W_Color *black;
192 W_Color *gray;
193 W_Color *darkGray;
195 GC stippleGC;
197 GC copyGC;
198 GC clipGC;
200 GC monoGC; /* GC for 1bpp visuals */
202 GC xorGC;
204 GC ixorGC; /* IncludeInferiors XOR */
206 GC drawStringGC; /* for WMDrawString() */
208 GC drawImStringGC; /* for WMDrawImageString() */
210 W_Font *normalFont;
212 W_Font *boldFont;
214 WMHashTable *fontCache;
216 Bool antialiasedText;
218 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
220 struct W_Balloon *balloon;
223 struct W_Pixmap *checkButtonImageOn;
224 struct W_Pixmap *checkButtonImageOff;
226 struct W_Pixmap *radioButtonImageOn;
227 struct W_Pixmap *radioButtonImageOff;
229 struct W_Pixmap *buttonArrow;
230 struct W_Pixmap *pushedButtonArrow;
232 struct W_Pixmap *scrollerDimple;
234 struct W_Pixmap *upArrow;
235 struct W_Pixmap *downArrow;
236 struct W_Pixmap *leftArrow;
237 struct W_Pixmap *rightArrow;
239 struct W_Pixmap *hiUpArrow;
240 struct W_Pixmap *hiDownArrow;
241 struct W_Pixmap *hiLeftArrow;
242 struct W_Pixmap *hiRightArrow;
244 struct W_Pixmap *pullDownIndicator;
245 struct W_Pixmap *popUpIndicator;
247 struct W_Pixmap *checkMark;
249 struct W_Pixmap *homeIcon;
250 struct W_Pixmap *altHomeIcon;
252 struct W_Pixmap *trashcanIcon;
253 struct W_Pixmap *altTrashcanIcon;
255 struct W_Pixmap *createDirIcon;
256 struct W_Pixmap *altCreateDirIcon;
258 struct W_Pixmap *disketteIcon;
259 struct W_Pixmap *altDisketteIcon;
260 struct W_Pixmap *unmountIcon;
261 struct W_Pixmap *altUnmountIcon;
263 struct W_Pixmap *magnifyIcon;
264 /*struct W_Pixmap *altMagnifyIcon;*/
265 struct W_Pixmap *wheelIcon;
266 struct W_Pixmap *grayIcon;
267 struct W_Pixmap *rgbIcon;
268 struct W_Pixmap *cmykIcon;
269 struct W_Pixmap *hsbIcon;
270 struct W_Pixmap *customPaletteIcon;
271 struct W_Pixmap *colorListIcon;
273 struct W_Pixmap *defaultObjectIcon;
275 Cursor defaultCursor;
277 Cursor textCursor;
279 Cursor invisibleCursor;
281 Atom attribsAtom; /* GNUstepWindowAttributes */
283 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
285 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
287 Atom clipboardAtom; /* CLIPBOARD */
289 Atom xdndAwareAtom; /* XdndAware */
290 Atom xdndSelectionAtom;
291 Atom xdndEnterAtom;
292 Atom xdndLeaveAtom;
293 Atom xdndPositionAtom;
294 Atom xdndDropAtom;
295 Atom xdndFinishedAtom;
296 Atom xdndTypeListAtom;
297 Atom xdndActionListAtom;
298 Atom xdndActionDescriptionAtom;
299 Atom xdndStatusAtom;
301 Atom xdndActionCopy;
302 Atom xdndActionMove;
303 Atom xdndActionLink;
304 Atom xdndActionAsk;
305 Atom xdndActionPrivate;
307 Atom wmIconDragOffsetAtom;
309 Atom wmStateAtom; /* WM_STATE */
311 Atom utf8String;
313 Atom netwmName;
314 Atom netwmIconName;
315 Atom netwmIcon;
317 /* stuff for detecting double-clicks */
318 Time lastClickTime; /* time of last mousedown event */
319 Window lastClickWindow; /* window of the last mousedown */
321 struct W_View *modalView;
322 unsigned modalLoop:1;
323 unsigned ignoreNextDoubleClick:1;
324 } W_Screen;
328 typedef struct W_ViewDelegate {
329 void *data;
331 void (*didMove)(struct W_ViewDelegate*, WMView*);
333 void (*didResize)(struct W_ViewDelegate*, WMView*);
335 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
337 void (*willResize)(struct W_ViewDelegate*, WMView*,
338 unsigned int*, unsigned int*);
339 } W_ViewDelegate;
343 typedef struct W_View {
344 struct W_Screen *screen;
346 WMWidget *self; /* must point to the widget the view belongs to */
348 W_ViewDelegate *delegate;
350 Window window;
352 WMSize size;
354 short topOffs;
355 short leftOffs;
356 short bottomOffs;
357 short rightOffs;
359 WMPoint pos;
361 struct W_View *nextFocusChain; /* next/prev in focus chain */
362 struct W_View *prevFocusChain;
364 struct W_View *nextResponder; /* next to receive keyboard events */
366 struct W_View *parent; /* parent WMView */
368 struct W_View *childrenList; /* first in list of child windows */
370 struct W_View *nextSister; /* next on parent's children list */
372 WMArray *eventHandlers; /* event handlers for this window */
374 unsigned long attribFlags;
375 XSetWindowAttributes attribs;
377 void *hangedData; /* data holder for user program */
379 WMColor *backColor;
381 Cursor cursor;
383 Atom *droppableTypes;
384 struct W_DragSourceProcs *dragSourceProcs;
385 struct W_DragDestinationProcs *dragDestinationProcs;
386 WMPixmap *dragImage;
387 int helpContext;
389 XIC xic;
391 struct {
392 unsigned int realized:1;
393 unsigned int mapped:1;
394 unsigned int parentDying:1;
395 unsigned int dying:1; /* the view is being destroyed */
396 unsigned int topLevel:1; /* is a top level window */
397 unsigned int root:1; /* is the root window */
398 unsigned int mapWhenRealized:1; /* map the view when it's realized */
399 unsigned int alreadyDead:1; /* view was freed */
401 unsigned int dontCompressMotion:1; /* motion notify event compress */
402 unsigned int notifySizeChanged:1;
403 unsigned int dontCompressExpose:1; /* expose event compress */
405 /* toplevel only */
406 unsigned int worksWhenModal:1;
407 unsigned int pendingRelease1:1;
408 unsigned int pendingRelease2:1;
409 unsigned int pendingRelease3:1;
410 unsigned int pendingRelease4:1;
411 unsigned int pendingRelease5:1;
412 unsigned int xdndHintSet:1;
413 } flags;
415 int refCount;
416 } W_View;
419 typedef struct W_EventHandler {
420 unsigned long eventMask;
422 WMEventProc *proc;
424 void *clientData;
425 } W_EventHandler;
430 typedef struct _WINGsConfiguration {
431 char *systemFont;
432 char *boldSystemFont;
433 int defaultFontSize;
434 Bool antialiasedText;
435 char *floppyPath;
436 unsigned doubleClickDelay;
437 unsigned mouseWheelUp;
438 unsigned mouseWheelDown;
439 } _WINGsConfiguration;
441 extern _WINGsConfiguration WINGsConfiguration;
445 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
448 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
449 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
451 #define W_VIEW_REALIZED(view) (view)->flags.realized
452 #define W_VIEW_MAPPED(view) (view)->flags.mapped
454 #define W_VIEW_DISPLAY(view) (view)->screen->display
455 #define W_VIEW_SCREEN(view) (view)->screen
456 #define W_VIEW_DRAWABLE(view) (view)->window
458 #define W_VIEW_WIDTH(view) (view)->size.width
459 #define W_VIEW_HEIGHT(view) (view)->size.height
462 #define W_PIXEL(c) (c)->color.pixel
464 #define W_FONTID(f) (f)->font->fid
466 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
470 W_View *W_GetViewForXWindow(Display *display, Window window);
472 W_View *W_CreateView(W_View *parent);
474 W_View *W_CreateTopView(W_Screen *screen);
476 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
479 W_View *W_CreateRootView(W_Screen *screen);
481 void W_DestroyView(W_View *view);
483 void W_RealizeView(W_View *view);
485 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
487 void W_RaiseView(W_View *view);
489 void W_LowerView(W_View *view);
492 void W_MapView(W_View *view);
494 void W_MapSubviews(W_View *view);
496 void W_UnmapSubviews(W_View *view);
498 W_View *W_TopLevelOfView(W_View *view);
500 void W_UnmapView(W_View *view);
502 void W_MoveView(W_View *view, int x, int y);
504 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
506 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
508 void W_SetViewCursor(W_View *view, Cursor cursor);
510 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
511 unsigned int height, WMReliefType relief);
513 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
514 unsigned int width, unsigned int height,
515 WMReliefType relief,
516 GC black, GC dark, GC light, GC white);
518 void W_CallDestroyHandlers(W_View *view);
520 void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
521 W_Font *font, WMReliefType relief, char *text,
522 WMAlignment alignment, W_Pixmap *image,
523 WMImagePosition position, WMColor *backColor, int ofs);
525 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
526 int width, WMAlignment alignment, WMColor *color,
527 int wrap, char *text, int length);
529 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
532 int W_TextWidth(WMFont *font, char *text, int length);
535 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
537 void W_DispatchMessage(W_View *target, XEvent *event);
539 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
541 W_View *W_FocusedViewOfToplevel(W_View *view);
543 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
545 void W_ReleaseView(WMView *view);
547 WMView *W_RetainView(WMView *view);
549 void W_InitApplication(WMScreen *scr);
551 void W_InitNotificationCenter(void);
553 W_Class W_RegisterUserWidget(void);
555 void W_RedisplayView(WMView *view);
557 Bool W_ApplicationInitialized(void);
559 void W_HandleSelectionEvent(XEvent *event);
561 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
563 void W_FlushASAPNotificationQueue(void);
565 void W_FlushIdleNotificationQueue(void);
567 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
569 void W_BalloonHandleEnterView(WMView *view);
571 void W_BalloonHandleLeaveView(WMView *view);
573 Bool W_CheckIdleHandlers(void);
575 void W_CheckTimerHandlers(void);
577 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
579 /* XDnD */
580 Atom W_OperationToAction(WMScreen *scr, WMDragOperationType operation);
582 WMDragOperationType W_ActionToOperation(WMScreen *scr, Atom action);
584 void W_FreeDragOperationItem(void* item);
586 Bool W_SendDnDClientMessage(Display *dpy, Window win, Atom message,
587 unsigned long data1, unsigned long data2,
588 unsigned long data3, unsigned long data4,
589 unsigned long data5);
591 void W_DragSourceStartTimer(WMDraggingInfo *info);
593 void W_DragSourceStopTimer();
595 void W_DragSourceStateHandler(WMDraggingInfo *info, XClientMessageEvent *event);
597 void W_DragDestinationStartTimer(WMDraggingInfo *info);
599 void W_DragDestinationStopTimer();
601 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info, WMView *toplevel,
602 XClientMessageEvent *event);
604 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo *info,
605 WMView *toplevel,
606 XClientMessageEvent *event);
608 void W_DragDestinationCancelDropOnEnter(WMView *toplevel, WMDraggingInfo *info);
610 void W_DragDestinationStateHandler(WMDraggingInfo *info,
611 XClientMessageEvent *event);
613 void W_DragDestinationInfoClear(WMDraggingInfo *info);
615 void W_FreeViewXdndPart(WMView *view);
617 /* XIM */
618 void W_InitIM(WMScreen *scr);
620 void W_CreateIC(WMView *view);
622 void W_DestroyIC(WMView *view);
624 void W_FocusIC(WMView *view);
626 void W_UnFocusIC(WMView *view);
628 void W_SetPreeditPositon(W_View *view, int x, int y);
630 int W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer,
631 int buflen, KeySym *keysym, Status *status);
633 #ifdef __cplusplus
635 #endif /* __cplusplus */
637 #endif /* _WINGSP_H_ */