wide char support
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
blob69f4ccd76a9ff6cb5a8ccefdf573110f7d1a75c2
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 #ifdef XFT
52 struct _XftFont *font;
53 #else
54 // pick one
55 //XFontSet font;
56 XFontStruct *font;
57 #endif
59 short height;
60 short y;
61 short refCount;
62 char *name;
63 //unsigned int notFontSet:1;
64 //unsigned int antialiased:1;
65 } W_Font;
68 typedef struct W_Pixmap {
69 struct W_Screen *screen;
70 Pixmap pixmap;
71 Pixmap mask;
72 unsigned short width;
73 unsigned short height;
74 short depth;
75 short refCount;
76 } W_Pixmap;
79 typedef struct W_Color {
80 struct W_Screen *screen;
82 XColor color;
83 unsigned short alpha;
84 short refCount;
85 GC gc;
86 struct {
87 unsigned int exact:1;
88 } flags;
89 } W_Color;
92 typedef struct W_FocusInfo {
93 struct W_View *toplevel;
94 struct W_View *focused; /* view that has the focus in this toplevel */
95 struct W_FocusInfo *next;
96 } W_FocusInfo;
100 struct W_DraggingInfo {
101 Window destinationWindow;
102 Window sourceWindow;
104 WMPoint location;
106 unsigned sourceOperation;
107 WMPixmap *image;
108 WMPoint imageLocation;
110 char **types;
112 Time timestamp;
114 int protocolVersion;
116 /* should be treated as internal data */
117 WMView *sourceView;
118 WMView *destView;
119 WMSize mouseOffset;
120 unsigned finished:1;
124 typedef struct W_Screen {
125 Display *display;
126 int screen;
127 int depth;
129 Colormap colormap;
131 Visual *visual;
133 Time lastEventTime;
135 Window rootWin;
137 struct W_View *rootView;
139 RContext *rcontext;
141 struct W_IMContext *imctx;
143 struct _XftDraw *xftdraw; /* shared XftDraw */
145 /* application related */
147 W_FocusInfo *focusInfo;
149 RImage *applicationIconImage; /* image (can have alpha channel) */
150 struct W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
151 Window applicationIconWindow;
153 struct W_Window *windowList; /* list of windows in the app */
155 Window groupLeader; /* the leader of the application */
156 /* also used for other things */
158 struct W_SelectionHandlers *selectionHandlerList;
160 struct {
161 unsigned int hasAppIcon:1;
162 unsigned int simpleApplication:1;
163 } aflags;
165 WMOpenPanel *sharedOpenPanel;
166 WMSavePanel *sharedSavePanel;
168 struct W_FontPanel *sharedFontPanel;
170 struct W_ColorPanel *sharedColorPanel;
172 Pixmap stipple;
174 struct W_View *dragSourceView;
175 struct W_DraggingInfo dragInfo;
177 /* colors */
178 W_Color *white;
179 W_Color *black;
180 W_Color *gray;
181 W_Color *darkGray;
183 GC stippleGC;
185 GC copyGC;
186 GC clipGC;
188 GC monoGC; /* GC for 1bpp visuals */
190 GC xorGC;
192 GC ixorGC; /* IncludeInferiors XOR */
194 GC drawStringGC; /* for WMDrawString() */
196 GC drawImStringGC; /* for WMDrawImageString() */
198 W_Font *normalFont;
200 W_Font *boldFont;
202 WMHashTable *fontCache;
204 Bool useMultiByte;
206 Bool antialiasedText;
208 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
210 struct W_Balloon *balloon;
213 struct W_Pixmap *checkButtonImageOn;
214 struct W_Pixmap *checkButtonImageOff;
216 struct W_Pixmap *radioButtonImageOn;
217 struct W_Pixmap *radioButtonImageOff;
219 struct W_Pixmap *buttonArrow;
220 struct W_Pixmap *pushedButtonArrow;
222 struct W_Pixmap *scrollerDimple;
224 struct W_Pixmap *upArrow;
225 struct W_Pixmap *downArrow;
226 struct W_Pixmap *leftArrow;
227 struct W_Pixmap *rightArrow;
229 struct W_Pixmap *hiUpArrow;
230 struct W_Pixmap *hiDownArrow;
231 struct W_Pixmap *hiLeftArrow;
232 struct W_Pixmap *hiRightArrow;
234 struct W_Pixmap *pullDownIndicator;
235 struct W_Pixmap *popUpIndicator;
237 struct W_Pixmap *checkMark;
239 struct W_Pixmap *homeIcon;
240 struct W_Pixmap *altHomeIcon;
242 struct W_Pixmap *trashcanIcon;
243 struct W_Pixmap *altTrashcanIcon;
245 struct W_Pixmap *createDirIcon;
246 struct W_Pixmap *altCreateDirIcon;
248 struct W_Pixmap *disketteIcon;
249 struct W_Pixmap *altDisketteIcon;
250 struct W_Pixmap *unmountIcon;
251 struct W_Pixmap *altUnmountIcon;
253 struct W_Pixmap *magnifyIcon;
254 /* struct W_Pixmap *altMagnifyIcon;*/
255 struct W_Pixmap *wheelIcon;
256 struct W_Pixmap *grayIcon;
257 struct W_Pixmap *rgbIcon;
258 struct W_Pixmap *cmykIcon;
259 struct W_Pixmap *hsbIcon;
260 struct W_Pixmap *customPaletteIcon;
261 struct W_Pixmap *colorListIcon;
263 struct W_Pixmap *defaultObjectIcon;
265 Cursor defaultCursor;
267 Cursor textCursor;
269 Cursor invisibleCursor;
271 Atom attribsAtom; /* GNUstepWindowAttributes */
273 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
275 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
277 Atom clipboardAtom; /* CLIPBOARD */
279 Atom xdndAwareAtom; /* XdndAware */
280 Atom xdndSelectionAtom;
281 Atom xdndEnterAtom;
282 Atom xdndLeaveAtom;
283 Atom xdndPositionAtom;
284 Atom xdndDropAtom;
285 Atom xdndFinishedAtom;
286 Atom xdndTypeListAtom;
287 Atom xdndStatusAtom;
289 Atom xdndActionCopy;
290 Atom xdndActionMove;
291 Atom xdndActionLink;
292 Atom xdndActionAsk;
293 Atom xdndActionPrivate;
295 Atom wmIconDragOffsetAtom;
297 Atom wmStateAtom; /* WM_STATE */
299 /* stuff for detecting double-clicks */
300 Time lastClickTime; /* time of last mousedown event */
301 Window lastClickWindow; /* window of the last mousedown */
303 struct W_View *modalView;
304 unsigned modalLoop:1;
305 unsigned ignoreNextDoubleClick:1;
306 } W_Screen;
310 typedef struct W_ViewDelegate {
311 void *data;
313 void (*didMove)(struct W_ViewDelegate*, WMView*);
315 void (*didResize)(struct W_ViewDelegate*, WMView*);
317 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
319 void (*willResize)(struct W_ViewDelegate*, WMView*,
320 unsigned int*, unsigned int*);
321 } W_ViewDelegate;
325 typedef struct W_View {
326 struct W_Screen *screen;
328 WMWidget *self; /* must point to the widget the
329 * view belongs to */
331 W_ViewDelegate *delegate;
333 Window window;
335 WMSize size;
337 short topOffs;
338 short leftOffs;
339 short bottomOffs;
340 short rightOffs;
342 WMPoint pos;
344 struct W_View *nextFocusChain; /* next/prev in focus chain */
345 struct W_View *prevFocusChain;
347 struct W_View *nextResponder; /* next to receive keyboard events */
349 struct W_View *parent; /* parent WMView */
351 struct W_View *childrenList; /* first in list of child windows */
353 struct W_View *nextSister; /* next on parent's children list */
355 WMArray *eventHandlers; /* event handlers for this window */
357 unsigned long attribFlags;
358 XSetWindowAttributes attribs;
360 void *hangedData; /* data holder for user program */
362 WMColor *backColor;
364 Cursor cursor;
366 Atom *droppableTypes;
367 struct W_DragSourceProcs *dragSourceProcs;
368 struct W_DragDestinationProcs *dragDestinationProcs;
369 int helpContext;
372 struct {
373 unsigned int realized:1;
374 unsigned int mapped:1;
375 unsigned int parentDying:1;
376 unsigned int dying:1; /* the view is being destroyed */
377 unsigned int topLevel:1; /* is a top level window */
378 unsigned int root:1; /* is the root window */
379 unsigned int mapWhenRealized:1;/* map the view when it's realized */
380 unsigned int alreadyDead:1; /* view was freed */
382 unsigned int dontCompressMotion:1; /* motion notify event compress */
383 unsigned int notifySizeChanged:1;
384 unsigned int dontCompressExpose:1; /* will compress all expose
385 events into one */
386 /* toplevel only */
387 unsigned int worksWhenModal:1;
388 unsigned int pendingRelease1:1;
389 unsigned int pendingRelease2:1;
390 unsigned int pendingRelease3:1;
391 unsigned int pendingRelease4:1;
392 unsigned int pendingRelease5:1;
393 unsigned int xdndHintSet:1;
394 } flags;
396 int refCount;
397 } W_View;
400 typedef struct W_EventHandler {
401 unsigned long eventMask;
403 WMEventProc *proc;
405 void *clientData;
406 } W_EventHandler;
411 typedef struct _WINGsConfiguration {
412 char *systemFont;
413 char *boldSystemFont;
414 int defaultFontSize;
415 Bool antialiasedText;
416 Bool useMultiByte;
417 char *floppyPath;
418 unsigned doubleClickDelay;
419 unsigned mouseWheelUp;
420 unsigned mouseWheelDown;
421 } _WINGsConfiguration;
423 extern _WINGsConfiguration WINGsConfiguration;
427 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
430 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
431 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
433 #define W_VIEW_REALIZED(view) (view)->flags.realized
434 #define W_VIEW_MAPPED(view) (view)->flags.mapped
436 #define W_VIEW_DISPLAY(view) (view)->screen->display
437 #define W_VIEW_SCREEN(view) (view)->screen
438 #define W_VIEW_DRAWABLE(view) (view)->window
440 #define W_VIEW_WIDTH(view) (view)->size.width
441 #define W_VIEW_HEIGHT(view) (view)->size.height
444 #define W_PIXEL(c) (c)->color.pixel
446 #define W_FONTID(f) (f)->font->fid
448 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
452 W_View *W_GetViewForXWindow(Display *display, Window window);
454 W_View *W_CreateView(W_View *parent);
456 W_View *W_CreateTopView(W_Screen *screen);
458 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
461 W_View *W_CreateRootView(W_Screen *screen);
463 void W_DestroyView(W_View *view);
465 void W_RealizeView(W_View *view);
467 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
469 void W_RaiseView(W_View *view);
471 void W_LowerView(W_View *view);
474 void W_MapView(W_View *view);
476 void W_MapSubviews(W_View *view);
478 void W_UnmapSubviews(W_View *view);
480 W_View *W_TopLevelOfView(W_View *view);
482 void W_UnmapView(W_View *view);
484 void W_MoveView(W_View *view, int x, int y);
486 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
488 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
490 void W_SetViewCursor(W_View *view, Cursor cursor);
492 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
493 unsigned int height, WMReliefType relief);
495 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
496 unsigned int width, unsigned int height,
497 WMReliefType relief,
498 GC black, GC dark, GC light, GC white);
500 void W_CallDestroyHandlers(W_View *view);
502 void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
503 W_Font *font, WMReliefType relief, char *text,
504 WMAlignment alignment, W_Pixmap *image,
505 WMImagePosition position, WMColor *backColor, int ofs);
507 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
508 int width, WMAlignment alignment, WMColor *color,
509 int wrap, char *text, int length);
511 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
514 int W_TextWidth(WMFont *font, char *text, int length);
517 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
519 void W_DispatchMessage(W_View *target, XEvent *event);
521 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
523 W_View *W_FocusedViewOfToplevel(W_View *view);
525 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
527 void W_ReleaseView(WMView *view);
529 WMView *W_RetainView(WMView *view);
531 void W_InitApplication(WMScreen *scr);
533 void W_InitNotificationCenter(void);
535 W_Class W_RegisterUserWidget(void);
537 void W_RedisplayView(WMView *view);
539 Bool W_ApplicationInitialized(void);
541 void W_HandleSelectionEvent(XEvent *event);
543 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
545 void W_FlushASAPNotificationQueue(void);
547 void W_FlushIdleNotificationQueue(void);
549 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
551 void W_BalloonHandleEnterView(WMView *view);
553 void W_BalloonHandleLeaveView(WMView *view);
555 Bool W_CheckIdleHandlers(void);
557 void W_CheckTimerHandlers(void);
559 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
561 #ifdef __cplusplus
563 #endif /* __cplusplus */
565 #endif /* _WINGSP_H_ */