wmaker: Fix whitespace in menu.h; passes checkpatch.pl inspection.
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
blob4cbe0fc29648a37d8ac0158f87abb2e2683a2df6
1 #ifndef _WINGSP_H_
2 #define _WINGSP_H_
5 #include <X11/Xlib.h>
6 #include <X11/Xutil.h>
8 #ifdef USE_PANGO
9 #include <pango/pango.h>
10 #endif
12 #include <WINGs/WINGs.h>
14 #if WINGS_H_VERSION < 20041030
15 #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
16 #endif
18 #include <assert.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <strings.h>
23 #include <stdio.h>
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
29 /* ---[ global settigns ]------------------------------------------------- */
31 #define DOUBLE_BUFFER 1
33 #define SCROLLER_WIDTH 20
35 typedef struct _WINGsConfiguration {
36 char *systemFont;
37 char *boldSystemFont;
38 int defaultFontSize;
39 Bool antialiasedText;
40 char *floppyPath;
41 unsigned doubleClickDelay;
42 unsigned mouseWheelUp;
43 unsigned mouseWheelDown;
44 } _WINGsConfiguration;
46 extern char *_WINGS_progname;
47 extern _WINGsConfiguration WINGsConfiguration;
48 extern struct W_Application WMApplication;
51 /* ---[ drag*.c ]--------------------------------------------------------- */
54 * We need to define these structure first because they are used in W_Screen
55 * below. The rest of drag-related stuff if after because it needs W_Screen
57 #define XDND_VERSION 3
59 typedef struct W_DraggingInfo {
60 unsigned char protocolVersion; /* version supported on the other side */
61 Time timestamp;
63 Atom sourceAction;
64 Atom destinationAction;
66 struct W_DragSourceInfo* sourceInfo; /* infos needed by source */
67 struct W_DragDestinationInfo* destInfo; /* infos needed by destination */
68 } W_DraggingInfo;
70 /* ---[ Structures from WINGs.h ]----------------------------------------- */
72 /* Pre-definition of internal structs */
73 typedef struct W_Color W_Color;
74 typedef struct W_Pixmap W_Pixmap;
75 typedef struct W_View W_View;
77 typedef struct W_FocusInfo {
78 W_View *toplevel;
79 W_View *focused; /* view that has the focus in this toplevel */
80 struct W_FocusInfo *next;
81 } W_FocusInfo;
83 typedef struct W_Screen {
84 Display *display;
85 int screen;
86 int depth;
88 Colormap colormap;
90 Visual *visual;
92 Time lastEventTime;
94 Window rootWin;
96 W_View *rootView;
98 RContext *rcontext;
100 struct W_IMContext *imctx;
102 struct _XftDraw *xftdraw; /* shared XftDraw */
104 /* application related */
106 W_FocusInfo *focusInfo;
108 RImage *applicationIconImage; /* image (can have alpha channel) */
109 W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
110 Window applicationIconWindow;
112 struct W_Window *windowList; /* list of windows in the app */
114 Window groupLeader; /* the leader of the application */
115 /* also used for other things */
117 struct W_SelectionHandlers *selectionHandlerList;
119 struct {
120 unsigned int hasAppIcon:1;
121 unsigned int simpleApplication:1;
122 } aflags;
124 WMOpenPanel *sharedOpenPanel;
125 WMSavePanel *sharedSavePanel;
127 struct W_FontPanel *sharedFontPanel;
129 struct W_ColorPanel *sharedColorPanel;
131 Pixmap stipple;
133 W_View *dragSourceView;
134 W_DraggingInfo dragInfo;
136 /* colors */
137 W_Color *white;
138 W_Color *black;
139 W_Color *gray;
140 W_Color *darkGray;
142 GC stippleGC;
144 GC copyGC;
145 GC clipGC;
147 GC monoGC; /* GC for 1bpp visuals */
149 GC xorGC;
151 GC ixorGC; /* IncludeInferiors XOR */
153 GC drawStringGC; /* for WMDrawString() */
155 GC drawImStringGC; /* for WMDrawImageString() */
157 struct W_Font *normalFont;
159 struct W_Font *boldFont;
161 WMHashTable *fontCache;
163 Bool antialiasedText;
165 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
167 struct W_Balloon *balloon;
170 W_Pixmap *checkButtonImageOn;
171 W_Pixmap *checkButtonImageOff;
173 W_Pixmap *radioButtonImageOn;
174 W_Pixmap *radioButtonImageOff;
176 W_Pixmap *buttonArrow;
177 W_Pixmap *pushedButtonArrow;
179 W_Pixmap *scrollerDimple;
181 W_Pixmap *upArrow;
182 W_Pixmap *downArrow;
183 W_Pixmap *leftArrow;
184 W_Pixmap *rightArrow;
186 W_Pixmap *hiUpArrow;
187 W_Pixmap *hiDownArrow;
188 W_Pixmap *hiLeftArrow;
189 W_Pixmap *hiRightArrow;
191 W_Pixmap *pullDownIndicator;
192 W_Pixmap *popUpIndicator;
194 W_Pixmap *checkMark;
196 W_Pixmap *homeIcon;
197 W_Pixmap *altHomeIcon;
199 W_Pixmap *trashcanIcon;
200 W_Pixmap *altTrashcanIcon;
202 W_Pixmap *createDirIcon;
203 W_Pixmap *altCreateDirIcon;
205 W_Pixmap *disketteIcon;
206 W_Pixmap *altDisketteIcon;
207 W_Pixmap *unmountIcon;
208 W_Pixmap *altUnmountIcon;
210 W_Pixmap *magnifyIcon;
211 /*W_Pixmap *altMagnifyIcon;*/
212 W_Pixmap *wheelIcon;
213 W_Pixmap *grayIcon;
214 W_Pixmap *rgbIcon;
215 W_Pixmap *cmykIcon;
216 W_Pixmap *hsbIcon;
217 W_Pixmap *customPaletteIcon;
218 W_Pixmap *colorListIcon;
220 W_Pixmap *defaultObjectIcon;
222 Cursor defaultCursor;
224 Cursor textCursor;
226 Cursor invisibleCursor;
228 Atom attribsAtom; /* GNUstepWindowAttributes */
230 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
232 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
234 Atom clipboardAtom; /* CLIPBOARD */
236 Atom xdndAwareAtom; /* XdndAware */
237 Atom xdndSelectionAtom;
238 Atom xdndEnterAtom;
239 Atom xdndLeaveAtom;
240 Atom xdndPositionAtom;
241 Atom xdndDropAtom;
242 Atom xdndFinishedAtom;
243 Atom xdndTypeListAtom;
244 Atom xdndActionListAtom;
245 Atom xdndActionDescriptionAtom;
246 Atom xdndStatusAtom;
248 Atom xdndActionCopy;
249 Atom xdndActionMove;
250 Atom xdndActionLink;
251 Atom xdndActionAsk;
252 Atom xdndActionPrivate;
254 Atom wmIconDragOffsetAtom;
256 Atom wmStateAtom; /* WM_STATE */
258 Atom utf8String;
260 Atom netwmName;
261 Atom netwmIconName;
262 Atom netwmIcon;
264 /* stuff for detecting double-clicks */
265 Time lastClickTime; /* time of last mousedown event */
266 Window lastClickWindow; /* window of the last mousedown */
268 struct W_View *modalView;
269 unsigned modalLoop:1;
270 unsigned ignoreNextDoubleClick:1;
273 * New stuff in Window Maker 0.95.7
274 * Added at the end of the structure to avoid breaking binary compatibility
275 * with previous versions of the toolkit
277 W_Pixmap *tristateButtonImageOn;
278 W_Pixmap *tristateButtonImageOff;
279 W_Pixmap *tristateButtonImageTri;
281 } W_Screen;
283 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
286 /* ---[ configuration.c ]------------------------------------------------- */
288 void W_ReadConfigurations(void);
291 /* ---[ drag*.c ]--------------------------------------------------------- */
293 typedef struct W_DragOperationItem {
294 WMDragOperationType type;
295 char* text;
296 } W_DragOperationItem;
298 typedef void* W_DndState(WMView *destView, XClientMessageEvent *event,
299 WMDraggingInfo *info);
301 typedef struct W_DragSourceInfo {
302 WMView *sourceView;
303 Window destinationWindow;
304 W_DndState *state;
305 WMSelectionProcs *selectionProcs;
306 Window icon;
307 WMPoint imageLocation;
308 WMPoint mouseOffset; /* mouse pos in icon */
309 Cursor dragCursor;
310 WMRect noPositionMessageZone;
311 Atom firstThreeTypes[3];
312 } W_DragSourceInfo;
314 typedef struct W_DragDestinationInfo {
315 WMView *destView;
316 WMView *xdndAwareView;
317 Window sourceWindow;
318 W_DndState *state;
319 Bool sourceActionChanged;
320 WMArray *sourceTypes;
321 WMArray *requiredTypes;
322 Bool typeListAvailable;
323 WMArray *dropDatas;
324 } W_DragDestinationInfo;
326 /* -- Functions -- */
328 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
330 Atom W_OperationToAction(WMScreen *scr, WMDragOperationType operation);
332 WMDragOperationType W_ActionToOperation(WMScreen *scr, Atom action);
334 void W_FreeDragOperationItem(void* item);
336 Bool W_SendDnDClientMessage(Display *dpy, Window win, Atom message,
337 unsigned long data1, unsigned long data2,
338 unsigned long data3, unsigned long data4,
339 unsigned long data5);
341 void W_DragSourceStartTimer(WMDraggingInfo *info);
343 void W_DragSourceStopTimer(void);
345 void W_DragSourceStateHandler(WMDraggingInfo *info, XClientMessageEvent *event);
347 void W_DragDestinationStartTimer(WMDraggingInfo *info);
349 void W_DragDestinationStopTimer(void);
351 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info, WMView *toplevel,
352 XClientMessageEvent *event);
354 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo *info,
355 WMView *toplevel,
356 XClientMessageEvent *event);
358 void W_DragDestinationCancelDropOnEnter(WMView *toplevel, WMDraggingInfo *info);
360 void W_DragDestinationStateHandler(WMDraggingInfo *info,
361 XClientMessageEvent *event);
363 void W_DragDestinationInfoClear(WMDraggingInfo *info);
365 void W_FreeViewXdndPart(WMView *view);
368 /* ---[ handlers.c ]------------------------------------------------------ */
370 Bool W_CheckIdleHandlers(void);
372 void W_CheckTimerHandlers(void);
374 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
377 /* ---[ notification.c ]-------------------------------------------------- */
379 void W_InitNotificationCenter(void);
381 void W_ReleaseNotificationCenter(void);
383 void W_FlushASAPNotificationQueue(void);
385 void W_FlushIdleNotificationQueue(void);
388 /* ---[ selection.c ]----------------------------------------------------- */
390 void W_HandleSelectionEvent(XEvent *event);
393 /* ---[ wapplication.c ]-------------------------------------------------- */
395 typedef struct W_Application {
396 char *applicationName;
397 int argc;
398 char **argv;
399 char *resourcePath;
400 } W_Application;
402 /* -- Functions -- */
404 void W_InitApplication(WMScreen *scr);
406 Bool W_ApplicationInitialized(void);
409 /* ---[ wballoon.c ]------------------------------------------------------ */
411 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
413 void W_BalloonHandleEnterView(WMView *view);
415 void W_BalloonHandleLeaveView(WMView *view);
418 /* ---[ wcolor.c ]-------------------------------------------------------- */
420 struct W_Color {
421 struct W_Screen *screen;
423 XColor color;
424 unsigned short alpha;
425 short refCount;
426 GC gc;
427 struct {
428 unsigned int exact:1;
429 } flags;
432 #define W_PIXEL(c) (c)->color.pixel
435 /* ---[ wevent.c ]-------------------------------------------------------- */
437 typedef struct W_EventHandler {
438 unsigned long eventMask;
440 WMEventProc *proc;
442 void *clientData;
443 } W_EventHandler;
445 /* -- Functions -- */
447 void W_CallDestroyHandlers(W_View *view);
450 /* ---[ wfont.c ]--------------------------------------------------------- */
452 typedef struct W_Font {
453 struct W_Screen *screen;
455 struct _XftFont *font;
457 short height;
458 short y;
459 short refCount;
460 char *name;
462 #ifdef USE_PANGO
463 PangoLayout *layout;
464 #endif
465 } W_Font;
467 #define W_FONTID(f) (f)->font->fid
470 /* ---[ widgets.c ]------------------------------------------------------- */
472 #define WC_UserWidget 128
474 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
476 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
477 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
479 /* -- Functions -- */
481 W_Class W_RegisterUserWidget(void);
484 /* ---[ winputmethod.c ]-------------------------------------------------- */
486 void W_InitIM(WMScreen *scr);
488 void W_CreateIC(WMView *view);
490 void W_DestroyIC(WMView *view);
492 void W_FocusIC(WMView *view);
494 void W_UnFocusIC(WMView *view);
496 void W_SetPreeditPositon(W_View *view, int x, int y);
498 int W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer,
499 int buflen, KeySym *keysym, Status *status);
502 /* ---[ wmisc.c ]--------------------------------------------------------- */
504 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
505 unsigned int height, WMReliefType relief);
507 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
508 unsigned int width, unsigned int height,
509 WMReliefType relief,
510 GC black, GC dark, GC light, GC white);
512 void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
513 W_Font *font, WMReliefType relief, const char *text,
514 WMAlignment alignment, W_Pixmap *image,
515 WMImagePosition position, WMColor *backColor, int ofs);
517 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
518 int width, WMAlignment alignment, WMColor *color,
519 int wrap, const char *text, int length);
521 int W_GetTextHeight(WMFont *font, const char *text, int width, int wrap);
524 /* ---[ wpixmap.c ]------------------------------------------------------- */
526 struct W_Pixmap {
527 struct W_Screen *screen;
528 Pixmap pixmap;
529 Pixmap mask;
530 unsigned short width;
531 unsigned short height;
532 short depth;
533 short refCount;
537 /* ---[ wview.c ]--------------------------------------------------------- */
539 typedef struct W_ViewDelegate {
540 void *data;
541 void (*didMove)(struct W_ViewDelegate*, WMView*);
542 void (*didResize)(struct W_ViewDelegate*, WMView*);
543 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
544 void (*willResize)(struct W_ViewDelegate*, WMView*,
545 unsigned int*, unsigned int*);
546 } W_ViewDelegate;
548 struct W_View {
549 struct W_Screen *screen;
551 WMWidget *self; /* must point to the widget the view belongs to */
553 W_ViewDelegate *delegate;
555 Window window;
557 WMSize size;
559 short topOffs;
560 short leftOffs;
561 short bottomOffs;
562 short rightOffs;
564 WMPoint pos;
566 struct W_View *nextFocusChain; /* next/prev in focus chain */
567 struct W_View *prevFocusChain;
569 struct W_View *nextResponder; /* next to receive keyboard events */
571 struct W_View *parent; /* parent WMView */
573 struct W_View *childrenList; /* first in list of child windows */
575 struct W_View *nextSister; /* next on parent's children list */
577 WMArray *eventHandlers; /* event handlers for this window */
579 unsigned long attribFlags;
580 XSetWindowAttributes attribs;
582 void *hangedData; /* data holder for user program */
584 WMColor *backColor;
585 WMPixmap *backImage;
588 Cursor cursor;
590 Atom *droppableTypes;
591 struct W_DragSourceProcs *dragSourceProcs;
592 struct W_DragDestinationProcs *dragDestinationProcs;
593 WMPixmap *dragImage;
594 int helpContext;
596 XIC xic;
598 struct {
599 unsigned int realized:1;
600 unsigned int mapped:1;
601 unsigned int parentDying:1;
602 unsigned int dying:1; /* the view is being destroyed */
603 unsigned int topLevel:1; /* is a top level window */
604 unsigned int root:1; /* is the root window */
605 unsigned int mapWhenRealized:1; /* map the view when it's realized */
606 unsigned int alreadyDead:1; /* view was freed */
608 unsigned int dontCompressMotion:1; /* motion notify event compress */
609 unsigned int notifySizeChanged:1;
610 unsigned int dontCompressExpose:1; /* expose event compress */
612 /* toplevel only */
613 unsigned int worksWhenModal:1;
614 unsigned int pendingRelease1:1;
615 unsigned int pendingRelease2:1;
616 unsigned int pendingRelease3:1;
617 unsigned int pendingRelease4:1;
618 unsigned int pendingRelease5:1;
619 unsigned int xdndHintSet:1;
620 } flags;
622 int refCount;
625 #define W_VIEW_REALIZED(view) (view)->flags.realized
626 #define W_VIEW_MAPPED(view) (view)->flags.mapped
628 #define W_VIEW_DISPLAY(view) (view)->screen->display
629 #define W_VIEW_SCREEN(view) (view)->screen
630 #define W_VIEW_DRAWABLE(view) (view)->window
632 #define W_VIEW_WIDTH(view) (view)->size.width
633 #define W_VIEW_HEIGHT(view) (view)->size.height
635 /* -- Functions -- */
637 W_View *W_GetViewForXWindow(Display *display, Window window);
639 W_View *W_CreateView(W_View *parent);
641 W_View *W_CreateTopView(W_Screen *screen);
643 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
645 W_View *W_CreateRootView(W_Screen *screen);
647 void W_DestroyView(W_View *view);
649 void W_RealizeView(W_View *view);
651 void W_RedisplayView(WMView *view);
653 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
655 void W_RaiseView(W_View *view);
657 void W_LowerView(W_View *view);
659 void W_MapView(W_View *view);
661 void W_MapSubviews(W_View *view);
663 void W_UnmapSubviews(W_View *view);
665 W_View *W_TopLevelOfView(W_View *view);
667 void W_UnmapView(W_View *view);
669 WMView *W_RetainView(WMView *view);
671 void W_ReleaseView(WMView *view);
673 void W_MoveView(W_View *view, int x, int y);
675 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
677 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
679 void W_SetViewBackgroundPixmap(W_View *view, WMPixmap *pix);
681 void W_SetViewCursor(W_View *view, Cursor cursor);
683 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
685 W_View *W_FocusedViewOfToplevel(W_View *view);
687 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
689 void W_DispatchMessage(W_View *target, XEvent *event);
692 #ifdef __cplusplus
694 #endif /* __cplusplus */
696 #endif /* _WINGSP_H_ */