changed indentation to use spaces only
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
blob9d76b128d3ebcb2fa2f1de9d114ba965dbece7fd
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 < 20040406
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 4
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 #ifdef XFT
47 struct _XftFont *font;
48 #else
49 // pick one
50 //XFontSet font;
51 XFontStruct *font;
52 #endif
54 short height;
55 short y;
56 short refCount;
57 char *name;
58 //unsigned int notFontSet:1;
59 //unsigned int antialiased: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 unsigned short alpha;
79 short refCount;
80 GC gc;
81 struct {
82 unsigned int exact:1;
83 } flags;
84 } W_Color;
87 typedef struct W_FocusInfo {
88 struct W_View *toplevel;
89 struct W_View *focused; /* view that has the focus in this toplevel */
90 struct W_FocusInfo *next;
91 } W_FocusInfo;
95 typedef void* W_DndState(WMView *destView, XClientMessageEvent *event,
96 WMDraggingInfo *info);
99 typedef struct W_DragOperationItem {
100 WMDragOperationType type;
101 char* text;
102 } W_DragOperationItem;
105 typedef struct W_DragSourceInfo {
106 WMView *sourceView;
107 Window destinationWindow;
108 W_DndState *state;
109 WMSelectionProcs *selectionProcs;
110 Window icon;
111 WMPoint imageLocation;
112 WMPoint mouseOffset; /* mouse pos in icon */
113 Cursor dragCursor;
114 WMRect noPositionMessageZone;
115 Atom firstThreeTypes[3];
116 } W_DragSourceInfo;
119 typedef struct W_DragDestinationInfo {
120 WMView *destView;
121 Window sourceWindow;
122 W_DndState *state;
123 WMArray *sourceTypes;
124 WMArray *requiredTypes;
125 Bool typeListAvailable;
126 WMArray *dropDatas;
127 } W_DragDestinationInfo;
130 struct W_DraggingInfo {
131 unsigned char protocolVersion;
132 Time timestamp;
134 Atom sourceAction;
135 Atom destinationAction;
137 W_DragSourceInfo* sourceInfo; /* infos needed by source */
138 W_DragDestinationInfo* destInfo; /* infos needed by destination */
139 } W_DraggingInfo;
141 /* original
142 struct W_DraggingInfo {
143 Window destinationWindow;
144 Window sourceWindow;
146 WMPoint location;
148 unsigned sourceOperation;
149 WMPixmap *image;
150 WMPoint imageLocation;
152 char **types;
154 Time timestamp;
156 int protocolVersion;
158 // should be treated as internal data
159 WMView *sourceView;
160 WMView *destView;
161 WMSize mouseOffset;
162 unsigned finished:1;
167 typedef struct W_Screen {
168 Display *display;
169 int screen;
170 int depth;
172 Colormap colormap;
174 Visual *visual;
176 Time lastEventTime;
178 Window rootWin;
180 struct W_View *rootView;
182 RContext *rcontext;
184 struct W_IMContext *imctx;
186 struct _XftDraw *xftdraw; /* shared XftDraw */
188 /* application related */
190 W_FocusInfo *focusInfo;
192 RImage *applicationIconImage; /* image (can have alpha channel) */
193 struct W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
194 Window applicationIconWindow;
196 struct W_Window *windowList; /* list of windows in the app */
198 Window groupLeader; /* the leader of the application */
199 /* also used for other things */
201 struct W_SelectionHandlers *selectionHandlerList;
203 struct {
204 unsigned int hasAppIcon:1;
205 unsigned int simpleApplication:1;
206 } aflags;
208 WMOpenPanel *sharedOpenPanel;
209 WMSavePanel *sharedSavePanel;
211 struct W_FontPanel *sharedFontPanel;
213 struct W_ColorPanel *sharedColorPanel;
215 Pixmap stipple;
217 struct W_View *dragSourceView;
218 struct W_DraggingInfo dragInfo;
220 /* colors */
221 W_Color *white;
222 W_Color *black;
223 W_Color *gray;
224 W_Color *darkGray;
226 GC stippleGC;
228 GC copyGC;
229 GC clipGC;
231 GC monoGC; /* GC for 1bpp visuals */
233 GC xorGC;
235 GC ixorGC; /* IncludeInferiors XOR */
237 GC drawStringGC; /* for WMDrawString() */
239 GC drawImStringGC; /* for WMDrawImageString() */
241 W_Font *normalFont;
243 W_Font *boldFont;
245 WMHashTable *fontCache;
247 Bool useMultiByte;
249 Bool useWideChar;
251 Bool antialiasedText;
253 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
255 struct W_Balloon *balloon;
258 struct W_Pixmap *checkButtonImageOn;
259 struct W_Pixmap *checkButtonImageOff;
261 struct W_Pixmap *radioButtonImageOn;
262 struct W_Pixmap *radioButtonImageOff;
264 struct W_Pixmap *buttonArrow;
265 struct W_Pixmap *pushedButtonArrow;
267 struct W_Pixmap *scrollerDimple;
269 struct W_Pixmap *upArrow;
270 struct W_Pixmap *downArrow;
271 struct W_Pixmap *leftArrow;
272 struct W_Pixmap *rightArrow;
274 struct W_Pixmap *hiUpArrow;
275 struct W_Pixmap *hiDownArrow;
276 struct W_Pixmap *hiLeftArrow;
277 struct W_Pixmap *hiRightArrow;
279 struct W_Pixmap *pullDownIndicator;
280 struct W_Pixmap *popUpIndicator;
282 struct W_Pixmap *checkMark;
284 struct W_Pixmap *homeIcon;
285 struct W_Pixmap *altHomeIcon;
287 struct W_Pixmap *trashcanIcon;
288 struct W_Pixmap *altTrashcanIcon;
290 struct W_Pixmap *createDirIcon;
291 struct W_Pixmap *altCreateDirIcon;
293 struct W_Pixmap *disketteIcon;
294 struct W_Pixmap *altDisketteIcon;
295 struct W_Pixmap *unmountIcon;
296 struct W_Pixmap *altUnmountIcon;
298 struct W_Pixmap *magnifyIcon;
299 /*struct W_Pixmap *altMagnifyIcon;*/
300 struct W_Pixmap *wheelIcon;
301 struct W_Pixmap *grayIcon;
302 struct W_Pixmap *rgbIcon;
303 struct W_Pixmap *cmykIcon;
304 struct W_Pixmap *hsbIcon;
305 struct W_Pixmap *customPaletteIcon;
306 struct W_Pixmap *colorListIcon;
308 struct W_Pixmap *defaultObjectIcon;
310 Cursor defaultCursor;
312 Cursor textCursor;
314 Cursor invisibleCursor;
316 Atom attribsAtom; /* GNUstepWindowAttributes */
318 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
320 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
322 Atom clipboardAtom; /* CLIPBOARD */
324 Atom xdndAwareAtom; /* XdndAware */
325 Atom xdndSelectionAtom;
326 Atom xdndEnterAtom;
327 Atom xdndLeaveAtom;
328 Atom xdndPositionAtom;
329 Atom xdndDropAtom;
330 Atom xdndFinishedAtom;
331 Atom xdndTypeListAtom;
332 Atom xdndActionListAtom;
333 Atom xdndActionDescriptionAtom;
334 Atom xdndStatusAtom;
336 Atom xdndActionCopy;
337 Atom xdndActionMove;
338 Atom xdndActionLink;
339 Atom xdndActionAsk;
340 Atom xdndActionPrivate;
342 Atom wmIconDragOffsetAtom;
344 Atom wmStateAtom; /* WM_STATE */
346 /* stuff for detecting double-clicks */
347 Time lastClickTime; /* time of last mousedown event */
348 Window lastClickWindow; /* window of the last mousedown */
350 struct W_View *modalView;
351 unsigned modalLoop:1;
352 unsigned ignoreNextDoubleClick:1;
353 } W_Screen;
357 typedef struct W_ViewDelegate {
358 void *data;
360 void (*didMove)(struct W_ViewDelegate*, WMView*);
362 void (*didResize)(struct W_ViewDelegate*, WMView*);
364 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
366 void (*willResize)(struct W_ViewDelegate*, WMView*,
367 unsigned int*, unsigned int*);
368 } W_ViewDelegate;
372 typedef struct W_View {
373 struct W_Screen *screen;
375 WMWidget *self; /* must point to the widget the
376 * view belongs to */
378 W_ViewDelegate *delegate;
380 Window window;
382 WMSize size;
384 short topOffs;
385 short leftOffs;
386 short bottomOffs;
387 short rightOffs;
389 WMPoint pos;
391 struct W_View *nextFocusChain; /* next/prev in focus chain */
392 struct W_View *prevFocusChain;
394 struct W_View *nextResponder; /* next to receive keyboard events */
396 struct W_View *parent; /* parent WMView */
398 struct W_View *childrenList; /* first in list of child windows */
400 struct W_View *nextSister; /* next on parent's children list */
402 WMArray *eventHandlers; /* event handlers for this window */
404 unsigned long attribFlags;
405 XSetWindowAttributes attribs;
407 void *hangedData; /* data holder for user program */
409 WMColor *backColor;
411 Cursor cursor;
413 Atom *droppableTypes;
414 struct W_DragSourceProcs *dragSourceProcs;
415 struct W_DragDestinationProcs *dragDestinationProcs;
416 WMPixmap *dragImage;
417 int helpContext;
420 struct {
421 unsigned int realized:1;
422 unsigned int mapped:1;
423 unsigned int parentDying:1;
424 unsigned int dying:1; /* the view is being destroyed */
425 unsigned int topLevel:1; /* is a top level window */
426 unsigned int root:1; /* is the root window */
427 unsigned int mapWhenRealized:1; /* map the view when it's realized */
428 unsigned int alreadyDead:1; /* view was freed */
430 unsigned int dontCompressMotion:1; /* motion notify event compress */
431 unsigned int notifySizeChanged:1;
432 unsigned int dontCompressExpose:1; /* expose event compress */
434 /* toplevel only */
435 unsigned int worksWhenModal:1;
436 unsigned int pendingRelease1:1;
437 unsigned int pendingRelease2:1;
438 unsigned int pendingRelease3:1;
439 unsigned int pendingRelease4:1;
440 unsigned int pendingRelease5:1;
441 unsigned int xdndHintSet:1;
442 } flags;
444 int refCount;
445 } W_View;
448 typedef struct W_EventHandler {
449 unsigned long eventMask;
451 WMEventProc *proc;
453 void *clientData;
454 } W_EventHandler;
459 typedef struct _WINGsConfiguration {
460 char *systemFont;
461 char *boldSystemFont;
462 int defaultFontSize;
463 Bool antialiasedText;
464 Bool useMultiByte;
465 char *floppyPath;
466 unsigned doubleClickDelay;
467 unsigned mouseWheelUp;
468 unsigned mouseWheelDown;
469 } _WINGsConfiguration;
471 extern _WINGsConfiguration WINGsConfiguration;
475 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
478 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
479 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
481 #define W_VIEW_REALIZED(view) (view)->flags.realized
482 #define W_VIEW_MAPPED(view) (view)->flags.mapped
484 #define W_VIEW_DISPLAY(view) (view)->screen->display
485 #define W_VIEW_SCREEN(view) (view)->screen
486 #define W_VIEW_DRAWABLE(view) (view)->window
488 #define W_VIEW_WIDTH(view) (view)->size.width
489 #define W_VIEW_HEIGHT(view) (view)->size.height
492 #define W_PIXEL(c) (c)->color.pixel
494 #define W_FONTID(f) (f)->font->fid
496 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
500 W_View *W_GetViewForXWindow(Display *display, Window window);
502 W_View *W_CreateView(W_View *parent);
504 W_View *W_CreateTopView(W_Screen *screen);
506 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
509 W_View *W_CreateRootView(W_Screen *screen);
511 void W_DestroyView(W_View *view);
513 void W_RealizeView(W_View *view);
515 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
517 void W_RaiseView(W_View *view);
519 void W_LowerView(W_View *view);
522 void W_MapView(W_View *view);
524 void W_MapSubviews(W_View *view);
526 void W_UnmapSubviews(W_View *view);
528 W_View *W_TopLevelOfView(W_View *view);
530 void W_UnmapView(W_View *view);
532 void W_MoveView(W_View *view, int x, int y);
534 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
536 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
538 void W_SetViewCursor(W_View *view, Cursor cursor);
540 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
541 unsigned int height, WMReliefType relief);
543 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
544 unsigned int width, unsigned int height,
545 WMReliefType relief,
546 GC black, GC dark, GC light, GC white);
548 void W_CallDestroyHandlers(W_View *view);
550 void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
551 W_Font *font, WMReliefType relief, char *text,
552 WMAlignment alignment, W_Pixmap *image,
553 WMImagePosition position, WMColor *backColor, int ofs);
555 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
556 int width, WMAlignment alignment, WMColor *color,
557 int wrap, char *text, int length);
559 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
562 int W_TextWidth(WMFont *font, char *text, int length);
565 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
567 void W_DispatchMessage(W_View *target, XEvent *event);
569 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
571 W_View *W_FocusedViewOfToplevel(W_View *view);
573 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
575 void W_ReleaseView(WMView *view);
577 WMView *W_RetainView(WMView *view);
579 void W_InitApplication(WMScreen *scr);
581 void W_InitNotificationCenter(void);
583 W_Class W_RegisterUserWidget(void);
585 void W_RedisplayView(WMView *view);
587 Bool W_ApplicationInitialized(void);
589 void W_HandleSelectionEvent(XEvent *event);
591 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
593 void W_FlushASAPNotificationQueue(void);
595 void W_FlushIdleNotificationQueue(void);
597 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
599 void W_BalloonHandleEnterView(WMView *view);
601 void W_BalloonHandleLeaveView(WMView *view);
603 Bool W_CheckIdleHandlers(void);
605 void W_CheckTimerHandlers(void);
607 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
609 /* XDnD */
610 Atom W_OperationToAction(WMScreen *scr, WMDragOperationType operation);
612 WMDragOperationType W_ActionToOperation(WMScreen *scr, Atom action);
614 void W_FreeDragOperationItem(void* item);
616 Bool W_SendDnDClientMessage(Display *dpy, Window win, Atom message,
617 unsigned long data1, unsigned long data2,
618 unsigned long data3, unsigned long data4,
619 unsigned long data5);
621 void W_DragSourceStartTimer(WMDraggingInfo *info);
623 void W_DragSourceStopTimer();
625 void W_DragSourceStateHandler(WMDraggingInfo *info, XClientMessageEvent *event);
627 void W_DragDestinationStartTimer(WMDraggingInfo *info);
629 void W_DragDestinationStopTimer();
631 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info, WMView *toplevel,
632 XClientMessageEvent *event);
634 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo *info,
635 WMView *toplevel,
636 XClientMessageEvent *event);
638 void W_DragDestinationCancelDropOnEnter(WMView *toplevel, WMDraggingInfo *info);
640 void W_DragDestinationStateHandler(WMDraggingInfo *info,
641 XClientMessageEvent *event);
643 void W_DragDestinationInfoClear(WMDraggingInfo *info);
645 void W_FreeViewXdndPart(WMView *view);
647 #ifdef __cplusplus
649 #endif /* __cplusplus */
651 #endif /* _WINGSP_H_ */