Text Selection 99% complete, replaceSelection added
[wmaker-crm.git] / WINGs / WINGsP.h
blob3b35f5fa1dff800891fc14a7a55e09488b0983e9
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 < 20000521
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;
141 struct W_Window *windowList; /* list of windows in the app */
143 Window groupLeader; /* the leader of the application */
144 /* also used for other things */
146 struct W_SelectionHandlers *selectionHandlerList;
148 struct {
149 unsigned int hasAppIcon:1;
150 unsigned int simpleApplication:1;
151 } aflags;
153 WMOpenPanel *sharedOpenPanel;
154 WMSavePanel *sharedSavePanel;
156 struct W_FontPanel *sharedFontPanel;
158 struct W_ColorPanel *sharedColorPanel;
160 Pixmap stipple;
162 struct W_View *dragSourceView;
163 struct W_DraggingInfo dragInfo;
165 /* colors */
166 W_Color *white;
167 W_Color *black;
168 W_Color *gray;
169 W_Color *darkGray;
171 GC stippleGC;
173 GC copyGC;
174 GC clipGC;
176 GC monoGC; /* GC for 1bpp visuals */
178 GC xorGC;
180 GC ixorGC; /* IncludeInferiors XOR */
182 GC textFieldGC;
184 W_Font *normalFont;
186 W_Font *boldFont;
188 WMHashTable *fontCache;
190 Bool useMultiByte;
192 struct W_Balloon *balloon;
195 struct W_Pixmap *checkButtonImageOn;
196 struct W_Pixmap *checkButtonImageOff;
198 struct W_Pixmap *radioButtonImageOn;
199 struct W_Pixmap *radioButtonImageOff;
201 struct W_Pixmap *buttonArrow;
202 struct W_Pixmap *pushedButtonArrow;
204 struct W_Pixmap *scrollerDimple;
206 struct W_Pixmap *upArrow;
207 struct W_Pixmap *downArrow;
208 struct W_Pixmap *leftArrow;
209 struct W_Pixmap *rightArrow;
211 struct W_Pixmap *hiUpArrow;
212 struct W_Pixmap *hiDownArrow;
213 struct W_Pixmap *hiLeftArrow;
214 struct W_Pixmap *hiRightArrow;
216 struct W_Pixmap *pullDownIndicator;
217 struct W_Pixmap *popUpIndicator;
219 struct W_Pixmap *checkMark;
221 struct W_Pixmap *homeIcon;
222 struct W_Pixmap *altHomeIcon;
224 struct W_Pixmap *trashcanIcon;
225 struct W_Pixmap *altTrashcanIcon;
227 struct W_Pixmap *createDirIcon;
228 struct W_Pixmap *altCreateDirIcon;
230 struct W_Pixmap *disketteIcon;
231 struct W_Pixmap *altDisketteIcon;
232 struct W_Pixmap *unmountIcon;
233 struct W_Pixmap *altUnmountIcon;
235 struct W_Pixmap *magnifyIcon;
236 /* struct W_Pixmap *altMagnifyIcon;*/
237 struct W_Pixmap *wheelIcon;
238 struct W_Pixmap *grayIcon;
239 struct W_Pixmap *rgbIcon;
240 struct W_Pixmap *cmykIcon;
241 struct W_Pixmap *hsbIcon;
242 struct W_Pixmap *customPaletteIcon;
243 struct W_Pixmap *colorListIcon;
245 struct W_Pixmap *defaultObjectIcon;
247 Cursor defaultCursor;
249 Cursor textCursor;
251 Cursor invisibleCursor;
253 Atom attribsAtom; /* GNUstepWindowAttributes */
255 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
257 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
259 Atom clipboardAtom; /* CLIPBOARD */
261 Atom xdndAwareAtom; /* XdndAware */
262 Atom xdndSelectionAtom;
263 Atom xdndEnterAtom;
264 Atom xdndLeaveAtom;
265 Atom xdndPositionAtom;
266 Atom xdndDropAtom;
267 Atom xdndFinishedAtom;
268 Atom xdndTypeListAtom;
269 Atom xdndStatusAtom;
271 Atom xdndActionCopy;
272 Atom xdndActionMove;
273 Atom xdndActionLink;
274 Atom xdndActionAsk;
275 Atom xdndActionPrivate;
277 Atom wmIconDragOffsetAtom;
279 Atom wmStateAtom; /* WM_STATE */
281 /* stuff for detecting double-clicks */
282 Time lastClickTime; /* time of last mousedown event */
283 Window lastClickWindow; /* window of the last mousedown */
285 struct W_View *modalView;
286 unsigned modal:1;
287 unsigned ignoreNextDoubleClick:1;
288 } W_Screen;
292 typedef struct W_ViewDelegate {
293 void *data;
295 void (*didMove)(struct W_ViewDelegate*, WMView*);
297 void (*didResize)(struct W_ViewDelegate*, WMView*);
299 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
301 void (*willResize)(struct W_ViewDelegate*, WMView*,
302 unsigned int*, unsigned int*);
303 } W_ViewDelegate;
307 typedef struct W_View {
308 struct W_Screen *screen;
310 WMWidget *self; /* must point to the widget the
311 * view belongs to */
313 W_ViewDelegate *delegate;
315 Window window;
317 WMSize size;
319 WMPoint pos;
321 struct W_View *nextFocusChain; /* next/prev in focus chain */
322 struct W_View *prevFocusChain;
324 struct W_View *parent; /* parent WMView */
326 struct W_View *childrenList; /* first in list of child windows */
328 struct W_View *nextSister; /* next on parent's children list */
330 WMBag *eventHandlers; /* event handlers for this window */
332 unsigned long attribFlags;
333 XSetWindowAttributes attribs;
335 void *hangedData; /* data holder for user program */
337 WMColor *backColor;
340 Atom *droppableTypes;
341 struct W_DragSourceProcs *dragSourceProcs;
342 struct W_DragDestinationProcs *dragDestinationProcs;
343 int helpContext;
346 struct {
347 unsigned int realized:1;
348 unsigned int mapped:1;
349 unsigned int parentDying:1;
350 unsigned int dying:1; /* the view is being destroyed */
351 unsigned int topLevel:1; /* is a top level window */
352 unsigned int root:1; /* is the root window */
353 unsigned int mapWhenRealized:1;/* map the view when it's realized */
354 unsigned int alreadyDead:1; /* view was freed */
356 unsigned int dontCompressMotion:1; /* motion notify event compress */
357 unsigned int notifySizeChanged:1;
358 unsigned int dontCompressExpose:1; /* will compress all expose
359 events into one */
360 /* toplevel only */
361 unsigned int worksWhenModal:1;
362 unsigned int pendingRelease1:1;
363 unsigned int pendingRelease2:1;
364 unsigned int pendingRelease3:1;
365 unsigned int pendingRelease4:1;
366 unsigned int pendingRelease5:1;
367 unsigned int xdndHintSet:1;
368 } flags;
370 int refCount;
371 } W_View;
374 typedef struct W_EventHandler {
375 unsigned long eventMask;
377 WMEventProc *proc;
379 void *clientData;
380 } W_EventHandler;
385 typedef struct _WINGsConfiguration {
386 char *systemFont;
387 char *boldSystemFont;
388 int defaultFontSize;
389 Bool useMultiByte;
390 char *floppyPath;
391 unsigned doubleClickDelay;
392 unsigned mouseWheelUp;
393 unsigned mouseWheelDown;
394 } _WINGsConfiguration;
396 extern _WINGsConfiguration WINGsConfiguration;
400 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
403 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
404 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
406 #define W_VIEW_REALIZED(view) (view)->flags.realized
407 #define W_VIEW_MAPPED(view) (view)->flags.mapped
409 #define W_VIEW_DISPLAY(view) (view)->screen->display
410 #define W_VIEW_SCREEN(view) (view)->screen
411 #define W_VIEW_DRAWABLE(view) (view)->window
413 #define W_VIEW_WIDTH(view) (view)->size.width
414 #define W_VIEW_HEIGHT(view) (view)->size.height
417 #define W_PIXEL(c) (c)->color.pixel
419 #define W_FONTID(f) (f)->font->fid
421 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
425 W_View *W_GetViewForXWindow(Display *display, Window window);
427 W_View *W_CreateView(W_View *parent);
429 W_View *W_CreateTopView(W_Screen *screen);
431 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
434 W_View *W_CreateRootView(W_Screen *screen);
436 void W_DestroyView(W_View *view);
438 void W_RealizeView(W_View *view);
440 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
442 void W_RaiseView(W_View *view);
444 void W_LowerView(W_View *view);
447 void W_MapView(W_View *view);
449 void W_MapSubviews(W_View *view);
451 void W_UnmapSubviews(W_View *view);
453 W_View *W_TopLevelOfView(W_View *view);
455 void W_UnmapView(W_View *view);
457 void W_MoveView(W_View *view, int x, int y);
459 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
461 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
463 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
464 unsigned int height, WMReliefType relief);
466 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
467 unsigned int width, unsigned int height,
468 WMReliefType relief,
469 GC black, GC dark, GC light, GC white);
471 void W_CleanUpEvents(W_View *view);
473 void W_CallDestroyHandlers(W_View *view);
475 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
476 WMReliefType relief, char *text,
477 WMAlignment alignment, W_Pixmap *image,
478 WMImagePosition position, GC backGC, int ofs);
480 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
481 int width, WMAlignment alignment, GC gc,
482 int wrap, char *text, int length);
484 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
487 int W_TextWidth(WMFont *font, char *text, int length);
490 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
492 void W_DispatchMessage(W_View *target, XEvent *event);
494 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
496 W_View *W_FocusedViewOfToplevel(W_View *view);
498 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
500 void W_ReleaseView(WMView *view);
502 WMView *W_RetainView(WMView *view);
504 void W_InitApplication(WMScreen *scr);
506 void W_InitNotificationCenter(void);
508 W_Class W_RegisterUserWidget(void);
510 void W_RedisplayView(WMView *view);
512 Bool W_ApplicationInitialized(void);
514 void W_HandleSelectionEvent(XEvent *event);
516 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
518 void W_FlushASAPNotificationQueue();
520 void W_FlushIdleNotificationQueue();
522 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
524 void W_BalloonHandleEnterView(WMView *view);
526 void W_BalloonHandleLeaveView(WMView *view);
528 #ifdef __cplusplus
530 #endif /* __cplusplus */
532 #endif /* _WINGSP_H_ */