fixed many bugs, removed linked list
[wmaker-crm.git] / WINGs / WINGsP.h
blob205aca9b4ed4486878bbf7edd9018deeb0f9bedf
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 < 990516
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
35 /* internal messages */
36 #define WM_UPDATE_COLORWELL 130
39 #define WM_USER_MESSAGE 1024
42 #define SETUP_INTERNAL_MESSAGE(event, scrPtr) \
43 event.xclient.type=ClientMessage;\
44 event.xclient.display=scrPtr->display;\
45 event.xclient.send_event=False;\
46 event.xclient.serial=0;\
47 event.xclient.format=32;\
48 event.xclient.message_type=scrPtr->internalMessage;
51 typedef struct W_Application {
52 char *applicationName;
53 int argc;
54 char **argv;
55 char *resourcePath;
56 } W_Application;
59 typedef struct W_Font {
60 struct W_Screen *screen;
62 union {
63 XFontSet set;
64 XFontStruct *normal;
65 } font;
66 short height;
67 short y;
68 short refCount;
69 char *name;
70 unsigned int notFontSet:1;
71 } W_Font;
74 typedef struct W_Pixmap {
75 struct W_Screen *screen;
76 Pixmap pixmap;
77 Pixmap mask;
78 unsigned short width;
79 unsigned short height;
80 short depth;
81 short refCount;
82 } W_Pixmap;
85 typedef struct W_Color {
86 struct W_Screen *screen;
88 XColor color;
89 short refCount;
90 GC gc;
91 struct {
92 unsigned int exact:1;
93 } flags;
94 } W_Color;
97 typedef struct W_FocusInfo {
98 struct W_View *toplevel;
99 struct W_View *focused; /* view that has the focus in this toplevel */
100 struct W_FocusInfo *next;
101 } W_FocusInfo;
104 typedef struct W_Screen {
105 Display *display;
106 int screen;
107 int depth;
109 Colormap colormap;
111 Visual *visual;
113 Time lastEventTime;
115 Window rootWin;
117 struct W_View *rootView;
119 RContext *rcontext;
121 /* application related */
123 W_FocusInfo *focusInfo;
125 struct W_Pixmap *applicationIcon;
127 struct W_Window *windowList; /* list of windows in the app */
129 Window groupLeader; /* the leader of the application */
130 /* also used for other things */
132 struct W_SelectionHandlers *selectionHandlerList;
134 struct {
135 unsigned int hasAppIcon:1;
136 unsigned int simpleApplication:1;
137 } aflags;
139 WMOpenPanel *sharedOpenPanel;
140 WMSavePanel *sharedSavePanel;
142 struct W_FontPanel *sharedFontPanel;
144 struct W_ColorPanel *sharedColorPanel;
146 Pixmap stipple;
148 /* colors */
149 W_Color *white;
150 W_Color *black;
151 W_Color *gray;
152 W_Color *darkGray;
154 GC stippleGC;
156 GC copyGC;
157 GC clipGC;
159 GC monoGC; /* GC for 1bpp visuals */
161 GC xorGC;
163 GC ixorGC; /* IncludeInferiors XOR */
165 GC textFieldGC;
167 W_Font *normalFont;
169 W_Font *boldFont;
171 WMHashTable *fontCache;
173 Bool useMultiByte;
175 struct W_Balloon *balloon;
178 struct W_Pixmap *checkButtonImageOn;
179 struct W_Pixmap *checkButtonImageOff;
181 struct W_Pixmap *radioButtonImageOn;
182 struct W_Pixmap *radioButtonImageOff;
184 struct W_Pixmap *buttonArrow;
185 struct W_Pixmap *pushedButtonArrow;
187 struct W_Pixmap *scrollerDimple;
189 struct W_Pixmap *upArrow;
190 struct W_Pixmap *downArrow;
191 struct W_Pixmap *leftArrow;
192 struct W_Pixmap *rightArrow;
194 struct W_Pixmap *hiUpArrow;
195 struct W_Pixmap *hiDownArrow;
196 struct W_Pixmap *hiLeftArrow;
197 struct W_Pixmap *hiRightArrow;
199 struct W_Pixmap *pullDownIndicator;
200 struct W_Pixmap *popUpIndicator;
202 struct W_Pixmap *checkMark;
204 struct W_Pixmap *homeIcon;
205 struct W_Pixmap *altHomeIcon;
207 struct W_Pixmap *trashcanIcon;
208 struct W_Pixmap *altTrashcanIcon;
210 struct W_Pixmap *createDirIcon;
211 struct W_Pixmap *altCreateDirIcon;
213 struct W_Pixmap *disketteIcon;
214 struct W_Pixmap *altDisketteIcon;
215 struct W_Pixmap *unmountIcon;
216 struct W_Pixmap *altUnmountIcon;
218 struct W_Pixmap *magnifyIcon;
219 /* struct W_Pixmap *altMagnifyIcon;*/
220 struct W_Pixmap *wheelIcon;
221 struct W_Pixmap *grayIcon;
222 struct W_Pixmap *rgbIcon;
223 struct W_Pixmap *cmykIcon;
224 struct W_Pixmap *hsbIcon;
225 struct W_Pixmap *customPaletteIcon;
226 struct W_Pixmap *colorListIcon;
228 struct W_Pixmap *defaultObjectIcon;
230 Cursor defaultCursor;
232 Cursor textCursor;
234 Cursor invisibleCursor;
236 Atom internalMessage; /* for ClientMessage */
238 Atom attribsAtom; /* GNUstepWindowAttributes */
240 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
242 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
244 Atom clipboardAtom; /* CLIPBOARD */
247 /* stuff for detecting double-clicks */
248 Time lastClickTime; /* time of last mousedown event */
249 Window lastClickWindow; /* window of the last mousedown */
251 struct W_View *modalView;
252 unsigned modal:1;
253 unsigned ignoreNextDoubleClick:1;
254 } W_Screen;
258 typedef struct W_ViewDelegate {
259 void *data;
261 void (*didMove)(struct W_ViewDelegate*, WMView*);
263 void (*didResize)(struct W_ViewDelegate*, WMView*);
265 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
267 void (*willResize)(struct W_ViewDelegate*, WMView*,
268 unsigned int*, unsigned int*);
269 } W_ViewDelegate;
273 typedef struct W_View {
274 struct W_Screen *screen;
276 WMWidget *self; /* must point to the widget the
277 * view belongs to */
279 W_ViewDelegate *delegate;
281 Window window;
283 WMSize size;
285 WMPoint pos;
287 struct W_View *nextFocusChain; /* next/prev in focus chain */
288 struct W_View *prevFocusChain;
290 struct W_View *parent; /* parent WMView */
292 struct W_View *childrenList; /* first in list of child windows */
294 struct W_View *nextSister; /* next on parent's children list */
296 struct W_EventHandler *handlerList;/* list of event handlers for this window */
298 unsigned long attribFlags;
299 XSetWindowAttributes attribs;
301 void *hangedData; /* data holder for user program */
303 WMColor *backColor;
305 #if 0
306 struct W_DragSourceProcs *dragSourceProcs;
307 struct W_DragDestinationProcs *dragDestinationProcs;
308 int helpContext;
309 #endif
311 struct {
312 unsigned int realized:1;
313 unsigned int mapped:1;
314 unsigned int parentDying:1;
315 unsigned int dying:1; /* the view is being destroyed */
316 unsigned int topLevel:1; /* is a top level window */
317 unsigned int root:1; /* is the root window */
318 unsigned int mapWhenRealized:1;/* map the view when it's realized */
319 unsigned int alreadyDead:1; /* view was freed */
321 unsigned int dontCompressMotion:1; /* motion notify event compress */
322 unsigned int notifySizeChanged:1;
323 unsigned int dontCompressExpose:1; /* will compress all expose
324 events into one */
325 /* toplevel only */
326 unsigned int worksWhenModal:1;
327 unsigned int pendingRelease1:1;
328 unsigned int pendingRelease2:1;
329 unsigned int pendingRelease3:1;
330 unsigned int pendingRelease4:1;
331 unsigned int pendingRelease5:1;
332 } flags;
334 int refCount;
335 } W_View;
338 typedef struct W_EventHandler {
339 unsigned long eventMask;
341 WMEventProc *proc;
343 void *clientData;
345 struct W_EventHandler *nextHandler;
346 } W_EventHandler;
351 typedef struct _WINGsConfiguration {
352 char *systemFont;
353 char *boldSystemFont;
354 Bool useMultiByte;
355 unsigned doubleClickDelay;
356 } _WINGsConfiguration;
358 _WINGsConfiguration WINGsConfiguration;
362 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
365 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
366 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
368 #define W_VIEW_REALIZED(view) (view)->flags.realized
369 #define W_VIEW_MAPPED(view) (view)->flags.mapped
371 #define W_PIXEL(c) (c)->color.pixel
373 #define W_FONTID(f) (f)->font->fid
375 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
379 W_View *W_GetViewForXWindow(Display *display, Window window);
381 W_View *W_CreateView(W_View *parent);
383 W_View *W_CreateTopView(W_Screen *screen);
386 W_View *W_CreateRootView(W_Screen *screen);
388 void W_DestroyView(W_View *view);
390 void W_RealizeView(W_View *view);
392 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
394 void W_MapView(W_View *view);
396 void W_MapSubviews(W_View *view);
398 void W_UnmapSubviews(W_View *view);
400 W_View *W_TopLevelOfView(W_View *view);
402 void W_UnmapView(W_View *view);
404 void W_MoveView(W_View *view, int x, int y);
406 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
408 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
410 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
411 unsigned int height, WMReliefType relief);
414 void W_CleanUpEvents(W_View *view);
416 void W_CallDestroyHandlers(W_View *view);
418 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
419 WMReliefType relief, char *text,
420 WMAlignment alignment, W_Pixmap *image,
421 WMImagePosition position, GC backGC, int ofs);
423 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
424 int width, WMAlignment alignment, GC gc,
425 int wrap, char *text, int length);
427 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
430 int W_TextWidth(WMFont *font, char *text, int length);
433 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
435 void W_DispatchMessage(W_View *target, XEvent *event);
437 Bool W_CheckInternalMessage(W_Screen *scr, XClientMessageEvent *cev, int event);
439 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
441 W_View *W_FocusedViewOfToplevel(W_View *view);
443 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
445 void W_ReleaseView(WMView *view);
447 WMView *W_RetainView(WMView *view);
449 void W_InitApplication(WMScreen *scr);
451 void W_InitNotificationCenter(void);
453 W_Class W_RegisterUserWidget(void);
455 void W_RedisplayView(WMView *view);
457 Bool W_ApplicationInitialized(void);
459 char *W_GetTextSelection(WMScreen *scr, Atom selection);
461 void W_HandleSelectionEvent(XEvent *event);
463 #ifdef __cplusplus
465 #endif /* __cplusplus */
467 #endif /* _WINGSP_H_ */
469 void W_FlushASAPNotificationQueue();
471 void W_FlushIdleNotificationQueue();
473 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
475 void W_BalloonHandleEnterView(WMView *view);
477 void W_BalloonHandleLeaveView(WMView *view);