bug fixes, faq update, fix of wrong bug fix in actions.c etc
[wmaker-crm.git] / WINGs / WINGsP.h
blobee5619e05e8700831bed523e67cc9603601de1cb
1 #ifndef _WINGSP_H_
2 #define _WINGSP_H_
5 #include <X11/Xlib.h>
6 #include <X11/Xutil.h>
9 #include "WINGs.h"
10 #include "WUtil.h"
12 #if WINGS_H_VERSION < 990222
13 #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
14 #endif
16 #include <assert.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <stdio.h>
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
26 #define DOUBLE_BUFFER
30 #define WC_UserWidget 128
34 #define SCROLLER_WIDTH 20
36 /* internal messages */
37 #define WM_UPDATE_COLORWELL 130
40 #define WM_USER_MESSAGE 1024
43 #define SETUP_INTERNAL_MESSAGE(event, scrPtr) \
44 event.xclient.type=ClientMessage;\
45 event.xclient.display=scrPtr->display;\
46 event.xclient.send_event=False;\
47 event.xclient.serial=0;\
48 event.xclient.format=32;\
49 event.xclient.message_type=scrPtr->internalMessage;
52 typedef struct W_Font {
53 struct W_Screen *screen;
55 union {
56 XFontSet set;
57 XFontStruct *normal;
58 } font;
59 short height;
60 short y;
61 short refCount;
62 char *name;
63 unsigned int notFontSet:1;
64 } W_Font;
67 typedef struct W_Pixmap {
68 struct W_Screen *screen;
69 Pixmap pixmap;
70 Pixmap mask;
71 unsigned short width;
72 unsigned short height;
73 short depth;
74 short refCount;
75 } W_Pixmap;
78 typedef struct W_Color {
79 struct W_Screen *screen;
81 XColor color;
82 short refCount;
83 GC gc;
84 struct {
85 unsigned int exact:1;
86 } flags;
87 } W_Color;
90 typedef struct W_FocusInfo {
91 struct W_View *toplevel;
92 struct W_View *focused; /* view that has the focus in this toplevel */
93 struct W_FocusInfo *next;
94 } W_FocusInfo;
96 typedef struct W_Screen {
97 Display *display;
98 int screen;
99 int depth;
101 Colormap colormap;
103 Visual *visual;
105 Time lastEventTime;
107 Window rootWin;
109 struct W_View *rootView;
111 RContext *rcontext;
113 /* application related */
115 W_FocusInfo *focusInfo;
117 struct W_Pixmap *applicationIcon;
119 struct W_Window *windowList; /* list of windows in the app */
121 Window groupLeader; /* the leader of the application */
122 /* also used for other things */
124 struct W_SelectionHandlers *selectionHandlerList;
126 struct {
127 unsigned int hasAppIcon:1;
128 unsigned int simpleApplication:1;
129 } aflags;
131 WMOpenPanel *sharedOpenPanel;
132 WMSavePanel *sharedSavePanel;
134 struct W_FontPanel *sharedFontPanel;
136 struct W_ColorPanel *sharedColorPanel;
138 /* colors */
139 W_Color *white;
140 W_Color *black;
141 W_Color *gray;
142 W_Color *darkGray;
144 GC stippleGC;
146 GC copyGC;
147 GC clipGC;
149 GC monoGC; /* GC for 1bpp visuals */
151 GC xorGC;
153 GC ixorGC; /* IncludeInferiors XOR */
155 GC textFieldGC;
157 W_Font *normalFont;
159 W_Font *boldFont;
161 WMHashTable *fontCache;
164 struct W_Balloon *balloon;
167 struct W_Pixmap *checkButtonImageOn;
168 struct W_Pixmap *checkButtonImageOff;
170 struct W_Pixmap *radioButtonImageOn;
171 struct W_Pixmap *radioButtonImageOff;
173 struct W_Pixmap *buttonArrow;
174 struct W_Pixmap *pushedButtonArrow;
176 struct W_Pixmap *scrollerDimple;
178 struct W_Pixmap *upArrow;
179 struct W_Pixmap *downArrow;
180 struct W_Pixmap *leftArrow;
181 struct W_Pixmap *rightArrow;
183 struct W_Pixmap *hiUpArrow;
184 struct W_Pixmap *hiDownArrow;
185 struct W_Pixmap *hiLeftArrow;
186 struct W_Pixmap *hiRightArrow;
188 struct W_Pixmap *pullDownIndicator;
189 struct W_Pixmap *popUpIndicator;
191 struct W_Pixmap *checkMark;
193 struct W_Pixmap *homeIcon;
194 struct W_Pixmap *altHomeIcon;
196 struct W_Pixmap *magnifyIcon;
197 struct W_Pixmap *altMagnifyIcon;
198 struct W_Pixmap *wheelIcon;
199 struct W_Pixmap *grayIcon;
200 struct W_Pixmap *rgbIcon;
201 struct W_Pixmap *cmykIcon;
202 struct W_Pixmap *hsbIcon;
203 struct W_Pixmap *customPaletteIcon;
204 struct W_Pixmap *colorListIcon;
206 struct W_Pixmap *defaultObjectIcon;
208 Cursor defaultCursor;
210 Cursor textCursor;
212 Atom internalMessage; /* for ClientMessage */
214 Atom attribsAtom; /* GNUstepWindowAttributes */
216 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
218 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
220 Atom clipboardAtom; /* CLIPBOARD */
223 /* stuff for detecting double-clicks */
224 Time lastClickTime; /* time of last mousedown event */
225 Window lastClickWindow; /* window of the last mousedown */
227 struct W_View *modalView;
228 unsigned modal:1;
229 unsigned ignoreNextDoubleClick:1;
230 } W_Screen;
234 typedef struct W_View {
235 struct W_Screen *screen;
237 WMWidget *self; /* must point to the widget the
238 * view belongs to */
240 Window window;
242 WMSize size;
244 WMPoint pos;
246 struct W_View *nextFocusChain; /* next/prev in focus chain */
247 struct W_View *prevFocusChain;
249 struct W_View *parent; /* parent WMView */
251 struct W_View *childrenList; /* first in list of child windows */
253 struct W_View *nextSister; /* next on parent's children list */
255 struct W_EventHandler *handlerList;/* list of event handlers for this window */
257 unsigned long attribFlags;
258 XSetWindowAttributes attribs;
260 void *hangedData; /* data holder for user program */
261 #if 0
262 struct W_DragSourceProcs *dragSourceProcs;
263 struct W_DragDestinationProcs *dragDestinationProcs;
264 int helpContext;
265 #endif
267 struct {
268 unsigned int realized:1;
269 unsigned int mapped:1;
270 unsigned int parentDying:1;
271 unsigned int dying:1; /* the view is being destroyed */
272 unsigned int topLevel:1; /* is a top level window */
273 unsigned int root:1; /* is the root window */
274 unsigned int mapWhenRealized:1;/* map the view when it's realized */
275 unsigned int alreadyDead:1; /* view was freed */
277 unsigned int dontCompressMotion:1; /* motion notify event compress */
278 unsigned int notifySizeChanged:1;
279 unsigned int dontCompressExpose:1; /* will compress all expose
280 events into one */
281 /* toplevel only */
282 unsigned int worksWhenModal:1;
283 unsigned int pendingRelease1:1;
284 unsigned int pendingRelease2:1;
285 unsigned int pendingRelease3:1;
286 unsigned int pendingRelease4:1;
287 unsigned int pendingRelease5:1;
288 } flags;
290 int refCount;
291 } W_View;
294 typedef struct W_EventHandler {
295 unsigned long eventMask;
297 WMEventProc *proc;
299 void *clientData;
301 struct W_EventHandler *nextHandler;
302 } W_EventHandler;
306 typedef struct W_ViewProcedureTable {
307 void (*setBackgroundColor)(WMWidget*, WMColor *color);
308 void (*resize)(WMWidget*, unsigned int, unsigned int);
309 void (*move)(WMWidget*, int, int);
310 } W_ViewProcedureTable;
314 typedef struct _WINGsConfiguration {
315 char *systemFont;
316 char *boldSystemFont;
317 unsigned doubleClickDelay;
318 } _WINGsConfiguration;
320 _WINGsConfiguration WINGsConfiguration;
324 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
327 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
328 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
330 #define W_VIEW_REALIZED(view) (view)->flags.realized
331 #define W_VIEW_MAPPED(view) (view)->flags.mapped
333 #define W_PIXEL(c) (c)->color.pixel
335 #define W_FONTID(f) (f)->font->fid
337 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
341 W_View *W_GetViewForXWindow(Display *display, Window window);
343 W_View *W_CreateView(W_View *parent);
345 W_View *W_CreateTopView(W_Screen *screen);
348 W_View *W_CreateRootView(W_Screen *screen);
350 void W_DestroyView(W_View *view);
352 void W_RealizeView(W_View *view);
354 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
356 void W_MapView(W_View *view);
358 void W_MapSubviews(W_View *view);
360 void W_UnmapSubviews(W_View *view);
362 W_View *W_TopLevelOfView(W_View *view);
364 void W_UnmapView(W_View *view);
366 void W_MoveView(W_View *view, int x, int y);
368 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
370 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
372 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
373 unsigned int height, WMReliefType relief);
376 void W_CleanUpEvents(W_View *view);
378 void W_CallDestroyHandlers(W_View *view);
380 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
381 WMReliefType relief, char *text,
382 WMAlignment alignment, W_Pixmap *image,
383 WMImagePosition position, GC backGC, int ofs);
385 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
386 int width, WMAlignment alignment, GC gc,
387 int wrap, char *text, int length);
389 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
392 int W_TextWidth(WMFont *font, char *text, int length);
395 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
397 void W_DispatchMessage(W_View *target, XEvent *event);
399 Bool W_CheckInternalMessage(W_Screen *scr, XClientMessageEvent *cev, int event);
401 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
403 W_View *W_FocusedViewOfToplevel(W_View *view);
405 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
407 void W_ReleaseView(WMView *view);
409 WMView *W_RetainView(WMView *view);
411 void W_InitApplication(WMScreen *scr);
413 void W_InitNotificationCenter(void);
415 W_Class W_RegisterUserWidget(W_ViewProcedureTable *procTable);
417 void W_RedisplayView(WMView *view);
419 Bool W_ApplicationInitialized(void);
421 char *W_GetTextSelection(WMScreen *scr, Atom selection);
423 void W_HandleSelectionEvent(XEvent *event);
425 #ifdef __cplusplus
427 #endif /* __cplusplus */
429 #endif /* _WINGSP_H_ */
431 void W_FlushASAPNotificationQueue();
433 void W_FlushIdleNotificationQueue();