- made deiconification not automatically focus window in sloppy focus
[wmaker-crm.git] / WINGs / WINGsP.h
blob3ce51abcda13468268ede7e37982cc676a6f1c82
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 Pixmap stipple;
140 /* colors */
141 W_Color *white;
142 W_Color *black;
143 W_Color *gray;
144 W_Color *darkGray;
146 GC stippleGC;
148 GC copyGC;
149 GC clipGC;
151 GC monoGC; /* GC for 1bpp visuals */
153 GC xorGC;
155 GC ixorGC; /* IncludeInferiors XOR */
157 GC textFieldGC;
159 W_Font *normalFont;
161 W_Font *boldFont;
163 WMHashTable *fontCache;
166 struct W_Balloon *balloon;
169 struct W_Pixmap *checkButtonImageOn;
170 struct W_Pixmap *checkButtonImageOff;
172 struct W_Pixmap *radioButtonImageOn;
173 struct W_Pixmap *radioButtonImageOff;
175 struct W_Pixmap *buttonArrow;
176 struct W_Pixmap *pushedButtonArrow;
178 struct W_Pixmap *scrollerDimple;
180 struct W_Pixmap *upArrow;
181 struct W_Pixmap *downArrow;
182 struct W_Pixmap *leftArrow;
183 struct W_Pixmap *rightArrow;
185 struct W_Pixmap *hiUpArrow;
186 struct W_Pixmap *hiDownArrow;
187 struct W_Pixmap *hiLeftArrow;
188 struct W_Pixmap *hiRightArrow;
190 struct W_Pixmap *pullDownIndicator;
191 struct W_Pixmap *popUpIndicator;
193 struct W_Pixmap *checkMark;
195 struct W_Pixmap *homeIcon;
196 struct W_Pixmap *altHomeIcon;
198 struct W_Pixmap *magnifyIcon;
199 struct W_Pixmap *altMagnifyIcon;
200 struct W_Pixmap *wheelIcon;
201 struct W_Pixmap *grayIcon;
202 struct W_Pixmap *rgbIcon;
203 struct W_Pixmap *cmykIcon;
204 struct W_Pixmap *hsbIcon;
205 struct W_Pixmap *customPaletteIcon;
206 struct W_Pixmap *colorListIcon;
208 struct W_Pixmap *defaultObjectIcon;
210 Cursor defaultCursor;
212 Cursor textCursor;
214 Atom internalMessage; /* for ClientMessage */
216 Atom attribsAtom; /* GNUstepWindowAttributes */
218 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
220 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
222 Atom clipboardAtom; /* CLIPBOARD */
225 /* stuff for detecting double-clicks */
226 Time lastClickTime; /* time of last mousedown event */
227 Window lastClickWindow; /* window of the last mousedown */
229 struct W_View *modalView;
230 unsigned modal:1;
231 unsigned ignoreNextDoubleClick:1;
232 } W_Screen;
236 typedef struct W_View {
237 struct W_Screen *screen;
239 WMWidget *self; /* must point to the widget the
240 * view belongs to */
242 Window window;
244 WMSize size;
246 WMPoint pos;
248 struct W_View *nextFocusChain; /* next/prev in focus chain */
249 struct W_View *prevFocusChain;
251 struct W_View *parent; /* parent WMView */
253 struct W_View *childrenList; /* first in list of child windows */
255 struct W_View *nextSister; /* next on parent's children list */
257 struct W_EventHandler *handlerList;/* list of event handlers for this window */
259 unsigned long attribFlags;
260 XSetWindowAttributes attribs;
262 void *hangedData; /* data holder for user program */
263 #if 0
264 struct W_DragSourceProcs *dragSourceProcs;
265 struct W_DragDestinationProcs *dragDestinationProcs;
266 int helpContext;
267 #endif
269 struct {
270 unsigned int realized:1;
271 unsigned int mapped:1;
272 unsigned int parentDying:1;
273 unsigned int dying:1; /* the view is being destroyed */
274 unsigned int topLevel:1; /* is a top level window */
275 unsigned int root:1; /* is the root window */
276 unsigned int mapWhenRealized:1;/* map the view when it's realized */
277 unsigned int alreadyDead:1; /* view was freed */
279 unsigned int dontCompressMotion:1; /* motion notify event compress */
280 unsigned int notifySizeChanged:1;
281 unsigned int dontCompressExpose:1; /* will compress all expose
282 events into one */
283 /* toplevel only */
284 unsigned int worksWhenModal:1;
285 unsigned int pendingRelease1:1;
286 unsigned int pendingRelease2:1;
287 unsigned int pendingRelease3:1;
288 unsigned int pendingRelease4:1;
289 unsigned int pendingRelease5:1;
290 } flags;
292 int refCount;
293 } W_View;
296 typedef struct W_EventHandler {
297 unsigned long eventMask;
299 WMEventProc *proc;
301 void *clientData;
303 struct W_EventHandler *nextHandler;
304 } W_EventHandler;
308 typedef struct W_ViewProcedureTable {
309 void (*setBackgroundColor)(WMWidget*, WMColor *color);
310 void (*resize)(WMWidget*, unsigned int, unsigned int);
311 void (*move)(WMWidget*, int, int);
312 } W_ViewProcedureTable;
316 typedef struct _WINGsConfiguration {
317 char *systemFont;
318 char *boldSystemFont;
319 unsigned doubleClickDelay;
320 } _WINGsConfiguration;
322 _WINGsConfiguration WINGsConfiguration;
326 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
329 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
330 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
332 #define W_VIEW_REALIZED(view) (view)->flags.realized
333 #define W_VIEW_MAPPED(view) (view)->flags.mapped
335 #define W_PIXEL(c) (c)->color.pixel
337 #define W_FONTID(f) (f)->font->fid
339 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
343 W_View *W_GetViewForXWindow(Display *display, Window window);
345 W_View *W_CreateView(W_View *parent);
347 W_View *W_CreateTopView(W_Screen *screen);
350 W_View *W_CreateRootView(W_Screen *screen);
352 void W_DestroyView(W_View *view);
354 void W_RealizeView(W_View *view);
356 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
358 void W_MapView(W_View *view);
360 void W_MapSubviews(W_View *view);
362 void W_UnmapSubviews(W_View *view);
364 W_View *W_TopLevelOfView(W_View *view);
366 void W_UnmapView(W_View *view);
368 void W_MoveView(W_View *view, int x, int y);
370 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
372 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
374 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
375 unsigned int height, WMReliefType relief);
378 void W_CleanUpEvents(W_View *view);
380 void W_CallDestroyHandlers(W_View *view);
382 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
383 WMReliefType relief, char *text,
384 WMAlignment alignment, W_Pixmap *image,
385 WMImagePosition position, GC backGC, int ofs);
387 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
388 int width, WMAlignment alignment, GC gc,
389 int wrap, char *text, int length);
391 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
394 int W_TextWidth(WMFont *font, char *text, int length);
397 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
399 void W_DispatchMessage(W_View *target, XEvent *event);
401 Bool W_CheckInternalMessage(W_Screen *scr, XClientMessageEvent *cev, int event);
403 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
405 W_View *W_FocusedViewOfToplevel(W_View *view);
407 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
409 void W_ReleaseView(WMView *view);
411 WMView *W_RetainView(WMView *view);
413 void W_InitApplication(WMScreen *scr);
415 void W_InitNotificationCenter(void);
417 W_Class W_RegisterUserWidget(W_ViewProcedureTable *procTable);
419 void W_RedisplayView(WMView *view);
421 Bool W_ApplicationInitialized(void);
423 char *W_GetTextSelection(WMScreen *scr, Atom selection);
425 void W_HandleSelectionEvent(XEvent *event);
427 #ifdef __cplusplus
429 #endif /* __cplusplus */
431 #endif /* _WINGSP_H_ */
433 void W_FlushASAPNotificationQueue();
435 void W_FlushIdleNotificationQueue();
437 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
439 void W_BalloonHandleEnterView(WMView *view);
441 void W_BalloonHandleLeaveView(WMView *view);