Added Xft support in WINGs (for drawing antialiased fonts with transparency)
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
blobb3e9eb55e89b72f044c51097e686e177a2b78d01
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 < 20021008
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 struct _XftFont *xft;
55 } font;
56 short height;
57 short y;
58 short refCount;
59 char *name;
60 unsigned int notFontSet:1;
61 unsigned int antialiased:1;
62 } W_Font;
65 typedef struct W_Pixmap {
66 struct W_Screen *screen;
67 Pixmap pixmap;
68 Pixmap mask;
69 unsigned short width;
70 unsigned short height;
71 short depth;
72 short refCount;
73 } W_Pixmap;
76 typedef struct W_Color {
77 struct W_Screen *screen;
79 XColor color;
80 unsigned short alpha;
81 short refCount;
82 GC gc;
83 struct {
84 unsigned int exact:1;
85 } flags;
86 } W_Color;
89 typedef struct W_FocusInfo {
90 struct W_View *toplevel;
91 struct W_View *focused; /* view that has the focus in this toplevel */
92 struct W_FocusInfo *next;
93 } W_FocusInfo;
97 struct W_DraggingInfo {
98 Window destinationWindow;
99 Window sourceWindow;
101 WMPoint location;
103 unsigned sourceOperation;
104 WMPixmap *image;
105 WMPoint imageLocation;
107 char **types;
109 Time timestamp;
111 int protocolVersion;
113 /* should be treated as internal data */
114 WMView *sourceView;
115 WMView *destView;
116 WMSize mouseOffset;
117 unsigned finished:1;
121 typedef struct W_Screen {
122 Display *display;
123 int screen;
124 int depth;
126 Colormap colormap;
128 Visual *visual;
130 Time lastEventTime;
132 Window rootWin;
134 struct W_View *rootView;
136 RContext *rcontext;
138 struct W_IMContext *imctx;
140 /* application related */
142 W_FocusInfo *focusInfo;
144 RImage *applicationIconImage; /* image (can have alpha channel) */
145 struct W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
146 Window applicationIconWindow;
148 struct W_Window *windowList; /* list of windows in the app */
150 Window groupLeader; /* the leader of the application */
151 /* also used for other things */
153 struct W_SelectionHandlers *selectionHandlerList;
155 struct {
156 unsigned int hasAppIcon:1;
157 unsigned int simpleApplication:1;
158 } aflags;
160 WMOpenPanel *sharedOpenPanel;
161 WMSavePanel *sharedSavePanel;
163 struct W_FontPanel *sharedFontPanel;
165 struct W_ColorPanel *sharedColorPanel;
167 Pixmap stipple;
169 struct W_View *dragSourceView;
170 struct W_DraggingInfo dragInfo;
172 /* colors */
173 W_Color *white;
174 W_Color *black;
175 W_Color *gray;
176 W_Color *darkGray;
178 GC stippleGC;
180 GC copyGC;
181 GC clipGC;
183 GC monoGC; /* GC for 1bpp visuals */
185 GC xorGC;
187 GC ixorGC; /* IncludeInferiors XOR */
189 GC drawStringGC; /* for WMDrawString() */
191 GC drawImStringGC; /* for WMDrawImageString() */
193 W_Font *normalFont;
195 W_Font *boldFont;
197 WMHashTable *fontCache;
199 WMHashTable *fontSetCache;
201 Bool useMultiByte;
203 Bool antialiasedText;
205 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
207 struct W_Balloon *balloon;
210 struct W_Pixmap *checkButtonImageOn;
211 struct W_Pixmap *checkButtonImageOff;
213 struct W_Pixmap *radioButtonImageOn;
214 struct W_Pixmap *radioButtonImageOff;
216 struct W_Pixmap *buttonArrow;
217 struct W_Pixmap *pushedButtonArrow;
219 struct W_Pixmap *scrollerDimple;
221 struct W_Pixmap *upArrow;
222 struct W_Pixmap *downArrow;
223 struct W_Pixmap *leftArrow;
224 struct W_Pixmap *rightArrow;
226 struct W_Pixmap *hiUpArrow;
227 struct W_Pixmap *hiDownArrow;
228 struct W_Pixmap *hiLeftArrow;
229 struct W_Pixmap *hiRightArrow;
231 struct W_Pixmap *pullDownIndicator;
232 struct W_Pixmap *popUpIndicator;
234 struct W_Pixmap *checkMark;
236 struct W_Pixmap *homeIcon;
237 struct W_Pixmap *altHomeIcon;
239 struct W_Pixmap *trashcanIcon;
240 struct W_Pixmap *altTrashcanIcon;
242 struct W_Pixmap *createDirIcon;
243 struct W_Pixmap *altCreateDirIcon;
245 struct W_Pixmap *disketteIcon;
246 struct W_Pixmap *altDisketteIcon;
247 struct W_Pixmap *unmountIcon;
248 struct W_Pixmap *altUnmountIcon;
250 struct W_Pixmap *magnifyIcon;
251 /* struct W_Pixmap *altMagnifyIcon;*/
252 struct W_Pixmap *wheelIcon;
253 struct W_Pixmap *grayIcon;
254 struct W_Pixmap *rgbIcon;
255 struct W_Pixmap *cmykIcon;
256 struct W_Pixmap *hsbIcon;
257 struct W_Pixmap *customPaletteIcon;
258 struct W_Pixmap *colorListIcon;
260 struct W_Pixmap *defaultObjectIcon;
262 Cursor defaultCursor;
264 Cursor textCursor;
266 Cursor invisibleCursor;
268 Atom attribsAtom; /* GNUstepWindowAttributes */
270 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
272 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
274 Atom clipboardAtom; /* CLIPBOARD */
276 Atom xdndAwareAtom; /* XdndAware */
277 Atom xdndSelectionAtom;
278 Atom xdndEnterAtom;
279 Atom xdndLeaveAtom;
280 Atom xdndPositionAtom;
281 Atom xdndDropAtom;
282 Atom xdndFinishedAtom;
283 Atom xdndTypeListAtom;
284 Atom xdndStatusAtom;
286 Atom xdndActionCopy;
287 Atom xdndActionMove;
288 Atom xdndActionLink;
289 Atom xdndActionAsk;
290 Atom xdndActionPrivate;
292 Atom wmIconDragOffsetAtom;
294 Atom wmStateAtom; /* WM_STATE */
296 /* stuff for detecting double-clicks */
297 Time lastClickTime; /* time of last mousedown event */
298 Window lastClickWindow; /* window of the last mousedown */
300 struct W_View *modalView;
301 unsigned modalLoop:1;
302 unsigned ignoreNextDoubleClick:1;
303 } W_Screen;
307 typedef struct W_ViewDelegate {
308 void *data;
310 void (*didMove)(struct W_ViewDelegate*, WMView*);
312 void (*didResize)(struct W_ViewDelegate*, WMView*);
314 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
316 void (*willResize)(struct W_ViewDelegate*, WMView*,
317 unsigned int*, unsigned int*);
318 } W_ViewDelegate;
322 typedef struct W_View {
323 struct W_Screen *screen;
325 WMWidget *self; /* must point to the widget the
326 * view belongs to */
328 W_ViewDelegate *delegate;
330 Window window;
332 WMSize size;
334 short topOffs;
335 short leftOffs;
336 short bottomOffs;
337 short rightOffs;
339 WMPoint pos;
341 struct W_View *nextFocusChain; /* next/prev in focus chain */
342 struct W_View *prevFocusChain;
344 struct W_View *nextResponder; /* next to receive keyboard events */
346 struct W_View *parent; /* parent WMView */
348 struct W_View *childrenList; /* first in list of child windows */
350 struct W_View *nextSister; /* next on parent's children list */
352 WMArray *eventHandlers; /* event handlers for this window */
354 unsigned long attribFlags;
355 XSetWindowAttributes attribs;
357 void *hangedData; /* data holder for user program */
359 WMColor *backColor;
361 Cursor cursor;
363 Atom *droppableTypes;
364 struct W_DragSourceProcs *dragSourceProcs;
365 struct W_DragDestinationProcs *dragDestinationProcs;
366 int helpContext;
369 struct {
370 unsigned int realized:1;
371 unsigned int mapped:1;
372 unsigned int parentDying:1;
373 unsigned int dying:1; /* the view is being destroyed */
374 unsigned int topLevel:1; /* is a top level window */
375 unsigned int root:1; /* is the root window */
376 unsigned int mapWhenRealized:1;/* map the view when it's realized */
377 unsigned int alreadyDead:1; /* view was freed */
379 unsigned int dontCompressMotion:1; /* motion notify event compress */
380 unsigned int notifySizeChanged:1;
381 unsigned int dontCompressExpose:1; /* will compress all expose
382 events into one */
383 /* toplevel only */
384 unsigned int worksWhenModal:1;
385 unsigned int pendingRelease1:1;
386 unsigned int pendingRelease2:1;
387 unsigned int pendingRelease3:1;
388 unsigned int pendingRelease4:1;
389 unsigned int pendingRelease5:1;
390 unsigned int xdndHintSet:1;
391 } flags;
393 int refCount;
394 } W_View;
397 typedef struct W_EventHandler {
398 unsigned long eventMask;
400 WMEventProc *proc;
402 void *clientData;
403 } W_EventHandler;
408 typedef struct _WINGsConfiguration {
409 char *systemFont;
410 char *boldSystemFont;
411 char *aaSystemFont;
412 char *aaBoldSystemFont;
413 int defaultFontSize;
414 Bool antialiasedText;
415 Bool useMultiByte;
416 char *floppyPath;
417 unsigned doubleClickDelay;
418 unsigned mouseWheelUp;
419 unsigned mouseWheelDown;
420 } _WINGsConfiguration;
422 extern _WINGsConfiguration WINGsConfiguration;
426 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
429 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
430 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
432 #define W_VIEW_REALIZED(view) (view)->flags.realized
433 #define W_VIEW_MAPPED(view) (view)->flags.mapped
435 #define W_VIEW_DISPLAY(view) (view)->screen->display
436 #define W_VIEW_SCREEN(view) (view)->screen
437 #define W_VIEW_DRAWABLE(view) (view)->window
439 #define W_VIEW_WIDTH(view) (view)->size.width
440 #define W_VIEW_HEIGHT(view) (view)->size.height
443 #define W_PIXEL(c) (c)->color.pixel
445 #define W_FONTID(f) (f)->font->fid
447 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
451 W_View *W_GetViewForXWindow(Display *display, Window window);
453 W_View *W_CreateView(W_View *parent);
455 W_View *W_CreateTopView(W_Screen *screen);
457 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
460 W_View *W_CreateRootView(W_Screen *screen);
462 void W_DestroyView(W_View *view);
464 void W_RealizeView(W_View *view);
466 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
468 void W_RaiseView(W_View *view);
470 void W_LowerView(W_View *view);
473 void W_MapView(W_View *view);
475 void W_MapSubviews(W_View *view);
477 void W_UnmapSubviews(W_View *view);
479 W_View *W_TopLevelOfView(W_View *view);
481 void W_UnmapView(W_View *view);
483 void W_MoveView(W_View *view, int x, int y);
485 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
487 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
489 void W_SetViewCursor(W_View *view, Cursor cursor);
491 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
492 unsigned int height, WMReliefType relief);
494 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
495 unsigned int width, unsigned int height,
496 WMReliefType relief,
497 GC black, GC dark, GC light, GC white);
499 void W_CallDestroyHandlers(W_View *view);
501 void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
502 W_Font *font, WMReliefType relief, char *text,
503 WMAlignment alignment, W_Pixmap *image,
504 WMImagePosition position, WMColor *backColor, int ofs);
506 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
507 int width, WMAlignment alignment, WMColor *color,
508 int wrap, char *text, int length);
510 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
513 int W_TextWidth(WMFont *font, char *text, int length);
516 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
518 void W_DispatchMessage(W_View *target, XEvent *event);
520 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
522 W_View *W_FocusedViewOfToplevel(W_View *view);
524 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
526 void W_ReleaseView(WMView *view);
528 WMView *W_RetainView(WMView *view);
530 void W_InitApplication(WMScreen *scr);
532 void W_InitNotificationCenter(void);
534 W_Class W_RegisterUserWidget(void);
536 void W_RedisplayView(WMView *view);
538 Bool W_ApplicationInitialized(void);
540 void W_HandleSelectionEvent(XEvent *event);
542 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
544 void W_FlushASAPNotificationQueue(void);
546 void W_FlushIdleNotificationQueue(void);
548 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
550 void W_BalloonHandleEnterView(WMView *view);
552 void W_BalloonHandleLeaveView(WMView *view);
554 Bool W_CheckIdleHandlers(void);
556 void W_CheckTimerHandlers(void);
558 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
560 #ifdef __cplusplus
562 #endif /* __cplusplus */
564 #endif /* _WINGSP_H_ */