added responder chain alike stuff for relaying kbd events from widget to widget
[wmaker-crm.git] / WINGs / WINGsP.h
blobf8c0da34341911189e4e9a7c15eaafd05dd30105
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 struct W_Pixmap *applicationIcon;
140 Window applicationIconWindow;
142 struct W_Window *windowList; /* list of windows in the app */
144 Window groupLeader; /* the leader of the application */
145 /* also used for other things */
147 struct W_SelectionHandlers *selectionHandlerList;
149 struct {
150 unsigned int hasAppIcon:1;
151 unsigned int simpleApplication:1;
152 } aflags;
154 WMOpenPanel *sharedOpenPanel;
155 WMSavePanel *sharedSavePanel;
157 struct W_FontPanel *sharedFontPanel;
159 struct W_ColorPanel *sharedColorPanel;
161 Pixmap stipple;
163 struct W_View *dragSourceView;
164 struct W_DraggingInfo dragInfo;
166 /* colors */
167 W_Color *white;
168 W_Color *black;
169 W_Color *gray;
170 W_Color *darkGray;
172 GC stippleGC;
174 GC copyGC;
175 GC clipGC;
177 GC monoGC; /* GC for 1bpp visuals */
179 GC xorGC;
181 GC ixorGC; /* IncludeInferiors XOR */
183 GC textFieldGC;
185 W_Font *normalFont;
187 W_Font *boldFont;
189 WMHashTable *fontCache;
191 Bool useMultiByte;
193 struct W_Balloon *balloon;
196 struct W_Pixmap *checkButtonImageOn;
197 struct W_Pixmap *checkButtonImageOff;
199 struct W_Pixmap *radioButtonImageOn;
200 struct W_Pixmap *radioButtonImageOff;
202 struct W_Pixmap *buttonArrow;
203 struct W_Pixmap *pushedButtonArrow;
205 struct W_Pixmap *scrollerDimple;
207 struct W_Pixmap *upArrow;
208 struct W_Pixmap *downArrow;
209 struct W_Pixmap *leftArrow;
210 struct W_Pixmap *rightArrow;
212 struct W_Pixmap *hiUpArrow;
213 struct W_Pixmap *hiDownArrow;
214 struct W_Pixmap *hiLeftArrow;
215 struct W_Pixmap *hiRightArrow;
217 struct W_Pixmap *pullDownIndicator;
218 struct W_Pixmap *popUpIndicator;
220 struct W_Pixmap *checkMark;
222 struct W_Pixmap *homeIcon;
223 struct W_Pixmap *altHomeIcon;
225 struct W_Pixmap *trashcanIcon;
226 struct W_Pixmap *altTrashcanIcon;
228 struct W_Pixmap *createDirIcon;
229 struct W_Pixmap *altCreateDirIcon;
231 struct W_Pixmap *disketteIcon;
232 struct W_Pixmap *altDisketteIcon;
233 struct W_Pixmap *unmountIcon;
234 struct W_Pixmap *altUnmountIcon;
236 struct W_Pixmap *magnifyIcon;
237 /* struct W_Pixmap *altMagnifyIcon;*/
238 struct W_Pixmap *wheelIcon;
239 struct W_Pixmap *grayIcon;
240 struct W_Pixmap *rgbIcon;
241 struct W_Pixmap *cmykIcon;
242 struct W_Pixmap *hsbIcon;
243 struct W_Pixmap *customPaletteIcon;
244 struct W_Pixmap *colorListIcon;
246 struct W_Pixmap *defaultObjectIcon;
248 Cursor defaultCursor;
250 Cursor textCursor;
252 Cursor invisibleCursor;
254 Atom attribsAtom; /* GNUstepWindowAttributes */
256 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
258 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
260 Atom clipboardAtom; /* CLIPBOARD */
262 Atom xdndAwareAtom; /* XdndAware */
263 Atom xdndSelectionAtom;
264 Atom xdndEnterAtom;
265 Atom xdndLeaveAtom;
266 Atom xdndPositionAtom;
267 Atom xdndDropAtom;
268 Atom xdndFinishedAtom;
269 Atom xdndTypeListAtom;
270 Atom xdndStatusAtom;
272 Atom xdndActionCopy;
273 Atom xdndActionMove;
274 Atom xdndActionLink;
275 Atom xdndActionAsk;
276 Atom xdndActionPrivate;
278 Atom wmIconDragOffsetAtom;
280 Atom wmStateAtom; /* WM_STATE */
282 /* stuff for detecting double-clicks */
283 Time lastClickTime; /* time of last mousedown event */
284 Window lastClickWindow; /* window of the last mousedown */
286 struct W_View *modalView;
287 unsigned modalLoop:1;
288 unsigned ignoreNextDoubleClick:1;
289 } W_Screen;
293 typedef struct W_ViewDelegate {
294 void *data;
296 void (*didMove)(struct W_ViewDelegate*, WMView*);
298 void (*didResize)(struct W_ViewDelegate*, WMView*);
300 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
302 void (*willResize)(struct W_ViewDelegate*, WMView*,
303 unsigned int*, unsigned int*);
304 } W_ViewDelegate;
308 typedef struct W_View {
309 struct W_Screen *screen;
311 WMWidget *self; /* must point to the widget the
312 * view belongs to */
314 W_ViewDelegate *delegate;
316 Window window;
318 WMSize size;
320 WMPoint pos;
322 struct W_View *nextFocusChain; /* next/prev in focus chain */
323 struct W_View *prevFocusChain;
325 struct W_View *nextResponder; /* next to receive keyboard events */
327 struct W_View *parent; /* parent WMView */
329 struct W_View *childrenList; /* first in list of child windows */
331 struct W_View *nextSister; /* next on parent's children list */
333 WMBag *eventHandlers; /* event handlers for this window */
335 unsigned long attribFlags;
336 XSetWindowAttributes attribs;
338 void *hangedData; /* data holder for user program */
340 WMColor *backColor;
342 Cursor cursor;
344 Atom *droppableTypes;
345 struct W_DragSourceProcs *dragSourceProcs;
346 struct W_DragDestinationProcs *dragDestinationProcs;
347 int helpContext;
350 struct {
351 unsigned int realized:1;
352 unsigned int mapped:1;
353 unsigned int parentDying:1;
354 unsigned int dying:1; /* the view is being destroyed */
355 unsigned int topLevel:1; /* is a top level window */
356 unsigned int root:1; /* is the root window */
357 unsigned int mapWhenRealized:1;/* map the view when it's realized */
358 unsigned int alreadyDead:1; /* view was freed */
360 unsigned int dontCompressMotion:1; /* motion notify event compress */
361 unsigned int notifySizeChanged:1;
362 unsigned int dontCompressExpose:1; /* will compress all expose
363 events into one */
364 /* toplevel only */
365 unsigned int worksWhenModal:1;
366 unsigned int pendingRelease1:1;
367 unsigned int pendingRelease2:1;
368 unsigned int pendingRelease3:1;
369 unsigned int pendingRelease4:1;
370 unsigned int pendingRelease5:1;
371 unsigned int xdndHintSet:1;
372 } flags;
374 int refCount;
375 } W_View;
378 typedef struct W_EventHandler {
379 unsigned long eventMask;
381 WMEventProc *proc;
383 void *clientData;
384 } W_EventHandler;
389 typedef struct _WINGsConfiguration {
390 char *systemFont;
391 char *boldSystemFont;
392 int defaultFontSize;
393 Bool useMultiByte;
394 char *floppyPath;
395 unsigned doubleClickDelay;
396 unsigned mouseWheelUp;
397 unsigned mouseWheelDown;
398 } _WINGsConfiguration;
400 extern _WINGsConfiguration WINGsConfiguration;
404 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
407 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
408 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
410 #define W_VIEW_REALIZED(view) (view)->flags.realized
411 #define W_VIEW_MAPPED(view) (view)->flags.mapped
413 #define W_VIEW_DISPLAY(view) (view)->screen->display
414 #define W_VIEW_SCREEN(view) (view)->screen
415 #define W_VIEW_DRAWABLE(view) (view)->window
417 #define W_VIEW_WIDTH(view) (view)->size.width
418 #define W_VIEW_HEIGHT(view) (view)->size.height
421 #define W_PIXEL(c) (c)->color.pixel
423 #define W_FONTID(f) (f)->font->fid
425 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
429 W_View *W_GetViewForXWindow(Display *display, Window window);
431 W_View *W_CreateView(W_View *parent);
433 W_View *W_CreateTopView(W_Screen *screen);
435 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
438 W_View *W_CreateRootView(W_Screen *screen);
440 void W_DestroyView(W_View *view);
442 void W_RealizeView(W_View *view);
444 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
446 void W_RaiseView(W_View *view);
448 void W_LowerView(W_View *view);
451 void W_MapView(W_View *view);
453 void W_MapSubviews(W_View *view);
455 void W_UnmapSubviews(W_View *view);
457 W_View *W_TopLevelOfView(W_View *view);
459 void W_UnmapView(W_View *view);
461 void W_MoveView(W_View *view, int x, int y);
463 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
465 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
467 void W_SetViewCursor(W_View *view, Cursor cursor);
469 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
470 unsigned int height, WMReliefType relief);
472 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
473 unsigned int width, unsigned int height,
474 WMReliefType relief,
475 GC black, GC dark, GC light, GC white);
477 void W_CleanUpEvents(W_View *view);
479 void W_CallDestroyHandlers(W_View *view);
481 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
482 WMReliefType relief, char *text,
483 WMAlignment alignment, W_Pixmap *image,
484 WMImagePosition position, GC backGC, int ofs);
486 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
487 int width, WMAlignment alignment, GC gc,
488 int wrap, char *text, int length);
490 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
493 int W_TextWidth(WMFont *font, char *text, int length);
496 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
498 void W_DispatchMessage(W_View *target, XEvent *event);
500 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
502 W_View *W_FocusedViewOfToplevel(W_View *view);
504 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
506 void W_ReleaseView(WMView *view);
508 WMView *W_RetainView(WMView *view);
510 void W_InitApplication(WMScreen *scr);
512 void W_InitNotificationCenter(void);
514 W_Class W_RegisterUserWidget(void);
516 void W_RedisplayView(WMView *view);
518 Bool W_ApplicationInitialized(void);
520 void W_HandleSelectionEvent(XEvent *event);
522 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
524 void W_FlushASAPNotificationQueue();
526 void W_FlushIdleNotificationQueue();
528 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
530 void W_BalloonHandleEnterView(WMView *view);
532 void W_BalloonHandleLeaveView(WMView *view);
534 #ifdef __cplusplus
536 #endif /* __cplusplus */
538 #endif /* _WINGSP_H_ */