added drag and drop
[wmaker-crm.git] / WINGs / WINGsP.h
blob40aa741ac3d740317c60679c8906b88cac09d0bc
1 #ifndef _WINGSP_H_
2 #define _WINGSP_H_
5 #include <X11/Xlib.h>
6 #include <X11/Xutil.h>
9 #include "WINGs.h"
11 #if WINGS_H_VERSION < 20000402
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;
117 typedef struct W_Screen {
118 Display *display;
119 int screen;
120 int depth;
122 Colormap colormap;
124 Visual *visual;
126 Time lastEventTime;
128 Window rootWin;
130 struct W_View *rootView;
132 RContext *rcontext;
134 /* application related */
136 W_FocusInfo *focusInfo;
138 struct W_Pixmap *applicationIcon;
140 struct W_Window *windowList; /* list of windows in the app */
142 Window groupLeader; /* the leader of the application */
143 /* also used for other things */
145 struct W_SelectionHandlers *selectionHandlerList;
147 struct {
148 unsigned int hasAppIcon:1;
149 unsigned int simpleApplication:1;
150 } aflags;
152 WMOpenPanel *sharedOpenPanel;
153 WMSavePanel *sharedSavePanel;
155 struct W_FontPanel *sharedFontPanel;
157 struct W_ColorPanel *sharedColorPanel;
159 Pixmap stipple;
161 struct W_View *dragSourceView;
162 struct W_DraggingInfo dragInfo;
164 /* colors */
165 W_Color *white;
166 W_Color *black;
167 W_Color *gray;
168 W_Color *darkGray;
170 GC stippleGC;
172 GC copyGC;
173 GC clipGC;
175 GC monoGC; /* GC for 1bpp visuals */
177 GC xorGC;
179 GC ixorGC; /* IncludeInferiors XOR */
181 GC textFieldGC;
183 W_Font *normalFont;
185 W_Font *boldFont;
187 WMHashTable *fontCache;
189 Bool useMultiByte;
191 struct W_Balloon *balloon;
194 struct W_Pixmap *checkButtonImageOn;
195 struct W_Pixmap *checkButtonImageOff;
197 struct W_Pixmap *radioButtonImageOn;
198 struct W_Pixmap *radioButtonImageOff;
200 struct W_Pixmap *buttonArrow;
201 struct W_Pixmap *pushedButtonArrow;
203 struct W_Pixmap *scrollerDimple;
205 struct W_Pixmap *upArrow;
206 struct W_Pixmap *downArrow;
207 struct W_Pixmap *leftArrow;
208 struct W_Pixmap *rightArrow;
210 struct W_Pixmap *hiUpArrow;
211 struct W_Pixmap *hiDownArrow;
212 struct W_Pixmap *hiLeftArrow;
213 struct W_Pixmap *hiRightArrow;
215 struct W_Pixmap *pullDownIndicator;
216 struct W_Pixmap *popUpIndicator;
218 struct W_Pixmap *checkMark;
220 struct W_Pixmap *homeIcon;
221 struct W_Pixmap *altHomeIcon;
223 struct W_Pixmap *trashcanIcon;
224 struct W_Pixmap *altTrashcanIcon;
226 struct W_Pixmap *createDirIcon;
227 struct W_Pixmap *altCreateDirIcon;
229 struct W_Pixmap *disketteIcon;
230 struct W_Pixmap *altDisketteIcon;
231 struct W_Pixmap *unmountIcon;
232 struct W_Pixmap *altUnmountIcon;
234 struct W_Pixmap *magnifyIcon;
235 /* struct W_Pixmap *altMagnifyIcon;*/
236 struct W_Pixmap *wheelIcon;
237 struct W_Pixmap *grayIcon;
238 struct W_Pixmap *rgbIcon;
239 struct W_Pixmap *cmykIcon;
240 struct W_Pixmap *hsbIcon;
241 struct W_Pixmap *customPaletteIcon;
242 struct W_Pixmap *colorListIcon;
244 struct W_Pixmap *defaultObjectIcon;
246 Cursor defaultCursor;
248 Cursor textCursor;
250 Cursor invisibleCursor;
252 Atom attribsAtom; /* GNUstepWindowAttributes */
254 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
256 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
258 Atom clipboardAtom; /* CLIPBOARD */
260 Atom xdndAwareAtom; /* XdndAware */
261 Atom xdndSelectionAtom;
262 Atom xdndEnterAtom;
263 Atom xdndLeaveAtom;
264 Atom xdndPositionAtom;
265 Atom xdndDropAtom;
266 Atom xdndFinishedAtom;
267 Atom xdndTypeListAtom;
268 Atom xdndStatusAtom;
270 Atom xdndActionCopy;
271 Atom xdndActionMove;
272 Atom xdndActionLink;
273 Atom xdndActionAsk;
274 Atom xdndActionPrivate;
276 Atom wmStateAtom; /* WM_STATE */
278 /* stuff for detecting double-clicks */
279 Time lastClickTime; /* time of last mousedown event */
280 Window lastClickWindow; /* window of the last mousedown */
282 struct W_View *modalView;
283 unsigned modal:1;
284 unsigned ignoreNextDoubleClick:1;
285 } W_Screen;
289 typedef struct W_ViewDelegate {
290 void *data;
292 void (*didMove)(struct W_ViewDelegate*, WMView*);
294 void (*didResize)(struct W_ViewDelegate*, WMView*);
296 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
298 void (*willResize)(struct W_ViewDelegate*, WMView*,
299 unsigned int*, unsigned int*);
300 } W_ViewDelegate;
304 typedef struct W_View {
305 struct W_Screen *screen;
307 WMWidget *self; /* must point to the widget the
308 * view belongs to */
310 W_ViewDelegate *delegate;
312 Window window;
314 WMSize size;
316 WMPoint pos;
318 struct W_View *nextFocusChain; /* next/prev in focus chain */
319 struct W_View *prevFocusChain;
321 struct W_View *parent; /* parent WMView */
323 struct W_View *childrenList; /* first in list of child windows */
325 struct W_View *nextSister; /* next on parent's children list */
327 struct W_EventHandler *handlerList;/* list of event handlers for this window */
329 unsigned long attribFlags;
330 XSetWindowAttributes attribs;
332 void *hangedData; /* data holder for user program */
334 WMColor *backColor;
337 Atom *droppableTypes;
338 struct W_DragSourceProcs *dragSourceProcs;
339 struct W_DragDestinationProcs *dragDestinationProcs;
340 int helpContext;
343 struct {
344 unsigned int realized:1;
345 unsigned int mapped:1;
346 unsigned int parentDying:1;
347 unsigned int dying:1; /* the view is being destroyed */
348 unsigned int topLevel:1; /* is a top level window */
349 unsigned int root:1; /* is the root window */
350 unsigned int mapWhenRealized:1;/* map the view when it's realized */
351 unsigned int alreadyDead:1; /* view was freed */
353 unsigned int dontCompressMotion:1; /* motion notify event compress */
354 unsigned int notifySizeChanged:1;
355 unsigned int dontCompressExpose:1; /* will compress all expose
356 events into one */
357 /* toplevel only */
358 unsigned int worksWhenModal:1;
359 unsigned int pendingRelease1:1;
360 unsigned int pendingRelease2:1;
361 unsigned int pendingRelease3:1;
362 unsigned int pendingRelease4:1;
363 unsigned int pendingRelease5:1;
364 unsigned int xdndHintSet:1;
365 } flags;
367 int refCount;
368 } W_View;
371 typedef struct W_EventHandler {
372 unsigned long eventMask;
374 WMEventProc *proc;
376 void *clientData;
378 struct W_EventHandler *nextHandler;
379 } W_EventHandler;
384 typedef struct _WINGsConfiguration {
385 char *systemFont;
386 char *boldSystemFont;
387 int defaultFontSize;
388 Bool useMultiByte;
389 unsigned doubleClickDelay;
390 } _WINGsConfiguration;
392 extern _WINGsConfiguration WINGsConfiguration;
396 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
399 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
400 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
402 #define W_VIEW_REALIZED(view) (view)->flags.realized
403 #define W_VIEW_MAPPED(view) (view)->flags.mapped
405 #define W_VIEW_SCREEN(view) (view)->screen
406 #define W_VIEW_DRAWABLE(view) (view)->window
408 #define W_VIEW_WIDTH(view) (view)->size.width
409 #define W_VIEW_HEIGHT(view) (view)->size.height
412 #define W_PIXEL(c) (c)->color.pixel
414 #define W_FONTID(f) (f)->font->fid
416 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
420 W_View *W_GetViewForXWindow(Display *display, Window window);
422 W_View *W_CreateView(W_View *parent);
424 W_View *W_CreateTopView(W_Screen *screen);
427 W_View *W_CreateRootView(W_Screen *screen);
429 void W_DestroyView(W_View *view);
431 void W_RealizeView(W_View *view);
433 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
435 void W_MapView(W_View *view);
437 void W_MapSubviews(W_View *view);
439 void W_UnmapSubviews(W_View *view);
441 W_View *W_TopLevelOfView(W_View *view);
443 void W_UnmapView(W_View *view);
445 void W_MoveView(W_View *view, int x, int y);
447 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
449 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
451 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
452 unsigned int height, WMReliefType relief);
455 void W_CleanUpEvents(W_View *view);
457 void W_CallDestroyHandlers(W_View *view);
459 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
460 WMReliefType relief, char *text,
461 WMAlignment alignment, W_Pixmap *image,
462 WMImagePosition position, GC backGC, int ofs);
464 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
465 int width, WMAlignment alignment, GC gc,
466 int wrap, char *text, int length);
468 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
471 int W_TextWidth(WMFont *font, char *text, int length);
474 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
476 void W_DispatchMessage(W_View *target, XEvent *event);
478 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
480 W_View *W_FocusedViewOfToplevel(W_View *view);
482 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
484 void W_ReleaseView(WMView *view);
486 WMView *W_RetainView(WMView *view);
488 void W_InitApplication(WMScreen *scr);
490 void W_InitNotificationCenter(void);
492 W_Class W_RegisterUserWidget(void);
494 void W_RedisplayView(WMView *view);
496 Bool W_ApplicationInitialized(void);
498 void W_HandleSelectionEvent(XEvent *event);
500 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
502 void W_FlushASAPNotificationQueue();
504 void W_FlushIdleNotificationQueue();
506 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
508 void W_BalloonHandleEnterView(WMView *view);
510 void W_BalloonHandleLeaveView(WMView *view);
512 #ifdef __cplusplus
514 #endif /* __cplusplus */
516 #endif /* _WINGSP_H_ */