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