- Fixed a bug with empty frame titles (Alexey Voinov <voins@voins.program.ru>)
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
bloba9a70be7526a9c87d709ac44c4ad4177d465a2f7
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 < 20021124
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 struct _XftDraw *xftdraw; /* shared XftDraw */
142 Bool hasXftSupport; /* if it can antialias text */
144 /* application related */
146 W_FocusInfo *focusInfo;
148 RImage *applicationIconImage; /* image (can have alpha channel) */
149 struct W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
150 Window applicationIconWindow;
152 struct W_Window *windowList; /* list of windows in the app */
154 Window groupLeader; /* the leader of the application */
155 /* also used for other things */
157 struct W_SelectionHandlers *selectionHandlerList;
159 struct {
160 unsigned int hasAppIcon:1;
161 unsigned int simpleApplication:1;
162 } aflags;
164 WMOpenPanel *sharedOpenPanel;
165 WMSavePanel *sharedSavePanel;
167 struct W_FontPanel *sharedFontPanel;
169 struct W_ColorPanel *sharedColorPanel;
171 Pixmap stipple;
173 struct W_View *dragSourceView;
174 struct W_DraggingInfo dragInfo;
176 /* colors */
177 W_Color *white;
178 W_Color *black;
179 W_Color *gray;
180 W_Color *darkGray;
182 GC stippleGC;
184 GC copyGC;
185 GC clipGC;
187 GC monoGC; /* GC for 1bpp visuals */
189 GC xorGC;
191 GC ixorGC; /* IncludeInferiors XOR */
193 GC drawStringGC; /* for WMDrawString() */
195 GC drawImStringGC; /* for WMDrawImageString() */
197 W_Font *normalFont;
199 W_Font *boldFont;
201 WMHashTable *fontCache;
203 WMHashTable *xftFontCache;
205 WMHashTable *fontSetCache;
207 WMHashTable *xftFontSetCache;
209 Bool useMultiByte;
211 Bool antialiasedText;
213 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
215 struct W_Balloon *balloon;
218 struct W_Pixmap *checkButtonImageOn;
219 struct W_Pixmap *checkButtonImageOff;
221 struct W_Pixmap *radioButtonImageOn;
222 struct W_Pixmap *radioButtonImageOff;
224 struct W_Pixmap *buttonArrow;
225 struct W_Pixmap *pushedButtonArrow;
227 struct W_Pixmap *scrollerDimple;
229 struct W_Pixmap *upArrow;
230 struct W_Pixmap *downArrow;
231 struct W_Pixmap *leftArrow;
232 struct W_Pixmap *rightArrow;
234 struct W_Pixmap *hiUpArrow;
235 struct W_Pixmap *hiDownArrow;
236 struct W_Pixmap *hiLeftArrow;
237 struct W_Pixmap *hiRightArrow;
239 struct W_Pixmap *pullDownIndicator;
240 struct W_Pixmap *popUpIndicator;
242 struct W_Pixmap *checkMark;
244 struct W_Pixmap *homeIcon;
245 struct W_Pixmap *altHomeIcon;
247 struct W_Pixmap *trashcanIcon;
248 struct W_Pixmap *altTrashcanIcon;
250 struct W_Pixmap *createDirIcon;
251 struct W_Pixmap *altCreateDirIcon;
253 struct W_Pixmap *disketteIcon;
254 struct W_Pixmap *altDisketteIcon;
255 struct W_Pixmap *unmountIcon;
256 struct W_Pixmap *altUnmountIcon;
258 struct W_Pixmap *magnifyIcon;
259 /* struct W_Pixmap *altMagnifyIcon;*/
260 struct W_Pixmap *wheelIcon;
261 struct W_Pixmap *grayIcon;
262 struct W_Pixmap *rgbIcon;
263 struct W_Pixmap *cmykIcon;
264 struct W_Pixmap *hsbIcon;
265 struct W_Pixmap *customPaletteIcon;
266 struct W_Pixmap *colorListIcon;
268 struct W_Pixmap *defaultObjectIcon;
270 Cursor defaultCursor;
272 Cursor textCursor;
274 Cursor invisibleCursor;
276 Atom attribsAtom; /* GNUstepWindowAttributes */
278 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
280 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
282 Atom clipboardAtom; /* CLIPBOARD */
284 Atom xdndAwareAtom; /* XdndAware */
285 Atom xdndSelectionAtom;
286 Atom xdndEnterAtom;
287 Atom xdndLeaveAtom;
288 Atom xdndPositionAtom;
289 Atom xdndDropAtom;
290 Atom xdndFinishedAtom;
291 Atom xdndTypeListAtom;
292 Atom xdndStatusAtom;
294 Atom xdndActionCopy;
295 Atom xdndActionMove;
296 Atom xdndActionLink;
297 Atom xdndActionAsk;
298 Atom xdndActionPrivate;
300 Atom wmIconDragOffsetAtom;
302 Atom wmStateAtom; /* WM_STATE */
304 /* stuff for detecting double-clicks */
305 Time lastClickTime; /* time of last mousedown event */
306 Window lastClickWindow; /* window of the last mousedown */
308 struct W_View *modalView;
309 unsigned modalLoop:1;
310 unsigned ignoreNextDoubleClick:1;
311 } W_Screen;
315 typedef struct W_ViewDelegate {
316 void *data;
318 void (*didMove)(struct W_ViewDelegate*, WMView*);
320 void (*didResize)(struct W_ViewDelegate*, WMView*);
322 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
324 void (*willResize)(struct W_ViewDelegate*, WMView*,
325 unsigned int*, unsigned int*);
326 } W_ViewDelegate;
330 typedef struct W_View {
331 struct W_Screen *screen;
333 WMWidget *self; /* must point to the widget the
334 * view belongs to */
336 W_ViewDelegate *delegate;
338 Window window;
340 WMSize size;
342 short topOffs;
343 short leftOffs;
344 short bottomOffs;
345 short rightOffs;
347 WMPoint pos;
349 struct W_View *nextFocusChain; /* next/prev in focus chain */
350 struct W_View *prevFocusChain;
352 struct W_View *nextResponder; /* next to receive keyboard events */
354 struct W_View *parent; /* parent WMView */
356 struct W_View *childrenList; /* first in list of child windows */
358 struct W_View *nextSister; /* next on parent's children list */
360 WMArray *eventHandlers; /* event handlers for this window */
362 unsigned long attribFlags;
363 XSetWindowAttributes attribs;
365 void *hangedData; /* data holder for user program */
367 WMColor *backColor;
369 Cursor cursor;
371 Atom *droppableTypes;
372 struct W_DragSourceProcs *dragSourceProcs;
373 struct W_DragDestinationProcs *dragDestinationProcs;
374 int helpContext;
377 struct {
378 unsigned int realized:1;
379 unsigned int mapped:1;
380 unsigned int parentDying:1;
381 unsigned int dying:1; /* the view is being destroyed */
382 unsigned int topLevel:1; /* is a top level window */
383 unsigned int root:1; /* is the root window */
384 unsigned int mapWhenRealized:1;/* map the view when it's realized */
385 unsigned int alreadyDead:1; /* view was freed */
387 unsigned int dontCompressMotion:1; /* motion notify event compress */
388 unsigned int notifySizeChanged:1;
389 unsigned int dontCompressExpose:1; /* will compress all expose
390 events into one */
391 /* toplevel only */
392 unsigned int worksWhenModal:1;
393 unsigned int pendingRelease1:1;
394 unsigned int pendingRelease2:1;
395 unsigned int pendingRelease3:1;
396 unsigned int pendingRelease4:1;
397 unsigned int pendingRelease5:1;
398 unsigned int xdndHintSet:1;
399 } flags;
401 int refCount;
402 } W_View;
405 typedef struct W_EventHandler {
406 unsigned long eventMask;
408 WMEventProc *proc;
410 void *clientData;
411 } W_EventHandler;
416 typedef struct _WINGsConfiguration {
417 char *systemFont;
418 char *boldSystemFont;
419 char *antialiasedSystemFont;
420 char *antialiasedBoldSystemFont;
421 int defaultFontSize;
422 Bool antialiasedText;
423 Bool useMultiByte;
424 char *floppyPath;
425 unsigned doubleClickDelay;
426 unsigned mouseWheelUp;
427 unsigned mouseWheelDown;
428 } _WINGsConfiguration;
430 extern _WINGsConfiguration WINGsConfiguration;
434 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
437 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
438 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
440 #define W_VIEW_REALIZED(view) (view)->flags.realized
441 #define W_VIEW_MAPPED(view) (view)->flags.mapped
443 #define W_VIEW_DISPLAY(view) (view)->screen->display
444 #define W_VIEW_SCREEN(view) (view)->screen
445 #define W_VIEW_DRAWABLE(view) (view)->window
447 #define W_VIEW_WIDTH(view) (view)->size.width
448 #define W_VIEW_HEIGHT(view) (view)->size.height
451 #define W_PIXEL(c) (c)->color.pixel
453 #define W_FONTID(f) (f)->font->fid
455 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
459 W_View *W_GetViewForXWindow(Display *display, Window window);
461 W_View *W_CreateView(W_View *parent);
463 W_View *W_CreateTopView(W_Screen *screen);
465 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
468 W_View *W_CreateRootView(W_Screen *screen);
470 void W_DestroyView(W_View *view);
472 void W_RealizeView(W_View *view);
474 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
476 void W_RaiseView(W_View *view);
478 void W_LowerView(W_View *view);
481 void W_MapView(W_View *view);
483 void W_MapSubviews(W_View *view);
485 void W_UnmapSubviews(W_View *view);
487 W_View *W_TopLevelOfView(W_View *view);
489 void W_UnmapView(W_View *view);
491 void W_MoveView(W_View *view, int x, int y);
493 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
495 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
497 void W_SetViewCursor(W_View *view, Cursor cursor);
499 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
500 unsigned int height, WMReliefType relief);
502 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
503 unsigned int width, unsigned int height,
504 WMReliefType relief,
505 GC black, GC dark, GC light, GC white);
507 void W_CallDestroyHandlers(W_View *view);
509 void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
510 W_Font *font, WMReliefType relief, char *text,
511 WMAlignment alignment, W_Pixmap *image,
512 WMImagePosition position, WMColor *backColor, int ofs);
514 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
515 int width, WMAlignment alignment, WMColor *color,
516 int wrap, char *text, int length);
518 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
521 int W_TextWidth(WMFont *font, char *text, int length);
524 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
526 void W_DispatchMessage(W_View *target, XEvent *event);
528 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
530 W_View *W_FocusedViewOfToplevel(W_View *view);
532 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
534 void W_ReleaseView(WMView *view);
536 WMView *W_RetainView(WMView *view);
538 void W_InitApplication(WMScreen *scr);
540 void W_InitNotificationCenter(void);
542 W_Class W_RegisterUserWidget(void);
544 void W_RedisplayView(WMView *view);
546 Bool W_ApplicationInitialized(void);
548 void W_HandleSelectionEvent(XEvent *event);
550 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
552 void W_FlushASAPNotificationQueue(void);
554 void W_FlushIdleNotificationQueue(void);
556 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
558 void W_BalloonHandleEnterView(WMView *view);
560 void W_BalloonHandleLeaveView(WMView *view);
562 Bool W_CheckIdleHandlers(void);
564 void W_CheckTimerHandlers(void);
566 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
568 #ifdef __cplusplus
570 #endif /* __cplusplus */
572 #endif /* _WINGSP_H_ */